UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SamplerOnChord.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#include "Geo/GeoEnum.h"
7#include "Geo/Curves/Curve.h"
11#include "Math/Boundary.h"
12#include "Math/Point.h"
13#include "Utils/ArrayUtils.h"
14
15//#define DEBUG_CHECKCHORDERROR
16
17namespace UE::CADKernel
18{
19
20template<class PointType>
21class TSamplerBasedOnChordError : public TCurveSamplerAbstract<TPolyline<PointType>, PointType>
22{
23public:
28
29protected:
30
49 virtual int32 CheckSamplingError(int32 FirstIndex, int32 EndIndex) override
50 {
51 const PointType& APoint = this->Sampling.Points[this->StartSamplingSegmentIndex];
52 double ACoordinate = this->Sampling.Coordinates[this->StartSamplingSegmentIndex];
53
54 const PointType& BPoint = this->EndStudySegment.Polyline->Points[this->EndStudySegment.Index];
55 double BCoordinate = this->EndStudySegment.Polyline->Coordinates[this->EndStudySegment.Index];
56
57 double MaxChord = 0;
58 for (int32 Index = FirstIndex; Index < EndIndex; ++Index)
59 {
60 const PointType& Middle = this->CandidatePoints.GetPointAt(Index);
61 double Chord = DistanceOfPointToSegment<PointType>(Middle, APoint, BPoint);
62 if (Chord > MaxChord)
63 {
64 MaxChord = Chord;
65 }
66
67 if (MaxChord > this->DesiredChordError)
68 {
69 break;
70 }
71 }
72
73#ifdef DEBUG_CHECKCHORDERROR
74 if (bDisplay)
75 {
76 {
77 int32 Index = 0;
78 F3DDebugSession G(FString::Printf(TEXT("CheckChord %f %d"), MaxChord, FirstIndex));
79
82
83 for (int32 Index = FirstIndex; Index < EndIndex; ++Index)
84 {
85 const PointType& Middle = CandidatePoints.GetPoints()[Index];
87 }
88
92
93 for (int32 Index = FirstIndex; Index < EndIndex - 1; ++Index)
94 {
96 }
97 }
98 }
99#endif
100
102 {
103 // S2 = S1 * sqare(L2 / L1)
104 // if the length is doubled, the chord error is still smaller than the desired chord error.
105 // the end point is not needed
106 return 0;
107 }
109 {
110 // the end point is needed because the Chord is smaller but nearly equal to the desired chord error.
111 return 1;
112 }
114 {
115 // if the length is divided by two, the chord error is divided by 4 and becomes smaller than the desired chord error.
116 // Add First index and Index
117 return this->CheckTangentError(APoint, ACoordinate, BPoint, BCoordinate, FirstIndex, EndIndex, this->StartSamplingSegmentIndex);
118 }
119 else
120 {
122 }
123 };
124#ifdef DEBUG_CHECKCHORDERROR
125 bool bDisplay = true;
126#endif
127};
128
156
181
183{
184public:
190
198
199protected:
200
203 bool bNotDerivableFound = false;
204
207
221
222 virtual void EvaluatesNewCandidatePoints() override
223 {
225 {
227
232
233 Swap(CandidatePoints.Points, PointGrid.Points3D);
234 };
235
236 if (CandidatePoints.Coordinates.Num() > 0)
237 {
238 if (IsoType == EIso::IsoU)
239 {
241 }
242 else
243 {
245 }
246 }
247 else
248 {
249 CandidatePoints.Points.SetNum(0);
250 }
251 }
252
253};
254
255} // ns UE::CADKernel
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define TEXT(x)
Definition Platform.h:1272
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_NODEBUG UE_FORCEINLINE_HINT SizeType Add(ElementType &&Item)
Definition Array.h:2696
void Empty(SizeType Slack=0)
Definition Array.h:2273
Definition AndroidPlatformMisc.h:14
Definition Display.h:62
Definition SamplerOnChord.h:158
virtual void EvaluatesNewCandidatePoints() override
Definition SamplerOnChord.h:170
FCurve2DSamplerOnChord(const FCurve &InCurve, const FLinearBoundary &InBoundary, double InMaxAllowedError, FPolyline2D &OutPolyline)
Definition SamplerOnChord.h:160
virtual void GetNotDerivableCoordinates(TArray< double > &OutNotDerivableCoordinates) override
Definition SamplerOnChord.h:175
const FCurve & Curve
Definition SamplerOnChord.h:168
Definition SamplerOnChord.h:133
virtual void GetNotDerivableCoordinates(TArray< double > &OutNotDerivableCoordinates) override
Definition SamplerOnChord.h:150
virtual void EvaluatesNewCandidatePoints() override
Definition SamplerOnChord.h:145
FCurveSamplerOnChord(const FCurve &InCurve, const FLinearBoundary &InBoundary, double InMaxAllowedError, FPolyline3D &OutPolyline)
Definition SamplerOnChord.h:135
const FCurve & Curve
Definition SamplerOnChord.h:143
Definition Curve.h:21
virtual void EvaluatePoints(const TArray< double > &Coordinates, TArray< FCurvePoint > &OutPoints, int32 DerivativeOrder=0) const
Definition Curve.cpp:35
void FindNotDerivableCoordinates(int32 DerivativeOrder, TArray< double > &OutNotDerivableCoordinates) const
Definition Curve.h:190
virtual void Evaluate2DPoints(const TArray< double > &Coordinates, TArray< FVector2d > &OutPoints) const
Definition Curve.cpp:68
Definition SamplerOnChord.h:183
FIsoCurve3DSamplerOnChord(const FSurface &InSurface, double InMaxAllowedError, FPolyline3D &OutPolyline)
Definition SamplerOnChord.h:185
FCoordinateGrid NotDerivableCoordinates
Definition SamplerOnChord.h:202
TArray< double > IsoCoordinate
Definition SamplerOnChord.h:205
EIso IsoType
Definition SamplerOnChord.h:206
bool bNotDerivableFound
Definition SamplerOnChord.h:203
const FSurface & Surface
Definition SamplerOnChord.h:201
void Set(EIso InIsoType, double InIsoCoordinate, const FLinearBoundary &CurveBounds)
Definition SamplerOnChord.h:191
virtual void GetNotDerivableCoordinates(TArray< double > &OutNotDerivableCoordinates) override
Definition SamplerOnChord.h:208
virtual void EvaluatesNewCandidatePoints() override
Definition SamplerOnChord.h:222
Definition Polyline.h:204
Definition Surface.h:27
const FSurfacicBoundary & GetBoundary() const
Definition Surface.h:128
virtual void EvaluatePointGrid(const FCoordinateGrid &Coordinates, FSurfacicSampling &OutPoints, bool bComputeNormals=false) const
Definition Surface.cpp:170
virtual void LinesNotDerivables(const FSurfacicBoundary &Bounds, int32 InDerivativeOrder, FCoordinateGrid &OutNotDerivableCoordinates) const
Definition Surface.h:242
double GetIsoTolerance(EIso Iso) const
Definition Surface.h:164
Definition SamplerAbstract.h:20
TSamplingPoint EndStudySegment
Definition SamplerAbstract.h:409
TPolyline< PointType > & Sampling
Definition SamplerAbstract.h:384
FLinearBoundary Boundary
Definition SamplerAbstract.h:381
int32 CheckTangentError(const PointType &APoint, double ACoordinate, const PointType &BPoint, double BCoordinate, int32 FirstIndex, int32 EndIndex, int32 InStartSamplingSegmentIndex)
Definition SamplerAbstract.h:334
int32 CountOfNeededPointsToRespectChordError(const PointType &PointA, const PointType &PointB, double ChordError)
Definition SamplerAbstract.h:326
TPolyline< PointType > CandidatePoints
Definition SamplerAbstract.h:386
Definition Polyline.h:17
Definition SamplerOnChord.h:22
TSamplerBasedOnChordError(const FLinearBoundary &InBoundary, double InMaxAllowedError, TPolyline< PointType > &OutPolyline)
Definition SamplerOnChord.h:24
virtual int32 CheckSamplingError(int32 FirstIndex, int32 EndIndex) override
Definition SamplerOnChord.h:49
void SubArrayWithoutBoundary(const TArray< double > &InitialArray, const FLinearBoundary &Boundary, double Tolerance, TArray< double > &OutArray)
Definition ArrayUtils.h:154
Definition CADEntity.cpp:23
void Display(const FPlane &Plane, FIdent Ident)
Definition Display.cpp:350
void DisplaySegment(const FVector &Point1, const FVector &Point2, FIdent Ident, EVisuProperty Property)
Definition Display.cpp:1268
EIso
Definition GeoEnum.h:66
@ IsoV
Definition GeoEnum.h:68
@ IsoU
Definition GeoEnum.h:67
@ YellowCurve
Definition Visu.h:29
@ BluePoint
Definition Visu.h:30
@ YellowPoint
Definition Visu.h:28
@ BlueCurve
Definition Visu.h:31
U16 Index
Definition radfft.cpp:71
Definition GeoPoint.h:103
void Swap(TArray< double > &InUCoordinates, TArray< double > &InVCoordinates)
Definition GeoPoint.h:116
Definition Boundary.h:18
Definition SurfacicSampling.h:14