CGAL 6.2 - Meshing and Remeshing of Polygonal Meshes

Loading...
Searching...
No Matches
PMP_Remeshing/delaunay_remeshing_example.cpp
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/detect_features.h>
#include <CGAL/Polygon_mesh_processing/surface_Delaunay_remeshing.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <CGAL/Mesh_constant_domain_field_3.h>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
typedef CGAL::Mesh_constant_domain_field_3<K, int> Sizing_field;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
std::string filename = (argc > 1) ? std::string(argv[1]) : CGAL::data_file_path("meshes/anchor_dense.off");
Mesh mesh;
if (!PMP::IO::read_polygon_mesh(filename, mesh) || !CGAL::is_triangle_mesh(mesh))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
double target_edge_length = (argc > 2) ? std::stod(std::string(argv[2])) : 0.02;
Sizing_field size(target_edge_length);
double fdist = (argc > 3) ? std::stod(std::string(argv[3])) : 0.01;
std::cout << "Detect features..." << std::endl;
using EIFMap = boost::property_map<Mesh, CGAL::edge_is_feature_t>::type;
EIFMap eif = get(CGAL::edge_is_feature, mesh);
PMP::detect_sharp_edges(mesh, 45, eif);
std::cout << "Start remeshing of " << filename << " (" << num_faces(mesh) << " faces)..." << std::endl;
Mesh outmesh = PMP::surface_Delaunay_remeshing(mesh, CGAL::parameters::protect_constraints(true)
.mesh_edge_size(size)
.mesh_facet_distance(fdist)
.edge_is_constrained_map(eif));
std::cout << "Remeshing done." << std::endl;
CGAL::IO::write_polygon_mesh("anchor_remeshed.off", outmesh, CGAL::parameters::stream_precision(17));
return 0;
}
CGAL::Exact_predicates_inexact_constructions_kernel
CGAL::Mesh_constant_domain_field_3
CGAL::Surface_mesh
CGAL::Polygon_mesh_processing::detect_sharp_edges
void detect_sharp_edges(const PolygonMesh &pmesh, FT angle_in_deg, EdgeIsFeatureMap edge_is_feature_map, const NamedParameters &np=parameters::default_values())
CGAL::Polygon_mesh_processing::surface_Delaunay_remeshing
TriangleMeshOut surface_Delaunay_remeshing(const TriangleMesh &tmesh, const NamedParameters &np=parameters::default_values())
remeshes a surface triangle mesh following the Delaunay refinement algorithm described in the 3D Mesh...
Definition: surface_Delaunay_remeshing.h:181
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())