#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Mesh_triangulation_3.h>
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
#include <CGAL/Mesh_criteria_3.h>
#include <CGAL/Mesh_domain_with_polyline_features_3.h>
#include <CGAL/Labeled_mesh_domain_3.h>
#include <CGAL/Image_3.h>
#include <CGAL/Mesh_3/Detect_features_in_image.h>
#include <CGAL/make_mesh_3.h>
#include <CGAL/tetrahedral_remeshing.h>
#include <CGAL/property_map.h>
#include <unordered_set>
#include <iostream>
#ifdef CGAL_CONCURRENT_MESH_3
#else
#endif
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>>;
using Constraints_pmap = CGAL::Boolean_property_map<Constraints_set>;
template <typename Tr>
struct Cells_of_subdomain_pmap
{
using Subdomain_index
= typename Tr::Triangulation_data_structure::Cell::Subdomain_index;
const Subdomain_index m_subdomain;
public:
using key_type = typename Tr::Cell_handle;
using value_type = bool;
using reference = bool;
using category = boost::read_write_property_map_tag;
friend value_type get(const Cells_of_subdomain_pmap& map, const key_type& c) {
return (map.m_subdomain == c->subdomain_index());
}
friend void put(Cells_of_subdomain_pmap&, const key_type&, const value_type) {
;
}
};
int main(int argc, char* argv[])
{
std::cerr << "Error: Cannot read file " << fname << std::endl;
return EXIT_FAILURE;
}
Mesh_domain domain
= Mesh_domain::create_labeled_image_mesh_domain(image,
double sizing_default = diag * 0.05;
Mesh_criteria criteria(params::edge_size = sizing_default,
params::facet_size = sizing_default,
params::facet_distance = sizing_default / 10
);
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria,
std::ofstream out0("out_meshed.mesh");
out0.close();
Constraints_set constraints;
Constraints_pmap constraints_pmap(constraints);
params::edge_is_constrained_map(constraints_pmap));
const double remeshing_target_size = sizing_default * 0.5;
std::cout << "Remeshing with target edge length: " << remeshing_target_size << std::endl;
params::cell_is_selected_map(Cells_of_subdomain_pmap<Triangulation_3>{4})
.number_of_iterations(5)
.edge_is_constrained_map(constraints_pmap)
.remesh_boundaries(false));
std::ofstream out("out_remeshed.mesh");
out.close();
return EXIT_SUCCESS;
}
bool read(const char *file)
unspecified_type no_perturb()
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())
remeshes a tetrahedral mesh.
Definition: tetrahedral_remeshing.h:187
CGAL::Triangulation_3< typename Tr::Geom_traits, typename Tr::Triangulation_data_structure > convert_to_triangulation_3(CGAL::Mesh_complex_3_in_triangulation_3< Tr, CornerIndex, CurveIndex > c3t3, const NamedParameters &np=parameters::default_values())
converts the triangulation contained in the input to a Triangulation_3.
Definition: tetrahedral_remeshing.h:357
std::string data_file_path(const std::string &filename)