UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TopologicalVertex.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"
6#include "Core/HaveStates.h"
7#include "Core/Types.h"
8#include "Math/Point.h"
9#include "Topo/Linkable.h"
11
12namespace UE::CADKernel
13{
14class FDatabase;
15class FModelMesh;
16class FTopologicalEdge;
17class FVertexMesh;
18class FTopologicalVertex;
19
23class FVertexLink : public TTopologicalLink<FTopologicalVertex>
24{
25 friend class FTopologicalVertex;
26
27protected:
29
31 {
33 }
34
35public:
37 : Barycenter(FVector::ZeroVector)
38 {
39 }
40
46
47 virtual void Serialize(FCADKernelArchive& Ar) override
48 {
50 Ar << Barycenter;
51 }
52
53#ifdef CADKERNEL_DEV
54 CADKERNEL_API virtual FInfoEntity& GetInfo(FInfoEntity& Info) const override;
55#endif
56
57 const FVector& GetBarycenter() const
58 {
59 return Barycenter;
60 }
61
62 virtual bool CleanLink() override
63 {
65 {
68 return true;
69 }
70 return false;
71 }
72
73 virtual EEntity GetEntityType() const override
74 {
76 }
77
80};
81
82class FTopologicalVertex : public TLinkable<FTopologicalVertex, FVertexLink>
83{
84 friend class FEntity;
85 friend class FVertexLink;
86
87protected:
88
92
97
98 FTopologicalVertex() = default;
99
100public:
101
102 virtual ~FTopologicalVertex() override
103 {
105 }
106
108 {
109 TSharedRef<FTopologicalVertex> Vertex = FEntity::MakeShared<FTopologicalVertex>(InCoordinate);
110 Vertex->Finalize();
111 return Vertex;
112 }
113
114 virtual void Serialize(FCADKernelArchive& Ar) override
115 {
116 if (Ar.IsSaving())
117 {
119 }
120
124 }
125
126 CADKERNEL_API virtual void SpawnIdent(FDatabase& Database) override;
127
128#ifdef CADKERNEL_DEV
129 CADKERNEL_API virtual FInfoEntity& GetInfo(FInfoEntity&) const override;
130#endif
131
132 virtual EEntity GetEntityType() const override
133 {
135 }
136
140 inline const FVector& GetBarycenter() const
141 {
142 if (TopologicalLink.IsValid() && TopologicalLink->GetTwinEntityNum() > 1)
143 {
144 return TopologicalLink->GetBarycenter();
145 }
146 return Coordinates;
147 }
148
152 const FVector& GetCoordinates() const
153 {
154 return Coordinates;
155 }
156
158 {
159 if (GetLink()->GetTwinEntityNum() > 1)
160 {
161 // Update barycenter
162 FVector BaryCenter = GetLink()->GetBarycenter() * (double)GetLink()->GetTwinEntityNum();
165 BaryCenter /= (double)GetLink()->GetTwinEntityNum();
166 GetLink()->SetBarycenter(BaryCenter);
167 }
168 else
169 {
170 GetLink()->SetBarycenter(NewCoordinates);
171 }
173 }
174
176 {
177 return FVector::Distance(Coordinates, OtherVertex.Coordinates);
178 }
179
181 {
182 return FVector::DistSquared(Coordinates, OtherVertex.Coordinates);
183 }
184
186 {
187 return FVector::DistSquared(GetLink()->GetBarycenter(), OtherVertex.GetLink()->GetBarycenter());
188 }
189
190 double SquareDistance(const FVector& Point) const
191 {
193 }
194
196
197 const FVertexMesh* GetMesh() const
198 {
199 if (!IsActiveEntity())
200 {
201 return GetLinkActiveEntity()->GetMesh();
202 }
203 if (Mesh.IsValid())
204 {
205 return Mesh.Get();
206 }
207 return nullptr;
208 }
209
211
213
214 virtual void RemoveFromLink() override
215 {
217 {
218 TopologicalLink->RemoveEntity(*this);
219 TopologicalLink->ComputeBarycenter();
221 }
222 }
223
225 {
226 if (ConnectedEdges.Num() == 0)
227 {
229 {
230 TopologicalLink->RemoveEntity(*this);
231 if (!TopologicalLink->IsDeleted())
232 {
233 TopologicalLink->ComputeBarycenter();
234 }
236 }
237 Delete();
238 }
239 }
240
241 virtual void Empty() override
242 {
243 ConnectedEdges.Empty();
244 Mesh.Reset();
246 }
247
248 CADKERNEL_API bool IsBorderVertex() const;
249
252
267
269
271 {
273 {
275 }
276 else
277 {
278 OutConnectedEdges.Reserve(100);
279 for (const FTopologicalVertex* Vertex : GetLink()->GetTwinEntities())
280 {
281 OutConnectedEdges.Append(Vertex->ConnectedEdges);
282 }
283 }
284 }
285
287 {
289 {
290 return ConnectedEdges.Num();
291 }
292 else
293 {
294 int32 Count = 0;
295 for (const FTopologicalVertex* Vertex : GetLink()->GetTwinEntities())
296 {
297 Count += Vertex->ConnectedEdges.Num();
298 }
299 return Count;
300 }
301 }
302
307};
308
309} // namespace UE::CADKernel
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
#define ensureCADKernel(InExpression)
Definition Types.h:115
@ Vertex
Definition MetalRHIPrivate.h:223
Definition Array.h:670
Definition SharedPointer.h:692
UE_FORCEINLINE_HINT void Reset()
Definition SharedPointer.h:1120
UE_FORCEINLINE_HINT const bool IsValid() const
Definition SharedPointer.h:1085
Definition SharedPointer.h:153
Definition CADKernelArchive.h:19
void Serialize(void *Value, int64 Length)
Definition CADKernelArchive.h:118
bool IsSaving() const
Definition CADKernelArchive.h:113
Definition Database.h:17
Definition CADEntity.h:56
static void SerializeIdents(FCADKernelArchive &Ar, TArray< FEntity * > &Array, bool bSaveSelection=true)
Definition CADEntity.cpp:186
Definition ModelMesh.h:21
Definition TopologicalEdge.h:63
Definition TopologicalFace.h:56
Definition TopologicalVertex.h:83
virtual void Empty() override
Definition TopologicalVertex.h:241
CADKERNEL_API FVertexMesh & GetOrCreateMesh(FModelMesh &MeshModel)
Definition TopologicalVertex.cpp:176
double SquareDistance(const FVector &Point) const
Definition TopologicalVertex.h:190
const FVertexMesh * GetMesh() const
Definition TopologicalVertex.h:197
FTopologicalVertex(const FVector &InCoordinates)
Definition TopologicalVertex.h:93
double SquareDistanceBetweenBarycenters(const FTopologicalVertex &OtherVertex) const
Definition TopologicalVertex.h:185
CADKERNEL_API void RemoveConnectedEdge(FTopologicalEdge &Edge)
Definition TopologicalVertex.cpp:17
virtual ~FTopologicalVertex() override
Definition TopologicalVertex.h:102
virtual void Serialize(FCADKernelArchive &Ar) override
Definition TopologicalVertex.h:114
CADKERNEL_API bool IsBorderVertex() const
Definition TopologicalVertex.cpp:34
TSharedPtr< FVertexMesh > Mesh
Definition TopologicalVertex.h:91
TArray< FTopologicalEdge * > ConnectedEdges
Definition TopologicalVertex.h:89
CADKERNEL_API const FTopologicalFace * GetFace() const
Definition TopologicalVertex.cpp:55
const TArray< FTopologicalEdge * > & GetDirectConnectedEdges() const
Definition TopologicalVertex.h:263
virtual CADKERNEL_API void SpawnIdent(FDatabase &Database) override
Definition TopologicalVertex.cpp:195
const FVector & GetBarycenter() const
Definition TopologicalVertex.h:140
const int32 ConnectedEdgeCount()
Definition TopologicalVertex.h:286
static TSharedRef< FTopologicalVertex > Make(const FVector &InCoordinate)
Definition TopologicalVertex.h:107
FVector Coordinates
Definition TopologicalVertex.h:90
void SetCoordinates(const FVector &NewCoordinates)
Definition TopologicalVertex.h:157
virtual void RemoveFromLink() override
Definition TopologicalVertex.h:214
CADKERNEL_API void UnlinkTo(FTopologicalVertex &Entity)
Definition TopologicalVertex.cpp:111
CADKERNEL_API void AddConnectedEdge(FTopologicalEdge &Edge)
Definition TopologicalVertex.cpp:12
void GetConnectedEdges(TArray< FTopologicalEdge * > &OutConnectedEdges) const
Definition TopologicalVertex.h:270
virtual EEntity GetEntityType() const override
Definition TopologicalVertex.h:132
const FVector & GetCoordinates() const
Definition TopologicalVertex.h:152
double Distance(const FTopologicalVertex &OtherVertex) const
Definition TopologicalVertex.h:175
double SquareDistance(const FTopologicalVertex &OtherVertex) const
Definition TopologicalVertex.h:180
void DeleteIfIsolated()
Definition TopologicalVertex.h:224
Definition VertexMesh.h:11
int32 GetMesh() const
Definition VertexMesh.h:20
Definition Linkable.h:15
bool IsActiveEntity() const
Definition Linkable.h:58
TSharedPtr< FVertexLink > TopologicalLink
Definition Linkable.h:17
virtual void Serialize(FCADKernelArchive &Ar) override
Definition Linkable.h:33
virtual TSharedPtr< FVertexLink > GetLink() const
Definition Linkable.h:76
virtual void Empty() override
Definition Linkable.h:39
const TSharedRef< const FTopologicalVertex > GetLinkActiveEntity() const
Definition Linkable.h:44
Definition CADEntity.cpp:23
@ Point
Definition Visu.h:17
EEntity
Definition CADEntity.h:18
static UE_FORCEINLINE_HINT double Distance(const TVector< double > &V1, const TVector< double > &V2)
Definition Vector.h:1018
static UE_FORCEINLINE_HINT double DistSquared(const TVector< double > &V1, const TVector< double > &V2)
Definition Vector.h:2478