UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Polyline.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
8#include "UI/Display.h"
9
11
12namespace UE::CADKernel
13{
14
15template<class PointType>
17{
18public:
19
24 bool bWithTangent = false;
25
26
33
39
44
46 {
47 Ar << Points;
48 Ar << Coordinates;
49 }
50
51 PointType ApproximatePoint(double InCoordinate) const
52 {
53 return Approximator.ApproximatePoint(InCoordinate);
54 }
55
60
65
70 {
71 Approximator.UpdateSubPolylineBBox(InBoundary, OutBBox);
72 }
73
74 void Sample(const FLinearBoundary& Boundary, const double DesiredSegmentLength, TArray<double>& OutCoordinates) const
75 {
76 Approximator.SamplePolyline(Boundary, DesiredSegmentLength, OutCoordinates);
77 }
78
79 double GetCoordinateOfProjectedPoint(const FLinearBoundary& Boundary, const PointType& PointOnEdge, PointType& ProjectedPoint) const
80 {
81 return Approximator.ProjectPointToPolyline(Boundary, PointOnEdge, ProjectedPoint);
82 }
83
88
89 const PointType& GetPointAt(int32 Index) const
90 {
91 return Points[Index];
92 }
93
95 {
96 return Points;
97 }
98
100 {
101 return Coordinates;
102 }
103
105 {
106 return Coordinates;
107 }
108
118
119 void GetAt(int32 Index, double& Coordinate, PointType& Point)
120 {
122 Coordinate = Coordinates[Index];
123 Point = Points[Index];
124 }
125
129 int32 Size() const
130 {
131 return Points.Num();
132 }
133
144
150 void Empty(int32 Slack = 0)
151 {
152 Points.Empty(Slack);
153 Coordinates.Empty(Slack);
154 }
155
161
162
164 {
165 const int32 Count = Points.Num();
166
167 TBitArray<> Markers(true, Count);
168
169 for (int32 Index = Count - 1; Index >= 0; Index -= Offset)
170 {
171 Markers[Index] = false;
172 }
173
174 int32 CurrentIndex = 0;
175 for (int32 Index = 0; Index < Count; ++Index)
176 {
177 if (Markers[Index])
178 {
179 Coordinates[CurrentIndex] = Coordinates[Index];
180 Points[CurrentIndex] = Points[Index];
181 ++CurrentIndex;
182 }
183 }
184
186 Points.SetNum(CurrentIndex, EAllowShrinking::No);
187 }
188
194
196 {
197 return Approximator.ComputeLengthOfSubPolyline(InBoundary);
198 }
199};
200
202
203class FPolyline2D : public TPolyline<FVector2d>
204{
205public:
206
211 {
212 OutIntersections.Empty(8);
213
214 int32 UIndex = Iso == EIso::IsoU ? 0 : 1;
215 int32 VIndex = Iso == EIso::IsoU ? 1 : 0;
216
217 TFunction<void(const int32, const int32, const int32)> ComputeIntersection = [&](const int32 Index1, const int32& Index2, const int32 MinIndex)
218 {
219 if (IsoParameter > Points[Index1][UIndex] && IsoParameter <= Points[Index2][UIndex])
220 {
221 double Intersection = (IsoParameter - Points[Index1][UIndex]) / (Points[Index2][UIndex] - Points[Index1][UIndex]);
223 }
224 };
225
226 for (int32 Index = 1; Index < Points.Num(); ++Index)
227 {
229 {
230 if (Points[Index - 1][UIndex] < Points[Index][UIndex])
231 {
232 ComputeIntersection(Index - 1, Index, Index - 1);
233 }
234 else
235 {
236 ComputeIntersection(Index, Index - 1, Index - 1);
237 }
238 }
239 }
240 }
241};
242
243} // ns UE::CADKernel
244
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
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
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
void SetNum(SizeType NewNum, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:2308
UE_NODEBUG UE_FORCEINLINE_HINT bool IsValidIndex(SizeType Index) const
Definition Array.h:1122
ElementType Pop(EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:1196
UE_FORCEINLINE_HINT void EmplaceAt(SizeType Index, ArgsType &&... Args)
Definition Array.h:2665
void Empty(SizeType Slack=0)
Definition Array.h:2273
UE_FORCEINLINE_HINT void Reserve(SizeType Number)
Definition Array.h:3016
Definition AndroidPlatformMisc.h:14
Definition CADKernelArchive.h:19
Definition Polyline.h:204
void FindIntersectionsWithIso(const EIso Iso, double IsoParameter, TArray< double > &OutIntersections)
Definition Polyline.h:210
Definition PolylineTools.h:194
Definition Polyline.h:17
void GetSubPolyline(const FLinearBoundary &InBoundary, const EOrientation InOrientation, TArray< PointType > &OutPoints) const
Definition Polyline.h:61
TPolylineApproximator< PointType > Approximator
Definition Polyline.h:23
TPolyline(const TArray< PointType > &InPoints, const TArray< double > &InCoordinates)
Definition Polyline.h:27
const PointType & GetPointAt(int32 Index) const
Definition Polyline.h:89
void EmplaceAt(int32 Index, TPolyline< PointType > &Polyline, int32 PointIndex)
Definition Polyline.h:156
TArray< PointType > Points
Definition Polyline.h:21
const TArray< PointType > & GetPoints() const
Definition Polyline.h:94
int32 Size() const
Definition Polyline.h:129
TArray< double > Coordinates
Definition Polyline.h:20
bool bWithTangent
Definition Polyline.h:24
void Pop()
Definition Polyline.h:189
void Serialize(FCADKernelArchive &Ar)
Definition Polyline.h:45
TArray< PointType > Tangent
Definition Polyline.h:22
void Sample(const FLinearBoundary &Boundary, const double DesiredSegmentLength, TArray< double > &OutCoordinates) const
Definition Polyline.h:74
TPolyline(const TArray< PointType > &InPoints)
Definition Polyline.h:34
void GetAt(int32 Index, double &Coordinate, PointType &Point)
Definition Polyline.h:119
TPolyline()
Definition Polyline.h:40
void ApproximatePoints(const TArray< double > &InCoordinates, TArray< PointType > &OutPoints) const
Definition Polyline.h:56
double GetCoordinateOfProjectedPoint(const FLinearBoundary &Boundary, const PointType &PointOnEdge, PointType &ProjectedPoint) const
Definition Polyline.h:79
void Reserve(int32 Number)
Definition Polyline.h:139
void UpdateSubPolylineBBox(const FLinearBoundary &InBoundary, FPolylineBBox &OutBBox) const
Definition Polyline.h:69
const TArray< double > & GetCoordinates() const
Definition Polyline.h:99
TArray< double > & GetCoordinates()
Definition Polyline.h:104
double GetLength(const FLinearBoundary &InBoundary) const
Definition Polyline.h:195
void SwapCoordinates(TArray< double > &NewCoordinates)
Definition Polyline.h:109
PointType ApproximatePoint(double InCoordinate) const
Definition Polyline.h:51
void ProjectPoints(const FLinearBoundary &InBoundary, const TArray< PointType > &InPointsToProject, TArray< double > &ProjectedPointCoordinates, TArray< PointType > &ProjectedPoints) const
Definition Polyline.h:84
void Empty(int32 Slack=0)
Definition Polyline.h:150
void RemoveComplementaryPoints(int32 Offset)
Definition Polyline.h:163
PointType LinearInterpolation(const TArray< PointType > &Array, const int32 Index, const double Coordinate)
Definition PolylineTools.h:76
Definition CADEntity.cpp:23
TPolyline< FVector > FPolyline3D
Definition Polyline.h:201
EOrientation
Definition GeoEnum.h:82
EIso
Definition GeoEnum.h:66
@ IsoU
Definition GeoEnum.h:67
@ Iso
Definition Visu.h:20
@ Point
Definition Visu.h:17
U16 Index
Definition radfft.cpp:71
static UE_FORCEINLINE_HINT bool IsNearlyEqual(float A, float B, float ErrorTolerance=UE_SMALL_NUMBER)
Definition UnrealMathUtility.h:388
Definition Boundary.h:18
Definition PolylineTools.h:20