CGAL 6.1 - Dynamic Skeletonization Via Variational Medial Axis Sampling
Loading...
Searching...
No Matches
Variational_medial_axis/vmas_class_interface.cpp
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Variational_medial_axis_sampling.h>
int main(int argc, char** argv)
{
const std::string filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/chair.off");
Mesh mesh;
if(!CGAL::IO::read_polygon_mesh(filename, mesh))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
// Compute medial skeleton with custom parameters
vmas.sample(
CGAL::parameters::number_of_iterations(1000) // number of max iterations
.number_of_spheres(200)// target number of spheres
.lambda(0.2) // lambda parameter for the optimization
.verbose(true)); // enable verbose output
// add additional 3 sphere, this function will update the medial skeleton automatically
vmas.add_spheres(3);
// update the medial skeleton with 20 iterations
vmas.update(20);
std::cout << "Exporting skeleton..." << std::endl;
auto skeleton = vmas.skeleton();
// Write skeleton to PLY file
std::string output_filename = "skeleton.ply";
CGAL::IO::write_PLY(skeleton, output_filename, CGAL::parameters::stream_precision(9));
}
Algorithm class for extracting a variational medial skeleton from a triangulated surface mesh.
Definition: Variational_medial_axis_sampling.h:539
void update(std::size_t nb_iteration)
performs a specified number of algorithm iterations.
Definition: Variational_medial_axis_sampling.h:849
bool sample(const NamedParameters &np=parameters::default_values())
computes a static skeleton based on the Variational Medial Axis Sampling method.
Definition: Variational_medial_axis_sampling.h:717
bool add_spheres(int nb_sphere)
adds spheres by iteratively splitting existing spheres.
Definition: Variational_medial_axis_sampling.h:869
Medial_skeleton< TriangleMesh, GeomTraits > skeleton() const
returns the medial skeleton as a Medial_skeleton object.
Definition: Variational_medial_axis_sampling.h:936
bool read_polygon_mesh(const std::string &fname, Graph &g, const NamedParameters &np=parameters::default_values())
bool write_PLY(std::ostream &out, const PointRange &points, const PolygonRange &polygons, const NamedParameters &np=parameters::default_values())
std::string data_file_path(const std::string &filename)