Merge remote-tracking branch 'maxGimeno/PMP-compare_faces_from_meshes-maxGimeno' into gsoc2019-PMPHDist-martinskrodzki

This commit is contained in:
Dmitry Anisimov
2021-04-07 13:54:02 +02:00
357 changed files with 7048 additions and 10260 deletions
@@ -91,6 +91,7 @@ create_single_source_cgal_program("locate_example.cpp")
create_single_source_cgal_program("orientation_pipeline_example.cpp")
#create_single_source_cgal_program( "self_snapping_example.cpp")
#create_single_source_cgal_program( "snapping_example.cpp")
create_single_source_cgal_program("compare_meshes_example.cpp")
if(OpenMesh_FOUND)
@@ -98,6 +99,10 @@ if(OpenMesh_FOUND)
target_link_libraries(compute_normals_example_OM
PRIVATE ${OPENMESH_LIBRARIES})
create_single_source_cgal_program("corefinement_OM_union.cpp")
target_link_libraries(corefinement_OM_union
PRIVATE ${OPENMESH_LIBRARIES})
if(TARGET CGAL::Eigen3_support)
create_single_source_cgal_program("hole_filling_example_OM.cpp")
target_link_libraries(hole_filling_example_OM PRIVATE CGAL::Eigen3_support
@@ -0,0 +1,54 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/boost/graph/copy_face_graph.h>
#include <CGAL/boost/graph/Euler_operations.h>
#include <CGAL/Polygon_mesh_processing/measure.h>
#include <CGAL/boost/graph/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <fstream>
#include <iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef K::Point_3 Point;
typedef CGAL::Surface_mesh<Point> Surface_mesh;
typedef boost::graph_traits<Surface_mesh>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Surface_mesh>::face_descriptor face_descriptor;
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const char* filename1 = (argc > 1) ? argv[1] : "data/P.off";
Surface_mesh mesh1, mesh2;
if(!PMP::read_polygon_mesh(filename1, mesh1))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
mesh2 = mesh1;
CGAL::Euler::add_center_vertex(*halfedges(mesh2).begin(),mesh2);
std::vector<std::pair<face_descriptor, face_descriptor> > common;
std::vector<face_descriptor> m1_only, m2_only;
PMP::match_faces(mesh1, mesh2, std::back_inserter(common), std::back_inserter(m1_only), std::back_inserter(m2_only));
std::cout<<"Faces only in m1 : "<<std::endl;
for(const auto& f : m1_only)
{
std::cout<<f<<", ";
}
std::cout<<"\n Faces only in m2: "<<std::endl;
for(const auto& f : m2_only)
{
std::cout<<f<<", ";
}
std::cout<<"\n Faces in both: "<<std::endl;
for(const auto& f_pair : common)
{
std::cout<<f_pair.first<<", "<<f_pair.second<<";;"<<std::endl;
}
return 0;
}
@@ -0,0 +1,102 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh>
#include <CGAL/boost/graph/graph_traits_PolyMesh_ArrayKernelT.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <fstream>
#include <iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K; // default kernel for OpenMesh point type
typedef CGAL::Exact_predicates_exact_constructions_kernel EK; // alternatice kernel we want to use
typedef OpenMesh::PolyMesh_ArrayKernelT< > Mesh;
typedef boost::property_map<Mesh, CGAL::dynamic_vertex_property_t<EK::Point_3> >::type Exact_point_map;
struct Exact_vertex_point_map
{
// typedef for the property map
typedef boost::property_traits<Exact_point_map>::value_type value_type;
typedef boost::property_traits<Exact_point_map>::reference reference;
typedef boost::property_traits<Exact_point_map>::category category;
typedef boost::property_traits<Exact_point_map>::key_type key_type;
// exterior references
Exact_point_map exact_point_map;
Mesh* tm_ptr;
// Converters
CGAL::Cartesian_converter<K, EK> to_exact;
CGAL::Cartesian_converter<EK, K> to_input;
Exact_vertex_point_map()
: tm_ptr(nullptr)
{}
Exact_vertex_point_map(const Exact_point_map& ep, Mesh& tm)
: exact_point_map(ep)
, tm_ptr(&tm)
{
for (key_type v : vertices(tm))
put(exact_point_map, v, to_exact(get(boost::vertex_point, tm, v)));
}
friend
reference get(const Exact_vertex_point_map& map, key_type k)
{
CGAL_precondition(map.tm_ptr!=nullptr);
return get(map.exact_point_map, k);
}
friend
void put(const Exact_vertex_point_map& map, key_type k, const EK::Point_3& p)
{
CGAL_precondition(map.tm_ptr!=nullptr);
put(map.exact_point_map, k, p);
// create the input point from the exact one
put(boost::vertex_point, *map.tm_ptr, k, map.to_input(p));
}
};
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off";
const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off";
Mesh mesh1, mesh2;
OpenMesh::IO::read_mesh(mesh1, filename1);
OpenMesh::IO::read_mesh(mesh2, filename2);
Mesh out;
// Create exact map properties
Exact_point_map pm_1 = get(CGAL::dynamic_vertex_property_t<EK::Point_3>(), mesh1);
Exact_point_map pm_2 = get(CGAL::dynamic_vertex_property_t<EK::Point_3>(), mesh2);
Exact_point_map pm_out = get(CGAL::dynamic_vertex_property_t<EK::Point_3>(), out);
// Create exact vertex point map that will provide the point to another kernel and fill the default map
Exact_vertex_point_map vpm_1(pm_1, mesh1);
Exact_vertex_point_map vpm_2(pm_2, mesh2);
Exact_vertex_point_map vpm_out(pm_out, out);
bool valid_union = PMP::corefine_and_compute_union(mesh1, mesh2, out,
CGAL::parameters::vertex_point_map(vpm_1),
CGAL::parameters::vertex_point_map(vpm_2),
CGAL::parameters::vertex_point_map(vpm_out));
if (valid_union)
{
std::cout << "Union was successfully computed\n";
OpenMesh::IO::write_mesh(out, "union.off");
return 0;
}
std::cout << "Union could not be computed\n";
return 1;
}
@@ -8,14 +8,11 @@
#include <fstream>
#include <iostream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Exact_predicates_exact_constructions_kernel EK;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
typedef Mesh::Property_map<vertex_descriptor,EK::Point_3> Exact_point_map;
typedef Mesh::Property_map<vertex_descriptor,bool> Exact_point_computed;
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Exact_predicates_exact_constructions_kernel EK;
typedef CGAL::Surface_mesh<K::Point_3> Mesh;
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
typedef Mesh::Property_map<vertex_descriptor,EK::Point_3> Exact_point_map;
namespace PMP = CGAL::Polygon_mesh_processing;
namespace params = PMP::parameters;