Search code examples
c++return-valuecgal

CGAL: Output from neighbour when the triangle has none


So I am wondering what happens in CGAL Delaunay triangulation when you call the neighbor function for a neighbor that doesn't exist. In the documentation (HERE) it says this:

The neighbor with index i is the neighbor which is opposite to the vertex with index i.

Face_handle  f.neighbor ( int i) const   //returns the neighbor i of f.
                                        //Precondition:     0 ≤ i ≤ 2.

But not all triangles can have 3 neighbors. Edge and corner triangles will neighbor only 2. Given that it must now return a Face_handle, what would happen for the neighbors that don't exist? Maybe it will be NULL? How can i check this?

The reason i am looking to do this is because i would like to identify all the edge triangles in a Delaunay triangulation. Being able to check for triangles with 2 or less neighbors would be very useful.

Any ideas?


Solution

  • See the documentation.

    CGAL introduces an infinite vertex, hence each "border edge" has an additional neighbour, which is an infinite triangle composed of the two vertices of your edge and the infinite vertex.