Updated the examples of the SMP to work with the new Seam mesh

Also a small change in the Polyhedron demo
This commit is contained in:
Mael Rouxel-Labbé 2016-11-07 12:19:32 +01:00
parent b00c5f9a56
commit c71d8285d0
10 changed files with 315 additions and 210 deletions

View File

@ -0,0 +1,24 @@
OFF
11 7 0
# vertices
-1 -1 1
-1 1 1
1 1 1
1 -1 1
-1 -1 -1
-1 1 -1
1 1 -1
1 -1 -1
2 2 2
3 2 2
3 3 3
# facets
3 3 2 1
3 3 1 0
4 0 1 5 4
4 6 5 1 2
4 3 7 6 2
4 4 7 3 0
4 4 5 6 7
3 8 9 10

View File

@ -0,0 +1,3 @@
1 5 1 0 1 3 2 1

View File

@ -0,0 +1,3 @@
2 1 1 0

View File

@ -0,0 +1,3 @@
1 5 5 4 4 7 3 7 1 3

View File

@ -12,121 +12,138 @@
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point;
typedef CGAL::Surface_mesh<Point> Mesh;
typedef CGAL::Seam_mesh<Mesh> Seam_mesh;
typedef boost::graph_traits<Mesh>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Mesh>::halfedge_descriptor halfedge_descriptor;
typedef boost::graph_traits<Mesh>::edge_descriptor edge_descriptor;
typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
typedef boost::graph_traits<Mesh>::vertex_descriptor SM_vertex_descriptor;
typedef boost::graph_traits<Mesh>::halfedge_descriptor SM_halfedge_descriptor;
typedef boost::graph_traits<Mesh>::edge_descriptor SM_edge_descriptor;
typedef boost::graph_traits<Mesh>::face_descriptor SM_face_descriptor;
typedef Mesh::Property_map<SM_edge_descriptor, bool> Seam_edge_pmap;
typedef Mesh::Property_map<SM_vertex_descriptor, bool> Seam_vertex_pmap;
typedef CGAL::Seam_mesh<Mesh, Seam_edge_pmap, Seam_vertex_pmap> Seam_mesh;
typedef boost::graph_traits<Seam_mesh>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<Seam_mesh>::halfedge_descriptor halfedge_descriptor;
typedef boost::graph_traits<Seam_mesh>::edge_descriptor edge_descriptor;
typedef boost::graph_traits<Seam_mesh>::face_descriptor face_descriptor;
int main(int argc, char* argv[])
int main(int argc, char* argv[])
{
Mesh sm;
std::ifstream in((argc>1)?argv[1]:"data/cube.off");
std::ifstream in((argc>1) ? argv[1] : "data/cube.off");
in >> sm;
std::vector<edge_descriptor> seam;
Seam_edge_pmap seam_edge_pm =
sm.add_property_map<SM_edge_descriptor, bool>("e:on_seam", false).first;
Seam_vertex_pmap seam_vertex_pm =
sm.add_property_map<SM_vertex_descriptor, bool>("v:on_seam",false).first;
// split cube in two connected components
BOOST_FOREACH(halfedge_descriptor hd, halfedges_around_face(*halfedges(sm).first,sm)){
seam.push_back(edge(hd,sm));
Seam_mesh mesh(sm, seam_edge_pm, seam_vertex_pm);
// Add the seams
#if 1
// Split the cube in two connected components
SM_halfedge_descriptor smhd = mesh.add_seams("data/two_connected_components.selection.txt");
#else
// Seams are all edges incident to a vertex
SM_halfedge_descriptor smhd = mesh.add_seams("data/flatten.selection.txt");
#endif
assert(smhd != SM_halfedge_descriptor());
std::cout << "Added: " << mesh.number_of_seam_edges() << " seam edges" << std::endl;
halfedge_descriptor bhd(smhd);
std::cout << "First seam halfedge: " << smhd << std::endl;
std::cout << "source = " << source(smhd, mesh)
<< " (pointing to vertex: " << source(smhd, sm) << ")" << std::endl;
std::cout << "target = " << target(smhd, mesh)
<< " (pointing to vertex: " << target(smhd, sm) << ")" << std::endl;
std::cout << "prev of seam halfedge in (base) mesh: " << prev(smhd, sm) << std::endl;
std::cout << "prev of seam halfedge in seam mesh: " << prev(bhd, mesh) << std::endl;
std::cout << "next of seam halfedge in (base) mesh: " << next(smhd, sm) << std::endl;
std::cout << "next of seam halfedge in seam mesh: " << next(bhd, mesh) << std::endl;
std::cout << "opposite of seam halfedge in (base) mesh: " << opposite(smhd, sm) << std::endl;
std::cout << "opposite of seam halfedge in seam mesh: " << opposite(bhd, mesh) << std::endl;
std::cout << "vertices on one of the seams" << std::endl;
BOOST_FOREACH(halfedge_descriptor hd,
halfedges_around_face(opposite(bhd, mesh), mesh)){
std::cout << target(hd.tmhd, sm) << " ";
}
std::cout << std::endl;
#if 0
//cube
halfedge_descriptor hd = * halfedges(sm).first;
std::cout << "center = " << target(hd,sm) << std::endl;
int count=0;
BOOST_FOREACH(hd, halfedges_around_target(hd,sm)){
std::cout << "v = " << source(hd,sm) << std::endl;
if(count==0 || count==2){
seam.push_back(edge(hd,sm));
std::cout << "vertices around " << target(smhd , sm) << " in (base) mesh" << std::endl;
BOOST_FOREACH(SM_halfedge_descriptor hd, halfedges_around_target(smhd, sm)){
std::cout << source(hd, sm) << " ";
}
std::cout << std::endl;
std::cout << "vertices around " << target(bhd , mesh) << " in seam mesh" << std::endl;
BOOST_FOREACH(halfedge_descriptor hd, halfedges_around_target(bhd, mesh)){
std::cout << source(hd.tmhd, sm) << " ";
}
std::cout << std::endl;
std::cout << "vertices around " << source(smhd , sm) << " in (base) mesh" << std::endl;
BOOST_FOREACH(SM_halfedge_descriptor hd,
halfedges_around_source(source(smhd, sm), sm)){
std::cout << target(hd, sm) << " ";
}
std::cout << std::endl;
std::cout << "vertices around " << source(bhd , mesh) << " in seam mesh" << std::endl;
BOOST_FOREACH(halfedge_descriptor hd,
halfedges_around_source(source(bhd, mesh), mesh)){
std::cout << target(hd.tmhd, sm) << " ";
}
std::cout << std::endl;
std::cout << "vertices around vertices in seam mesh" << std::endl;
BOOST_FOREACH(vertex_descriptor vd, vertices(mesh)){
halfedge_descriptor hd = halfedge(vd, mesh);
std::cout << " " << vd << " has incident vertices:" << std::endl;
BOOST_FOREACH(halfedge_descriptor hd2, halfedges_around_target(hd, mesh)){
std::cout << " " << hd2;
}
if(seam.size() == 2)
break;
count++;
std::cout << std::endl;
}
#endif
#if 0
//cube-ouvert
BOOST_FOREACH(halfedge_descriptor hd, halfedges(sm)){
if(is_border(hd,sm)){
seam.push_back(edge(next(opposite(hd,sm),sm),sm));
break;
}
std::cout << "done" << std::endl;
std::cout << "the (base) mesh has: " << num_halfedges(sm) << " halfedges" << std::endl;
std::cout << "the seam mesh has: " << num_halfedges(mesh) << " halfedges" << std::endl;
std::cout << "halfedges in (base) mesh" << std::endl;
BOOST_FOREACH(SM_halfedge_descriptor hd, halfedges(sm)){
std::cout << hd << " ";
}
#endif
std::cout << std::endl;
typedef std::map<Seam_mesh::halfedge_descriptor,int> H_vertex_index_map;
typedef boost::associative_property_map<H_vertex_index_map> H_vertex_index_pmap;
H_vertex_index_map hvim; H_vertex_index_pmap hvipm(hvim);
std::cout << "halfedges in seam mesh" << std::endl;
BOOST_FOREACH(halfedge_descriptor hd, halfedges(mesh)){
std::cout << hd << " ";
}
std::cout << std::endl;
halfedge_descriptor mhd = halfedge(seam.front(),sm);
Seam_mesh ssm(sm, seam);
std::cout << "faces of the base and seam meshes" << std::endl;
BOOST_FOREACH(face_descriptor fd, faces(mesh)){
std::cout << fd << " ";
}
std::cout << std::endl;
std::vector<face_descriptor> faces;
boost::graph_traits<Seam_mesh>::halfedge_descriptor shd(halfedge(seam.front(),sm));
CGAL::Polygon_mesh_processing::connected_component(face(shd,ssm),
ssm,
CGAL::Polygon_mesh_processing::connected_component(face(bhd, mesh),
mesh,
std::back_inserter(faces));
std::cerr << faces.size() << std::endl;
faces.clear();
shd = opposite(halfedge(seam.front(),sm),sm);
CGAL::Polygon_mesh_processing::connected_component(face(shd,ssm),
ssm,
std::back_inserter(faces));
std::cerr << faces.size() << std::endl;
return 0;
BOOST_FOREACH(Seam_mesh::vertex_descriptor vd, vertices(ssm)){
halfedge_descriptor hd = vd;
std::cerr << vd << " has incident halfedges:" << std::endl;
BOOST_FOREACH(Seam_mesh::halfedge_descriptor hd2, halfedges_around_target(vd,ssm)){
std::cerr << hd2 << std::endl;
}
}
std::cerr << "done"<< std::endl;
Seam_mesh::halfedge_descriptor smhd(mhd), smhd2(opposite(mhd,sm));
std::cout << "target = " << target(smhd,ssm) << std::endl;
std::cout << "vertices on seam" << std::endl;
BOOST_FOREACH(Seam_mesh::halfedge_descriptor hd, halfedges_around_face(opposite(smhd,ssm),ssm)){
std::cout << target(hd.tmhd,sm) << std::endl;
}
std::cout << "vertices around target in mesh" << std::endl;
BOOST_FOREACH(halfedge_descriptor hd, halfedges_around_target(mhd,sm)){
std::cout << source(hd,sm) << std::endl;
}
std::cout << "vertices around target in seam mesh" << std::endl;
BOOST_FOREACH(Seam_mesh::halfedge_descriptor hd, halfedges_around_target(smhd,ssm)){
std::cout << source(hd.tmhd,sm) << std::endl;
}
std::cout << "vertices around source in seam mesh" << std::endl;
BOOST_FOREACH(Seam_mesh::halfedge_descriptor hd, halfedges_around_source(opposite(smhd,ssm),ssm)){
std::cout << target(hd.tmhd,sm) << std::endl;
}
std::cout << "vertices around source in seam mesh" << std::endl;
BOOST_FOREACH(Seam_mesh::halfedge_descriptor hd, halfedges_around_source(smhd2,ssm)){
std::cout << target(hd.tmhd,sm) << std::endl;
}
std::cout << "vertices around target in seam mesh" << std::endl;
BOOST_FOREACH(Seam_mesh::halfedge_descriptor hd, halfedges_around_target(opposite(smhd2,ssm),ssm)){
std::cout << source(hd.tmhd,sm) << std::endl;
}
boost::property_map<Seam_mesh, CGAL::vertex_point_t>::type vpm = get(CGAL::vertex_point,ssm);
//std::cout << get(vpm, source(hd,ssm)) << std::endl;
std::cout << "the connected component (in the seam mesh) given by halfedge: " << smhd;
std::cout << " has " << faces.size() << " faces." << std::endl;
std::cout << "accessing coordinates of the source of halfedge " << smhd << ": ";
boost::property_map<Seam_mesh, CGAL::vertex_point_t>::type vpm =
get(CGAL::vertex_point, mesh);
std::cout << get(vpm, source(smhd, mesh)) << std::endl;
return 0;
}

View File

@ -827,6 +827,11 @@ public:
return tmhd;
}
void set_seam_number(const edges_size_type sn) const
{
number_of_seams = sn;
}
/// Constructs a seam mesh for a triangle mesh and an edge and vertex property map
/// \param tm the adapted mesh
/// \param sem the edge property map with value `true` for seam edges

View File

@ -499,11 +499,13 @@ void Polyhedron_demo_parameterization_plugin::parameterize(const Parameterizatio
}
}
}
Seam_mesh *sMesh = new Seam_mesh(tMesh, seam_edge_pm, seam_vertex_pm);
sMesh->set_seam_number(seam_edges.size());
UV_uhm uv_uhm;
UV_pmap uv_pm(uv_uhm);
QString new_item_name;
//determine the different connected_components
boost::property_map<Textured_polyhedron::Base, boost::face_external_index_t>::type fim

View File

@ -58,7 +58,6 @@ struct Face2Polyline
int main(int argc, char * argv[])
{
SurfaceMesh sm;
std::vector<SM_edge_descriptor> seam;
std::ifstream in_mesh((argc>1)?argv[1]:"data/lion.off");
in_mesh >> sm;
@ -67,7 +66,9 @@ int main(int argc, char * argv[])
Seam_edge_pmap seam_edge_pm = sm.add_property_map<SM_edge_descriptor,bool>("e:on_seam", false).first;
Seam_vertex_pmap seam_vertex_pm = sm.add_property_map<SM_vertex_descriptor,bool>("v:on_seam",false).first;
std::ifstream in((argc>2)?argv[2]:"data/lion.selection.txt");
const char* filename = (argc>2) ? argv[2] : "data/lion.selection.txt";
std::ifstream in(filename);
std::string vertices;
std::getline(in,vertices);
std::istringstream iss(vertices);
@ -77,22 +78,9 @@ int main(int argc, char * argv[])
two_vertices_given = true;
}
int s,t;
SM_halfedge_descriptor smhd;
while(in >> s >> t){
SM_vertex_descriptor svd(s), tvd(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<SurfaceMesh>::null_halfedge()){
smhd = halfedge(edge(svd, tvd, sm).first, sm);
}
}
}
Mesh mesh(sm, seam_edge_pm, seam_vertex_pm);
SM_halfedge_descriptor smhd = mesh.add_seams(filename);
assert(smhd != SM_halfedge_descriptor());
// 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

View File

@ -3,13 +3,13 @@
#include <CGAL/Surface_mesh.h>
#include <CGAL/boost/graph/graph_traits_Surface_mesh.h>
#include <CGAL/boost/graph/Seam_mesh.h>
#include <CGAL/boost/graph/graph_traits_Seam_mesh.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Polygon_mesh_processing/measure.h>
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
#include <CGAL/boost/graph/Seam_mesh.h>
#include <CGAL/boost/graph/graph_traits_Seam_mesh.h>
#include <CGAL/ARAP_parameterizer_3.h>
#include <CGAL/Barycentric_mapping_parameterizer_3.h>
#include <CGAL/Discrete_authalic_parameterizer_3.h>
@ -30,56 +30,79 @@ typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Point_3 Point_3;
#define POLY_MESH
#define POLY_MESH // Polyhedron mesh
#ifdef POLY_MESH
#define MVC_POLY_MESH
#define BARY_POLY_MESH
#define ARAP_POLY_MESH
#endif
#define SURF_MESH
#define SURF_MESH // Surface_mesh
#ifdef SURF_MESH
#define ARAP_SURF_MESH
#endif
//#define SEAM_MESH
#ifdef SEAM_MESH
#define PM_SEAM_MESH // Polyhedron-based seam mesh
#ifdef PM_SEAM_MESH
#define POLY_MESH
#define ARAP_PM_SEAM_MESH
#endif
#define SM_SEAM_MESH // Surface_mesh-based seam mesh
#ifdef SM_SEAM_MESH
#define SURF_MESH
#define ARAP_SEMESH
#define ARAP_SM_SEAM_MESH
#endif
// #define REDIRECT_OUTPUT
#ifdef POLY_MESH
typedef CGAL::Polyhedron_3<Kernel> PMesh;
typedef CGAL::Polyhedron_3<Kernel> PMesh;
typedef boost::graph_traits<PMesh>::vertex_descriptor vertex_descriptor;
typedef boost::graph_traits<PMesh>::halfedge_descriptor halfedge_descriptor;
typedef boost::graph_traits<PMesh>::face_descriptor face_descriptor;
typedef boost::graph_traits<PMesh>::vertex_descriptor PM_vertex_descriptor;
typedef boost::graph_traits<PMesh>::halfedge_descriptor PM_halfedge_descriptor;
typedef CGAL::Parameterizer_traits_3<PMesh>::Error_code Error_code;
typedef CGAL::Unique_hash_map<PM_halfedge_descriptor, Point_2> PM_UV_hmap;
typedef boost::associative_property_map<PM_UV_hmap> PM_UV_pmap;
typedef CGAL::Parameterizer_traits_3<PMesh>::Error_code Error_code;
#endif
#ifdef SURF_MESH
typedef CGAL::Surface_mesh<Point_3> SMesh;
typedef CGAL::Surface_mesh<Point_3> SMesh;
typedef boost::graph_traits<SMesh>::vertex_descriptor SM_vertex_descriptor;
typedef boost::graph_traits<SMesh>::halfedge_descriptor SM_halfedge_descriptor;
typedef boost::graph_traits<SMesh>::face_descriptor SM_face_descriptor;
typedef boost::graph_traits<SMesh>::vertex_descriptor SM_vertex_descriptor;
typedef boost::graph_traits<SMesh>::halfedge_descriptor SM_halfedge_descriptor;
typedef SMesh::Property_map<SM_halfedge_descriptor, Point_2> SM_UV_pmap;
#endif
#ifdef SEAM_MESH
#ifdef SM_SEAM_MESH
typedef boost::graph_traits<SMesh>::edge_descriptor SM_edge_descriptor;
typedef SMesh::Property_map<SM_halfedge_descriptor, Point_2> UV_pmap;
typedef SMesh::Property_map<SM_edge_descriptor, bool> Seam_edge_pmap;
typedef SMesh::Property_map<SM_vertex_descriptor, bool> Seam_vertex_pmap;
typedef SMesh::Property_map<SM_edge_descriptor, bool> SM_seam_edge_pmap;
typedef SMesh::Property_map<SM_vertex_descriptor, bool> SM_seam_vertex_pmap;
typedef CGAL::Seam_mesh<SMesh, Seam_edge_pmap, Seam_vertex_pmap> TMesh;
typedef CGAL::Seam_mesh<SMesh, SM_seam_edge_pmap, SM_seam_vertex_pmap>
SM_Seam_mesh;
typedef boost::graph_traits<TMesh>::vertex_descriptor TM_vertex_descriptor;
typedef boost::graph_traits<TMesh>::halfedge_descriptor TM_halfedge_descriptor;
typedef boost::graph_traits<TMesh>::face_descriptor TM_face_descriptor;
typedef boost::graph_traits<SM_Seam_mesh>::vertex_descriptor SM_SE_vertex_descriptor;
typedef boost::graph_traits<SM_Seam_mesh>::halfedge_descriptor SM_SE_halfedge_descriptor;
#endif
#ifdef PM_SEAM_MESH
typedef boost::graph_traits<PMesh>::edge_descriptor PM_edge_descriptor;
typedef CGAL::Unique_hash_map<PM_edge_descriptor, bool> PM_seam_edge_hmap;
typedef boost::associative_property_map<PM_seam_edge_hmap> PM_seam_edge_pmap;
typedef CGAL::Unique_hash_map<PM_vertex_descriptor, bool> PM_seam_vertex_hmap;
typedef boost::associative_property_map<PM_seam_vertex_hmap> PM_seam_vertex_pmap;
typedef CGAL::Seam_mesh<PMesh, PM_seam_edge_pmap, PM_seam_vertex_pmap>
PM_Seam_mesh;
typedef boost::graph_traits<PM_Seam_mesh>::vertex_descriptor PM_SE_vertex_descriptor;
typedef boost::graph_traits<PM_Seam_mesh>::halfedge_descriptor PM_SE_halfedge_descriptor;
#endif
int main(int argc, char * argv[])
@ -91,18 +114,19 @@ int main(int argc, char * argv[])
std::freopen("/home/mrouxell/POLY_MESH.txt", "w", stdout);
#endif
// std::ifstream in((argc>1)?argv[1]:"../data/tiny_nef.off");
std::ifstream in((argc>1)?argv[1]:"../data/tiny_nef.off");
// std::ifstream in((argc>1)?argv[1]:"../data/nefertiti.off");
// std::ifstream in((argc>1)?argv[1]:"../data/lion.off");
// std::ifstream in((argc>1)?argv[1]:"../data/blob.off");
std::ifstream in((argc>1)?argv[1]:"/home/mrouxell/Data/OFF/mushroom.off");
// std::ifstream in((argc>1)?argv[1]:"/home/mrouxell/Data/OFF/mushroom.off");
// std::ifstream in((argc>1)?argv[1]:"/home/mrouxell/Data/OFF/lion-head.off");
// std::ifstream in((argc>1)?argv[1]:"../data/three_peaks.off");
// std::ifstream in((argc>1)?argv[1]:"/home/mrouxell/Data/OFF/three_peaks_dense.off");
// std::ifstream in((argc>1)?argv[1]:"../data/cow_with_hole.off");
// std::ifstream in((argc>1)?argv[1]:"../data/cow_dense.off");
// std::ifstream in((argc>1)?argv[1]:"../data/cow_densified.off");
// std::ifstream in((argc>1)?argv[1]:"../data/mushroom_hole_2.off");
// std::ifstream in((argc>1)?argv[1]:"../data/mushroom_big_hole.off");
// std::ifstream in((argc>1)?argv[1]:"../data/mushroom_hole_1.off");
if(!in){
std::cerr << "Problem loading the input data" << std::endl;
@ -118,13 +142,13 @@ int main(int argc, char * argv[])
PMesh pm;
in >> pm;
halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(pm).first;
PM_halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(pm).first;
CGAL::Unique_hash_map<vertex_descriptor, Point_2,
boost::hash<vertex_descriptor> > uvhm;
CGAL::Unique_hash_map<PM_vertex_descriptor, Point_2,
boost::hash<PM_vertex_descriptor> > uvhm;
boost::associative_property_map<
CGAL::Unique_hash_map<vertex_descriptor, Point_2,
boost::hash<vertex_descriptor> > > uvpm(uvhm);
CGAL::Unique_hash_map<PM_vertex_descriptor, Point_2,
boost::hash<PM_vertex_descriptor> > > uvpm(uvhm);
// Go to default (aka Mean values)
CGAL::parameterize(pm, hd, uvpm);
@ -141,16 +165,16 @@ int main(int argc, char * argv[])
PMesh pm;
in >> pm;
halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(pm).first;
PM_halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(pm).first;
// UV map
CGAL::Unique_hash_map<vertex_descriptor, Point_2,
boost::hash<vertex_descriptor> > uvhm;
CGAL::Unique_hash_map<PM_vertex_descriptor, Point_2,
boost::hash<PM_vertex_descriptor> > uvhm;
boost::associative_property_map<
CGAL::Unique_hash_map<vertex_descriptor, Point_2,
boost::hash<vertex_descriptor> > > uvpm(uvhm);
CGAL::Unique_hash_map<PM_vertex_descriptor, Point_2,
boost::hash<PM_vertex_descriptor> > > uvpm(uvhm);
// Indices map
typedef boost::unordered_map<vertex_descriptor,int> Indices;
typedef boost::unordered_map<PM_vertex_descriptor, int> Indices;
Indices indices;
CGAL::Polygon_mesh_processing::connected_component(face(opposite(hd, pm), pm),
pm,
@ -158,8 +182,8 @@ int main(int argc, char * argv[])
CGAL::Parameterization::Vertices<PMesh, Indices>(pm, indices)));
// Vertex parameterized map
boost::unordered_set<vertex_descriptor> vs;
CGAL::internal::Bool_property_map<boost::unordered_set<vertex_descriptor> > vpm(vs);
boost::unordered_set<PM_vertex_descriptor> vs;
CGAL::internal::Bool_property_map<boost::unordered_set<PM_vertex_descriptor> > vpm(vs);
typename CGAL::Barycentric_mapping_parameterizer_3<PMesh> parameterizer;
parameterizer.parameterize(pm, hd, uvpm, boost::make_assoc_property_map(indices), vpm);
@ -177,17 +201,17 @@ int main(int argc, char * argv[])
PMesh pm;
in >> pm;
halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(pm).first;
PM_halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(pm).first;
// UV map
CGAL::Unique_hash_map<vertex_descriptor, Point_2,
boost::hash<vertex_descriptor> > uvhm;
CGAL::Unique_hash_map<PM_vertex_descriptor, Point_2,
boost::hash<PM_vertex_descriptor> > uvhm;
boost::associative_property_map<
CGAL::Unique_hash_map<vertex_descriptor, Point_2,
boost::hash<vertex_descriptor> > > uvpm(uvhm);
CGAL::Unique_hash_map<PM_vertex_descriptor, Point_2,
boost::hash<PM_vertex_descriptor> > > uvpm(uvhm);
// Indices map
typedef boost::unordered_map<vertex_descriptor, int> Indices;
typedef boost::unordered_map<PM_vertex_descriptor, int> Indices;
Indices indices;
CGAL::Polygon_mesh_processing::connected_component(
face(opposite(hd, pm), pm),
@ -198,8 +222,8 @@ int main(int argc, char * argv[])
boost::associative_property_map<Indices> vipm(indices);
// Vertex parameterized map
boost::unordered_set<vertex_descriptor> vs;
CGAL::internal::Bool_property_map<boost::unordered_set<vertex_descriptor> > vpm(vs);
boost::unordered_set<PM_vertex_descriptor> vs;
CGAL::internal::Bool_property_map<boost::unordered_set<PM_vertex_descriptor> > vpm(vs);
// Parameterizer
typename CGAL::ARAP_parameterizer_3<PMesh> parameterizer;
@ -257,68 +281,96 @@ int main(int argc, char * argv[])
#endif
// ***************************************************************************
// ARAP WITH SEAM_MESH
// ARAP WITH SEAM_MESH (SM)
// ***************************************************************************
#ifdef ARAP_SEMESH
#ifdef ARAP_SM_SEAM_MESH
{
SMesh sm;
in.clear();
in.seekg(0, std::ios::beg);
in >> sm;
Seam_edge_pmap seam_edge_pm =
SM_seam_edge_pmap seam_edge_pm =
sm.add_property_map<SM_edge_descriptor,bool>("e:on_seam", false).first;
Seam_vertex_pmap seam_vertex_pm =
SM_seam_vertex_pmap seam_vertex_pm =
sm.add_property_map<SM_vertex_descriptor,bool>("v:on_seam",false).first;
std::ifstream in((argc>2) ? argv[2] : "../data/lion.selection.txt");
std::string vertices;
std::getline(in,vertices);
std::istringstream iss(vertices);
int p1, p2;
bool two_vertices_given = false;
if(iss >> p1 >> p2){
two_vertices_given = true;
}
int s, t;
SM_halfedge_descriptor smhd;
while(in >> s >> t){
SM_vertex_descriptor svd(s), tvd(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<SMesh>::null_halfedge()){
smhd = halfedge(edge(svd, tvd, sm).first, sm);
}
}
}
TMesh mesh(sm, seam_edge_pm, seam_vertex_pm);
SM_Seam_mesh mesh(sm, seam_edge_pm, seam_vertex_pm);
SM_halfedge_descriptor smhd = mesh.add_seams("../data/lion.selection.txt");
// 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_pmap uv_pm = sm.add_property_map<SM_halfedge_descriptor,
SM_UV_pmap uv_pm = sm.add_property_map<SM_halfedge_descriptor,
Point_2>("h:uv").first;
TM_halfedge_descriptor bhd(smhd);
SM_SE_halfedge_descriptor bhd(smhd);
bhd = opposite(bhd, mesh); // a halfedge on the virtual border
// Indices
typedef boost::unordered_map<TM_vertex_descriptor, int> Vertex_index_map;
Vertex_index_map vim;
boost::associative_property_map<Vertex_index_map> vipm(vim);
mesh.initialize_vertex_index_map(bhd, vipm);
typedef boost::unordered_map<SM_SE_vertex_descriptor, int> Indices;
Indices indices;
CGAL::Polygon_mesh_processing::connected_component(
face(opposite(bhd, mesh), mesh),
mesh,
boost::make_function_output_iterator(
CGAL::Parameterization::Vertices<SM_Seam_mesh, Indices>(mesh, indices)));
boost::associative_property_map<Indices> vipm(indices);
// Parameterized
boost::unordered_set<TM_vertex_descriptor> vs;
CGAL::internal::Bool_property_map<boost::unordered_set<TM_vertex_descriptor> > vpm(vs);
boost::unordered_set<SM_SE_vertex_descriptor> vs;
CGAL::internal::Bool_property_map<boost::unordered_set<SM_SE_vertex_descriptor> > vpm(vs);
typename CGAL::ARAP_parameterizer_3<TMesh> parameterizer;
typename CGAL::ARAP_parameterizer_3<SM_Seam_mesh> parameterizer;
parameterizer.parameterize(mesh, bhd, uv_pm, vipm, vpm);
}
#endif
// ***************************************************************************
// ARAP WITH SEAM_MESH (POLY)
// ***************************************************************************
#ifdef ARAP_PM_SEAM_MESH
{
PMesh pm;
in.clear();
in.seekg(0, std::ios::beg);
in >> pm;
PM_seam_edge_hmap seam_edge_hm(false);
PM_seam_edge_pmap seam_edge_pm(seam_edge_hm);
PM_seam_vertex_hmap seam_vertex_hm(false);
PM_seam_vertex_pmap seam_vertex_pm(seam_vertex_hm);
PM_Seam_mesh mesh(pm, seam_edge_pm, seam_vertex_pm);
PM_halfedge_descriptor pmhd = mesh.add_seams("../data/lion.selection.txt");
// 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
PM_UV_hmap uv_hm;
PM_UV_pmap uv_pm(uv_hm);
PM_SE_halfedge_descriptor bhd(pmhd);
bhd = opposite(bhd, mesh); // a halfedge on the virtual border
// Indices
typedef boost::unordered_map<PM_SE_vertex_descriptor, int> Indices;
Indices indices;
CGAL::Polygon_mesh_processing::connected_component(
face(opposite(bhd, mesh), mesh),
mesh,
boost::make_function_output_iterator(
CGAL::Parameterization::Vertices<PM_Seam_mesh, Indices>(mesh, indices)));
boost::associative_property_map<Indices> vipm(indices);
// Parameterized
boost::unordered_set<PM_SE_vertex_descriptor> vs;
CGAL::internal::Bool_property_map<boost::unordered_set<PM_SE_vertex_descriptor> > vpm(vs);
typename CGAL::ARAP_parameterizer_3<PM_Seam_mesh> parameterizer;
parameterizer.parameterize(mesh, bhd, uv_pm, vipm, vpm);
}
#endif

View File

@ -207,10 +207,14 @@ parameterize(Seam_mesh<TM,SEM,SVM>& mesh,
boost::unordered_set<vertex_descriptor> vs;
internal::Bool_property_map< boost::unordered_set<vertex_descriptor> > vpm(vs);
typedef boost::unordered_map<vertex_descriptor,int> Vertex_index_map;
Vertex_index_map vim;
boost::associative_property_map<Vertex_index_map> vipm(vim);
mesh.initialize_vertex_index_map(bhd,vipm);
typedef boost::unordered_map<vertex_descriptor, int> Indices;
Indices indices;
CGAL::Polygon_mesh_processing::connected_component(
face(opposite(bhd, mesh), mesh),
mesh,
boost::make_function_output_iterator(
Parameterization::Vertices<Seam_mesh<TM,SEM,SVM>, Indices>(mesh, indices)));
boost::associative_property_map<Indices> vipm(indices);
Mean_value_coordinates_parameterizer_3<Seam_mesh<TM,SEM,SVM> > parameterizer;
return parameterizer.parameterize(mesh, bhd, uvm, vipm, vpm);
@ -229,10 +233,14 @@ parameterize(Seam_mesh<TM,SEM,SVM>& mesh,
boost::unordered_set<vertex_descriptor> vs;
internal::Bool_property_map< boost::unordered_set<vertex_descriptor> > vpm(vs);
typedef boost::unordered_map<vertex_descriptor,int> Vertex_index_map;
Vertex_index_map vim;
boost::associative_property_map<Vertex_index_map> vipm(vim);
mesh.initialize_vertex_index_map(bhd,vipm);
typedef boost::unordered_map<vertex_descriptor, int> Indices;
Indices indices;
CGAL::Polygon_mesh_processing::connected_component(
face(opposite(bhd, mesh), mesh),
mesh,
boost::make_function_output_iterator(
Parameterization::Vertices<Seam_mesh<TM,SEM,SVM>, Indices>(mesh, indices)));
boost::associative_property_map<Indices> vipm(indices);
return parameterizer.parameterize(mesh, bhd, uvm, vipm, vpm);
}