Subject: CGAL users discussion list
List archive
- From: Sebastien Loriot <>
- To:
- Subject: Re: [cgal-discuss] Problem with Voronor diagram
- Date: Wed, 27 Jun 2007 15:07:13 +0200
Le mer 27 juin 2007 14:43, Kuan a écrit :
> Hi all,
> I have a question about the Voronor diagram.
> I created a Voronor diagram in 2D from input points. And it will of course
> have some infinite edges. But now i want to restrict the diagram in a quad
> area. So how can i get the direction of the infinite edges, so i can
> calculate the intersect point of the edge and the quad area boundary.
>
> greeting
> Kuan
Hi,
You can do something like this.
typedef CGAL::Ray_2<KernelCD> Ray;
typedef CGAL::Line_2<KernelCD>
Line;
typedef CGAL::Segment_2<KernelCD>
Segment;
typedef std::list<Ray>
RayList;
typedef std::list<Line>
LineList;
typedef std::list<Segment>
SegmentList;
typedef CGAL::Iso_rectangle_2<KernelCD>
Rectangle;
struct Voronoi_recup { //class using stream to get the voronoi diagram
RayList quR;
LineList quL;
SegmentList quS;
Voronoi_recup() {}
void operator<<(const Ray p){quR.insert(quR.begin(),p);}
void operator<<(const Line p){quL.insert(quL.begin(),p);}
void operator<<(const Segment p){quS.insert(quS.begin(),p);}
};
//Convert objects into drawable segments
template<class iterator,class lst>
void cast_into_seg(const iterator first,const iterator end,const Rectangle&
bbox,lst& Seglist){
for (iterator it=first;it!=end;++it){
CGAL::Object obj_cgal = CGAL::intersection(*it,bbox);
Segment s;
if (CGAL::assign(s, obj_cgal))
Seglist.push_back(s);
}
}
int main(){
CGAL::Delaunay_triangulation_2<KernelCD> de;
Voronoi_recup v_recup = Voronoi_recup();
//add your points here
dt.draw_dual(v_recup);
cast_into_seg(v_recup.quR.begin(),v_recup.quR.end(),bbox_cgal,SL);//cast rays
into segments in bbox
cast_into_seg(v_recup.quL.begin(),v_recup.quL.end(),bbox_cgal,SL);//cast
lines into segments in bbox
cast_into_seg(v_recup.quS.begin(),v_recup.quS.end(),bbox_cgal,SL);//cast
lines into segments in bbox
}
--
INRIA Sophia-Antipolis - Geometrica
2004 route des Lucioles, BP 93
06902 Sophia-Antipolis FRANCE
Phone: 33 (0)4 92 38 79 73
,
http://www-sop.inria.fr/geometrica
- Problem with Voronor diagram, Kuan, 06/27/2007
- Re: [cgal-discuss] Problem with Voronor diagram, Sebastien Loriot, 06/27/2007
- Re: [cgal-discuss] Problem with Voronor diagram, Kuan, 06/27/2007
- Re: [cgal-discuss] Problem with Voronor diagram, Sebastien Loriot, 06/27/2007
- Re: [cgal-discuss] Problem with Voronor diagram, Kuan, 06/27/2007
- Re: [cgal-discuss] Problem with Voronor diagram, Sebastien Loriot, 06/27/2007
Archive powered by MHonArc 2.6.16.