chrono::ChConvexDecompositionVHACD Class Reference

Description

Class for wrapping the V-HACD convex decomposition code by Khaled Mamou.

#include <ChConvexDecomposition.h>

Inheritance diagram for chrono::ChConvexDecompositionVHACD:
Collaboration diagram for chrono::ChConvexDecompositionVHACD:

Public Member Functions

 ChConvexDecompositionVHACD ()
 Basic constructor.
 
virtual ~ChConvexDecompositionVHACD ()
 Destructor.
 
virtual void Reset () override
 Reset the input mesh data.
 
virtual bool AddTriangle (const ChVector3d &v1, const ChVector3d &v2, const ChVector3d &v3) override
 Add a triangle, by passing three points for vertices. More...
 
void SetParameters (unsigned int max_chull_count=256, unsigned int max_verts_per_chull=64, unsigned int voxel_resolution=1000, double min_volume_perc_error=1.0, unsigned int max_recursion_depth=10, bool shrink_wrap=true)
 Set the parameters for this convex decomposition algorithm. More...
 
virtual unsigned int ComputeConvexDecomposition () override
 Perform the convex decomposition. More...
 
virtual unsigned int GetHullCount () override
 Get the number of computed hulls after the convex decomposition.
 
virtual bool GetConvexHullResult (unsigned int hull_index, ChTriangleMesh &convextrimesh) override
 Get the n-th computed convex hull, by filling a ChTriangleMesh object that is passed as a parameter. More...
 
virtual bool GetConvexHullResult (unsigned int hull_index, std::vector< ChVector3d > &convexhull) override
 Get the n-th computed convex hull, by filling a vector with related vertices. More...
 
virtual void WriteConvexHullsAsWavefrontObj (std::ostream &stream) override
 Write the convex decomposition to a Wavefront '.obj' file, where each hull is a separate group.
 
- Public Member Functions inherited from chrono::ChConvexDecomposition
 ChConvexDecomposition ()
 Basic constructor.
 
virtual ~ChConvexDecomposition ()
 Destructor.
 
virtual bool AddTriangle (const ChTriangle &t1)
 Add a triangle, by passing a ChTriangle object (that will be copied, not referenced). More...
 
virtual bool AddTriangleMesh (const ChTriangleMesh &tm)
 Add a triangle mesh, by passing an entire ChTriangleMesh object. More...
 
virtual bool WriteConvexHullsAsChullsFile (std::ostream &stream)
 Write the convex decomposition to a '.chulls' file, where each hull is a sequence of non-repeated vertices.
 

Member Function Documentation

◆ AddTriangle()

bool chrono::ChConvexDecompositionVHACD::AddTriangle ( const ChVector3d v1,
const ChVector3d v2,
const ChVector3d v3 
)
overridevirtual

Add a triangle, by passing three points for vertices.

Note: the vertices must have proper winding (oriented triangle, normal pointing outside).

Implements chrono::ChConvexDecomposition.

◆ ComputeConvexDecomposition()

unsigned int chrono::ChConvexDecompositionVHACD::ComputeConvexDecomposition ( )
overridevirtual

Perform the convex decomposition.

This operation is time consuming, and it may take a while to complete. Quality of the results can depend a lot on the parameters. Also, meshes with triangles that are not well oriented (normals always pointing outside) or with gaps/holes, may give wrong results.

Implements chrono::ChConvexDecomposition.

◆ GetConvexHullResult() [1/2]

bool chrono::ChConvexDecompositionVHACD::GetConvexHullResult ( unsigned int  hull_index,
ChTriangleMesh convextrimesh 
)
overridevirtual

Get the n-th computed convex hull, by filling a ChTriangleMesh object that is passed as a parameter.

Note 1: passed ChTriangleMesh is cleared before populating it. Note 2: passed ChTriangleMesh is filled with disconnected triangles.

Implements chrono::ChConvexDecomposition.

◆ GetConvexHullResult() [2/2]

bool chrono::ChConvexDecompositionVHACD::GetConvexHullResult ( unsigned int  hull_index,
std::vector< ChVector3d > &  convexhull 
)
overridevirtual

Get the n-th computed convex hull, by filling a vector with related vertices.

Note: passed vector of points is cleared before populating it.

Implements chrono::ChConvexDecomposition.

◆ SetParameters()

void chrono::ChConvexDecompositionVHACD::SetParameters ( unsigned int  max_chull_count = 256,
unsigned int  max_verts_per_chull = 64,
unsigned int  voxel_resolution = 1000,
double  min_volume_perc_error = 1.0,
unsigned int  max_recursion_depth = 10,
bool  shrink_wrap = true 
)

Set the parameters for this convex decomposition algorithm.

Use this function before calling ComputeConvexDecomposition().

Parameters
max_chull_countmax number of chulls to produce
max_verts_per_chullmax number of vertices per chull
voxel_resolutionvoxel resolution to use
min_volume_perc_errormin percentage of voxel volume wrt chull allowed
max_recursion_depthmax recursion depth
shrink_wrapshrink voxel positions to the source mesh on output

The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono/collision/ChConvexDecomposition.h
  • /builds/uwsbel/chrono/src/chrono/collision/ChConvexDecomposition.cpp