mirror of https://github.com/CGAL/cgal
Merge branch 'Polygon_mesh_processing_OpenMesh-GF' of github.com:CGAL/cgal-public-dev into Polygon_mesh_processing_OpenMesh-GF
This commit is contained in:
commit
c4e9b7412c
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
#include <CGAL/Exact_predicates_inexact_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/point_generators_3.h>
|
||||
|
||||
#include <CGAL/Point_inside_polygon_mesh.h>
|
||||
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <limits>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
|
||||
typedef OpenMesh::PolyMesh_ArrayKernelT< > Mesh;
|
||||
typedef K::Point_3 Point;
|
||||
|
||||
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
|
||||
|
||||
double max_coordinate(const Mesh& mesh)
|
||||
{
|
||||
typedef boost::property_map<Mesh,CGAL::vertex_point_t>::type VPmap;
|
||||
VPmap vpmap = get(CGAL::vertex_point,mesh);
|
||||
|
||||
double max_coord = std::numeric_limits<double>::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<Mesh, K> inside(mesh);
|
||||
|
||||
double size = max_coordinate(mesh);
|
||||
|
||||
unsigned int nb_points = 100;
|
||||
std::vector<Point> points;
|
||||
points.reserve(nb_points);
|
||||
CGAL::Random_points_in_cube_3<Point> 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;
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
|
||||
#include <CGAL/Exact_predicates_inexact_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/stitch_borders.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ struct Naive_border_stitching_modifier
|
|||
typedef typename boost::graph_traits<PM>::vertex_descriptor vertex_descriptor;
|
||||
typedef typename boost::graph_traits<PM>::halfedge_descriptor halfedge_descriptor;
|
||||
typedef typename std::pair<halfedge_descriptor, halfedge_descriptor> halfedges_pair;
|
||||
typedef typename PM::Point Point;
|
||||
typedef typename boost::property_traits<VertexPointMap>::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<typename std::map<Point, vertex_descriptor>::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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue