Subject: CGAL users discussion list
List archive
Re: [cgal-discuss] How to extract faces from a CDT? examples/Mesh_2/mesh_global.cpp
Chronological Thread
- From: "Laurent Rineau (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] How to extract faces from a CDT? examples/Mesh_2/mesh_global.cpp
- Date: Wed, 7 Oct 2009 22:10:40 +0200
- Organization: GeometryFactory
Le mercredi 07 octobre 2009 16:23:45, Alejandro Aguilar Sierra a écrit :
> Hi Matt,
>
> Thank you for the hint. Actually what I want is to get the index of
> the vertices on the container so I can build a drawable OBJ file.
>
> A dirrty way to do it is using this code:
>
> for (CDT::Face_iterator fit = cdt.faces_begin(); fit!=
> cdt.faces_end(); ++fit) {
> int idx = 0;
> int i0, i1, i2;
>
> for (CDT::Vertex_iterator vit = cdt.vertices_begin(); vit!=
> cdt.vertices_end(); ++vit) {
> idx++;
> if ((*vit).point() == (*fit).vertex(0)->point()) i0 = idx;
> if ((*vit).point() == (*fit).vertex(1)->point()) i1 = idx;
> if ((*vit).point() == (*fit).vertex(2)->point()) i2 = idx;
> }
>
> std::cout << "f " << i0 << " " << cdt.triangle(fit) << std::endl;
> }
>
> And I get a drawable mesh. Is there a cleaner way?
Fill a std::map<Vertex_handle, int>:
std::map<Vertex_handle, int> vertex_index;
int idx = 0;
for (CDT::Vertex_iterator vit = cdt.vertices_begin(); vit!=
cdt.vertices_end(); ++vit) {
vertex_index[vit]=idx++;
}
for (CDT::Face_iterator fit = cdt.faces_begin(); fit!=
cdt.faces_end(); ++fit) {
int i0 = vertex_index[fit->vertex(0)];
int i1 = vertex_index[fit->vertex(1)];
int i2 = vertex_index[fit->vertex(2)];
// and so on...
}
--
Laurent Rineau, PhD
Release Manager of the CGAL Project
http://www.cgal.org/
R&D Engineer at GeometryFactory
http://www.geometryfactory.com/
- [cgal-discuss] How to extract faces from a CDT? examples/Mesh_2/mesh_global.cpp, Alejandro Aguilar Sierra, 10/07/2009
- Message not available
- Re: [cgal-discuss] How to extract faces from a CDT? examples/Mesh_2/mesh_global.cpp, Matthew Denno, 10/07/2009
- Re: [cgal-discuss] How to extract faces from a CDT? examples/Mesh_2/mesh_global.cpp, Matthew Denno, 10/07/2009
- Re: [cgal-discuss] How to extract faces from a CDT? examples/Mesh_2/mesh_global.cpp, Alejandro Aguilar Sierra, 10/07/2009
- Re: [cgal-discuss] How to extract faces from a CDT? examples/Mesh_2/mesh_global.cpp, Laurent Rineau (GeometryFactory), 10/07/2009
- Re: [cgal-discuss] How to extract faces from a CDT? examples/Mesh_2/mesh_global.cpp, Alejandro Aguilar Sierra, 10/07/2009
- Re: [cgal-discuss] How to extract faces from a CDT? examples/Mesh_2/mesh_global.cpp, Matthew Denno, 10/07/2009
- Re: [cgal-discuss] How to extract faces from a CDT? examples/Mesh_2/mesh_global.cpp, Matthew Denno, 10/07/2009
- Message not available
Archive powered by MHonArc 2.6.16.