chrono::collision::ChConvexDecompositionHACD Class Reference

Description

Class for wrapping the HACD convex decomposition code by Khaled Mamou (in the convexdecomposition/ directory) so that it is easier to use it by passing the Chrono::Engine structures of type ChTriangleMesh, ChTriangle, etc.

#include <ChCConvexDecomposition.h>

Inheritance diagram for chrono::collision::ChConvexDecompositionHACD:
Collaboration diagram for chrono::collision::ChConvexDecompositionHACD:

Public Member Functions

 ChConvexDecompositionHACD ()
 Basic constructor.
 
virtual ~ChConvexDecompositionHACD ()
 Destructor.
 
virtual void Reset (void)
 Reset the input mesh data.
 
virtual bool AddTriangle (const ChVector<> &v1, const ChVector<> &v2, const ChVector<> &v3)
 Add a triangle, by passing three points for vertexes. More...
 
virtual bool AddTriangleMesh (const geometry::ChTriangleMesh &tm)
 Add a triangle, by passing a ChTriangle object (that will be copied, not referenced). More...
 
void SetParameters (unsigned int nClusters=2, unsigned int targetDecimation=0, double smallClusterThreshold=0.25, bool addFacesPoints=false, bool addExtraDistPoints=false, double concavity=100.0, double ccConnectDist=30, double volumeWeight=0.0, double compacityAlpha=0.1, unsigned int nVerticesPerCH=50)
 Set the parameters for this convex decomposition algorithm. More...
 
virtual int ComputeConvexDecomposition ()
 Perform the convex decomposition. More...
 
virtual unsigned int GetHullCount ()
 Get the number of computed hulls after the convex decomposition.
 
virtual bool GetConvexHullResult (unsigned int hullIndex, geometry::ChTriangleMesh &convextrimesh)
 Get the n-th computed convex hull, by filling a ChTriangleMesh object that is passed as a parameter. More...
 
virtual bool GetConvexHullResult (unsigned int hullIndex, std::vector< ChVector< double > > &convexhull)
 Get the n-th computed convex hull, by filling a vector of points of the vertexes of the n-th hull that is passed as a parameter. More...
 
virtual void WriteConvexHullsAsWavefrontObj (ChStreamOutAscii &mstream)
 Save the computed convex hulls as a Wavefront file using the '.obj' fileformat, with each hull as a separate group. More...
 
- Public Member Functions inherited from chrono::collision::ChConvexDecomposition
 ChConvexDecomposition ()
 Basic constructor.
 
virtual ~ChConvexDecomposition ()
 Destructor.
 
virtual bool AddTriangle (const geometry::ChTriangle &t1)
 Add a triangle, by passing a ChTriangle object (that will be copied, not referenced). More...
 
virtual bool WriteConvexHullsAsChullsFile (ChStreamOutAscii &mstream)
 Write the convex decomposition to a ".chulls" file, where each hull is a sequence of x y z coords. More...
 

Member Function Documentation

bool chrono::collision::ChConvexDecompositionHACD::AddTriangle ( const ChVector<> &  v1,
const ChVector<> &  v2,
const ChVector<> &  v3 
)
virtual

Add a triangle, by passing three points for vertexes.

Note: the vertexes must be properly ordered (oriented triangle, normal pointing outside)

Implements chrono::collision::ChConvexDecomposition.

bool chrono::collision::ChConvexDecompositionHACD::AddTriangleMesh ( const geometry::ChTriangleMesh tm)
virtual

Add a triangle, by passing a ChTriangle object (that will be copied, not referenced).

Note: the vertexes must be properly ordered (oriented triangle, normal pointing outside) Add a triangle mesh soup, by passing an entire ChTriangleMesh object. Note 1: the triangle mesh does not need connectivity information (a basic 'triangle soup' is enough) Note 2: all vertexes must be properly ordered (oriented triangles, normals pointing outside). Note 3: the triangles must define closed volumes (holes, gaps in edges, etc. may trouble the decomposition)

Reimplemented from chrono::collision::ChConvexDecomposition.

int chrono::collision::ChConvexDecompositionHACD::ComputeConvexDecomposition ( )
virtual

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::collision::ChConvexDecomposition.

bool chrono::collision::ChConvexDecompositionHACD::GetConvexHullResult ( unsigned int  hullIndex,
geometry::ChTriangleMesh convextrimesh 
)
virtual

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

Implements chrono::collision::ChConvexDecomposition.

bool chrono::collision::ChConvexDecompositionHACD::GetConvexHullResult ( unsigned int  hullIndex,
std::vector< ChVector< double > > &  convexhull 
)
virtual

Get the n-th computed convex hull, by filling a vector of points of the vertexes of the n-th hull that is passed as a parameter.

Implements chrono::collision::ChConvexDecomposition.

void chrono::collision::ChConvexDecompositionHACD::SetParameters ( unsigned int  nClusters = 2,
unsigned int  targetDecimation = 0,
double  smallClusterThreshold = 0.25,
bool  addFacesPoints = false,
bool  addExtraDistPoints = false,
double  concavity = 100.0,
double  ccConnectDist = 30,
double  volumeWeight = 0.0,
double  compacityAlpha = 0.1,
unsigned int  nVerticesPerCH = 50 
)

Set the parameters for this convex decomposition algorithm.

Use this function before calling ComputeConvexDecomposition().

Parameters
nClustersMinimum number of clusters
targetDecimationIf 0 no decimation, otherwise n.of vertexes in decimated mesh
smallClusterThresholdThreshold for small cluster grouping
addFacesPointsAdd points in faces in concavity
addExtraDistPointsAdd extra points in concavity
concavityMax allowed concavity
ccConnectDistMax allowed distance for cc to be connected
volumeWeight'beta' parameter, ie. volume weight
compacityAlpha'alpha' paramater
nVerticesPerCHMax vertices for cc.
void chrono::collision::ChConvexDecompositionHACD::WriteConvexHullsAsWavefrontObj ( ChStreamOutAscii mstream)
virtual

Save the computed convex hulls as a Wavefront file using the '.obj' fileformat, with each hull as a separate group.

May throw exceptions if file locked etc.

Implements chrono::collision::ChConvexDecomposition.