Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Voronoi 2D : convert Halfedge to Segment_2 or Ray_2

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Voronoi 2D : convert Halfedge to Segment_2 or Ray_2


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Voronoi 2D : convert Halfedge to Segment_2 or Ray_2
  • Date: Tue, 13 Apr 2010 08:24:25 +0200

Laure Guicherd wrote:
Hi all,
I'm kind of stuck with this issue with Voronoi 2D. I know this topic has been discussed a lot in this mailing, but I could not find a solution in the archives.

I am getting a Voronoi diagram from successive sites insertions, then i want to get its faces and vertices. Since i want to bound this diagram with a convex hull, i need to get the intersection of the diagram edges with this hull, and in this purpose i want to convert each halfedge to Segment_2 or Ray_2 in order to test this intersection.

Here is my (simplified) code :



typedef typename CGAL::Delaunay_triangulation_2<K> DT; typedef typename CGAL::Delaunay_triangulation_adaptation_traits_2<DT> AT;
typedef typename CGAL::Delaunay_triangulation_caching_degeneracy_removal_policy_2<DT> AP;
typedef typename CGAL::Voronoi_diagram_2<DT,AT,AP> Voronoi;
typedef typename Voronoi::Face_iterator Face_iterator;
typedef typename Voronoi::Ccb_halfedge_circulator Ccb_halfedge_circulator;
typedef typename AT::Site_2 Site_2;


Voronoi VD;

// for each point [x,y] :
VD.insert( Site_2(x,y) );

for ( Face_iterator bf = VD.faces_begin() ; bf != VD.faces_end() ; ++bf )
{
Ccb_halfedge_circulator firstEdge = (*bf).outer_ccb();
Ccb_halfedge_circulator he = firstEdge;
do
{
CGAL::Object obj = make_object(he);

Segment_2 segment;
Ray_2 ray;
bool isSegment = ( CGAL::assign( segment, obj ) );
bool isRay = ( CGAL::assign( ray, obj ) );

// test intersection, get points, etc.
}
while ( ++he != firstEdge );
}


My problem is that isRay and isSegment always return false, even when he->is_ray() or he->is_segment() are true.

What did i do wrong ? How can i make this conversion ?
Any hint will be greatly appreciated, thank you !

Laure


This post could help you.

https://lists-sop.inria.fr/sympa/arc/cgal-discuss/2007-06/msg00229.html


If you really need to use the approach with the adaptator, you can
find if a halfedge is on a ray or a segment using functions has_source() and has_target() like in this example:
http://www.cgal.org/Manual/last/doc_html/cgal_manual/Voronoi_diagram_2/Chapter_main.html#Section_44.5

Note that in the approach you are using, Voronoi diagram is described using a halfedge data struture. If you are not familiar with it, have a look here:

http://www.cgal.org/Manual/last/doc_html/cgal_manual/HalfedgeDS/Chapter_main.html

S.



Archive powered by MHonArc 2.6.16.

Top of Page