UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IntersectionIsoSegmentTool.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"
6#include "Math/Boundary.h"
7#include "UI/Visu.h"
8
9namespace UE::CADKernel
10{
11class FGrid;
12class FIsoNode;
13
14namespace IntersectionIsoSegmentTool
15{
16
18{
19private:
20 const FVector2d& Point0;
21 const FVector2d& Point1;
22 double IsoCoordinate;
23 double MinCoordinate;
24 double MaxCoordinate;
25
26public:
27
28 FIntersectionIsoSegment(const FVector2d& StartPoint, const FVector2d& EndPoint, const double InIsoCoordinate, const double InStartCoordinate, const double InEndCoordinate)
29 : Point0(StartPoint)
30 , Point1(EndPoint)
31 , IsoCoordinate(InIsoCoordinate)
32 , MinCoordinate(FMath::Min(InStartCoordinate, InEndCoordinate))
33 , MaxCoordinate(FMath::Max(InStartCoordinate, InEndCoordinate))
34 {}
35
37 {}
38
39 virtual FVector2d GetMinPoint() const = 0;
40 virtual FVector2d GetMaxPoint() const = 0;
41
42 double GetIsoCoordinate() const
43 {
44 return IsoCoordinate;
45 }
46
47 double GetMinCoordinate() const
48 {
49 return MinCoordinate;
50 }
51
52 double GetMaxCoordinate() const
53 {
54 return MaxCoordinate;
55 }
56
58 {
59 return FSegment2D(Point0, Point1);
60 }
61
63 {
64 if (FMath::IsNearlyEqual(A.IsoCoordinate, B.IsoCoordinate))
65 {
66 return A.MinCoordinate < B.MinCoordinate;
67 }
68 else
69 {
70 return A.IsoCoordinate < B.IsoCoordinate;
71 }
72 }
73};
74
76{
77public:
78 FIsoUSegment(const FVector2d& StartPoint, const FVector2d& EndPoint)
79 : FIntersectionIsoSegment(StartPoint, EndPoint, StartPoint.X, StartPoint.Y, EndPoint.Y)
80 {}
81
82 virtual FVector2d GetMinPoint() const override
83 {
85 }
86 virtual FVector2d GetMaxPoint() const override
87 {
89 }
90};
91
93{
94public:
95 FIsoVSegment(const FVector2d& StartPoint, const FVector2d& EndPoint)
96 : FIntersectionIsoSegment(StartPoint, EndPoint, StartPoint.Y, StartPoint.X, EndPoint.X)
97 {}
98
99 virtual FVector2d GetMinPoint() const override
100 {
102 }
103
104 virtual FVector2d GetMaxPoint() const override
105 {
107 }
108
109};
110
111}
112
114{
115private:
116 const FGrid& Grid;
117
118 TArray<TPair<double, int32>> CoordToIndex[2];
119
122
123 bool bIsSorted = false;
124
125public:
126 FIntersectionIsoSegmentTool(const FGrid& InGrid, const double Tolerance);
127
128 void AddIsoSegment(const FVector2d& StartPoint, const FVector2d& EndPoint, const ESegmentType InType);
129
130 bool DoesIntersect(const FIsoNode& StartNode, const FIsoNode& EndNode) const;
131
132 int32 CountIntersections(const FIsoNode& StartNode, const FIsoNode& EndNode) const;
133
134 void Sort();
135
136private:
137 int32 GetStartIndex(EIso Iso, double Min) const;
138 int32 GetStartIndex(EIso Iso, const FSurfacicBoundary& Boundary) const;
139
140public:
141#ifdef CADKERNEL_DEBUG
142 void Display(bool bDisplay, const TCHAR* Message, EVisuProperty Property = EVisuProperty::BlueCurve) const;
143#endif
144};
145
146} // namespace UE::CADKernel
147
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
DIRECTLINK_API Display
Definition DirectLinkLog.h:8
#define X(Name, Desc)
Definition FormatStringSan.h:47
UE::Math::TVector2< double > FVector2d
Definition MathFwd.h:61
Definition Array.h:670
Definition Grid.h:46
Definition IntersectionIsoSegmentTool.h:114
int32 CountIntersections(const FIsoNode &StartNode, const FIsoNode &EndNode) const
Definition IntersectionIsoSegmentTool.cpp:140
void Sort()
Definition IntersectionIsoSegmentTool.cpp:216
bool DoesIntersect(const FIsoNode &StartNode, const FIsoNode &EndNode) const
Definition IntersectionIsoSegmentTool.cpp:151
void AddIsoSegment(const FVector2d &StartPoint, const FVector2d &EndPoint, const ESegmentType InType)
Definition IntersectionIsoSegmentTool.cpp:29
Definition IsoNode.h:62
Definition Boundary.h:248
virtual ~FIntersectionIsoSegment()
Definition IntersectionIsoSegmentTool.h:36
friend bool operator<(const FIntersectionIsoSegment &A, const FIntersectionIsoSegment &B)
Definition IntersectionIsoSegmentTool.h:62
double GetMaxCoordinate() const
Definition IntersectionIsoSegmentTool.h:52
FIntersectionIsoSegment(const FVector2d &StartPoint, const FVector2d &EndPoint, const double InIsoCoordinate, const double InStartCoordinate, const double InEndCoordinate)
Definition IntersectionIsoSegmentTool.h:28
double GetMinCoordinate() const
Definition IntersectionIsoSegmentTool.h:47
double GetIsoCoordinate() const
Definition IntersectionIsoSegmentTool.h:42
FSegment2D GetSegment2D() const
Definition IntersectionIsoSegmentTool.h:57
Definition IntersectionIsoSegmentTool.h:76
FIsoUSegment(const FVector2d &StartPoint, const FVector2d &EndPoint)
Definition IntersectionIsoSegmentTool.h:78
virtual FVector2d GetMaxPoint() const override
Definition IntersectionIsoSegmentTool.h:86
virtual FVector2d GetMinPoint() const override
Definition IntersectionIsoSegmentTool.h:82
Definition IntersectionIsoSegmentTool.h:93
virtual FVector2d GetMinPoint() const override
Definition IntersectionIsoSegmentTool.h:99
FIsoVSegment(const FVector2d &StartPoint, const FVector2d &EndPoint)
Definition IntersectionIsoSegmentTool.h:95
virtual FVector2d GetMaxPoint() const override
Definition IntersectionIsoSegmentTool.h:104
Definition CADEntity.cpp:23
ESegmentType
Definition IsoSegment.h:12
TSegment< FVector2d > FSegment2D
Definition Geometry.h:286
EIso
Definition GeoEnum.h:66
EVisuProperty
Definition Visu.h:15
@ BlueCurve
Definition Visu.h:31
@ Iso
Definition Visu.h:20
Definition UnrealMathUtility.h:270
static UE_FORCEINLINE_HINT bool IsNearlyEqual(float A, float B, float ErrorTolerance=UE_SMALL_NUMBER)
Definition UnrealMathUtility.h:388
Definition Geometry.h:250