From 12f15bf3f8f269a2cbdb48f5aff9cb57d02fad3d Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Tue, 6 Jun 2017 12:11:19 +0200 Subject: [PATCH] add an example for random perturbation --- .../random_perturbation_SM_example.cpp | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Polygon_mesh_processing/examples/Polygon_mesh_processing/random_perturbation_SM_example.cpp diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/random_perturbation_SM_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/random_perturbation_SM_example.cpp new file mode 100644 index 00000000000..8d4d69dbe98 --- /dev/null +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/random_perturbation_SM_example.cpp @@ -0,0 +1,40 @@ +#include +#include + +#include + +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; +typedef K::Point_3 Point; + +typedef CGAL::Surface_mesh Surface_mesh; +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef boost::graph_traits::face_descriptor face_descriptor; + +int main(int argc, char* argv[]) +{ + const char* filename = (argc > 1) ? argv[1] : "data/eight.off"; + std::ifstream input(filename); + + Surface_mesh mesh; + if (!input || !(input >> mesh) || mesh.is_empty()) { + std::cerr << "Not a valid off file." << std::endl; + return 1; + } + + const double max_size = (argc > 2) ? atof(argv[2]) : 0.02; + + namespace PMP = CGAL::Polygon_mesh_processing; + PMP::random_perturbation( + mesh, + max_size, + PMP::parameters::vertex_point_map(mesh.points()).geom_traits(K())); + + std::ofstream out("data/eight_perturbed.off"); + out << mesh; + out.close(); + + return 0; +}