UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MeshBoundaryLoops.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3// Port of geometry3cpp MeshBoundaryLoops
4
5#pragma once
6
8#include "EdgeLoop.h"
9#include "EdgeSpan.h"
10#include "VectorUtil.h"
11#include "Util/BufferUtil.h"
12
13namespace UE
14{
15namespace Geometry
16{
17
19{
20public:
22 const FDynamicMesh3* Mesh = nullptr;
23
26
29
31 bool bAborted = false;
33 bool bSawOpenSpans = false;
36
37 enum class ESpanBehaviors
38 {
40 };
43
44
46 {
47 Abort, // die, and you clean up
48 ConvertToOpenSpan // keep un-closed loop as a span
49 };
52
54 TFunction<bool(int)> EdgeFilterFunc = nullptr;
55
58
60 bool bOnlyComputeSpans = false;
61
62public:
64
66 {
67 Mesh = MeshIn;
68 if (bAutoCompute)
69 {
70 Compute();
71 }
72 }
73
75
82
83
84
86 int GetLoopCount() const
87 {
88 return Loops.Num();
89 }
90
92 int GetSpanCount() const
93 {
94 return Spans.Num();
95 }
96
98 const FEdgeLoop& operator[](int Index) const
99 {
100 return Loops[Index];
101 }
102
103
106
109
113 GEOMETRYCORE_API FIndex2i FindVertexInLoop(int VertexID) const;
114
118 GEOMETRYCORE_API int FindLoopContainingVertex(int VertexID) const;
119
123 GEOMETRYCORE_API int FindLoopContainingEdge(int EdgeID) const;
124
129
134
138 GEOMETRYCORE_API int FindSpanContainingEdge(int EdgeID) const;
139
140
141protected:
142
144
145 // [TODO] cache this : a dictionary? we will not need very many, but we will
146 // need each multiple times!
148
149 // ok, bdry_edges[0...bdry_edges_count] contains the boundary edges coming out of bowtie_v.
150 // We want to pick the best one to continue the loop that came in to bowtie_v on incoming_e.
151 // If the loops are all sane, then we will get the smallest loops by "turning left" at bowtie_v.
153
159
160
161 // This is called when loopV contains one or more "bowtie" vertices.
162 // These vertices *might* be duplicated in loopV (but not necessarily)
163 // If they are, we have to break loopV into subloops that don't contain duplicates.
165
166
167
168protected:
169
171
172 /*
173 * static Utility functions that can be re-used in MeshRegionBoundaryLoops
174 * In all the functions below, the list loopV is assumed to possibly
175 * contain "removed" vertices indicated by -1. These are ignored.
176 */
177
178 // Check if the loop from bowtieV to bowtieV inside loopV contains any other bowtie verts.
179 // Also returns start and end indices in loopV of "clean" loop
180 // Note that start may be < end, if the "clean" loop wraps around the end
182
183 // check if forward path from loopV[i1] to loopV[i2] contains any bowtie verts other than bowtieV
185
186
187 // Read out the span from loop[i0] to loop [i1-1] into an array.
188 // If bMarkInvalid, then these values are set to -1 in loop
190
191 // count number of valid vertices in l between loop[i0] and loop[i1-1]
192 static GEOMETRYCORE_API int CountSpan(const TArray<int>& Loop, int i0, int i1);
193
194 // find the index of item in loop, starting at start index
195 static GEOMETRYCORE_API int FindIndex(const TArray<int>& Loop, int Start, int Item);
196
197 // count number of times item appears in loop
198 static GEOMETRYCORE_API int CountInList(const TArray<int>& Loop, int Item);
199
200
201};
202
203
204} // end namespace UE::Geometry
205} // end namespace UE
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const bool
Definition NetworkReplayStreaming.h:178
Definition Array.h:670
Definition AndroidPlatformMisc.h:14
Definition DynamicMesh3.h:108
Definition EdgeLoop.h:19
Definition MeshBoundaryLoops.h:19
TFunction< bool(int)> EdgeFilterFunc
Definition MeshBoundaryLoops.h:54
GEOMETRYCORE_API int FindLoopContainingEdge(int EdgeID) const
Definition MeshBoundaryLoops.cpp:76
GEOMETRYCORE_API int FindLeftTurnEdge(int incoming_e, int bowtie_v, TArray< int > &bdry_edges, int bdry_edges_count, TArray< bool > &used_edges)
Definition MeshBoundaryLoops.cpp:390
GEOMETRYCORE_API FVector3d GetVertexNormal(int vid)
Definition MeshBoundaryLoops.cpp:368
int GetLoopCount() const
Definition MeshBoundaryLoops.h:86
void SetMesh(const FDynamicMesh3 *MeshIn)
Definition MeshBoundaryLoops.h:74
GEOMETRYCORE_API FIndex2i FindVertexInLoop(int VertexID) const
Definition MeshBoundaryLoops.cpp:46
static GEOMETRYCORE_API int CountInList(const TArray< int > &Loop, int Item)
Definition MeshBoundaryLoops.cpp:674
int GetSpanCount() const
Definition MeshBoundaryLoops.h:92
static GEOMETRYCORE_API int FindIndex(const TArray< int > &Loop, int Start, int Item)
Definition MeshBoundaryLoops.cpp:661
ESpanBehaviors SpanBehavior
Definition MeshBoundaryLoops.h:42
FMeshBoundaryLoops()
Definition MeshBoundaryLoops.h:63
GEOMETRYCORE_API int FindLoopEdgesHint(const TSet< int > &BorderHintEdges) const
Definition MeshBoundaryLoops.cpp:711
bool bSawOpenSpans
Definition MeshBoundaryLoops.h:33
const FDynamicMesh3 * Mesh
Definition MeshBoundaryLoops.h:22
const FEdgeLoop & operator[](int Index) const
Definition MeshBoundaryLoops.h:98
EFailureBehaviors FailureBehavior
Definition MeshBoundaryLoops.h:51
TArray< FEdgeLoop > Loops
Definition MeshBoundaryLoops.h:25
GEOMETRYCORE_API int FindLoopTrianglesHint(const TArray< int > &BorderHintTris) const
Definition MeshBoundaryLoops.cpp:687
TArray< int > FailureBowties
Definition MeshBoundaryLoops.h:57
static GEOMETRYCORE_API void ExtractSpan(TArray< int > &Loop, int i0, int i1, bool bMarkInvalid, TArray< int > &OutSpan)
Definition MeshBoundaryLoops.cpp:625
FMeshBoundaryLoops(const FDynamicMesh3 *MeshIn, bool bAutoCompute=true)
Definition MeshBoundaryLoops.h:65
bool bAborted
Definition MeshBoundaryLoops.h:31
GEOMETRYCORE_API int GetLongestLoopIndex() const
Definition MeshBoundaryLoops.cpp:23
GEOMETRYCORE_API int FindSpanContainingEdge(int EdgeID) const
Definition MeshBoundaryLoops.cpp:739
TArray< FEdgeSpan > Spans
Definition MeshBoundaryLoops.h:28
EFailureBehaviors
Definition MeshBoundaryLoops.h:46
GEOMETRYCORE_API bool Compute()
Definition MeshBoundaryLoops.cpp:92
GEOMETRYCORE_API bool ExtractSubloops(TArray< int > &loopV, TArray< int > &loopE, TArray< int > &bowties, Subloops &SubloopsOut)
Definition MeshBoundaryLoops.cpp:450
static GEOMETRYCORE_API bool IsSimpleBowtieLoop(const TArray< int > &LoopVerts, const TArray< int > &BowtieVerts, int BowtieVertex, int &start_i, int &end_i)
Definition MeshBoundaryLoops.cpp:581
GEOMETRYCORE_API int GetMaxVerticesLoopIndex() const
Definition MeshBoundaryLoops.cpp:8
static GEOMETRYCORE_API bool IsSimplePath(const TArray< int > &LoopVerts, const TArray< int > &BowtieVerts, int BowtieVertex, int i1, int i2)
Definition MeshBoundaryLoops.cpp:604
bool bOnlyComputeSpans
Definition MeshBoundaryLoops.h:60
GEOMETRYCORE_API int FindLoopContainingVertex(int VertexID) const
Definition MeshBoundaryLoops.cpp:62
bool bFellBackToSpansOnFailure
Definition MeshBoundaryLoops.h:35
TArray< int > VerticesTemp
Definition MeshBoundaryLoops.h:143
static GEOMETRYCORE_API int CountSpan(const TArray< int > &Loop, int i0, int i1)
Definition MeshBoundaryLoops.cpp:646
ESpanBehaviors
Definition MeshBoundaryLoops.h:38
Definition MeshRegionBoundaryLoops.h:22
Definition AdvancedWidgetsModule.cpp:13
U16 Index
Definition radfft.cpp:71
Definition IndexTypes.h:27
Definition MeshBoundaryLoops.h:155
TArray< FEdgeLoop > Loops
Definition MeshBoundaryLoops.h:156
TArray< FEdgeSpan > Spans
Definition MeshBoundaryLoops.h:157