CGAL 6.2 - Meshing and Remeshing of Polygonal Meshes: PMP_Remeshing/isotropic_remeshing_with_sizing_example.cpp

CGAL 6.2 - Meshing and Remeshing of Polygonal Meshes

Loading...
Searching...
No Matches
PMP_Remeshing/isotropic_remeshing_with_sizing_example.cpp
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/remesh.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/Polygon_mesh_processing/Adaptive_sizing_field.h>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
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/nefertiti.off");
Mesh mesh;
if (!PMP::IO::read_polygon_mesh(filename, mesh) || !CGAL::is_triangle_mesh(mesh))
{
std::cerr << "Not a valid input file." << std::endl;
return 1;
}
std::cout << "Start remeshing of " << filename << " (" << num_faces(mesh) << " faces)..." << std::endl;
const double tol = 0.001;
const std::pair edge_min_max{0.001, 0.5};
PMP::Adaptive_sizing_field<Mesh> sizing_field(tol, edge_min_max, faces(mesh), mesh);
unsigned int nb_iter = 5;
PMP::isotropic_remeshing(faces(mesh), sizing_field, mesh,
CGAL::parameters::number_of_iterations(nb_iter)
.number_of_relaxation_steps(3));
std::cout << "Remeshing done." << std::endl;
CGAL::IO::write_polygon_mesh("out.off", mesh, CGAL::parameters::stream_precision(17));
return 0;
}
CGAL::Exact_predicates_inexact_constructions_kernel
CGAL::Polygon_mesh_processing::Adaptive_sizing_field
A sizing field describing variable target mesh edge lengths for CGAL::Polygon_mesh_processing::isotro...
Definition: Adaptive_sizing_field.h:58
CGAL::Surface_mesh
CGAL::Polygon_mesh_processing::isotropic_remeshing
void isotropic_remeshing(const FaceRange &faces, SizingFunction &sizing, PolygonMesh &pmesh, const NamedParameters &np=parameters::default_values())
remeshes a triangulated region of a polygon mesh.
Definition: remesh.h:217
CGAL::is_triangle_mesh
bool is_triangle_mesh(const FaceGraph &g)
CGAL::IO::write_polygon_mesh
bool write_polygon_mesh(const std::string &fname, Graph &g, const NamedParameters &np=parameters::default_values())