Go to the documentation of this file.
3 #include <console_bridge/console.h>
23 void Update(
const double overallProgress,
24 const double stageProgress,
25 const char*
const stage,
26 const char* operation)
override
28 std::cout << std::setfill(
' ') << std::setw(3) << ceil(overallProgress) <<
"% "
29 <<
"[ " << stage <<
" " << std::setfill(
' ') << std::setw(3) << ceil(stageProgress) <<
"% ] " << operation
36 std::vector<std::shared_ptr<tesseract_geometry::ConvexMesh> >
41 std::vector<double> points_local;
42 points_local.reserve(vertices.size() * 3);
43 for (
const auto& v : vertices)
45 points_local.push_back(v.x());
46 points_local.push_back(v.y());
47 points_local.push_back(v.z());
50 std::vector<unsigned int> triangles_local;
51 triangles_local.reserve(
static_cast<std::size_t
>(faces.size()) / 4);
52 for (Eigen::Index i = 0; i < faces.rows();)
54 int face_vertice_cnt = faces(i++);
55 if (face_vertice_cnt != 3)
56 throw std::runtime_error(
"Currently only supports triangle meshes");
58 triangles_local.push_back(
static_cast<unsigned int>(faces(i++)));
59 triangles_local.push_back(
static_cast<unsigned int>(faces(i++)));
60 triangles_local.push_back(
static_cast<unsigned int>(faces(i++)));
80 bool res = interfaceVHACD->
Compute(points_local.data(),
81 static_cast<unsigned int>(points_local.size() / 3),
82 triangles_local.data(),
83 static_cast<unsigned int>(triangles_local.size() / 3),
86 std::vector<tesseract_geometry::ConvexMesh::Ptr> output;
91 for (
unsigned int p = 0; p < num_convex_hulls; ++p)
95 auto vhacd_vertices = std::make_shared<tesseract_common::VectorVector3d>();
96 vhacd_vertices->reserve(ch.m_points.size());
97 for (
const auto& m_point : ch.m_points)
99 Eigen::Vector3d v(m_point.mX, m_point.mY, m_point.mZ);
100 vhacd_vertices->push_back(v);
103 auto ch_vertices = std::make_shared<tesseract_common::VectorVector3d>();
104 auto ch_faces = std::make_shared<Eigen::VectorXi>();
106 output.push_back(std::make_shared<tesseract_geometry::ConvexMesh>(ch_vertices, ch_faces, ch_num_faces));
111 CONSOLE_BRIDGE_logError(
"Decomposition cancelled by user!");
114 interfaceVHACD->
Clean();
122 std::stringstream msg;
123 msg <<
"+ Parameters\n";
125 msg <<
"\t Voxel resolution " <<
resolution <<
"\n";
128 msg <<
"\t Shrinkwrap output to source mesh " <<
shrinkwrap <<
"\n";
129 msg <<
"\t Fill mode ";
136 msg <<
"SURFACE_ONLY";
139 msg <<
"RAYCAST_FILL";
144 msg <<
"\t Run asynchronously " <<
async_ACD <<
"\n";
146 msg <<
"\t Attempt to split planes along the best location " <<
find_best_plane <<
"\n";
148 std::cout << msg.str();
uint32_t m_maxConvexHulls
uint32_t m_maxRecursionDepth
uint32_t min_edge_length
Once a voxel patch has an edge length of less than 4 on all 3 sides, we don't keep recursing.
double minimum_volume_percent_error_allowed
if the voxels are within 1% of the volume of the hull, we consider this a close enough approximation
int createConvexHull(tesseract_common::VectorVector3d &vertices, Eigen::VectorXi &faces, const tesseract_common::VectorVector3d &input, double shrink=-1, double shrinkClamp=-1)
Create a convex hull from vertices using Bullet Convex Hull Computer.
double m_minimumVolumePercentErrorAllowed
void Update(const double overallProgress, const double stageProgress, const char *const stage, const char *operation) override
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
Convex decomposition VHACD implementation.
virtual bool GetConvexHull(const uint32_t index, ConvexHull &ch) const =0
This is a collection of common methods.
ConvexDecompositionVHACD()=default
uint32_t max_convex_hulls
The maximum number of convex hulls to produce.
bool find_best_plane
Whether or not to attempt to split planes along the best location. Experimental feature....
~ProgressCallback() override=default
virtual bool Compute(const float *const points, const uint32_t countPoints, const uint32_t *const triangles, const uint32_t countTriangles, const Parameters ¶ms)=0
std::vector< Eigen::Vector3d > VectorVector3d
virtual uint32_t GetNConvexHulls() const =0
VHACD::FillMode fill_mode
How to fill the interior of the voxelized mesh.
uint32_t resolution
The voxel resolution to use.
IUserCallback * m_callback
uint32_t m_maxNumVerticesPerCH
uint32_t max_recursion_depth
The maximum recursion depth.
ProgressCallback()=default
bool async_ACD
Whether or not to run asynchronously, taking advantage of additional cores.
ProgressCallback & operator=(const ProgressCallback &)=default
std::vector< std::shared_ptr< tesseract_geometry::ConvexMesh > > compute(const tesseract_common::VectorVector3d &vertices, const Eigen::VectorXi &faces) const override
Run convex decomposition algorithm.
uint32_t max_num_vertices_per_ch
The maximum number of vertices allowed in any output convex hull.
bool shrinkwrap
Whether or not to shrinkwrap the voxel positions to the source mesh on output.