Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Strange question on computing Power Diagram

Subject: CGAL users discussion list

List archive

[cgal-discuss] Strange question on computing Power Diagram


Chronological Thread 
  • From: Guodong Rong <>
  • To: <>
  • Subject: [cgal-discuss] Strange question on computing Power Diagram
  • Date: Thu, 11 Jun 2009 16:18:34 -0500
  • Importance: Normal

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;
}



Windows Live™ SkyDrive™: Get 25 GB of free online storage. Get it on your BlackBerry or iPhone.



Archive powered by MHonArc 2.6.16.

Top of Page