Subject: CGAL users discussion list
List archive
- From: memecs <>
- To:
- Subject: [cgal-discuss] Voronoi Diagram and NaN
- Date: Tue, 15 Nov 2011 03:13:43 -0800 (PST)
Hi,
I am trying to generate a bounded (by a rectangle) voronoi diagram. Here is
my code:
DT dt;
dt.insert(points.begin(), points.end());
typedef typename K::Point_2 Point_2;
typename K::Ray_2 ray;
typename K::Line_2 line;
typename K::Segment_2 segment;
vector<Polygon_2> bounded_voronoi_faces;
// Find to which voronoi face the boundary points belong to.
list<std::pair<DT::Vertex_handle, Point_2> > nearest_vertices;
for(int j = 0; j < 4; ++j) {
DT::Vertex_handle nearest =
dt.nearest_vertex(bbox.vertex(j));
nearest_vertices.push_back(std::pair<DT::Vertex_handle,
Point_2>(nearest, bbox.vertex(j)));
}
// Iterate over all delaunay vertices. Each vertex is a site of a
voronoi face.
unsigned i = 0;
for(DT::Finite_vertices_iterator fvit = dt.finite_vertices_begin();
fvit != dt.finite_vertices_end(); ++fvit, ++i) {
// Circulate over all edges incident to the current vertex.
vector<Point_2> unique_points;
DT::Edge_circulator ec = dt.incident_edges(fvit);
do {
if(!dt.is_infinite(ec)) {
CGAL::Object voronoi_obj, intersection_obj;
voronoi_obj = dt.dual(ec);
if(CGAL::assign(segment,voronoi_obj)) {
intersection_obj =
CGAL::intersection(segment,bbox);
}
else if(CGAL::assign(ray,voronoi_obj)) {
intersection_obj =
CGAL::intersection(ray,bbox);
}
else if(CGAL::assign(line,voronoi_obj)) {
intersection_obj =
CGAL::intersection(line,bbox);
}
else {
// Something is wrong???
assert(false);
}
typename K::Segment_2 intersected_segment;
Point_2 intersected_point;
if(CGAL::assign(intersected_segment,intersection_obj)) {
// The object intersected
unique_points.push_back(intersected_segment.source());
unique_points.push_back(intersected_segment.target());
}
else {
// If it's a point or didn't
intersect do nothing...
}
}
} while(++ec != dt.incident_edges(fvit));
The problem is:
sometimes I get voronoi segments with source or target points equals to
NaN.
For example:
if(CGAL::assign(segment,voronoi_obj)) {
Delaunay segment: 490 39 495 29
Voronoi segment: 493.5 34.5 -nan -nan
}
I really don't understand how is this possible. The input points I use to
construct the delaunay triangulation don't overlap.
Does someone have an idea?
Thanks
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Voronoi-Diagram-and-NaN-tp4042568p4042568.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] Voronoi Diagram and NaN, memecs, 11/15/2011
- Re: [cgal-discuss] Voronoi Diagram and NaN, Sebastien Loriot (GeometryFactory), 11/15/2011
- [cgal-discuss] Re: Voronoi Diagram and NaN, memecs, 11/15/2011
- [cgal-discuss] Re: Voronoi Diagram and NaN, memecs, 11/15/2011
- Re: [cgal-discuss] Re: Voronoi Diagram and NaN, Sebastien Loriot (GeometryFactory), 11/15/2011
- [cgal-discuss] Re: Voronoi Diagram and NaN, memecs, 11/15/2011
- Re: [cgal-discuss] Re: Voronoi Diagram and NaN, Sebastien Loriot (GeometryFactory), 11/16/2011
- [cgal-discuss] Re: Voronoi Diagram and NaN, memecs, 11/15/2011
- [cgal-discuss] Re: Voronoi Diagram and NaN, memecs, 11/15/2011
- Re: [cgal-discuss] Voronoi Diagram and NaN, Sebastien Loriot (GeometryFactory), 11/15/2011
Archive powered by MHonArc 2.6.16.