diff --git a/BGL/include/CGAL/boost/graph/iterator.h b/BGL/include/CGAL/boost/graph/iterator.h index df6ba9991c8..7c8d955ce09 100644 --- a/BGL/include/CGAL/boost/graph/iterator.h +++ b/BGL/include/CGAL/boost/graph/iterator.h @@ -444,7 +444,7 @@ public: Self& operator++() { CGAL_assertion(g != NULL); - pos = next(pos,*g); + pos = next(pos,*g); // AF: added CGAL:: it compiles if ( pos == anchor) ++winding; return *this; diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/CMakeLists.txt b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/CMakeLists.txt index 56a3bfc9f5d..e4b13f249e7 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/CMakeLists.txt +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/CMakeLists.txt @@ -24,6 +24,7 @@ if ( CGAL_FOUND ) create_single_source_cgal_program( "lscm.cpp" ) create_single_source_cgal_program( "seam.cpp" ) + create_single_source_cgal_program( "seam_Polyhedron_3.cpp" ) create_single_source_cgal_program( "discrete_authalic.cpp" ) create_single_source_cgal_program( "Simple_parameterization.cpp" ) diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/seam_Polyhedron_3.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/seam_Polyhedron_3.cpp new file mode 100644 index 00000000000..619b014614e --- /dev/null +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/seam_Polyhedron_3.cpp @@ -0,0 +1,118 @@ +#include +#include +#include +#include +#include + +#include +#include +#include + + +typedef CGAL::Simple_cartesian Kernel; +typedef Kernel::Point_2 Point_2; +typedef Kernel::Point_3 Point_3; +typedef CGAL::Polyhedron_3 SurfaceMesh; + +typedef boost::graph_traits::edge_descriptor SM_edge_descriptor; +typedef boost::graph_traits::halfedge_descriptor SM_halfedge_descriptor; +typedef boost::graph_traits::vertex_descriptor SM_vertex_descriptor; + +typedef CGAL::Unique_hash_map UV_uhm; +typedef CGAL::Unique_hash_map Seam_edge_uhm; +typedef CGAL::Unique_hash_map Seam_vertex_uhm; + +typedef boost::associative_property_map UV_pmap; +typedef boost::associative_property_map Seam_edge_pmap; +typedef boost::associative_property_map Seam_vertex_pmap; + +typedef CGAL::Seam_mesh Mesh; + +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef boost::graph_traits::halfedge_descriptor halfedge_descriptor; +typedef boost::graph_traits::face_descriptor face_descriptor; + +/// A helper class that writes a face as a polyline in the xy-plane +struct Face2Polyline { + const Mesh& mesh; + const UV_pmap uvpm; + + Face2Polyline(const Mesh& mesh, const UV_pmap& uvpm) + : mesh(mesh), uvpm(uvpm) + {} + + void operator()(face_descriptor fd) const + { + halfedge_descriptor hd = halfedge(fd,mesh); + + std::cout << "4 " << uvpm[target(hd,mesh)].x() << " " << uvpm[target(hd,mesh)].y() << " 0 "; + /* + hd = next(hd,mesh); + BOOST_FOREACH(vertex_descriptor vd, vertices_around_face(hd,mesh)){ + std::cout << uvpm[vd].x() << " " << uvpm[vd].y() << " 0 "; + } + */ + std::cout << std::endl; + } +}; + +int main(int argc, char * argv[]) +{ + SurfaceMesh sm; + std::vector seam; + + std::ifstream in_mesh((argc>1)?argv[1]:"data/lion.off"); + in_mesh >> sm; + + std::vector id2v; + BOOST_FOREACH(SM_vertex_descriptor vd, vertices(sm)){ + id2v.push_back(vd); + } + + // Two property maps to store the seam edges and vertices + Seam_edge_uhm seam_edge_uhm(false); + Seam_edge_pmap seam_edge_pm(seam_edge_uhm); + + Seam_vertex_uhm seam_vertex_uhm(false); + Seam_vertex_pmap seam_vertex_pm(seam_vertex_uhm); + + std::ifstream in((argc>2)?argv[2]:"data/lion.selection.txt"); + int s,t; + SM_halfedge_descriptor smhd; + while(in >> s >> t){ + SM_vertex_descriptor svd = id2v[s], tvd = id2v[t]; + SM_edge_descriptor ed = edge(svd, tvd,sm).first; + if(! is_border(ed,sm)){ + put(seam_edge_pm, ed, true); + put(seam_vertex_pm, svd, true); + put(seam_vertex_pm, tvd, true); + if(smhd == boost::graph_traits::null_halfedge()){ + smhd = halfedge(edge(svd,tvd,sm).first,sm); + } + } + } + + Mesh mesh(sm, seam_edge_pm, seam_vertex_pm); + + // The 2D points of the uv parametrisation will be written into this map + // Note that this is a halfedge property map, and that the uv + // is only stored for the canonical halfedges representing a vertex + + UV_uhm uv_uhm; + UV_pmap uv_pm(uv_uhm); + + halfedge_descriptor bhd(smhd); + bhd = opposite(bhd,mesh); // a halfedge on the virtual border + + // CGAL::parameterize(mesh, bhd, uv_pm); + get(CGAL::vertex_point, mesh); + Face2Polyline f2p(mesh,uv_pm); + // As the seam may define a patch we write + /* + CGAL::Polygon_mesh_processing::connected_component(face(opposite(bhd,mesh),mesh), + mesh, + boost::make_function_output_iterator(f2p)); + */ + return 0; +} + diff --git a/Surface_mesh_parameterization/include/CGAL/Fixed_border_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/Fixed_border_parameterizer_3.h index 7aaf234241a..03b8ed57217 100644 --- a/Surface_mesh_parameterization/include/CGAL/Fixed_border_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Fixed_border_parameterizer_3.h @@ -381,7 +381,7 @@ parameterize(TriangleMesh& mesh, if( main_border.find(v) == main_border.end() ) { int index = get(vimap,v); - put(uvmap,v,Point_2(Xu[index],Xv[index])); + //AF put(uvmap,v,Point_2(Xu[index],Xv[index])); put(vpm,v,true); } }