UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MeshQueries.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
8#include "BoxTypes.h"
9#include "IndexTypes.h"
10#include "Algo/Accumulate.h"
11#include "Async/ParallelFor.h"
12
13namespace UE
14{
15namespace Geometry
16{
17
18
19template <class TriangleMeshType>
21{
22public:
23 TMeshQueries() = delete;
24
29 {
30 check(Mesh.IsTriangle(TriIdx));
32 Mesh.GetTriVertices(TriIdx, tri.V[0], tri.V[1], tri.V[2]);
34 q.GetSquared();
35 return q;
36 }
37
42 {
43 check(Mesh.IsTriangle(TriIdx));
45 Mesh.GetTriVertices(TriIdx, tri.V[0], tri.V[1], tri.V[2]);
47 q.Find();
48 return q;
49 }
50
58 {
60 Mesh.GetTriVertices(TriIdx, Triangle.V[0], Triangle.V[1], Triangle.V[2]);
61 return Triangle.Centroid();
62 }
63
72 static void GetTriNormalAreaCentroid(const TriangleMeshType& Mesh, int TriIdx, FVector3d& Normal, double& Area, FVector3d& Centroid)
73 {
75 Mesh.GetTriVertices(TriIdx, Triangle.V[0], Triangle.V[1], Triangle.V[2]);
76 Centroid = Triangle.Centroid();
78 }
79
84 {
85 FVector3d Centroid(0, 0, 0);
86 for (int VertIdx = 0; VertIdx < Mesh.MaxVertexID(); VertIdx++)
87 {
88 if (Mesh.IsVertex(VertIdx))
89 {
90 Centroid += Mesh.GetVertex(VertIdx);
91 }
92 }
93 int NumVertices = Mesh.VertexCount();
94 if (NumVertices > 0)
95 {
96 Centroid /= (double)NumVertices;
97 }
98 return Centroid;
99 }
100
108 {
109 double Volume = 0.0;
110 // computing wrt a centroid is enough to ensure that e.g. a plane will have volume 0 instead of arbitrary volume
112 for (int TriIdx = 0; TriIdx < Mesh.MaxTriangleID(); TriIdx++)
113 {
114 if (!Mesh.IsTriangle(TriIdx))
115 {
116 continue;
117 }
118
119 FVector3d V0, V1, V2;
120 Mesh.GetTriVertices(TriIdx, V0, V1, V2);
121
122 // (6x) volume of the tetrahedron formed by the triangles and the reference point
126
127 Volume += ((V0-RefPt) * DimScaleFactor).Dot(N);
128 }
129
130 return Volume * (1.0 / 6.0);
131 }
132
133
135 {
136 double Volume = 0.0;
137 double Area = 0;
138 for (int TriIdx = 0; TriIdx < Mesh.MaxTriangleID(); TriIdx++)
139 {
140 if (!Mesh.IsTriangle(TriIdx))
141 {
142 continue;
143 }
144
145 FVector3d V0, V1, V2;
146 Mesh.GetTriVertices(TriIdx, V0, V1, V2);
147
148 // Get cross product of edges and (un-normalized) normal vector.
149 FVector3d V1mV0 = V1 - V0;
150 FVector3d V2mV0 = V2 - V0;
152
153 Area += N.Length();
154
155 double tmp0 = V0.X + V1.X;
156 double f1x = tmp0 + V2.X;
157 Volume += N.X * f1x;
158 }
159
160 return FVector2d(Volume * (1.0/6.0), Area * .5f);
161 }
162
164 {
165 double Volume = 0.0;
166 double Area = 0;
168
169 // Compute quantities relative to the first vertex for more stable computation
171 for (int VertIdx = 0; VertIdx < Mesh.MaxVertexID(); ++VertIdx)
172 {
173 if (Mesh.IsVertex(VertIdx))
174 {
175 RefVert = Mesh.GetVertex(VertIdx);
176 break;
177 }
178 }
179 for (int TriIdx = 0; TriIdx < Mesh.MaxTriangleID(); TriIdx++)
180 {
181 if (!Mesh.IsTriangle(TriIdx))
182 {
183 continue;
184 }
185
186 FVector3d V0, V1, V2;
187 Mesh.GetTriVertices(TriIdx, V0, V1, V2);
188 // Subtract reference vertex for stability
189 V0 -= RefVert;
190 V1 -= RefVert;
191 V2 -= RefVert;
192
193 // Get cross product of edges and (un-normalized) normal vector.
194 FVector3d V1mV0 = V1 - V0;
195 FVector3d V2mV0 = V2 - V0;
197 Area += N.Length();
198
199 FVector3d F1 = V0 + V1 + V2;
200 FVector3d F2(
201 V0.X * V0.X + V1.X * (V0.X + V1.X) + V2.X * F1.X,
202 V0.Y * V0.Y + V1.Y * (V0.Y + V1.Y) + V2.Y * F1.Y,
203 V0.Z * V0.Z + V1.Z * (V0.Z + V1.Z) + V2.Z * F1.Z);
204
205 Volume += N.X * F1.X;
206 OutCenterOfMass += N * F2;
207 }
208
209 if (Volume != 0.0)
210 {
211 OutCenterOfMass /= (Volume * 4.0);
212 }
213
215
216 return FVector2d(Volume * (1.0 / 6.0), Area * .5);
217 }
218
219
220 static FVector2d GetVolumeArea(const TriangleMeshType& Mesh, const TArray<int>& TriIndices)
221 {
222 double Volume = 0.0;
223 double Area = 0;
224 for (int TriIdx : TriIndices)
225 {
226 if (!Mesh.IsTriangle(TriIdx))
227 {
228 continue;
229 }
230
231 FVector3d V0, V1, V2;
232 Mesh.GetTriVertices(TriIdx, V0, V1, V2);
233
234 // Get cross product of edges and (un-normalized) normal vector.
235 FVector3d V1mV0 = V1 - V0;
236 FVector3d V2mV0 = V2 - V0;
238
239 Area += N.Length();
240
241 double tmp0 = V0.X + V1.X;
242 double f1x = tmp0 + V2.X;
243 Volume += N.X * f1x;
244 }
245
246 return FVector2d(Volume * (1.0 / 6.0), Area * .5f);
247 }
248
250 {
251 FIndex3i TriInds = Mesh.GetTriangle(TID);
252 FVector3d MinV, MaxV, V = Mesh.GetVertex(TriInds.A);
253 MinV = MaxV = V;
254 for (int i = 1; i < 3; ++i)
255 {
256 V = Mesh.GetVertex(TriInds[i]);
257 if (V.X < MinV.X) MinV.X = V.X;
258 else if (V.X > MaxV.X) MaxV.X = V.X;
259 if (V.Y < MinV.Y) MinV.Y = V.Y;
260 else if (V.Y > MaxV.Y) MaxV.Y = V.Y;
261 if (V.Z < MinV.Z) MinV.Z = V.Z;
262 else if (V.Z > MaxV.Z) MaxV.Z = V.Z;
263 }
264 return FAxisAlignedBox3d(MinV, MaxV);
265 }
266
268 {
270 for (int i = 0; i < Mesh.MaxVertexID(); ++i)
271 {
272 if (Mesh.IsVertex(i))
273 {
274 Bounds.Contain(Mesh.GetVertex(i));
275 }
276 }
277 return Bounds;
278 }
279
281 template<typename EnumerableTriListType>
283 const TriangleMeshType& Mesh,
284 const EnumerableTriListType& Triangles,
286 {
288 for (int32 tid : Triangles)
289 {
290 if (Mesh.IsTriangle(tid))
291 {
292 FVector3d A,B,C;
293 Mesh.GetTriVertices(tid, A,B,C); // cannot use GetTriBounds here unless it is a FDynamicMesh3!
294 Bounds.Contain(Transform.TransformPosition(A));
295 Bounds.Contain(Transform.TransformPosition(B));
296 Bounds.Contain(Transform.TransformPosition(C));
297 }
298 }
299 return Bounds;
300 }
301
303 template<typename EnumerableTriListType>
305 const TriangleMeshType& Mesh,
306 const EnumerableTriListType& Vertices,
308 {
310 for (int32 vid : Vertices)
311 {
312 if (Mesh.IsVertex(vid))
313 {
314 Bounds.Contain( Transform.TransformPosition(Mesh.GetVertex(vid)) );
315 }
316 }
317 return Bounds;
318 }
319
320 // brute force search for nearest triangle to Point
322 {
325 for (int TriIdx : Mesh.TriangleIndicesItr())
326 {
327 double distSqr = TriDistanceSqr(Mesh, TriIdx, P);
328 if (distSqr < fNearestSqr)
329 {
332 }
333 }
334 return tNearest;
335 }
336
341 {
342 FVector3d NearestPoint = P;
344 for (int TriIdx : Mesh.TriangleIndicesItr())
345 {
347 if (Query.GetSquared() < NearestSqr)
348 {
349 NearestSqr = Query.GetSquared();
350 NearestPoint = Query.ClosestTrianglePoint;
351 }
352 }
353 return NearestPoint;
354 }
355
356
357
361 static double TriDistanceSqr(const TriangleMeshType& Mesh, int TriIdx, const FVector3d& Point)
362 {
364 Mesh.GetTriVertices(TriIdx, Triangle.V[0], Triangle.V[1], Triangle.V[2]);
365
367 return Distance.GetSquared();
368 }
369
370 // brute force search for nearest triangle intersection
372 {
376
377 for (int TriIdx = 0; TriIdx < Mesh.MaxTriangleID(); TriIdx++)
378 {
379 if (!Mesh.IsTriangle(TriIdx))
380 {
381 continue;
382 }
383 Mesh.GetTriVertices(TriIdx, Triangle.V[0], Triangle.V[1], Triangle.V[2]);
385 if (Query.Find())
386 {
387 if (Query.RayParameter < fNearestT)
388 {
389 fNearestT = Query.RayParameter;
391 }
392 }
393 }
394
395 return tNearestID;
396 }
397
398 // brute force search for all triangle intersections, sorted
400 {
402 SortedHitTriangles.Empty();
403
404 for (int TriIdx : Mesh.TriangleIndicesItr())
405 {
406 Mesh.GetTriVertices(TriIdx, Triangle.V[0], Triangle.V[1], Triangle.V[2]);
408 if (Query.Find())
409 {
410 SortedHitTriangles.Emplace(Query.RayParameter, TriIdx);
411 }
412 }
413
415 {
416 return A.Key < B.Key;
417 });
418 }
419
425 {
426 for (int TI = 0; TI < Mesh1.MaxTriangleID(); TI++)
427 {
428 if (!Mesh1.IsTriangle(TI))
429 {
430 continue;
431 }
433 Mesh1.GetTriVertices(TI, Tri1.V[0], Tri1.V[1], Tri1.V[2]);
434 for (int TJ = 0; TJ < Mesh2.MaxTriangleID(); TJ++)
435 {
436 if (!Mesh2.IsTriangle(TJ))
437 {
438 continue;
439 }
441 Mesh2.GetTriVertices(TJ, Tri2.V[0], Tri2.V[1], Tri2.V[2]);
443 {
444 return FIndex2i(TI, TJ);
445 }
446 }
447 }
448 return FIndex2i::Invalid();
449 }
450
454 template<typename RayType = FRay3d>
456 {
458 Mesh.GetTriVertices(TriIdx, Triangle.V[0], Triangle.V[1], Triangle.V[2]);
459
461 Query.Find();
462 return Query;
463 }
464
469 static void GetAllEdgeLengths(const TriangleMeshType& Mesh, TArray<double>& Lengths, double& TotalLength)
470 {
471 Lengths.Init(-1.0, Mesh.MaxEdgeID());
472 TotalLength = 0.0;
473 for (const int32 EdgeID : Mesh.EdgeIndicesItr())
474 {
475 FVector3d vA, vB;
476 Mesh.GetEdgeV(EdgeID, vA, vB);
477 Lengths[EdgeID] = (vA - vB).Length();
478 TotalLength += Lengths[EdgeID];
479 }
480 }
481
484 {
485 if (Mesh.EdgeCount() == 0)
486 {
487 return 0.0;
488 }
489
490 double SumLengths = Algo::TransformAccumulate(Mesh.EdgeIndicesItr(), [&Mesh](int EdgeIndex) -> double
491 {
492 FVector3d vA, vB;
493 Mesh.GetEdgeV(EdgeIndex, vA, vB);
494 return (vA - vB).Length();
495 }, 0.0);
496
497 return SumLengths / Mesh.EdgeCount();
498 }
499
501 static double MaxEdgeLength(const TriangleMeshType& Mesh)
502 {
503 double MaxLength = 0.0;
504 for (auto EdgeID : Mesh.EdgeIndicesItr())
505 {
506 FVector3d vA, vB;
507 Mesh.GetEdgeV(EdgeID, vA, vB);
508 MaxLength = FMath::Max(MaxLength, (vA - vB).Length());
509 }
510
511 return MaxLength;
512 }
513
515 static double MinEdgeLength(const TriangleMeshType& Mesh)
516 {
517 if (Mesh.EdgeCount() == 0)
518 {
519 return 0.0;
520 }
521
522 double MinLength = FMathd::MaxReal;
523 for (auto EdgeID : Mesh.EdgeIndicesItr())
524 {
525 FVector3d vA, vB;
526 Mesh.GetEdgeV(EdgeID, vA, vB);
527 MinLength = FMath::Min(MinLength, (vA - vB).Length());
528 }
529
530 return MinLength;
531 }
532
534 static double TotalEdgeLength(const TriangleMeshType& Mesh, const TArray<int>& Edges)
535 {
536 double AccumulatedLength = 0;
537 for (int EdgeID : Edges)
538 {
539 if (Mesh.IsEdge(EdgeID))
540 {
541 FVector3d A, B;
542 Mesh.GetEdgeV(EdgeID, A, B);
544 }
545 }
546 return AccumulatedLength;
547 }
548
549
551 static void EdgeLengthStatsFromEdges(const TriangleMeshType& Mesh, const TArray<int>& Edges, double& MinEdgeLength,
552 double& MaxEdgeLength, double& AverageEdgeLength)
553 {
554 if (Mesh.EdgeCount() == 0)
555 {
556 MinEdgeLength = 0.0;
557 MaxEdgeLength = 0.0;
558 AverageEdgeLength = 0.0;
559 return;
560 }
561
565 int EdgeCount = 0;
566
567 for (int EdgeID : Edges)
568 {
569 if (Mesh.IsEdge(EdgeID))
570 {
571 FVector3d A, B;
572 Mesh.GetEdgeV(EdgeID, A, B);
573 double Length = Distance(A, B);
577 ++EdgeCount;
578 }
579 }
580
581 AverageEdgeLength /= (double)EdgeCount;
582 }
583
587 double& AverageEdgeLength, int NumSamples = 0)
588 {
589 if (Mesh.EdgeCount() == 0)
590 {
591 MinEdgeLength = 0.0;
592 MaxEdgeLength = 0.0;
593 AverageEdgeLength = 0.0;
594 return;
595 }
596
600 int MaxID = Mesh.MaxEdgeID();
601
602 // if we are only taking some samples, use a prime-modulo-loop instead of random
603 int PrimeNumber = (NumSamples == 0) ? 1 : 31337;
604 int MaxCount = (NumSamples == 0) ? MaxID : NumSamples;
605
606 FVector3d A, B;
607 int EdgeID = 0;
608 int EdgeCount = 0;
609 do
610 {
611 if (Mesh.IsEdge(EdgeID))
612 {
613 Mesh.GetEdgeV(EdgeID, A, B);
614 double Length = Distance(A, B);
618 ++EdgeCount;
619 }
620 EdgeID = (EdgeID + PrimeNumber) % MaxID;
621 } while (EdgeID != 0 && EdgeCount < MaxCount);
622
623 AverageEdgeLength /= (double)EdgeCount;
624 }
625
630 template<typename MeshSpatialType>
632 {
633 check(SpatialB.SupportsNearestTriangle());
634 Distances.SetNumZeroed(MeshA.VertexCount());
635
636 ParallelFor(MeshA.VertexCount(), [&MeshA, &SpatialB, &Distances](int VertexID)
637 {
638 if (!MeshA.IsVertex(VertexID)) { return; }
639
640 FVector3d VertexPosition = MeshA.GetVertex(VertexID);
641 double DistSqr;
642 SpatialB.FindNearestTriangle(VertexPosition, DistSqr);
643 Distances[VertexID] = sqrt(DistSqr);
644 });
645 }
646
652 template<typename MeshSpatialType>
654 {
655 TArray<double> Distances;
656 VertexToSurfaceDistances(MeshA, SpatialB, Distances);
657
658 double MaxDist = -BIG_NUMBER;
659 for (auto& Dist : Distances)
660 {
661 MaxDist = FMath::Max(Dist, MaxDist);
662 }
663
664 return MaxDist;
665 }
666
668 template<typename MeshSpatialType>
671 {
672 return FMath::Max(HausdorffDistance(MeshA, SpatialB), HausdorffDistance(MeshB, SpatialA));
673 }
674
675
677 template<typename MeshSpatialType>
679 {
680 check(SpatialB.SupportsNearestTriangle());
681 Distances.SetNumZeroed(MeshA.VertexCount());
682
683 for (int VertexID = 0; VertexID < MeshA.VertexCount(); ++VertexID)
684 {
685 if (!MeshA.IsVertex(VertexID)) { continue; }
686
687 FVector3d VertexPosition = MeshA.GetVertex(VertexID);
688 double DistSqr;
689 SpatialB.FindNearestTriangle(VertexPosition, DistSqr);
690 Distances[VertexID] = sqrt(DistSqr);
691 }
692 }
693
696 template<typename MeshSpatialType>
698 {
699 TArray<double> Distances;
700 VertexToSurfaceDistancesSerial(MeshA, SpatialB, Distances);
701
702 double MaxDist = -BIG_NUMBER;
703 for (auto& Dist : Distances)
704 {
705 MaxDist = FMath::Max(Dist, MaxDist);
706 }
707
708 return MaxDist;
709 }
710
711 template<typename MeshSpatialType>
714 {
715 return FMath::Max(HausdorffDistanceSerial(MeshA, SpatialB), HausdorffDistanceSerial(MeshB, SpatialA));
716 }
717
721 template<typename MeshSpatialType>
723 const TriangleMeshType& MeshA,
725 const TriangleMeshType* MeshB,
727 bool bSymmetric,
728 double& MaxDistance,
729 double& MinDistance,
730 double& AverageDistance,
732 )
733 {
734 TArray<double> Distances;
735 VertexToSurfaceDistances(MeshA, SpatialB, Distances);
736
737 if (bSymmetric && MeshB != nullptr && SpatialA != nullptr)
738 {
740 VertexToSurfaceDistances(*MeshB, *SpatialA, Distances2);
741 Distances.Append(Distances2);
742 }
743
744 double NumDistances = (double)Distances.Num();
745
747 MinDistance = BIG_NUMBER;
748 AverageDistance = 0;
749 for (double& Dist : Distances)
750 {
751 MaxDistance = FMath::Max(Dist, MaxDistance);
752 MinDistance = FMath::Min(Dist, MinDistance);
754 RootMeanSqrDeviation += (Dist * Dist);
755 }
757 }
758
769 {
771 if (bWeightByAngle)
772 {
773 TriNormalWeights = Mesh.GetTriInternalAnglesR(TriID); // component-wise multiply by per-vertex internal angles
774 }
775 if (bWeightByArea)
776 {
778 }
779 return TriNormalWeights;
780 }
781
789 {
790 TSet<int32> TriangleSet; // All triangles shared by vertices in Vertices array
791 TriangleSet.Reserve(Vertices.Num());
792 for (const int32 VID : Vertices)
793 {
794 for (const int32 TID : Mesh.VtxTrianglesItr(VID))
795 {
796 TriangleSet.Add(TID);
797 }
798 }
799
800 return TriangleSet.Array();
801 }
802
811 const TArray<int32>& Selection,
814 {
815 VIDToExpandedSelectionIdx.Reserve(Selection.Num());
816 ExpandedSelection.Reserve(Selection.Num());
817
818 int32 Idx = 0;
819 for (const int32 SelectedVID : Selection)
820 {
822 {
825 }
826
827 for (const int32 NeighborVID : Mesh.VtxVerticesItr(SelectedVID))
828 {
830 {
833 }
834 }
835 }
836 }
837};
838
839
840} // end namespace UE::Geometry
841} // end namespace UE
@ Normal
Definition AndroidInputInterface.h:116
#define check(expr)
Definition AssertionMacros.h:314
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
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::Math::TVector2< double > FVector2d
Definition MathFwd.h:61
#define BIG_NUMBER
Definition UnrealMathUtility.h:68
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
void SetNumZeroed(SizeType NewNum, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:2340
void Init(const ElementType &Element, SizeType Number)
Definition Array.h:3043
void Append(const TArray< OtherElementType, OtherAllocatorType > &Source)
Definition Array.h:2412
UE_FORCEINLINE_HINT void Reserve(SizeType Number)
Definition Array.h:3016
Definition UnrealString.h.inl:34
static RealType Sqrt(const RealType Value)
Definition MathUtil.h:342
Definition DistPoint3Triangle3.h:23
Real GetSquared()
Definition DistPoint3Triangle3.h:44
Definition IntrRay3Triangle3.h:67
bool Find()
Definition IntrRay3Triangle3.h:244
static bool Intersects(const TTriangle3< Real > &Triangle0, const TTriangle3< Real > &Triangle1, Real Tolerance=TMathUtil< Real >::ZeroTolerance)
Definition IntrTriangle3Triangle3.h:386
Definition MeshQueries.h:21
static double GetVolumeNonWatertight(const TriangleMeshType &Mesh, double DimScaleFactor=1)
Definition MeshQueries.h:107
static FVector2d GetVolumeAreaCenter(const TriangleMeshType &Mesh, FVector3d &OutCenterOfMass)
Definition MeshQueries.h:163
static FIntrRay3Triangle3d TriangleIntersection(const TriangleMeshType &Mesh, int TriIdx, const FRay3d &Ray)
Definition MeshQueries.h:41
static double MaxEdgeLength(const TriangleMeshType &Mesh)
Compute the longest edge length for the given mesh.
Definition MeshQueries.h:501
static FIndex2i FindIntersectingTriangles_LinearSearch(const TriangleMeshType &Mesh1, const TriangleMeshType &Mesh2)
Definition MeshQueries.h:424
static void VertexToSurfaceDistances(const TriangleMeshType &MeshA, const MeshSpatialType &SpatialB, TArray< double > &Distances)
Definition MeshQueries.h:631
static int FindHitTriangle_LinearSearch(const TriangleMeshType &Mesh, const FRay3d &Ray)
Definition MeshQueries.h:371
static void GetAllEdgeLengths(const TriangleMeshType &Mesh, TArray< double > &Lengths, double &TotalLength)
Definition MeshQueries.h:469
static double HausdorffDistanceSerial(const TriangleMeshType &MeshA, const MeshSpatialType &SpatialB)
Definition MeshQueries.h:697
static void VertexToSurfaceDistancesSerial(const TriangleMeshType &MeshA, const MeshSpatialType &SpatialB, TArray< double > &Distances)
Compute all vertex-to-surface distances in serial. Should only be used for debugging the parallel ver...
Definition MeshQueries.h:678
static double AverageEdgeLength(const TriangleMeshType &Mesh)
Compute the mean edge length for the given mesh.
Definition MeshQueries.h:483
static void EdgeLengthStatsFromEdges(const TriangleMeshType &Mesh, const TArray< int > &Edges, double &MinEdgeLength, double &MaxEdgeLength, double &AverageEdgeLength)
Given a mesh and a subset of mesh edges, compute the min, max, and mean edge lengths.
Definition MeshQueries.h:551
static FVector3d GetMeshVerticesCentroid(const TriangleMeshType &Mesh)
Definition MeshQueries.h:83
static FVector3d FindNearestPoint_LinearSearch(const TriangleMeshType &Mesh, const FVector3d &P)
Definition MeshQueries.h:340
static double TotalEdgeLength(const TriangleMeshType &Mesh, const TArray< int > &Edges)
Given a mesh and a subset of mesh edges, compute the total length of all the edges.
Definition MeshQueries.h:534
static FVector3d GetVertexWeightsOnTriangle(const TriangleMeshType &Mesh, int TriID, double TriArea, bool bWeightByArea, bool bWeightByAngle)
Definition MeshQueries.h:768
static FVector3d GetTriCentroid(const TriangleMeshType &Mesh, int TriIdx)
Definition MeshQueries.h:57
static FAxisAlignedBox3d GetTrianglesBounds(const TriangleMeshType &Mesh, const EnumerableTriListType &Triangles, const FTransform &Transform=FTransform::Identity)
Definition MeshQueries.h:282
static double HausdorffDistance(const TriangleMeshType &MeshA, const MeshSpatialType &SpatialB)
Definition MeshQueries.h:653
static FIntrRay3Triangle3d RayTriangleIntersection(const TriangleMeshType &Mesh, int TriIdx, const RayType &Ray)
Definition MeshQueries.h:455
static FVector2d GetVolumeArea(const TriangleMeshType &Mesh, const TArray< int > &TriIndices)
Definition MeshQueries.h:220
static FAxisAlignedBox3d GetTriBounds(const TriangleMeshType &Mesh, int TID)
Definition MeshQueries.h:249
static FDistPoint3Triangle3d TriangleDistance(const TriangleMeshType &Mesh, int TriIdx, FVector3d Point)
Definition MeshQueries.h:28
static double TwoSidedHausdorffDistanceSerial(const TriangleMeshType &MeshA, const MeshSpatialType &SpatialA, const TriangleMeshType &MeshB, const MeshSpatialType &SpatialB)
Definition MeshQueries.h:712
static void ExpandVertexSelectionToNeighbors(const TriangleMeshType &Mesh, const TArray< int32 > &Selection, TArray< int32 > &ExpandedSelection, TMap< int32, int32 > &VIDToExpandedSelectionIdx)
Definition MeshQueries.h:810
static void MeshDistanceStatistics(const TriangleMeshType &MeshA, const MeshSpatialType &SpatialB, const TriangleMeshType *MeshB, const MeshSpatialType *SpatialA, bool bSymmetric, double &MaxDistance, double &MinDistance, double &AverageDistance, double &RootMeanSqrDeviation)
Definition MeshQueries.h:722
static void GetTriNormalAreaCentroid(const TriangleMeshType &Mesh, int TriIdx, FVector3d &Normal, double &Area, FVector3d &Centroid)
Definition MeshQueries.h:72
static void FindHitTriangles_LinearSearch(const TriangleMeshType &Mesh, const FRay3d &Ray, TArray< TPair< float, int > > &SortedHitTriangles)
Definition MeshQueries.h:399
static double MinEdgeLength(const TriangleMeshType &Mesh)
Compute the shortest edge length for the given mesh.
Definition MeshQueries.h:515
static int FindNearestTriangle_LinearSearch(const TriangleMeshType &Mesh, const FVector3d &P)
Definition MeshQueries.h:321
static FAxisAlignedBox3d GetBounds(const TriangleMeshType &Mesh)
Definition MeshQueries.h:267
static FVector2d GetVolumeArea(const TriangleMeshType &Mesh)
Definition MeshQueries.h:134
static FAxisAlignedBox3d GetVerticesBounds(const TriangleMeshType &Mesh, const EnumerableTriListType &Vertices, const FTransform &Transform=FTransform::Identity)
Definition MeshQueries.h:304
static void EdgeLengthStats(const TriangleMeshType &Mesh, double &MinEdgeLength, double &MaxEdgeLength, double &AverageEdgeLength, int NumSamples=0)
Definition MeshQueries.h:586
static double TwoSidedHausdorffDistance(const TriangleMeshType &MeshA, const MeshSpatialType &SpatialA, const TriangleMeshType &MeshB, const MeshSpatialType &SpatialB)
Because Hausdorff distance is not symmetric, we compute the maximum of the distances between two surf...
Definition MeshQueries.h:669
static TArray< int32 > GetVertexSelectedTriangles(const TriangleMeshType &Mesh, const TArray< int32 > &Vertices)
Definition MeshQueries.h:788
static double TriDistanceSqr(const TriangleMeshType &Mesh, int TriIdx, const FVector3d &Point)
Definition MeshQueries.h:361
T TransformAccumulate(const A &Input, MapT MapOp, T Init, OpT Op)
Definition Accumulate.h:71
constexpr int InvalidID
Definition IndexTypes.h:13
TVector< RealType > NormalArea(const TVector< RealType > &V0, const TVector< RealType > &V1, const TVector< RealType > &V2, RealType &AreaOut)
Definition VectorUtil.h:139
TAxisAlignedBox3< double > FAxisAlignedBox3d
Definition BoxTypes.h:885
@ Area
Definition FitOrientedBox2.h:17
@ Volume
Definition FitOrientedBox3.h:19
Definition AdvancedWidgetsModule.cpp:13
Definition NumericLimits.h:41
Definition Tuple.h:652
Definition IndexTypes.h:27
static constexpr FIndex2i Invalid()
Definition IndexTypes.h:52
Definition IndexTypes.h:158
static TAxisAlignedBox3< double > Empty()
Definition BoxTypes.h:382
void Contain(const TVector< RealType > &V)
Definition BoxTypes.h:438
Definition TriangleTypes.h:263
TVector< RealType > Centroid() const
Definition TriangleTypes.h:304
static CORE_API const TTransform< double > Identity
Definition TransformNonVectorized.h:58
static TVector< double > One()
Definition Vector.h:115
T Z
Definition Vector.h:68
T Y
Definition Vector.h:65
static CORE_API const TVector< double > ZeroVector
Definition Vector.h:79
T Length() const
Definition Vector.h:1722
UE_FORCEINLINE_HINT TVector< T > Cross(const TVector< T > &V2) const
Definition Vector.h:1535
T X
Definition Vector.h:62
UE_FORCEINLINE_HINT T Dot(const TVector< T > &V) const
Definition Vector.h:1553