diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt index 39c1bde74dd..0ad19b9b024 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/CMakeLists.txt @@ -89,8 +89,15 @@ create_single_source_cgal_program( "remove_degeneracies_example.cpp") if(OpenMesh_FOUND) create_single_source_cgal_program( "compute_normals_example_OM.cpp" ) target_link_libraries( compute_normals_example_OM ${OPENMESH_LIBRARIES} ) + create_single_source_cgal_program( "hole_filling_example_OM.cpp" ) target_link_libraries( hole_filling_example_OM ${OPENMESH_LIBRARIES} ) + +create_single_source_cgal_program( "point_inside_example_OM.cpp") +target_link_libraries( point_inside_example_OM ${OPENMESH_LIBRARIES} ) + +create_single_source_cgal_program( "stitch_borders_example_OM.cpp" ) +target_link_libraries( stitch_borders_example_OM ${OPENMESH_LIBRARIES} ) endif() else(EIGEN3_FOUND) diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/point_inside_example_OM.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/point_inside_example_OM.cpp new file mode 100644 index 00000000000..a5840d67f44 --- /dev/null +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/point_inside_example_OM.cpp @@ -0,0 +1,77 @@ +#include + +#include +#include + +#include + +#include + +#include + +#include +#include +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; + +typedef OpenMesh::PolyMesh_ArrayKernelT< > Mesh; +typedef K::Point_3 Point; + +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; + +double max_coordinate(const Mesh& mesh) +{ + typedef boost::property_map::type VPmap; + VPmap vpmap = get(CGAL::vertex_point,mesh); + + double max_coord = std::numeric_limits::min(); + BOOST_FOREACH(vertex_descriptor v, vertices(mesh)) + { + Point p = get(vpmap, v); + max_coord = (std::max)(max_coord, p.x()); + max_coord = (std::max)(max_coord, p.y()); + max_coord = (std::max)(max_coord, p.z()); + } + return max_coord; +} + +int main(int argc, char* argv[]) +{ + const char* filename = (argc > 1) ? argv[1] : "data/eight.off"; + + Mesh mesh; + OpenMesh::IO::read_mesh(mesh, filename); + + CGAL::Point_inside_polygon_mesh inside(mesh); + + double size = max_coordinate(mesh); + + unsigned int nb_points = 100; + std::vector points; + points.reserve(nb_points); + CGAL::Random_points_in_cube_3 gen(size); + for (unsigned int i = 0; i < nb_points; ++i) + points.push_back(*gen++); + + std::cout << "Test " << nb_points << " random points in cube " + << "[-" << size << "; " << size <<"]" << std::endl; + + int nb_inside = 0; + int nb_boundary = 0; + for (std::size_t i = 0; i < nb_points; ++i) + { + CGAL::Bounded_side res = inside(points[i]); + + if (res == CGAL::ON_BOUNDED_SIDE) { ++nb_inside; } + if (res == CGAL::ON_BOUNDARY) { ++nb_boundary; } + } + + std::cerr << "Total query size: " << points.size() << std::endl; + std::cerr << " " << nb_inside << " points inside " << std::endl; + std::cerr << " " << nb_boundary << " points on boundary " << std::endl; + std::cerr << " " << points.size() - nb_inside - nb_boundary << " points outside " << std::endl; + + return 0; +} diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/stitch_borders_example_OM.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/stitch_borders_example_OM.cpp new file mode 100644 index 00000000000..3b2fdedb37f --- /dev/null +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/stitch_borders_example_OM.cpp @@ -0,0 +1,39 @@ + +#include + +#include +#include +#include +#include + +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K; + + +typedef OpenMesh::PolyMesh_ArrayKernelT< > Mesh; +int main(int argc, char* argv[]) +{ + const char* filename = (argc > 1) ? argv[1] : "data/full_border_quads.off"; + std::ifstream input(filename); + + Mesh mesh; + OpenMesh::IO::read_mesh(mesh, filename); + + std::cout << "Before stitching : " << std::endl; + std::cout << "\t Number of vertices :\t" << num_vertices(mesh) << std::endl; + std::cout << "\t Number of halfedges :\t" << num_halfedges(mesh) << std::endl; + std::cout << "\t Number of facets :\t" << num_faces(mesh) << std::endl; + + CGAL::Polygon_mesh_processing::stitch_borders(mesh, + CGAL::Polygon_mesh_processing::parameters::vertex_point_map(get(CGAL::vertex_point, mesh))); + + mesh.garbage_collection(); + std::cout << "Stitching done : " << std::endl; + std::cout << "\t Number of vertices :\t" << num_vertices(mesh) << std::endl; + std::cout << "\t Number of halfedges :\t" << num_halfedges(mesh) << std::endl; + std::cout << "\t Number of facets :\t" << num_faces(mesh) << std::endl; + + return 0; +} diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h index 153d5cc1164..c587c6b9495 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/stitch_borders.h @@ -105,7 +105,7 @@ struct Naive_border_stitching_modifier typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename std::pair halfedges_pair; - typedef typename PM::Point Point; + typedef typename boost::property_traits::value_type Point; typedef HalfedgePairsRange To_stitch; @@ -151,7 +151,7 @@ struct Naive_border_stitching_modifier vertex_descriptor v_to_keep = h1_tgt; std::pair::iterator, bool > insert_res = - vertices_kept.insert( std::make_pair(vpmap[v_to_keep], v_to_keep) ); + vertices_kept.insert( std::make_pair(get(vpmap, v_to_keep), v_to_keep) ); if (!insert_res.second && v_to_keep != insert_res.first->second) {