UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IsoSegment.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "Core/Types.h"
6#include "UI/Display.h"
7
8namespace UE::CADKernel
9{
10
11enum class ESegmentType : uint8
12{
13 Unknown = 0,
14 Loop = 1,
15 ThinZone = 2,
16 IsoU,
17 IsoV,
18 LoopToLoop, // IsBoundaryToInner use that xxxToBoundary are bigger than BoundaryToBoundary
23};
24
26{
27 None = 0x00u, // No flags.
28
29 Candidate = 0x01u,
30
31 LeftCycle = 0x02u,
32 RightCycle = 0x04u,
33
34 Degenerate = 0x08u,
35
36 LeftTriangle = 0x10u,
37 RightTriangle = 0x20u,
38 SegmentComplete = 0x30u,
39
40 Final = 0x40u,
41 Delete = 0x80u,
42
43 All = 0xFFu
44};
45
47
48
49class FGrid;
50
52{
53protected:
58
59public:
60
62 : FirstNode(nullptr)
63 , SecondNode(nullptr)
66 {
67 }
68
88
90 {
92 {
93 return false;
94 }
95
98 return true;
99 }
100
101 static bool IsItAlreadyDefined(const FIsoNode* StartNode, const FIsoNode* EndNode)
102 {
103 for (const FIsoSegment* Segment : StartNode->GetConnectedSegments())
104 {
105 const FIsoNode& OtherNode = (StartNode == &Segment->GetFirstNode()) ? Segment->GetSecondNode() : Segment->GetFirstNode();
106 if (&OtherNode == EndNode)
107 {
108 return true;
109 }
110 }
111 return false;
112 }
113
114 void Clean()
115 {
116 if (FirstNode)
117 {
119 }
120 if (SecondNode)
121 {
123 }
124 FirstNode = nullptr;
125 SecondNode = nullptr;
127 }
128
129 bool IsDelete() const
130 {
132 }
133
138
143
148
153
154 bool IsAFinalSegment() const
155 {
157 }
158
163
168
173
178
180 {
181 return (States & Side) == Side;
182 }
183
188
193
199
205
207 {
208 States |= Side;
209 }
210
215
220
222 {
223 if (bOrientation)
224 {
226 }
227 else
228 {
230 }
231 }
232
237
242
247
252
253 bool IsFirstNode(const FIsoNode* Node) const
254 {
255 return FirstNode == Node;
256 }
257
258 const FIsoNode& GetFirstNode() const
259 {
260 return *FirstNode;
261 }
262
264 {
265 return *FirstNode;
266 }
267
268 const FIsoNode& GetSecondNode() const
269 {
270 return *SecondNode;
271 }
272
274 {
275 return *SecondNode;
276 }
277
278 void SetFirstNode(FIsoNode& NewNode)
279 {
280 FirstNode = &NewNode;
281
282 ((FLoopNode*)SecondNode)->SetPreviousConnectedNode((FLoopNode*)FirstNode);
283 ((FLoopNode*)FirstNode)->SetNextConnectedNode((FLoopNode*)SecondNode);
284 }
285
286 void SetSecondNode(FIsoNode& NewNode)
287 {
288 SecondNode = &NewNode;
289
290 ((FLoopNode*)SecondNode)->SetPreviousConnectedNode((FLoopNode*)FirstNode);
291 ((FLoopNode*)FirstNode)->SetNextConnectedNode((FLoopNode*)SecondNode);
292 }
293
295 {
296 if (FirstNode == &OldNode)
297 {
298 SetFirstNode(NewNode);
299 }
300 else
301 {
303 SetSecondNode(NewNode);
304 }
305 }
306
308 {
312
313 ((FLoopNode*)FirstNode)->SetNextConnectedNode((FLoopNode*)SecondNode);
314 ((FLoopNode*)SecondNode)->SetPreviousConnectedNode((FLoopNode*)FirstNode);
315 }
316
317 const FIsoNode& GetOtherNode(const FIsoNode* Node) const
318 {
319 return (FirstNode == Node) ? *SecondNode : *FirstNode;
320 }
321
323 {
324 return (FirstNode == Node) ? *SecondNode : *FirstNode;
325 }
326
327 const ESegmentType GetType() const
328 {
329 return Type;
330 }
331
332 double Get2DLengthSquare(EGridSpace Space, const FGrid& Grid) const
333 {
334 const FVector2d& Point1 = FirstNode->Get2DPoint(Space, Grid);
335 const FVector2d& Point2 = SecondNode->Get2DPoint(Space, Grid);
336 return FVector2d::DistSquared(Point1, Point2);
337 }
338
339 double Get3DLengthSquare(const FGrid& Grid) const
340 {
341 const FVector& Point1 = FirstNode->Get3DPoint(Grid);
342 const FVector& Point2 = SecondNode->Get3DPoint(Grid);
343 return FVector::DistSquared(Point1, Point2);
344 }
345};
346
348{
349 uint32 StartHash = GetTypeHash(Segment.GetFirstNode());
350 uint32 EndHash = GetTypeHash(Segment.GetSecondNode());
351 if (StartHash < EndHash)
352 {
354 }
355 else
356 {
358 }
359};
360
361inline uint32 GetTypeHash(const FIsoSegment& Segment0, const FIsoSegment& Segment1)
362{
364 uint32 EndHash = GetTypeHash(Segment1);
365 if (StartHash < EndHash)
366 {
368 }
369 else
370 {
372 }
373};
374
375
377{
378 if (this == Node)
379 {
380 return nullptr;
381 }
382
384 {
385 if (&Segment->GetFirstNode() == Node)
386 {
387 return Segment;
388 }
389 if (&Segment->GetSecondNode() == Node)
390 {
391 return Segment;
392 }
393 }
394 return nullptr;
395}
396
397} // namespace UE::CADKernel
398
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define ensureCADKernel(InExpression)
Definition Types.h:115
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
constexpr uint32 HashCombine(uint32 A, uint32 C)
Definition TypeHash.h:36
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Grid.h:46
Definition IsoNode.h:62
void DisconnectSegment(FIsoSegment &Segment)
Definition IsoNode.h:124
TArray< FIsoSegment * > ConnectedSegments
Definition IsoNode.h:64
virtual const FVector & Get3DPoint(const FGrid &Grid) const =0
FIsoSegment * GetSegmentConnectedTo(const FIsoNode *Node) const
Definition IsoSegment.h:376
const TArray< FIsoSegment * > & GetConnectedSegments() const
Definition IsoNode.h:112
virtual const FVector2d & Get2DPoint(EGridSpace Space, const FGrid &Grid) const =0
void ConnectSegment(FIsoSegment &Segment)
Definition IsoNode.h:119
void SetLinkedToIso(EIsoLink Iso)
Definition IsoNode.h:186
Definition IsoSegment.h:52
FIsoNode * SecondNode
Definition IsoSegment.h:55
void SetHaveCycleOnRight()
Definition IsoSegment.h:174
bool HasTriangleOnRightAndLeft()
Definition IsoSegment.h:200
void SetAsDegenerated()
Definition IsoSegment.h:238
FIsoNode & GetSecondNode()
Definition IsoSegment.h:273
EIsoSegmentStates States
Definition IsoSegment.h:57
void SetHasTriangleOnLeft()
Definition IsoSegment.h:211
bool IsFirstNode(const FIsoNode *Node) const
Definition IsoSegment.h:253
bool ConnectToNode()
Definition IsoSegment.h:89
static bool IsItAlreadyDefined(const FIsoNode *StartNode, const FIsoNode *EndNode)
Definition IsoSegment.h:101
double Get2DLengthSquare(EGridSpace Space, const FGrid &Grid) const
Definition IsoSegment.h:332
const FIsoNode & GetOtherNode(const FIsoNode *Node) const
Definition IsoSegment.h:317
void ResetHasTriangle()
Definition IsoSegment.h:233
void SetSecondNode(FIsoNode &NewNode)
Definition IsoSegment.h:286
void SetFinalMarker()
Definition IsoSegment.h:149
const FIsoNode & GetSecondNode() const
Definition IsoSegment.h:268
void SetFirstNode(FIsoNode &NewNode)
Definition IsoSegment.h:278
void SwapOrientation()
Definition IsoSegment.h:307
bool HasCycleOnLeft()
Definition IsoSegment.h:159
FIsoNode & GetOtherNode(const FIsoNode *Node)
Definition IsoSegment.h:322
FIsoNode * FirstNode
Definition IsoSegment.h:54
bool HasTriangleOn(EIsoSegmentStates Side)
Definition IsoSegment.h:179
void SetHasTriangleOnRight()
Definition IsoSegment.h:216
bool IsAFinalSegment() const
Definition IsoSegment.h:154
void Init(FIsoNode &InFirstNode, FIsoNode &InSecondNode, const ESegmentType InType)
Definition IsoSegment.h:69
ESegmentType Type
Definition IsoSegment.h:56
void SetCandidate()
Definition IsoSegment.h:139
void Clean()
Definition IsoSegment.h:114
bool IsDegenerated() const
Definition IsoSegment.h:248
bool HasntTriangle()
Definition IsoSegment.h:194
bool HasCycleOnRight()
Definition IsoSegment.h:169
bool HasTriangleOnRight()
Definition IsoSegment.h:189
void SetSelected()
Definition IsoSegment.h:134
const FIsoNode & GetFirstNode() const
Definition IsoSegment.h:258
FIsoSegment()
Definition IsoSegment.h:61
bool IsDelete() const
Definition IsoSegment.h:129
void SetHasTriangleOn(EIsoSegmentStates Side)
Definition IsoSegment.h:206
bool IsACandidate() const
Definition IsoSegment.h:144
bool HasTriangleOnLeft()
Definition IsoSegment.h:184
void SetHasInnerTriangle(bool bOrientation)
Definition IsoSegment.h:221
void SetHaveCycleOnLeft()
Definition IsoSegment.h:164
void ReplaceNode(FIsoNode &OldNode, FIsoNode &NewNode)
Definition IsoSegment.h:294
double Get3DLengthSquare(const FGrid &Grid) const
Definition IsoSegment.h:339
const ESegmentType GetType() const
Definition IsoSegment.h:327
FIsoNode & GetFirstNode()
Definition IsoSegment.h:263
void ResetDegenerated()
Definition IsoSegment.h:243
Definition IsoNode.h:285
Definition CADEntity.cpp:23
uint32 GetTypeHash(const FIsoNode &Node)
Definition IsoNode.h:436
EGridSpace
Definition MeshEnum.h:17
ESegmentType
Definition IsoSegment.h:12
@ IsoV
Definition GeoEnum.h:68
@ IsoU
Definition GeoEnum.h:67
EIsoSegmentStates
Definition IsoSegment.h:26
static UE_FORCEINLINE_HINT double DistSquared(const TVector2< double > &V1, const TVector2< double > &V2)
Definition Vector2D.h:935
static UE_FORCEINLINE_HINT double DistSquared(const TVector< double > &V1, const TVector< double > &V2)
Definition Vector.h:2478