2015-11-24 1 views
0

J'ai calculé une triangulation delaunay contrainte 2D à partir de données 2.5D en utilisant le projection_traits_xy_3 [1]. Maintenant, je voudrais obtenir un maillage que je peux visualiser.Obtention d'un mesh_3 'off' de Projection_traits_xy_3 contraint delaunay

J'ai réussi à faire cela avec 3D delaunay suivant le manuel [2], comment pourrais-je l'obtenir avec un CDT 2.5D?

[...] 
typedef CGAL::Projection_traits_xy_3<K> Gt; 
typedef CGAL::Constrained_Delaunay_triangulation_2<Gt, Tds> CDT; 
[...] 
CDT cdt; 
cdt.insert(points.begin(),points.end()); 
[...] 
¿? 
[...] 
std::ofstream out(outdir + "out.off"); 
Polyhedron output_mesh; 
CGAL::output_surface_facets_to_polyhedron(¿?, output_mesh); 
out << output_mesh; 

[1] http://pastebin.com/HzAwrnW5

[2] http://doc.cgal.org/latest/Point_set_processing_3/index.html#chappoint_set_processing_3 http://doc.cgal.org/latest/Surface_reconstruction_points_3/

Répondre

0

De suggestion @Andreas:

Voici le c ode pour l'écrire dans un fichier

std::ofstream outstream("output.off"); 
outstream << "OFF\n" << cdt.number_of_vertices() 
     << " " << cdt.number_of_faces() << " 0" << std::endl; 

std::map<CDT::Vertex_handle,int> indices; 
int counter = 0; 

for(CDT::Finite_vertices_iterator it = cdt.finite_vertices_begin(); it != cdt.finite_vertices_end(); ++it) 
{ 
    outstream << it->point() << std::endl; 
    indices.insert(std::pair<CDT::Vertex_handle,int>(it, counter++)); 
} 

for(CDT::Finite_faces_iterator it = cdt.finite_faces_begin(); it != cdt.finite_faces_end(); ++it) 
{ 
    outstream << "3 " << indices[it->vertex(0)] 
      << " " << indices[it->vertex(1)] 
      << " " << indices[it->vertex(2)] << std::endl; 
} 
0

vient ici pseudocode ForWriting dans un fichier de

cout << "OFF\n" << cdt.number_of_vertices() 
     << " " << cdt.number_of_faces() << " 0" << std::endl; 

std::map<vertex_handle,int> indices; 
int counter = 0; 

for all finite vertices v { 
    cout << v->point() <<std::endl; 
    indices.insert(v, counter++); 
} 

for all finite faces f { 
    cout << "3 " << indices[f->vertex(0)]  
     << " " << indices[f->vertex(1)] 
     << " " << indices[f->vertex(2)] << std::endl; 
} 
+0

ok! Puis-je modifier votre réponse avec le code réel? – quimnuss

+0

Je l'ai fait, si vous préférez que j'écrive une autre réponse annuler les changements et je vais commettre une bonne réponse. – quimnuss

+0

s'il vous plaît aller de l'avant. –