I am trying to project a Polyhedron on the xy plane with CGAL, which should result in a (2D) polygon.

I wonder, if there is an elegant way to achieve it?

Of course, I can iterate over all surfaces and build 2D-Segments from the 3D-Segments by throwing away the z coordinate and then reassemble the polgon cycles.

But I feel, that somehow using Projection_traits_xy_3 it should be possible to solve that task more elegant, however, I couldn't find a way. Is this possible?


1 Answer 1


A possible way to do this is tracing the silhouette edges of the polyhedron and projecting them to a 2d polygon only at the end of the process.

A silhouette edge (in your context) is defined by its neighboring facets having one upwards and one downwards normal (i.e., one positive normal z-coordinate and one negative). This can be checked using Polyhedron_traits_with_normals_3 or you can compute the normals yourself on-the-fly.

If you only need the outside polygon, you can start with an extreme vertex (e.g., the one with minimal x-coordinate), circulate over its incident halfedges (using Halfedge_around_vertex_circulator), take the one that is a silhouette edge and continue tracing with its next vertex until you close the cycle.

If you also need inside (hole) polygons, a possible solution can be to gather the silhouette edges from all the polyhedron, and trace the cycles from this set.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.