Subject: CGAL users discussion list
List archive
- From: <>
- To:
- Subject: [cgal-discuss] How can I get the boundaries of a Face of voronoi diagram
- Date: Sat, 13 Feb 2010 13:12:47 +0100 (CET)
Hi all,
I am a newbie to cgal and I have a problem concerning voronoi Diagrams.
I created voronoi Diagrams and I am able to write the Points of each Edge
(x,y
) to the output stream.
But how can I get the boundary segments of one Face containing a Point of
interest. I need this to calculate the area of the corresponding face.
So far I used the the code from the CGAL Homepage
By transforming the edges to segments I get the two Points (x,y) describing
one edge.
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> Triangulation;
typedef Triangulation::Edge_iterator Edge_iterator;
typedef Triangulation::Point Point;
int main( )
{
std::ifstream in("data/voronoi.cin");
std::istream_iterator<Point> begin(in);
std::istream_iterator<Point> end;
Triangulation T;
T.insert(begin, end);
int ns = 0;
int nr = 0;
Edge_iterator eit =T.edges_begin();
for ( ; eit !=T.edges_end(); ++eit) {
CGAL::Object o = T.dual(eit);
if (CGAL::object_cast<K::Segment_2>(&o)) {++ns;}
else if (CGAL::object_cast<K::Ray_2>(&o)) {++nr;}
}
std::cout << "The Voronoi diagram has " << ns << " finite edges "
<< " and " << nr << " rays" << std::endl;
return 0;
}
Thank you very much in advance.
Andi
- [cgal-discuss] How can I get the boundaries of a Face of voronoi diagram, csae8148, 02/13/2010
Archive powered by MHonArc 2.6.16.