chrono::ChConvexDecompositionHACD Class Reference

Description

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

#include <ChConvexDecomposition.h>

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

Public Member Functions

 ChConvexDecompositionHACD ()
 Basic constructor.
 
virtual ~ChConvexDecompositionHACD ()
 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...
 
virtual bool AddTriangleMesh (const ChTriangleMesh &tm) override
 Add a triangle mesh soup, by passing an entire ChTriangleMesh object. More...
 
void SetParameters (unsigned int num_clusters=2, unsigned int target_decimation=0, double small_cluster_threshold=0.25, bool add_faces_points=false, bool add_extra_dist_points=false, double concavity=100.0, double cc_connect_dist=30, double volume_weight=0.0, double compacity_alpha=0.1, unsigned int num_vertices_per_CH=50)
 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 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::ChConvexDecompositionHACD::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.

◆ AddTriangleMesh()

bool chrono::ChConvexDecompositionHACD::AddTriangleMesh ( const ChTriangleMesh tm)
overridevirtual

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 vertices must have proper winding (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::ChConvexDecomposition.

◆ ComputeConvexDecomposition()

unsigned int chrono::ChConvexDecompositionHACD::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::ChConvexDecompositionHACD::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::ChConvexDecompositionHACD::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::ChConvexDecompositionHACD::SetParameters ( unsigned int  num_clusters = 2,
unsigned int  target_decimation = 0,
double  small_cluster_threshold = 0.25,
bool  add_faces_points = false,
bool  add_extra_dist_points = false,
double  concavity = 100.0,
double  cc_connect_dist = 30,
double  volume_weight = 0.0,
double  compacity_alpha = 0.1,
unsigned int  num_vertices_per_CH = 50 
)

Set the parameters for this convex decomposition algorithm.

Use this function before calling ComputeConvexDecomposition().

Parameters
num_clustersminimum number of clusters generated
target_decimationif 0 no decimation, otherwise number of vertices in decimated mesh
small_cluster_thresholdthreshold for small cluster grouping, as percentage of tot mesh surface
add_faces_pointsadd points in faces in concavity
add_extra_dist_pointsadd extra points in concavity
concavitymax allowed concavity
cc_connect_distmax allowed distance for cc to be connected
volume_weight'beta' parameter, ie. volume weight
compacity_alpha'alpha' parameter, ie. compacity weight
num_vertices_per_CHmax vertices per conxex hull

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