UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SegmentCurve.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "Geo/Curves/Curve.h"
5#include "Geo/GeoEnum.h"
6
7namespace UE::CADKernel
8{
9
11{
12 friend class FEntity;
13
14protected:
17
20 , StartPoint(InStartPoint)
21 , EndPoint(InEndPoint)
22 {
23 }
24
27 , StartPoint(InStartPoint, 0.)
28 , EndPoint(InEndPoint, 0.)
29 {
30 }
31
32 FSegmentCurve() = default;
33
34public:
35
36 virtual void Serialize(FCADKernelArchive& Ar) override
37 {
38 FCurve::Serialize(Ar);
39 Ar << StartPoint;
40 Ar << EndPoint;
41 }
42
43#ifdef CADKERNEL_DEV
44 virtual FInfoEntity& GetInfo(FInfoEntity&) const override;
45#endif
46
47 virtual ECurve GetCurveType() const override
48 {
49 return ECurve::Segment;
50 }
51
52 virtual TSharedPtr<FEntityGeom> ApplyMatrix(const FMatrixH& InMatrix) const override;
53 virtual void Offset(const FVector& OffsetDirection) override;
54
55 virtual void EvaluatePoint(double Coordinate, FCurvePoint& OutPoint, int32 DerivativeOrder = 0) const override
56 {
58 Evaluate<FCurvePoint, FVector>(Coordinate, OutPoint, DerivativeOrder);
59 }
60
61 virtual void Evaluate2DPoint(double Coordinate, FCurvePoint2D& OutPoint, int32 DerivativeOrder = 0) const override
62 {
64 Evaluate<FCurvePoint2D, FVector2d>(Coordinate, OutPoint, DerivativeOrder);
65 }
66
67 const FVector& GetStartPoint() const
68 {
69 return StartPoint;
70 }
71
72 const FVector& GetEndPoint() const
73 {
74 return EndPoint;
75 }
76
77 virtual void ExtendTo(const FVector& DesiredPosition) override
78 {
82 {
83 EndPoint = DesiredPosition;
84 }
85 else
86 {
87 StartPoint = DesiredPosition;
88 }
89 }
90
91private:
92 void GetTangent(FVector& Tangent) const
93 {
94 Tangent = EndPoint - StartPoint;
95 }
96
97 void GetTangent(FVector2d& Tangent) const
98 {
99 Tangent = FVector2d(EndPoint.X - StartPoint.X, EndPoint.Y - StartPoint.Y);
100 }
101
102 template <typename CurvePointType, typename PointType>
103 void Evaluate(double Coordinate, CurvePointType& OutPoint, int32 DerivativeOrder) const
104 {
105 OutPoint.DerivativeOrder = DerivativeOrder;
106
107 PointType Tangent;
108 GetTangent(Tangent);
109
110 OutPoint.Point = Tangent * Coordinate + PointType(StartPoint);
111
112 if (DerivativeOrder > 0)
113 {
114 OutPoint.Gradient = MoveTemp(Tangent);
115 }
116 }
117
118};
119
120} // namespace UE::CADKernel
121
FPlatformTypes::int8 int8
An 8-bit signed integer.
Definition Platform.h:1121
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
UE::Math::TVector2< double > FVector2d
Definition MathFwd.h:61
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32 Offset
Definition VulkanMemory.cpp:4033
Definition SharedPointer.h:692
Definition CADKernelArchive.h:19
Definition Curve.h:21
Definition CADEntity.h:56
Definition MatrixH.h:14
Definition SegmentCurve.h:11
FSegmentCurve(const FVector2d &InStartPoint, const FVector2d &InEndPoint, int8 InDimension=3)
Definition SegmentCurve.h:25
virtual void ExtendTo(const FVector &DesiredPosition) override
Definition SegmentCurve.h:77
FVector StartPoint
Definition SegmentCurve.h:15
const FVector & GetStartPoint() const
Definition SegmentCurve.h:67
FVector EndPoint
Definition SegmentCurve.h:16
const FVector & GetEndPoint() const
Definition SegmentCurve.h:72
virtual void Serialize(FCADKernelArchive &Ar) override
Definition SegmentCurve.h:36
virtual ECurve GetCurveType() const override
Definition SegmentCurve.h:47
virtual void Evaluate2DPoint(double Coordinate, FCurvePoint2D &OutPoint, int32 DerivativeOrder=0) const override
Definition SegmentCurve.h:61
FSegmentCurve(const FVector &InStartPoint, const FVector &InEndPoint, int8 InDimension=3)
Definition SegmentCurve.h:18
virtual void EvaluatePoint(double Coordinate, FCurvePoint &OutPoint, int32 DerivativeOrder=0) const override
Definition SegmentCurve.h:55
Definition CADEntity.cpp:23
ECurve
Definition GeoEnum.h:10
Definition GeoPoint.h:11
Definition GeoPoint.h:50
T Y
Definition Vector.h:65
T X
Definition Vector.h:62
static UE_FORCEINLINE_HINT double DistSquared(const TVector< double > &V1, const TVector< double > &V2)
Definition Vector.h:2478