created Surface_mesh_decomposition package

added approximate_convex_decomposition doc to Convex_decomposition_3
added license file
This commit is contained in:
Sven Oesau 2025-11-20 12:08:02 +01:00
parent 2b97365ef1
commit 24dc3cdddd
16 changed files with 2185 additions and 5 deletions

View File

@ -17,8 +17,20 @@ decomposing both polyhedra into convex pieces, compute pairwise
Minkowski sums of the convex pieces, and unite the pairwise sums.
While it is desirable to have a decomposition into a minimum number of
pieces, this problem is known to be NP-hard \cgalCite{c-cpplb-84}. Our
implementation decomposes a Nef polyhedron \f$ N\f$ into \cgalBigO{r^2} convex
pieces, this problem is known to be NP-hard \cgalCite{c-cpplb-84}. This
package offers two methods for decomposing polyhedra. The
\ref Convex_decomposition_3Nef "Convex Decomposition of Nef Polyhedra"
splits polyhedra into convex pieces with an upper bound on the number
of pieces. The \ref Convex_decomposition_3ACD_Intro
"Approximate convex decomposition" method offers a fast
approximate decomposition of the convex hull into convex volumes. While
any number of convex volumes can be generated, these convex volumes
are more compact than the convex hull, but still include additional
empty space than just the input polyhedron.
\section Convex_decomposition_3Nef Convex Decomposition of Nef Polyhedra
Our implementation decomposes a Nef polyhedron \f$ N\f$ into \cgalBigO{r^2} convex
pieces, where \f$ r\f$ is the number of edges that have two adjacent
facets that span an angle of more than 180 degrees with respect to the
interior of the polyhedron. Those edges are also called reflex edges.
@ -38,7 +50,7 @@ illustrates the two steps.
At the moment our implementation is restricted to the decomposition of
bounded polyhedra. An extension to unbounded polyhedra is planned.
\section Convex_decomposition_3InterfaceandUsage Interface and Usage
\subsection Convex_decomposition_3InterfaceandUsage Interface and Usage
An instance of `Nef_polyhedron_3` represents a subdivision of the
three-dimensional space into vertices, edges, facets, and
@ -79,6 +91,271 @@ support the use of extended kernels in the convex decomposition.
\cgalExample{Convex_decomposition_3/list_of_convex_parts.cpp}
\section Convex_decomposition_3ACD_Intro Approximate Convex Decomposition
\cgalFigureAnchor{Acd_topfig}
<center>
<img src="https://soesau.github.io/acd_top.jpg" style="max-width:70%;"/>
</center>
\cgalFigureCaptionBegin{Acd_topfig}
Approximate convex decomposition of the elephant.off model.\n From left to right: 1. input mesh 2. 5 convex volumes 3. 8 convex volumes 4. 12 convex volumes
\cgalFigureCaptionEnd
The H-VACD, introduced by computes a set of convex volumes that fit the polyhedron. Contrary to the decomposition of the polyhedron into convex parts, the convex volumes cover the polyhedron, but also include additional volume outside of the polyhedron.
A sufficiently tight enclosure of the polyhedron by several convex volumes allows fast intersection calculation and collision detection among polyhedra while offering a non-hierachical approach and may thus be easier to use in a parallel setting.
The resulting set of convex volumes minimizes the volume between their union and the polyhedron while fully including the input polyhedron. While the optimal solution with `n` convex hulls that cover the polydron with the smallest additional volume remains NP-hard, this method provides a fast error-driven approximation.
\subsection Convex_decomposition_3ACD_Algorithm Algorithm
The algorithm computes a set of convex volumes \f$ C=\{C_i\f$ with \f$ i \in[0..n-1]\} \f$ that cover the input polyhedron while minimizing the additional covered volume:
\f{equation}{
\arg \min_C d(\bigcup_{C_i \in C} C_i, P) \\
\f}
<center>with</center>
\f{equation}{
d(A, B) = |A| - |B|
\f}
Where \f$|A|\f$ is the volume of A, P is the input polyhedron and \f$C_i\f$ are convex volumes. The convex volumes \f$C_i\f$ are pairwise disjunct, i.e., \f$|C_i \cap C_j| = 0\f$ if \f$i \neq j\f$. And the union of convex volumes contain the input polyhedron \f$ P \subset \bigcup_{C_i \in C} \f$.
\cgalFigureAnchor{Acd_pipelinefig}
<center>
<img src="https://soesau.github.io/acd_pipeline.jpg" style="max-width:90%;"/>
</center>
\cgalFigureCaptionBegin{Acd_pipelinefig}
Approximate convex decomposition pipeline.\n From left to right: 1. input mesh 2. voxel grid 3. convex volumes after error-driven splitting 4. final convex volumes after merging
\cgalFigureCaptionEnd
The method employs a top-down splitting phase followed by a bottom-up merging to achieve the target number of convex volumes. The splitting phase aims at decomposing the input mesh into smaller mostly convex parts. Each part of the input mesh is approximated with its convex hull. In a hierarchical manner, each part of the mesh is split into two parts when its convexity is low. The convexity is measured by the volume difference of the part and its convex hull. Splitting a part into two can be done by simply cutting the longest side of the bounding box in half. A better choice is often found by searching the longest side of the bounding box for a concave spot. However, it comes with a higher computational cost. The hierarchical splitting stops when either the convexity is sufficiently high or the maximum depth is reached.
The volume calculation, convex hull computation and the concavity search is accelerated by a voxel grid. The grid is prepared before the splitting phase and is labelled into outside, inside or surface. The convex hulls are calculated from voxel corners. Thus, a mesh with a high resolution is less penalized by its number of vertices.
The splitting phase typically results in a number of convex volumes larger than targeted. The second phase employs a bottom-up merging that reduces the number of convex volumes to the targeted number while aiming at maintaining a low volume difference between convex volumes and the input mesh. The greedy merging maintains a priority queue to incrementally merge the pair of convex volumes with the smallest increase of volume difference.
The splitting phase is not limited by the chosen `maximum_number_of_convex_hulls`, because a splitting into a larger number of more convex parts with a subsequent merging leads to better results.
\subsection Convex_decomposition_3ACD_Parameters Parameters
Several parameters of the algorithm impact the quality of the result as well as the running time.
- `maximum_number_of_convex_hulls`: The maximum number of convex volumes output by the method. The actual number may be lower for mostly convex input meshes, e.g., a sphere. The impact on the running time is rather low. The default is 16.
- `maximum_depth`: The maximum depth for the hierarchical splitting phase. For complex meshes, a higher maximum depth is required to split small concavities into convex parts. The choice of `maximum_depth` has a larger impact on the running time. The default is 10.
- `maximum_number_of_voxels`: This parameter controls the resolution of the voxel grid used for speed-up. Larger numbers result in a higher memory footprint and a higher running time. A small number also limits the `maximum_depth`. The voxel grid is isotropic and the longest axis of the bounding box will be split into a number of voxels equal to the cubic root of `maximum_number_of_voxels`. The default value is 1.000.000.
- `volume_error`: The splitting of a convex volume into smaller parts is controlled by the `volume_error` which provides the tolerance for difference in volume. The difference is calculated by \f$ (|C_i| - |P_i|) / |P_i|\f$. The default value is 0.01. Thus, if a convex volume has 1 percent more volume that the part of the input mesh it approximates, it will be further divided.
- `split_at_concavity`: The splitting can be either performed after searching a concavity on the longest side of the bounding box or simply by splitting the longest side of the bounding box in half. The default value is true, i.e., splitting at the concavity.
\subsection Convex_decomposition_3ACD_Performance Performance
<b>Here will be images and more tables to show the impact of different parameters</b>
The method has been evaluated on several models:
<TABLE CELLSPACING=5 >
<TR><TD ALIGN=LEFT NOWRAP COLSPAN=5><HR>
<TR>
<TD class="math" ALIGN=CENTER NOWRAP>
Data set
<TD class="math" ALIGN=CENTER NOWRAP>
Faces
<TD class="math" ALIGN=CENTER NOWRAP>
Volume
<TD class="math" ALIGN=CENTER NOWRAP>
Convex hull volume
<TD class="math" ALIGN=CENTER NOWRAP>
Overhead
<TR><TD ALIGN=LEFT NOWRAP COLSPAN=5><HR>
<TR>
<TD class="math" ALIGN=CENTER NOWRAP>
Camel
<TD class="math" ALIGN=RIGHT NOWRAP>
19.536
<TD class="math" ALIGN=RIGHT NOWRAP>
0.0468
<TD class="math" ALIGN=RIGHT NOWRAP>
0.15541
<TD class="math" ALIGN=CENTER NOWRAP>
2.32388
<TR>
<TD class="math" ALIGN=CENTER NOWRAP>
Elephant
<TD class="math" ALIGN=RIGHT NOWRAP>
5.558
<TD class="math" ALIGN=RIGHT NOWRAP>
0.0462
<TD class="math" ALIGN=RIGHT NOWRAP>
0.12987
<TD class="math" ALIGN=CENTER NOWRAP>
1.81087
<TR>
<TD class="math" ALIGN=CENTER NOWRAP>
Triceratops
<TD class="math" ALIGN=RIGHT NOWRAP>
5.660
<TD class="math" ALIGN=RIGHT NOWRAP>
136.732
<TD class="math" ALIGN=RIGHT NOWRAP>
336.925
<TD class="math" ALIGN=CENTER NOWRAP>
1.46412
<TR>
<TD ALIGN=LEFT NOWRAP COLSPAN=12><HR>
</TABLE>
If not mentioned otherwise, all tests used a volume error of 0.01, a maximum depth of 10, 1 million voxels and split at the concavity.
Impact of varying the number of generated convex volumes with splitting at the concavity on volume overhead:
<TABLE CELLSPACING=5 >
<TR><TD ALIGN=LEFT NOWRAP COLSPAN=7><HR>
<TR>
<TD class="math" ALIGN=CENTER NOWRAP>
Data set
<TD class="math" ALIGN=CENTER NOWRAP>
Split location
<TD class="math" ALIGN=CENTER NOWRAP>
5 volumes
<TD class="math" ALIGN=CENTER NOWRAP>
7 volumes
<TD class="math" ALIGN=CENTER NOWRAP>
9 volumes
<TD class="math" ALIGN=CENTER NOWRAP>
11 volumes
<TD class="math" ALIGN=CENTER NOWRAP>
12 volumes
<TR><TD ALIGN=LEFT NOWRAP COLSPAN=7><HR>
<TR>
<TD class="math" ALIGN=CENTER NOWRAP>
Camel
<TD class="math" ALIGN=RIGHT NOWRAP>
Concavity
<TD class="math" ALIGN=LEFT NOWRAP>
0.8006
<TD class="math" ALIGN=LEFT NOWRAP>
0.6680
<TD class="math" ALIGN=LEFT NOWRAP>
0.5871
<TD class="math" ALIGN=LEFT NOWRAP>
0.5736
<TD class="math" ALIGN=LEFT NOWRAP>
0.5463
<TD class="math" ALIGN=LEFT NOWRAP>
<TR>
<TD class="math" ALIGN=CENTER NOWRAP>
Elephant
<TD class="math" ALIGN=RIGHT NOWRAP>
Concavity
<TD class="math" ALIGN=LEFT NOWRAP>
1.1927
<TD class="math" ALIGN=LEFT NOWRAP>
0.9731
<TD class="math" ALIGN=LEFT NOWRAP>
0.84613
<TD class="math" ALIGN=LEFT NOWRAP>
0.7506
<TD class="math" ALIGN=LEFT NOWRAP>
0.6947
<TD class="math" ALIGN=LEFT NOWRAP>
<TR>
<TD class="math" ALIGN=CENTER NOWRAP>
Triceratops
<TD class="math" ALIGN=RIGHT NOWRAP>
Concavity
<TD class="math" ALIGN=LEFT NOWRAP>
0.9770
<TD class="math" ALIGN=LEFT NOWRAP>
0.7676
<TD class="math" ALIGN=LEFT NOWRAP>
0.6722
<TD class="math" ALIGN=LEFT NOWRAP>
0.5971
<TD class="math" ALIGN=LEFT NOWRAP>
0.5658
<TD class="math" ALIGN=LEFT NOWRAP>
<TR>
<TD ALIGN=LEFT NOWRAP COLSPAN=7><HR>
</TABLE>
And by using the mid split:
<TABLE CELLSPACING=5 >
<TR><TD ALIGN=LEFT NOWRAP COLSPAN=7><HR>
<TR>
<TD class="math" ALIGN=CENTER NOWRAP>
Data set
<TD class="math" ALIGN=CENTER NOWRAP>
Split location
<TD class="math" ALIGN=CENTER NOWRAP>
5 volumes
<TD class="math" ALIGN=CENTER NOWRAP>
7 volumes
<TD class="math" ALIGN=CENTER NOWRAP>
9 volumes
<TD class="math" ALIGN=CENTER NOWRAP>
11 volumes
<TD class="math" ALIGN=CENTER NOWRAP>
12 volumes
<TR><TD ALIGN=LEFT NOWRAP COLSPAN=7><HR>
<TR>
<TD class="math" ALIGN=CENTER NOWRAP>
Camel
<TD class="math" ALIGN=RIGHT NOWRAP>
Mid
<TD class="math" ALIGN=LEFT NOWRAP>
1.1158
<TD class="math" ALIGN=LEFT NOWRAP>
1.0468
<TD class="math" ALIGN=LEFT NOWRAP>
0.8660
<TD class="math" ALIGN=LEFT NOWRAP>
0.6764
<TD class="math" ALIGN=LEFT NOWRAP>
0.6057
<TD class="math" ALIGN=LEFT NOWRAP>
<TR>
<TD class="math" ALIGN=CENTER NOWRAP>
Elephant
<TD class="math" ALIGN=RIGHT NOWRAP>
Mid
<TD class="math" ALIGN=LEFT NOWRAP>
1.2121
<TD class="math" ALIGN=LEFT NOWRAP>
1.00867
<TD class="math" ALIGN=LEFT NOWRAP>
0.8444
<TD class="math" ALIGN=LEFT NOWRAP>
0.7465
<TD class="math" ALIGN=LEFT NOWRAP>
0.6931
<TD class="math" ALIGN=LEFT NOWRAP>
<TR>
<TD class="math" ALIGN=CENTER NOWRAP>
Triceratops
<TD class="math" ALIGN=RIGHT NOWRAP>
Mid
<TD class="math" ALIGN=LEFT NOWRAP>
1.2191
<TD class="math" ALIGN=LEFT NOWRAP>
0.6870
<TD class="math" ALIGN=LEFT NOWRAP>
0.8463
<TD class="math" ALIGN=LEFT NOWRAP>
0.7375
<TD class="math" ALIGN=LEFT NOWRAP>
0.6871
<TD class="math" ALIGN=LEFT NOWRAP>
<TR>
<TD ALIGN=LEFT NOWRAP COLSPAN=7><HR>
</TABLE>
The running time for all cases in the above tables were between 1.4 and 3 seconds while being slightly lower when splitting at the concavity. Although searching the voxel grid for the concavity takes additional computational time, it is more than compensated by fewer splits.
\subsection Convex_decomposition_3ACD_Example Example
\cgalExample{Surface_mesh_decomposition/approximate_convex_decomposition.cpp }
*/
} /* namespace CGAL */

