Subject: CGAL users discussion list
List archive
- From: "Wesley Smith" <>
- To:
- Subject: 3D voronoi from Delaunay Triangulation 3D
- Date: Fri, 14 Sep 2007 17:28:33 -0700
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=n+fY+0FLz2PMF0MSPHb5zcX9AIBVSfDd5XKozQZISWfNWZdS30xvzCfP5+vXqpWjjugawv3xW5KADUUzKHNsjMN54Sq3YmLwUOCWZO6F+7NUeGYT089nXYed/mzSIb4PzGH1tEt7hmw5w5LzpQqPKIpJTgswNsUDkHugk56uXv0=
I'm working on getting 3D voronoi information from
Delaunay_triangulation_3 and am getting some information I'm not sure
is valid. The points in the triangulation are:
(0, 0, 0)
(1, 0, 0)
(0, 1, 0)
(0, 0, 1)
(1, 1, 1)
These are the cells
p0: 0 0 0
p1: 1 0 0
p2: 0 1 0
p3: 0 0 1
dual: 0.5 0.5 0.5
p0: 1 0 0
p1: 1 1 1
p2: 0 1 0
p3: 0 0 1
dual: 0.5 0.5 0.5
And the duals for the finite facets:
segment:
p0: 0.5 0.5 0.5
p1: 0.5 0.5 0.5
What I'm trying to figure out is why I get a degenerate segment
(basically a point) as the only dual. The code for getting the duals
looks like:
for(Finite_facets_iterator fi = T.finite_facets_begin();
fi != T.finite_facets_end();
fi++)
{
CGAL::Object o = T.dual(*fi);
if(const Segment * seg = CGAL::object_cast<Segment>(&o)) {
Point p0 = seg->vertex(0);
Point p1 = seg->vertex(1);
}
}
Is this how it's supposed to be done? I'm trying to figure out how
Object works but am not sure if I got it right. The entire code is
here:
#include <CGAL/basic.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Triangulation_cell_base_with_circumcenter_3.h>
#include <CGAL/IO/Triangulation_geomview_ostream_3.h>
#include <iostream>
// exact constructions (circumcenter computations) are needed in this
// demo, not only predicates
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
typedef CGAL::Triangulation_vertex_base_3<K> Vb;
typedef CGAL::Triangulation_cell_base_with_circumcenter_3<K> Cb;
typedef CGAL::Triangulation_data_structure_3<Vb, Cb> TDS;
typedef CGAL::Delaunay_triangulation_3<K, TDS> Triangulation;
// typedef CGAL::Delaunay_triangulation_3<K> Triangulation;
typedef Triangulation::Cell_handle
Cell_handle;
typedef Triangulation::Finite_cells_iterator Finite_cells_iterator;
typedef Triangulation::Point Point;
typedef Triangulation::Finite_facets_iterator
Finite_facets_iterator;
typedef Triangulation::Segment
Segment;
int main()
{
Triangulation T;
std::cout <<" Inserting points" << std::endl ;
T.insert(Point(0, 0, 0));
T.insert(Point(1, 0, 0));
T.insert(Point(0, 1, 0));
T.insert(Point(0, 0, 1));
T.insert(Point(1, 1, 1));
for(Finite_cells_iterator it = T.finite_cells_begin(); it !=
T.finite_cells_end(); it++) {
Cell_handle c = it;
Point p0 = c->vertex(0)->point();
Point p1 = c->vertex(1)->point();
Point p2 = c->vertex(2)->point();
Point p3 = c->vertex(3)->point();
Point dual = T.dual(c);
std::cout << std::endl;
std::cout << "p0: " << p0.x() << " " << p0.y() << " " <<
p0.z() << std::endl;
std::cout << "p1: " << p1.x() << " " << p1.y() << " " <<
p1.z() << std::endl;
std::cout << "p2: " << p2.x() << " " << p2.y() << " " <<
p2.z() << std::endl;
std::cout << "p3: " << p3.x() << " " << p3.y() << " " <<
p3.z() << std::endl;
std::cout << "dual: " << dual.x() << " " << dual.y() << " " <<
dual.z() << std::endl;
}
int segments = 0;
for(Finite_facets_iterator fi = T.finite_facets_begin();
fi != T.finite_facets_end();
fi++)
{
CGAL::Object o = T.dual(*fi);
if(const Segment * seg = CGAL::object_cast<Segment>(&o)) {
printf("\nsegment: %d\n", segments);
segments++;
Point p0 = seg->vertex(0);
Point p1 = seg->vertex(1);
std::cout << "p0: " << p0.x() << " " << p0.y() << " "
<< p0.z() << std::endl;
std::cout << "p1: " << p1.x() << " " << p1.y() << " "
<< p1.z() << std::endl;
}
}
return 0;
}
- 3D voronoi from Delaunay Triangulation 3D, Wesley Smith, 09/15/2007
- Re: 3D voronoi from Delaunay Triangulation 3D, Wesley Smith, 09/15/2007
- Re: [cgal-discuss] 3D voronoi from Delaunay Triangulation 3D, Andreas Fabri, 09/15/2007
Archive powered by MHonArc 2.6.16.