UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
EdgeSegment.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"
5
6#include "Math/Geometry.h"
7#include "Core/HaveStates.h"
8#include "Math/Boundary.h"
9#include "Math/Point.h"
10#include "Math/SlopeUtils.h"
11
12namespace UE::CADKernel
13{
14class FTopologicalLoop;
15class FTopologicalEdge;
16class FGrid;
17class FThinZone;
18class FThinZone2DFinder;
19class FTopologicalVertex;
20
22{
23private:
24 FTopologicalEdge* Edge;
25 double Coordinates[2];
26 FVector2d USSPoints[2]; // in Uniform Scaled space
27
28 FEdgeSegment* NextSegment;
29 FEdgeSegment* PreviousSegment;
30
31 FEdgeSegment* ClosedSegment;
32
33 FSurfacicBoundary Boundary;
34 double AxisMin;
35
36 double SquareDistanceToClosedSegment;
37 double Length;
38
39 FIdent ChainIndex;
40
41 FIdent Id;
42 static FIdent LastId;
43
44public:
46 : Edge(nullptr)
47 , NextSegment(nullptr)
48 , PreviousSegment(nullptr)
49 , ClosedSegment(nullptr)
50 , AxisMin(0.)
51 , SquareDistanceToClosedSegment(HUGE_VALUE)
52 , Length(-1.)
53 , ChainIndex(Ident::Undefined)
54 , Id(0)
55 {
56 };
57
59
60 virtual ~FEdgeSegment() = default;
61
63 {
65 {
66 SetInner();
67 }
68
69 Edge = InEdge;
70 Coordinates[ELimit::Start] = InStartU;
71 Coordinates[ELimit::End] = InEndU;
72 USSPoints[ELimit::Start] = InStartPoint;
73 USSPoints[ELimit::End] = InEndPoint;
74 NextSegment = nullptr;
75 PreviousSegment = nullptr;
76 ClosedSegment = nullptr;
77
78 SquareDistanceToClosedSegment = HUGE_VAL;
79 Length = FVector2d::Distance(USSPoints[ELimit::Start], USSPoints[ELimit::End]);
80
81 Id = ++LastId;
82 ChainIndex = Ident::Undefined;
83
84 Boundary.Set(USSPoints[ELimit::Start], USSPoints[ELimit::End]);
85
86 AxisMin = Boundary[EIso::IsoU].Min + Boundary[EIso::IsoV].Min;
87 };
88
90 {
92 {
93 if (Reference)
94 {
95 FEdgeSegment** NewReference = Map.Find(Reference->GetId());
96 if (NewReference)
97 {
98 Reference = *NewReference;
99 }
100 else
101 {
102 Reference = nullptr;
103 }
104 }
105 };
106
107 UpdateReference(NextSegment);
108 UpdateReference(PreviousSegment);
109 UpdateReference(ClosedSegment);
110 }
111
112 double GetAxeMin() const
113 {
114 return AxisMin;
115 }
116
118 {
119 return ChainIndex;
120 }
121
123 {
124 ChainIndex = index;
125 }
126
127 bool IsInner() const
128 {
130 }
131
132 void SetInner()
133 {
135 }
136
137 FIdent GetId() const
138 {
139 return Id;
140 }
141
143 {
144 return Edge;
145 }
146
147 double GetLength() const
148 {
149 return Length;
150 }
151
156 {
157 return (USSPoints[ELimit::Start] + USSPoints[ELimit::End]) * 0.5;
158 }
159
164 {
165 double SegmentParamS = (EdgeParamU - Coordinates[ELimit::Start]) / (Coordinates[ELimit::End] - Coordinates[ELimit::Start]);
166 return USSPoints[ELimit::Start] + (USSPoints[ELimit::End] - USSPoints[ELimit::Start]) * SegmentParamS;
167 }
168
172 const FVector2d& GetExtemity(const ELimit Limit) const
173 {
174 return USSPoints[Limit];
175 }
176
177 double GetCoordinate(const ELimit Limit) const
178 {
179 return Coordinates[Limit];
180 }
181
182 bool IsForward() const
183 {
184 return (Coordinates[ELimit::End] - Coordinates[ELimit::Start]) >= 0;
185 }
186
191 {
192 double ReferenceSlope = ComputeSlope(USSPoints[ELimit::Start], USSPoints[ELimit::End]);
194 }
195
200 {
201 double ReferenceSlope = ComputeSlope(USSPoints[ELimit::Start], USSPoints[ELimit::End]);
203 }
204
208 double ComputeUnorientedSlopeOf(const FVector2d& Middle, const FVector2d& Projection) const
209 {
210 double ReferenceSlope = ComputeSlope(USSPoints[ELimit::Start], USSPoints[ELimit::End]);
212 }
213
217 double ComputeOrientedSlopeOf(const FVector2d& Middle, const FVector2d& Projection) const
218 {
219 double ReferenceSlope = ComputeSlope(USSPoints[ELimit::Start], USSPoints[ELimit::End]);
221 }
222
224 {
225 return NextSegment;
226 }
227
229 {
230 return PreviousSegment;
231 }
232
234 {
235 return ClosedSegment;
236 }
237
239 {
240 if (ClosedSegment->ClosedSegment == this)
241 {
242 ClosedSegment->ClosedSegment = nullptr;
243 }
244 ClosedSegment = nullptr;
245 SquareDistanceToClosedSegment = HUGE_VAL;
246 }
247
249 {
250 ClosedSegment = InSegmentA;
251 SquareDistanceToClosedSegment = InDistance;
252
253 if (InDistance < InSegmentA->SquareDistanceToClosedSegment)
254 {
255 InSegmentA->ClosedSegment = this;
256 InSegmentA->SquareDistanceToClosedSegment = InDistance;
257 }
258 }
259
261 {
262 return SquareDistanceToClosedSegment;
263 }
264
266 {
267 NextSegment = Segment;
268 Segment->SetPrevious(this);
269 }
270
271 double ComputeEdgeCoordinate(const double SegmentU) const
272 {
273 return Coordinates[ELimit::Start] + (Coordinates[ELimit::End] - Coordinates[ELimit::Start]) * SegmentU;
274 }
275
277 double ComputeDeltaU(const double DeltaLength) const
278 {
279 return FMath::Abs(Coordinates[ELimit::End] - Coordinates[ELimit::Start]) * DeltaLength / Length;
280 }
281
283 {
285 }
286
287private:
288 void SetPrevious(FEdgeSegment* Segment)
289 {
290 PreviousSegment = Segment;
291 }
292};
293}
294
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint32 FIdent
Definition Types.h:27
#define HUGE_VALUE
Definition Types.h:16
AUTORTFM_INFER constexpr auto Projection(Invocable0Type &&Invocable0, InvocableTypes &&... Invocables)
Definition Projection.h:108
Definition AndroidPlatformMisc.h:14
Definition UnrealString.h.inl:34
Definition EdgeSegment.h:22
void SetChainIndex(FIdent index)
Definition EdgeSegment.h:122
FTopologicalEdge * GetEdge() const
Definition EdgeSegment.h:142
FVector2d GetCenter() const
Definition EdgeSegment.h:155
FVector2d ProjectPoint(const FVector2d &PointToProject, double &SegmentU) const
Definition EdgeSegment.h:282
FIdent GetChainIndex() const
Definition EdgeSegment.h:117
double ComputeUnorientedSlopeOf(const FVector2d &Middle, const FVector2d &Projection) const
Definition EdgeSegment.h:208
double ComputeUnorientedSlopeOf(const FEdgeSegment *Segment) const
Definition EdgeSegment.h:190
bool IsForward() const
Definition EdgeSegment.h:182
void SetInner()
Definition EdgeSegment.h:132
void SetNext(FEdgeSegment *Segment)
Definition EdgeSegment.h:265
const FVector2d & GetExtemity(const ELimit Limit) const
Definition EdgeSegment.h:172
double ComputeDeltaU(const double DeltaLength) const
Definition EdgeSegment.h:277
double GetCoordinate(const ELimit Limit) const
Definition EdgeSegment.h:177
FEdgeSegment * GetNext() const
Definition EdgeSegment.h:223
FEdgeSegment * GetPrevious() const
Definition EdgeSegment.h:228
double ComputeEdgeCoordinate(const double SegmentU) const
Definition EdgeSegment.h:271
void ResetCloseData()
Definition EdgeSegment.h:238
double ComputeOrientedSlopeOf(const FVector2d &Middle, const FVector2d &Projection) const
Definition EdgeSegment.h:217
FIdent GetId() const
Definition EdgeSegment.h:137
virtual ~FEdgeSegment()=default
double GetLength() const
Definition EdgeSegment.h:147
double GetCloseSquareDistance() const
Definition EdgeSegment.h:260
double GetAxeMin() const
Definition EdgeSegment.h:112
bool IsInner() const
Definition EdgeSegment.h:127
void SetBoundarySegment(bool bInIsInnerLoop, FTopologicalEdge *InEdge, double InStartU, double InEndU, const FVector2d &InStartPoint, const FVector2d &InEndPoint)
Definition EdgeSegment.h:62
void SetCloseSegment(FEdgeSegment *InSegmentA, double InDistance)
Definition EdgeSegment.h:248
void UpdateReferences(TMap< int32, FEdgeSegment * > &Map)
Definition EdgeSegment.h:89
FVector2d ComputeEdgePoint(double EdgeParamU) const
Definition EdgeSegment.h:163
FEdgeSegment * GetCloseSegment() const
Definition EdgeSegment.h:233
double ComputeOrientedSlopeOf(const FEdgeSegment *Segment) const
Definition EdgeSegment.h:199
FEdgeSegment(const FEdgeSegment &Segment)=default
FEdgeSegment()
Definition EdgeSegment.h:45
Definition HaveStates.h:48
EHaveStates States
Definition HaveStates.h:50
Definition Boundary.h:248
void Set(const FVector2d &Point1, const FVector2d &Point2)
Definition Boundary.h:282
Definition TopologicalEdge.h:63
Definition CADEntity.cpp:23
double ComputeOrientedSlope(const FVector2d &StartPoint, const FVector2d &EndPoint, double ReferenceSlope)
Definition SlopeUtils.h:320
double ComputeSlope(const FVector2d &StartPoint, const FVector2d &EndPoint)
Definition SlopeUtils.h:180
double ComputeUnorientedSlope(const FVector2d &StartPoint, const FVector2d &EndPoint, double ReferenceSlope)
Definition SlopeUtils.h:337
@ Undefined
Definition GeoEnum.h:89
ELimit
Definition GeoEnum.h:99
@ End
Definition GeoEnum.h:101
@ Start
Definition GeoEnum.h:100
@ IsoV
Definition GeoEnum.h:68
@ IsoU
Definition GeoEnum.h:67
static UE_FORCEINLINE_HINT double Distance(const TVector2< double > &V1, const TVector2< double > &V2)
Definition Vector2D.h:941