Skip to content

Commit 6e71a7e

Browse files
marrtsLevi-Armstrong
authored andcommitted
Make printouts during convex decomposition optional at compute time
1 parent edda8d3 commit 6e71a7e

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

tesseract_collision/bullet/include/tesseract_collision/bullet/convex_decomposition_hacd.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class ConvexDecompositionHACD : public ConvexDecomposition
5555
ConvexDecompositionHACD(const HACDParameters& params);
5656

5757
std::vector<std::shared_ptr<tesseract_geometry::ConvexMesh>> compute(const tesseract_common::VectorVector3d& vertices,
58-
const Eigen::VectorXi& faces) const override;
58+
const Eigen::VectorXi& faces,
59+
bool verbose = true) const override;
5960

6061
private:
6162
HACDParameters params_;

tesseract_collision/bullet/src/convex_decomposition_hacd.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ namespace tesseract_collision
1717
ConvexDecompositionHACD::ConvexDecompositionHACD(const HACDParameters& params) : params_(params) {}
1818

1919
std::vector<tesseract_geometry::ConvexMesh::Ptr>
20-
ConvexDecompositionHACD::compute(const tesseract_common::VectorVector3d& vertices, const Eigen::VectorXi& faces) const
20+
ConvexDecompositionHACD::compute(const tesseract_common::VectorVector3d& vertices,
21+
const Eigen::VectorXi& faces,
22+
bool verbose) const
2123
{
22-
params_.print();
24+
if (verbose)
25+
params_.print();
2326

2427
std::vector<HACD::Vec3<HACD::Real>> points_local;
2528
points_local.reserve(vertices.size());

tesseract_collision/core/include/tesseract_collision/core/convex_decomposition.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ class ConvexDecomposition
5353
* @return
5454
*/
5555
virtual std::vector<std::shared_ptr<tesseract_geometry::ConvexMesh>>
56-
compute(const tesseract_common::VectorVector3d& vertices, const Eigen::VectorXi& faces) const = 0;
56+
compute(const tesseract_common::VectorVector3d& vertices,
57+
const Eigen::VectorXi& faces,
58+
bool verbose = true) const = 0;
5759
};
5860

5961
} // namespace tesseract_collision

tesseract_collision/vhacd/include/tesseract_collision/vhacd/convex_decomposition_vhacd.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ class ConvexDecompositionVHACD : public ConvexDecomposition
7373
ConvexDecompositionVHACD(const VHACDParameters& params);
7474

7575
std::vector<std::shared_ptr<tesseract_geometry::ConvexMesh>> compute(const tesseract_common::VectorVector3d& vertices,
76-
const Eigen::VectorXi& faces) const override;
76+
const Eigen::VectorXi& faces,
77+
bool verbose = true) const override;
7778

7879
private:
7980
VHACDParameters params_;

tesseract_collision/vhacd/src/convex_decomposition_vhacd.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class ProgressCallback : public VHACD::IVHACD::IUserCallback
1515
public:
1616
ProgressCallback() = default;
1717
~ProgressCallback() override = default;
18+
ProgressCallback(bool verbose) : verbose_(verbose) {}
1819
ProgressCallback(const ProgressCallback&) = default;
1920
ProgressCallback& operator=(const ProgressCallback&) = default;
2021
ProgressCallback(ProgressCallback&&) = default;
@@ -25,18 +26,26 @@ class ProgressCallback : public VHACD::IVHACD::IUserCallback
2526
const char* const stage,
2627
const char* operation) override
2728
{
29+
if (!verbose_)
30+
return;
2831
std::cout << std::setfill(' ') << std::setw(3) << ceil(overallProgress) << "% "
2932
<< "[ " << stage << " " << std::setfill(' ') << std::setw(3) << ceil(stageProgress) << "% ] " << operation
3033
<< "\n";
3134
}
35+
36+
private:
37+
bool verbose_{ true };
3238
};
3339

3440
ConvexDecompositionVHACD::ConvexDecompositionVHACD(const VHACDParameters& params) : params_(params) {}
3541

3642
std::vector<std::shared_ptr<tesseract_geometry::ConvexMesh> >
37-
ConvexDecompositionVHACD::compute(const tesseract_common::VectorVector3d& vertices, const Eigen::VectorXi& faces) const
43+
ConvexDecompositionVHACD::compute(const tesseract_common::VectorVector3d& vertices,
44+
const Eigen::VectorXi& faces,
45+
bool verbose) const
3846
{
39-
params_.print();
47+
if (verbose)
48+
params_.print();
4049

4150
std::vector<double> points_local;
4251
points_local.reserve(vertices.size() * 3);
@@ -63,7 +72,7 @@ ConvexDecompositionVHACD::compute(const tesseract_common::VectorVector3d& vertic
6372
// run V-HACD
6473
VHACD::IVHACD* interfaceVHACD = VHACD::CreateVHACD();
6574

66-
ProgressCallback progress_callback;
75+
ProgressCallback progress_callback(verbose);
6776
VHACD::IVHACD::Parameters par;
6877
par.m_maxConvexHulls = params_.max_convex_hulls;
6978
par.m_resolution = params_.resolution;

0 commit comments

Comments
 (0)