UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Aabb.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "Math/Point.h"
5
6
8{
9 XMax = 0x00000000u,
10 YMax = 0x00000000u,
11 ZMax = 0x00000000u,
12 XMin = 0x00000001u,
13 YMin = 0x00000002u,
14 ZMin = 0x00000004u,
15};
16
18
19namespace UE::CADKernel
20{
21template<class PointType, int Dimension = 3>
22class TAABB
23{
24
25protected:
26 PointType MinCorner;
27 PointType MaxCorner;
28
29public:
31 {
32 }
33
34 TAABB(const PointType& InMinCorner, const PointType& InMaxCorner)
37 {
38 }
39
40 friend FArchive& operator<<(FArchive& Ar, TAABB& AABB)
41 {
42 Ar << AABB.MinCorner;
43 Ar << AABB.MaxCorner;
44 return Ar;
45 }
46
47 bool IsValid() const
48 {
49 for (int32 Axis = 0; Axis < Dimension; Axis++)
50 {
52 {
53 return false;
54 }
55 }
56 return true;
57 }
58
59 void Empty()
60 {
61 }
62
63 bool Contains(const PointType& Point) const
64 {
65 for (int32 Axis = 0; Axis < Dimension; Axis++)
66 {
67 if ((Point[Axis] < MinCorner[Axis]) || (Point[Axis] > MaxCorner[Axis]))
68 {
69 return false;
70 }
71 }
72 return true;
73 }
74
75 void SetMinSize(double MinSize)
76 {
77 for (int32 Axis = 0; Axis < Dimension; Axis++)
78 {
79 double AxisSize = GetSize(Axis);
80 if (AxisSize < MinSize)
81 {
82 double Offset = (MinSize - AxisSize) / 2;
85 }
86 }
87 }
88
89 double GetMaxSize() const
90 {
91 double MaxSideSize = 0;
92 for (int32 Index = 0; Index < Dimension; Index++)
93 {
94 double Size = GetSize(Index);
95 if (Size > MaxSideSize)
96 {
98 }
99 }
100 return MaxSideSize;
101 }
102
103 double GetSize(int32 Axis) const
104 {
105 return MaxCorner[Axis] - MinCorner[Axis];
106 }
107
108 double DiagonalLength() const
109 {
110 return PointType::Distance(MaxCorner, MinCorner);
111 }
112
113 PointType Diagonal() const
114 {
115 return MaxCorner - MinCorner;
116 }
117
118 bool Contains(const TAABB& Aabb) const
119 {
120 return IsValid() && Aabb.IsValid() && Contains(Aabb.MinCorner) && Contains(Aabb.MaxCorner);
121 }
122
123 const PointType& GetMin() const
124 {
125 return MinCorner;
126 }
127
128 const PointType& GetMax() const
129 {
130 return MaxCorner;
131 }
132
133 TAABB& operator+= (const double* Point)
134 {
135 for (int32 Index = 0; Index < Dimension; Index++)
136 {
137 if (Point[Index] < MinCorner[Index])
138 {
140 }
141 if (Point[Index] > MaxCorner[Index])
142 {
144 }
145 }
146 return *this;
147 }
148
149 TAABB& operator+= (const PointType& Point)
150 {
151 for (int32 Index = 0; Index < Dimension; Index++)
152 {
153 if (Point[Index] < MinCorner[Index])
154 {
156 }
157 if (Point[Index] > MaxCorner[Index])
158 {
160 }
161 }
162 return *this;
163 }
164
165
167 {
168 for (const PointType& Point : Points)
169 {
170 *this += Point;
171 }
172 return *this;
173 }
174
175
176 void Offset(double Offset)
177 {
178 for (int32 Index = 0; Index < Dimension; Index++)
179 {
182 }
183 }
184
186 {
187 *this += aabb.MinCorner;
188 *this += aabb.MaxCorner;
189 return *this;
190 }
191
192 TAABB operator+ (const PointType& Point) const
193 {
194 TAABB Other = *this;
195 Other += Point;
196 return Other;
197 }
198
199
201 {
202 TAABB Other = *this;
203 Other += Aabb;
204 return Other;
205 }
206};
207
208template<>
210 : MinCorner(FVectorUtil::FarawayPoint2D)
211 , MaxCorner(-FVectorUtil::FarawayPoint2D)
212{
213}
214
215template<>
217 : MinCorner(FVectorUtil::FarawayPoint3D)
218 , MaxCorner(-FVectorUtil::FarawayPoint3D)
219{
220}
221
222template<>
224{
225 MinCorner = FVectorUtil::FarawayPoint2D;
226 MaxCorner = -FVectorUtil::FarawayPoint2D;
227}
228
229template<>
231{
232 MinCorner = FVectorUtil::FarawayPoint3D;
233 MaxCorner = -FVectorUtil::FarawayPoint3D;
234}
235
236
237class FAABB : public TAABB<FVector>
238{
239
240public:
242 : TAABB<FVector>()
243 {
244 }
245
250
251 FVector GetCorner(int32 Corner) const
252 {
253 return FVector(
254 Corner & EAABBBoundary::XMin ? MinCorner[0] : MaxCorner[0],
255 Corner & EAABBBoundary::YMin ? MinCorner[1] : MaxCorner[1],
256 Corner & EAABBBoundary::ZMin ? MinCorner[2] : MaxCorner[2]
257 );
258 }
259};
260
261class CADKERNEL_API FAABB2D : public TAABB<FVector2d, 2>
262{
263public:
265 : TAABB<FVector2d, 2>()
266 {
267 }
268
273
275 {
276 return FVector2d(
277 CornerIndex & EAABBBoundary::XMin ? MinCorner[0] : MaxCorner[0],
278 CornerIndex & EAABBBoundary::YMin ? MinCorner[1] : MaxCorner[1]
279 );
280 }
281
282};
283
284} // namespace UE::CADKernel
285
EAABBBoundary
Definition Aabb.h:8
@ XMax
Definition Aabb.h:9
@ ZMin
Definition Aabb.h:14
@ YMin
Definition Aabb.h:13
@ XMin
Definition Aabb.h:12
@ ZMax
Definition Aabb.h:11
@ YMax
Definition Aabb.h:10
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 ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
#define X(Name, Desc)
Definition FormatStringSan.h:47
#define FVector
Definition IOSSystemIncludes.h:8
UE::Math::TVector2< double > FVector2d
Definition MathFwd.h:61
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
Definition Array.h:670
Definition Aabb.h:262
FAABB2D()
Definition Aabb.h:264
FAABB2D(const FVector &InMinCorner, const FVector &InMaxCorner)
Definition Aabb.h:269
FVector2d GetCorner(int32 CornerIndex) const
Definition Aabb.h:274
Definition Aabb.h:238
FVector GetCorner(int32 Corner) const
Definition Aabb.h:251
FAABB(const FVector &InMinCorner, const FVector &InMaxCorner)
Definition Aabb.h:246
FAABB()
Definition Aabb.h:241
Definition Point.h:13
static CADKERNEL_API const FVector FarawayPoint3D
Definition Point.h:15
static CADKERNEL_API const FVector2d FarawayPoint2D
Definition Point.h:16
Definition Aabb.h:23
const PointType & GetMin() const
Definition Aabb.h:123
TAABB operator+(const PointType &Point) const
Definition Aabb.h:192
PointType Diagonal() const
Definition Aabb.h:113
bool IsValid() const
Definition Aabb.h:47
double GetMaxSize() const
Definition Aabb.h:89
PointType MinCorner
Definition Aabb.h:26
const PointType & GetMax() const
Definition Aabb.h:128
bool Contains(const PointType &Point) const
Definition Aabb.h:63
TAABB & operator+=(const double *Point)
Definition Aabb.h:133
TAABB(const PointType &InMinCorner, const PointType &InMaxCorner)
Definition Aabb.h:34
bool Contains(const TAABB &Aabb) const
Definition Aabb.h:118
double DiagonalLength() const
Definition Aabb.h:108
double GetSize(int32 Axis) const
Definition Aabb.h:103
PointType MaxCorner
Definition Aabb.h:27
friend FArchive & operator<<(FArchive &Ar, TAABB &AABB)
Definition Aabb.h:40
void Offset(double Offset)
Definition Aabb.h:176
void SetMinSize(double MinSize)
Definition Aabb.h:75
TAABB()
Definition Aabb.h:30
void Empty()
Definition Aabb.h:59
Definition CADEntity.cpp:23
@ Point
Definition Visu.h:17
U16 Index
Definition radfft.cpp:71