Rebel Fork Framework
Urho3D::TetrahedralMesh Class Reference

Tetrahedral mesh. More...

#include <Urho3D/Math/TetrahedralMesh.h>

Classes

struct  DelaunayContext
 Data used for Delaunay triangulation. More...
 

Public Member Functions

void Define (ea::span< const Vector3 > positions)
 Define mesh from vertices.
 
void CollectEdges (ea::vector< ea::pair< unsigned, unsigned >> &edges)
 Collect all edges in the mesh, e.g. for debug rendering.
 
HighPrecisionSphere GetTetrahedronCircumsphere (unsigned tetIndex) const
 Calculate circumsphere of given tetrahedron.
 
Vector4 GetInnerBarycentricCoords (unsigned tetIndex, const Vector3 &position) const
 Calculate barycentric coordinates for inner tetrahedron.
 
Vector4 GetOuterBarycentricCoords (unsigned tetIndex, const Vector3 &position) const
 Calculate barycentric coordinates for outer tetrahedron.
 
Vector4 GetBarycentricCoords (unsigned tetIndex, const Vector3 &position) const
 Calculate barycentric coordinates for tetrahedron.
 
Vector4 GetInterpolationFactors (const Vector3 &position, unsigned &tetIndexHint) const
 Find tetrahedron containing given position and calculate barycentric coordinates within this tetrahedron.
 
template<class Container >
auto Sample (const Container &container, const Vector3 &position, unsigned &tetIndexHint) const
 Sample value at given position from the arbitrary container of per-vertex data.
 

Public Attributes

ea::vector< Vector3vertices_
 Vertices.
 
ea::vector< Tetrahedrontetrahedrons_
 Tetrahedrons.
 
ea::vector< Vector3hullNormals_
 Hull normals.
 
ea::vector< unsigned > ignoredVertices_
 Array of ignored vertices.
 
unsigned numInnerTetrahedrons_ {}
 Number of inner tetrahedrons.
 
ea::vector< ea::pair< unsigned, unsigned > > debugHighlightEdges_
 Debug array of edges related to errors in generation.
 

Private Member Functions

unsigned FindTetrahedron (const Vector3 &position, ea::vector< bool > &removed) const
 Find tetrahedron for given position. Ignore removed tetrahedrons. Return invalid index if cannot find.
 
void InitializeSuperMesh (const BoundingBox &boundingBox)
 Create super-mesh for Delaunay triangulation.
 
void BuildTetrahedrons (ea::span< const Vector3 > positions)
 Build tetrahedrons for given positions.
 
bool IsAdjacencyValid (bool fullyConnected) const
 Return whether the adjacency is valid.
 
void DisconnectTetrahedron (unsigned tetIndex)
 Disconnect tetrahedron from mesh.
 
bool FindAndRemoveIntersected (DelaunayContext &ctx, const Vector3 &position, TetrahedralMeshSurface &holeSurface, ea::vector< unsigned > &removedTetrahedrons, bool dumpErrors=false) const
 
void DisconnectRemovedTetrahedrons (const ea::vector< unsigned > &removedTetrahedrons)
 Disconnect removed tetrahedrons from the rest.
 
void FillStarShapedHole (DelaunayContext &ctx, const ea::vector< unsigned > &outputTetrahedrons, const TetrahedralMeshSurface &holeSurface, unsigned centerIndex)
 
void DisconnectSuperMeshTetrahedrons (ea::vector< bool > &removed)
 Mark super-mesh tetrahedrons in the to-be-removed array and disconnect all related adjacency.
 
void EnsureMeshConnectivity (ea::vector< bool > &removed)
 Ensure mesh connectivity, remove disconnected parts.
 
void FilterMeshSurface (ea::vector< bool > &removed)
 Collect surface tetrahedrons and ensure that the surface doesn't have edge connections.
 
void RemoveMarkedTetrahedrons (const ea::vector< bool > &removed)
 Remove marked tetrahedrons from array.
 
void RemoveSuperMeshVertices ()
 Remove super-mesh vertices.
 
void UpdateIgnoredVertices ()
 Update array of ignored vertices.
 
void BuildHullSurface (TetrahedralMeshSurface &hullSurface)
 Build hull surface.
 
void CalculateHullNormals (const TetrahedralMeshSurface &hullSurface)
 Calculate hull normals.
 
void BuildOuterTetrahedrons (const TetrahedralMeshSurface &hullSurface)
 Build outer tetrahedrons.
 
void CalculateOuterMatrices ()
 Calculate matrices for outer tetrahedrons.
 

Static Private Member Functions

static int SolveCubicEquation (double result[], double a, double b, double c, double eps)
 Solve cubic equation x^3 + a*x^2 + b*x + c = 0.
 
static float SolveCubic (const Vector3 &abc)
 Calculate most positive root of cubic equation x^3 + a*x^2 + b*x + c = 0.
 
static float SolveQuadratic (const Vector3 &abc)
 Calculate most positive root of quadratic or linear equation a*x^2 + b*x + c = 0.
 
static double GetSmallestPositiveRoot (const double roots[], int count)
 Pick smallest positive root.
 
static Vector3 GetTriangleBarycentricCoords (const Vector3 &position, const Vector3 &p1, const Vector3 &p2, const Vector3 &p3)
 Calculate barycentric coordinates on triangle.
 

Static Private Attributes

static const unsigned NumSuperMeshVertices = 8
 Number of initial super-mesh vertices.
 

Detailed Description

Tetrahedral mesh.

Member Function Documentation

◆ FillStarShapedHole()

void Urho3D::TetrahedralMesh::FillStarShapedHole ( TetrahedralMesh::DelaunayContext ctx,
const ea::vector< unsigned > &  outputTetrahedrons,
const TetrahedralMeshSurface holeSurface,
unsigned  centerIndex 
)
private

Fill star-shaped hole with tetrahedrons connected to specified vertex. Output tetrahedrons should be allocated beforehand.

◆ FindAndRemoveIntersected()

bool Urho3D::TetrahedralMesh::FindAndRemoveIntersected ( TetrahedralMesh::DelaunayContext ctx,
const Vector3 position,
TetrahedralMeshSurface holeSurface,
ea::vector< unsigned > &  removedTetrahedrons,
bool  dumpErrors = false 
) const
private

Find and remove (aka set removed flag) tetrahedrons whose circumspheres intersect given point. Returns hole surface. Returns true on success. Mesh remains valid in case of failure.


The documentation for this class was generated from the following files: