UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Criterion.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
5#include "Core/CADEntity.h"
6#include "Core/Types.h"
7#include "Geo/GeoPoint.h"
8#include "Math/Point.h"
10
11namespace UE::CADKernel
12{
13extern const TCHAR* CriterionTypeNames[];
14
15// Defined for Python purpose
16extern const char* CriterionTypeConstNames[];
17extern const char* CriterionTypeConstDescHelp[];
18
19class FTopologicalEdge;
20struct FCurvePoint;
21struct FIsoCurvature;
22
24{
25 friend class FEntity;
26
27protected:
28
29 FCriterion() = default;
30
31public:
32
33 virtual void Serialize(FCADKernelArchive& Ar) override
34 {
35 // Criterion's type is serialize because it is used to instantiate the correct entity on deserialization (@see Deserialize(FArchive& Archive))
36 if (Ar.IsSaving())
37 {
38 ECriterion CriterionType = GetCriterionType();
39 Ar << CriterionType;
40 }
41 FEntity::Serialize(Ar);
42 }
43
47 static TSharedPtr<FCriterion> Deserialize(FCADKernelArchive& Archive);
48
49 static TSharedPtr<FCriterion> CreateCriterion(ECriterion type, double value = 0.);
50
51#ifdef CADKERNEL_DEV
52 virtual FInfoEntity& GetInfo(FInfoEntity&) const override;
53#endif
54
55 virtual EEntity GetEntityType() const override
56 {
57 return EEntity::Criterion;
58 }
59
64 virtual void ApplyOnEdgeParameters(FTopologicalEdge& Edge, const TArray<double>& Coordinates, const TArray<FCurvePoint>& Points) const;
65
66 virtual ECriterion GetCriterionType() const = 0;
67
69 {
70 return CriterionTypeNames[(int32)GetCriterionType()];
71 }
72
73 virtual double Value() const = 0;
74
75 static double EvaluateSag(const FVector& PointPoint, const FVector& PointNext, const FVector& PointMiddle, double& Length)
76 {
79
80 double Sag = 0.0;
81 double NormSqrVec = ChordVec | ChordVec;
83
85 {
87 double NormSqrSag = VecSag | VecSag;
89
91 {
92 Sag = 0.;
93 }
94 else
95 {
96 Sag = sqrt(Sag);
97 }
98 }
99 return Sag;
100 }
101
102 virtual bool IsAppliedBetweenBreaks() const
103 {
104 return false;
105 }
106
111
112
113 static double DefaultValue(ECriterion type);
114
125 virtual void UpdateDelta(double InDeltaU, double InUSag, double InDiagonalSag, double InVSag, double ChordLength, double DiagonalLength, double& OutDeltaUMax, double& OutDeltaUMin, FIsoCurvature& SurfaceCurvature) const
126 {
127 // the component according to U of the sag along the diagonal = (diagonal sag - V Sag) * U Length / diag length
128 const double DiagonalSagU = FMath::Abs(InDiagonalSag - InVSag) * ChordLength / DiagonalLength;
129 InUSag = FMath::Max(InUSag, DiagonalSagU);
130
132 {
133 const double CriterionDeltaUMax = ComputeDeltaU(ChordLength, InDeltaU, InUSag);
134 UpdateWithUMaxValue(CriterionDeltaUMax, OutDeltaUMax, OutDeltaUMin);
135 }
136 }
137
138protected:
139
140 virtual double ComputeDeltaU(double ChordLength, double DeltaU, double Sag) const
141 {
142 ensureCADKernel(false);
143 return 0.0;
144 };
145
149 void UpdateWithUMaxValue(double NewMaxValue, double& OutDeltaUMax, const double& OutDeltaUMin) const
150 {
152 {
154 {
156 }
157 else
158 {
160 }
161 }
162 }
163
169 void UpdateWithUMinValue(double NewMinValue, double& OutDeltaUMax, double& OutDeltaUMin) const
170 {
172 {
174 }
176 {
178 }
179 }
180};
181
182} // namespace UE::CADKernel
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
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
#define SMALL_NUMBER_SQUARE
Definition Types.h:10
#define DOUBLE_SMALL_NUMBER
Definition UnrealMathUtility.h:72
Definition Array.h:670
Definition SharedPointer.h:692
Definition CADKernelArchive.h:19
bool IsSaving() const
Definition CADKernelArchive.h:113
Definition Criterion.h:24
static double EvaluateSag(const FVector &PointPoint, const FVector &PointNext, const FVector &PointMiddle, double &Length)
Definition Criterion.h:75
virtual void UpdateDelta(double InDeltaU, double InUSag, double InDiagonalSag, double InVSag, double ChordLength, double DiagonalLength, double &OutDeltaUMax, double &OutDeltaUMin, FIsoCurvature &SurfaceCurvature) const
Definition Criterion.h:125
virtual ECriterion GetCriterionType() const =0
virtual double ComputeDeltaU(double ChordLength, double DeltaU, double Sag) const
Definition Criterion.h:140
FString GetCriterionName()
Definition Criterion.h:68
virtual double Value() const =0
void UpdateWithUMinValue(double NewMinValue, double &OutDeltaUMax, double &OutDeltaUMin) const
Definition Criterion.h:169
virtual EEntity GetEntityType() const override
Definition Criterion.h:55
virtual void Serialize(FCADKernelArchive &Ar) override
Definition Criterion.h:33
virtual bool IsAppliedBetweenBreaks() const
Definition Criterion.h:102
static FString GetCriterionName(ECriterion CriterionType)
Definition Criterion.h:107
void UpdateWithUMaxValue(double NewMaxValue, double &OutDeltaUMax, const double &OutDeltaUMin) const
Definition Criterion.h:149
Definition CADEntity.h:56
Definition TopologicalEdge.h:63
Definition CADEntity.cpp:23
ECriterion
Definition CriterionType.h:9
const char * CriterionTypeConstDescHelp[]
Definition Criterion.cpp:147
const TCHAR * CriterionTypeNames[]
Definition Criterion.cpp:125
const char * CriterionTypeConstNames[]
Definition Criterion.cpp:136
EEntity
Definition CADEntity.h:18
Definition Curvature.h:10