Subject: CGAL users discussion list
List archive
- From: redpearl <>
- To:
- Subject: [cgal-discuss] Strange question on computing Power Diagram
- Date: Sun, 14 Jun 2009 08:18:17 -0700 (PDT)
I am trying to use CGAL to compute the Power Diagram. My code is as follows.
It can correctly compute the Regular Triangulation (with 4 vertices and 1
hidden vertex). However, the computed Power Diagram is incorrect, which has
5 faces instead of 4. And more, its dual has 5 vertices and 0 hidden vertex.
Can anyone point out where the problems is? Thanks a lot!
====================================================
#include <iostream>
#include <CGAL/basic.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Regular_triangulation_filtered_traits_2.h>
#include <CGAL/Regular_triangulation_2.h>
#include <CGAL/Regular_triangulation_adaptation_traits_2.h>
#include <CGAL/Regular_triangulation_adaptation_policies_2.h>
#include <CGAL/Voronoi_diagram_2.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel
K;
typedef CGAL::Regular_triangulation_filtered_traits_2<K>
RT_Traits;
typedef CGAL::Regular_triangulation_2<RT_Traits>
RT;
typedef CGAL::Regular_triangulation_adaptation_traits_2<RT>
AT;
typedef CGAL::Regular_triangulation_caching_degeneracy_removal_policy_2<RT>
AP;
typedef CGAL::Voronoi_diagram_2<RT,AT,AP>
PD;
typedef CGAL::Point_2<K> Point_2;
typedef RT::Weighted_point RT_Weighted_point;
RT rt;
PD pd;
int num_sites=5;
double sites[5][2];
void main(void)
{
sites[0][0] = 0.0;
sites[0][1] = 0.0;
sites[1][0] = 0.8;
sites[1][1] = 0.0;
sites[2][0] = 0.0;
sites[2][1] = 1.0;
sites[3][0] = -0.8;
sites[3][1] = 0.0;
sites[4][0] = 0.0;
sites[4][1] = -1.0;
for (int i=0; i<num_sites; i++)
{
double x, y, weight;
x = sites[i][0];
y = sites[i][1];
if (i==0)
weight = 0;
else
weight = 1.44;
pd.insert(RT_Weighted_point(Point_2(x, y), weight));
rt.insert(RT_Weighted_point(Point_2(x, y), weight));
}
std::cout << "number of vertices in RT: " << rt.number_of_vertices()
<<
std::endl;
std::cout << "number of hidden vertices in RT: " <<
rt.number_of_hidden_vertices() << std::endl << std::endl;
std::cout << "num of faces in PD: " << pd.number_of_faces() <<
std::endl <<
std::endl;
RT dual = pd.dual();
std::cout << "number of vertices in Dual: " <<
dual.number_of_vertices()
<< std::endl;
std::cout << "number of hidden vertices in Dual: " <<
dual.number_of_hidden_vertices() << std::endl;
}
--
View this message in context:
http://www.nabble.com/Strange-question-on-computing-Power-Diagram-tp23989082p23989082.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
- [cgal-discuss] Strange question on computing Power Diagram, Guodong Rong, 06/11/2009
- Re: [cgal-discuss] Strange question on computing Power Diagram, Ophir Setter, 06/13/2009
- Re: [cgal-discuss] Strange question on computing Power Diagram, redpearl, 06/14/2009
- <Possible follow-up(s)>
- [cgal-discuss] Strange question on computing Power Diagram, redpearl, 06/14/2009
- Re: [cgal-discuss] Strange question on computing Power Diagram, Ophir Setter, 06/13/2009
Archive powered by MHonArc 2.6.16.