Subject: CGAL users discussion list
List archive
- From: Philipp Moeller <>
- To:
- Subject: Re: [cgal-discuss] Getting facet indexes from polyhedron_3
- Date: Fri, 13 Apr 2012 00:45:33 +0200
- Organization: GeometryFactory
<>
writes:
> Hi!
>
> I have a Polyhedron_3 object and i would like to get the 3 vertex-index of
> facet.
> Basically what i want is a list of indexes which is exactly the same as the
> 2nd
> part of an .off model.
>
> How can i do that?
> I tried:
>
> for ( Facet_const_iterator i = Poly.facets_begin(); i != Poly.facets_end();
> ++i)
> {
> cout << i->plane() << endl;
> }
>
> but it only prints out for zeros a line.
When using a Polyhedron with indices you need to initialize the indices
manually, e.g.
std::size_t i = 0;
for(Polyhedron::Vertex_iterator it = Poly.vertices_begin(), blabla...)
it->id() = i++;
i = 0;
for(Polyhedron::Facet_iterator it = Poly.vertices_begin(), blabla...)
it->id() = i++;
// edges etc.
Then you can iterate around the facets and access the indices:
for(Polyhedron::Face_iterator it = Poly.facets_begin(), blabla...) {
Polyhedron::Halfedge_around_facet_circulator circ =
it->facet_begin();
cout << "Vertex indices of facet: " << it->id();
do {
cout << circ->vertex()->id() << " ";
} while ( ++circ != it->facet_begin());
cout << '\n';
}
Make sure to use a Polyhedron_item that supports indices. There is one
prepared in CGAL.
#include <CGAL/Polyhedron_items_with_id_3.h>
typedef CGAL::Polyhedron_3<Kernel,CGAL::Polyhedron_items_with_id_3>
Polyhedron;
But you might need to look-up how to create your own Polyhedron items.
If you really require the order to be the same as in the OFF file you
need to play with Incremental_builder to get the id right when building
the Polyhedron.
>
> Thank you very much in advance!
>
> Sincerely,
>
> Zoli
HTH,
Philipp Moeller
GeometryFactory
- [cgal-discuss] Getting facet indexes from polyhedron_3, vrzolt, 04/12/2012
- Re: [cgal-discuss] Getting facet indexes from polyhedron_3, Philipp Moeller, 04/13/2012
- Re: [cgal-discuss] Getting facet indexes from polyhedron_3, vrzolt, 04/14/2012
Archive powered by MHonArc 2.6.16.