27#ifndef EXT_DELAUNAY_TETRAHEDRALIZER_H
28#define EXT_DELAUNAY_TETRAHEDRALIZER_H
30#include "foundation/PxArray.h"
31#include "foundation/PxVec3.h"
32#include "foundation/PxHashSet.h"
33#include "GuTetrahedron.h"
41 using Edge = PxPair<PxI32, PxI32>;
42 using Tetrahedron = Gu::TetrahedronT<PxI32>;
43 using Tetrahedron16 = Gu::TetrahedronT<PxI16>;
45 void buildNeighborhood(
const PxArray<Tetrahedron>& tets, PxArray<PxI32>& result);
46 void buildNeighborhood(
const PxI32* tets, PxU32 numTets, PxArray<PxI32>& result);
48 PX_FORCE_INLINE PxF64 tetVolume(
const Vec3& a,
const Vec3& b,
const Vec3& c,
const Vec3& d)
50 return (-1.0 / 6.0) * (a - d).dot((b - d).cross(c - d));
53 PX_FORCE_INLINE PxF64 tetVolume(
const Tetrahedron& tet,
const PxArray<Vec3>& points)
55 return tetVolume(points[tet[0]], points[tet[1]], points[tet[2]], points[tet[3]]);
59 PX_FORCE_INLINE void intersectionOfSortedLists(
const PxArray<PxI32>& sorted1,
const PxArray<PxI32>& sorted2, PxArray<PxI32>& result)
64 while (a < sorted1.size() && b < sorted2.size())
66 if (sorted1[a] == sorted2[b])
68 result.pushBack(sorted1[a]);
72 else if (sorted1[a] > sorted2[b])
79 PX_FORCE_INLINE bool intersectionOfSortedListsContainsElements(
const PxArray<PxI32>& sorted1,
const PxArray<PxI32>& sorted2)
83 while (a < sorted1.size() && b < sorted2.size())
85 if (sorted1[a] == sorted2[b])
87 else if (sorted1[a] > sorted2[b])
103 virtual bool improved(PxF64 previousQuality, PxF64 newQuality)
const = 0;
121 bool improved(PxF64 previousQuality, PxF64 newQuality)
const;
142 bool improved(PxF64 previousQuality, PxF64 newQuality)
const;
163 A = a; B = b; C = c; Flipped =
false;
164 if (A > B) { PxSwap(A, B); Flipped = !Flipped; }
165 if (B > C) { PxSwap(B, C); Flipped = !Flipped; }
166 if (A > B) { PxSwap(A, B); Flipped = !Flipped; }
174 return k.A ^ k.B ^ k.C;
179 return first.A == second.A && first.B == second.B && first.C == second.C;
225 bool insertPoints(
const PxArray<Vec3>& inPoints, PxI32 start, PxI32 end);
229 bool canCollapseEdge(PxI32 edgeVertexToKeep, PxI32 edgeVertexToRemove, PxF64 volumeChangeThreshold = 0.1,
BaseTetAnalyzer* tetAnalyzer = NULL);
230 bool canCollapseEdge(PxI32 edgeVertexToKeep, PxI32 edgeVertexToRemove,
const PxArray<PxI32>& tetsConnectedToA,
const PxArray<PxI32>& tetsConnectedToB,
231 PxF64& qualityAfterCollapse, PxF64 volumeChangeThreshold = 0.1,
BaseTetAnalyzer* tetAnalyzer = NULL);
233 void collapseEdge(PxI32 edgeVertexToKeep, PxI32 edgeVertexToRemove);
235 void collapseEdge(PxI32 edgeVertexAToKeep, PxI32 edgeVertexBToRemove,
const PxArray<PxI32>& tetsConnectedToA,
const PxArray<PxI32>& tetsConnectedToB);
237 void collectTetsConnectedToVertex(PxI32 vertexIndex,
PxArray<PxI32>& tetIds);
241 void collectTetsConnectedToEdge(PxI32 edgeStart, PxI32 edgeEnd,
PxArray<PxI32>& tetIds);
243 PX_FORCE_INLINE const Vec3& point(PxI32 index)
const {
return centeredNormalizedPoints[index]; }
245 PX_FORCE_INLINE PxU32 numPoints()
const {
return centeredNormalizedPoints.size(); }
250 PxU32 addPoint(
const Vec3& p)
252 centeredNormalizedPoints.pushBack(p);
254 return centeredNormalizedPoints.size() - 1;
264 void copyInternalPointsTo(
PxArray<Vec3>& points) { points = centeredNormalizedPoints; }
268 void insertPointIntoEdge(PxI32 newPointIndex, PxI32 edgeA, PxI32 edgeB,
PxArray<PxI32>& affectedTets,
BaseTetAnalyzer* qualityAnalyzer = NULL);
276 void clearLockedEdges() { lockedEdges.clear(); }
278 void clearLockedTriangles() { lockedTriangles.clear(); }
292 PxI32 numAdditionalPointsAtBeginning = 4;
317 return lhs.Length < rhs.Length;
328 SplitEdge(PxI32 a, PxI32 b, PxF64 q, PxF64 l,
bool interiorEdge)
334 InteriorEdge = interiorEdge;
341 return lhs.L > rhs.L;
342 return lhs.Q > rhs.Q;
347 PxArray<
PxArray<PxI32>>& pointToOriginalTriangle, PxI32 numFixPoints, BaseTetAnalyzer* qualityAnalyzer = NULL);
353 PxI32 maxPointsToInsert = -1,
bool sortByQuality =
false, BaseTetAnalyzer* qualityAnalyzer = NULL, PxF64 qualityThreshold = 10);
356 void optimize(DelaunayTetrahedralizer& del,
PxArray<
PxArray<PxI32>>& pointToOriginalTriangle, PxI32 numFixPoints,
Definition ExtDelaunayTetrahedralizer.h:97
Definition ExtDelaunayTetrahedralizer.h:211
Definition ExtDelaunayTetrahedralizer.h:130
Definition ExtDelaunayTetrahedralizer.h:109
Definition ExtDelaunayTetrahedralizer.h:195
PX_FORCE_INLINE void forceSize_Unsafe(uint32_t size)
Definition PxArray.h:507
PX_FORCE_INLINE T & pushBack(const T &a)
Definition PxArray.h:296
Definition PxHashSet.h:77
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition ExtDelaunayTetrahedralizer.h:302
Definition ExtDelaunayTetrahedralizer.h:185
Definition ExtDelaunayTetrahedralizer.h:321
Definition ExtDelaunayTetrahedralizer.h:171
Definition GuTriangle.h:48
Definition GuPCMContactConvexCommon.h:340