UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
GeometrySet3.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Async/ParallelFor.h"
6#include "BoxTypes.h"
7#include "Containers/Array.h"
8#include "Containers/Map.h"
9#include "Math/Ray.h"
10#include "Math/UnrealMathSSE.h"
11#include "Math/Vector.h"
12#include "Polyline3.h"
13#include "Templates/Function.h"
14#include "Templates/Invoke.h"
15
16namespace UE
17{
18namespace Geometry
19{
20
28{
29public:
34 GEOMETRYCORE_API void Reset(bool bPoints = true, bool bCurves = true);
35
37 GEOMETRYCORE_API void AddPoint(int PointID, const FVector3d& Position);
40
42 GEOMETRYCORE_API void RemovePoint(int PointID);
45
47 GEOMETRYCORE_API void UpdatePoint(int PointID, const FVector3d& Position);
50
74
75
84 TFunction<bool(const FVector3d&, const FVector3d&)> PointWithinToleranceTest) const;
85
96 TFunction<bool(const FVector3d&, const FVector3d&)> PointWithinToleranceTest) const;
97
106 TFunction<bool(const FVector3d&, const FVector3d&)> PointWithinToleranceTest) const;
107
118 TFunction<bool(const FVector3d&, const FVector3d&)> PointWithinToleranceTest) const;
119
127 template <typename PredicateType, typename IntContainerType>
129 {
130 PointIDsOut.Reset();
131 for (const FPoint& Point : Points)
132 {
133 if (Invoke(Predicate, Point.Position))
134 {
135 PointIDsOut.Add(Point.ID);
136 }
137 }
138 return !PointIDsOut.IsEmpty();
139 }
140
144 template <typename PredicateType, typename IntContainerType>
146 {
149 ParallelFor(Points.Num(), [this, &Predicate, &Flags](int32 i)
150 {
151 if (Invoke(Predicate, Points[i].Position))
152 {
153 Flags[i] = true;
154 }
155 });
156
157 for (int32 i = 0; i < Points.Num(); ++i)
158 {
159 if (Flags[i])
160 {
161 PointIDsOut.Add(Points[i].ID);
162 }
163 }
164 return !PointIDsOut.IsEmpty();
165 }
166
174 template <typename PredicateType, typename IntContainerType>
176 {
177 CurveIDsOut.Reset();
178 for (const FCurve& Curve : Curves)
179 {
180 if (Invoke(Predicate, Curve.Geometry))
181 {
182 CurveIDsOut.Add(Curve.ID);
183 }
184 }
185 return !CurveIDsOut.IsEmpty();
186 }
187
191 template <typename PredicateType, typename IntContainerType>
193 {
195 Flags.SetNumZeroed(Curves.Num());
196 ParallelFor(Curves.Num(), [this, &Predicate, &Flags](int32 i)
197 {
198 if (Invoke(Predicate, Curves[i].Geometry))
199 {
200 Flags[i] = true;
201 }
202 });
203
204 for (int32 i = 0; i < Curves.Num(); ++i)
205 {
206 if (Flags[i])
207 {
208 CurveIDsOut.Add(Curves[i].ID);
209 }
210 }
211 return !CurveIDsOut.IsEmpty();
212 }
213
214protected:
215
216 struct FPoint
217 {
218 int ID;
220 };
223
233
234};
235
236
237} // end namespace UE::Geometry
238} // end namespace UE
void ParallelFor(int32 Num, TFunctionRef< void(int32)> Body, bool bForceSingleThread, bool bPumpRenderingThread=false)
Definition ParallelFor.h:481
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
AUTORTFM_INFER UE_FORCEINLINE_HINT constexpr auto Invoke(FuncType &&Func, ArgTypes &&... Args) -> decltype(((FuncType &&) Func)((ArgTypes &&) Args...))
Definition Invoke.h:44
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition Array.h:670
void SetNumZeroed(SizeType NewNum, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:2340
Definition AndroidPlatformMisc.h:14
Definition UnrealString.h.inl:34
Definition GeometrySet3.h:28
GEOMETRYCORE_API bool CollectCurvesNearRay(const FRay3d &Ray, TArray< FNearest > &ResultsOut, TFunction< bool(const FVector3d &, const FVector3d &)> PointWithinToleranceTest) const
Definition GeometrySet3.cpp:260
GEOMETRYCORE_API bool CollectPointsNearRay(const FRay3d &Ray, TArray< FNearest > &ResultsOut, TFunction< bool(const FVector3d &, const FVector3d &)> PointWithinToleranceTest) const
Definition GeometrySet3.cpp:135
bool FindAllCurvesSatisfying(PredicateType Predicate, IntContainerType &CurveIDsOut) const
Definition GeometrySet3.h:175
TMap< int, int > PointIDToIndex
Definition GeometrySet3.h:222
TArray< FCurve > Curves
Definition GeometrySet3.h:231
TMap< int, int > CurveIDToIndex
Definition GeometrySet3.h:232
GEOMETRYCORE_API void AddPoint(int PointID, const FVector3d &Position)
Definition GeometrySet3.cpp:23
bool ParallelFindAllPointsSatisfying(PredicateType Predicate, IntContainerType &PointIDsOut) const
Definition GeometrySet3.h:145
GEOMETRYCORE_API bool FindNearestPointToRay(const FRay3d &Ray, FNearest &ResultOut, TFunction< bool(const FVector3d &, const FVector3d &)> PointWithinToleranceTest) const
Definition GeometrySet3.cpp:95
GEOMETRYCORE_API void RemovePoint(int PointID)
Definition GeometrySet3.cpp:42
GEOMETRYCORE_API void UpdatePoint(int PointID, const FVector3d &Position)
Definition GeometrySet3.cpp:78
TArray< FPoint > Points
Definition GeometrySet3.h:221
GEOMETRYCORE_API void RemoveCurve(int CurveID)
Definition GeometrySet3.cpp:60
GEOMETRYCORE_API void AddCurve(int CurveID, const FPolyline3d &Polyline)
Definition GeometrySet3.cpp:31
GEOMETRYCORE_API void UpdateCurve(int CurveID, const FPolyline3d &Polyline)
Definition GeometrySet3.cpp:85
bool FindAllPointsSatisfying(PredicateType Predicate, IntContainerType &PointIDsOut) const
Definition GeometrySet3.h:128
GEOMETRYCORE_API bool FindNearestCurveToRay(const FRay3d &Ray, FNearest &ResultOut, TFunction< bool(const FVector3d &, const FVector3d &)> PointWithinToleranceTest) const
Definition GeometrySet3.cpp:181
bool ParallelFindAllCurvesSatisfying(PredicateType Predicate, IntContainerType &CurveIDsOut) const
Definition GeometrySet3.h:192
Definition Polyline.h:49
Definition AdvancedWidgetsModule.cpp:13
Definition GeometrySet3.h:225
int ID
Definition GeometrySet3.h:226
FPolyline3d Geometry
Definition GeometrySet3.h:227
FAxisAlignedBox3d Bounds
Definition GeometrySet3.h:229
Definition GeometrySet3.h:55
bool bIsPoint
Definition GeometrySet3.h:59
FVector3d NearestRayPoint
Definition GeometrySet3.h:62
int PolySegmentIdx
Definition GeometrySet3.h:70
int ID
Definition GeometrySet3.h:57
FVector3d NearestGeoPoint
Definition GeometrySet3.h:64
double PolySegmentParam
Definition GeometrySet3.h:72
double RayParam
Definition GeometrySet3.h:67
Definition GeometrySet3.h:217
int ID
Definition GeometrySet3.h:218
FVector3d Position
Definition GeometrySet3.h:219