View File

@ -3,3 +3,7 @@
PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - Convex Decomposition of Polyhedra"
EXTRACT_ALL = false
HIDE_UNDOC_CLASSES = true
INPUT += ${CGAL_Surface_mesh_decomposition_INCLUDE_DIR}/CGAL/approximate_convex_decomposition.h
EXAMPLE_PATH += ${CGAL_Surface_mesh_decomposition_EXAMPLE_DIR}

View File

@ -5,8 +5,9 @@
\cgalPkgDescriptionBegin{Convex Decomposition of Polyhedra,PkgConvexDecomposition3}
\cgalPkgPicture{Convex_decomposition_3/fig/Convex_decomposition_3-teaser.png}
\cgalPkgSummaryBegin
\cgalPkgAuthor{Peter Hachenberger}
\cgalPkgDesc{This packages provides a function for decomposing a bounded polyhedron into convex sub-polyhedra. The decomposition yields \cgalBigO{r^2} convex pieces, where \f$ r\f$ is the number of edges, whose adjacent facets form an angle of more than 180 degrees with respect to the polyhedron's interior. This bound is worst-case optimal. }
\cgalPkgAuthor{Peter Hachenberger, Sven Oesau}
\cgalPkgDesc{This packages provides two functions for computing a set of convex volumes that cover a bounded polyhedron. The `CGAL::convex_decomposition_3()` splits provides a decomposition into \cgalBigO{r^2} convex pieces, where \f$ r\f$ is the number of edges, whose adjacent facets form an angle of more than 180 degrees with respect to the polyhedron's interior. This bound is worst-case optimal.
The `CGAL::approximate_convex_decomposition()` instead splits the convex hull of the polyhedron into a set of convex volumes. While these convex volumes cover additional space outside of the polyhedron, the computation is fast for any chosen number of convex volumes.}
\cgalPkgManuals{Chapter_Convex_Decomposition_of_Polyhedra,PkgConvexDecomposition3Ref}
\cgalPkgSummaryEnd
\cgalPkgShortInfoBegin
@ -21,6 +22,7 @@
\cgalCRPSection{Functions}
- `CGAL::convex_decomposition_3(Nef_polyhedron_3& N)`
- `CGAL::approximate_convex_decomposition()`
*/

View File

@ -5,3 +5,4 @@ Algebraic_foundations
Circulator
Stream_support
Nef_3
BGL

View File

@ -1,3 +1,4 @@
/*!
\example Convex_decomposition_3/list_of_convex_parts.cpp
\example Surface_mesh_decomposition/approximate_convex_decomposition.cpp
*/

View File

@ -0,0 +1,54 @@
// Copyright (c) 2016 GeometryFactory SARL (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org)
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial
//
// Author(s) : Andreas Fabri
//
// Warning: this file is generated, see include/CGAL/license/README.md
#ifndef CGAL_LICENSE_SURFACE_MESH_DECOMPOSITION_H
#define CGAL_LICENSE_SURFACE_MESH_DECOMPOSITION_H
#include <CGAL/config.h>
#include <CGAL/license.h>
#ifdef CGAL_SURFACE_MESH_DECOMPOSITION_COMMERCIAL_LICENSE
# if CGAL_SURFACE_MESH_DECOMPOSITION_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE
# if defined(CGAL_LICENSE_WARNING)
CGAL_pragma_warning("Your commercial license for CGAL does not cover "
"this release of the Triangulated Surface Mesh Decomposition package.")
# endif
# ifdef CGAL_LICENSE_ERROR
# error "Your commercial license for CGAL does not cover this release \
of the Triangulated Surface Mesh Decomposition package. \
You get this error, as you defined CGAL_LICENSE_ERROR."
# endif // CGAL_LICENSE_ERROR
# endif // CGAL_SURFACE_MESH_DECOMPOSITION_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE
#else // no CGAL_SURFACE_MESH_DECOMPOSITION_COMMERCIAL_LICENSE
# if defined(CGAL_LICENSE_WARNING)
CGAL_pragma_warning("\nThe macro CGAL_SURFACE_MESH_DECOMPOSITION_COMMERCIAL_LICENSE is not defined."
"\nYou use the CGAL Triangulated Surface Mesh Decomposition package under "
"the terms of the GPLv3+.")
# endif // CGAL_LICENSE_WARNING
# ifdef CGAL_LICENSE_ERROR
# error "The macro CGAL_SURFACE_MESH_DECOMPOSITION_COMMERCIAL_LICENSE is not defined.\
You use the CGAL Triangulated Surface Mesh Decomposition package under the terms of \
the GPLv3+. You get this error, as you defined CGAL_LICENSE_ERROR."
# endif // CGAL_LICENSE_ERROR
#endif // no CGAL_SURFACE_MESH_DECOMPOSITION_COMMERCIAL_LICENSE
#endif // CGAL_LICENSE_SURFACE_MESH_DECOMPOSITION_H

View File

@ -93,6 +93,7 @@ Straight_skeleton_extrusion_2 2D Straight Skeleton Extrusion
Stream_lines_2 2D Placement of Streamlines
Surface_mesh_approximation Triangulated Surface Mesh Approximation
Surface_mesh_deformation Triangulated Surface Mesh Deformation
Surface_mesh_decomposition Triangulated Surface Mesh Decomposition
Surface_mesher 3D Surface Mesh Generation
Surface_mesh Surface Mesh
Surface_mesh_parameterization Triangulated Surface Mesh Parameterization

View File

@ -0,0 +1,19 @@
# Created by the script cgal_create_CMakeLists
# This is the CMake script for compiling a set of CGAL applications.
cmake_minimum_required(VERSION 3.12...3.31)
project(Surface_mesh_decomposition_Examples)
# CGAL and its components
find_package(CGAL REQUIRED)
find_package(TBB QUIET)
include(CGAL_TBB_support)
create_single_source_cgal_program("approximate_convex_decomposition.cpp")
if(TARGET CGAL::TBB_support)
target_link_libraries(approximate_convex_decomposition PRIVATE CGAL::TBB_support)
else()
message(STATUS "NOTICE: Intel TBB was not found. Sequential code will be used.")
endif()

View File

@ -0,0 +1,47 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/approximate_convex_decomposition.h>
#include <iostream>
#include <string>
#include <vector>
using K = CGAL::Exact_predicates_inexact_constructions_kernel;
using Point = K::Point_3;
using Convex_hull = std::pair<std::vector<Point>, std::vector<std::array<unsigned int, 3> > >;
using Mesh = CGAL::Surface_mesh<Point>;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const std::string filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/knot2.off");
std::cout << filename << std::endl;
Mesh mesh;
if(!PMP::IO::read_polygon_mesh(filename, mesh)) {
std::cerr << "Invalid input." << std::endl;
return 1;
}
std::vector<Convex_hull> convex_hulls;
convex_hulls.reserve(9);
CGAL::approximate_convex_decomposition(mesh, std::back_inserter(convex_hulls),
CGAL::parameters::maximum_depth(10)
.volume_error(0.1)
.maximum_number_of_convex_hulls(9)
.split_at_concavity(true)
.maximum_number_of_voxels(1000000)
.concurrency_tag(CGAL::Parallel_if_available_tag()));
for (std::size_t i = 0;i<convex_hulls.size();i++) {
const Convex_hull& ch = convex_hulls[i];
CGAL::IO::write_polygon_soup(std::to_string(i) + ".off", ch.first, ch.second);
}
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
GeometryFactory

View File

@ -0,0 +1,25 @@
Algebraic_foundations
Arithmetic_kernel
BGL
CGAL_Core
Cartesian_kernel
Circulator
Convex_decomposition_3
Convex_hull_3
Distance_3
HalfedgeDS
Hash_map
Homogeneous_kernel
Installation
Intersections_3
Interval_support
Kernel_23
Modifier
Number_types
Polyhedron
Polygon_mesh_processing
Profiling_tools
Property_map
STL_Extension
Spatial_sorting
Stream_support

View File

@ -0,0 +1 @@
GPL (v3 or later)

View File

@ -0,0 +1 @@
GeometryFactory

View File

@ -0,0 +1,10 @@
# Created by the script cgal_create_CMakeLists
# This is the CMake script for compiling a set of CGAL applications.
cmake_minimum_required(VERSION 3.12...3.31)
project(Surface_mesh_decomposition_Examples)
# CGAL and its components
find_package(CGAL REQUIRED)
create_single_source_cgal_program("test_acd.cpp")

View File

@ -0,0 +1,58 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/approximate_convex_decomposition.h>
#include <iostream>
#include <string>
#include <vector>
using K = CGAL::Exact_predicates_inexact_constructions_kernel;
using Point = K::Point_3;
using Convex_hull = std::pair<std::vector<Point>, std::vector<std::array<unsigned int, 3> > >;
using Mesh = CGAL::Surface_mesh<Point>;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const std::string filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/knot2.off");
std::cout << filename << std::endl;
Mesh mesh;
std::vector<Convex_hull> convex_hulls;
// Try with empty mesh
CGAL::approximate_convex_decomposition(mesh, std::back_inserter(convex_hulls),
CGAL::parameters::maximum_depth(10)
.volume_error(0.1)
.maximum_number_of_convex_hulls(9)
.split_at_concavity(true)
.maximum_number_of_voxels(1000000)
.concurrency_tag(CGAL::Parallel_if_available_tag()));
assert(convex_hulls.size() == 0);
if (!PMP::IO::read_polygon_mesh(filename, mesh)) {
std::cerr << "Invalid input." << std::endl;
return 1;
}
convex_hulls.reserve(9);
CGAL::approximate_convex_decomposition(mesh, std::back_inserter(convex_hulls),
CGAL::parameters::maximum_depth(10)
.volume_error(0.1)
.maximum_number_of_convex_hulls(9)
.split_at_concavity(true)
.maximum_number_of_voxels(1000000)
.concurrency_tag(CGAL::Parallel_if_available_tag()));
assert(convex_hulls.size() > 0);
assert(convex_hulls.size() <= 9);
return 0;
}