I am using CGAL and I have a Polygon that I created with some vertices.
Now I get a segment, with:
Segment_2 segment = polygon.edge(i)
where i
is an index from 0
to polygon.size()
.
How can I transform an Segment_2
to an Edge
? Like there is a t.segment(Edge e)
to get a Segment_2
from an Edge
, I want something to get the reverse (Segment_2
to Edge
).
Now I am completely sure that this segment belongs to an Edge on the Triangulation_2, how can I get it? something like triangulation.edge(Segment_2)
maybe.
Help please.
If you have kept the two vertex handles corresponding to the two points of the segment, you can use this function:
bool
CGAL::Triangulation_2< Traits, Tds >::
is_edge(Vertex_handle va,
Vertex_handle vb,
Face_handle & fr,
int & i
)
Assuming v1
and v2
are the vertex handles, and t
your triangulation object:
Face_handle fh;
int i;
if(t.is_edge(v1, v2, fh, i)) {
Edge my_edge = Edge(fh, i);
// ... use your Edge
}