Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Face_handle from face?

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Face_handle from face?


Chronological Thread 
  • From: Sylvain Pion <>
  • To:
  • Subject: Re: [cgal-discuss] Face_handle from face?
  • Date: Tue, 25 Nov 2014 12:04:49 -0800

I can think of 2 ways.

First is to usTriangulation_data_structure::Face_range::s_iterator_to() similarly to what I wrote here :
http://stackoverflow.com/questions/23671091/how-to-efficiently-access-vertex-handle-from-cgaltriangulation-3-for-a-vertex

Second is to go to a neighboring face and back : pick f.neighbor(0), then look among its 3 neighbors Face_handles which one has the same address as f.


2014-11-25 11:13 GMT-08:00 Jack Stalnaker <>:
I can't use c++11 features right now, but I did find a workaround.

I wanted to do this: 
CGAL::centroid(cdt.triangle(face));

but that didn't work as described above. However, this works:
CGAL::centroid(face.vertex(0)->point(), face.vertex(1)->point(), face.vertex(2)->point())

which will suffice unless anyone knows a cleaner way.

On Tue, Nov 25, 2014 at 1:00 PM, Chris Marsh <> wrote:
Mmh sorry, I misunderstood. Why not wrap DoSomething() in a lambda that does the cast? Although that is predicated on C++11 compiler features, which may be a no-go. 

On Tue, Nov 25, 2014 at 12:55 PM, Jack Stalnaker <> wrote:
That works well for a for loop, but not for an STL algorithm like for_each like this:

std::for_each(cdt.finite_faces_begin(), cdt.finite_faces_end(), DoSomething())

where DoSomething is a functor. DoSomething gets *fit instead of fit, which is a face. I'd like to call cdt.triangle, but that only accepts Face_handles.

On Tue, Nov 25, 2014 at 12:45 PM, Chris Marsh <> wrote:
I do this:

    for (Delaunay::Finite_faces_iterator fit = this->finite_faces_begin();
         fit != this->finite_faces_end(); ++fit)
    {
        Delaunay::Face_handle face = fit;

Where Delaunay is just
typedef CGAL::Delaunay_triangulation_2<Gt, Tds> Delaunay; //specify a delauany triangulation

Cheers
Chris

On Tue, Nov 25, 2014 at 12:41 PM, Jack Stalnaker <> wrote:
How do I get a Face_handle from a face? If I use a finite_faces_iterator in an STL algorithm, it dereferences the iterator to a face, but I'd like to use Triangle CGAL::Triangulation_2< Traits, Tds >::triangle, which only accepts Face_handles.  

Thanks.








Archive powered by MHonArc 2.6.18.

Top of Page