Skip to Content.
Sympa Menu

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

Subject: CGAL users discussion list

List archive

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


Chronological Thread 
  • From: Laure Guicherd <>
  • To:
  • Subject: [cgal-discuss] Voronoi 2D : convert Halfedge to Segment_2 or Ray_2
  • Date: Mon, 12 Apr 2010 17:05:51 +0200
  • Organization: Buf Compagnie

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



Archive powered by MHonArc 2.6.16.

Top of Page