UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TopologicalLoop.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
5#include "Core/CADEntity.h"
7#include "Geo/GeoEnum.h"
8#include "Math/Boundary.h"
12
13namespace UE::CADKernel
14{
15
16class FDatabase;
17class FTopologicalFace;
18class FTopologicalVertex;
19
20class CADKERNEL_API FOrientedEdge : public TOrientedEntity<FTopologicalEdge>
21{
22public:
27
30 {
31 }
32
33 bool operator==(const FOrientedEdge& Edge) const
34 {
35 return Entity == Edge.Entity;
36 }
37
39 {
40 return Direction == EOrientation::Front ? Entity->GetStartVertex() : Entity->GetEndVertex();
41 }
42
44 {
45 return Direction == EOrientation::Front ? Entity->GetEndVertex() : Entity->GetStartVertex();
46 }
47
49 {
50 return Direction == EOrientation::Front ? Entity->GetBoundary().GetMin() : Entity->GetBoundary().GetMax();
51 }
52
54 {
55 return Direction == EOrientation::Front ? Entity->GetBoundary().GetMax() : Entity->GetBoundary().GetMin();
56 }
57};
58
60{
61 friend class FEntity;
62 friend class FTopologicalFace;
63 friend class FTopologicalFace;
64 friend class FTopologicalEdge;
65
66public:
68
69protected:
71
74
76
77 FTopologicalLoop() = default;
78
79private:
80
81 void SetSurface(FTopologicalFace* HostedFace)
82 {
84 }
85
86 void ResetSurface()
87 {
88 Face = nullptr;
89 }
90
91public:
92
93 virtual ~FTopologicalLoop() override
94 {
95 FTopologicalLoop::Empty();
96 }
97
98 virtual void Empty() override
99 {
100 for (FOrientedEdge& Edge : Edges)
101 {
102 Edge.Entity->Empty();
103 }
104 Edges.Empty();
105 FTopologicalEntity::Empty();
106 }
107
109
110 void DeleteLoopEdges();
111
112 virtual void Serialize(FCADKernelArchive& Ar) override
113 {
114 FTopologicalEntity::Serialize(Ar);
115 SerializeIdents(Ar, (TArray<TOrientedEntity<FEntity>>&) Edges);
116 SerializeIdent(Ar, &Face);
117 Ar << bIsExternal;
118 }
119
120 virtual void SpawnIdent(FDatabase& Database) override
121 {
122 if (!FEntity::SetId(Database))
123 {
124 return;
125 }
126
127 SpawnIdentOnEntities((TArray<TOrientedEntity<FEntity>>&) Edges, Database);
128 }
129
130 virtual void ResetMarkersRecursively() const override
131 {
132 ResetMarkers();
133 ResetMarkersRecursivelyOnEntities((TArray<TOrientedEntity<FEntity>>&) Edges);
134 }
135
136#ifdef CADKERNEL_DEV
137 virtual FInfoEntity& GetInfo(FInfoEntity&) const override;
138#endif
139
140 virtual EEntity GetEntityType() const override
141 {
142 return EEntity::TopologicalLoop;
143 }
144
145 double Length() const;
146
147 const int32 EdgeCount() const
148 {
149 return Edges.Num();
150 }
151
153 {
154 return Edges;
155 }
156
158 {
159 return Edges;
160 }
161
163 {
164 for (const FOrientedEdge& Edge : Edges)
165 {
166 if (Edge.Entity.Get() == InEdge)
167 {
168 return &Edge;
169 }
170 }
171 return nullptr;
172 }
173
179 {
180 for (const FOrientedEdge& Edge : Edges)
181 {
182 TSharedPtr<FTopologicalEdge> ActiveEdge = Edge.Entity->GetLinkActiveEdge();
183 if (!ActiveEdge->HasMarker1())
184 {
185 ActiveEdge->SetMarker1();
186 OutEdges.Emplace(ActiveEdge);
187 }
188 }
189 }
190
192 {
193 return Face;
194 }
195
196 bool IsExternal() const
197 {
198 return bIsExternal;
199 }
200
202 {
203 bIsExternal = true;
204 }
205
207 {
208 bIsExternal = false;
209 }
210
211 /*
212 * @return false if the orientation is doubtful
213 */
214 bool Orient();
215 void SwapOrientation();
216
219 void ReplaceEdges(TArray<FOrientedEdge>& Candidates, TSharedPtr<FTopologicalEdge>& NewEdge);
220
227
228 void RemoveEdge(TSharedPtr<FTopologicalEdge>& Edge);
229 //void ReplaceEdgesWithMergedEdge(TArray<TSharedPtr<FTopologicalEdge>>& OldEdges, TSharedPtr<FTopologicalVertex>& MiddleVertex, TSharedPtr<FTopologicalEdge>& NewEdge);
230
231 EOrientation GetDirection(TSharedPtr<FTopologicalEdge>& Edge, bool bAllowLinkedEdge = false) const;
232
234 {
235 return Edges[Index].Direction;
236 }
237
239 {
240 return Edges[Index].Entity;
241 }
242
244 {
245 for (int32 Index = 0; Index < Edges.Num(); ++Index)
246 {
247 if (&Edge == Edges[Index].Entity.Get())
248 {
249 return Index;
250 }
251 }
252 return -1;
253 }
254
255 void Get2DSampling(TArray<FVector2d>& LoopSampling) const;
256
264 bool Get2DSamplingWithoutDegeneratedEdges(TArray<FVector2d>& LoopSampling) const;
265
268
269 void ComputeBoundaryProperties(const TArray<int32>& StartSideIndex, TArray<FEdge2DProperties>& OutSideProperties) const;
270
271 void EnsureLogicalClosing(const double GeometricTolerance);
272
273 void CheckEdgesOrientation();
274 void CheckLoopWithTwoEdgesOrientation();
275 void RemoveDegeneratedEdges();
276
277 bool IsInside(const FTopologicalLoop& Other) const;
278
279};
280
281}
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
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
void Empty(SizeType Slack=0)
Definition Array.h:2273
Definition SharedPointer.h:692
Definition SharedPointer.h:153
Definition CADKernelArchive.h:19
Definition Database.h:17
Definition CADEntity.h:56
Definition TopologicalLoop.h:21
FOrientedEdge()
Definition TopologicalLoop.h:28
bool operator==(const FOrientedEdge &Edge) const
Definition TopologicalLoop.h:33
FOrientedEdge(TSharedPtr< FTopologicalEdge > &InEntity, EOrientation InDirection)
Definition TopologicalLoop.h:23
TSharedRef< FTopologicalVertex > GetStartVertex()
Definition TopologicalLoop.h:38
double GetStartCoordinate()
Definition TopologicalLoop.h:48
double GetEndCoordinate()
Definition TopologicalLoop.h:53
TSharedRef< FTopologicalVertex > GetEndVertex()
Definition TopologicalLoop.h:43
Definition Boundary.h:248
Definition TopologicalEdge.h:63
Definition TopologicalEntity.h:16
Definition TopologicalFace.h:56
Definition TopologicalLoop.h:60
virtual EEntity GetEntityType() const override
Definition TopologicalLoop.h:140
TArray< FOrientedEdge > Edges
Definition TopologicalLoop.h:70
int32 GetEdgeIndex(const FTopologicalEdge &Edge) const
Definition TopologicalLoop.h:243
TArray< FOrientedEdge > & GetEdges()
Definition TopologicalLoop.h:157
void SetInternal()
Definition TopologicalLoop.h:206
FTopologicalFace * Face
Definition TopologicalLoop.h:72
const TArray< FOrientedEdge > & GetEdges() const
Definition TopologicalLoop.h:152
virtual void Serialize(FCADKernelArchive &Ar) override
Definition TopologicalLoop.h:112
void GetActiveEdges(TArray< TSharedPtr< FTopologicalEdge > > &OutEdges) const
Definition TopologicalLoop.h:178
virtual void SpawnIdent(FDatabase &Database) override
Definition TopologicalLoop.h:120
const TSharedPtr< FTopologicalEdge > & GetEdge(int32 Index) const
Definition TopologicalLoop.h:238
const FOrientedEdge * GetOrientedEdge(const FTopologicalEdge *InEdge) const
Definition TopologicalLoop.h:162
virtual void Empty() override
Definition TopologicalLoop.h:98
virtual void ResetMarkersRecursively() const override
Definition TopologicalLoop.h:130
void SetExternal()
Definition TopologicalLoop.h:201
const int32 EdgeCount() const
Definition TopologicalLoop.h:147
FTopologicalFace * GetFace() const
Definition TopologicalLoop.h:191
EOrientation GetDirection(int32 Index) const
Definition TopologicalLoop.h:233
bool IsExternal() const
Definition TopologicalLoop.h:196
bool bIsExternal
Definition TopologicalLoop.h:73
virtual ~FTopologicalLoop() override
Definition TopologicalLoop.h:93
FSurfacicBoundary Boundary
Definition TopologicalLoop.h:67
Definition OrientedEntity.h:11
Definition CADEntity.cpp:23
EOrientation
Definition GeoEnum.h:82
void SwapOrientation(EOrientation &Orientation)
Definition GeoEnum.h:128
EEntity
Definition CADEntity.h:18
U16 Index
Definition radfft.cpp:71