Merge branch 'master' into PMP-Make_remove_self_intersections_local-GF

This commit is contained in:
Mael
2020-03-30 09:44:36 +02:00
committed by GitHub
101 changed files with 5927 additions and 974 deletions
@@ -83,6 +83,7 @@ create_single_source_cgal_program( "corefinement_polyhedron_union.cpp" )
create_single_source_cgal_program( "random_perturbation_SM_example.cpp" )
create_single_source_cgal_program( "corefinement_LCC.cpp")
create_single_source_cgal_program( "detect_features_example.cpp" )
create_single_source_cgal_program( "volume_connected_components.cpp" )
create_single_source_cgal_program( "manifoldness_repair_example.cpp" )
create_single_source_cgal_program( "repair_polygon_soup_example.cpp" )
create_single_source_cgal_program( "mesh_smoothing_example.cpp")
@@ -91,6 +92,7 @@ create_single_source_cgal_program( "locate_example.cpp")
#create_single_source_cgal_program( "snapping_example.cpp")
#create_single_source_cgal_program( "mesh_self_intersection_removal_example.cpp")
if(OpenMesh_FOUND)
create_single_source_cgal_program( "compute_normals_example_OM.cpp" )
@@ -0,0 +1,53 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/orientation.h>
#include <CGAL/boost/graph/Face_filtered_graph.h>
#include <iostream>
#include <fstream>
#include <sstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Surface_mesh<Kernel::Point_3> Surface_mesh;
namespace PMP = CGAL::Polygon_mesh_processing;
namespace params = CGAL::parameters;
int main(int argc, char** argv)
{
const char* filename = (argc > 1) ? argv[1] : "data/blobby.off";
std::ifstream input(filename);
assert(input);
Surface_mesh sm;
input >> sm;
// property map to assign a volume id for each face
Surface_mesh::Property_map<Surface_mesh::Face_index, std::size_t> vol_id_map =
sm.add_property_map<Surface_mesh::Face_index, std::size_t>().first;
std::vector<PMP::Volume_error_code> err_codes;
// fill the volume id map
std::size_t nb_vol =
PMP::volume_connected_components(sm,
vol_id_map,
params::error_codes(std::ref(err_codes)));
std::cout << "Found " << nb_vol << " volumes\n";
// write each volume in an OFF file
typedef CGAL::Face_filtered_graph<Surface_mesh> Filtered_graph;
Filtered_graph vol_mesh(sm, 0, vol_id_map);
for(std::size_t id = 0; id < nb_vol; ++id)
{
if (err_codes[id] != PMP::VALID_VOLUME)
std::cerr << "There is an issue with volume #" << id << "\n";
if(id > 0)
vol_mesh.set_selected_faces(id, vol_id_map);
Surface_mesh out;
CGAL::copy_face_graph(vol_mesh, out);
std::ostringstream oss;
oss << "vol_" << id <<".off";
std::ofstream os(oss.str().data());
os << out;
}
}