So I have a disparate number of line segments which I want to combine to form a polygon. So imagine 4 points p0,p1,p2,p3
which form a open polygon p0-p1-p2-p3
. (This is illustrative : the polygon could be closed also)
But my algorithm generates the segments in random order say (p2,p3) (p0,p1) (p1,p2)
. Hence to combine them coherently I used the Arrangements_2 class in CGAL.
I have combined them. But now they form a single polygon with an unbounded face. I am not so sure how can I print out the vertex in an orderly fashion.
What I want is the algorithm to output (p0-p1-p2-p3) OR (p3-p2-p1-p0).
I looked at the documentation link here and they have a nice traversal order for bounded faces but not so much for unbounded faces.
My questions :
Can I achieve the same using traversals for unbounded face ?
If not Arrangements_2 what else can I use in CGAL to achieve the same thing ? (The next best thing I can think of is writing a DS myself)
Arrangements will certainly do the job.
Once all curves inserted, you can verify that the arrangement has two faces arr.number_of_faces()
; one unbounded face that has exactly one inner ccb (connected component of the boundary) and another face that has exactly one outer ccb.
Obtain the first face arr.faces_begin()
. If it's unbounded f−>is_unbounded()
, obtain its first inner boundary f−>holes_begin()
. Otherwise, obtain its outer boundary f−>outer_ccb()
.