UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FaceAnalyzer.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "Core/Chrono.h"
5#include "Core/HaveStates.h"
6#include "Core/Factory.h"
7#include "Core/Types.h"
8#include "Math/Point.h"
9#include "Math/Geometry.h"
10
11
12//#define DEBUG_THIN_FACE
13//#define DISPLAY_THIN_FACE // to display found thin zone
14
15
16namespace UE::CADKernel
17{
18class FTopologicalFace;
19class FTopologicalEdge;
20class FTopologicalLoop;
21
22namespace Topo
23{
24
31
33{
34private:
35 const FTopologicalEdge* Edge = nullptr;
36 double Coordinates[2] = {0. ,0.};
37 FVector Points[2];
38 FVector Middle;
39 FVector Vector;
40
41 FEdgeSegment* ClosedSegment = nullptr;
42
43 double MiddleAxis = 0.;
44 double SquareDistanceToClosedSegment = 0.;
45
46 double Length;
47
48 bool bIsThinZone = false;
49
50#ifdef CADKERNEL_DEV
51 FIdent Id;
52 static FIdent LastId;
53#endif
54
55public:
56 FEdgeSegment() = default;
57
58 virtual ~FEdgeSegment() = default;
59
61 {
62 Edge = InEdge;
63 Coordinates[ELimit::Start] = InStartU;
64 Coordinates[ELimit::End] = InEndU;
66 Points[ELimit::End] = InEndPoint;
67 Middle = (Points[ELimit::Start] + Points[ELimit::End]) * 0.5;
68 Vector = Points[ELimit::End] - Points[ELimit::Start];
69
70 ClosedSegment = nullptr;
71
72 SquareDistanceToClosedSegment = -1.;
73 Length = FVector::Distance(Points[ELimit::Start], Points[ELimit::End]);
74
75 MiddleAxis = FVectorUtil::DiagonalAxisCoordinate(Middle);
76
77#ifdef CADKERNEL_DEV
78 Id = LastId++;
79#endif
80 };
81
82 const FVector GetVector() const
83 {
84 return Vector;
85 }
86
87#ifdef CADKERNEL_DEV
88 FIdent GetId() const
89 {
90 return Id;
91 }
92#endif
93
95 {
96 return Edge;
97 }
98
99 double GetLength() const
100 {
101 return Length;
102 }
103
105 {
106 return Middle;
107 }
108
109 constexpr const FVector& GetExtemity(const ELimit Limit) const
110 {
111 return Points[Limit];
112 }
113
114 constexpr double GetCoordinate(const ELimit Limit) const
115 {
116 return Coordinates[Limit];
117 }
118
123 {
124 return FVectorUtil::ComputeCosinus(GetVector() , Segment->GetVector());
125 }
126
128 {
129 return ClosedSegment;
130 }
131
133 {
134 ClosedSegment = InSegmentA;
135 SquareDistanceToClosedSegment = InSquareDistance;
136 }
137
139 {
140 return SquareDistanceToClosedSegment;
141 }
142
147
149 {
150 return bIsThinZone;
151 }
152
154 {
155 bIsThinZone = true;
156 }
157};
158
179
180}
181
183{
184
185public:
187
188protected:
189 const double Tolerance;
190 const double SquareTolerance;
192
194
195public:
196
204
205 bool IsThinFace(double& OutGapSize);
206
207private:
208
209 void BuildLoopSegments(Topo::FThinFaceContext& Context);
210 void FindClosedSegments(Topo::FThinFaceContext& Context);
211 void Analyze(Topo::FThinFaceContext& Context);
212
213#ifdef CADKERNEL_DEV
216#endif
217};
218}
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint32 FIdent
Definition Types.h:27
#define Square(a, x, y)
Definition Predicates.inl:251
Definition Array.h:670
Definition FaceAnalyzer.h:183
FTopologicalFace & Face
Definition FaceAnalyzer.h:193
const double MaxOppositSideLength
Definition FaceAnalyzer.h:191
FFaceAnalyzer(FTopologicalFace &InFace, double InTol)
Definition FaceAnalyzer.h:197
const double Tolerance
Definition FaceAnalyzer.h:189
bool IsThinFace(double &OutGapSize)
Definition FaceAnalyzer.cpp:242
const double SquareTolerance
Definition FaceAnalyzer.h:190
Topo::FFaceAnalyzerChronos Chronos
Definition FaceAnalyzer.h:186
Definition HaveStates.h:48
Definition TopologicalEdge.h:63
Definition TopologicalFace.h:56
Definition TopologicalLoop.h:60
static double DiagonalAxisCoordinate(const FVector &Vec)
Definition Point.h:53
static double ComputeCosinus(const VectorType &Vec1, const VectorType &Vec2)
Definition Point.h:24
Definition Factory.h:18
Definition FaceAnalyzer.h:33
FEdgeSegment * GetClosedSegment() const
Definition FaceAnalyzer.h:127
FVector GetMiddle() const
Definition FaceAnalyzer.h:104
void SetClosedSegment(FEdgeSegment *InSegmentA, double InSquareDistance)
Definition FaceAnalyzer.h:132
constexpr const FVector & GetExtemity(const ELimit Limit) const
Definition FaceAnalyzer.h:109
void SetBoundarySegment(const FTopologicalEdge *InEdge, double InStartU, double InEndU, const FVector &InStartPoint, const FVector &InEndPoint)
Definition FaceAnalyzer.h:60
FVector ProjectPoint(const FVector &PointToProject, double &SegmentU) const
Definition FaceAnalyzer.h:143
constexpr double GetCoordinate(const ELimit Limit) const
Definition FaceAnalyzer.h:114
double ComputeCosAngleOf(const FEdgeSegment *Segment)
Definition FaceAnalyzer.h:122
const FVector GetVector() const
Definition FaceAnalyzer.h:82
double GetClosedSquareDistance() const
Definition FaceAnalyzer.h:138
const FTopologicalEdge * GetEdge() const
Definition FaceAnalyzer.h:94
bool IsThinZone()
Definition FaceAnalyzer.h:148
double GetLength() const
Definition FaceAnalyzer.h:99
void SetAsThinZone()
Definition FaceAnalyzer.h:153
Definition CADEntity.cpp:23
uint64 FDuration
Definition Chrono.h:27
ELimit
Definition GeoEnum.h:99
@ End
Definition GeoEnum.h:101
@ Start
Definition GeoEnum.h:100
Definition UnrealMathUtility.h:270
Definition FaceAnalyzer.h:26
FDuration FindClosedSegmentTime
Definition FaceAnalyzer.h:28
FDuration BuildLoopSegmentsTime
Definition FaceAnalyzer.h:27
FDuration AnalyzeClosedSegmentTime
Definition FaceAnalyzer.h:29
Definition FaceAnalyzer.h:160
TArray< double > EdgeMaxSquareDistance
Definition FaceAnalyzer.h:168
TFactory< Topo::FEdgeSegment > SegmentFatory
Definition FaceAnalyzer.h:165
FThinFaceContext(const FTopologicalLoop &InLoop)
Definition FaceAnalyzer.h:174
const FTopologicalLoop & Loop
Definition FaceAnalyzer.h:161
double OppositSideEdgeLength
Definition FaceAnalyzer.h:172
double ExternalLoopLength
Definition FaceAnalyzer.h:164
double ThinSideEdgeLength
Definition FaceAnalyzer.h:171
double MaxSquareDistance
Definition FaceAnalyzer.h:170
TArray< double > EdgeSquareDistance
Definition FaceAnalyzer.h:167
TArray< Topo::FEdgeSegment * > LoopSegments
Definition FaceAnalyzer.h:163
static UE_FORCEINLINE_HINT double Distance(const TVector< double > &V1, const TVector< double > &V2)
Definition Vector.h:1018