Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Problem with Voronor diagram

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Problem with Voronor diagram


Chronological Thread 
  • From: Kuan <>
  • To:
  • Subject: Re: [cgal-discuss] Problem with Voronor diagram
  • Date: Wed, 27 Jun 2007 15:51:22 +0200
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=jlZL2dSSYCTvLSu2CAxsD+68EZBpO5IKu8VQVoXHelhS4krzu7vPK8oC7qyF8ZNQIRQ9NHLMkx8UaKuwcPskCd9J2KN3JeUQpAUZTYiAa0jKcHABDqTJ59XeOrTBWuBxFx9EfDclaQfDSPZF14/ofssOnnUUo8XLZ67jfzrqqVk=

Hi Sebastien,
thank you very much, it seems good!
And i have one more question, if i use CGAL::Vronoi diagram 2, how can i get these CGAL::Ray_2?
Because in that class, i can only get Halfedge, which only has a marker to define whether it's infinite. Because i also want to do someting with these directions.
greeting
Kuan

2007/6/27, Sebastien Loriot <>:
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

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss




Archive powered by MHonArc 2.6.16.

Top of Page