CGAL 6.1 - 3D Constrained Triangulations
Loading...
Searching...
No Matches
Constrained_triangulation_3/remesh_constrained_Delaunay_triangulation_3.cpp

How to use CGAL::tetrahedral_isotropic_remeshing with a constrained Delaunay triangulation.

How to use CGAL::tetrahedral_isotropic_remeshing with a constrained Delaunay triangulation.

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Conforming_constrained_Delaunay_triangulation_cell_base_3.h>
#include <CGAL/Conforming_constrained_Delaunay_triangulation_vertex_base_3.h>
#include <CGAL/Tetrahedral_remeshing/Remeshing_cell_base_3.h>
#include <CGAL/Tetrahedral_remeshing/Remeshing_vertex_base_3.h>
#include <CGAL/make_conforming_constrained_Delaunay_triangulation_3.h>
#include <CGAL/tetrahedral_remeshing.h>
#include <CGAL/IO/File_medit.h>
#include <CGAL/IO/polygon_mesh_io.h>
#include <CGAL/IO/write_MEDIT.h>
#include <CGAL/property_map.h>
#include <unordered_set>
#include <fstream>
#include <string>
// Triangulation for Remeshing
using CCDT_Tr = CCDT::Triangulation;
using Vertex_handle = Triangulation_3::Vertex_handle;
using Vertex_pair = std::pair<Vertex_handle, Vertex_handle>;
using Constraints_set = std::unordered_set<Vertex_pair, boost::hash<Vertex_pair>>;
int main(int argc, char* argv[])
{
std::string filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/mpi.off");
double target_edge_length = (argc > 2) ? std::stod(argv[2]) : 1.0;
unsigned int iterations = (argc > 3) ? std::stoi(argv[3]) : 3;
if(!CGAL::IO::read_polygon_mesh(filename, mesh))
{
std::cerr << "Error: cannot read file " << filename << std::endl;
return EXIT_FAILURE;
}
CCDT ccdt = CGAL::make_conforming_constrained_Delaunay_triangulation_3<CCDT>(mesh);
std::ofstream out("ccdt.mesh");
out.close();
Constraints_set constraints;
Constraints_pmap constraints_pmap(constraints);
namespace np = CGAL::parameters;
namespace Tet_remesh = CGAL::Tetrahedral_remeshing;
Tr tr = Tet_remesh::get_remeshing_triangulation(std::move(ccdt),
np::edge_is_constrained_map(constraints_pmap));
std::cout << "There are " << tr.number_of_vertices() << " vertices in the constrained triangulation" << std::endl;
target_edge_length,
np::number_of_iterations(iterations)
.edge_is_constrained_map(constraints_pmap));
std::cout << "There are " << tr.number_of_vertices() << " vertices after remeshing" << std::endl;
std::ofstream ofs("remeshed.mesh");
return EXIT_SUCCESS;
}
This class template represents a 3D conforming constrained Delaunay triangulation.
Definition: Conforming_constrained_Delaunay_triangulation_3.h:554
Cell base class for the 3D conforming constrained Delaunay triangulation.
Definition: Conforming_constrained_Delaunay_triangulation_cell_base_3.h:42
Vertex base class for the 3D conforming constrained Delaunay triangulation.
Definition: Conforming_constrained_Delaunay_triangulation_vertex_base_3.h:43
bool read_polygon_mesh(const std::string &fname, Graph &g, const NamedParameters &np=parameters::default_values())
void write_MEDIT(std::ostream &os, const T3 &t3, const NamedParameters &np=parameters::default_values())
void tetrahedral_isotropic_remeshing(CGAL::Triangulation_3< Traits, TDS, SLDS > &tr, const SizingFunction &sizing, const NamedParameters &np=parameters::default_values())
Definition: Conforming_constrained_Delaunay_triangulation_3.h:4174