UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Solidify.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
7
9
10namespace UE
11{
12namespace Geometry
13{
14
15using namespace UE::Math;
16
21template<typename TriangleMeshType>
23{
24public:
25
30
34
35 const TriangleMeshType* Source = nullptr;
38
40 double WindingThreshold = .5;
41
43 bool bUseCustomBounds = false;
44
47
49 double ExtendBounds = 1;
50
52 bool bSolidAtBoundaries = true;
53
56
58 double MeshCellSize = 1.0;
59
68
70 TFunction<bool(void)> CancelF = []()
71 {
72 return false;
73 };
74
75protected:
76
78
79public:
80
84 bool Validate()
85 {
86 bool bValidMeshAndSpatial = Source != nullptr && SourceSpatial != nullptr && SourceSpatial->IsValid(false);
87 bool bValidWinding = SourceWinding != nullptr;
88 bool bValidParams = SurfaceSearchSteps >= 0 && MeshCellSize > 0 && FMath::IsFinite(MeshCellSize);
90 }
91
96 {
98 if (!ensure(Validate()))
99 {
100 // give up and return and empty result on invalid parameters
101 return MarchingCubes;
102 }
103
105 if (!bUseCustomBounds)
106 {
108 }
109
111
113 // expand marching cubes bounds beyond the 'internal' bounds to ensure we sample outside the bounds, if solid-at-boundaries is requested
115 {
117 }
118
123
125 {
126 MarchingCubes.Implicit = [this, UseBounds](const FVector3d& Pos)
127 {
128 return UseBounds.Contains(Pos) ? SourceWinding->FastWindingNumber(Pos) : -(WindingThreshold + 1);
129 };
130 }
131 else
132 {
133 MarchingCubes.Implicit = [this](const FVector3d& Pos)
134 {
135 return SourceWinding->FastWindingNumber(Pos);
136 };
137 }
138
140 for ( int32 VertIdx : Source->VertexIndicesItr() )
141 {
142 FVector3d Vertex = Source->GetVertex(VertIdx);
143 // Only add vertices that are inside the spatial bounds
144 // In the non-custom-bounds case, this will only filter out unreferenced vertices, so should not miss surfaces.
145 // However, in the case of custom bounds smaller than the mesh bounds, it may cause us to miss surfaces.
146 // TODO: consider adding additional sampling options to better support this case
148 {
149 MCSeeds.Add(Vertex);
150 }
151 }
153
154 return MarchingCubes;
155 }
156};
157
158
159
160
161
162
163
168{
169public:
170
180
182 {
183 }
184
188
190 TUniqueFunction<double(const FVector3d&)> WindingFunction = [](const FVector3d& Pos) { return 0.0; };
191
194
197
199 double WindingThreshold = .5;
200
202 double ExtendBounds = 1;
203
206
209
211 double MeshCellSize = 1.0;
212
221
223 TFunction<bool(void)> CancelF = []()
224 {
225 return false;
226 };
227
228protected:
229
231
232public:
233
237 bool Validate()
238 {
239 bool bValidParams = SurfaceSearchSteps >= 0 && MeshCellSize > 0 && FMath::IsFinite(MeshCellSize);
240 return bValidParams;
241 }
242
247 {
249 if (!ensure(Validate()))
250 {
251 // give up and return and empty result on invalid parameters
252 return MarchingCubes;
253 }
254
257
259
261
262 // expand marching cubes bounds beyond the 'internal' bounds to ensure we sample outside the bounds, if solid-at-boundaries is requested
264 {
266 }
267
272
274 {
275 MarchingCubes.Implicit = [this, InternalBounds](const FVector3d& Pos)
276 {
277 return InternalBounds.Contains(Pos) ? WindingFunction(Pos) : -(WindingThreshold + 1);
278 };
279 }
280 else
281 {
282 MarchingCubes.Implicit = [this](const FVector3d& Pos)
283 {
284 return WindingFunction(Pos);
285 };
286 }
287
289 for ( const FVector3d& SeedPoint : SeedPoints )
290 {
292 }
294
295 return MarchingCubes;
296 }
297};
298
299
300
301
302
303
304} // end namespace UE::Geometry
305} // end namespace UE
#define ensure( InExpression)
Definition AssertionMacros.h:464
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const bool
Definition NetworkReplayStreaming.h:178
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
Definition Array.h:670
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
Definition AndroidPlatformMisc.h:14
Definition FunctionFwd.h:19
Definition MarchingCubes.h:51
TFunction< bool(void)> CancelF
Definition MarchingCubes.h:106
double CubeSize
Definition MarchingCubes.h:74
double IsoValue
Definition MarchingCubes.h:62
ERootfindingModes RootMode
Definition MarchingCubes.h:97
TAxisAlignedBox3< double > Bounds
Definition MarchingCubes.h:68
TFunction< double(TVector< double >)> Implicit
Definition MarchingCubes.h:56
FMeshShapeGenerator & GenerateContinuation(TArrayView< const FVector3d > Seeds)
Definition MarchingCubes.h:169
int RootModeSteps
Definition MarchingCubes.h:102
Definition MeshShapeGenerator.h:19
void Reset()
Definition MeshShapeGenerator.h:80
int SurfaceSearchSteps
Definition Solidify.h:208
FAxisAlignedBox3d FunctionBounds
Definition Solidify.h:193
bool Validate()
Definition Solidify.h:237
void SetCellSizeAndExtendBounds(const FAxisAlignedBox3d &Bounds, double ExtendBoundsIn, int TargetOutputVoxelCount)
Definition Solidify.h:216
bool bSolidAtBoundaries
Definition Solidify.h:205
double MeshCellSize
Definition Solidify.h:211
double ExtendBounds
Definition Solidify.h:202
TArray< FVector3d > SeedPoints
Definition Solidify.h:196
FMarchingCubes MarchingCubes
Definition Solidify.h:230
virtual ~FWindingNumberBasedSolidify()
Definition Solidify.h:181
FWindingNumberBasedSolidify(TUniqueFunction< double(const FVector3d &)> WindingFunctionIn, const FAxisAlignedBox3d &BoundsIn, const TArray< FVector3d > &SeedPointsIn)
Definition Solidify.h:171
TFunction< bool(void)> CancelF
Definition Solidify.h:223
TUniqueFunction< double(const FVector3d &)> WindingFunction
Definition Solidify.h:190
double WindingThreshold
Definition Solidify.h:199
const FMeshShapeGenerator & Generate()
Definition Solidify.h:246
Definition FastWinding.h:316
Definition Solidify.h:23
double ExtendBounds
Definition Solidify.h:49
TMeshAABBTree3< TriangleMeshType > * SourceSpatial
Definition Solidify.h:36
int SurfaceSearchSteps
Definition Solidify.h:55
TFastWindingTree< TriangleMeshType > * SourceWinding
Definition Solidify.h:37
const TriangleMeshType * Source
Definition Solidify.h:35
TImplicitSolidify(const TriangleMeshType *Source=nullptr, TMeshAABBTree3< TriangleMeshType > *SourceSpatial=nullptr, TFastWindingTree< TriangleMeshType > *SourceWinding=nullptr)
Definition Solidify.h:26
bool Validate()
Definition Solidify.h:84
FAxisAlignedBox3d CustomBounds
Definition Solidify.h:46
TFunction< bool(void)> CancelF
Definition Solidify.h:70
double WindingThreshold
Definition Solidify.h:40
void SetCellSizeAndExtendBounds(FAxisAlignedBox3d Bounds, double ExtendBoundsIn, int TargetOutputVoxelCount)
Definition Solidify.h:63
bool bUseCustomBounds
Definition Solidify.h:43
bool bSolidAtBoundaries
Definition Solidify.h:52
FMarchingCubes MarchingCubes
Definition Solidify.h:77
double MeshCellSize
Definition Solidify.h:58
const FMeshShapeGenerator & Generate()
Definition Solidify.h:95
Definition MeshAABBTree3.h:61
Definition Sphere.cpp:10
Definition AdvancedWidgetsModule.cpp:13
bool Contains(const TVector< RealType > &V) const
Definition BoxTypes.h:492
void Expand(RealType Radius)
Definition BoxTypes.h:618
RealType MaxDim() const
Definition BoxTypes.h:598