Skip to Content.
Sympa Menu

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

Subject: CGAL users discussion list

List archive

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


Chronological Thread 
  • From: Ophir Setter <>
  • To:
  • Subject: Re: [cgal-discuss] Strange question on computing Power Diagram
  • Date: Sat, 13 Jun 2009 18:07:41 +0300
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type; b=BsKqsmoRZmkPnlfEb0zhqF+TSKwsl7eMkHr5UJpJoKAKIOm8UbdV7jPtDNzhYXCVkn NuUhdjTcMYebGSLtNBk50gsbmxb0hmZButzbjERliBsRcFUlwlknlNwGoIWhsToMbrdZ 35LweVNgtmion9HW9bejjjV2fOf+Af0i74bOA=

The problem is probably that you use double representation of coordinate (like 1.0) which do not necessarily translate to a rational number (1/1) exactly.

Ophir

On Fri, Jun 12, 2009 at 12:18 AM, Guodong Rong <> wrote:

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