diff --git a/Apollonius_graph_2/TODO b/Apollonius_graph_2/TODO new file mode 100644 index 00000000000..c252c825d8f --- /dev/null +++ b/Apollonius_graph_2/TODO @@ -0,0 +1,2 @@ +- rename file names if needed to match the names of the classes + they contain diff --git a/Apollonius_graph_2/archive/generators/README.txt b/Apollonius_graph_2/archive/generators/README.txt new file mode 100644 index 00000000000..2c382e1dce1 --- /dev/null +++ b/Apollonius_graph_2/archive/generators/README.txt @@ -0,0 +1,70 @@ +Below you can find a description of the various generators in the +include/CGAL directory: + +make_degenerate.h +================= +PROVIDES: make_degenerate (function) +INPUT: A input range of sites, an output iterator, and a traits class. +OUTPUT: Computes the Apollonius graph of the input range, then writes + the Voronoi circles of the Apollonius diagram of the input + sites to the output iterator. The output is a set of sites for + the Apollonius diagram. +EXAMPLE: mk_degen.cpp +USAGE: Can be used to generate a set of sites in almost degenerate or + degenerate configuration using the input set of sites. + +random_sites_in_0x1_box.h +========================= +PROVIDES: Random_sites_in_0x1_box (functor) +INPUT: at construction time the max radius and a seed need to be passed. +OUTPUT: using operator*(), the user can get one random site with its + center in the box [0,1]x[0,1] and its radius between 0 and the + max radius passed at construction time; the random number + generator used is CGAL::Random. +EXAMPLE: gen_sites_in_0x1_box.cpp +USAGE: Can be used to generate random sites within the [0,1]x[0,1] box + with a prespecified max radius and seed for the random number + generator. There is no guarantee as to whether the site + returned is hidden or not by previously generated sites. + +random_integral_sites_in_square_2.h +=================================== +PROVIDES: Random_integral_sites_in_square_2 (functor) +INPUT: at construction two unsigned integers b and B and a seed need + to be passed. +OUTPUT: using operator*(), the user can get one random site with its + center in [-M,M]x[-M,M], where M = 2^b-1, and its weight in + [0,R], where R = 2^B-1; the random number generator used is + CGAL::Random. Zero bit size means that the corresponding + number is zero. +EXAMPLE: gen_integral_sites_in_square.cpp +USAGE: Can be used to generate sites with integer coordinates and + weight; the bit size of the coordinates and the weight can be + prescribed; allowed values of bit sizes are between 0 and 52, + inclusive. There is no guarantee as to whether the site + returned is hidden or not by previously generated sites. + +random_integral_sites_on_parabola_2.h +===================================== +PROVIDES: Random_integral_sites_on_parabola_2 (functor) +INPUT: at construction an unsigned integer b, an unsigned integer p + and a seed need to be passed. By default p is set to 0. +OUTPUT: using operator*(), the user can get one random site of the + form {(t, t^2), w}, where t is in [-M, M], M = 2^b-1; the + weight w is equal to t^2 unless p is not equal to zero, + in which case w is equal t^2 + e, where e is an integer of bit + size at most p; the random number generator used is + CGAL::Random. Zero bit size means that the corresponding + number is zero. +EXAMPLE: gen_integral_sites_on_parabola.cpp +USAGE: Can be used to generate sites with integer coordinates and + weight with prescribed bit size; allowed values of bit sizes + are between 0 and 26, inclusive. There is no guarantee as to + whether the site returned is hidden or not by previously + generated sites. If p is equal to 0, the Apollonius diagram + created has a vertex of degree n-2, where n is the number of + sites created; all sites are tangent to the x-axis and all lie + above it. If p is non-zero, but small with respect to b, then + the centers of the sites still lie on the parabola y = x^2, but + the weights are perturbed by just a fe bits, thus providing a + set of input sites that are in almost degenerate configuration. diff --git a/Apollonius_graph_2/archive/generators/gen_integral_sites_in_square.cpp b/Apollonius_graph_2/archive/generators/gen_integral_sites_in_square.cpp new file mode 100644 index 00000000000..d1bc078f1e9 --- /dev/null +++ b/Apollonius_graph_2/archive/generators/gen_integral_sites_in_square.cpp @@ -0,0 +1,62 @@ +#include +#include +#include + +#include +#include +#include + +#include +#include + +typedef CGAL::Simple_cartesian K; +typedef CGAL::Apollonius_site_2 Site_2; +typedef CGAL::Random Random; + +int usage (int argc, char *argv[]) +{ + std::cerr << "usage: " << argv[0] + << " " + << "[bit size of weights] [seed]" << std::endl; + return 2; +} + +int main(int argc, char *argv[]) +{ + int num, seed = 17; + unsigned int b, B; + + if ( argc < 3 ) { + return usage(argc, argv); + } + + { + std::istringstream is(argv[1]); + if ( !(is >> num) ) { return usage(argc, argv); } + } + + { + std::istringstream is(argv[2]); + if ( !(is >> b) ) { return usage(argc, argv); } + B = b; + } + + if ( argc > 3 ) { + std::istringstream is(argv[3]); + if ( !(is >> B) ) { return usage(argc, argv); } + } + + if ( argc > 4 ) { + std::istringstream is(argv[4]); + if ( !(is >> seed) ) { return usage(argc, argv); } + } + + CGAL::Random_integral_sites_in_square_2 g(b, B, seed); + + std::cout << std::setprecision(17); + for (int i = 0; i < num; ++i) { + std::cout << *g << std::endl; + } + + return 0; +} diff --git a/Apollonius_graph_2/archive/generators/gen_integral_sites_on_parabola.cpp b/Apollonius_graph_2/archive/generators/gen_integral_sites_on_parabola.cpp new file mode 100644 index 00000000000..e79e6182507 --- /dev/null +++ b/Apollonius_graph_2/archive/generators/gen_integral_sites_on_parabola.cpp @@ -0,0 +1,61 @@ +#include +#include +#include + +#include +#include +#include + +#include +#include + +typedef CGAL::Simple_cartesian K; +typedef CGAL::Apollonius_site_2 Site_2; +typedef CGAL::Random Random; + +int usage (int argc, char *argv[]) +{ + std::cerr << "usage: " << argv[0] + << " " + << "[bit size of perturbation] [seed]" << std::endl; + return 2; +} + +int main(int argc, char *argv[]) +{ + int num, seed = 17; + unsigned int b, p = 0; + + if ( argc < 3 ) { + return usage(argc, argv); + } + + { + std::istringstream is(argv[1]); + if ( !(is >> num) ) { return usage(argc, argv); } + } + + { + std::istringstream is(argv[2]); + if ( !(is >> b) ) { return usage(argc, argv); } + } + + if ( argc > 3 ) { + std::istringstream is(argv[3]); + if ( !(is >> p) ) { return usage(argc, argv); } + } + + if ( argc > 4 ) { + std::istringstream is(argv[4]); + if ( !(is >> seed) ) { return usage(argc, argv); } + } + + CGAL::Random_integral_sites_on_parabola_2 g(b, p, seed); + + std::cout << std::setprecision(17); + for (int i = 0; i < num; ++i) { + std::cout << *g << std::endl; + } + + return 0; +} diff --git a/Apollonius_graph_2/archive/generators/gen_sites_in_0x1_box.cpp b/Apollonius_graph_2/archive/generators/gen_sites_in_0x1_box.cpp new file mode 100644 index 00000000000..72216777c56 --- /dev/null +++ b/Apollonius_graph_2/archive/generators/gen_sites_in_0x1_box.cpp @@ -0,0 +1,52 @@ +#include +#include + +#include +#include +#include + +#include +#include + +typedef CGAL::Simple_cartesian K; +typedef CGAL::Apollonius_site_2 Site_2; + +int usage (int argc, char **argv) +{ + std::cerr << "usage: " << argv[0] + << " [seed]" << std::endl; + return 2; +} + + +int main (int argc, char **argv) +{ + int num, seed = 42; + double rmax; + + if (argc < 3) + return usage (argc, argv); + + { + std::istringstream is(argv[1]); + if ( !(is >> num) ) { return usage(argc, argv); } + } + { + std::istringstream is(argv[2]); + if ( !(is >> rmax) ) { return usage(argc, argv); } + } + if (argc > 3) { + std::istringstream is(argv[3]); + if ( !(is >> seed) ) { return usage(argc, argv); } + } + + CGAL::Random_sites_in_0x1_box g(rmax, seed); + + std::cout << std::setprecision(17); + + for (int i = 0; i < num; ++i) { + std::cout << *g << std::endl; + } + + return 0; +} diff --git a/Apollonius_graph_2/archive/generators/include/CGAL/Apollonius_graph_2/make_degenerate.h b/Apollonius_graph_2/archive/generators/include/CGAL/Apollonius_graph_2/make_degenerate.h new file mode 100644 index 00000000000..54e2198b1fa --- /dev/null +++ b/Apollonius_graph_2/archive/generators/include/CGAL/Apollonius_graph_2/make_degenerate.h @@ -0,0 +1,39 @@ +#ifndef CGAL_APOLLONIUS_GRAPH_2_MAKE_DEGENERATE_H +#define CGAL_APOLLONIUS_GRAPH_2_MAKE_DEGENERATE_H 1 + +#include +#include + +namespace CGAL { + +template +OutputIterator +make_degenerate(InputIterator first, + InputIterator beyond, + OutputIterator oit, + const Traits& tr = Traits()) +{ + typedef CGAL::Apollonius_graph_hierarchy_2 Apollonius_graph; + + typedef typename Apollonius_graph::Site_2 Site_2; + + typedef typename Apollonius_graph::Finite_faces_iterator + Finite_faces_iterator; + + Apollonius_graph ag; + Site_2 site; + + for (InputIterator it = first; it != beyond; ++it) { + ag.insert(*it); + } + + for (Finite_faces_iterator f = ag.finite_faces_begin(); + f != ag.finite_faces_end(); ++f) { + *oit++ = ag.dual(f); + } + return oit; +} + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_MAKE_DEGENERATE_H diff --git a/Apollonius_graph_2/archive/generators/include/CGAL/Apollonius_graph_2/random_integral_sites_in_square_2.h b/Apollonius_graph_2/archive/generators/include/CGAL/Apollonius_graph_2/random_integral_sites_in_square_2.h new file mode 100644 index 00000000000..a434fd09175 --- /dev/null +++ b/Apollonius_graph_2/archive/generators/include/CGAL/Apollonius_graph_2/random_integral_sites_in_square_2.h @@ -0,0 +1,54 @@ +#ifndef CGAL_APOLLONIUS_GRAPH_2_RANDOM_INTEGRAL_SITES_IN_SQUARE_2_H +#define CGAL_APOLLONIUS_GRAPH_2_RANDOM_INTEGRAL_SITES_IN_SQUARE_2_H 1 + +#include +#include + +namespace CGAL { + +// creates a random site with x, y in [-M,M]x[-M,M] +// where M = 2^b - 1 and r in [0,R], R = 2^B - 1 + +template +class Random_integral_sites_in_square_2 +{ +public: + typedef Site Site_2; + typedef R Random; + +public: + Random_integral_sites_in_square_2(unsigned int b) + : b_(b), B_(b), r_(0) { + CGAL_precondition( b >= 0 && b <= 52 ); + } + + Random_integral_sites_in_square_2(unsigned int b, int seed) + : b_(b), B_(b), r_(seed) { + CGAL_precondition( b >= 0 && b <= 52 ); + } + + Random_integral_sites_in_square_2(unsigned int b, unsigned int B, int seed) + : b_(b), B_(B), r_(seed) { + CGAL_precondition( b >= 0 && b <= 52 ); + CGAL_precondition( B >= 0 && B <= 52 ); + } + + Site_2 operator*() + { + double x = random_integer(r_, b_, true); + double y = random_integer(r_, b_, true); + double w = random_integer(r_, B_, false); + CGAL_assertion( w >= 0 ); + + typename Site_2::Point_2 p(x, y); + return Site_2(p, w); + } + +private: + unsigned int b_, B_; + Random r_; +}; + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_RANDOM_INTEGRAL_SITES_IN_SQUARE_2_H diff --git a/Apollonius_graph_2/archive/generators/include/CGAL/Apollonius_graph_2/random_integral_sites_on_parabola_2.h b/Apollonius_graph_2/archive/generators/include/CGAL/Apollonius_graph_2/random_integral_sites_on_parabola_2.h new file mode 100644 index 00000000000..357d33f01f1 --- /dev/null +++ b/Apollonius_graph_2/archive/generators/include/CGAL/Apollonius_graph_2/random_integral_sites_on_parabola_2.h @@ -0,0 +1,54 @@ +#ifndef CGAL_APOLLONIUS_GRAPH_2_RANDOM_INTEGRAL_SITES_ON_PARABOLA_2_H +#define CGAL_APOLLONIUS_GRAPH_2_RANDOM_INTEGRAL_SITES_ON_PARABOLA_2_H 1 + +#include +#include + +namespace CGAL { + +// creates a random site of the form {(t, t^2), t^2}, where t is in +// the range [-M, M], M = 2^b - 1 + +template +class Random_integral_sites_on_parabola_2 +{ +public: + typedef Site Site_2; + typedef R Random; + +public: + Random_integral_sites_on_parabola_2(unsigned int b) + : b_(b), p_(0), r_(0) { + CGAL_precondition( b >= 0 && b <= 26 ); + } + + Random_integral_sites_on_parabola_2(unsigned int b, int seed) + : b_(b), p_(0), r_(seed) { + CGAL_precondition( b >= 0 && b <= 26 ); + } + + Random_integral_sites_on_parabola_2(unsigned int b, unsigned int p, + int seed) + : b_(b), p_(p), r_(seed) { + CGAL_precondition( b >= 0 && b <= 26 ); + CGAL_precondition( p >= 0 && p <= 26 ); + } + + Site_2 operator*() + { + double t = random_integer(r_, b_, true); + double t2 = t * t; + double perb = random_integer(r_, p_, true); + + typename Site_2::Point_2 p(t, t2); + return Site_2(p, t2 + perb); + } + +private: + unsigned int b_, p_; + Random r_; +}; + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_RANDOM_INTEGRAL_SITES_ON_PARABOLA_2_H diff --git a/Apollonius_graph_2/archive/generators/include/CGAL/Apollonius_graph_2/random_sites_in_0x1_box.h b/Apollonius_graph_2/archive/generators/include/CGAL/Apollonius_graph_2/random_sites_in_0x1_box.h new file mode 100644 index 00000000000..6941db05a0c --- /dev/null +++ b/Apollonius_graph_2/archive/generators/include/CGAL/Apollonius_graph_2/random_sites_in_0x1_box.h @@ -0,0 +1,37 @@ +#ifndef CGAL_APOLLONIUS_GRAPH_2_RANDOM_SITES_IN_0X1_BOX_H +#define CGAL_APOLLONIUS_GRAPH_2_RANDOM_SITES_IN_0X1_BOX_H 1 + +#include +#include + +namespace CGAL { + +template +class Random_sites_in_0x1_box +{ +public: + typedef Site Site_2; + typedef Site_2 result_type; + +private: + typedef typename Site_2::Point_2 Point_2; + +public: + Random_sites_in_0x1_box(double rmax = 0.125, int seed = 0) + : rmax_(rmax), random_(seed) {} + + Site_2 operator*() { + double x = random_.get_double(0, 1); + double y = random_.get_double(0, 1); + double w = random_.get_double(0, rmax_); + return Site_2(Point_2(x,y),w); + } + +private: + double rmax_; + Random random_; +}; + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_RANDOM_SITES_IN_0X1_BOX_H diff --git a/Apollonius_graph_2/archive/generators/include/CGAL/bits.h b/Apollonius_graph_2/archive/generators/include/CGAL/bits.h new file mode 100644 index 00000000000..9d9a9cf1e9a --- /dev/null +++ b/Apollonius_graph_2/archive/generators/include/CGAL/bits.h @@ -0,0 +1,23 @@ +#ifndef CGAL_BITS_H +#define CGAL_BITS_H + +#include +#include + +namespace CGAL { + +double log2(double x) +{ + return log10(x) / log10(2.0); +} + +unsigned int bits(double x) +{ + CGAL_precondition( static_cast(x) == x ); + if ( x == 0 ) { return 1; } + return static_cast(log2( CGAL::abs(x) )) + 1; +} + +} //namespace CGAL + +#endif // CGAL_BITS_H diff --git a/Apollonius_graph_2/archive/generators/include/CGAL/random_integer.h b/Apollonius_graph_2/archive/generators/include/CGAL/random_integer.h new file mode 100644 index 00000000000..f7c29dee82f --- /dev/null +++ b/Apollonius_graph_2/archive/generators/include/CGAL/random_integer.h @@ -0,0 +1,110 @@ +#ifndef CGAL_RANDOM_INTEGER_H +#define CGAL_RANDOM_INTEGER_H + +#include +#include +#include + +// type "man {rand, random, drand48}" for C functions that produce +// random numbers + +//extern "C" int getpid(); +//extern "C" int srandom(unsigned); +//extern "C" long random(); + +namespace CGAL { + +// powers of 2 from 2^0 to 2^53 +double +P2[54]={1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0, + 512.0, 1024.0, 2048.0, 4096.0, 8192.0, 16384.0, 32768.0, + 65536.0, 131072.0, 262144.0, 524288.0, 1048576.0, + 2097152.0, 4194304.0, 8388608.0, 16777216.0, 33554432.0, + 67108864.0, 134217728.0, 268435456.0, 536870912.0, + 1073741824.0, 2147483648.0, 4294967296.0, 8589934592.0, + 17179869184.0, 34359738368.0, 68719476736.0, + 137438953472.0, 274877906944.0, 549755813888.0, + 1099511627776.0, 2199023255552.0, 4398046511104.0, + 8796093022208.0, 17592186044416.0, 35184372088832.0, + 70368744177664.0, 140737488355328.0, 281474976710656.0, + 562949953421312.0, 1125899906842624.0, 2251799813685248.0, + 4503599627370496.0, 9007199254740992.0}; + +// set the random number generator seed +void set_seed(unsigned int seed) +{ + srandom(seed); +} + +// return random integer of b bits +double random_integer(int b, bool allow_negative = true) +{ + double value; + + if (b > 27) { + value = ((int)random()) % ((int)P2[27]); + value += ( ((int)random()) % ((int)P2[b - 27]) ) * P2[27]; + } else { + value = ((int)random()) % (int)P2[b]; + } + if ( allow_negative ) { + value *= ( ((int) random()) % 2 == 0 ) ? 1 : -1; + } + return value; +} + +template +double random_integer(Random& r, unsigned int b, bool allow_negative = true) +{ + // returns random integers in the range [0, 2^b - 1). + // b is required to be at least 1 and at most 52 + // and if allow_negative is true then the range includes negative + // numbers as well and becomes: [-2^b + 1, 2^b - 1). + CGAL_precondition( b >= 0 && b <= 52 ); + + if ( b == 0 ) { return 0; } + + double M = pow(2.0,b); + CGAL::Gmpz z; + + if ( allow_negative ) { + z = r.get_double(-M, M); + } else { + z = r.get_double(0, M); + } + return CGAL::to_double(z); +} + + +template +double random_even_integer(Random& r, unsigned int b, + bool allow_negative = true) +{ + // returns random even integers in the range [0, 2^b - 1). + // b is required to be at least 1 and at most 52 + // and if allow_negative is true then the range includes negative + // numbers as well and becomes: [-2^b + 1, 2^b - 1). + CGAL_precondition( b >= 0 && b <= 52 ); + + if ( b == 0 ) { return 0; } + + double M = pow(2.0,b); + CGAL::Gmpz z; + CGAL::Gmpz two(2); + + do { + if ( allow_negative ) { + z = r.get_double(-M, M); + } else { + z = r.get_double(0, M); + } + } while ( z % two != 0 ); + + return CGAL::to_double(z); +} + + +} //namespace CGAL + + +#endif // CGAL_RANDOM_INTEGER_H diff --git a/Apollonius_graph_2/archive/generators/mk_degen.cpp b/Apollonius_graph_2/archive/generators/mk_degen.cpp new file mode 100644 index 00000000000..368f2f2594b --- /dev/null +++ b/Apollonius_graph_2/archive/generators/mk_degen.cpp @@ -0,0 +1,44 @@ +#include +#include + +#include +#include +#include + +#include +#include + +#include + +typedef CGAL::Simple_cartesian CK; +typedef CGAL::Simple_cartesian EK; + +typedef CGAL::Field_with_sqrt_tag CM; +typedef CGAL::Integral_domain_without_division_tag EM; +typedef CGAL::Apollonius_graph_filtered_traits_2 Traits; + +typedef Traits::Site_2 Site; +typedef std::vector Site_vector; + +int main() +{ + Site_vector input, output; + Site site; + + std::back_insert_iterator oit(output); + + while (std::cin >> site) { input.push_back(site); } + + oit = CGAL::make_degenerate(input.begin(), input.end(), oit, Traits()); + + std::cout << std::setprecision(17); + for (std::vector::iterator it = output.begin(); + it != output.end(); ++it) + { + std::cout << (*it) << std::endl; + } + + return 0; +} + + diff --git a/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Apollonius_graph_mixed_filtered_traits_2.h b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Apollonius_graph_mixed_filtered_traits_2.h new file mode 100644 index 00000000000..c221d5fdd52 --- /dev/null +++ b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Apollonius_graph_mixed_filtered_traits_2.h @@ -0,0 +1,407 @@ +// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_MIXED_FILTERED_TRAITS_2_H +#define CGAL_APOLLONIUS_GRAPH_MIXED_FILTERED_TRAITS_2_H + + +#include + +#include +#include + +// includes for the default parameters of the filtered traits +#include +#include +#include +#include +#include + + +namespace CGAL { + + +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// the filtered Traits class +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- + +template, + class EK_MTag = CK_MTag, + class FK_t = Simple_cartesian< Interval_nt >, + class FK_MTag = CK_MTag, + class C2E_t = Cartesian_converter, + class C2F_t = + Cartesian_converter > > +class Apollonius_graph_mixed_filtered_traits_2 +{ +private: + typedef Apollonius_graph_mixed_traits_2 CK_traits; + typedef Apollonius_graph_mixed_traits_2 FK_traits; + typedef Apollonius_graph_mixed_traits_2 EK_traits; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Apollonius_graph_kernel_wrapper_2 CK; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Apollonius_graph_kernel_wrapper_2 FK; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Apollonius_graph_kernel_wrapper_2 EK; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS:: + Apollonius_graph_cartesian_converter C2E; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS:: + Apollonius_graph_cartesian_converter C2F; + +#if 0 + // the following typedefs have been made in the direction of + // providing filtered constructions; however, there is a problem, + // namely, the Construct_Apollonius_site_2 functor has two + // different operator()'s with two different return types; this + // functor should be split in two (along with the appropriate + // changes in the spec/concept); see also changes needed for the + // filtered construction below. + typedef Cartesian_converter > F2C_t; + typedef Cartesian_converter > E2C_t; + + typedef + Apollonius_graph_cartesian_converter F2C; + typedef + Apollonius_graph_cartesian_converter E2C; +#endif + + // Types for the construction kernel + typedef typename CK::Point_2 CK_Point_2; + typedef typename CK::Site_2 CK_Site_2; + + typedef typename CK::Line_2 CK_Line_2; + typedef typename CK::Ray_2 CK_Ray_2; + typedef typename CK::Segment_2 CK_Segment_2; + + typedef typename CK::FT CK_FT; + typedef typename CK::RT CK_RT; + + // Types for the exact kernel + typedef typename EK::Point_2 EK_Point_2; + typedef typename EK::Site_2 EK_Site_2; + + typedef typename EK::Line_2 EK_Line_2; + typedef typename EK::Ray_2 EK_Ray_2; + typedef typename EK::Segment_2 EK_Segment_2; + + typedef typename EK::FT EK_FT; + typedef typename EK::RT EK_RT; + + // Types for the filtering kernel + typedef typename FK::Point_2 FK_Point_2; + typedef typename FK::Site_2 FK_Site_2; + + typedef typename FK::Line_2 FK_Line_2; + typedef typename FK::Ray_2 FK_Ray_2; + typedef typename FK::Segment_2 FK_Segment_2; + + typedef typename FK::FT FK_FT; + typedef typename FK::RT FK_RT; + +public: + //----------------------------------------------------------------------- + // TYPE DEFINITIONS + //----------------------------------------------------------------------- + + // BASIC TYPES + //------------ + typedef CK_t R; + typedef CK_MTag Method_tag; + + typedef CK_traits Construction_traits; + typedef FK_traits Filtering_traits; + typedef EK_traits Exact_traits; + + typedef CK_MTag Construction_traits_method_tag; + typedef FK_MTag Filtering_traits_method_tag; + typedef EK_MTag Exact_traits_method_tag; + + typedef typename CK::Point_2 Point_2; + typedef typename CK::Site_2 Site_2; + + typedef typename CK::Line_2 Line_2; + typedef typename CK::Ray_2 Ray_2; + typedef typename CK::Segment_2 Segment_2; + + typedef typename CK::Object_2 Object_2; + typedef typename CK::FT FT; + typedef typename CK::RT RT; + + +public: + // OBJECT CONSTRUCTION & ASSIGNMENT + //--------------------------------- + typedef typename CK_traits::Construct_object_2 Construct_object_2; + typedef typename CK_traits::Assign_2 Assign_2; + + // CONSTRUCTIONS + //-------------- + // vertex and dual site +protected: + typedef typename CK_traits::Construct_Apollonius_vertex_2 + CK_Construct_Apollonius_vertex_2; + + typedef typename CK_traits::Construct_Apollonius_site_2 + CK_Construct_Apollonius_site_2; + + typedef typename FK_traits::Construct_Apollonius_vertex_2 + FK_Construct_Apollonius_vertex_2; + + typedef typename FK_traits::Construct_Apollonius_site_2 + FK_Construct_Apollonius_site_2; + + typedef typename EK_traits::Construct_Apollonius_vertex_2 + EK_Construct_Apollonius_vertex_2; + + typedef typename EK_traits::Construct_Apollonius_site_2 + EK_Construct_Apollonius_site_2; + +public: +#if 0 + // the following typedefs have been made in the direction of + // providing filtered constructions; however, there is a problem, + // namely, the Construct_Apollonius_site_2 functor has two + // different operator()'s with two different return types; this + // functor should be split in two (along with the appropriate + // changes in the spec/concept); see also changes needed for the + // filtered construction above. + typedef Filtered_construction + Construct_Apollonius_vertex_2; + + typedef Filtered_construction + Construct_Apollonius_site_2; +#else + typedef typename CK_traits::Construct_Apollonius_vertex_2 + Construct_Apollonius_vertex_2; + + typedef typename CK_traits::Construct_Apollonius_site_2 + Construct_Apollonius_site_2; +#endif + +private: + // PREDICATES FOR THE TWO KERNELS + //------------------------------- + + // Predicates for the filtering kernel + typedef typename FK_traits::Compare_x_2 FK_Compare_x_2; + typedef typename FK_traits::Compare_y_2 FK_Compare_y_2; + typedef typename FK_traits::Compare_weight_2 FK_Compare_weight_2; + typedef typename FK_traits::Orientation_2 FK_Orientation_2; + typedef typename FK_traits::Orientation_new_2 FK_Orientation_new_2; + typedef typename FK_traits::Is_hidden_2 FK_Is_hidden_2; + typedef typename FK_traits::Vertex_conflict_2 FK_Vertex_conflict_2; + + typedef typename FK_traits::Oriented_side_of_bisector_2 + FK_Oriented_side_of_bisector_2; + + typedef typename FK_traits::Finite_edge_interior_conflict_2 + FK_Finite_edge_interior_conflict_2; + + typedef typename FK_traits::Infinite_edge_interior_conflict_2 + FK_Infinite_edge_interior_conflict_2; + + typedef typename FK_traits::Is_degenerate_edge_2 + FK_Is_degenerate_edge_2; + + + // Predicates for the exact kernel + typedef typename EK_traits::Compare_x_2 EK_Compare_x_2; + typedef typename EK_traits::Compare_y_2 EK_Compare_y_2; + typedef typename EK_traits::Compare_weight_2 EK_Compare_weight_2; + typedef typename EK_traits::Orientation_2 EK_Orientation_2; + typedef typename EK_traits::Orientation_new_2 EK_Orientation_new_2; + typedef typename EK_traits::Is_hidden_2 EK_Is_hidden_2; + typedef typename EK_traits::Vertex_conflict_2 EK_Vertex_conflict_2; + + typedef typename EK_traits::Oriented_side_of_bisector_2 + EK_Oriented_side_of_bisector_2; + + typedef typename EK_traits::Finite_edge_interior_conflict_2 + EK_Finite_edge_interior_conflict_2; + + typedef typename EK_traits::Infinite_edge_interior_conflict_2 + EK_Infinite_edge_interior_conflict_2; + + typedef typename EK_traits::Is_degenerate_edge_2 + EK_Is_degenerate_edge_2; + +public: + // PREDICATES + //----------- + + typedef + Filtered_predicate + Compare_x_2; + + typedef + Filtered_predicate + Compare_y_2; + + typedef + Filtered_predicate + Compare_weight_2; + + typedef + Filtered_predicate + Orientation_2; + + typedef + Filtered_predicate + Orientation_new_2; + + typedef + Filtered_predicate + Is_hidden_2; + + typedef + Filtered_predicate + Oriented_side_of_bisector_2; + + typedef + Filtered_predicate + Vertex_conflict_2; + + typedef + Filtered_predicate + Finite_edge_interior_conflict_2; + + typedef + Filtered_predicate + Infinite_edge_interior_conflict_2; + + typedef + Filtered_predicate + Is_degenerate_edge_2; + +public: + //----------------------------------------------------------------------- + // ACCESS TO OBJECTS + //----------------------------------------------------------------------- + + // OBJECT CONSTRUCTION & ASSIGNMENT + Assign_2 + assign_2_object() const { + return Assign_2(); + } + + Construct_object_2 + construct_object_2_object() const { + return Construct_object_2(); + } + + + // CONSTRUCTIONS + //-------------- + Construct_Apollonius_vertex_2 + construct_Apollonius_vertex_2_object() const { + return Construct_Apollonius_vertex_2(); + } + + Construct_Apollonius_site_2 + construct_Apollonius_site_2_object() const { + return Construct_Apollonius_site_2(); + } + + // PREDICATES + //----------- + Compare_x_2 + compare_x_2_object() const { + return Compare_x_2(); + } + + Compare_y_2 + compare_y_2_object() const { + return Compare_y_2(); + } + + Compare_weight_2 + compare_weight_2_object() const { + return Compare_weight_2(); + } + + Orientation_2 + orientation_2_object() const { + return Orientation_2(); + } + + Orientation_new_2 + orientation_new_2_object() const { + return Orientation_new_2(); + } + + Is_hidden_2 + is_hidden_2_object() const { + return Is_hidden_2(); + } + + Oriented_side_of_bisector_2 + oriented_side_of_bisector_2_object() const { + return Oriented_side_of_bisector_2(); + } + + Vertex_conflict_2 + vertex_conflict_2_object() const { + return Vertex_conflict_2(); + } + + Finite_edge_interior_conflict_2 + finite_edge_interior_conflict_2_object() const { + return Finite_edge_interior_conflict_2(); + } + + Infinite_edge_interior_conflict_2 + infinite_edge_interior_conflict_2_object() const { + return Infinite_edge_interior_conflict_2(); + } + + Is_degenerate_edge_2 + is_degenerate_edge_2_object() const { + return Is_degenerate_edge_2(); + } + +}; + + + +} //namespace CGAL + + +#endif // CGAL_APOLLONIUS_GRAPH_UNCERTAIN_FILTERED_TRAITS_2_H diff --git a/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Apollonius_graph_mixed_traits_2.h b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Apollonius_graph_mixed_traits_2.h new file mode 100644 index 00000000000..08f0ce66720 --- /dev/null +++ b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Apollonius_graph_mixed_traits_2.h @@ -0,0 +1,206 @@ +// Copyright (c) 2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas +// Christophe Delage +// David Millman + +#ifndef CGAL_APOLLONIUS_GRAPH_MIXED_TRAITS_2_H +#define CGAL_APOLLONIUS_GRAPH_MIXED_TRAITS_2_H + +#include +#include +#include + +namespace CGAL { + +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// the Traits class +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +template < class Rep, class MTag = Integral_domain_without_division_tag > +class Apollonius_graph_mixed_traits_2 +{ +public: + //----------------------------------------------------------------------- + // TYPE DEFINITIONS + //----------------------------------------------------------------------- + + // BASIC TYPES + //------------ +private: + typedef Apollonius_graph_new_traits_2 Self; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Apollonius_graph_kernel_wrapper_2 Kernel; + +public: + typedef Rep R; + typedef MTag Method_tag; + typedef typename Kernel::Point_2 Point_2; + typedef typename Kernel::Site_2 Site_2; + + typedef typename Kernel::Line_2 Line_2; + typedef typename Kernel::Ray_2 Ray_2; + typedef typename Rep::Segment_2 Segment_2; + + typedef typename Kernel::Object_2 Object_2; + typedef typename Kernel::FT FT; + typedef typename Kernel::RT RT; + + +public: + // OBJECT CONSTRUCTION & ASSIGNMENT + //--------------------------------- + typedef typename Kernel::Construct_object_2 Construct_object_2; + typedef typename Kernel::Assign_2 Assign_2; + + // CONSTRUCTIONS + //-------------- + // vertex and dual site + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Construct_Apollonius_vertex_2 + /* */ Construct_Apollonius_vertex_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Construct_Apollonius_site_2 + /* */ Construct_Apollonius_site_2; + + + // PREDICATES + //----------- + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Compare_x_2 Compare_x_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Compare_y_2 Compare_y_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Compare_weight_2 + Compare_weight_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Orientation_2 + Orientation_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Orientation_new_2 + Orientation_new_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Is_hidden_2 Is_hidden_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Oriented_side_of_bisector_2 + /* */ Oriented_side_of_bisector_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Vertex_conflict_new_2 + Vertex_conflict_2; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Finite_edge_interior_conflict_2 + /* */ Finite_edge_interior_conflict_2; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Infinite_edge_interior_conflict_2 + /* */ Infinite_edge_interior_conflict_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Is_degenerate_edge_2 + /* */ Is_degenerate_edge_2; + + +public: + //----------------------------------------------------------------------- + // ACCESS TO OBJECTS + //----------------------------------------------------------------------- + + // OBJECT CONSTRUCTION & ASSIGNMENT + Assign_2 + assign_2_object() const { + return Assign_2(); + } + + Construct_object_2 + construct_object_2_object() const { + return Construct_object_2(); + } + + + // CONSTRUCTIONS + //-------------- + Construct_Apollonius_vertex_2 + construct_Apollonius_vertex_2_object() const { + return Construct_Apollonius_vertex_2(); + } + + Construct_Apollonius_site_2 + construct_Apollonius_site_2_object() const { + return Construct_Apollonius_site_2(); + } + + + // PREDICATES + //----------- + Compare_x_2 + compare_x_2_object() const { + return Compare_x_2(); + } + + Compare_y_2 + compare_y_2_object() const { + return Compare_y_2(); + } + + Compare_weight_2 + compare_weight_2_object() const { + return Compare_weight_2(); + } + + Orientation_2 + orientation_2_object() const { + return Orientation_2(); + } + + Orientation_new_2 + orientation_new_2_object() const { + return Orientation_new_2(); + } + + Is_hidden_2 + is_hidden_2_object() const { + return Is_hidden_2(); + } + + Oriented_side_of_bisector_2 + oriented_side_of_bisector_2_object() const { + return Oriented_side_of_bisector_2(); + } + + Vertex_conflict_2 + vertex_conflict_2_object() const { + return Vertex_conflict_2(); + } + + Finite_edge_interior_conflict_2 + finite_edge_interior_conflict_2_object() const { + return Finite_edge_interior_conflict_2(); + } + + Infinite_edge_interior_conflict_2 + infinite_edge_interior_conflict_2_object() const { + return Infinite_edge_interior_conflict_2(); + } + + Is_degenerate_edge_2 + is_degenerate_edge_2_object() const { + return Is_degenerate_edge_2(); + } + +}; + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_NEW_TRAITS_2_H diff --git a/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Apollonius_graph_new_filtered_traits_2.h b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Apollonius_graph_new_filtered_traits_2.h new file mode 100644 index 00000000000..b6fc3246cf3 --- /dev/null +++ b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Apollonius_graph_new_filtered_traits_2.h @@ -0,0 +1,410 @@ +// Copyright (c) 2003,2004,2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_NEW_FILTERED_TRAITS_2_H +#define CGAL_APOLLONIUS_GRAPH_NEW_FILTERED_TRAITS_2_H + + +#include + +#include +#include + +// includes for the default parameters of the filtered traits +#include +#include +#include +#include +#include + + +namespace CGAL { + + +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// the filtered Traits class +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- + +template, + class EK_MTag = CK_MTag, + class FK_t = Simple_cartesian< Interval_nt >, + class FK_MTag = CK_MTag, + class C2E_t = Cartesian_converter, + class C2F_t = + Cartesian_converter > > +class Apollonius_graph_new_filtered_traits_2 +{ +private: + typedef Apollonius_graph_new_traits_2 CK_traits; + typedef Apollonius_graph_new_traits_2 FK_traits; + typedef Apollonius_graph_new_traits_2 EK_traits; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Apollonius_graph_kernel_wrapper_2 CK; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Apollonius_graph_kernel_wrapper_2 FK; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Apollonius_graph_kernel_wrapper_2 EK; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS:: + Apollonius_graph_cartesian_converter C2E; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS:: + Apollonius_graph_cartesian_converter C2F; + +#if 0 + // the following typedefs have been made in the direction of + // providing filtered constructions; however, there is a problem, + // namely, the Construct_Apollonius_site_2 functor has two + // different operator()'s with two different return types; this + // functor should be split in two (along with the appropriate + // changes in the spec/concept); see also changes needed for the + // filtered construction below. + typedef Cartesian_converter > F2C_t; + typedef Cartesian_converter > E2C_t; + + typedef + Apollonius_graph_cartesian_converter F2C; + typedef + Apollonius_graph_cartesian_converter E2C; +#endif + + // Types for the construction kernel + typedef typename CK::Point_2 CK_Point_2; + typedef typename CK::Site_2 CK_Site_2; + + typedef typename CK::Line_2 CK_Line_2; + typedef typename CK::Ray_2 CK_Ray_2; + typedef typename CK::Segment_2 CK_Segment_2; + + typedef typename CK::FT CK_FT; + typedef typename CK::RT CK_RT; + + // Types for the exact kernel + typedef typename EK::Point_2 EK_Point_2; + typedef typename EK::Site_2 EK_Site_2; + + typedef typename EK::Line_2 EK_Line_2; + typedef typename EK::Ray_2 EK_Ray_2; + typedef typename EK::Segment_2 EK_Segment_2; + + typedef typename EK::FT EK_FT; + typedef typename EK::RT EK_RT; + + // Types for the filtering kernel + typedef typename FK::Point_2 FK_Point_2; + typedef typename FK::Site_2 FK_Site_2; + + typedef typename FK::Line_2 FK_Line_2; + typedef typename FK::Ray_2 FK_Ray_2; + typedef typename FK::Segment_2 FK_Segment_2; + + typedef typename FK::FT FK_FT; + typedef typename FK::RT FK_RT; + +public: + //----------------------------------------------------------------------- + // TYPE DEFINITIONS + //----------------------------------------------------------------------- + + // BASIC TYPES + //------------ + typedef CK_t R; + typedef CK_MTag Method_tag; + + typedef CK_traits Construction_traits; + typedef FK_traits Filtering_traits; + typedef EK_traits Exact_traits; + + typedef CK_MTag Construction_traits_method_tag; + typedef FK_MTag Filtering_traits_method_tag; + typedef EK_MTag Exact_traits_method_tag; + + typedef typename CK::Point_2 Point_2; + typedef typename CK::Site_2 Site_2; + + typedef typename CK::Line_2 Line_2; + typedef typename CK::Ray_2 Ray_2; + typedef typename CK::Segment_2 Segment_2; + + typedef typename CK::Object_2 Object_2; + typedef typename CK::FT FT; + typedef typename CK::RT RT; + + +public: + // OBJECT CONSTRUCTION & ASSIGNMENT + //--------------------------------- + typedef typename CK_traits::Construct_object_2 Construct_object_2; + typedef typename CK_traits::Assign_2 Assign_2; + + // CONSTRUCTIONS + //-------------- + // vertex and dual site +protected: + typedef typename CK_traits::Construct_Apollonius_vertex_2 + CK_Construct_Apollonius_vertex_2; + + typedef typename CK_traits::Construct_Apollonius_site_2 + CK_Construct_Apollonius_site_2; + + typedef typename FK_traits::Construct_Apollonius_vertex_2 + FK_Construct_Apollonius_vertex_2; + + typedef typename FK_traits::Construct_Apollonius_site_2 + FK_Construct_Apollonius_site_2; + + typedef typename EK_traits::Construct_Apollonius_vertex_2 + EK_Construct_Apollonius_vertex_2; + + typedef typename EK_traits::Construct_Apollonius_site_2 + EK_Construct_Apollonius_site_2; + +public: +#if 0 + // the following typedefs have been made in the direction of + // providing filtered constructions; however, there is a problem, + // namely, the Construct_Apollonius_site_2 functor has two + // different operator()'s with two different return types; this + // functor should be split in two (along with the appropriate + // changes in the spec/concept); see also changes needed for the + // filtered construction above. + typedef Filtered_construction + Construct_Apollonius_vertex_2; + + typedef Filtered_construction + Construct_Apollonius_site_2; +#else + typedef typename CK_traits::Construct_Apollonius_vertex_2 + Construct_Apollonius_vertex_2; + + typedef typename CK_traits::Construct_Apollonius_site_2 + Construct_Apollonius_site_2; +#endif + +private: + // PREDICATES FOR THE TWO KERNELS + //------------------------------- + + // Predicates for the filtering kernel + typedef typename FK_traits::Compare_x_2 FK_Compare_x_2; + typedef typename FK_traits::Compare_y_2 FK_Compare_y_2; + typedef typename FK_traits::Compare_weight_2 FK_Compare_weight_2; + typedef typename FK_traits::Orientation_2 FK_Orientation_2; + typedef typename FK_traits::Orientation_new_2 FK_Orientation_new_2; + typedef typename FK_traits::Is_hidden_2 FK_Is_hidden_2; + + typedef typename FK_traits::Oriented_side_of_bisector_2 + FK_Oriented_side_of_bisector_2; + + typedef typename FK_traits::Vertex_conflict_2 FK_Vertex_conflict_2; + + typedef typename FK_traits::Finite_edge_interior_conflict_2 + FK_Finite_edge_interior_conflict_2; + + typedef typename FK_traits::Infinite_edge_interior_conflict_2 + FK_Infinite_edge_interior_conflict_2; + + typedef typename FK_traits::Is_degenerate_edge_2 + FK_Is_degenerate_edge_2; + + + // Predicates for the exact kernel + typedef typename EK_traits::Compare_x_2 EK_Compare_x_2; + typedef typename EK_traits::Compare_y_2 EK_Compare_y_2; + typedef typename EK_traits::Compare_weight_2 EK_Compare_weight_2; + typedef typename EK_traits::Orientation_2 EK_Orientation_2; + typedef typename EK_traits::Orientation_new_2 EK_Orientation_new_2; + typedef typename EK_traits::Is_hidden_2 EK_Is_hidden_2; + + typedef typename EK_traits::Oriented_side_of_bisector_2 + EK_Oriented_side_of_bisector_2; + + typedef typename EK_traits::Vertex_conflict_2 EK_Vertex_conflict_2; + + typedef typename EK_traits::Finite_edge_interior_conflict_2 + EK_Finite_edge_interior_conflict_2; + + typedef typename EK_traits::Infinite_edge_interior_conflict_2 + EK_Infinite_edge_interior_conflict_2; + + typedef typename EK_traits::Is_degenerate_edge_2 + EK_Is_degenerate_edge_2; + +public: + // PREDICATES + //----------- + + typedef + Filtered_predicate + Compare_x_2; + + typedef + Filtered_predicate + Compare_y_2; + + typedef + Filtered_predicate + Compare_weight_2; + + typedef + Filtered_predicate + Orientation_2; + + typedef + Filtered_predicate + Orientation_new_2; + + typedef + Filtered_predicate + Is_hidden_2; + + typedef + Filtered_predicate + Oriented_side_of_bisector_2; + + typedef + Filtered_predicate + Vertex_conflict_2; + + typedef + Filtered_predicate + Finite_edge_interior_conflict_2; + + typedef + Filtered_predicate + Infinite_edge_interior_conflict_2; + + typedef + Filtered_predicate + Is_degenerate_edge_2; + +public: + //----------------------------------------------------------------------- + // ACCESS TO OBJECTS + //----------------------------------------------------------------------- + + // OBJECT CONSTRUCTION & ASSIGNMENT + Assign_2 + assign_2_object() const { + return Assign_2(); + } + + Construct_object_2 + construct_object_2_object() const { + return Construct_object_2(); + } + + + // CONSTRUCTIONS + //-------------- + Construct_Apollonius_vertex_2 + construct_Apollonius_vertex_2_object() const { + return Construct_Apollonius_vertex_2(); + } + + Construct_Apollonius_site_2 + construct_Apollonius_site_2_object() const { + return Construct_Apollonius_site_2(); + } + + // PREDICATES + //----------- + Compare_x_2 + compare_x_2_object() const { + return Compare_x_2(); + } + + Compare_y_2 + compare_y_2_object() const { + return Compare_y_2(); + } + + Compare_weight_2 + compare_weight_2_object() const { + return Compare_weight_2(); + } + + Orientation_2 + orientation_2_object() const { + return Orientation_2(); + } + + Orientation_new_2 + orientation_new_2_object() const { + return Orientation_new_2(); + } + + Is_hidden_2 + is_hidden_2_object() const { + return Is_hidden_2(); + } + + Oriented_side_of_bisector_2 + oriented_side_of_bisector_2_object() const { + return Oriented_side_of_bisector_2(); + } + + Vertex_conflict_2 + vertex_conflict_2_object() const { + return Vertex_conflict_2(); + } + + Finite_edge_interior_conflict_2 + finite_edge_interior_conflict_2_object() const { + return Finite_edge_interior_conflict_2(); + } + + Infinite_edge_interior_conflict_2 + infinite_edge_interior_conflict_2_object() const { + return Infinite_edge_interior_conflict_2(); + } + + Is_degenerate_edge_2 + is_degenerate_edge_2_object() const { + return Is_degenerate_edge_2(); + } + +}; + + + +} //namespace CGAL + + +#endif // CGAL_APOLLONIUS_GRAPH_NEW_FILTERED_TRAITS_2_H diff --git a/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Apollonius_graph_new_traits_2.h b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Apollonius_graph_new_traits_2.h new file mode 100644 index 00000000000..f3e33e91f09 --- /dev/null +++ b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Apollonius_graph_new_traits_2.h @@ -0,0 +1,209 @@ +// Copyright (c) 2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas +// Christophe Delage +// David Millman + +#ifndef CGAL_APOLLONIUS_GRAPH_NEW_TRAITS_2_H +#define CGAL_APOLLONIUS_GRAPH_NEW_TRAITS_2_H + +#include +#include +#include + +namespace CGAL { + +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// the Traits class +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +template < class Rep, class MTag = Integral_domain_without_division_tag > +class Apollonius_graph_new_traits_2 +{ +public: + //----------------------------------------------------------------------- + // TYPE DEFINITIONS + //----------------------------------------------------------------------- + + // BASIC TYPES + //------------ +private: + typedef Apollonius_graph_new_traits_2 Self; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Apollonius_graph_kernel_wrapper_2 Kernel; + +public: + typedef Rep R; + typedef MTag Method_tag; + typedef typename Kernel::Point_2 Point_2; + typedef typename Kernel::Site_2 Site_2; + + typedef typename Kernel::Line_2 Line_2; + typedef typename Kernel::Ray_2 Ray_2; + typedef typename Rep::Segment_2 Segment_2; + + typedef typename Kernel::Object_2 Object_2; + typedef typename Kernel::FT FT; + typedef typename Kernel::RT RT; + + +public: + // OBJECT CONSTRUCTION & ASSIGNMENT + //--------------------------------- + typedef typename Kernel::Construct_object_2 Construct_object_2; + typedef typename Kernel::Assign_2 Assign_2; + + // CONSTRUCTIONS + //-------------- + // vertex and dual site + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Construct_Apollonius_vertex_2 + /* */ Construct_Apollonius_vertex_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Construct_Apollonius_site_2 + /* */ Construct_Apollonius_site_2; + + + // PREDICATES + //----------- + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Compare_x_2 Compare_x_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Compare_y_2 Compare_y_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Compare_weight_2 + Compare_weight_2; + + // the following seems to be buggy + // typedef CGAL::AG2_Orientation_test_new_2 Orientation_2; + // use the old one: + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Orientation_new_2 + Orientation_new_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Orientation_2 + Orientation_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Is_hidden_2 Is_hidden_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Oriented_side_of_bisector_2 + /* */ Oriented_side_of_bisector_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Vertex_conflict_new_2 + Vertex_conflict_2; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Finite_edge_interior_conflict_new_2 + /* */ Finite_edge_interior_conflict_2; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Infinite_edge_interior_conflict_new_2 + /* */ Infinite_edge_interior_conflict_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Is_degenerate_edge_2 + /* */ Is_degenerate_edge_2; + + +public: + //----------------------------------------------------------------------- + // ACCESS TO OBJECTS + //----------------------------------------------------------------------- + + // OBJECT CONSTRUCTION & ASSIGNMENT + Assign_2 + assign_2_object() const { + return Assign_2(); + } + + Construct_object_2 + construct_object_2_object() const { + return Construct_object_2(); + } + + + // CONSTRUCTIONS + //-------------- + Construct_Apollonius_vertex_2 + construct_Apollonius_vertex_2_object() const { + return Construct_Apollonius_vertex_2(); + } + + Construct_Apollonius_site_2 + construct_Apollonius_site_2_object() const { + return Construct_Apollonius_site_2(); + } + + + // PREDICATES + //----------- + Compare_x_2 + compare_x_2_object() const { + return Compare_x_2(); + } + + Compare_y_2 + compare_y_2_object() const { + return Compare_y_2(); + } + + Compare_weight_2 + compare_weight_2_object() const { + return Compare_weight_2(); + } + + Orientation_2 + orientation_2_object() const { + return Orientation_2(); + } + + Orientation_new_2 + orientation_new_2_object() const { + return Orientation_new_2(); + } + + Is_hidden_2 + is_hidden_2_object() const { + return Is_hidden_2(); + } + + Oriented_side_of_bisector_2 + oriented_side_of_bisector_2_object() const { + return Oriented_side_of_bisector_2(); + } + + Vertex_conflict_2 + vertex_conflict_2_object() const { + return Vertex_conflict_2(); + } + + Finite_edge_interior_conflict_2 + finite_edge_interior_conflict_2_object() const { + return Finite_edge_interior_conflict_2(); + } + + Infinite_edge_interior_conflict_2 + infinite_edge_interior_conflict_2_object() const { + return Infinite_edge_interior_conflict_2(); + } + + Is_degenerate_edge_2 + is_degenerate_edge_2_object() const { + return Is_degenerate_edge_2(); + } + +}; + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_NEW_TRAITS_2_H diff --git a/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Conflict_2.h b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Conflict_2.h new file mode 100644 index 00000000000..4fba67aa2b2 --- /dev/null +++ b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Conflict_2.h @@ -0,0 +1,181 @@ +// Copyright (c) 2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas +// Christophe Delage +// David Millman + +#ifndef CGAL_APOLLONIUS_GRAPH_2_CONFLICT_2_H +#define CGAL_APOLLONIUS_GRAPH_2_CONFLICT_2_H 1 + +#include +#include + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +//----------------------------------------------------------------------- +// Conflict Base +//----------------------------------------------------------------------- +template < class K, class Method_tag > +class Conflict_2 +{ +public: + typedef Inverted_weighted_point_2 Inverted_weighted_point; + typedef typename K::RT RT; + typedef typename K::Sign Sign; + typedef Sign result_type; + +protected: + + Sign orientation(const Inverted_weighted_point &p1, + const Inverted_weighted_point &p2, + const Inverted_weighted_point &p3) const + { + return sign_of_determinant( p1.p(), p2.p(), p3.p(), + p1.x(), p2.x(), p3.x(), + p1.y(), p2.y(), p3.y() ); + } + + Sign radical_intersection(const Inverted_weighted_point &p1, + const Inverted_weighted_point &p2, + const Inverted_weighted_point &p3, int i) const + { + Sign s = CGAL::sign( + CGAL::square(determinant( + p1.p(), p1.weight(), p1.y(), + p2.p(), p2.weight(), p2.y(), + p3.p(), p3.weight(), p3.y())) + + CGAL::square(determinant( + p1.p(), p1.x(), p1.weight(), + p2.p(), p2.x(), p2.weight(), + p3.p(), p3.x(), p3.weight())) + - CGAL::square(determinant( + p1.p(), p1.x(), p1.y(), + p2.p(), p2.x(), p2.y(), + p3.p(), p3.x(), p3.y()))); + + if (s != ZERO || i < 0) { return s; } + + // perturbation + switch (i) { + case (1) : return radical_side(p3, p2, p1, 3); + case (2) : return radical_side(p1, p3, p2, 3); + case (3) : return radical_side(p1, p2, p3, 3); + default : + CGAL_error_msg( "Case should not hapen"); + return ZERO; + } + } + + Sign radical_side(const Inverted_weighted_point &p1, + const Inverted_weighted_point &p2, + const Inverted_weighted_point &p3, int i) const + { + CGAL_assertion(i == -1 || i == 1 || i == 2 || i == 3); + + Sign s = -CGAL::sign( + determinant( + p1.p(), p1.x(), + p2.p(), p2.x()) + * determinant( + p1.p(), p1.weight(), p1.x(), + p2.p(), p2.weight(), p2.x(), + p3.p(), p3.weight(), p3.x()) + + determinant( + p1.p(), p1.y(), + p2.p(), p2.y()) + * determinant( + p1.p(), p1.weight(), p1.y(), + p2.p(), p2.weight(), p2.y(), + p3.p(), p3.weight(), p3.y())); + + if (s != ZERO || i < 1) { return s; } + + // perturbation + return POSITIVE; + } + + Sign power_test(const Inverted_weighted_point &p1, + const Inverted_weighted_point &p2, + const Inverted_weighted_point &p3, int i) const + { + CGAL_assertion(i == -1 || i == 1 || i == 2 || i == 3); + Sign s; + + Sign s_xTest = sign_of_determinant(p2.p(), p2.x(), p1.p(), p1.x()); + if ( s_xTest != ZERO ) { + s = s_xTest * + sign_of_determinant( p1.p(), p1.x(), p1.weight(), + p2.p(), p2.x(), p2.weight(), + p3.p(), p3.x(), p3.weight() ); + } else { + s = sign_determinant2x2( p2.p(), p2.y(), p1.p(), p1.y() ) * + sign_of_determinant( p1.p(), p1.y(), p1.weight(), + p2.p(), p2.y(), p2.weight(), + p3.p(), p3.y(), p3.weight() ); + } + if (s != ZERO || i < 1) { return s; } + + switch (i) { + case 1: + return ordered_on_line (p1, p2, p3) ? NEGATIVE : POSITIVE; + case 2: + return ordered_on_line (p2, p1, p3) ? NEGATIVE : POSITIVE; + case 3: + return NEGATIVE; + default: + CGAL_error_msg( "this should not happen."); + } + + // perturbation + bool ool; + if (i == 1) { + ool = ordered_on_line(p2, p1, p3); + } else if (i == 2) { + ool = ordered_on_line(p1, p2, p3); + } else if (i == 3) { + ool = ordered_on_line(p1, p3, p2); + } else { + CGAL_error_msg( "this does not happen."); + ool = false; + } + + if (ool) { return NEGATIVE; } + + return POSITIVE; + } + + Sign ordered_on_line_test(const Inverted_weighted_point &p1, + const Inverted_weighted_point &p2) const + { + Sign s_det = sign_of_determinant( p1.p(), p1.x(), p2.p(), p2.x() ); + if ( s_det != ZERO ) { return s_det; } + return sign_of_determinant( p1.p(), p1.y(), p2.p(), p2.y() ); + } + + bool ordered_on_line(const Inverted_weighted_point &p1, + const Inverted_weighted_point &p2, + const Inverted_weighted_point &p3) const + { + if (ordered_on_line_test(p1, p2) == POSITIVE) { + return ordered_on_line_test(p2, p3) == POSITIVE; + } + return ordered_on_line_test(p3, p2) == POSITIVE; + } +}; + + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_CONFLICT_2_H diff --git a/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Edge_conflict_2.h b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Edge_conflict_2.h new file mode 100644 index 00000000000..f4631da2d2b --- /dev/null +++ b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Edge_conflict_2.h @@ -0,0 +1,104 @@ +// Copyright (c) 2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas +// Christophe Delage +// David Millman + +#ifndef CGAL_APOLLONIUS_GRAPH_2_EDGE_CONFLICT_2_H +#define CGAL_APOLLONIUS_GRAPH_2_EDGE_CONFLICT_2_H 1 + + +#include + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +//----------------------------------------------------------------------- +// Edge Conflict Base +//----------------------------------------------------------------------- + +template < class K, class Method_tag > +class Edge_conflict_2 : public Conflict_2 +{ +private: + typedef Conflict_2 Base; +public: + typedef typename Base::Inverted_weighted_point Inverted_weighted_point; + typedef bool result_type; + typedef typename Base::Sign Sign; + +protected: + + bool edge_conflict_test(const Inverted_weighted_point &p2, + const Inverted_weighted_point &p3, + const Inverted_weighted_point &p4, + const Inverted_weighted_point &q, + bool b, int /*i23Q*/, int /*i24Q*/) const + { + + // orientations + Sign orient23Q = this->orientation(p2, p3, q); + Sign orient42Q = this->orientation(p4, p2, q); + Sign orient234 = this->orientation(p2, p3, p4); + + // radical intersections + Sign radInt23Q = this->radical_intersection(p2, p3, q, -1); + Sign radInt24Q = this->radical_intersection(p2, p4, q, -1); + + // radical side + Sign radSid2Q3 = this->radical_side(p2, q, p3, -1); + Sign radSid2Q4 = this->radical_side(p2, q, p4, -1); + + // order of a line + bool oolQ24 = this->ordered_on_line(q, p2, p4); + bool oolQ23 = this->ordered_on_line(q, p2, p3); + + if ( b ) + { + if ( CGAL::sign(q.p()) != POSITIVE ) { return true; } + // degenerate case + if (orient234 == ZERO && orient23Q == ZERO && orient42Q == ZERO) { + return (oolQ23 || oolQ24); + } else if (! ((radInt23Q != NEGATIVE && radSid2Q3 == NEGATIVE) && + (radInt24Q != NEGATIVE && radSid2Q4 == NEGATIVE))) { + // non degenerate case + return true; + } else if (orient234 != NEGATIVE) { + return orient23Q != POSITIVE && orient42Q != POSITIVE; + } else { + return orient23Q != POSITIVE || orient42Q != POSITIVE; + } + } + else + { + CGAL_assertion ( CGAL::sign(q.p()) == POSITIVE ); + // degenerate case + if (orient234 == ZERO && orient23Q == ZERO && orient42Q == ZERO) { + return (oolQ23 && oolQ24); + } else if (! ((radInt23Q != NEGATIVE && radSid2Q3 == NEGATIVE) && + (radInt24Q != NEGATIVE && radSid2Q4 == NEGATIVE))) { + // non degenerate case + return false; + } else if (orient234 != NEGATIVE) { + return orient23Q != POSITIVE || orient42Q != POSITIVE; + } else { + return orient23Q != POSITIVE && orient42Q != POSITIVE; + } + } + } +}; + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_EDGE_CONFLICT_2_H diff --git a/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Finite_edge_conflict_2.h b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Finite_edge_conflict_2.h new file mode 100644 index 00000000000..5c6ab3904dc --- /dev/null +++ b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Finite_edge_conflict_2.h @@ -0,0 +1,83 @@ +// Copyright (c) 2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas +// Christophe Delage +// David Millman + +#ifndef CGAL_APOLLONIUS_GRAPH_2_FINITE_EDGE_CONFLICT_2_H +#define CGAL_APOLLONIUS_GRAPH_2_FINITE_EDGE_CONFLICT_2_H + +#include + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +//----------------------------------------------------------------------- +// Finite edge interior conflict +//----------------------------------------------------------------------- + +template < class K, class Method_tag > +class Finite_edge_interior_conflict_new_2 + : public Edge_conflict_2 +{ +private: + typedef Edge_conflict_2 Base; + + using Base::edge_conflict_test; + +public: + typedef typename Base::Inverted_weighted_point Inverted_weighted_point; + typedef Weighted_point_inverter_2 Weighted_point_inverter; + typedef typename K::Site_2 Site_2; + typedef typename K::Point_2 Point_2; + typedef bool result_type; + + inline + bool operator()(const Site_2& p1, const Site_2& p2, + const Site_2& q, bool b) const + { + Weighted_point_inverter inverter(p1); + Point_2 origin(0,0); + Site_2 origin_site(origin,0); + return edge_conflict_test(inverter(p2), + Inverted_weighted_point(origin_site,1), + Inverted_weighted_point(origin_site,1), + inverter(q), b, 2, 2); + } + + inline + bool operator()(const Site_2& p1, const Site_2& p2, + const Site_2& p3, const Site_2& q, bool b) const + { + Weighted_point_inverter inverter(p2); + Point_2 origin(0,0); + Site_2 origin_site(origin,0); + return edge_conflict_test(inverter(p1), + Inverted_weighted_point(origin_site,1), + inverter(p3), inverter(q), b, 2, 1); + } + + inline + bool operator()(const Site_2& p1, const Site_2& p2, const Site_2& p3, + const Site_2& p4, const Site_2& q, bool b) const + { + Weighted_point_inverter inverter(p2); + return edge_conflict_test(inverter(p1), inverter(p4), inverter(p3), + inverter(q), b, 1, 1); + } +}; + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_FINITE_EDGE_CONFLICT_2_H diff --git a/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Infinite_edge_conflict_2.h b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Infinite_edge_conflict_2.h new file mode 100644 index 00000000000..6be7d9522dd --- /dev/null +++ b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Infinite_edge_conflict_2.h @@ -0,0 +1,62 @@ +// Copyright (c) 2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas +// Christophe Delage +// David Millman + +#ifndef CGAL_APOLLONIUS_GRAPH_2_INFINITE_EDGE_CONFLICT_2_H +#define CGAL_APOLLONIUS_GRAPH_2_INFINITE_EDGE_CONFLICT_2_H + + +#include + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +//----------------------------------------------------------------------- +// Infinite edge interior conflict +//----------------------------------------------------------------------- + +template < class K, class Method_tag > +class Infinite_edge_interior_conflict_new_2 + : public Edge_conflict_2 +{ +private: + typedef Edge_conflict_2 Base; + using Base::edge_conflict_test; + +public: + typedef Weighted_point_inverter_2 Weighted_point_inverter; + typedef typename Base::Inverted_weighted_point Inverted_weighted_point; + typedef typename K::Site_2 Site_2; + typedef typename K::Point_2 Point_2; + typedef bool result_type; + + inline + bool operator()(const Site_2& p2, const Site_2& p3, + const Site_2& p4, const Site_2& q, bool b) const + { + Weighted_point_inverter inverter(p2); + Point_2 origin(0,0); + Site_2 origin_site(origin,0); + return edge_conflict_test(Inverted_weighted_point(origin_site, 1), + inverter(p4), inverter(p3), inverter(q), + b, 1, 1); + } +}; + + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_INFINITE_EDGE_CONFLICT_2_H diff --git a/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/New_predicates_C2.h b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/New_predicates_C2.h new file mode 100644 index 00000000000..6fee61f3626 --- /dev/null +++ b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/New_predicates_C2.h @@ -0,0 +1,25 @@ +// Copyright (c) 2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_NEW_PREDICATES_C2_H +#define CGAL_APOLLONIUS_GRAPH_2_NEW_PREDICATES_C2_H 1 + +#include + +#include +#include +#include +#include + +#endif // CGAL_APOLLONIUS_GRAPH_2_NEW_PREDICATES_C2_H diff --git a/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Orientation_2.h b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Orientation_2.h new file mode 100644 index 00000000000..2894971a591 --- /dev/null +++ b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Orientation_2.h @@ -0,0 +1,92 @@ +// Copyright (c) 2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas +// Christophe Delage +// David Millman + +#ifndef CGAL_APOLLONIUS_GRAPH_2_ORIENTATION_NEW_2_H +#define CGAL_APOLLONIUS_GRAPH_2_ORIENTATION_NEW_2_H + + +#include + +namespace CGAL { + +namespace ApolloniusGraph_2 { + + +template +class Orientation_new_2 : public Orientation_2 +{ +private: + typedef Orientation_2 Base; +public: + typedef K Kernel; + typedef typename K::RT RT; + typedef typename K::Site_2 Site_2; + typedef typename K::Point_2 Point_2; + + typedef typename Base::Orientation Orientation; + typedef Orientation result_type; + typedef Site_2 argument_type; + + Orientation operator() (const Site_2 &s0, const Site_2 &s1, + const Site_2 &s2, const Point_2 &q) const + { + RT x1 = s1.x() - s0.x(); + RT y1 = s1.y() - s0.y(); + RT w1 = s1.weight() - s0.weight(); + + RT x2 = s2.x() - s0.x(); + RT y2 = s2.y() - s0.y(); + RT w2 = s2.weight() - s0.weight(); + + RT xq = q.x() - s0.x(); + RT yq = q.y() - s0.y(); + + RT a1 = CGAL::square(x1) + CGAL::square(y1) - CGAL::square(w1); + RT a2 = CGAL::square(x2) + CGAL::square(y2) - CGAL::square(w2); + + CGAL_assertion (CGAL::sign(a1) == POSITIVE); + CGAL_assertion (CGAL::sign(a2) == POSITIVE); + + RT x = a1 * x2 - a2 * x1; + RT y = a1 * y2 - a2 * y1; + RT w = a1 * w2 - a2 * w1; + RT s = x * xq + y * yq; + + Sign W = CGAL::sign (w); + Sign S = CGAL::sign (s); + + if (W == ZERO) { return -S; } + + RT o = x * yq - y * xq; + + Sign O = CGAL::sign(o); + + if (S == 0) { return O * W; } + + if (W * S * O != POSITIVE) { return -S; } + + RT i = CGAL::square(w) * (CGAL::square(xq) + CGAL::square(yq)) + - CGAL::square(s); + + Sign I = CGAL::sign(i); + + return S * I; + } +}; + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_ORIENTATION_NEW_2_H diff --git a/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Vertex_conflict_2.h b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Vertex_conflict_2.h new file mode 100644 index 00000000000..2990c589105 --- /dev/null +++ b/Apollonius_graph_2/archive/include/CGAL/Apollonius_graph_2/Delage_traits/Vertex_conflict_2.h @@ -0,0 +1,320 @@ +// Copyright (c) 2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas +// Christophe Delage +// David Millman + +#ifndef CGAL_APOLLONIUS_GRAPH_2_VERTEX_CONFLICT_2_H +#define CGAL_APOLLONIUS_GRAPH_2_VERTEX_CONFLICT_2_H + + +#include + + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +//----------------------------------------------------------------------- +// Vertex conflict +//----------------------------------------------------------------------- + +template < class K, class Method_tag > +class Vertex_conflict_new_2 +{ +public: + typedef typename K::Site_2 Site_2; + typedef typename K::RT RT; + typedef Sign result_type; + +private: + + inline + bool is_less (const Site_2 &p0, const Site_2 &p1) const + { + if (p0.weight() < p1.weight()) return true; + if (p0.weight() > p1.weight()) return false; + + if (p0.x() < p1.x()) return true; + if (p0.x() > p1.x()) return false; + + return p0.y() < p1.y(); + } + + inline + int max_radius(const Site_2 &p0, const Site_2 &p1, + const Site_2 &p2, const Site_2 &p3) const + { + int i = 0; + const Site_2 *p = &p0; + + if (is_less (*p, p1)) { i = 1; p = &p1; } + if (is_less (*p, p2)) { i = 2; p = &p2; } + if (is_less (*p, p3)) { i = 3; } + + return i; + } + + inline + Sign predicate (const Site_2 &p1, const Site_2 &p2, + const Site_2 &p3, const Site_2 &q, bool perturb) const + { + RT xq = q.x() - p1.x(); + RT yq = q.y() - p1.y(); + RT wq = q.weight() - p1.weight(); + RT aq = CGAL::square(xq) + CGAL::square(yq) - CGAL::square(wq); + + // q is hiding p1 + if (CGAL::sign(aq) != POSITIVE){ + // I BELIEVE MENELAOS RETURNS -1 in this case even when degernate + //if (sign (aq) == ZERO && ! perturb) return ZERO; + + //return NEGATIVE; + return POSITIVE; + } + + RT x2 = p2.x() - p1.x(); + RT y2 = p2.y() - p1.y(); + RT w2 = p2.weight() - p1.weight(); + RT a2 = CGAL::square(x2) + CGAL::square(y2) - CGAL::square(w2); + + CGAL_assertion (a2 > 0); + + RT x3 = p3.x() - p1.x(); + RT y3 = p3.y() - p1.y(); + RT w3 = p3.weight() - p1.weight(); + RT a3 = CGAL::square(x3) + CGAL::square(y3) - CGAL::square(w3); + + CGAL_assertion (a3 > 0); + + RT ax3q = a3 * xq - x3 * aq; + RT ax2q = a2 * xq - x2 * aq; + RT ax23 = a2 * x3 - x2 * a3; + + RT ay23 = a2 * y3 - y2 * a3; + RT ay2q = a2 * yq - y2 * aq; + RT ay3q = a3 * yq - y3 * aq; + + RT axw23q = ax23 * wq - ax2q * w3 + ax3q * w2; + RT ayw23q = ay23 * wq - ay2q * w3 + ay3q * w2; + + RT axy23q = y2 * ax3q - y3 * ax2q + yq * ax23; + + // orientation + Sign orient = CGAL::sign(axy23q); + + // orientation degenerate + if (orient == ZERO) { + Sign orient1 = CGAL::sign(ax23); + + Sign power_test = + ( orient1 == ZERO ? + (CGAL::sign(ay23) * CGAL::sign(ayw23q)) : + (orient1 * CGAL::sign(axw23q)) + ); + + if (power_test != ZERO || !perturb) { + return -power_test; + } + + int i = max_radius (p1, p2, p3, q); + + if (i == 3) { return NEGATIVE; } + + Sign o23, o2q, o3q; + + if (orient1 == ZERO) { + o23 = CGAL::sign(ay23); + o2q = CGAL::sign(ay2q); + o3q = CGAL::sign(ay3q); + } else { + o23 = CGAL::sign(ax23); + o2q = CGAL::sign(ax2q); + o3q = CGAL::sign(ax3q); + } + + if (o23 != o2q) { return i == 2 ? NEGATIVE : POSITIVE; } + + if (o23 == o3q) { return i == 1 ? NEGATIVE : POSITIVE; } + + return i == 0 ? NEGATIVE : POSITIVE; + } + + + // radical side + RT rs23q = ax23 * axw23q + ay23 * ayw23q; + Sign radSide = CGAL::sign(rs23q); + + if (radSide == ZERO || radSide != orient) { return orient; } + + // radical intersection + Sign radInt = + CGAL::sign(CGAL::square(axw23q) + CGAL::square(ayw23q) + - CGAL::square( axy23q)); + + // radical intersection degenerate + if (radInt == ZERO) { + Sign radSideQ = CGAL::sign(ax23 * axw23q + ay23 * ayw23q); + + CGAL_assertion (radSideQ != ZERO); + + if (!perturb) { return (radSideQ == orient) ? ZERO : orient; } + + int i = max_radius (p1, p2, p3, q); + + if (i == 3) { + radInt = radSideQ; + } else if (i == 2) { + radInt = -CGAL::sign(ax2q * axw23q + ay2q * ayw23q); + if (radInt == ZERO) { return NEGATIVE; } + } else if (i == 1) { + radInt = CGAL::sign(ax3q * axw23q + ay3q * ayw23q); + if (radInt == ZERO) { return NEGATIVE; } + } else { + CGAL_assertion (i == 0); + Sign radSide1 = -CGAL::sign(ax2q * axw23q + ay2q * ayw23q); + if (radSide1 == ZERO) { return NEGATIVE; } + + Sign radSide2 = CGAL::sign(ax3q * axw23q + ay3q * ayw23q); + if (radSide2 == ZERO) { return NEGATIVE; } + + radInt = Sign (-(radSideQ + radSide1 + radSide2)); + } + } + + CGAL_assertion (!perturb || radInt != ZERO); + + if (radInt == NEGATIVE) { return orient; } + + return -radSide; + } + + + inline + Sign predicate(const Site_2 &p1, const Site_2 &p2, + const Site_2 &q, bool perturb) const + { + // NOTE:*************************************** + // * the perturb boolean variable is not used + // * for consistancy with Menelaos + // NOTE:*************************************** + RT x2 = p2.x() - p1.x(); + RT y2 = p2.y() - p1.y(); + RT w2 = p2.weight() - p1.weight(); + RT xq = q.x() - p1.x(); + RT yq = q.y() - p1.y(); + RT wq = q.weight() - p1.weight(); + + RT xw2q = x2 * wq - xq * w2; + RT yw2q = y2 * wq - yq * w2; + RT xy2q = x2 * yq - xq * y2; + + // orientation + Sign orient = CGAL::sign(xy2q); + + // orientation degenerate + if (orient == ZERO) { + Sign o12 = CGAL::sign(x2); + Sign o1q, o2q; + + Sign power_test; + if (o12 != ZERO) { + power_test = o12 * CGAL::sign(xw2q); + + // this results is consistant with Menelaos + if (power_test != ZERO) { return -power_test; } + + // this result is consistant with the perturb on off idea + //if (power_test != ZERO || ! perturb) return -power_test; + o1q = CGAL::sign(xq); + o2q = CGAL::sign(q.x() - p2.x()); + } else { + o12 = CGAL::sign(y2); + power_test = o12 * CGAL::sign(yw2q); + + // this results is consistant with Menelaos + if (power_test != ZERO) { return -power_test; } + + // this result is consistant with the perturb on off idea + //if (power_test != ZERO || ! perturb) return -power_test; + o1q = CGAL::sign(yq); + o2q = CGAL::sign(q.y() - p2.y()); + } + + if (o1q != o12) { return POSITIVE; } + if (o2q == o12) { return POSITIVE; } + + return NEGATIVE; + } + + // radical side + RT rs12q = x2 * xw2q + y2 * yw2q; + Sign radSide = CGAL::sign(rs12q); + + if (radSide == ZERO || radSide == orient) { + return -orient; + } + + // radical intersection + Sign radInt = + CGAL::sign(CGAL::square(xw2q) + CGAL::square(yw2q) + - CGAL::square(xy2q)); + + // radical intersection degerate + if (radInt == ZERO) { + CGAL_assertion (radSide != ZERO); + + // this result is consistant with the perturb on off idea + //if (! perturb) return (radSide == orient) ? ZERO : orient; + + RT rs2q1 = (p2.x() - q.x()) * xw2q + (p2.y() - q.y()) * yw2q; + Sign radSide1 = CGAL::sign(rs2q1); + if (radSide1 == ZERO) { return NEGATIVE; } + + RT rsq12 = xq * xw2q + yq * yw2q; + Sign radSide2 = CGAL::sign(rsq12); + if (radSide2 == ZERO) { return NEGATIVE; } + + return -(radSide1 * radSide2); + } + + CGAL_assertion (!perturb || radInt != ZERO); + + if (radInt == POSITIVE) { return orient; } + return radSide; + } + +public: + inline + Sign operator()(const Site_2 &p1, const Site_2 &p2, + const Site_2 &p3, const Site_2 &q, + bool perturb = true) const + { + Sign newPred = predicate(p1, p2, p3, q, perturb); + CGAL_assertion (!perturb || newPred != ZERO); + return newPred; + } + + inline + Sign operator()(const Site_2 &p1, const Site_2 &p2, + const Site_2 &q, bool perturb = true) const + { + Sign newPred = predicate(p1, p2, q, perturb); + CGAL_assertion (!perturb || newPred != ZERO); + return newPred; + } +}; + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_VERTEX_CONFLICT_2_H diff --git a/Apollonius_graph_2/archive/test/Apollonius_graph_2/test_ag_new_traits_2.cpp b/Apollonius_graph_2/archive/test/Apollonius_graph_2/test_ag_new_traits_2.cpp new file mode 100644 index 00000000000..e240628d93b --- /dev/null +++ b/Apollonius_graph_2/archive/test/Apollonius_graph_2/test_ag_new_traits_2.cpp @@ -0,0 +1,194 @@ +#include + +#include +#include + +#include +#include + +#include +#include +#include + +typedef CGAL::Sign Sign; + +template +class Check_traits : public GT +{ + GT_test test; +public: + + typedef typename GT::Site_2 Site_2; + + Check_traits (const GT > = GT(), const GT_test >_test = GT_test()) + : GT(gt), test (gt_test) + {} + + template + struct Checked_predicate : public Predicate + { + New_predicate newp; + typedef typename Predicate::result_type result_type; + + Checked_predicate (const Predicate &p, const New_predicate &np) + : Predicate (p), newp (np) + {} + + template + result_type operator() (const T1 &t1) const + { + result_type r1 = Predicate::operator() (t1); + result_type r2 = newp (t1); + assert(r1 == r2); + return r1; + } + template + result_type operator() (const T1 &t1, const T2 &t2) const + { + result_type r1 = Predicate::operator() (t1, t2); + result_type r2 = newp (t1, t2); + assert(r1 == r2); + return r1; + } + template + result_type operator() (const T1 &t1, const T2 &t2, const T3 &t3) const + { + result_type r1 = Predicate::operator() (t1, t2, t3); + result_type r2 = newp (t1, t2, t3); + assert(r1 == r2); + return r1; + } + template + result_type operator() (const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4) const + { + result_type r1 = Predicate::operator() (t1, t2, t3, t4); + result_type r2 = newp (t1, t2, t3, t4); + assert(r1 == r2); + return r1; + } + template + result_type operator() (const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5) const + { + result_type r1 = Predicate::operator() (t1, t2, t3, t4, t5); + result_type r2 = newp (t1, t2, t3, t4, t5); + assert(r1 == r2); + return r1; + } + template + result_type operator() (const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4, const T5 &t5, const T6 &t6) const + { + result_type r1 = Predicate::operator() (t1, t2, t3, t4, t5, t6); + result_type r2 = newp (t1, t2, t3, t4, t5, t6); + assert(r1 == r2); + return r1; + } + }; + + typedef Checked_predicate + Vertex_conflict_2; + + typedef Checked_predicate + Finite_edge_interior_conflict_2; + + typedef Checked_predicate + Infinite_edge_interior_conflict_2; + + Vertex_conflict_2 + vertex_conflict_2_object() const + { + return Vertex_conflict_2 ( + GT::vertex_conflict_2_object(), + test.vertex_conflict_2_object()); + } + Finite_edge_interior_conflict_2 + finite_edge_interior_conflict_2_object() const + { + return Finite_edge_interior_conflict_2 ( + GT::finite_edge_interior_conflict_2_object(), + test.finite_edge_interior_conflict_2_object()); + } + Infinite_edge_interior_conflict_2 + infinite_edge_interior_conflict_2_object() const + { + return Infinite_edge_interior_conflict_2 ( + GT::infinite_edge_interior_conflict_2_object(), + test.infinite_edge_interior_conflict_2_object()); + } +}; + +typedef CGAL::MP_Float NT; +typedef CGAL::Simple_cartesian K; +typedef CGAL::Apollonius_graph_traits_2 GT_old; +typedef CGAL::Apollonius_graph_new_traits_2 GT_new; +typedef Check_traits GT; +typedef CGAL::Apollonius_graph_2 AG; + +typedef AG::Site_2 Site; +typedef AG::Finite_faces_iterator Finite_faces_iterator; +typedef AG::Finite_vertices_iterator Finite_vertices_iterator; +typedef AG::Vertex_handle Vertex_handle; + +void test_orientation (const AG &ag, + Vertex_handle v0, Vertex_handle v1, Vertex_handle v2) +{ + const Site &s0 = v0->site(); + const Site &s1 = v1->site(); + const Site &s2 = v2->site(); + + GT gt; + GT_new gt_new; + + GT::Orientation_2 orientation1 = gt.orientation_2_object(); + GT_new::Orientation_new_2 orientation2 = gt_new.orientation_new_2_object(); + + for (Finite_vertices_iterator _v = ag.finite_vertices_begin(); + _v != ag.finite_vertices_end(); ++_v) + { + Vertex_handle v = _v; + if (v == v0) continue; + + Sign o1 = orientation1 (s0, s1, s2, s0, v->site()); + Sign o2 = orientation2 (s0, s1, s2, v->site().point()); + + assert(o1 == o2); + } +} + +void test_file (const char *filename) +{ + std::ifstream is (filename); + + assert(is); + + std::cout << "File " << filename << ": construction... " << std::flush; + AG ag; + Site s; while (is >> s) ag.insert (s); + + std::cout << "validation... " << std::flush; + assert(ag.is_valid()); + + std::cout << "OK" << std::endl; + + std::cout << "Test orientation... " << std::flush; + + for (Finite_faces_iterator f = ag.finite_faces_begin(); + f != ag.finite_faces_end(); ++f) + { + test_orientation (ag, f->vertex(0), f->vertex(1), f->vertex(2)); + test_orientation (ag, f->vertex(1), f->vertex(2), f->vertex(0)); + test_orientation (ag, f->vertex(2), f->vertex(0), f->vertex(1)); + } + + std::cout << "OK" << std::endl; +} + +int main (void) +{ + test_file ("data/traits.dat"); + test_file ("data/algo.dat"); + + return 0; +} diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/Apollonius_graph_2.txt b/Apollonius_graph_2/doc/Apollonius_graph_2/Apollonius_graph_2.txt new file mode 100644 index 00000000000..0b2f6aa2082 --- /dev/null +++ b/Apollonius_graph_2/doc/Apollonius_graph_2/Apollonius_graph_2.txt @@ -0,0 +1,438 @@ +namespace CGAL { +/*! + +\mainpage User Manual +\anchor Chapter_2D_Apollonius_Graphs +\anchor chapterapollonius2 +\cgalAutoToc +\authors Menelaos Karavelas and Mariette Yvinec + +This chapter describes the two-dimensional Apollonius graph +of \cgal. We start with a few definitions in +Section \ref secapollonius2definitions. +The software design of the 2D Apollonius graph package is described +in Section \ref secapollonius2design. +In Section \ref secapollonius2traits we discuss the geometric +traits of the 2D Apollonius graph package and in Section +\ref secapollonius2hierarchy the Apollonius graph hierarchy, a data +structure suitable for fast nearest neighbor queries, is briefly +described. + +\section secapollonius2definitions Definitions + +\cgalFigureBegin{figapollonius,apollonius_diagram.png,apollonius_graph.png} +The Apollonius diagram (left) and its dual the Apollonius graph (right). +\cgalFigureEnd + +The 2D Apollonius graph class of \cgal is designed to compute the +dual of the Apollonius diagram or, as it is also known, the +Additively weighted Voronoi diagram. The algorithm that has been +implemented is dynamic, which means that we can perform insertions and +deletions on line. The corresponding \cgal class is called +`Apollonius_graph_2` +and will be discussed in more detail in the sequel. The interested +reader may want to refer to the paper by Karavelas and Yvinec +\cgalCite{cgal:ky-dawvd-02} for the general idea as well as the details of the +algorithm implemented. + +Before describing the details of the implementation we make a brief +introduction to the theory of Apollonius diagrams. +The Apollonius diagram is defined over a set of sites +\f$ P_i=(c_i,w_i)\f$, \f$ i=1,\ldots,n\f$, where \f$ c_i\f$ is the point and \f$ w_i\f$ +the weight of \f$ P_i\f$. It is a subdivision of the plane into connected +regions, called cells, associated with the sites (see +\cgalFigureRef{figapollonius} (left)). The cell of a +site \f$ P_i\f$ is the locus of points on the plane that are +closer to \f$ P_i\f$ than any other site \f$ P_j\f$, \f$ j\neq i\f$. +The distance \f$ \delta(x, P_i)\f$ of a point \f$ x\f$ in the plane to a +site \f$ P_i\f$ is defined as: +\f[ \delta(x,P_i)=\|x-c_i\|-w_i, \f] +where \f$ \|\cdot\|\f$ denotes the Euclidean norm. +It can easily be seen that it is a generalization of the Voronoi +diagram for points, which can actually be obtained if all the weights +\f$ w_i\f$ are equal. Unlike the case of points, however, it is +possible that a site \f$ P_i\f$ might have an empty cell. This +can also happen in the case of the power diagram, whose dual is the +regular triangulation (see Section +\ref Section_2D_Triangulations_Regular ). If this is +the case we call the site hidden (these are the black +circles in \cgalFigureRef{figapollonius} ). A site which is not +hidden will be referred to as visible. + +If all weights \f$ w_i\f$ are non-negative, the Apollonius +diagram can be viewed as the Voronoi diagram of the set of circles +\f$ \{P_1,\ldots, P_n\}\f$, where \f$ c_i\f$ is the center of the circle \f$ P_i\f$ +and \f$ w_i\f$ its radius. If the weights are allowed to be negative, +we need to go to 3D in order to explain what the Apollonius diagram +means geometrically. We identify the 2D Euclidean plane with the +\f$ xy\f$-plane in 3D. Then the Voronoi diagram of a set of points can be +seen as the vertical projection on the \f$ xy\f$-plane of the lower +envelope of a set of 3D cones defined as follows: for each point \f$ p\f$ +in the set of 2D points we have a cone \f$ C_p\f$ whose apex is the point +\f$ p\f$. The axis of +\f$ C_p\f$ is a line parallel to the \f$ z\f$-axis passing through \f$ p\f$, the +angle of \f$ C_p\f$ is \f$ 45^\circ\f$ and, finally \f$ C_p\f$ is facing in the +positive \f$ z\f$-direction (that is, \f$ C_p\f$ is contained in the positive +\f$ z\f$-halfspace). +The Apollonius diagram corresponds to shifting the +apexes of these cones in the \f$ z\f$-direction by a quantity equal to the +weight. Sites with negative weight will give rise to +cones whose apex is in the negative \f$ z\f$-halfspace and sites +with positive weight will give rise to cones whose apex is in the +positive \f$ z\f$-halfspace. In a manner analogous to the case of points, +the Apollonius diagram can then be defined as the vertical projection +on the \f$ xy\f$-plane of the lower envelope of the set of shifted cones. +Notice that when all apexes are translated along the \f$ z\f$-direction by +the same amount, the projection of the lower envelope of the set of +cones does not change. In particular, we can translate all cones by a +large enough amount so that all apexes are in the positive +\f$ z\f$-halfspace. Algebraically, this means that the Apollonius diagram +does not change if we add to all weights the same quantity, which in +particular, implies that we can assume without loss of generality that +all weights are positive. Given the observations above and in order to +simplify our discussion of Apollonius diagrams, we will, from now on, +assume that all weights are positive, and we will refer to the +sites as circles. + +The Apollonius diagram is a planar graph, and so is its dual, the +Apollonius graph. There are many ways to embed it on the plane and one +such way is shown in \cgalFigureRef{figapollonius} (right). +The Apollonius graph is uniquely defined once we have +the Apollonius diagram. If the circles are in general position +(see precise definition below), then the Apollonius graph is a graph +with triangular faces away from +the convex hull of the set of circles (by triangular we mean that +every face has exactly three edges). Near the convex hull we may +have some spikes (i.e., vertices of degree 1). To unify our approach +and handling of the Apollonius graph we add to the set of (finite) +circles a fictitious circle at infinity, which we call the +site at infinity. We can then connect all vertices of the outer +face of the Apollonius graph to the site at infinity which gives us +a graph with the property that all of its faces are now +triangular. However, the Apollonius graph is not a triangulation for +two main reasons: we cannot always embed it on the plane with straight +line segments that yield a triangulation and, moreover, we may have two +faces of the graph that have two edges in common, which is not allowed +in a triangulation. Both of these particularities appear when we +consider the Apollonius graph of the set of circles in +\cgalFigureRef{figapollonius}. + +We would like to finish our brief introduction to the theory of +Apollonius graphs by discussing the concept of general position. We say +that a set of circles is in general position if no two triplets of +circles have the same tritangent circle. This statement is rather +technical and it is best understood in the context of points. The +equivalent statement for points is that we have no two triplets of +points that define the same circumcircle, or equivalently that no +four points are co-circular. The statement about general position made +above is a direct generalization of the (much simpler to understand) +statement about points. On the contrary, when we have circles in +degenerate position, the Apollonius graph has faces with more than +three edges on their boundary. We can get a triangulated version of +the graph by simply triangulating the corresponding faces in an +arbitrary way. In fact the algorithm that has been implemented in +\cgal has the property that it always returns a valid +triangulated version of the Apollonius graph. By valid we mean +that it contains the actual Apollonius graph (i.e., the actual dual of +the Apollonius diagram) and whenever there are faces with more than +three faces then they are triangulated. The way that they are +triangulated depends on the order of insertion and deletion of the +circles in the diagram. + +One final point has to be made about hidden circles. First of all we +would like to be more precise about our definition of hidden circles: +we say that a circle is hidden if its cell has empty interior. This +definition allows us to guarantee that all visible circles have +cells that are two-dimensional regions. +Geometrically the fact that a circle is hidden means that it is +contained in the closure of the disk of another circle (see again +\cgalFigureRef{figapollonius} ). Note that a circle contained in the union +of several disks, but not in the closure of any one of them, is not +hidden. + +Hidden circles pose an additional +difficulty to our algorithm and software design. Since we allow +circles to be inserted and deleted at wish, it is possible that a +circle that was hidden at some point in time, may become visible at +a later point in time; for example this can happen if we delete the +circle that hides it. For this purpose we store hidden circles and +have them reappear when they become visible. We will discuss this +issue in detail below. For the time being it suffices to say that the +user has the ability to control this behavior. More specifically it is +possible to discard the circles that become hidden. This choice is +totally natural when for example we expect to do only insertions, +since in this case a circle that becomes hidden will never +reappear. On the other hand if deletions are expected as well, then we +lose the ability to have the hidden circles reappear. + +Degenerate Dimensions. + +The dimension of the Apollonius graph is in general 2. The exceptions +to this rule are as follows: +
    +
  • The dimension is \f$ -1\f$ if the Apollonius graph contains no circles. +
  • The dimension is \f$ 0\f$ if the Apollonius graph contains exactly +one visible circle. +
  • The dimension is \f$ 1\f$ is the Apollonius graph contains exactly +two visible circles. +
+ +\section secapollonius2design Software Design + +The 2D Apollonius graph class +`Apollonius_graph_2` +follows the design of the triangulation packages of \cgal. It is +parametrized by two arguments: +
    +
  • the geometric traits class. It provides the basic +geometric objects involved in the algorithm, such as sites, points +etc. It also provides the geometric predicates for the computation +of the Apollonius graph, as well as some basic constructions that +can be used, for example, to visualize the Apollonius graph or the +Apollonius diagram. The geometric traits for the Apollonius graph +will be discussed in more detail in the next section. +
  • the Apollonius graph data structure. This is essentially +the same as the triangulation data structure (discussed in Chapter +\ref Chapter_2D_Triangulation_Data_Structure ), augmented with some +additional operations that are specific to Apollonius graphs. The +corresponding concept is that of +`ApolloniusGraphDataStructure_2`, which in fact is a refinement +of the `TriangulationDataStructure_2` concept. The class +`Triangulation_data_structure_2` is a model of +the concept `ApolloniusGraphDataStructure_2`. A default value +for the corresponding template parameter is provided, so the user +does not need to specify it. +
+ +Storing Hidden Sites. + +As we have already mentioned a circle is hidden if it is contained +inside some visible circle. This creates a parent-child relationship +between visible and hidden circles: the parent of a hidden circle is the +visible circle that contains it. If more than one visible circles +contain a hidden circle then the hidden circle can be assigned to any of +the visible circles arbitrarily. + +To store hidden circles we assign to every visible circle a list. This +list comprises the hidden circles that are contained in the +visible circle. The user can access the hidden circles associated with +a visible circle through an iterator called +`Hidden_sites_iterator`. This iterator is defined in the +`ApolloniusGraphVertexBase_2` concept and is implemented by its +model, the `Apollonius_graph_vertex_base_2` +class. It is also possible to iterate through the entire set of hidden +sites using an homonymous iterator defined by the +`Apollonius_graph_2` class. + +Since storing hidden sites may not be of interest in some cases (e.g., +for example this is the case if we only perform insertions in the +Apollonius graph), the user has the possibility of controlling this +behavior. More precisely, the class +`Apollonius_graph_vertex_base_2` has two template +parameters, the second of which is a Boolean value. This value is by +default `true` and it indicates that hidden sites should be +stored. The user can indicate that hidden sites may be discarded +by setting this value to `false`. + +\section secapollonius2traits The Geometric Traits + +The predicates required for the computation of the Apollonius graph +are rather complicated. It is not the purpose of this document to +discuss them in detail. The interested reader may refer to the papers +by Karavelas and Emiris for the details +\cgalCite{cgal:ke-ppawv-02}, \cgalCite{cgal:ke-rctac-03}. However, we would like to give a brief +overview of what they +compute. There are several predicates needed by this algorithm. We +will discuss the most important/complicated ones. It turns out that +it is much easier to describe them in terms of the Apollonius diagram, +rather than the Apollonius graph. Whenever it is applicable we will also +describe their meaning in terms of the Apollonius graph. + +The first two geometric predicates are called +`Is_hidden_2` and `Oriented_side_of_bisector_2`. The first one +involves two circles, say \f$ P_1\f$ and \f$ P_2\f$. It determines if \f$ P_1\f$ is +hidden with respect to \f$ P_2\f$; more precisely it checks whether the +circle \f$ P_1\f$ is contained in the closure of the disk defined by the +circle \f$ P_2\f$. As its name indicates, it determines if a circle is +hidden or not. The second predicate involves two circles \f$ P_1\f$ and +\f$ P_2\f$ and a point \f$ q\f$. It answers the question whether \f$ q\f$ is closer +to \f$ P_1\f$ or \f$ P_2\f$. Its name stems from the fact that answering the +aforementioned question is equivalent to determining the oriented +side of the bisector of \f$ P_1\f$ and \f$ P_2\f$ that contains the query point +\f$ q\f$. This predicate is used by the algorithm for closest neighbor +queries for points. + +The next geometric predicate is called `Vertex_conflict_2` and it +involves four circles \f$ P_1\f$, \f$ P_2\f$, \f$ P_3\f$, and \f$ P_4\f$ (see +\cgalFigureRef{figag2vc} ). The first three (red circles in +\cgalFigureRef{figag2vc} ) define a tritangent circle (yellow +circle in \cgalFigureRef{figag2vc} ). What we want to determine is +the sign of the distance of the green circle from the yellow +circle. The distance between two circles \f$ K_1=(c_1,r_1)\f$ and +\f$ K_2=(c_2, r_2)\f$ is defined as the distance of their centers minus +their radii: +\f[ \delta(K_1, K_2) = \|c_1-c_2\|-r_1-r_2. \f] +This predicate determines if a vertex in the Apollonius diagram +(the center of the yellow circle) is destroyed when a new circle is +inserted in the diagram (the green circle). In the Apollonius graph +it tells us if a triangular face of the diagram is to be destroyed or +not. + +\cgalFigureBegin{figag2vc,apollonius-vertex_conflict-false.png,apollonius-vertex_conflict-true.png} +The `Vertex_conflict_2` predicate. The left-most, bottom-most and top-most circles define the tritangent circle in the middle. We want to determine the sign of the distance of the left-most circle from the one in the middle. The almost horizontal curve is the bisector of the top-most and bottom-most circles. Left: the predicate returns `NEGATIVE`. Right: the predicate returns `POSITIVE`. +\cgalFigureEnd + +What we essentially want to compute when we construct incrementally a +Voronoi diagram, is whether the object to be inserted destroys an edge +of the Voronoi diagram or not. In the case of points this is really +easy and it amounts to the well known incircle test. +In the case +of circles the situation is more complicated. We can have six possible +outcomes as to what portion of an edge of the Apollonius diagram the +new circle destroys (see \cgalFigureRef{figag2edgeconflict} ). The first +two can be answered directly by the `Vertex_conflict_2` predicate +evaluated for the two endpoints of the Apollonius diagram edge. This +is due to the fact that the value of the `Vertex_conflict_2` +predicate is different for the two endpoints. If the two values are +the same then we need an additional test which determines if the interior +of the Apollonius diagram edge is destroyed by the new circle. This is +what the `Finite_edge_interior_conflict_2` and +`Infinite_edge_interior_conflict_2` predicates do. In essence, it +is the same predicate (same idea) applied to two different types of +edges in the Apollonius diagram: a finite or an infinite edge. An edge +is infinite if its dual edge in the Apollonius graph connects the +site at infinity with the vertex corresponding to a (finite) circle; +otherwise it is a finite edge. + +\cgalFigureAnchor{figag2edgeconflict} +
+ + + + + + + + + + + + + +
+\image html ./apollonius-left_vertex.png +\image latex ./apollonius-left_vertex.png + +\image html ./apollonius-right_vertex.png +\image latex ./apollonius-right_vertex.png +
+\image html ./apollonius-no_conflict.png +\image latex ./apollonius-no_conflict.png + +\image html ./apollonius-entire_edge.png +\image latex ./apollonius-entire_edge.png +
+\image html ./apollonius-interior.png +\image latex ./apollonius-interior.png + +\image html ./apollonius-both_vertices.png +\image latex ./apollonius-both_vertices.png +
+
+\cgalFigureCaptionBegin{figag2edgeconflict} +The 6 possible outcomes of the +`Finite_edge_interior_conflict_2` predicate. Top left: only a +neighborhood around the left-most endpoint of the edge will be +destroyed. Top right: only a neighborhood around the right-most +endpoint of the edge will be destroyed. Middle left: no portion of the +edge is destroyed. Middle right: the entire edge will be +destroyed. Bottom left: a neighborhood in the interior of the edge +will be destroyed; the regions near the endpoints remain +unaffected. Bottom right: The neighborhood around the two endpoints +will be destroyed, but an interval in the interior of the edge will +remain in the new diagram. +\cgalFigureCaptionEnd + +The last predicate that we want to discuss is called +`Is_degenerate_edge_2`. It tells us whether an edge in the +Apollonius diagram is degenerate, that is if its two endpoints +coincide. In the Apollonius graph such an edge corresponds to one of +the additional edges that we use to triangulate the non-triangular +faces. + +The aforementioned predicates are part of the +`ApolloniusGraphTraits_2` concept of \cgal. \cgal also provides +a model for this concept, the +`Apollonius_graph_traits_2` class. The first +template parameter of this class must be a model of the `Kernel` +concept. The second template parameter is a tag that indicates what +operations are allowed in the computations that take place within the +traits class. +The two possible values of the `Method_tag` parameter are +`Integral_domain_without_division_tag` and `Field_with_sqrt_tag`. When +`Integral_domain_without_division_tag` is used, only ring operations are used during the +evaluation of the predicates, whereas if `Field_with_sqrt_tag` is +chosen, all four field operations, as well as square roots, are used +during the predicate evaluation. + +The `Apollonius_graph_traits_2` class provides exact +predicates if the number type in the kernel `K` is an exact number +type. This is to be associated with the type of operations allowed for +the predicate evaluation. For example `MP_Float` as number +type, with `Integral_domain_without_division_tag` as tag will give exact predicates, +whereas `MP_Float` with `Field_with_sqrt_tag` will give +inexact predicates. + +Although exact number types provide exact predicates and constructions, +their use often results in unacceptably large runtimes. +The class `Apollonius_graph_filtered_traits_2` +aims to paliate this shortcoming. Similar to a filtered kernel, it takes a +constructions kernel `CK`, a filtering kernel `FK` and an +exact kernel `EK`, as well as the corresponding tags +(`CM`, `FM` and `EM`, respectively). +Predicates are evaluated by first using the filtering kernel, and +if this fails the evaluation is performed using the exact kernel, +thus yielding exact predicates at a generally much cheaper cost +than directly using an exact number type. The constructions +are done using the kernel `CK`, which means that +they are not necessarily exact. All template parameters except +`CK` have default values, which are explained in the reference +manual. + +\section secapollonius2hierarchy The Apollonius Graph Hierarchy + +The `Apollonius_graph_hierarchy_2` class is nothing but the equivalent of the `Triangulation_hierarchy_2` +class, applied to the Apollonius graph. It consists of a series of +Apollonius graphs constructed in a manner analogous to the Delaunay +hierarchy by Devillers \cgalCite{d-iirdt-98}. The class +`Apollonius_graph_hierarchy_2` +has exactly the same interface and functionality as the +`Apollonius_graph_2` +class. Using the Apollonius graph hierarchy involves an additional +cost in space and time for maintaining the hierarchy. Our experiments +have shown that it usually pays off to use the hierarchy for inputs +consisting of more than 1,000 circles. This threshold holds for both +the construction of the Apollonius diagram itself, as well as for +nearest neighbor queries. + +\section secapollonius2examples Examples + +\subsection Apollonius_graph_2FirstExample First Example + +\cgalExample{Apollonius_graph_2/ag2_exact_traits.cpp} + +\subsection Apollonius_graph_2SecondExample Second Example + +\cgalExample{Apollonius_graph_2/ag2_exact_traits_sqrt.cpp} + +\subsection Apollonius_graph_2ThirdExample Third Example + +\cgalExample{Apollonius_graph_2/ag2_filtered_traits_no_hidden.cpp} + +\subsection Apollonius_graph_2FourthExample Fourth Example + +\cgalExample{Apollonius_graph_2/ag2_hierarchy.cpp} + +*/ +} /* namespace CGAL */ + diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_graph_2.h b/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_graph_2.h new file mode 100644 index 00000000000..fb82e23c709 --- /dev/null +++ b/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_graph_2.h @@ -0,0 +1,743 @@ + +namespace CGAL { + +/*! +\ingroup PkgApolloniusGraph2Ref + +The class `Apollonius_graph_2` represents the Apollonius graph. +It supports insertions and deletions of sites. + +\tparam Gt is the geometric traits class and must be a model of `ApolloniusGraphTraits_2`. + +\tparam Agds is the Apollonius graph data structure and must be a model of `ApolloniusGraphDataStructure_2` +whose vertex and face must be models of `ApolloniusGraphVertexBase_2` and `TriangulationFaceBase_2`, +respectively. +It defaults to: +\code + CGAL::Triangulation_data_structure_2< + CGAL::Apollonius_graph_vertex_base_2, + CGAL::Triangulation_face_base_2 >` +\endcode + +\cgalHeading{Traversal of the Apollonius Graph} + +An Apollonius graph can be seen as a container of faces and vertices. +Therefore the Apollonius graph provides several iterators and +circulators that allow to traverse it (completely or partially). + +\cgalHeading{Traversal of the Convex Hull} + +Applied on the `infinite_vertex` the `incident_*` functions allow to +visit the vertices on the convex hull and the infinite edges and +faces. Note that a counterclockwise traversal of the vertices adjacent +to the `infinite_vertex` is a clockwise traversal of the convex hull. + +\code{.cpp} +CGAL::Apollonius_graph_2 ag; +CGAL::Apollonius_graph_2::Face f; + +ag.incident_vertices(ag.infinite_vertex()); +ag.incident_vertices(ag.infinite_vertex(), f); + +ag.incident_faces(ag.infinite_vertex()); +ag.incident_faces(ag.infinite_vertex(), f); + +ag.incident_edges(ag.infinite_vertex()); +ag.incident_edges(ag.infinite_vertex(), f); +\endcode + +\cgalModels `DelaunayGraph_2` + +\sa `CGAL::Apollonius_graph_traits_2` +\sa `CGAL::Apollonius_graph_filtered_traits_2` +\sa `CGAL::Apollonius_graph_hierarchy_2` +*/ +template< typename Gt, typename Agds > +class Apollonius_graph_2 { +public: + +/// \name Types +/// @{ + +/*! +A type for the underlying +data structure. +*/ +typedef Agds Data_structure; + +/*! +Same as the `Data_structure` type. This type has been introduced +in order for the `Apollonius_graph_2` class to be a +model of the `DelaunayGraph_2` concept. +*/ +typedef Data_structure Triangulation_data_structure; + +/*! +A type for the geometric traits. +*/ +typedef Gt Geom_traits; + +/*! +A type for the +point defined in the geometric traits. +*/ +typedef Gt::Point_2 Point_2; + +/*! +A type for the Apollonius site, defined in the geometric traits. +*/ +typedef Gt::Site_2 Site_2; + +/// @} + +/// \name Handles And Iterators +/// The vertices and faces of the Apollonius graph are accessed +/// through `handles`, `iterators`, and `circulators`. The iterators +/// and circulators are all bidirectional and non-mutable. The +/// circulators and iterators are assignable to the corresponding +/// handle types, and they are also convertible to the corresponding +/// handles. The edges of the Apollonius graph can also be visited +/// through iterators and circulators, the edge circulators and +/// iterators are also bidirectional and non-mutable. In the +/// following, we call infinite any face or edge incident to +/// the infinite vertex and the infinite vertex itself. Any other +/// feature (face, edge or vertex) of the Apollonius graph is said to +/// be finite. Some iterators (the `All` iterators ) allow to +/// visit finite or infinite features while the others (the `Finite` +/// iterators) visit only finite features. Circulators visit both +/// infinite and finite features. +/// @{ + +/*! +the edge type. +The `Edge(f,i)` is the edge common to faces `f` and +`f.neighbor(i)`. It is also the edge joining the vertices +`vertex(cw(i))` and `vertex(ccw(i))` of `f`. +\pre `i` must be `0`, `1` or `2`. +*/ +typedef Data_structure::Edge Edge; + +/*! +A type for a vertex. +*/ +typedef Data_structure::Vertex Vertex; + +/*! +A type for a face. +*/ +typedef Data_structure::Face Face; + +/*! +A type for a handle to a vertex. +*/ +typedef Data_structure::Vertex_handle Vertex_handle; + +/*! +A type for a handle to a face. +*/ +typedef Data_structure::Face_handle Face_handle; + +/*! +A type for a circulator over vertices incident to a given vertex. +*/ +typedef Data_structure::Vertex_circulator Vertex_circulator; + +/*! +A type for a circulator over faces incident to a given vertex. +*/ +typedef Data_structure::Face_circulator Face_circulator; + +/*! +A type for a circulator over edges incident to a given vertex. +*/ +typedef Data_structure::Edge_circulator Edge_circulator; + +/*! +A type for an iterator over all vertices. +*/ +typedef Data_structure::Vertex_iterator +All_vertices_iterator; + +/*! +A type for an iterator over all faces. +*/ +typedef Data_structure::Face_iterator +All_faces_iterator; + +/*! +A type for an iterator over all edges. +*/ +typedef Data_structure::Edge_iterator +All_edges_iterator; + +/*! +An unsigned integral type. +*/ +typedef Data_structure::size_type size_type; + +/*! +A type for an iterator over finite vertices. +*/ +typedef unspecified_type Finite_vertices_iterator; + +/*! +A type for an iterator over finite faces. +*/ +typedef unspecified_type Finite_faces_iterator; + +/*! +A type for an iterator over finite edges. +*/ +typedef unspecified_type Finite_edges_iterator; + +/// @} + +/// \name Site Iterators +/// In addition to iterators and circulators for vertices and faces, +/// iterators for sites are provided. In particular there are +/// iterators for the entire set of sites, the hidden sites and the +/// visible sites of the Apollonius graph. +/// @{ + +/*! +A type for an iterator over all sites. +*/ +typedef unspecified_type Sites_iterator; + +/*! +A type for an iterator over all visible sites. +*/ +typedef unspecified_type Visible_sites_iterator; + +/*! +A type for an iterator over all hidden sites. +*/ +typedef unspecified_type Hidden_sites_iterator; + +/// @} + +/// \name Creation +/// @{ + +/*! +Creates an +Apollonius graph `ag` using `gt` as geometric traits. +*/ +Apollonius_graph_2(Gt gt=Gt()); + +/*! +Creates an Apollonius graph `ag` using `gt` as +geometric traits and inserts all sites in the range +[`first`, `beyond`). +\pre `Input_iterator` must be a model of `InputIterator`. The value type of `Input_iterator` must be `Site_2`. +*/ +template< class Input_iterator > +Apollonius_graph_2(Input_iterator first, Input_iterator beyond, +Gt gt=Gt()); + +/*! +Copy constructor. All faces and vertices are duplicated. After the +construction, +`ag` and `other` refer to two different Apollonius graphs : if +`other` is modified, `ag` is not. +*/ +Apollonius_graph_2(const Apollonius_graph_2& other); + +/*! +Assignment. If `ag` and `other` are the same object +nothing is done. Otherwise, all the vertices and faces are +duplicated. After the assignment, `ag` and `other` refer to +different Apollonius graphs : if `other` is modified, `ag` is +not. +*/ +Apollonius_graph_2 +operator=(const Apollonius_graph_2& other); + +/// @} + +/// \name Access Functions +/// @{ + +/*! +Returns a reference to the Apollonius graph traits object. +*/ +const Geom_traits& geom_traits() const; + +/*! +Returns a reference to the +underlying data structure. +*/ +const Data_structure& data_structure() const; + +/*! +Same as `data_structure()`. This +method has been added in compliance with the `DelaunayGraph_2` +concept. +*/ +const Data_structure& tds() const; + +/*! +Returns the dimension of the Apollonius graph. +*/ +int dimension() const; + +/*! +Returns the number of finite vertices. +*/ +size_type number_of_vertices() const; + +/*! +Returns the number of visible sites. +*/ +size_type number_of_visible_sites() const; + +/*! +Returns the number of hidden sites. +*/ +size_type number_of_hidden_sites() const; + +/*! +Returns the number of faces (both finite and infinite) of the +Apollonius graph. +*/ +size_type number_of_faces() const; + +/*! +Returns a face incident to the `infinite_vertex`. +*/ +Face_handle infinite_face() const; + +/*! +Returns the `infinite_vertex`. +*/ +Vertex_handle infinite_vertex() const; + +/*! +Returns a vertex distinct from the `infinite_vertex`. +\pre The number of (visible) vertices in the Apollonius graph must be at least one. +*/ +Vertex_handle finite_vertex() const; + +/// @} + +/// \name Face, Edge and Vertex Iterators +/// The following iterators allow respectively to visit finite faces, +/// finite edges and finite vertices of the Apollonius graph. These +/// iterators are non-mutable, bidirectional and their value types are +/// respectively `Face`, `Edge` and `Vertex`. They are all invalidated +/// by any change in the Apollonius graph. The following iterators +/// allow respectively to visit all (both finite and infinite) faces, +/// edges and vertices of the Apollonius graph. These iterators are +/// non-mutable, bidirectional and their value types are respectively +/// `Face`, `Edge` and `Vertex`. They are all invalidated by any +/// change in the Apollonius graph. +/// @{ + +/*! +Starts at an arbitrary finite vertex. +*/ +Finite_vertices_iterator finite_vertices_begin() const; + +/*! +Past-the-end iterator. +*/ +Finite_vertices_iterator finite_vertices_end() const; + +/*! +Starts at an arbitrary finite edge. +*/ +Finite_edges_iterator finite_edges_begin() const; + +/*! +Past-the-end iterator. +*/ +Finite_edges_iterator finite_edges_end() const; + +/*! +Starts at an arbitrary finite face. +*/ +Finite_faces_iterator finite_faces_begin() const; + +/*! +Past-the-end iterator. +*/ +Finite_faces_iterator finite_faces_end() const; + +/*! +Starts at an arbitrary vertex. +*/ +All_vertices_iterator all_vertices_begin() const; + +/*! +Past-the-end iterator. +*/ +All_vertices_iterator all_vertices_end() const; + +/*! +Starts at an arbitrary edge. +*/ +All_edges_iterator all_edges_begin() const; + +/*! +Past-the-end iterator. +*/ +All_edges_iterator all_edges_end() const; + +/*! +Starts at an arbitrary face. +*/ +All_faces_iterator all_faces_begin() const; + +/*! +Past-the-end iterator. +*/ +All_faces_iterator all_faces_end() const; + +/// @} + +/// \name Site Iterators +/// The following iterators allow respectively to visit all sites, the +/// visible sites and the hidden sites. These iterators are +/// non-mutable, bidirectional and their value type is `Site_2`. They +/// are all invalidated by any change in the Apollonius graph. +/// @{ + +/*! +Starts at an arbitrary site. +*/ +Sites_iterator sites_begin() const; + +/*! +Past-the-end iterator. +*/ +Sites_iterator sites_end() const; + +/*! +Starts at an arbitrary visible site. +*/ +Visible_sites_iterator visible_sites_begin() const; + +/*! +Past-the-end iterator. +*/ +Visible_sites_iterator visible_sites_end() const; + +/*! +Starts at an arbitrary hidden site. +*/ +Hidden_sites_iterator hidden_sites_begin() const; + +/*! +Past-the-end iterator. +*/ +Hidden_sites_iterator hidden_sites_end() const; + +/// @} + +/// \name Face, Edge and Vertex Circulators +/// The Apollonius graph also provides circulators that allow to visit +/// respectively all faces or edges incident to a given vertex or all +/// vertices adjacent to a given vertex. These circulators are +/// non-mutable and bidirectional. The operator `operator++` moves the +/// circulator counterclockwise around the vertex while the +/// `operator--` moves clockwise. A face circulator is invalidated by +/// any modification of the face pointed to. An edge circulator is +/// invalidated by any modification in one of the two faces incident +/// to the edge pointed to. A vertex circulator is invalidated by any +/// modification in any of the faces adjacent to the vertex pointed +/// to. +/// @{ + +/*! +Starts at an arbitrary face incident +to `v`. +*/ +Face_circulator incident_faces(Vertex_handle v) const; + +/*! +Starts at face `f`. +\pre Face `f` is incident to vertex `v`. +*/ +Face_circulator incident_faces(Vertex_handle v, Face_handle f) const; + +/*! +Starts at an arbitrary edge incident +to `v`. +*/ +Edge_circulator incident_edges(Vertex_handle v) const; + +/*! +Starts at the first edge of `f` incident to +`v`, in counterclockwise order around `v`. +\pre Face `f` is incident to vertex `v`. +*/ +Edge_circulator incident_edges(Vertex_handle v, Face_handle f) const; + +/*! +Starts at an arbitrary vertex incident +to `v`. +*/ +Vertex_circulator incident_vertices(Vertex_handle v) const; + +/*! +Starts at the first vertex of `f` adjacent to `v` +in counterclockwise order around `v`. +\pre Face `f` is incident to vertex `v`. +*/ +Vertex_circulator incident_vertices(Vertex_handle v, Face_handle f) const; + +/// @} + +/// \name Predicates +/// The class `Apollonius_graph_2` provides methods to test the finite +/// or infinite character of any feature. +/// @{ + +/*! +`true`, iff `v` is the `infinite_vertex`. +*/ +bool +is_infinite(Vertex_handle v) const; + +/*! +`true`, iff face `f` is infinite. +*/ +bool +is_infinite(Face_handle f) const; + +/*! +`true`, iff edge `(f,i)` is infinite. +*/ +bool is_infinite(Face_handle f, int i) const; + +/*! +`true`, iff edge `e` is infinite. +*/ +bool +is_infinite(const Edge& e) const; + +/*! +`true`, iff edge `*ec` is infinite. +*/ +bool +is_infinite(Edge_circulator ec) const; + +/// @} + +/// \name Insertion +/// @{ + +/*! +Inserts the sites in the range +[`first`,`beyond`). The number of sites in the range +[`first`, `beyond`) is returned. +\pre `Input_iterator` must be a model of `InputIterator` and its value type must be `Site_2`. +*/ +template< class Input_iterator > +unsigned int insert(Input_iterator first, Input_iterator beyond); + +/*! +Inserts the +site `s` in the Apollonius graph. If `s` is visible then the +vertex handle of `s` is returned, otherwise +`Vertex_handle(nullptr)` is returned. +*/ +Vertex_handle insert(const Site_2& s); + +/*! +Inserts `s` in the Apollonius graph using the site +associated with `vnear` as an estimate for the nearest neighbor of +the center of `s`. If `s` is visible then the vertex handle of +`s` is returned, otherwise `Vertex_handle(nullptr)` is +returned. +*/ +Vertex_handle insert(const Site_2& s, Vertex_handle vnear); + +/// @} + +/// \name Removal +/// @{ + +/*! +Removes the site +associated to the vertex handle `v` from the Apollonius +graph. +\pre `v` must correspond to a valid finite vertex of the Apollonius graph. +*/ +void remove(Vertex_handle v); + +/// @} + +/// \name Nearest Neighbor Location +/// @{ + +/*! +Finds the nearest neighbor of the point `p`. In other words it +finds the site whose Apollonius cell contains `p`. Ties are broken +arbitrarily and one of the nearest neighbors of `p` is +returned. If there are no visible sites in the Apollonius diagram +`Vertex_handle(nullptr)` is returned. +*/ +Vertex_handle nearest_neighbor(const Point_2& p) const; + +/*! +Finds the nearest neighbor of the point +`p` using the site associated with `vnear` as an +estimate for the nearest neighbor of `p`. Ties are broken +arbitrarily and one of the nearest neighbors of `p` is +returned. If there are no visible sites in the Apollonius diagram +`Vertex_handle(nullptr)` is returned. +*/ +Vertex_handle nearest_neighbor(const Point_2& p, Vertex_handle vnear) const; + +/// @} + +/// \name Access to the Dual +/// The `Apollonius_graph_2` class provides access to the duals of the +/// faces of the graph. The dual of a face of the Apollonius graph is +/// a site. If the originating face is infinite, its dual is a site +/// with center at infinity (or equivalently with infinite weight), +/// which means that it can be represented geometrically as a line. If +/// the originating face is finite, its dual is a site with finite +/// center and weight. In the following three methods the returned +/// object is assignable to either `Site_2` or `Gt::Line_2`, depending +/// on whether the corresponding face of the Apollonius graph is +/// finite or infinite, respectively. +/// @{ + +/*! +Returns the +dual corresponding to the face handle `f`. The returned object can +be assignable to one of the following: `Site_2`, `Gt::Line_2`. +*/ +Gt::Object_2 dual(Face_handle f) const; + +/*! +Returns the +dual of the face to which `it` points to. The returned object can +be assignable to one of the following: `Site_2`, `Gt::Line_2`. +*/ +Gt::Object_2 dual(All_faces_iterator it) const; + +/*! +Returns +the dual of the face to which `it` points to. The returned +object can be assignable to one of the following: `Site_2`, +`Gt::Line_2`. +*/ +Gt::Object_2 dual(Finite_faces_iterator it) const; + +/// @} + +/// \name I/O +/// @{ + +/*! +Draws the Apollonius graph to +the stream `str`. +\pre The following operators must be defined: +`Stream& operator<<(Stream&, Gt::Segment_2)`, +`Stream& operator<<(Stream&, Gt::Ray_2)`. + +*/ +template< class Stream > +Stream& draw_primal(Stream& str) const; + +/*! +Draws the dual of the +Apollonius graph, i.e., the Apollonius diagram, to the stream +`str`. +\pre The following operators must be defined: +`Stream& operator<<(Stream&, Gt::Segment_2)`, +`Stream& operator<<(Stream&, Gt::Ray_2)`, +`Stream& operator<<(Stream&, Gt::Line_2)`. + +*/ +template < class Stream > +Stream& draw_dual(Stream& str) const; + +/*! +Draws the edge +`e` of the Apollonius graph to the stream `str`. +\pre The following operators must be defined: +`Stream& operator<<(Stream&, Gt::Segment_2)`, +`Stream& operator<<(Stream&, Gt::Ray_2)`. + +*/ +template< class Stream > +Stream& draw_primal_edge(const Edge& e, Stream& str) const; + +/*! +Draws the dual of the +edge `e` to the stream `str`. The dual of `e` is an edge +of the Apollonius diagram. +\pre The following operators must be defined: +`Stream& operator<<(Stream&, Gt::Segment_2)`, +`Stream& operator<<(Stream&, Gt::Ray_2)`, +`Stream& operator<<(Stream&, Gt::Line_2)`. + +*/ +template< class Stream > +Stream& draw_dual_edge(const Edge& e, Stream& str) const; + +/*! +Writes the current +state of the Apollonius graph to an output stream. In particular, +all visible and hidden sites are written as well as the +underlying combinatorial data structure. +*/ +void file_output(std::ostream& os) const; + +/*! +Reads the state of the +Apollonius graph from an input stream. +*/ +void file_input(std::istream& is); + +/*! +Writes the current state of the Apollonius graph to an output stream. +*/ +std::ostream& operator<<(std::ostream& os, const Apollonius_graph_2& ag) const; + +/*! +Reads the state of the Apollonius graph from an input stream. +*/ +std::istream& operator>>(std::istream& is, const Apollonius_graph_2& ag); + +/// @} + +/// \name Validity Check +/// @{ + +/*! +Checks the validity of the Apollonius graph. If `verbose` is +`true` a short message is sent to `std::cerr`. If `level` +is 0, only the data structure is validated. If `level` is 1, then +both the data structure and the Apollonius graph are +validated. Negative values of `level` always return true, and +values greater than 1 are equivalent to `level` being 1. +*/ +bool is_valid(bool verbose = false, int level = 1) const; + +/// @} + +/// \name Miscellaneous +/// @{ + +/*! +Clears all contents of the Apollonius graph. +*/ +void clear(); + +/*! +The Apollonius graphs +`other` and `ag` are swapped. `ag.swap(other)` should +be preferred to `ag = other` or to `ag(other)` if +`other` is deleted afterwards. +*/ +void swap(Apollonius_graph_2& other); + +/// @} + +}; /* end Apollonius_graph_2 */ +} /* end namespace CGAL */ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_graph_filtered_traits_2.h b/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_graph_filtered_traits_2.h new file mode 100644 index 00000000000..155a7b240cb --- /dev/null +++ b/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_graph_filtered_traits_2.h @@ -0,0 +1,78 @@ + +namespace CGAL { + +/*! +\ingroup PkgApolloniusGraph2Ref + +The class `Apollonius_graph_filtered_traits_2` provides a model for the +`ApolloniusGraphTraits_2` concept. + +The class `Apollonius_graph_filtered_traits_2` uses the filtering technique \cgalCite{cgal:bbp-iayed-01} +to achieve traits for the `Apollonius_graph_2` class +with efficient and exact predicates given an exact +kernel `EK` and a filtering kernel `FK`. The geometric +constructions associated provided by this class are equivalent +to those provided by the traits class +`Apollonius_graph_traits_2`, which means that they may +be inexact. + +This class has six template parameters. The first, third and fifth +template parameters must be a models of the `Kernel` concept. The +second, fourth and sixth template parameters correspond to how +predicates are evaluated. There are two predefined possible values for +`Method_tag`, namely `CGAL::Field_with_sqrt_tag` and +`CGAL::Integral_domain_without_division_tag`. The first one must be used when the number type +used in the representation supports the exact evaluation of signs of +expressions involving all four basic operations and square roots, +whereas the second one requires the exact evaluation of signs of +ring-type expressions, i.e., expressions involving only additions, +subtractions and multiplications. +The way the predicates are evaluated is discussed in +\cgalCite{cgal:ke-ppawv-02}, \cgalCite{cgal:ke-rctac-03}. + +The default values for the template parameters are as follows: +`CM = CGAL::Integral_domain_without_division_tag`, +`EK = CGAL::Simple_cartesian`, +`EM = CM`, +`FK = CGAL::Simple_cartesian >`, +`FM = CM`. + +\cgalModels `ApolloniusGraphTraits_2` + +\sa `Kernel` +\sa `ApolloniusGraphTraits_2` +\sa `CGAL::Integral_domain_without_division_tag` +\sa `CGAL::Field_with_sqrt_tag` +\sa `CGAL::Apollonius_graph_2` +\sa `CGAL::Apollonius_graph_traits_2` + +*/ +template< typename CK, typename CM, typename EK, typename EM, typename FK, typename FM > +class Apollonius_graph_filtered_traits_2 { +public: + +/// \name Creation +/// @{ + +/*! +%Default constructor. +*/ +Apollonius_graph_filtered_traits_2(); + +/*! +Copy +constructor. +*/ +Apollonius_graph_filtered_traits_2 +(Apollonius_graph_filtered_traits_2 other); + +/*! +Assignment +operator. +*/ +Apollonius_graph_filtered_traits_2 operator=(other); + +/// @} + +}; /* end Apollonius_graph_filtered_traits_2 */ +} /* end namespace CGAL */ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_graph_hierarchy_2.h b/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_graph_hierarchy_2.h new file mode 100644 index 00000000000..778dd9160e1 --- /dev/null +++ b/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_graph_hierarchy_2.h @@ -0,0 +1,231 @@ + +namespace CGAL { + +/*! +\ingroup PkgApolloniusGraph2Ref + +We provide an alternative to the class +`Apollonius_graph_2` for the dynamic +construction of the Apollonius graph. The `Apollonius_graph_hierarchy_2` class maintains +a hierarchy of Apollonius graphs. The bottom-most level of the +hierarchy contains the full Apollonius diagram. A site that +is in level \f$ i\f$, is in level \f$ i+1\f$ with probability \f$ 1/\alpha\f$ +where \f$ \alpha > 1\f$ is some constant. The difference between the +`Apollonius_graph_2` class and the +`Apollonius_graph_hierarchy_2` is on how the nearest neighbor location is done. Given a +point \f$ p\f$ the location is done as follows: at the top most level we +find the nearest neighbor of \f$ p\f$ as in the +`Apollonius_graph_2` class. At every subsequent level \f$ i\f$ +we use the nearest neighbor found at level \f$ i+1\f$ to find the nearest +neighbor at level \f$ i\f$. This is a variant of the corresponding +hierarchy for points found in \cgalCite{d-iirdt-98}. + +The class has two template parameters which have essentially the same +meaning as in the `Apollonius_graph_2` class. + +\tparam Gt is the geometric traits class and must be a model of `ApolloniusGraphTraits_2`. + +\tparam Agds is the Apollonius graph data structure and must be a model of `ApolloniusGraphDataStructure_2` +whose vertex and face must be models of `ApolloniusGraphHierarchyVertexBase_2` and `TriangulationFaceBase_2`, respectively. +It defaults to: +\code + CGAL::Triangulation_data_structure_2< + CGAL::Apollonius_graph_hierarchy_vertex_base_2 >, + CGAL::Triangulation_face_base_2 > +\endcode + +\cgalHeading{Heritage} + +The `Apollonius_graph_hierarchy_2` class derives publicly from the +`Apollonius_graph_2` class. The interface is +the same with its base class. In the sequel only the methods +overridden are documented. + +`Apollonius_graph_hierarchy_2` does not introduce other types than those introduced by +its base class `Apollonius_graph_2`. + +\sa `CGAL::Apollonius_graph_2` +\sa `CGAL::Apollonius_graph_traits_2` +\sa `CGAL::Apollonius_graph_filtered_traits_2` +*/ +template< typename Gt, typename Agds > +class Apollonius_graph_hierarchy_2 : public CGAL::Apollonius_graph_2 { +public: + +/// \name Creation +/// @{ + +/*! +Creates an hierarchy of Apollonius graphs using `gt` as +geometric traits. +*/ +Apollonius_graph_hierarchy_2(Gt gt=Gt()); + +/*! +Creates an Apollonius graph hierarchy using +`gt` as geometric traits and inserts all sites in the +range [`first`, `beyond`). +*/ +template< class Input_iterator > +Apollonius_graph_hierarchy_2(Input_iterator first, Input_iterator beyond, Gt gt=Gt()); + +/*! +Copy constructor. All faces, vertices, and inter-level pointers +are duplicated. After the construction, `agh` and `other` refer +to two different Apollonius graph hierarchies: if +`other` is modified, `agh` is not. +*/ +Apollonius_graph_hierarchy_2(const Apollonius_graph_hierarchy_2& other); + +/*! +Assignment. All faces, vertices and inter-level pointers +are duplicated. After the construction, `agh` and `other` refer +to two different Apollonius graph hierarchies: if +`other` is modified, `agh` is not. +*/ +Apollonius_graph_hierarchy_2 +operator=(Apollonius_graph_hierarchy_2 +other); + +/// @} + +/// \name Insertion +/// @{ + +/*! +Inserts the sites in the range +[`first`,`beyond`). The number of sites in the range +[`first`, `beyond`) is returned. +\pre `Input_iterator` must be a model of `InputIterator` and its value type must be `Site_2`. +*/ +template< class Input_iterator > +unsigned int insert(Input_iterator first, Input_iterator beyond); + +/*! +Inserts the +site `s` in the Apollonius graph hierarchy. If `s` +is visible then the vertex handle of `s` is returned, otherwise +`Vertex_handle(nullptr)` is returned. +*/ +Vertex_handle insert(const Site_2& s); + +/*! +Inserts `s` in the Apollonius graph hierarchy using the +site associated with `vnear` as +an estimate for the nearest neighbor of the center of `s`. +If `s` is visible then the vertex handle of `s` is +returned, otherwise `Vertex_handle(nullptr)` is returned. +A call to this method is equivalent to `agh.insert(s);` and it has +been added for the sake of conformity with the interface of the +`Apollonius_graph_2` class. +*/ +Vertex_handle insert(const Site_2& s, Vertex_handle vnear); + +/// @} + +/// \name Removal +/// @{ + +/*! +Removes the site +associated to the vertex handle `v` from the Apollonius +graph hierarchy. +\pre `v` must correspond to a valid finite vertex of the Apollonius graph hierarchy. +*/ +void remove(Vertex_handle v); + +/// @} + +/// \name Nearest Neighbor Location +/// @{ + +/*! +Finds the nearest neighbor of the point `p`. In other words it +finds the site whose Apollonius cell contains `p`. Ties are broken +arbitrarily and one of the nearest neighbors of `p` is +returned. If there are no visible sites in the Apollonius diagram +`Vertex_handle(nullptr)` is returned. +*/ +Vertex_handle nearest_neighbor(const Point_2& p) const; + +/*! +Finds the nearest neighbor of the point +`p`. If there are no visible sites in the Apollonius diagram +`Vertex_handle(nullptr)` is returned. +A call to this method is equivalent to +`agh.nearest_neighbor(p);` and it has been added for the sake of +conformity with the interface of the +`Apollonius_graph_2` class. +*/ +Vertex_handle nearest_neighbor(const Point_2& p, Vertex_handle vnear) const; + +/// @} + +/// \name I/O +/// @{ + +/*! +Writes the current +state of the Apollonius graph hierarchy to an output stream. In particular, +all visible and hidden sites are written as well as the +underlying combinatorial hierarchical data structure. +*/ +void file_output(std::ostream& os) const; + +/*! +Reads the state of the +Apollonius graph hierarchy from an input stream. +*/ +void file_input(std::istream& is); + +/*! +Writes the current state of the Apollonius graph hierarchy to an +output stream. +*/ +std::ostream& operator<<(std::ostream& os, Apollonius_graph_hierarchy_2 agh) const; + +/*! +Reads the state of the Apollonius graph hierarchy from an input stream. +*/ +std::istream& operator>>(std::istream& is, Apollonius_graph_hierarchy_2 agh); + +/// @} + +/// \name Validity Check +/// @{ + +/*! +Checks the validity of the Apollonius graph hierarchy. If +`verbose` is `true` a short message is sent to +`std::cerr`. If `level` is 0, the data structure at all levels +is validated, as well as the inter-level pointers. If `level` is +1, then the data structure at all levels is validated, the inter-level +pointers are validated and all levels of the Apollonius graph +hierarchy are also validated. Negative values of `level` always +return `true`, and values greater than 1 are equivalent to +`level` being 1. +*/ +bool is_valid(bool verbose = false, int level = 1) const; + +/// @} + +/// \name Miscellaneous +/// @{ + +/*! +Clears all contents of the Apollonius graph +hierarchy. +*/ +void clear(); + +/*! +The Apollonius graph hierarchies `other` and `agh` are +swapped. `agh.swap(other)` should be preferred to `agh = other` +or to `agh(other)` if `other` is deleted afterwards. +*/ +void swap(Apollonius_graph_hierarchy_2& other); + +/// @} + +}; /* end Apollonius_graph_hierarchy_2 */ +} /* end namespace CGAL */ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_graph_hierarchy_vertex_base_2.h b/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_graph_hierarchy_vertex_base_2.h new file mode 100644 index 00000000000..c09d6255ab5 --- /dev/null +++ b/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_graph_hierarchy_vertex_base_2.h @@ -0,0 +1,49 @@ + +namespace CGAL { + +/*! +\ingroup PkgApolloniusGraph2Ref + +The class `Apollonius_graph_hierarchy_vertex_base_2` provides a model for the +`ApolloniusGraphHierarchyVertexBase_2` concept, which is the +vertex base required by the +`Apollonius_graph_hierarchy_2` class. The class +`Apollonius_graph_hierarchy_vertex_base_2` is templated by a class `Agvb` which must be a model +of the `ApolloniusGraphVertexBase_2` concept. + +\cgalModels `ApolloniusGraphHierarchyVertexBase_2` + +\sa `CGAL::Apollonius_graph_vertex_base_2` +\sa `CGAL::Triangulation_data_structure_2` +\sa `CGAL::Apollonius_graph_hierarchy_2` +*/ +template< typename Agvb > +class Apollonius_graph_hierarchy_vertex_base_2 : Agvb { +public: + +/// \name Creation +/// @{ + +/*! +%Default constructor. +*/ +Apollonius_graph_hierarchy_vertex_base_2(); + +/*! +Constructs a vertex associated with the site `s` and +embedded at the center of `s`. +*/ +Apollonius_graph_hierarchy_vertex_base_2(const Site_2& s); + +/*! +Constructs a vertex associated with +the site `s`, embedded at the center of `s`, +and pointing to the face associated with the face +handle `f`. +*/ +Apollonius_graph_hierarchy_vertex_base_2(const Site_2& s, Face_handle f); + +/// @} + +}; /* end Apollonius_graph_hierarchy_vertex_base_2 */ +} /* end namespace CGAL */ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_graph_traits_2.h b/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_graph_traits_2.h new file mode 100644 index 00000000000..3fe29ef740b --- /dev/null +++ b/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_graph_traits_2.h @@ -0,0 +1,54 @@ + +namespace CGAL { + +/*! +\ingroup PkgApolloniusGraph2Ref + +The class `Apollonius_graph_traits_2` provides a model for the +`ApolloniusGraphTraits_2` concept. +This class has two template parameters. The first template parameter +must be a model of the `Kernel` concept. The second template +parameter corresponds to how predicates are evaluated. There are two +predefined possible values for `Method_tag`, namely +`CGAL::Field_with_sqrt_tag` and `CGAL::Integral_domain_without_division_tag`. The first one +must be used when the number type used in the representation supports +the exact evaluation of signs of expressions involving all four basic +operations and square roots, whereas the second one requires the exact +evaluation of signs of ring-type expressions, i.e., expressions +involving only additions, subtractions and multiplications. The +default value for `Method_tag` is `CGAL::Integral_domain_without_division_tag`. +The way the predicates are evaluated is discussed in +\cgalCite{cgal:ke-ppawv-02}, \cgalCite{cgal:ke-rctac-03}. + +\cgalModels `ApolloniusGraphTraits_2` + +\sa `CGAL::Apollonius_graph_2` +\sa `CGAL::Apollonius_graph_filtered_traits_2` +*/ +template< typename K, typename Method_tag > +class Apollonius_graph_traits_2 { +public: + +/// \name Creation +/// @{ + +/*! +%Default constructor. +*/ +Apollonius_graph_traits_2(); + +/*! +Copy constructor. +*/ +Apollonius_graph_traits_2(const Apollonius_graph_traits_2& other); + +/*! +Assignment operator. +*/ +Apollonius_graph_traits_2 +operator=(const Apollonius_graph_traits_2& other); + +/// @} + +}; /* end Apollonius_graph_traits_2 */ +} /* end namespace CGAL */ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_graph_vertex_base_2.h b/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_graph_vertex_base_2.h new file mode 100644 index 00000000000..ae9eca3dc6e --- /dev/null +++ b/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_graph_vertex_base_2.h @@ -0,0 +1,54 @@ + +namespace CGAL { + +/*! +\ingroup PkgApolloniusGraph2Ref + +The class `Apollonius_graph_vertex_base_2` provides a model for the +`ApolloniusGraphVertexBase_2` concept which is the vertex base +required by the `ApolloniusGraphDataStructure_2` concept. The +class `Apollonius_graph_vertex_base_2` has two template arguments, the first being the +geometric traits of the Apollonius graph and should be a model of the +concept `ApolloniusGraphTraits_2`. The second is a Boolean which +controls whether hidden sites are actually stored. Such a +control is important if the user is not interested in hidden sites +and/or if only insertions are made, in which case no hidden +site can become visible. If `StoreHidden` is set to +`true`, hidden sites are stored, otherwise they are +discarded. By default `StoreHidden` is set to `true`. + +\cgalModels `ApolloniusGraphVertexBase_2` + +\sa `CGAL::Triangulation_data_structure_2` +\sa `CGAL::Apollonius_graph_hierarchy_vertex_base_2` +*/ +template< typename Gt, typename StoreHidden > +class Apollonius_graph_vertex_base_2 { +public: + +/// \name Creation +/// @{ + +/*! +%Default constructor. +*/ +Apollonius_graph_vertex_base_2(); + +/*! +Constructs a vertex associated with the site `s` and +embedded at the center of `s`. +*/ +Apollonius_graph_vertex_base_2(const Site_2& s); + +/*! +Constructs a vertex associated with +the site `s`, embedded at the center of `s`, +and pointing to the face associated with the face +handle `f`. +*/ +Apollonius_graph_vertex_base_2(const Site_2& s, Face_handle f); + +/// @} + +}; /* end Apollonius_graph_vertex_base_2 */ +} /* end namespace CGAL */ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_site_2.h b/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_site_2.h new file mode 100644 index 00000000000..162a6e46259 --- /dev/null +++ b/Apollonius_graph_2/doc/Apollonius_graph_2/CGAL/Apollonius_site_2.h @@ -0,0 +1,76 @@ + +namespace CGAL { + +/*! +\ingroup PkgApolloniusGraph2Ref + +The class `Apollonius_site_2` is a model for the concept +`ApolloniusSite_2`. It is parametrized by a template parameter +`K` which must be a model of the `Kernel` concept. + +\cgalModels `ApolloniusSite_2` + +\cgalHeading{Types} + +The class `Apollonius_site_2` does not introduce any types in addition to the +concept `ApolloniusSite_2`. + +\cgalHeading{I/O} + +The I/O operators are defined for `iostream`. + +The information output in the `iostream` is: the point of the +Apollonius site and its weight. + +\sa `CGAL::Qt_widget` +\sa `CGAL::Apollonius_graph_traits_2` +\sa `CGAL::Apollonius_graph_filtered_traits_2` +*/ +template< typename K > +class Apollonius_site_2 { +public: + +/// \name Creation +/// @{ + +/*! + +*/ +Apollonius_site_2(Point_2 p=Point_2(), Weight w= Weight(0)); + +/*! +Copy constructor. +*/ +Apollonius_site_2(const Apollonius_site_2& other); + +/// @} + +}; /* end Apollonius_site_2 */ + +/*! +Inserts the +Apollonius site `s` into the stream `os`. +\note Included through `CGAL/IO/Qt_widget_Apollonius_site_2.h`. +\pre The insert operator must be defined for `Point_2` and `Weight`. +\relates Apollonius_site_2 +*/ +std::ostream& operator<<(std::ostream& os, const Apollonius_site_2& s) const; + +/*! +Reads an Apollonius site from the stream `is` and assigns it +to `s`. +\note Included through `CGAL/IO/Qt_widget_Apollonius_site_2.h`. +\pre The extract operator must be defined for `Point_2` and `Weight`. +\relates Apollonius_site_2 +*/ +std::istream& operator>>(std::istream& is, const Apollonius_site_2& s); + +/*! +Inserts the Apollonius site `s` into the `Qt_widget` stream `w`. +\note Included through `CGAL/IO/Qt_widget_Apollonius_site_2.h`. +\pre The insert operator must be defined for `K::Circle_2`. +\relates Apollonius_site_2 +*/ +Qt_widget& operator<<(Qt_widget& w, const Apollonius_site_2& s) const; + +} /* end namespace CGAL */ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/Concepts/ApolloniusGraphDataStructure_2.h b/Apollonius_graph_2/doc/Apollonius_graph_2/Concepts/ApolloniusGraphDataStructure_2.h new file mode 100644 index 00000000000..8c3209da2e8 --- /dev/null +++ b/Apollonius_graph_2/doc/Apollonius_graph_2/Concepts/ApolloniusGraphDataStructure_2.h @@ -0,0 +1,68 @@ + +/*! +\ingroup PkgApolloniusGraph2Concepts +\cgalConcept + +The concept `ApolloniusGraphDataStructure_2` refines the concept +`TriangulationDataStructure_2`. In addition +it provides two methods for the insertion and removal of a degree 2 +vertex in the data structure. The insertion method adds a new vertex +to the specified edge, thus creating two new edges. Moreover, it +creates two new faces that have the two newly created edges in +common (see figure below). The removal method performs the reverse +operation. + +\image html insert_degree_2.png +\image latex insert_degree_2.png + +
Insertion and removal of degree 2 vertices. Left to right: +The edge `(f,i)` is replaced by two edges by means of inserting a +vertex `v` on the edge. The faces \f$ f_1\f$ and \f$ f_2\f$ are +created. Right to left: the faces \f$ f_1\f$ and \f$ f_2\f$ are +destroyed. The vertex `v` is deleted and its two adjacent edges are +merged.
+ +We only describe the additional requirements with respect to the +`TriangulationDataStructure_2` concept. + +\cgalRefines `TriangulationDataStructure_2` + +\cgalHasModel `CGAL::Triangulation_data_structure_2` + +\sa `TriangulationDataStructure_2` +\sa `ApolloniusGraphVertexBase_2` +\sa `TriangulationFaceBase_2` + +*/ + +class ApolloniusGraphDataStructure_2 { +public: + +/// \name Insertion +/// @{ + +/*! +inserts a degree two vertex and two faces adjacent to it that have two common edges. + +The edge defined by the face handle `f` and the integer `i` is duplicated. It returns a handle +to the vertex created. +*/ +Vertex_handle insert_degree_2(Face_handle f, int i); + +/// @} + +/// \name Removal +/// @{ + +/*! +Removes a degree 2 +vertex and the two faces adjacent to it. The two edges of the star of +`v` that are not incident to it are collapsed. +\pre The degree of `v` must be equal to 2. +*/ +void remove_degree_2(Vertex_handle v); + +/// @} + +}; /* end ApolloniusGraphDataStructure_2 */ + diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/Concepts/ApolloniusGraphHierarchyVertexBase_2.h b/Apollonius_graph_2/doc/Apollonius_graph_2/Concepts/ApolloniusGraphHierarchyVertexBase_2.h new file mode 100644 index 00000000000..8145923b669 --- /dev/null +++ b/Apollonius_graph_2/doc/Apollonius_graph_2/Concepts/ApolloniusGraphHierarchyVertexBase_2.h @@ -0,0 +1,85 @@ + +/*! +\ingroup PkgApolloniusGraph2Concepts +\cgalConcept + +The vertex of an Apollonius graph +included in an Apollonius graph hierarchy has to provide +some pointers to the corresponding vertices in the +graphs of the next and preceding levels. +Therefore, the concept `ApolloniusGraphHierarchyVertexBase_2` +refines the concept `ApolloniusGraphVertexBase_2`, by +adding two vertex handles to the corresponding vertices for the +next and previous level graphs. + +\cgalRefines `ApolloniusGraphVertexBase_2` + +\cgalHeading{Types} + +`ApolloniusGraphHierarchyVertexBase_2` does not introduce any +types in addition to those of `ApolloniusGraphVertexBase_2`. + +\cgalHasModel `CGAL::Apollonius_graph_hierarchy_vertex_base_2 >` + +\sa `ApolloniusGraphDataStructure_2` +\sa `CGAL::Apollonius_graph_hierarchy_2` +\sa `CGAL::Triangulation_data_structure_2` +*/ +class ApolloniusGraphHierarchyVertexBase_2 { +public: + +/// \name Creation +/// @{ + +/*! +%Default constructor. +*/ +ApolloniusGraphHierarchyVertexBase_2(); + +/*! +Constructs a vertex associated with the site `s` and +embedded at the center of `s`. +*/ +ApolloniusGraphHierarchyVertexBase_2(Site_2 s).; + +/*! +Constructs a vertex associated with +the site `s`, embedded at the center of `s`, +and pointing to face `f`. +*/ +ApolloniusGraphHierarchyVertexBase_2(Site_2 s, Face_handle f).; + +/// @} + +/// \name Operations +/// @{ + +/*! +Returns a handle to the corresponding +vertex of the next level Apollonius graph. If such a vertex does not +exist `Vertex_handle(nullptr)` is returned. +*/ +Vertex_handle up(); + +/*! +Returns a handle to the corresponding +vertex of the previous level Apollonius graph. +*/ +Vertex_handle down(); + +/*! +Sets the handle for the +vertex of the next level Apollonius graph. +*/ +void set_up(Vertex_handle u); + +/*! +Sets the handle for the +vertex of the previous level Apollonius graph; +*/ +void set_down(Vertex_handle d); + +/// @} + +}; /* end ApolloniusGraphHierarchyVertexBase_2 */ + diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/Concepts/ApolloniusGraphTraits_2.h b/Apollonius_graph_2/doc/Apollonius_graph_2/Concepts/ApolloniusGraphTraits_2.h new file mode 100644 index 00000000000..5ef6ff44848 --- /dev/null +++ b/Apollonius_graph_2/doc/Apollonius_graph_2/Concepts/ApolloniusGraphTraits_2.h @@ -0,0 +1,397 @@ + +/*! +\ingroup PkgApolloniusGraph2Concepts +\cgalConcept + +\cgalRefines `TriangulationTraits_2` + +The concept `ApolloniusGraphTraits_2` provides the traits +requirements for the `Apollonius_graph_2` class. In particular, +it provides a type `Site_2`, which must be a model of the concept +`ApolloniusSite_2`. It also provides +constructions for sites and several function object +types for the predicates. + +\cgalHasModel `CGAL::Apollonius_graph_traits_2` +\cgalHasModel `CGAL::Apollonius_graph_filtered_traits_2` + +\sa `CGAL::Apollonius_graph_2` +\sa `CGAL::Apollonius_graph_traits_2` +\sa `CGAL::Apollonius_graph_filtered_traits_2` + +*/ + +class ApolloniusGraphTraits_2 { +public: + +/// \name Types +/// @{ + +/*! +A type for a point. +*/ +typedef unspecified_type Point_2; + +/*! +A type for an Apollonius site. Must be a model +of the concept `ApolloniusSite_2`. +*/ +typedef unspecified_type Site_2; + +/*! +A type for a line. Only required if access to +the dual of the Apollonius graph is required or if the primal +or dual diagram are inserted in a stream. +*/ +typedef unspecified_type Line_2; + +/*! +A type for a ray. Only required if access to +the dual of the Apollonius graph is required or if the primal +or dual diagram are inserted in a stream. +*/ +typedef unspecified_type Ray_2; + +/*! +A type for a segment. Only required if access to +the dual of the Apollonius graph is required or if the primal +or dual diagram are inserted in a stream. +*/ +typedef unspecified_type Segment_2; + +/*! +A type representing different types of objects +in two dimensions, namely: `Point_2`, `Site_2`, +`Line_2`, `Ray_2` and `Segment_2`. +*/ +typedef unspecified_type Object_2; + +/*! +A type for the field number type of sites. +*/ +typedef unspecified_type FT; + +/*! +A type for the ring number type of sites. +*/ +typedef unspecified_type RT; + +/*! +Must provide `template bool operator() ( T& t, +Object_2 o)` which assigns `o` to `t` if `o` was +constructed from an object of type `T`. Returns +`true`, if the assignment was possible. +*/ +typedef unspecified_type Assign_2; + +/*! +Must provide `template +Object_2 operator()( T t)` that constructs an object of type +`Object_2` that contains `t` and returns it. +*/ +typedef unspecified_type Construct_object_2; + +/*! + +A constructor for a point of the Apollonius diagram equidistant +from three sites. Must provide +`Point_2 operator()(Site_2 s1, Site_2 s2, Site_2 s3)`, which +constructs a point equidistant from the sites `s1`, `s2` and +`s3`. + +*/ +typedef unspecified_type Construct_Apollonius_vertex_2; + +/*! +A constructor for +a dual Apollonius site (a site whose center is a +vertex of the Apollonius diagram and its weight is the common +distance of its center from the three defining sites). +Must provide `Site_2 operator()(Site_2 s1, +Site_2 s2, Site_2 s3)`, which constructs a +dual site whose center \f$ c\f$ is equidistant from `s1`, `s2` and +`s3`, and its weight is equal to the (signed) distance of \f$ c\f$ +from `s1` (or `s2` or `s3`). + +Must also provide `Line_2 operator()(Site_2 s1, Site_2 s2)`, which +constructs a line bitangent to `s1` and `s2`. This line is the +dual site of `s1`, `s2` and the site at infinity; it can be +viewed as a dual Apollonius site whose center is at infinity +and its weight is infinite. + +*/ +typedef unspecified_type Construct_Apollonius_site_2; + +/*! +A predicate object type. Must +provide `Comparison_result operator()(Site_2 s1, +Site_2 s2)`, which compares the \f$ x\f$-coordinates of the centers of +`s1` and `s2`. +*/ +typedef unspecified_type Compare_x_2; + +/*! +A predicate object type. Must +provide `Comparison_result operator()(Site_2 s1, +Site_2 s2)`, which compares the \f$ y\f$-coordinates of the centers of +`s1` and `s2`. +*/ +typedef unspecified_type Compare_y_2; + +/*! +A predicate object type. Must +provide `Comparison_result operator()(Site_2 s1, +Site_2 s2)`, which compares the weights of `s1` +and `s2`. +*/ +typedef unspecified_type Compare_weight_2; + +/*! +A predicate object type. Must +provide `Orientation operator()(Site_2 s1, +Site_2 s2, Site_2 s3)`, which performs the +usual orientation test for the centers of the three sites +`s1`, `s2` and `s3`. + +Must also provide `Orientation operator()(Site_2 s1, Site_2 s2, +Site_2 s3, Site_2 p1, Site_2 p2)`, +which performs the usual orientation test for the Apollonius vertex of +`s1`, `s2`, `s3` and the centers of `p1` and +`p2`. +\pre the Apollonius vertex of `s1`, `s2` and `s3` must exist. +*/ +typedef unspecified_type Orientation_2; + +/*! +A predicate object type. Must +provide `bool operator()(Site_2 s1, +Site_2 s2)`, which returns `true` if the circle +corresponding to `s2` is contained in the closure of the disk +corresponding to `s1`, `false` otherwise. +*/ +typedef unspecified_type Is_hidden_2; + +/*! +A predicate object type. +Must provide `Oriented_side operator()(Site_2 s1, +Site_2 s2, Point_2 p)`, which returns +the oriented side of the bisector of `s1` and `s2` that +contains `p`. Returns `ON_POSITIVE_SIDE` if `p` lies in +the half-space of `s1` (i.e., `p` is closer to `s1` than +`s2`); returns `ON_NEGATIVE_SIDE` if `p` lies in the +half-space of `s2`; returns `ON_ORIENTED_BOUNDARY` if `p` +lies on the bisector of `s1` and `s2`. +*/ +typedef unspecified_type Oriented_side_of_bisector_2; + +/*! +A predicate object type. +Must provide `Sign operator()(Site_2 s1, Site_2 +s2, Site_2 s3, Site_2 q)`, which +returns the sign of the distance of `q` from the dual Apollonius +site of `s1`, `s2`, `s3`. +\pre the dual Apollonius site of `s1`, `s2`, `s3` must exist. + +Must also provide `Sign operator()(Site_2 s1, +Site_2 s2, Site_2 q)`, which returns the sign of the distance of +`q` from the bitangent line of `s1`, `s2` (a degenerate +dual Apollonius site, with its center at infinity). +*/ +typedef unspecified_type Vertex_conflict_2; + +/*! +A predicate object type. +Must provide `bool operator()(Site_2 s1, Site_2 s2, Site_2 s3, Site_2 s4, Site_2 q, bool b)`. +The sites `s1`, `s2`, `s3` and `s4` define an Apollonius edge that lies on the +bisector of `s1` and `s2` and has as endpoints the Apollonius +vertices defined by the triplets `s1`, `s2`, `s3` and +`s1`, `s4` and `s2`. The Boolean `b` denotes if the +two Apollonius vertices are in conflict with the site +`q` (in which case `b` should be `true`, otherwise +`false`). In case that `b` is `true`, the predicate +returns `true` if and only if the entire Apollonius edge is in +conflict with `q`. If `b` is `false`, the predicate returns +`false` if and only if `q` is not in conflict with the +Apollonius edge. +\pre the Apollonius vertices of `s1`, `s2`, `s3`, and `s1`, `s4`, `s2` must exist. + +Must also provide `bool operator()(Site_2 s1, +Site_2 s2, Site_2 s3, Site_2 q, bool b)`. The +sites `s1`, `s2`, `s3` and the site at infinity +\f$ s_\infty\f$ define an Apollonius edge that lies on the bisector of +`s1` and `s2` and has as endpoints the Apollonius vertices +defined by the triplets `s1`, `s2`, `s3` and `s1`, +\f$ s_\infty\f$ and `s2` (the second Apollonius vertex is actually at +infinity). The Boolean `b` denotes if the two Apollonius vertices +are in conflict with the site `q` (in which case `b` +should be `true`, otherwise `false`). +In case that `b` is `true`, the predicate +returns `true` if and only if the entire Apollonius edge is in +conflict with `q`. If `b` is `false`, the predicate returns +`false` if and only if `q` is not in conflict with the +Apollonius edge. +\pre the Apollonius vertex of `s1`, `s2`, `s3` must exist. + +Must finally provide `bool operator()(Site_2 s1, +Site_2 s2, Site_2 q, bool b)`. The +sites `s1`, `s2` and the site at infinity +\f$ s_\infty\f$ define an Apollonius edge that lies on the bisector of +`s1` and `s2` and has as endpoints the Apollonius vertices +defined by the triplets `s1`, `s2`, \f$ s_\infty\f$ and `s1`, +\f$ s_\infty\f$ and `s2` (both Apollonius vertices are actually at +infinity). The Boolean `b` denotes if the two Apollonius vertices +are in conflict with the site `q` (in which case `b` +should be `true`, otherwise `false`). +In case that `b` is `true`, the predicate +returns `true` if and only if the entire Apollonius edge is in +conflict with `q`. If `b` is `false`, the predicate returns +`false` if and only if `q` is not in conflict with the +Apollonius edge. +*/ +typedef unspecified_type Finite_edge_interior_conflict_2; + +/*! +A predicate +object type. Must provide `bool operator()(Site_2 s1, +Site_2 s2, Site_2 s3, Site_2 q, bool b)`. The +sites \f$ s_\infty\f$, `s1`, `s2` and `s3` define an +Apollonius edge that lies on the bisector of \f$ s_\infty\f$ and `s1` +and has as endpoints the Apollonius vertices defined by the triplets +\f$ s_\infty\f$, `s1`, `s2` and \f$ s_\infty\f$, `s3` and +`s1`. The Boolean `b` denotes if the two Apollonius vertices +are in conflict with the site `q` (in which case `b` +should be `true`, otherwise `false`. +In case that `b` is `true`, the predicate +returns `true` if and only if the entire Apollonius edge is in +conflict with `q`. If `b` is `false`, the predicate returns +`false` if and only if `q` is not in conflict with the +Apollonius edge. +*/ +typedef unspecified_type Infinite_edge_interior_conflict_2; + +/*! +A predicate object type. +Must provide `bool operator()(Site_2 s1, Site_2 +s2, Site_2 s3, Site_2 s4)`. It returns `true` if +the Apollonius edge defined by `s1`, `s2`, `s3` and +`s4` is degenerate, `false` otherwise. An Apollonius edge is +called degenerate if its two endpoints coincide. +\pre the Apollonius vertices of `s1`, `s2`, `s3`, and `s1`, `s4`, `s2` must exist. +*/ +typedef unspecified_type Is_degenerate_edge_2; + +/// @} + +/// \name Creation +/// @{ + +/*! +Default constructor. +*/ +ApolloniusGraphTraits_2(); + +/*! +Copy constructor. +*/ +ApolloniusGraphTraits_2(ApolloniusGraphTraits_2 other); + +/*! +Assignment operator. +*/ +ApolloniusGraphTraits_2 operator=(ApolloniusGraphTraits_2 other); + +/// @} + +/// \name Access to predicate objects +/// @{ + +/*! + +*/ +Compare_x_2 compare_x_2_object(); + +/*! + +*/ +Compare_y_2 compare_y_2_object(); + +/*! + +*/ +Compare_weight_2 compare_weight_2_object(); + +/*! + +*/ +Orientation_2 orientation_2_object(); + +/*! + +*/ +Is_hidden_2 is_hidden_2_object(); + +/*! + +*/ +Oriented_side_of_bisector_2 +oriented_side_of_bisector_test_2_object(); + +/*! + +*/ +Vertex_conflict_2 vertex_conflict_2_object(); + +/*! + +*/ +Finite_edge_interior_conflict_2 +finite_edge_interior_conflict_2_object(); + +/*! + +*/ +Infinite_edge_interior_conflict_2 +infinite_edge_interior_conflict_2_object(); + +/*! + +*/ +Is_degenerate_edge_2 is_degenerate_edge_2_object(); + +/// @} + +/// \name Access to constructor objects +/// @{ + +/*! + +*/ +Construct_object_2 +construct_object_2_object(); + +/*! + +*/ +Construct_Apollonius_vertex_2 +construct_Apollonius_vertex_2_object(); + +/*! + +*/ +Construct_Apollonius_site_2 +construct_Apollonius_site_2_object(); + +/// @} + +/// \name Access to other objects +/// @{ + +/*! + +*/ +Assign_2 assign_2_object(); + +/// @} + +}; /* end ApolloniusGraphTraits_2 */ + diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/Concepts/ApolloniusGraphVertexBase_2.h b/Apollonius_graph_2/doc/Apollonius_graph_2/Concepts/ApolloniusGraphVertexBase_2.h new file mode 100644 index 00000000000..e25279179aa --- /dev/null +++ b/Apollonius_graph_2/doc/Apollonius_graph_2/Concepts/ApolloniusGraphVertexBase_2.h @@ -0,0 +1,166 @@ + +/*! +\ingroup PkgApolloniusGraph2Concepts +\cgalConcept + +The concept `ApolloniusGraphVertexBase_2` describes the +requirements for the vertex base class of the +`ApolloniusGraphDataStructure_2` concept. A vertex stores an +Apollonius site and provides access to one of its incident faces +through a `Face_handle`. In addition, it maintains a container of +sites. The container stores the hidden sites related to the vertex. + +\cgalRefines `TriangulationVertexBase_2` + +\cgalHasModel `CGAL::Apollonius_graph_vertex_base_2` + +\sa `ApolloniusGraphDataStructure_2` +\sa `CGAL::Apollonius_graph_2` +\sa `CGAL::Triangulation_data_structure_2` +*/ +class ApolloniusGraphVertexBase_2 { +public: + +/// \name Types +/// @{ + +/*! +A type for the geometric traits that defines +the site stored. \pre The type `Geom_traits` must define the type `Site_2`. +*/ +typedef unspecified_type Geom_traits; + +/*! +A Boolean that indicates if +hidden sites are actually stored or not. Its value is `true` if +hidden sites are stored, `false` otherwise. +*/ +typedef unspecified_type Store_hidden; + +/*! +A type for the site stored. +\pre This type must coincide with the type `Geom_traits::Site_2`. +*/ +typedef unspecified_type Site_2; + +/*! +A type for the +Apollonius graph data structure, to which the vertex belongs to. +*/ +typedef unspecified_type Apollonius_graph_data_structure_2; + +/*! +A type for the vertex handle of the +Apollonius graph data structure. +*/ +typedef unspecified_type Vertex_handle; + +/*! +A type for the face handle of the +Apollonius graph data structure. +*/ +typedef unspecified_type Face_handle; + +/*! +An iterator that +iterates over the hidden sites in the hidden sites +container of the vertex. +\pre Must be a model of `Iterator`. +*/ +typedef unspecified_type Hidden_sites_iterator; + +/// @} + +/// \name Creation +/// @{ + +/*! +%Default constructor. +*/ +ApolloniusGraphVertexBase_2(); + +/*! +Constructs a vertex associated with the Apollonius site `s` and +embedded at the center of `s`. +*/ +ApolloniusGraphVertexBase_2(Site_2 s); + +/*! +Constructs a vertex associated with +the site `s`, embedded at the center of `s`, +and pointing to the face associated with the face handle `f`. +*/ +ApolloniusGraphVertexBase_2(Site_2 s, +Face_handle f); + +/// @} + +/// \name Access Functions +/// @{ + +/*! +Returns the Apollonius site. +*/ +Site_2 site(); + +/*! +Returns a handle to an incident face. +*/ +Face_handle face(); + +/*! +Returns the number of hidden sites in the hidden +sites container. +*/ +unsigned int number_of_hidden_sites(); + +/*! +Starts at an arbitrary hidden site. +*/ +Hidden_sites_iterator +hidden_sites_begin(); + +/*! +Past-the-end iterator. +*/ +Hidden_sites_iterator hidden_sites_end(); + +/// @} + +/// \name Setting and unsetting +/// @{ + +/*! +Sets the Apollonius site. +*/ +void set_site(Site_2 s); + +/*! +Sets the incident face. +*/ +void set_face(Face_handle f); + +/*! +Adds a hidden site to the container of hidden sites. +*/ +void add_hidden_site(Site_2 s); + +/*! +Clears the container of hidden sites. +*/ +void clear_hidden_sites_container(); + +/// @} + +/// \name Checking +/// @{ + +/*! +Performs any required tests on a vertex. +*/ +bool is_valid(bool verbose, int level) const; + +/// @} + +}; /* end ApolloniusGraphVertexBase_2 */ + diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/Concepts/ApolloniusSite_2.h b/Apollonius_graph_2/doc/Apollonius_graph_2/Concepts/ApolloniusSite_2.h new file mode 100644 index 00000000000..9f1dd5ff9dd --- /dev/null +++ b/Apollonius_graph_2/doc/Apollonius_graph_2/Concepts/ApolloniusSite_2.h @@ -0,0 +1,78 @@ + +/*! +\ingroup PkgApolloniusGraph2Concepts +\cgalConcept + +The concept `ApolloniusSite_2` provides the requirements for an +Apollonius site class. + +\sa `ApolloniusGraphTraits_2` +\sa `CGAL::Apollonius_site_2` +\sa `CGAL::Apollonius_graph_traits_2` +\sa `CGAL::Apollonius_graph_filtered_traits_2` + +*/ + +class ApolloniusSite_2 { +public: + +/// \name Types +/// @{ + +/*! +The point type. +*/ +typedef unspecified_type Point_2; + +/*! +The field number type. +*/ +typedef unspecified_type FT; + +/*! +The ring number type. +*/ +typedef unspecified_type RT; + +/*! +The weight type. +\pre It must be the same as `FT`. +*/ +typedef unspecified_type Weight; + +/// @} + +/// \name Creation +/// @{ + +/*! + +*/ +ApolloniusSite2(Point_2 p=Point_2(), Weight w= Weight(0)); + +/*! +Copy constructor. +*/ +ApolloniusSite_2(ApolloniusSite_2 other); + +/// @} + +/// \name Access Functions +/// @{ + +/*! +Returns the center of the Apollonius +site. +*/ +Point_2 point() const; + +/*! +Returns the weight of the +Apollonius site. +*/ +Weight weight() const; + +/// @} + +}; /* end ApolloniusSite_2 */ + diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/Doxyfile.in b/Apollonius_graph_2/doc/Apollonius_graph_2/Doxyfile.in new file mode 100644 index 00000000000..22e3143eadf --- /dev/null +++ b/Apollonius_graph_2/doc/Apollonius_graph_2/Doxyfile.in @@ -0,0 +1,9 @@ +@INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS} + +PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - 2D Apollonius Graphs (Delaunay Graphs of Disks)" +EXCLUDE_SYMBOLS += Agvb + + + + + diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/PackageDescription.txt b/Apollonius_graph_2/doc/Apollonius_graph_2/PackageDescription.txt new file mode 100644 index 00000000000..f82d98db1ed --- /dev/null +++ b/Apollonius_graph_2/doc/Apollonius_graph_2/PackageDescription.txt @@ -0,0 +1,63 @@ +/// \defgroup PkgApolloniusGraph2Ref 2D Apollonius Graphs (Delaunay Graphs of Disks) Reference +/// \defgroup PkgApolloniusGraph2Concepts Concepts +/// \ingroup PkgApolloniusGraph2Ref +/*! +\addtogroup PkgApolloniusGraph2Ref +\todo check generated documentation +\cgalPkgDescriptionBegin{2D Apollonius Graphs (Delaunay Graphs of Disks),PkgApolloniusGraph2} +\cgalPkgPicture{CircleVoronoi.png} +\cgalPkgSummaryBegin +\cgalPkgAuthors{Menelaos Karavelas and Mariette Yvinec} +\cgalPkgDesc{Algorithms for computing the Apollonius graph in two dimensions. The Apollonius graph is the dual of the Apollonius diagram, also known as the additively weighted Voronoi diagram. The latter can be thought of as the Voronoi diagram of a set of disks under the Euclidean metric, and it is a generalization of the standard Voronoi diagram for points. The algorithms provided are dynamic.} +\cgalPkgManuals{Chapter_2D_Apollonius_Graphs,PkgApolloniusGraph2Ref} +\cgalPkgSummaryEnd +\cgalPkgShortInfoBegin +\cgalPkgSince{3.0} +\cgalPkgDependsOn{\ref PkgTDS2} +\cgalPkgBib{cgal:ky-ag2} +\cgalPkgLicense{\ref licensesGPL "GPL"} +\cgalPkgDemo{2D Apollonius Graph,apollonius_graph_2.zip} +\cgalPkgShortInfoEnd +\cgalPkgDescriptionEnd + +An Apollonius graph is the dual of the Apollonius diagram, also known +as the additively weighted Voronoi diagram. It is essentially the +Voronoi diagram of a set of disks, where the distance of a +point of the plane from a disk is defined as the Euclidean +distance of the point and the center of the circle, minus the radius +of the disk. + +\cgal provides the class `CGAL::Apollonius_graph_2` for +computing the 2D Apollonius graph. The two template parameters must be +models of the `ApolloniusGraphTraits_2` and +`ApolloniusGraphDataStructure_2` concepts. The first concept is +related to the geometric objects and predicates associated with +Apollonius graphs, whereas the second concept refers to the data +structure used to represent the Apollonius graph. The classes +`Apollonius_graph_traits_2` and +`Triangulation_data_structure_2` are models of the +aforementioned concepts. + +\cgalClassifedRefPages + +\cgalCRPSection{Concepts} + +- `ApolloniusSite_2` +- `ApolloniusGraphTraits_2` +- `ApolloniusGraphDataStructure_2` +- `ApolloniusGraphVertexBase_2` +- `ApolloniusGraphHierarchyVertexBase_2` + +\cgalCRPSection{Classes} + +- `CGAL::Apollonius_graph_2` +- `CGAL::Apollonius_site_2` +- `CGAL::Apollonius_graph_traits_2` +- `CGAL::Apollonius_graph_filtered_traits_2` +- `CGAL::Apollonius_graph_vertex_base_2` +- `CGAL::Apollonius_graph_hierarchy_2` +- `CGAL::Apollonius_graph_hierarchy_vertex_base_2` + + +*/ + diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/dependencies b/Apollonius_graph_2/doc/Apollonius_graph_2/dependencies new file mode 100644 index 00000000000..6270b1d0d3b --- /dev/null +++ b/Apollonius_graph_2/doc/Apollonius_graph_2/dependencies @@ -0,0 +1,10 @@ +Manual +Kernel_23 +STL_Extension +Algebraic_foundations +Circulator +Stream_support +Voronoi_diagram_2 +Number_types +TDS_2 +Triangulation_2 diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/examples.txt b/Apollonius_graph_2/doc/Apollonius_graph_2/examples.txt new file mode 100644 index 00000000000..3638b5b2a55 --- /dev/null +++ b/Apollonius_graph_2/doc/Apollonius_graph_2/examples.txt @@ -0,0 +1,6 @@ +/*! +\example Apollonius_graph_2/ag2_exact_traits.cpp +\example Apollonius_graph_2/ag2_exact_traits_sqrt.cpp +\example Apollonius_graph_2/ag2_filtered_traits_no_hidden.cpp +\example Apollonius_graph_2/ag2_hierarchy.cpp +*/ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/CircleVoronoi.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/CircleVoronoi.png new file mode 100644 index 00000000000..c2d17a7b6b9 Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/CircleVoronoi.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/CircleVoronoiLarge.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/CircleVoronoiLarge.png new file mode 100644 index 00000000000..3853018ed35 Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/CircleVoronoiLarge.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-both_vertices.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-both_vertices.png new file mode 100644 index 00000000000..29d8d50ba5a Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-both_vertices.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-both_vertices_bw.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-both_vertices_bw.png new file mode 100644 index 00000000000..7429546634a Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-both_vertices_bw.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-entire_edge.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-entire_edge.png new file mode 100644 index 00000000000..38406040236 Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-entire_edge.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-entire_edge_bw.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-entire_edge_bw.png new file mode 100644 index 00000000000..5ba40cca5d0 Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-entire_edge_bw.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-interior.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-interior.png new file mode 100644 index 00000000000..1423065e66a Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-interior.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-interior_bw.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-interior_bw.png new file mode 100644 index 00000000000..f393d39aeb2 Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-interior_bw.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-left_vertex.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-left_vertex.png new file mode 100644 index 00000000000..35f6078cf9f Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-left_vertex.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-left_vertex_bw.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-left_vertex_bw.png new file mode 100644 index 00000000000..6186621146a Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-left_vertex_bw.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-no_conflict.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-no_conflict.png new file mode 100644 index 00000000000..4d544baf562 Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-no_conflict.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-no_conflict_bw.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-no_conflict_bw.png new file mode 100644 index 00000000000..90ba2fbb7cd Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-no_conflict_bw.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-right_vertex.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-right_vertex.png new file mode 100644 index 00000000000..f2629ffd7b8 Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-right_vertex.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-right_vertex_bw.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-right_vertex_bw.png new file mode 100644 index 00000000000..908c9e41ad1 Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-right_vertex_bw.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-vertex_conflict-false.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-vertex_conflict-false.png new file mode 100644 index 00000000000..2b67ce1e7fc Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-vertex_conflict-false.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-vertex_conflict-false_bw.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-vertex_conflict-false_bw.png new file mode 100644 index 00000000000..93a0a00da0a Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-vertex_conflict-false_bw.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-vertex_conflict-true.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-vertex_conflict-true.png new file mode 100644 index 00000000000..4e2caf6b1dd Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-vertex_conflict-true.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-vertex_conflict-true_bw.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-vertex_conflict-true_bw.png new file mode 100644 index 00000000000..da68029a930 Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius-vertex_conflict-true_bw.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius_diagram.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius_diagram.png new file mode 100644 index 00000000000..13d893e7cc8 Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius_diagram.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius_diagram_bw.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius_diagram_bw.png new file mode 100644 index 00000000000..76437491b4b Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius_diagram_bw.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius_graph.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius_graph.png new file mode 100644 index 00000000000..768a1c74070 Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius_graph.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius_graph_bw.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius_graph_bw.png new file mode 100644 index 00000000000..fbcca9aa0cd Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/apollonius_graph_bw.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig/insert_degree_2.png b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/insert_degree_2.png new file mode 100644 index 00000000000..dbf53288ceb Binary files /dev/null and b/Apollonius_graph_2/doc/Apollonius_graph_2/fig/insert_degree_2.png differ diff --git a/Apollonius_graph_2/doc/Apollonius_graph_2/fig_src/insert_degree_2.fig b/Apollonius_graph_2/doc/Apollonius_graph_2/fig_src/insert_degree_2.fig new file mode 100644 index 00000000000..acc8413f6f4 --- /dev/null +++ b/Apollonius_graph_2/doc/Apollonius_graph_2/fig_src/insert_degree_2.fig @@ -0,0 +1,75 @@ +#FIG 3.2 +Landscape +Center +Inches +Letter +100.00 +Single +7 +1200 2 +6 1200 2100 4425 7050 +6 1200 4200 1500 4425 +4 1 0 50 0 1 18 0.0000 4 120 120 1275 4350 v\001 +4 0 0 50 0 0 14 0.0000 4 150 105 1350 4425 0\001 +-6 +6 4125 4650 4425 4875 +4 1 0 50 0 1 18 0.0000 4 120 120 4200 4800 v\001 +4 0 0 50 0 0 14 0.0000 4 150 105 4275 4875 1\001 +-6 +1 3 0 1 0 0 50 0 20 0.000 1 0.0000 1500 4500 75 75 1500 4500 1575 4500 +1 3 0 1 0 0 50 0 20 0.000 1 0.0000 2775 2400 75 75 2775 2400 2850 2400 +1 3 0 1 0 0 50 0 20 0.000 1 0.0000 2775 6675 75 75 2775 6675 2850 6675 +1 3 0 1 0 0 50 0 20 0.000 1 0.0000 4050 4500 75 75 4050 4500 4125 4500 +2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 0 0 2 + 1500 4500 4050 4500 +2 3 0 2 0 7 52 0 -1 0.000 0 0 -1 0 0 5 + 2775 2400 1500 4500 2775 6675 4050 4500 2775 2400 +4 1 0 50 0 1 18 0.0000 4 195 75 3000 2325 i\001 +4 1 0 50 0 1 18 0.0000 4 255 75 2775 3825 f\001 +4 1 0 50 0 1 18 0.0000 4 240 75 3000 6975 j\001 +4 1 0 50 0 1 18 0.0000 4 180 120 2775 5325 g\001 +-6 +6 7650 2325 10875 6750 +6 7650 4200 7950 4425 +4 1 0 50 0 1 18 0.0000 4 120 120 7725 4350 v\001 +4 0 0 50 0 0 14 0.0000 4 150 105 7800 4425 0\001 +-6 +6 10575 4650 10875 4875 +4 1 0 50 0 1 18 0.0000 4 120 120 10650 4800 v\001 +4 0 0 50 0 0 14 0.0000 4 150 105 10725 4875 1\001 +-6 +6 8850 4125 9150 4425 +4 1 0 50 0 1 18 0.0000 4 255 75 8925 4350 f\001 +4 0 0 50 0 0 14 0.0000 4 150 105 9000 4425 1\001 +-6 +6 8850 4650 9150 4950 +4 1 0 50 0 1 18 0.0000 4 255 75 8925 4875 f\001 +4 0 0 50 0 0 14 0.0000 4 150 105 9000 4950 2\001 +-6 +1 3 0 1 0 0 50 0 20 0.000 1 0.0000 9346 4494 75 75 9346 4494 9421 4494 +1 3 0 1 0 0 50 0 20 0.000 1 0.0000 8025 4500 75 75 8025 4500 8100 4500 +1 3 0 1 0 0 50 0 20 0.000 1 0.0000 9300 2400 75 75 9300 2400 9375 2400 +1 3 0 1 0 0 50 0 20 0.000 1 0.0000 9300 6675 75 75 9300 6675 9375 6675 +1 3 0 1 0 0 50 0 20 0.000 1 0.0000 10575 4500 75 75 10575 4500 10650 4500 +2 1 0 2 0 7 51 0 -1 0.000 0 0 -1 0 0 2 + 8025 4500 10575 4500 +2 3 0 2 0 7 52 0 -1 0.000 0 0 -1 0 0 5 + 9300 2400 8025 4500 9300 6675 10575 4500 9300 2400 +3 0 0 2 0 7 50 0 -1 0.000 0 0 0 3 + 8025 4500 9300 5550 10575 4500 + 0.000 1.000 0.000 +3 0 0 2 0 7 50 0 -1 0.000 0 0 0 3 + 8025 4500 9375 3450 10575 4500 + 0.000 1.000 0.000 +4 1 0 50 0 1 18 0.0000 4 255 75 9300 3525 f\001 +4 1 0 50 0 1 18 0.0000 4 180 120 9300 5625 g\001 +4 1 0 50 0 1 18 0.0000 4 120 120 9525 4425 v\001 +-6 +2 1 0 4 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 2 1 4.00 240.00 480.00 + 4950 4275 7200 4275 +2 1 0 4 0 7 50 0 -1 0.000 0 0 -1 1 0 2 + 2 1 4.00 240.00 480.00 + 7200 4725 4950 4725 +4 1 0 50 0 1 14 0.0000 4 150 690 6450 5025 removal\001 +4 1 0 50 0 1 14 0.0000 4 150 780 5625 4125 insertion\001 diff --git a/Apollonius_graph_2/examples/Apollonius_graph_2/CMakeLists.txt b/Apollonius_graph_2/examples/Apollonius_graph_2/CMakeLists.txt new file mode 100644 index 00000000000..a72517973a0 --- /dev/null +++ b/Apollonius_graph_2/examples/Apollonius_graph_2/CMakeLists.txt @@ -0,0 +1,18 @@ +# Created by the script cgal_create_cmake_script +# This is the CMake script for compiling a CGAL application. + +cmake_minimum_required(VERSION 3.1...3.20) +project(Apollonius_graph_2_Examples) + +find_package(CGAL REQUIRED COMPONENTS Core) + +include(${CGAL_USE_FILE}) + +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Apollonius_graph_2/examples/Apollonius_graph_2/README b/Apollonius_graph_2/examples/Apollonius_graph_2/README new file mode 100644 index 00000000000..522e49b6b0f --- /dev/null +++ b/Apollonius_graph_2/examples/Apollonius_graph_2/README @@ -0,0 +1,23 @@ +This is the examples directory for the Apollonius_graph_2 package +There are 4 example programs in this directory. Each one of these is +aimed at describing a different usage for the Apollonius_graph_2 +package. In particular: + +* ag2_exact_traits.C: a very basic example. It uses an exact number + type that supports ring operations to achieve robustness. + +* ag2_exact_traits_sqrt.C: it shows how to change the method the predicates + are evaluated. By default the predicates use only the operations +,-,* + and these are the only operations that is assumed they are exact. In + this example we show how to change that and how to define the traits + class so that the operations +,-,*,/,sqrt are used and are assumed + exact. Again an exact number type is used as the number type. + +* ag2_filtered_traits_no_hidden.C: a variation of the first example. The + filtered traits are now used instead of and exact number type. We also + show how to use another parameter for the algorithm, namely the one + that indicates whether hidden weighted points are to be stored or not. + +* ag2_hierarchy.C: same as the previous example except the fact that now + we store the hidden weighted points and on top of that we use a + hierarchy of Apollonius graphs. diff --git a/Apollonius_graph_2/examples/Apollonius_graph_2/ag2_exact_traits.cpp b/Apollonius_graph_2/examples/Apollonius_graph_2/ag2_exact_traits.cpp new file mode 100644 index 00000000000..7794f2331b0 --- /dev/null +++ b/Apollonius_graph_2/examples/Apollonius_graph_2/ag2_exact_traits.cpp @@ -0,0 +1,54 @@ +// standard includes +#include +#include +#include + +// the number type +#include + + +// example that uses an exact number type + +typedef CGAL::MP_Float NT; + +// *** WARNING *** +// The use of a kernel based on an exact number type is highly inefficient. +// It is used in this example primarily for illustration purposes. +// In an efficiency critical context, and/or for the purposes of +// benchmarking the Apollonius_graph_filtered_traits_2<> class should +// be used. + +// choose the kernel +#include + +typedef CGAL::Simple_cartesian Kernel; + +// typedefs for the traits and the algorithm + +#include +#include + +typedef CGAL::Apollonius_graph_traits_2 Traits; +typedef CGAL::Apollonius_graph_2 Apollonius_graph; + + + +int main() +{ + std::ifstream ifs("data/sites.cin"); + assert( ifs ); + + Apollonius_graph ag; + Apollonius_graph::Site_2 site; + + // read the sites and insert them in the Apollonius graph + while ( ifs >> site ) { + ag.insert(site); + } + + // validate the Apollonius graph + assert( ag.is_valid(true, 1) ); + std::cout << std::endl; + + return 0; +} diff --git a/Apollonius_graph_2/examples/Apollonius_graph_2/ag2_exact_traits_sqrt.cpp b/Apollonius_graph_2/examples/Apollonius_graph_2/ag2_exact_traits_sqrt.cpp new file mode 100644 index 00000000000..bdd70099b7a --- /dev/null +++ b/Apollonius_graph_2/examples/Apollonius_graph_2/ag2_exact_traits_sqrt.cpp @@ -0,0 +1,71 @@ +#include + +// standard includes +#include +#include +#include + +#if defined(CGAL_USE_CORE) || defined(CGAL_USE_LEDA) +# include +#endif + +// *** WARNING *** +// The use of a kernel based on an exact number type is highly inefficient. +// It is used in this example primarily for illustration purposes. +// In an efficiency critical context, and/or for the purposes of +// benchmarking the Apollonius_graph_filtered_traits_2<> class should +// be used. + +#if defined(CGAL_USE_CORE) || defined(CGAL_USE_LEDA) +// If LEDA is present use leda_real as the exact number type +// Otherwise if CORE is present use CORE's Expr as the exact number type +typedef CGAL::Exact_algebraic NT; + +#else + +// Otherwise just use double. This may cause numerical errors but it +// is still worth doing it to show how to define correctly the traits +// class +typedef double NT; + +#endif + + +#include + +typedef CGAL::Simple_cartesian Kernel; + + +// typedefs for the traits and the algorithm + +#include +#include + +// the traits class is now going to assume that the operations +// +,-,*,/ and sqrt are supported exactly +typedef +CGAL::Apollonius_graph_traits_2 Traits; + +typedef CGAL::Apollonius_graph_2 Apollonius_graph; + + + +int main() +{ + std::ifstream ifs("data/sites.cin"); + assert( ifs ); + + Apollonius_graph ag; + Apollonius_graph::Site_2 site; + + // read the sites and insert them in the Apollonius graph + while ( ifs >> site ) { + ag.insert(site); + } + + // validate the Apollonius graph + assert( ag.is_valid(true, 1) ); + std::cout << std::endl; + + return 0; +} diff --git a/Apollonius_graph_2/examples/Apollonius_graph_2/ag2_filtered_traits_no_hidden.cpp b/Apollonius_graph_2/examples/Apollonius_graph_2/ag2_filtered_traits_no_hidden.cpp new file mode 100644 index 00000000000..01628dee56f --- /dev/null +++ b/Apollonius_graph_2/examples/Apollonius_graph_2/ag2_filtered_traits_no_hidden.cpp @@ -0,0 +1,59 @@ +// standard includes +#include +#include +#include + +// example that uses the filtered traits + +// choose the representation +#include + +typedef CGAL::Simple_cartesian Rep; + +#include +#include +#include +#include +#include + +// typedef for the traits; the filtered traits class is used +typedef CGAL::Apollonius_graph_filtered_traits_2 Traits; + +// typedefs for the algorithm + +// With the second template argument in the vertex base class being +// false, we indicate that there is no need to store the hidden sites. +// One case where this is indeed not needed is when we only do +// insertions, like in the main program below. +typedef CGAL::Apollonius_graph_vertex_base_2 Vb; +typedef CGAL::Triangulation_face_base_2 Fb; +typedef CGAL::Triangulation_data_structure_2 Agds; +typedef CGAL::Apollonius_graph_2 Apollonius_graph; + + +int main() +{ + std::ifstream ifs("data/sites.cin"); + assert( ifs ); + + Apollonius_graph ag; + Apollonius_graph::Site_2 site; + + // read the sites and insert them in the Apollonius graph + while ( ifs >> site ) { + ag.insert(site); + } + + // validate the Apollonius graph + assert( ag.is_valid(true, 1) ); + std::cout << std::endl; + + // now remove all sites + std::cout << "Removing all sites... " << std::flush; + while ( ag.number_of_vertices() > 0 ) { + ag.remove( ag.finite_vertex() ); + } + std::cout << "done!" << std::endl << std::endl; + + return 0; +} diff --git a/Apollonius_graph_2/examples/Apollonius_graph_2/ag2_hierarchy.cpp b/Apollonius_graph_2/examples/Apollonius_graph_2/ag2_hierarchy.cpp new file mode 100644 index 00000000000..c8b490415b5 --- /dev/null +++ b/Apollonius_graph_2/examples/Apollonius_graph_2/ag2_hierarchy.cpp @@ -0,0 +1,61 @@ +// standard includes +#include +#include +#include + +// example that uses the filtered traits + +#include +#include + +// constructions kernel (inexact) +typedef CGAL::Simple_cartesian CK; + +// exact kernel +typedef CGAL::Simple_cartesian EK; + + +// typedefs for the traits and the algorithm + +#include +#include + + +// Type definition for the traits class. +// In this example we explicitly define the exact kernel. We also +// explicitly define what operations to use for the evaluation of the +// predicates and constructions, when the filtering and the exact +// kernels are used respectively. +// Note that the operations allowed for the filtering and the +// constructions (field operations plus square roots) are different +// from the operations allowed when the exact kernel is used (ring +// operations). +typedef CGAL::Field_with_sqrt_tag CM; +typedef CGAL::Integral_domain_without_division_tag EM; +typedef CGAL::Apollonius_graph_filtered_traits_2 Traits; + +// Now we use the Apollonius graph hierarchy. +// The hierarchy is faster for inputs consisting of about more than +// 1,000 sites +typedef CGAL::Apollonius_graph_hierarchy_2 Apollonius_graph; + + + +int main() +{ + std::ifstream ifs("data/hierarchy.cin"); + assert( ifs ); + + Apollonius_graph ag; + Apollonius_graph::Site_2 site; + + // read the sites and insert them in the Apollonius graph + while ( ifs >> site ) { + ag.insert(site); + } + + // validate the Apollonius graph + assert( ag.is_valid(true, 1) ); + + return 0; +} diff --git a/Apollonius_graph_2/examples/Apollonius_graph_2/data/hierarchy.cin b/Apollonius_graph_2/examples/Apollonius_graph_2/data/hierarchy.cin new file mode 100644 index 00000000000..5de3093d381 --- /dev/null +++ b/Apollonius_graph_2/examples/Apollonius_graph_2/data/hierarchy.cin @@ -0,0 +1,500 @@ +-199.259 28.7176 0.613542 +141.606 166.862 1.13775 +-5.56519 -156.845 3.31008 +50.3311 161.726 1.07564 +-64.7456 -87.8027 4.06628 +14.8532 105.665 2.20139 +76.5577 90.566 0.840065 +-49.4694 41.2512 3.67553 +-174.917 128.685 2.38958 +188.251 -109.254 1.15084 +16.9685 -57.0234 1.1601 +-16.1697 -7.94008 0.430175 +26.9857 83.0797 2.86061 +-11.288 -52.1136 0.989749 +100.909 33.9376 2.68043 +6.5738 -40.7596 0.366094 +-102.86 135.351 3.82307 +138.391 -197.444 0.704697 +67.0764 96.5988 1.01824 +157.823 -112.234 0.871374 +-99.2007 -20.1674 3.58348 +92.8592 72.6406 0.881359 +-24.0611 107.055 3.71868 +123.825 -64.0966 1.07758 +-42.2371 15.0832 4.83895 +117.003 -170.482 2.42112 +52.3544 -141.195 3.63537 +54.9108 164.65 2.86525 +-48.4905 -178.974 1.20371 +39.2751 -97.515 0.676493 +-180.892 -27.805 1.93648 +91.7483 -141.127 0.597223 +-1.19714 -70.6179 2.79646 +134.706 -173.123 1.84428 +-50.2105 -86.9171 3.81631 +-20.693 -99.8014 2.77885 +38.112 93.8881 0.933284 +2.76229 -15.2827 4.11967 +23.7883 -186.062 1.01354 +126.273 -89.7657 4.00448 +-101.532 -35.6463 4.24332 +-42.6583 119.272 2.89018 +86.7238 167.05 0.375211 +113.6 -9.23294 4.55904 +-173.317 138.309 1.43141 +-73.1181 43.6142 3.67274 +-179.23 -134.078 1.64915 +5.48731 -59.4149 4.18367 +19.4249 -129.841 1.98103 +129.659 -48.7584 1.05945 +-105.987 -128.4 2.2903 +-186.715 -188.935 4.25707 +180.336 42.2795 2.84112 +-28.8974 72.2964 1.76112 +-90.5882 37.0195 2.09466 +153.026 151.532 3.68069 +-181.052 45.3517 3.94031 +-40.4665 177.283 1.5089 +29.6921 111.977 4.25171 +180.934 -129.54 3.37245 +-147.467 -44.7849 4.54762 +-136.401 138.439 4.71368 +105.878 79.0047 4.46788 +-21.8252 -93.7059 1.60666 +-184.806 47.184 2.97431 +166.727 -185.243 2.38713 +12.0782 109.212 2.62399 +-10.6384 24.4369 4.61816 +-98.6612 145.149 2.48931 +-28.2016 85.2863 2.25098 +127.013 -44.9173 2.90765 +65.4525 -81.108 3.70263 +-55.5428 -104.013 2.52612 +50.7513 -146.583 4.7533 +-102.065 -18.0503 4.94323 +-87.3077 -180.106 4.52731 +-178.096 10.865 2.17829 +46.3413 -179.216 4.54531 +-8.50957 190.237 0.812045 +-123.223 -10.6186 2.95952 +31.8595 169.46 2.04719 +150.751 2.0718 0.365349 +-153.262 -101.717 2.17106 +-99.845 100.372 0.305455 +82.1047 80.6358 1.52965 +101.999 76.0943 2.9383 +-87.1359 38.2792 3.2121 +-66.3517 -187.458 1.29137 +-76.115 176.167 3.685 +113.266 -158.869 4.64471 +82.7263 77.8927 2.54295 +-115.202 -158.332 1.92735 +-16.9193 -129.104 2.51157 +-116.548 44.5811 3.76351 +164.088 69.0175 2.28982 +40.1826 191.389 1.06481 +-121.538 26.4532 2.47561 +-108.996 -116.578 4.14621 +-132.829 -13.2689 0.694777 +-91.698 -118.469 4.61061 +186.195 -146.892 3.14469 +-172.137 56.5441 4.20466 +-101.241 -189.268 1.49317 +143.34 11.6578 2.53633 +12.3573 -87.2613 2.08743 +3.74654 95.9243 0.0897139 +-169.8 181.109 1.07049 +-86.3787 -20.842 2.20804 +100.352 -89.1449 3.04768 +181.883 -33.5627 4.40146 +-165.009 -64.7142 4.22889 +91.5355 186.861 4.57717 +102.267 123.234 0.811658 +-86.0748 -157.313 0.103406 +26.6639 45.5936 2.75787 +-77.4118 -187.412 0.304705 +-96.3027 -180.235 0.682201 +82.8553 -94.5959 2.10247 +193.71 82.0472 0.856872 +-39.8523 -74.1384 0.630415 +95.4336 -122.022 1.06781 +82.2942 -183.711 4.712 +5.52791 182.463 3.49034 +48.2153 -152.604 4.91441 +-106.191 -144.332 2.74771 +-93.6031 76.298 4.28006 +-73.8378 100.674 0.576277 +31.5663 155.25 4.11197 +-86.3865 -76.5521 4.03335 +39.4751 -8.0024 1.0352 +117.453 42.4308 4.72811 +133.742 127.855 3.25679 +116.205 104.816 0.825892 +163.601 -15.957 3.92858 +-180.731 -22.8043 0.101193 +95.5669 197.012 1.43116 +-3.75869 139.417 3.00818 +-48.5082 185.519 0.902761 +74.9397 114.477 2.32293 +-133.063 37.1446 0.316367 +109.368 119.96 4.28453 +37.2235 98.2094 3.45631 +-57.961 -41.2472 2.40887 +126.082 24.8242 1.95388 +-96.7223 -60.8892 2.19474 +-99.71 -52.7938 0.889331 +-160.293 61.6986 3.34235 +-174.774 -97.6468 0.235995 +139.703 -25.4259 3.67274 +-23.1525 160.408 4.50946 +-103.192 185.718 3.37656 +195.017 128.48 1.34185 +-46.2301 4.9848 3.11734 +178.594 197.695 2.19336 +-82.2952 -45.9948 3.48434 +64.9111 129.585 4.73796 +-73.3903 -199.269 0.234298 +28.9629 68.119 0.549627 +-196.463 86.9986 4.79591 +163.945 -19.1822 2.00651 +149.663 -58.4257 3.2166 +78.1433 -188.301 3.15432 +-116.872 -80.9531 0.0764394 +-119.177 168.434 4.80886 +34.8278 -56.0969 1.28018 +-35.5875 -177.35 4.59156 +-34.8563 -198.313 1.17418 +-166.737 -179.569 4.03622 +120.261 -135.599 4.08043 +-98.9209 -151.926 3.62975 +42.6534 8.59436 3.00054 +54.3523 -134.077 1.47733 +173.399 118.268 2.51643 +141.833 124.383 3.52671 +-114.264 109.092 1.46206 +-91.6138 -188.494 3.51722 +-89.927 178.831 0.581516 +-69.4964 -127.234 0.9973 +-5.09564 195.664 0.000566293 +42.9782 122.098 1.26406 +-148.427 12.4784 4.29722 +-82.5049 -147.478 2.47663 +-164.237 -29.2921 2.14412 +160.146 172.022 1.41703 +69.238 54.1596 2.48874 +80.7442 171.125 3.84356 +59.5755 52.502 0.219476 +132.342 99.0233 1.85077 +128.005 178.807 4.28708 +50.1037 178.853 2.3243 +-137.418 -120.023 2.96896 +-84.8963 -176.245 4.43765 +85.8117 21.8849 4.88468 +57.8341 193.414 4.38651 +-88.0063 -93.2232 2.75198 +-116.882 105.876 1.26129 +135.62 13.3607 4.50598 +34.6435 30.9187 3.66025 +13.4508 178.98 2.76032 +-7.69665 121.946 0.886613 +72.2804 -92.1095 1.66889 +96.0352 145.407 3.10769 +-82.0799 100.419 1.68033 +-88.6656 91.1938 4.90326 +18.1112 42.1145 1.30318 +-76.0132 -137.727 2.34216 +137.347 -36.8239 1.53741 +-31.7339 -76.3455 4.47045 +-52.7535 -183.526 2.13859 +-130.807 37.2997 4.54238 +-22.9166 108.229 2.94588 +-77.5094 -158.26 1.64632 +-177.09 90.3548 3.12033 +114.104 -175.219 4.51201 +-43.7819 -182.958 2.23839 +18.4912 -78.7035 3.78823 +181.667 108.669 3.00507 +-94.6783 -168.338 0.108398 +-78.2039 189.298 1.94898 +159.096 -39.6151 2.81389 +67.3245 -76.2247 0.0274314 +109.064 159.446 1.55856 +-0.580817 -108.848 1.84494 +24.2006 140.778 0.771231 +41.2427 101.738 2.72396 +162.539 -119.19 0.455097 +71.2081 183.868 0.225937 +102.87 24.2739 1.54246 +92.1677 32.9458 3.06491 +-147.447 188.864 2.55361 +-23.6721 13.9753 0.895164 +-64.2261 16.1698 4.75847 +26.9257 140.855 2.25121 +-32.2964 -111.55 0.0537161 +-130.558 -49.8517 3.06925 +-49.7482 168.065 2.60099 +-65.88 -195.527 0.99109 +158.394 -177.452 4.77696 +-8.66023 -54.0558 3.42906 +-19.7961 191.137 4.08597 +194.179 -4.57438 1.29007 +10.349 67.0388 2.98724 +-48.7961 47.7163 0.823812 +39.6537 -172.187 2.92011 +189.802 -167.89 3.78813 +157.867 77.6502 0.666279 +162.339 -114.271 2.34278 +184.887 -34.9835 1.8227 +-69.1688 -52.8265 4.21445 +-78.0318 -178.502 1.467 +117.394 148.376 1.39424 +-15.5675 -148.419 4.0236 +-167.851 90.5603 0.913651 +-140.038 156.465 3.90932 +-107.928 -9.92617 3.78185 +169.722 -106.876 3.25518 +-144.548 -53.5733 2.78443 +20.4682 133.849 2.59551 +167.642 -120.335 4.2309 +189.14 -183.179 0.755505 +137.516 -65.8187 4.72293 +189.097 45.7205 2.02833 +79.657 -32.3914 2.43019 +36.1223 40.7007 3.17972 +-173.804 -46.5535 4.33062 +-80.6796 -144.006 3.95215 +65.7471 116.409 4.64529 +-0.403869 -60.8368 2.40114 +79.2614 146.804 1.99667 +96.0828 85.2766 1.86092 +-169.736 145.717 1.07986 +75.9847 123.551 0.943572 +-156.407 -114.182 4.43928 +84.294 80.2336 2.39081 +-162.26 -65.3891 2.71826 +-106.265 -118.94 4.20977 +-189.856 197.232 2.53161 +-50.6931 168.856 0.0265606 +-103.889 -39.0528 3.51733 +181.388 120.68 2.21836 +127.105 -130.446 2.59667 +50.656 -44.0573 1.04647 +136.474 31.4285 1.59139 +16.7076 -13.4288 0.145065 +151.319 177.836 0.616821 +-167.621 -4.70256 1.78851 +-170.389 -67.921 1.9153 +198.467 134.608 3.78164 +-40.5861 136.733 4.98303 +-119.906 18.1189 4.75038 +-50.3519 195.588 3.83919 +105.591 3.32129 1.97239 +-62.9807 87.0392 1.17831 +123.591 -185.649 3.88716 +101.427 -174.044 3.27864 +-103.276 -124.699 3.68337 +28.8033 18.3818 4.05351 +-36.5889 171.606 4.03435 +-99.8563 74.1371 1.02702 +118.263 72.7794 2.0282 +113.851 52.8096 3.8988 +-82.8281 -40.0555 2.71869 +-195.789 117.735 4.43143 +-181.438 -188 3.47631 +-155.483 122.973 2.24414 +-80.1812 -14.736 3.4532 +138.201 -120.066 1.31324 +109.807 -195.785 3.35588 +-16.0563 126.963 4.60767 +-143.277 -190.876 3.58595 +109.533 -28.6197 2.50909 +-130.523 -116.716 3.97373 +187.213 100.779 4.02637 +199.213 55.2933 4.25839 +122.186 -66.602 4.81486 +-92.5501 112.929 1.31259 +-12.6162 -10.8148 0.540102 +-8.40121 94.2442 4.41268 +-81.4385 -37.2857 1.71198 +-72.3142 -68.6719 2.42102 +99.0661 -181.796 1.29018 +182.35 18.9313 2.15864 +83.1297 -63.17 1.9988 +-61.577 -141.06 1.98896 +71.821 199.611 1.01629 +-15.2495 184.8 2.35941 +173.936 -110.192 4.70171 +68.1799 -66.9843 2.09669 +-169.106 -113.97 3.57871 +-37.7777 22.9888 0.174783 +-19.5733 -183.33 3.91311 +199.358 -80.1157 3.69249 +-63.8121 92.5755 2.23161 +-4.87228 -147.521 3.9619 +-5.26103 11.5961 2.35966 +-20.461 92.899 4.66904 +69.3466 -118.348 4.34324 +-197.638 -142.212 2.69549 +-111.607 25.5236 3.08166 +111.382 -88.1795 0.109442 +128.052 -74.1968 2.36478 +-152.064 -161.148 2.35675 +140.512 134.251 4.0591 +192.991 -87.22 1.4982 +4.58696 -170.268 3.93243 +-102.514 18.5048 1.17667 +-20.8624 -7.97184 4.5435 +36.9259 -60.5128 4.57303 +-137.55 155.126 0.677942 +-25.73 1.65912 4.57021 +100.073 10.4145 3.67086 +138.925 199.597 4.27006 +73.1762 -11.8635 3.52645 +185.956 -87.1356 3.43884 +-184.312 32.72 0.996175 +34.193 -52.6854 2.21475 +-173.779 41.4482 4.45397 +-34.2916 4.92842 2.41554 +-79.1656 -29.229 3.19616 +122.494 25.0063 0.374536 +-67.092 -9.37676 4.12545 +-67.4954 -115.708 3.36201 +120.641 -174.103 1.77672 +-166.495 108.013 1.60117 +66.2255 -16.8802 1.79727 +-186.46 62.8138 4.72469 +54.9883 -160.006 0.0524522 +-140.083 196.311 2.12381 +30.6877 -10.4454 3.63424 +-144.306 -154.752 2.66541 +46.3173 -124.79 4.32676 +130.609 -194.754 0.983063 +156.506 74.2077 4.99108 +64.5186 -183.655 0.409895 +-152.362 -55.5612 3.73771 +110.452 88.2207 3.90696 +150.446 66.1956 2.09432 +146.757 70.3918 2.84328 +-63.6882 -159.704 0.726874 +-18.4407 131.035 1.42305 +56.7697 -55.7323 4.50202 +62.0162 -109.592 3.63463 +-63.7761 -30.9468 3.09095 +-47.4311 -31.6606 1.39743 +97.0077 1.13095 1.99291 +-14.7717 -99.8519 0.873568 +-148.576 -187.295 0.254143 +121.816 -19.7493 4.58861 +162.112 -192.287 1.29251 +93.1475 -134.137 3.562 +-162.585 -20.2932 1.77162 +-72.1766 -60.132 0.0468209 +96.8767 -169.362 1.74962 +-134.784 77.9146 3.65673 +66.347 189.709 2.36933 +166.495 -50.8575 4.68468 +179.2 19.0279 0.327481 +-40.549 39.3593 4.35018 +-32.836 6.44796 3.87658 +33.0268 109.848 2.54092 +-187.266 -5.19188 3.00861 +-47.3983 136.538 4.60641 +-16.7599 140.283 3.31736 +-138.845 -119.747 4.13256 +-149.136 172.791 2.4619 +0.00640806 -37.6626 2.04309 +-180.966 -62.8882 1.78309 +58.3937 -36.6897 3.77623 +-135.158 -88.6754 0.865781 +174.69 -178.549 3.77862 +-30.5019 24.7249 3.93779 +-93.9643 -134.586 0.845307 +-153.681 -166.074 3.13581 +-73.4283 99.3156 3.90024 +-100.637 29.9208 4.53604 +61.7003 -173.127 2.03612 +198.812 -9.67982 2.27405 +-37.8776 132.968 0.50397 +73.447 35.0661 1.31449 +94.898 104.329 0.998115 +-80.3772 6.61785 3.11684 +-14.9632 -78.3592 4.44229 +18.9633 -10.7346 0.0212741 +-81.7211 -159.87 1.60342 +148.2 152.149 2.84546 +175.073 115.032 1.11671 +-34.6071 -122.078 1.10186 +-101.639 59.8459 3.12839 +133.427 100.164 1.54648 +37.7553 -194.677 0.232704 +-155.627 -114.828 1.72799 +-33.9861 134.519 4.04095 +155.279 89.9022 1.77799 +195.409 91.6041 3.25648 +147.559 -180.122 2.60897 +62.591 47.5143 2.29738 +140.513 136.851 4.36479 +0.358935 -175 0.594302 +-99.4775 75.2715 4.76214 +-94.1548 198.99 2.73408 +-8.98291 -182.394 3.28874 +-74.4637 -44.1547 0.363914 +-184.561 -120.879 4.8049 +107.043 21.3604 4.74752 +126.92 -118.121 4.092 +-25.5652 90.5964 2.37439 +-88.714 -125.613 1.6308 +-63.7139 -176.429 4.13529 +-188.442 -128.885 0.391819 +-189.452 -147.914 1.71488 +-171.846 70.8118 4.1026 +-16.001 -66.089 0.671801 +63.1202 -36.9759 0.864783 +-115.519 -52.5835 4.70282 +-33.6409 -72.7818 3.78932 +-143.044 -145.422 0.969758 +-68.6574 44.5294 2.36083 +-45.0868 174.994 4.06441 +26.028 105.817 4.20888 +78.1137 137.162 4.34072 +-51.0745 -125.647 4.69265 +82.8366 -197.439 1.99263 +-154.139 -143.695 0.281635 +-6.72277 -74.5127 1.33764 +120.495 -98.2873 3.41713 +175.074 -195.142 4.12907 +19.6032 -117.561 0.770857 +-5.40327 71.3057 2.70727 +-99.5867 -3.54152 0.532623 +-162.425 -66.8311 4.00904 +-88.0717 -119.573 0.870613 +-85.5111 -144.161 4.40607 +-29.2065 15.2491 4.97933 +96.2809 37.7799 2.39529 +197.994 144.791 1.40149 +-197.148 18.1617 1.08991 +-114.709 -51.5123 3.83495 +156.597 10.1562 1.26741 +-46.9446 -173.262 2.52257 +86.2243 -130.652 2.99227 +166.651 190.071 4.39137 +-177.51 -140.28 0.822481 +37.7388 -187.794 2.9574 +-124.481 -189.448 1.66091 +-179.69 2.17599 1.63583 +38.4717 114.295 1.67148 +186.959 -198.512 2.73762 +-2.88438 108.283 2.19508 +23.8536 -190.324 4.10827 +93.2015 11.4819 2.68608 +83.2728 -149.137 2.26922 +142.993 -197.827 2.55034 +155.199 -132.029 0.522073 +165.752 104.563 1.46606 +-32.0722 -162.564 1.71993 +-117.777 -31.6971 4.70083 +-116.29 102.021 4.53782 +191.994 -78.9689 2.00176 +-198.33 96.6377 4.79993 +13.1517 25.2997 3.46495 diff --git a/Apollonius_graph_2/examples/Apollonius_graph_2/data/sites.cin b/Apollonius_graph_2/examples/Apollonius_graph_2/data/sites.cin new file mode 100644 index 00000000000..42fd245c11c --- /dev/null +++ b/Apollonius_graph_2/examples/Apollonius_graph_2/data/sites.cin @@ -0,0 +1,9 @@ +20.0 -20 5 +9 -9 15. +1000 -1000 20 +10.0 5.0 5 +1.0 1.0 10 +-10 -10 11 +95 67 33 +-99 -100 -31 + diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2.h new file mode 100644 index 00000000000..c864aaf171b --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2.h @@ -0,0 +1,1343 @@ +// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_H +#define CGAL_APOLLONIUS_GRAPH_2_H + +#include + +#include + +#define CGAL_APOLLONIUS_GRAPH_PSEUDO_CIRCLE_DESIGN 1 + + +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include + + +namespace CGAL { + + +namespace internal { + + template struct AG2_which_list; + + // use the in-place edge list + template + struct AG2_which_list + { + typedef E Edge; + typedef In_place_edge_list List; + }; + + // do not use the in-place edge list + template + struct AG2_which_list + { + typedef E Edge; + // change the following to Tag_false in order to use + // CGAL's Unique_hash_map + typedef Tag_true Use_stl_map_tag; + typedef Edge_list List; + }; + + template < class Node > + struct Project_site_2 { + typedef Node argument_type; + typedef typename Node::Site_2 Site; + typedef Site result_type; + Site& operator()( Node& x) const { return x.site(); } + const Site& operator()( const Node& x) const { return x.site(); } + }; + +} // namespace internal + + +template +class Apollonius_graph_hierarchy_2; + +template < class Gt, + class Agds = Triangulation_data_structure_2 < + Apollonius_graph_vertex_base_2, + Triangulation_face_base_2 >, + class LTag = Tag_false> +class Apollonius_graph_2 + : private Triangulation_2 + ,Agds> +{ + friend class Apollonius_graph_hierarchy_2; +private: + // types and access methods needed for visualization + //-------------------------------------------------- + + // types + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Construct_Apollonius_bisector_2 + Construct_Apollonius_bisector_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Construct_Apollonius_bisector_ray_2 + Construct_Apollonius_bisector_ray_2; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Construct_Apollonius_bisector_segment_2 + Construct_Apollonius_bisector_segment_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Construct_Apollonius_primal_ray_2 + Construct_Apollonius_primal_ray_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Construct_Apollonius_primal_segment_2 + Construct_Apollonius_primal_segment_2; + + + // access + Construct_Apollonius_bisector_2 + construct_Apollonius_bisector_2_object() const { + return Construct_Apollonius_bisector_2(); + } + + Construct_Apollonius_bisector_ray_2 + construct_Apollonius_bisector_ray_2_object() const { + return Construct_Apollonius_bisector_ray_2(); + } + + Construct_Apollonius_bisector_segment_2 + construct_Apollonius_bisector_segment_2_object() const { + return Construct_Apollonius_bisector_segment_2(); + } + + Construct_Apollonius_primal_ray_2 + construct_Apollonius_primal_ray_2_object() const { + return Construct_Apollonius_primal_ray_2(); + } + + Construct_Apollonius_primal_segment_2 + construct_Apollonius_primal_segment_2_object() const { + return Construct_Apollonius_primal_segment_2(); + } + + +protected: + // some local types + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Apollonius_graph_traits_wrapper_2 + Modified_traits; + + typedef Triangulation_2 DG; + + typedef DG Delaunay_graph; + +public: + // TYPES + //------ + typedef Agds Data_structure; + typedef Agds Triangulation_data_structure; + typedef Gt Geom_traits; + typedef typename Gt::Point_2 Point_2; + typedef typename Gt::Site_2 Site_2; + + typedef typename Agds::Edge Edge; + typedef typename Agds::Vertex_handle Vertex_handle; + typedef typename Agds::Face_handle Face_handle; + typedef typename Agds::Vertex Vertex; + typedef typename Agds::Face Face; + + typedef typename Agds::Vertex_circulator Vertex_circulator; + typedef typename Agds::Edge_circulator Edge_circulator; + typedef typename Agds::Face_circulator Face_circulator; + + typedef typename Agds::Face_iterator All_faces_iterator; + typedef typename Agds::Vertex_iterator All_vertices_iterator; + typedef typename Agds::Edge_iterator All_edges_iterator; + + typedef typename DG::Finite_faces_iterator Finite_faces_iterator; + typedef typename DG::Finite_vertices_iterator Finite_vertices_iterator; + typedef typename DG::Finite_edges_iterator Finite_edges_iterator; + + typedef typename Agds::size_type size_type; + + // Auxiliary iterators for convenience + // do not use default template argument to please VC++ + typedef internal::Project_site_2 Proj_site; + typedef Iterator_project + /* */ Visible_sites_iterator; + + typedef + Apollonius_graph_vertex_base_nested_iterator_traits< + Finite_vertices_iterator> Hidden_sites_nested_iterator_traits; + + + typedef Nested_iterator + /* */ Hidden_sites_iterator; + + typedef Concatenate_iterator Sites_iterator; + + typedef Site_2 value_type; // to have a back_inserter + typedef const value_type& const_reference; + typedef value_type& reference; + +public: + struct Vertex_iterator {}; + struct Face_iterator {}; + struct Edge_iterator {}; + +protected: + // some more local types + // typedef typename Agds::Vertex Vertex; + + // point lists + typedef std::vector Site_list; + typedef typename Site_list::iterator Site_list_iterator; + + typedef std::map Face_map; + typedef std::map Face_face_map; + typedef std::map Vertex_map; + typedef std::set Edge_list; + + typedef std::list Vertex_list; + typedef typename Vertex_list::iterator Vertex_list_iterator; + typedef Vertex_handle Vh_triple[3]; + + // the edge list + typedef typename internal::AG2_which_list::List List; + + typedef enum { NO_CONFLICT = -1, INTERIOR, LEFT_VERTEX, + RIGHT_VERTEX, BOTH_VERTICES, ENTIRE_EDGE } + Conflict_type; + + static Conflict_type opposite(const Conflict_type& ct) { + if ( ct == RIGHT_VERTEX ) { return LEFT_VERTEX; } + if ( ct == LEFT_VERTEX ) { return RIGHT_VERTEX; } + return ct; + } + +protected: + // Less_than comparator for site weights; + // used to sort sites by decreasing weight when a sequence of sites + // is inserted + class Site_less_than_comparator + { + private: + const Gt& gt; + public: + Site_less_than_comparator(const Gt& gt) : gt(gt) {} + + bool operator ()(const Site_2& p, + const Site_2& q) { + Comparison_result result = gt.compare_weight_2_object()(p, q); + return (result == LARGER); + } + }; + +public: + // CREATION + //--------- + Apollonius_graph_2(const Gt& gt=Gt()) : + DG( Modified_traits(gt) ) {} + + template< class Input_iterator > + Apollonius_graph_2(Input_iterator first, Input_iterator beyond, + const Gt& gt=Gt()) + : DG( Modified_traits(gt) ) + { + insert(first, beyond); + } + + Apollonius_graph_2(const Apollonius_graph_2 &ag) + : DG(ag) + { + CGAL_postcondition( is_valid() ); + } + + Apollonius_graph_2& + operator=(const Apollonius_graph_2& ag) + { + if ( this != &ag ) { + DG::operator=(ag); + } + return (*this); + } + +public: + // ACCESS METHODS + // -------------- + const Geom_traits& geom_traits() const { + return DG::geom_traits(); + } + + const Data_structure& data_structure() const { return this->_tds; } + const Triangulation_data_structure& tds() const { return this->_tds; } + + int dimension() const { + return this->_tds.dimension(); + } + + size_type number_of_faces() const { + return this->_tds.number_of_faces(); + } + + size_type number_of_vertices() const { + return DG::number_of_vertices(); + } + + size_type number_of_visible_sites() const { + return number_of_vertices(); + } + + size_type number_of_hidden_sites() const { + // if ( !Vertex::StoreHidden ) { return 0; } + + size_type n_hidden(0); + for (Finite_vertices_iterator vit = finite_vertices_begin(); + vit != finite_vertices_end(); ++vit) { + n_hidden += vit->number_of_hidden_sites(); + } + + return n_hidden; + } + + Vertex_handle infinite_vertex() const { + return DG::infinite_vertex(); + } + + Face_handle infinite_face() const { + return DG::infinite_face(); + } + + Vertex_handle finite_vertex() const { + return DG::finite_vertex(); + } + +protected: + using Delaunay_graph::cw; + using Delaunay_graph::ccw; + +public: + // TRAVERSAL OF THE APOLLONIUS GRAPH + //---------------------------------- + Finite_faces_iterator finite_faces_begin() const { + return DG::finite_faces_begin(); + } + + Finite_faces_iterator finite_faces_end() const { + return DG::finite_faces_end(); + } + + Finite_vertices_iterator finite_vertices_begin() const { + return DG::finite_vertices_begin(); + } + + Finite_vertices_iterator finite_vertices_end() const { + return DG::finite_vertices_end(); + } + + Finite_edges_iterator finite_edges_begin() const { + return DG::finite_edges_begin(); + } + Finite_edges_iterator finite_edges_end() const { + return DG::finite_edges_end(); + } + + + Sites_iterator sites_begin() const { + return Sites_iterator(visible_sites_end(), + hidden_sites_begin(), + visible_sites_begin()); + } + + Sites_iterator sites_end() const { + return Sites_iterator(visible_sites_end(), + hidden_sites_begin(), + hidden_sites_end(),0); + } + + Visible_sites_iterator visible_sites_begin() const { + return Visible_sites_iterator(finite_vertices_begin()); + } + + Visible_sites_iterator visible_sites_end() const { + return Visible_sites_iterator(finite_vertices_end()); + } + + Hidden_sites_iterator hidden_sites_begin() const { + return Hidden_sites_iterator(finite_vertices_end(), + finite_vertices_begin()); + } + + Hidden_sites_iterator hidden_sites_end() const { + return Hidden_sites_iterator(finite_vertices_end(), + finite_vertices_end()); + } + + + All_faces_iterator all_faces_begin() const { + return DG::all_faces_begin(); + } + + All_faces_iterator all_faces_end() const { + return DG::all_faces_end(); + } + + All_vertices_iterator all_vertices_begin() const { + return DG::all_vertices_begin(); + } + + All_vertices_iterator all_vertices_end() const { + return DG::all_vertices_end(); + } + + All_edges_iterator all_edges_begin() const { + return DG::all_edges_begin(); + } + + All_edges_iterator all_edges_end() const { + return DG::all_edges_end(); + } + +public: + // CIRCULATORS + //------------ + Face_circulator + incident_faces(Vertex_handle v, + Face_handle f = Face_handle()) const { + return DG::incident_faces(v, f); + } + + Vertex_circulator + incident_vertices(Vertex_handle v, + Face_handle f = Face_handle()) const { + return DG::incident_vertices(v, f); + } + + Edge_circulator + incident_edges(Vertex_handle v, + Face_handle f = Face_handle()) const { + return DG::incident_edges(v, f); + } + +public: + // PREDICATES + //----------- + bool is_infinite(const Vertex_handle& v) const { + return DG::is_infinite(v); + } + + bool is_infinite(const Face_handle& f) const { + return DG::is_infinite(f); + } + + bool is_infinite(const Face_handle& f, int i) const { + return DG::is_infinite(f, i); + } + + bool is_infinite(const Edge& e) const { + return is_infinite(e.first, e.second); + } + + bool is_infinite(const Edge_circulator& ec) const { + return DG::is_infinite(ec); + } + +public: + // INSERTION + //---------- + template< class Input_iterator > + size_type insert(Input_iterator first, Input_iterator beyond) { + // copy to a local container + Site_list wp_list; + for (Input_iterator it = first; it != beyond; ++it) { + wp_list.push_back(*it); + } + + // sort by decreasing weight + Site_less_than_comparator less_than(geom_traits()); + std::sort(wp_list.begin(), wp_list.end(), less_than); + + // now insert + Site_list_iterator lit; + for (lit = wp_list.begin(); lit != wp_list.end(); ++lit) { + insert(*lit); + } + + // store how many sites where in the range + size_type num = wp_list.size(); + + // clear the local container + wp_list.clear(); + + // return the number of sites in range + return num; + } + + Vertex_handle insert(const Site_2& p) { + return insert(p, Vertex_handle()); + } + + Vertex_handle insert(const Site_2& p, Vertex_handle vnear); + +public: + // REMOVAL + //-------- + void remove(Vertex_handle v); + +public: + // NEAREST NEIGHBOR LOCATION + //-------------------------- + Vertex_handle nearest_neighbor(const Point_2& p) const; + Vertex_handle nearest_neighbor(const Point_2& p, + Vertex_handle vnear) const; + +public: + // ACCESS TO THE DUAL + //------------------- + typename Gt::Object_2 dual(const Face_handle& f) const; + + Site_2 dual(const Finite_faces_iterator& it) const + { + typename Gt::Object_2 o = dual(Face_handle(it)); + Site_2 s; + if ( assign(s, o) ) { + return s; + } else { + CGAL_assertion_code( bool the_assign_statement_must_always_work(false); ) + CGAL_assertion( the_assign_statement_must_always_work ); + } + return s; + } + + +private: + typename Gt::Object_2 dual(const Edge e) const; + + typename Gt::Object_2 dual(const Edge_circulator& ec) const { + return dual(*ec); + } + + typename Gt::Object_2 dual(const Finite_edges_iterator& ei) const { + return dual(*ei); + } + +public: + // I/O + //---- + void file_input(std::istream&); + void file_output(std::ostream&) const; + + template< class Stream > + Stream& draw_primal(Stream &str) const + { + if ( number_of_vertices() < 2 ) { + // do nothing + } else if ( number_of_vertices() == 2 ) { + Vertex_handle v1(finite_vertices_begin()); + Vertex_handle v2(++finite_vertices_begin()); + Site_2 p1 = v1->site(); + Site_2 p2 = v2->site(); + + + typename Geom_traits::Segment_2 seg = + construct_Apollonius_primal_segment_2_object()(p1,p2); + typename Geom_traits::Ray_2 ray1 = + construct_Apollonius_primal_ray_2_object()(p1,p2,p2); + typename Geom_traits::Ray_2 ray2 = + construct_Apollonius_primal_ray_2_object()(p2,p1,p1); + + str << seg; + str << ray1; + str << ray2; + } else { + All_edges_iterator eit = all_edges_begin(); + for (; eit != all_edges_end(); ++eit) { + draw_primal_edge< Stream >(eit, str); + } + } + return str; + } + + template < class Stream > + Stream& draw_dual(Stream &str) const + { + Finite_edges_iterator eit = finite_edges_begin(); + for (; eit != finite_edges_end(); ++eit) { + typename Gt::Object_2 o = dual(eit); + typename Geom_traits::Line_2 l; + typename Geom_traits::Segment_2 s; + typename Geom_traits::Ray_2 r; + CGAL::Hyperbola_2 h; + CGAL::Hyperbola_segment_2 hs; + CGAL::Hyperbola_ray_2 hr; + if (assign(hs, o)) hs.draw(str); + else if (assign(s, o)) str << s; + else if (assign(hr, o)) hr.draw(str); + else if (assign(r, o)) str << r; + else if (assign(h, o)) h.draw(str); + else if (assign(l, o)) str << l; + } + return str; + } + +protected: + template< class Stream > + Stream& draw_primal_vertex(const Finite_vertices_iterator& it, + Stream &str) const + { + return str << it->site().point(); + } + + + template< class Stream > + Stream& draw_dual_vertex(const Finite_faces_iterator& it, + Stream &str) const + { + return str << dual(it); + } + +public: + template< class Stream > + Stream& draw_primal_edge(const Finite_edges_iterator& eit, + Stream &str) const + { + return draw_primal_edge(*eit, str); + } + + template< class Stream > + Stream& draw_primal_edge(const All_edges_iterator& eit, + Stream &str) const + { + return draw_primal_edge(*eit, str); + } + + + template < class Stream > + Stream& draw_dual_edge(const Finite_edges_iterator& eit, + Stream &str) const + { + return draw_dual_edge(*eit, str); + } + + template< class Stream > + Stream& draw_primal_edge(const Edge& e, Stream &str) const + { + typedef typename Geom_traits::Segment_2 Segment_2; + typedef typename Geom_traits::Ray_2 Ray_2; + typedef std::pair Segment_pair_2; + + typename Geom_traits::Object_2 o = primal(e); + Segment_2 s; + Ray_2 r; + Segment_pair_2 s_pair; + CGAL::Hyperbola_segment_2 hs; + CGAL::Parabola_segment_2 ps; + if (assign(hs, o)) hs.draw(str); + if (assign(s, o)) str << s; + if (assign(ps, o)) ps.draw(str); + if (assign(r, o)) str << r; + if (assign(s_pair, o)) str << s_pair.first << s_pair.second; + return str; + } + + template < class Stream > + Stream& draw_dual_edge(const Edge& e, Stream &str) const + { + if ( is_infinite(e) ) { return str; } + typename Gt::Object_2 o = dual(e); + typename Geom_traits::Line_2 l; + typename Geom_traits::Segment_2 s; + typename Geom_traits::Ray_2 r; + CGAL::Hyperbola_2 h; + CGAL::Hyperbola_segment_2 hs; + CGAL::Hyperbola_ray_2 hr; + if (assign(hs, o)) hs.draw(str); + if (assign(s, o)) str << s; + if (assign(hr, o)) hr.draw(str); + if (assign(r, o)) str << r; + if (assign(h, o)) h.draw(str); + if (assign(l, o)) str << l; + + return str; + } + +protected: + template< class Stream > + Stream& draw_primal_face(All_faces_iterator fit, Stream &str) const + { + for (int i = 0; i < 3; i++) { + draw_primal_edge< Stream >(Edge(Face_handle(fit), i), str); + } + return str; + } + + + template< class Stream > + Stream& draw_dual_face(const All_vertices_iterator& vit, + Stream &str) const + { + Edge_circulator ec_start = incident_edges(Vertex_handle(vit)); + Edge_circulator ec = ec_start; + do { + draw_dual_edge< Stream >(*ec, str); + ++ec; + } while ( ec_start != ec ); + return str; + } + +protected: + template < class Stream > + Stream& draw_dual_sites(Stream &str) const + { + All_faces_iterator fit = all_faces_begin(); + for (; fit != all_faces_end(); ++fit) { + Face_handle f(fit); + if ( is_infinite(f) ) { + if ( is_infinite(f->vertex(0)) ) { + str << circumcircle( f->vertex(1)->site(), + f->vertex(2)->site() ); + } else if ( is_infinite(f->vertex(1)) ){ + str << circumcircle( f->vertex(2)->site(), + f->vertex(0)->site() ); + } else { + str << circumcircle( f->vertex(0)->site(), + f->vertex(1)->site() ); + } + } else { + Site_2 wp = circumcircle(f); + typename Gt::Rep::Circle_2 c(wp.point(), + CGAL::square(wp.weight())); + str << c; + } + } + return str; + } + +public: + // VALIDITY CHECK + //--------------- + bool is_valid(bool verbose = false, int level = 1) const; + +public: + // MISCELLANEOUS + //-------------- + void clear() { + DG::clear(); + } + + void swap(Apollonius_graph_2& ag) { + DG::swap(ag); + } + +public: + // MK: THE FOLLOWING ARE NOT IN THE SPEC + //====================================== + // Primal + typename Gt::Object_2 primal(const Edge e) const; + typename Gt::Object_2 primal(const Edge_circulator& ec) const { + return primal(*ec); + } + typename Gt::Object_2 primal(const Finite_edges_iterator& ei) const { + return primal(*ei); + } + +protected: + // wrappers for the geometric predicates + + // checks is q is contained inside p + bool is_hidden(const Site_2 &p, const Site_2 &q) const; + + // returns: + // ON_POSITIVE_SIDE if q is closer to p1 + // ON_NEGATIVE_SIDE if q is closer to p2 + // ON_ORIENTED_BOUNDARY if q is on the bisector of p1 and p2 + Oriented_side side_of_bisector(const Site_2 &p1, + const Site_2 &p2, + const Point_2 &q) const; + + Sign incircle(const Site_2 &p1, const Site_2 &p2, + const Site_2 &p3, const Site_2 &q) const; + + Sign incircle(const Site_2 &p1, const Site_2 &p2, + const Site_2 &q) const; + + + Sign incircle(const Face_handle& f, const Site_2& q) const; + + + Sign incircle(const Vertex_handle& v0, const Vertex_handle& v1, + const Vertex_handle& v) const; + + Sign incircle(const Vertex_handle& v0, const Vertex_handle& v1, + const Vertex_handle& v2, const Vertex_handle& v) const; + + + + bool finite_edge_interior(const Site_2& p1, + const Site_2& p2, + const Site_2& p3, + const Site_2& p4, + const Site_2& q, + bool endpoints_in_conflict) const; + + bool finite_edge_interior(const Face_handle& f, int i, + const Site_2& q, + bool endpoints_in_conflict) const; + + bool finite_edge_interior(const Vertex_handle& v1, + const Vertex_handle& v2, + const Vertex_handle& v3, + const Vertex_handle& v4, + const Vertex_handle& v, + bool endpoints_in_conflict) const; + + bool finite_edge_interior_degenerated(const Site_2& p1, + const Site_2& p2, + const Site_2& p3, + const Site_2& q, + bool endpoints_in_conflict) const; + + + bool finite_edge_interior_degenerated(const Site_2& p1, + const Site_2& p2, + const Site_2& q, + bool endpoints_in_conflict) const; + + bool finite_edge_interior_degenerated(const Face_handle& f, int i, + const Site_2& p, + bool endpoints_in_conflict) const; + + bool finite_edge_interior_degenerated(const Vertex_handle& v1, + const Vertex_handle& v2, + const Vertex_handle& v3, + const Vertex_handle& v4, + const Vertex_handle& v, + bool endpoints_in_conflict) const; + bool infinite_edge_interior(const Site_2& p2, + const Site_2& p3, + const Site_2& p4, + const Site_2& q, + bool endpoints_in_conflict) const; + + + bool infinite_edge_interior(const Face_handle& f, int i, + const Site_2& p, + bool endpoints_in_conflict) const; + + bool infinite_edge_interior(const Vertex_handle& v1, + const Vertex_handle& v2, + const Vertex_handle& v3, + const Vertex_handle& v4, + const Vertex_handle& v, + bool endpoints_in_conflict) const; + + Conflict_type + infinite_edge_conflict_type(const Site_2& p2, + const Site_2& p3, + const Site_2& p4, + const Site_2& q) const; + + Conflict_type + finite_edge_conflict_type_degenerated(const Site_2& p1, + const Site_2& p2, + const Site_2& q) const; + + bool edge_interior(const Face_handle& f, int i, + const Site_2& p, bool b) const; + + + bool edge_interior(const Edge& e, + const Site_2& p, bool b) const { + return edge_interior(e.first, e.second, p, b); + } + + bool edge_interior(const Vertex_handle& v1, + const Vertex_handle& v2, + const Vertex_handle& v3, + const Vertex_handle& v4, + const Vertex_handle& v, + bool endpoints_in_conflict) const; + + bool is_degenerate_edge(const Site_2& p1, + const Site_2& p2, + const Site_2& p3, + const Site_2& p4) const { + return geom_traits().is_degenerate_edge_2_object() + (p1, p2, p3, p4); + } + + bool is_degenerate_edge(const Vertex_handle& v1, + const Vertex_handle& v2, + const Vertex_handle& v3, + const Vertex_handle& v4) const { + CGAL_precondition( !is_infinite(v1) && !is_infinite(v2) && + !is_infinite(v3) && !is_infinite(v4) ); + + return is_degenerate_edge(v1->site(), v2->site(), + v3->site(), v4->site()); + } + + bool is_degenerate_edge(const Face_handle& f, int i) const { + Vertex_handle v1 = f->vertex( ccw(i) ); + Vertex_handle v2 = f->vertex( cw(i) ); + Vertex_handle v3 = f->vertex( i ); + Vertex_handle v4 = tds().mirror_vertex(f, i); + + return is_degenerate_edge(v1, v2, v3, v4); + } + + bool is_degenerate_edge(const Edge& e) const { + return is_degenerate_edge(e.first, e.second); + } + + +protected: + // wrappers for constructions + Point_2 circumcenter(const Face_handle& f) const; + Point_2 circumcenter(const Site_2& p0, + const Site_2& p1, + const Site_2& p2) const; + + Site_2 circumcircle(const Face_handle& f) const; + Site_2 circumcircle(const Site_2& p0, + const Site_2& p1, + const Site_2& p2) const; + + typename Gt::Line_2 circumcircle(const Site_2& p0, + const Site_2& p1) const; + +protected: + // wrappers for combinatorial operations on the data structure + + // getting the degree of a vertex + typename Data_structure::size_type degree(const Vertex_handle& v) { + return this->_tds.degree(v); + } + + // getting the symmetric edge + Edge sym_edge(const Edge e) const { + return sym_edge(e.first, e.second); + } + + Edge sym_edge(const Face_handle& f, int i) const { + Face_handle f_sym = f->neighbor(i); + return Edge( f_sym, f_sym->index( tds().mirror_vertex(f, i) ) ); + } + + Edge flip(Face_handle& f, int i); + Edge flip(Edge e); + + Vertex_handle insert_in_face(Face_handle& f, const Site_2& p); + + bool is_degree_2(const Vertex_handle& v) const; + + Vertex_handle insert_degree_2(Edge e); + Vertex_handle insert_degree_2(Edge e, const Site_2& p); + void remove_degree_2(Vertex_handle v); + void remove_degree_3(Vertex_handle v); + void remove_degree_3(Vertex_handle v, Face_handle f); + + // this was defined because the hierarchy needs it + Vertex_handle create_vertex() { + return this->_tds.create_vertex(); + } + +protected: + // insertion of the first three sites + Vertex_handle insert_first(const Site_2& p); + Vertex_handle insert_second(const Site_2& p); + Vertex_handle insert_third(const Site_2& p); + + // methods for insertion + void initialize_conflict_region(const Face_handle& f, List& l) const; + bool check_edge_for_hidden_sites(const Face_handle& f, int i, + const Site_2& p, Vertex_map& vm) const; + void expand_conflict_region(const Face_handle& f, + const Site_2& p, + List& l, Face_map& fm, Vertex_map& vm, + std::vector* fe); + + Vertex_handle add_bogus_vertex(Edge e, List& l); + Vertex_list add_bogus_vertices(List& l); + void remove_bogus_vertices(Vertex_list& vl); + + void move_hidden_sites(Vertex_handle& vold, Vertex_handle& vnew); + + // MK: this is not currently used + std::vector get_faces_for_recycling(Face_map& fm, + unsigned int n_wanted); + void remove_hidden_vertices(Vertex_map& vm); + Vertex_handle retriangulate_conflict_region(const Site_2& p, + List& l, + Face_map& fm, + Vertex_map& vm); + +protected: + // methods for removal + void remove_first(Vertex_handle v); + void remove_second(Vertex_handle v); + void remove_third(Vertex_handle v); + void remove_degree_d_vertex(Vertex_handle v); + void minimize_degree(Vertex_handle v); + + void find_conflict_region_remove(const Vertex_handle& v, + const Vertex_handle& vnearest, + List& l, Face_map& fm, + Vertex_map& vm, + std::vector* fe); + +protected: + // methods for I/O + + template + bool assign(T& t2, const typename Gt::Object_2& o2) const + { + return geom_traits().assign_2_object()(t2, o2); + } + + +protected: + template + OutputItFaces find_conflicts(const Face_handle& f, + const Site_2& p, + List& l, + Face_map& fm, + Vertex_map& vm, + OutputItFaces fit) const + { + // setting fm[f] to true means that the face has been reached and + // that the face is available for recycling. If we do not want the + // face to be available for recycling we must set this flag to + // false. + if ( fm.find(f) != fm.end() ) { return fit; } + fm[f] = true; + CGAL_assertion( incircle(f, p) == NEGATIVE ); + *fit++ = f; + + // CGAL_assertion( fm.find(f) != fm.end() ); + for (int i = 0; i < 3; i++) { + bool hidden_found = check_edge_for_hidden_sites(f, i, p, vm); + + Face_handle n = f->neighbor(i); + + if ( !hidden_found ) { + Sign s = incircle(n, p); + if ( s != NEGATIVE ) { continue; } + + bool interior_in_conflict = edge_interior(f, i, p, true); + + if ( !interior_in_conflict ) { continue; } + } + + if ( fm.find(n) != fm.end() ) { + Edge e = sym_edge(f, i); + if ( l.is_in_list(e) || + l.is_in_list(sym_edge(e)) ) { + l.remove(e); + l.remove(sym_edge(e)); + } + continue; + } + + Edge e = sym_edge(f, i); + + CGAL_assertion( l.is_in_list(e) ); + int j = tds().mirror_index(f, i); + Edge e_before = sym_edge(n, ccw(j)); + Edge e_after = sym_edge(n, cw(j)); + if ( !l.is_in_list(e_before) ) { + l.insert_before(e, e_before); + } + if ( !l.is_in_list(e_after) ) { + l.insert_after(e, e_after); + } + l.remove(e); + + fit = find_conflicts(n, p, l, fm, vm, fit); + } // for-loop + return fit; + } // find_conflicts + + bool equal(const Edge& e1, const Edge& e2) const { + return e1.first == e2.first && e1.second == e2.second; + } + + +protected: + template + boost::tuples::tuple + get_all(const Site_2& p, + OutputItFaces fit, + OutputItBoundaryEdges eit, + OutputItHiddenVertices vit, + Vertex_handle start, + bool find_nearest) const + { + CGAL_precondition( dimension() == 2 ); + + // first find the nearest neighbor + Vertex_handle vnearest = start; + if ( find_nearest ) { + vnearest = nearest_neighbor(p.point(), start); + CGAL_assertion( vnearest != Vertex_handle() ); + } + + // check if it is hidden + if ( is_hidden(vnearest->site(), p) ) { + return boost::tuples::make_tuple(fit, eit, vit); + } + + // find the first conflict + + // first look for conflict with vertex + Face_circulator fc_start = incident_faces(vnearest); + Face_circulator fc = fc_start; + Face_handle start_f; + Sign s; + do { + Face_handle f(fc); + s = incircle(f, p); + + if ( s == NEGATIVE ) { + start_f = f; + break; + } + ++fc; + } while ( fc != fc_start ); + + // we are not in conflict with an Apollonius vertex, so we have to + // be in conflict with the interior of an Apollonius edge + if ( s != NEGATIVE ) { + Edge_circulator ec_start = incident_edges(vnearest); + Edge_circulator ec = ec_start; + + bool interior_in_conflict(false); + Edge e; + do { + e = *ec; + interior_in_conflict = edge_interior(e, p, false); + + if ( interior_in_conflict ) { break; } + ++ec; + } while ( ec != ec_start ); + + CGAL_assertion( interior_in_conflict ); + + *eit++ = e; + *eit++ = sym_edge(e); + return boost::tuples::make_tuple(fit, eit, vit); + } + + // we are in conflict with an Apollonius vertex; start from that and + // find the entire conflict region and then repair the diagram + List l; + Face_map fm; + Vertex_map vm; + + // *fit++ = start_f; + initialize_conflict_region(start_f, l); + fit = find_conflicts(start_f, p, l, fm, vm, fit); + + // output the edges on the boundary of the conflict region + if ( l.size() > 0 ) { + const Edge& e_front = l.front(); + // here I should be able to write: const Edge& e = l.front(); + // instead of what I have; but the compiler complains for the + // assignment: e = l.next(e); + Edge e = l.front(); + do { + *eit++ = e; + e = l.next(e); + } while ( !equal(e, e_front) ); + } + + // output the hidden vertices + for (typename Vertex_map::iterator it = vm.begin(); it != vm.end(); ++it) { + *vit++ = it->first; + } + + // clear containers + fm.clear(); + vm.clear(); + l.clear(); + + return boost::tuples::make_tuple(fit, eit, vit); + } + +public: + template + boost::tuples::tuple + get_conflicts_and_boundary_and_hidden_vertices(const Site_2& p, + OutputItFaces fit, + OutputItBoundaryEdges eit, + OutputItHiddenVertices vit, + Vertex_handle start = + Vertex_handle()) const + { + return get_all(p, fit, eit, vit, start, true); + } + + template + std::pair + get_conflicts_and_boundary(const Site_2& p, + OutputItFaces fit, + OutputItBoundaryEdges eit, + Vertex_handle start = + Vertex_handle()) const { + boost::tuples::tuple + tup = + get_conflicts_and_boundary_and_hidden_vertices(p, + fit, + eit, + Emptyset_iterator(), + start); + return std::make_pair( boost::tuples::get<0>(tup), + boost::tuples::get<1>(tup) ); + } + + + template + std::pair + get_boundary_of_conflicts_and_hidden_vertices(const Site_2& p, + OutputItBoundaryEdges eit, + OutputItHiddenVertices vit, + Vertex_handle start = + Vertex_handle()) const { + boost::tuples::tuple + tup = + get_conflicts_and_boundary_and_hidden_vertices(p, + Emptyset_iterator(), + eit, + vit, + start); + return std::make_pair( boost::tuples::get<1>(tup), + boost::tuples::get<2>(tup) ); + } + + + template + std::pair + get_conflicts_and_hidden_vertices(const Site_2& p, + OutputItFaces fit, + OutputItHiddenVertices vit, + Vertex_handle start = + Vertex_handle()) const { + boost::tuples::tuple + tup = + get_conflicts_and_boundary_and_hidden_vertices(p, + fit, + Emptyset_iterator(), + vit, + start); + return std::make_pair( boost::tuples::get<0>(tup), + boost::tuples::get<2>(tup) ); + } + + template + OutputItFaces get_conflicts(const Site_2& p, + OutputItFaces fit, + Vertex_handle start = Vertex_handle()) const { + boost::tuples::tuple + tup = + get_conflicts_and_boundary_and_hidden_vertices(p, + fit, + Emptyset_iterator(), + Emptyset_iterator(), + start); + return boost::tuples::get<0>(tup); + } + + template + OutputItBoundaryEdges + get_boundary_of_conflicts(const Site_2& p, + OutputItBoundaryEdges eit, + Vertex_handle start = Vertex_handle()) const { + boost::tuples::tuple + tup = + get_conflicts_and_boundary_and_hidden_vertices(p, + Emptyset_iterator(), + eit, + Emptyset_iterator(), + start); + return boost::tuples::get<1>(tup); + } + + template + OutputItHiddenVertices + get_hidden_vertices(const Site_2& p, + OutputItHiddenVertices vit, + Vertex_handle start = Vertex_handle()) const { + boost::tuples::tuple + tup = + get_conflicts_and_boundary_and_hidden_vertices(p, + Emptyset_iterator(), + Emptyset_iterator(), + vit, + start); + return boost::tuples::get<2>(tup); + } + + +}; // Apollonius_graph_2 + +template +std::ostream& operator<<(std::ostream& os, + const Apollonius_graph_2& ag) +{ + ag.file_output(os); + return os; +} + +template +std::istream& operator>>(std::istream& is, + Apollonius_graph_2& ag) +{ + ag.file_input(is); + return is; +} + +} //namespace CGAL + +#include + +#include + +#endif // CGAL_APOLLONIUS_GRAPH_2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Bounded_side_of_ccw_circle_C2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Bounded_side_of_ccw_circle_C2.h new file mode 100644 index 00000000000..bbef2be6ac0 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Bounded_side_of_ccw_circle_C2.h @@ -0,0 +1,98 @@ +// Copyright (c) 2003,2004,2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_BOUNDED_SIDE_OF_CCW_CIRCLE_C2_H +#define CGAL_APOLLONIUS_GRAPH_2_BOUNDED_SIDE_OF_CCW_CIRCLE_C2_H + +#include + + +#include +#include + + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +//-------------------------------------------------------------------- + +template< class K > +class Sign_of_Voronoi_radius +{ +public: + typedef Voronoi_radius_2 Voronoi_radius; + typedef typename K::FT FT; + typedef typename K::Sign Sign; + +public: + + inline + Sign operator()(const Voronoi_radius& vr, const Field_with_sqrt_tag&) const + { + FT r = vr.c1() + vr.c2() * CGAL::sqrt(vr.delta()); + return CGAL::sign(r); + } + + + inline + Sign operator()(const Voronoi_radius& vr, const Integral_domain_without_division_tag&) const + { + // this is another way of doing this; the degree becomes 10 + // instead of 5 in this case. + // return sign_a_plus_b_x_sqrt_c(vr.c1(), vr.c2(), vr.delta()); + + bool is_first_root = CGAL::is_negative(vr.c2()); + + Sign s_beta = CGAL::sign(vr.b()); + Sign s_gamma = CGAL::sign(vr.c()); + + // the existence test + Sign sign_of_root; + if ( is_first_root ) { + sign_of_root = sign_of_first_root(s_beta, s_gamma); + } else { + sign_of_root = sign_of_second_root(s_beta, s_gamma); + } + return sign_of_root; + } +}; + +template< class K > +class Bounded_side_of_CCW_circle_2 +{ +private: + Sign_of_Voronoi_radius test; + +public: + typedef Voronoi_radius_2 Voronoi_radius; + typedef typename K::Bounded_side Bounded_dide; + +public: + template + inline Bounded_side + operator()(const Voronoi_radius& vr, const Tag& tag) + { + return enum_cast( -test(vr, tag ) ); + } +}; + + +//-------------------------------------------------------------------- + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_BOUNDED_SIDE_OF_CCW_CIRCLE_C2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Compare_weight_2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Compare_weight_2.h new file mode 100644 index 00000000000..d6aa847c7c1 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Compare_weight_2.h @@ -0,0 +1,52 @@ +// Copyright (c) 2003,2004,2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_COMPARE_WEIGHT_2_H +#define CGAL_APOLLONIUS_GRAPH_2_COMPARE_WEIGHT_2_H + +#include + + +#include + +//-------------------------------------------------------------------- + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +template +class Compare_weight_2 +{ +public: + typedef K Kernel; + typedef typename K::Site_2 Site_2; + + typedef typename K::Comparison_result result_type; + typedef Site_2 argument_type; + + inline + result_type operator()(const Site_2& s1, const Site_2& s2) const + { + return CGAL::compare(s1.weight(), s2.weight()); + } +}; + +//-------------------------------------------------------------------- + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_COMPARE_WEIGHT_2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Compare_x_2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Compare_x_2.h new file mode 100644 index 00000000000..4f5ea415f5f --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Compare_x_2.h @@ -0,0 +1,52 @@ +// Copyright (c) 2003,2004,2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_COMPARE_X_2_H +#define CGAL_APOLLONIUS_GRAPH_2_COMPARE_X_2_H + +#include + + +#include + +//-------------------------------------------------------------------- + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +template +class Compare_x_2 +{ +public: + typedef K Kernel; + typedef typename K::Site_2 Site_2; + + typedef typename K::Comparison_result result_type; + typedef Site_2 argument_type; + + inline + result_type operator()(const Site_2& s1, const Site_2& s2) const + { + return CGAL::compare(s1.x(), s2.x()); + } +}; + +//-------------------------------------------------------------------- + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_COMPARE_X_2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Compare_y_2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Compare_y_2.h new file mode 100644 index 00000000000..c6086a430d3 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Compare_y_2.h @@ -0,0 +1,52 @@ +// Copyright (c) 2003,2004,2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_COMPARE_Y_2_H +#define CGAL_APOLLONIUS_GRAPH_2_COMPARE_Y_2_H + +#include + + +#include + +//-------------------------------------------------------------------- + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +template +class Compare_y_2 +{ +public: + typedef K Kernel; + typedef typename K::Site_2 Site_2; + + typedef typename K::Comparison_result result_type; + typedef Site_2 argument_type; + + inline + result_type operator()(const Site_2& s1, const Site_2& s2) const + { + return CGAL::compare(s1.y(), s2.y()); + } +}; + +//-------------------------------------------------------------------- + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_COMPARE_Y_2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Constructions_C2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Constructions_C2.h new file mode 100644 index 00000000000..2c72c8e7c8d --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Constructions_C2.h @@ -0,0 +1,430 @@ +// Copyright (c) 2003,2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_CONSTRUCTIONS_C2_H +#define CGAL_APOLLONIUS_GRAPH_2_CONSTRUCTIONS_C2_H 1 + +#include + + +#include + +#include +#include +#include +#include + + +#include + + + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +//*********************************************************************** +//*********************************************************************** +// CONSTRUCTIONS +//*********************************************************************** +//*********************************************************************** + + +//----------------------------------------------------------------------- +// Apollonius vertex +//----------------------------------------------------------------------- + +template < class Gt > +inline +typename Gt::Point_2 +ad_circumcenter_2(const typename Gt::Site_2& p, + const typename Gt::Site_2& q, + const typename Gt::Site_2& r) +{ + typedef typename Gt::Point_2 Point_2; + + typename Gt::FT x,y; + ad_circumcenterC2(p.x(),p.y(),p.weight(), + q.x(),q.y(),q.weight(), + r.x(),r.y(),r.weight(),x,y); + return Point_2(x,y); +} + + +template < class Gt > +class Construct_Apollonius_vertex_2 +{ +public: + typedef typename Gt::Point_2 Point_2; + typedef typename Gt::Site_2 Site_2; + + typedef Point_2 result_type; + + Point_2 operator() (const Site_2& p, const Site_2& q, + const Site_2& r) const + { + return ad_circumcenter_2< Gt >(p,q,r); + } +}; + + +//----------------------------------------------------------------------- +// Apollonius site (dual site) +//----------------------------------------------------------------------- +template < class Gt > +inline +typename Gt::Site_2 +ad_circumcircle_2(const typename Gt::Site_2& p, + const typename Gt::Site_2& q, + const typename Gt::Site_2& r) +{ + typedef typename Gt::Site_2 Site_2; + typedef typename Gt::Point_2 Point_2; + + typename Gt::FT x, y, wt; + ad_circumcircleC2(p.x(),p.y(),p.weight(), + q.x(),q.y(),q.weight(), + r.x(),r.y(),r.weight(),x,y,wt); + return Site_2(Point_2(x,y), wt); +} + +template < class Gt > +inline +typename Gt::Line_2 +ad_left_bitangent_line_2(const typename Gt::Site_2& p, + const typename Gt::Site_2& q) +{ + typedef typename Gt::Line_2 Line_2; + + typename Gt::FT a, b, c; + ad_left_bitangent_lineC2(p.x(),p.y(),p.weight(), + q.x(),q.y(),q.weight(), + a,b,c); + return Line_2(a, b, c); +} + + +template < class Gt > +class Construct_Apollonius_site_2 +{ +public: + typedef typename Gt::Line_2 Line_2; + typedef typename Gt::Point_2 Point_2; + typedef typename Gt::Site_2 Site_2; + +#if 0 + // WARNING: the following type is just a hack; it is not + // really valid + typedef Site_2 result_type; +#endif + + inline Site_2 operator()(const Site_2& p, + const Site_2& q, + const Site_2& r) const + { + // CGAL_precondition( ! collinear(p, q, r) ); + return ad_circumcircle_2< Gt >(p,q,r); + } + + inline Line_2 operator()(const Site_2 &p, + const Site_2 &q) const + { + return ad_left_bitangent_line_2< Gt >(p, q); + } +}; + + +//----------------------------------------------------------------------- +// Apollonius bisector +//----------------------------------------------------------------------- + + +template< class Gt > +class Construct_Apollonius_bisector_2 +{ +public: + typedef typename Gt::Point_2 Point_2; + typedef typename Gt::Line_2 Line_2; + typedef typename Gt::Site_2 Site_2; + typedef typename Gt::Object_2 Object_2; + typedef typename Gt::Construct_object_2 Construct_object_2; + typedef CGAL::Hyperbola_2 Hyperbola_2; + +private: + template + Object_2 make_object(const T& t) const + { + return Construct_object_2()(t); + } + +public: + Object_2 operator() (const Site_2& p, const Site_2& q) const + { + Comparison_result cr = CGAL::compare(p.weight(), q.weight()); + if ( cr == EQUAL ) { + Line_2 l1(p.point(), q.point()); + Line_2 l = l1.perpendicular(midpoint(p.point(), q.point())); + return make_object(l); + } + + Hyperbola_2 h(p, q); + return make_object(h); + } +}; + +//----------------------------------------------------------------------- +// Apollonius bisector ray +//----------------------------------------------------------------------- + + +template< class Gt > +class Construct_Apollonius_bisector_ray_2 +{ +public: + typedef typename Gt::Point_2 Point_2; + typedef typename Gt::Line_2 Line_2; + typedef typename Gt::Ray_2 Ray_2; + typedef typename Gt::Site_2 Site_2; + typedef typename Gt::Object_2 Object_2; + typedef typename Gt::Construct_object_2 Construct_object_2; + typedef typename Gt::Construct_Apollonius_vertex_2 Apollonius_vertex_2; + typedef CGAL::Hyperbola_ray_2 Hyperbola_ray_2; + typedef CGAL::Sign Hyperbola_direction; + +private: + template + Object_2 make_object(const T& t) const + { + return Construct_object_2()(t); + } + +public: + Object_2 + operator() (const Site_2& p, + const Site_2& q, + const Point_2& r, + const Hyperbola_direction& direction) const { + // + Comparison_result cr = CGAL::compare(p.weight(), q.weight()); + if ( cr == EQUAL ) { + Line_2 l1(p.point(), q.point()); + Line_2 l = l1.perpendicular(midpoint(p.point(), q.point())); + Ray_2 ray(r, l.direction()); + return make_object(ray); + } + Hyperbola_ray_2 hr(p, q, r, direction); + return make_object(hr); + } + + Object_2 + operator() (const Site_2& p, + const Site_2& q, + const Site_2& r) const { + Point_2 c = Apollonius_vertex_2()(p, q, r); + Comparison_result cr = CGAL::compare(p.weight(), q.weight()); + if ( cr == EQUAL ) { + Line_2 l1(q.point(), p.point()); + Line_2 l = l1.perpendicular(midpoint(p.point(), q.point())); + Ray_2 ray(c, l.direction()); + return make_object(ray); + } + Hyperbola_ray_2 hr(p, q, c, NEGATIVE); + return make_object(hr); + } +}; + +//----------------------------------------------------------------------- +// Apollonius bisector segment +//----------------------------------------------------------------------- + +template< class Gt > +class Construct_Apollonius_bisector_segment_2 +{ +public: + typedef typename Gt::Point_2 Point_2; + typedef typename Gt::Segment_2 Segment_2; + typedef typename Gt::Site_2 Site_2; + typedef typename Gt::Object_2 Object_2; + typedef typename Gt::Construct_object_2 Construct_object_2; + typedef typename Gt::Construct_Apollonius_vertex_2 Apollonius_vertex_2; + typedef CGAL::Hyperbola_segment_2 Hyperbola_segment_2; + +private: + template + Object_2 make_object(const T& t) const + { + return Construct_object_2()(t); + } + +public: + inline Object_2 operator() (const Site_2& p, + const Site_2& q, + const Point_2& r, const Point_2& s) const { + // + Comparison_result cr = CGAL::compare(p.weight(), q.weight()); + if ( cr == EQUAL ) { + Segment_2 seg(r, s); + return make_object(seg); + } + Hyperbola_segment_2 hs(p, q, r, s); + return make_object(hs); + } + + inline Object_2 operator() (const Site_2& p, + const Site_2& q, + const Site_2& r, + const Site_2& s) const { + Apollonius_vertex_2 apollonius_vertex_2; + Point_2 c_pqr = apollonius_vertex_2(p,q,r); + Point_2 c_qps = apollonius_vertex_2(q,p,s); + // + Comparison_result cr = CGAL::compare(p.weight(), q.weight()); + if ( cr == EQUAL ) { + Segment_2 seg(c_pqr, c_qps); + return make_object(seg); + } + Hyperbola_segment_2 hs(p, q, c_pqr, c_qps); + return make_object(hs); + } + +}; + +//----------------------------------------------------------------------- +// Apollonius primal ray +//----------------------------------------------------------------------- + + +template< class Gt > +class Construct_Apollonius_primal_ray_2 +{ +private: + typedef typename Gt::RT RT; + +public: + typedef typename Gt::Point_2 Point_2; + typedef typename Gt::Line_2 Line_2; + typedef typename Gt::Ray_2 Ray_2; + typedef typename Gt::Site_2 Site_2; + typedef typename Gt::Construct_Apollonius_site_2 Apollonius_circle_2; + + inline Ray_2 operator() (const Site_2& p, + const Site_2& r, + const Site_2& s) const { + // + Apollonius_circle_2 apollonius_circle_2; + Line_2 l1 = apollonius_circle_2(r, p); + Line_2 l2 = apollonius_circle_2(p, s); + + RT d1 = CGAL::sqrt( CGAL::square(l1.a()) + CGAL::square(l1.b()) ); + RT d2 = CGAL::sqrt( CGAL::square(l2.a()) + CGAL::square(l2.b()) ); + RT a = l1.a() / d1 - l2.a() / d2; + RT b = l1.b() / d1 - l2.b() / d2; + Point_2 c(p.x() + b, p.y() - a); + return Ray_2(p.point(), c); + } +}; + +//----------------------------------------------------------------------- +// Apollonius primal segment +//----------------------------------------------------------------------- + +template< class Gt > +class Construct_Apollonius_primal_segment_2 +{ +public: + typedef typename Gt::Point_2 Point_2; + typedef typename Gt::Line_2 Line_2; + typedef typename Gt::Segment_2 Segment_2; + typedef typename Gt::Site_2 Site_2; + typedef typename Gt::Object_2 Object_2; + typedef typename Gt::Construct_object_2 Construct_object_2; + typedef typename Gt::RT Weight; + typedef CGAL::Hyperbola_segment_2 Hyperbola_segment_2; + typedef CGAL::Parabola_segment_2 Parabola_segment_2; + typedef typename Gt::Construct_Apollonius_site_2 Apollonius_circle_2; + typedef typename Gt::Construct_Apollonius_vertex_2 Apollonius_vertex_2; + typedef typename Gt::Is_degenerate_edge_2 Is_degenerate_edge_2; + +private: + template + Object_2 make_object(const T& t) const + { + return Construct_object_2()(t); + } + +public: + + inline Segment_2 + operator() (const Site_2& p, + const Site_2& q) const { + // + return Segment_2(p.point(), q.point()); + } + + inline Object_2 + operator() (const Site_2& p, + const Site_2& q, + const Point_2& r, const Point_2& s) const { + // + Comparison_result cr = CGAL::compare(p.weight(), q.weight()); + if ( cr == EQUAL ) { + Segment_2 seg(r, s); + return make_object(seg); + } + Hyperbola_segment_2 hs(p, q, r, s); + return make_object(hs); + } + + inline Object_2 + operator() (const Site_2& p, + const Site_2& q, + const Site_2& r, + const Site_2& s) const { + if ( Is_degenerate_edge_2()(p, q, r, s) ) { + Point_2 v = Apollonius_vertex_2()(p, q, r); + Segment_2 seg1(p.point(), v); + Segment_2 seg2(v, q.point()); + return make_object(std::pair(seg1, seg2)); + } + Apollonius_circle_2 apollonius_circle_2; + Site_2 c_pqr = apollonius_circle_2(p, q, r); + Site_2 c_qps = apollonius_circle_2(q, p, s); + // + Comparison_result cr = CGAL::compare(c_pqr.weight(), c_qps.weight()); + if ( cr == EQUAL ) { + Segment_2 seg(p.point(), q.point()); + return make_object(seg); + } + Hyperbola_segment_2 hs(c_pqr, c_qps, p.point(), q.point()); + return make_object(hs); + } + + inline Parabola_segment_2 + operator() (const Site_2& p, + const Site_2& q, + const Site_2& r) const { + // + Apollonius_circle_2 apollonius_circle_2; + Site_2 c = apollonius_circle_2(p, q, r); + Line_2 l = apollonius_circle_2(q, p); + return Parabola_segment_2(c, l, q.point(), p.point()); + } +}; + + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_CONSTRUCTIONS_C2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Constructions_ftC2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Constructions_ftC2.h new file mode 100644 index 00000000000..f76cd7bd856 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Constructions_ftC2.h @@ -0,0 +1,182 @@ +// Copyright (c) 2003,2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_CONSTRUCTIONS_FTC2_H +#define CGAL_APOLLONIUS_GRAPH_2_CONSTRUCTIONS_FTC2_H 1 + +#include + + +#include +#include + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +template < class FT > +inline +void +invert_C2(const FT &x, const FT &y, const FT &wt, + FT &new_x, FT &new_y, FT &new_wt) +{ + FT p = CGAL::square(x) + CGAL::square(y) - CGAL::square(wt); + + CGAL_assertion( CGAL::is_positive(p) ); + + new_x = x / p; + new_y = -y / p; + new_wt = wt / p; +} + + +template < class FT > +void +w_plane_tangent_line_2(const FT &x1, const FT &y1, const FT &w1, + const FT &x2, const FT &y2, const FT &w2, + const FT &x3, const FT &y3, const FT &w3, + FT & a, FT & b, FT & c) +{ + // we assume that the weight w1 is the smallest among w1, w2, w3. + + FT u2, v2; + FT u3, v3; + FT r2, r3; + + invert_C2(x2-x1, y2-y1, w2-w1, u2, v2, r2); + invert_C2(x3-x1, y3-y1, w3-w1, u3, v3, r3); + + FT Du = u2 - u3; + FT Dv = v2 - v3; + FT Dr = r2 - r3; + + FT Duv = determinant(u2, v2, u3, v3); + FT Dur = determinant(u2, r2, u3, r3); + FT Dvr = determinant(v2, r2, v3, r3); + + FT D1 = CGAL::square(Du) + CGAL::square(Dv); + FT D1inv = FT(1) / D1; + FT sqrtD = CGAL::sqrt(D1 - CGAL::square(Dr)); + + a = (Du * Dr - Dv * sqrtD) * D1inv; + b = (Dv * Dr + Du * sqrtD) * D1inv; + c = (Du * Dur + Dv * Dvr - Duv * sqrtD) * D1inv; +} + + +template < class FT > +inline +void +z_plane_circumcircle_2(const FT &x1, const FT &y1, const FT &w1, + const FT &x2, const FT &y2, const FT &w2, + const FT &x3, const FT &y3, const FT &w3, + FT &cx, FT &cy, FT &cwt) +{ + // we assume that the weight w1 is the smallest among w1, w2, w3. + + FT a, b, c; + w_plane_tangent_line_2(x1, y1, w1, x2, y2, w2, + x3, y3, w3, a, b, c); + + cx = -a / (FT(2) * c) + x1; + cy = b / (FT(2) * c) + y1; + + // this the only part that is computed at vain when only the center + // is needed. +#if 0 + FT cwt2 = (CGAL::square(a) + CGAL::square(b)) / + (FT(4) * CGAL::square(c)); +#endif + // cwt = CGAL::sqrt(cwt2) - FT(w1); + cwt = FT(1) / (FT(2) * c) - FT(w1); +} + + + +template < class FT > +void +ad_circumcircleC2(const FT &x1, const FT &y1, const FT &w1, + const FT &x2, const FT &y2, const FT &w2, + const FT &x3, const FT &y3, const FT &w3, + FT &cx, FT &cy, FT &cwt) +{ + if (CGAL::compare(w2, w1) != LARGER && + CGAL::compare(w2, w3) != LARGER) { + z_plane_circumcircle_2(x2, y2, w2, + x3, y3, w3, + x1, y1, w1, + cx, cy, cwt); + return; + } else if (CGAL::compare(w3, w1) != LARGER && + CGAL::compare(w3, w2) != LARGER) { + z_plane_circumcircle_2(x3, y3, w3, + x1, y1, w1, + x2, y2, w2, + cx, cy, cwt); + return; + } + z_plane_circumcircle_2(x1, y1, w1, + x2, y2, w2, + x3, y3, w3, + cx, cy, cwt); +} + +template < class FT > +inline +void +ad_circumcenterC2(const FT &x1, const FT &y1, const FT &w1, + const FT &x2, const FT &y2, const FT &w2, + const FT &x3, const FT &y3, const FT &w3, + FT &cx, FT &cy) +{ + FT cwt; + ad_circumcircleC2(x1, y1, w1, + x2, y2, w2, + x3, y3, w3, + cx, cy, cwt); +} + + +template < class FT > +void +ad_left_bitangent_lineC2(const FT &x1, const FT &y1, const FT &w1, + const FT &x2, const FT &y2, const FT &w2, + FT & a, FT & b, FT & c) +{ + FT dx = x1 - x2; + FT dy = y1 - y2; + FT dw = w1 - w2; + + FT dxw = determinant(x1, w1, x2, w2); + FT dyw = determinant(y1, w1, y2, w2); + FT dxy = determinant(x1, y1, x2, y2); + + FT D1 = CGAL::square(dx) + CGAL::square(dy); + FT invD1 = FT(1) / D1; + FT D = D1 - CGAL::square(dw); + FT sqrtD = CGAL::sqrt(D); + + a = -(dx * dw - dy * sqrtD) * invD1; + b = -(dy * dw + dx * sqrtD) * invD1; + c = -(dx * dxw + dy * dyw - dxy * sqrtD) * invD1; +} + + + + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_CONSTRUCTIONS_FTC2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Constructions_rtH2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Constructions_rtH2.h new file mode 100644 index 00000000000..025ecae27e4 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Constructions_rtH2.h @@ -0,0 +1,79 @@ +// Copyright (c) 2003 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_CONSTRUCTIONS_RTH2_H +#define CGAL_APOLLONIUS_GRAPH_2_CONSTRUCTIONS_RTH2_H + +#include + + +#include + +#include + +namespace CGAL { + +template < class RT, class We > +inline +void +ad_circumcenterH2(const RT &hx1, const RT &hy1, const RT &hw1, + const We &w1, + const RT &hx2, const RT &hy2, const RT &hw2, + const We &w2, + const RT &hx3, const RT &hy3, const RT &hw3, + const We &w3, + RT & cx, RT & cy, RT & cw) +{ + We cwt; + ad_circumcircleH2(hx1, hy1, hw1, w1, + hx2, hy2, hw2, w2, + hx3, hy3, hw3, w3, + cx, cy, cw, cwt); +} + +template < class RT, class We > +inline +void +ad_circumcircleH2(const RT &hx1, const RT &hy1, const RT &hw1, + const We &w1, + const RT &hx2, const RT &hy2, const RT &hw2, + const We &w2, + const RT &hx3, const RT &hy3, const RT &hw3, + const We &w3, + RT & cx, RT & cy, RT & cw, + We &cwt) +{ + ad_circumcircleC2(RT(hx1/hw1), RT(hy1/hw1), w1, + RT(hx2/hw2), RT(hy2/hw2), w2, + RT(hx3/hw3), RT(hy3/hw3), w3, + cx, cy, cwt); + cw = RT(1); +} + + +template < class RT, class We > +void +ad_left_bitangent_lineH2(const FT &hx1, const FT &hy1, const We &w1, + const FT &hx2, const FT &hy2, const We &w2, + RT & a, RT & b, RT & c) +{ + ad_left_bitangent_lineC2(RT(hx1/hw1), RT(hy1/hw1), w1, + RT(hx2/hw2), RT(hy2/hw2), w2, + a, b, c); +} + + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_CONSTRUCTIONS_RTH2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Finite_edge_test8_C2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Finite_edge_test8_C2.h new file mode 100644 index 00000000000..224952827d6 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Finite_edge_test8_C2.h @@ -0,0 +1,752 @@ +// Copyright (c) 2007 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_FINITE_EDGE_TEST8_C2_H +#define CGAL_APOLLONIUS_GRAPH_2_FINITE_EDGE_TEST8_C2_H + +#include + + +#include +#include +#include + + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +//-------------------------------------------------------------------- +//-------------------------------------------------------------------- + +template < class K, class MTag > +class Inside_Voronoi_quadrilateral8 +{ +public: + typedef K Kernel; + typedef MTag Method_tag; + typedef typename K::Site_2 Site_2; + typedef typename K::Orientation Orientation; + typedef typename K::Oriented_side Oriented_side; + +private: + typedef Orientation8_C2 Orientation_2; + typedef Constructive_orientation8_C2 Constructive_orientation_2; + typedef Oriented_side_of_bisector_2 Side_of_bisector_2; + +public: + bool + operator()(const Site_2& p1, + const Site_2& p2, + const Site_2& p3, + const Site_2& p4, + const Site_2& q, bool b, const Method_tag& tag) const + { +#if 1 + Constructive_orientation_2 orientation123(p1, p2, p3, true); + Constructive_orientation_2 orientation142(p1, p4, p2, false); + + Orientation o123_s = orientation123(); + Orientation o142_s = orientation142(); + +#if 0 +#ifndef NDEBUG + Orientation o123_s1 = orientation123(p1, p2); + Orientation o142_s1 = orientation142(p1, p2); + + CGAL_assertion( o123_s == o123_s1 ); + CGAL_assertion( o142_s == o142_s1 ); +#endif +#endif + + // first we consider the case where both Voronoi circles are in + // conflict; we want to determine if the entire edge is in + // conflict + + if ( b ) { + if ( o123_s != o142_s ) { + Orientation o123_1 = orientation123(p1, q); + Orientation o123_2 = orientation123(p2, q); + if ( o123_1 == POSITIVE && o123_2 == NEGATIVE ) { return true; } + + Orientation o142_1 = orientation142(p1, q); + Orientation o142_2 = orientation142(p2, q); + return (o142_1 == NEGATIVE && o142_2 == POSITIVE); + } + + Oriented_side os = Side_of_bisector_2()(p1, p2, q.point()); + + if ( o123_s == POSITIVE ) { + if ( os == ON_POSITIVE_SIDE ) { + Orientation o142_1 = orientation142(p1, q); + if ( o142_1 == NEGATIVE ) { return true; } + + Orientation o123_1 = orientation123(p1, q); + return o123_1 == POSITIVE; + } + + Orientation o142_2 = orientation142(p2, q); + if ( o142_2 == POSITIVE ) { return true; } + + Orientation o123_2 = orientation123(p2, q); + return o123_2 == NEGATIVE; + } + + if ( o123_s == NEGATIVE ) { + if ( os == ON_POSITIVE_SIDE ) { + Orientation o123_1 = orientation123(p1, q); + if ( o123_1 == POSITIVE ) { return true; } + + Orientation o142_1 = orientation142(p1, q); + return o142_1 == NEGATIVE; + } + + Orientation o123_2 = orientation123(p2, q); + if ( o123_2 == NEGATIVE ) { return true; } + + Orientation o142_2 = orientation142(p2, q); + return o142_2 == POSITIVE; + } + + CGAL_assertion( o123_s == ZERO ); + return true; + } + + // now consider the case where the two Voronoi circles are not in + // conflict; we want to determine if part of the interior is in + // conflict + + if ( o123_s != o142_s ) { + Orientation o123_1 = orientation123(p1, q); + if ( o123_1 != POSITIVE ) { return false; } + + Orientation o123_2 = orientation123(p2, q); + if ( o123_2 != NEGATIVE ) { return false; } + + Orientation o142_1 = orientation142(p1, q); + if ( o142_1 != NEGATIVE ) { return false; } + + Orientation o142_2 = orientation142(p2, q); + return o142_2 == POSITIVE; + } + + Oriented_side os = Side_of_bisector_2()(p1, p2, q.point()); + + if ( o123_s == POSITIVE ) { + if ( os == ON_POSITIVE_SIDE ) { + Orientation o123_1 = orientation123(p1, q); + if ( o123_1 != POSITIVE ) { return false; } + + Orientation o142_1 = orientation142(p1, q); + return o142_1 == NEGATIVE; + } + + Orientation o123_2 = orientation123(p2, q); + if ( o123_2 != NEGATIVE ) { return false; } + + Orientation o142_2 = orientation142(p2, q); + return o142_2 == POSITIVE; + } + + if ( o123_s == NEGATIVE ) { + if ( os == ON_POSITIVE_SIDE ) { + Orientation o142_1 = orientation142(p1, q); + if ( o142_1 != NEGATIVE ) { return false; } + + Orientation o123_1 = orientation123(p1, q); + return o123_1 == POSITIVE; + } + Orientation o142_2 = orientation142(p2, q); + if ( o142_2 != POSITIVE ) { return false; } + + Orientation o123_2 = orientation123(p2, q); + return o123_2 == NEGATIVE; + } + + CGAL_assertion( o123_s == ZERO ); + return false; + +#if 0 + if ( os == ON_POSITIVE_SIDE ) { + Orientation o123_1 = orientation(p1, p2, p3, p1, q); + Orientation o142_1 = orientation(p1, p4, p2, p1, q); + // std::cerr << "o123_1: " << o123_1 << std::endl; + // std::cerr << "o142_1: " << o142_1 << std::endl; + + if ( b ) { + return !(o123_1 == NEGATIVE && o142_1 == POSITIVE); + } + return o123_1 == POSITIVE && o142_1 == NEGATIVE; + } + + Orientation o123_2 = orientation(p1, p2, p3, p2, q); + Orientation o142_2 = orientation(p1, p4, p2, p2, q); + // std::cerr << "o123_2: " << o123_2 << std::endl; + // std::cerr << "o142_2: " << o142_2 << std::endl; + + if ( b ) { + return !(o123_2 == POSITIVE && o142_2 == NEGATIVE); + } + return o123_2 == NEGATIVE && o142_2 == POSITIVE; +#endif +#else + Constructive_orientation_2 orientation123(p1, p2, p3); + Constructive_orientation_2 orientation142(p1, p4, p2); + + Orientation o123_s = orientation123(p1, p2); + Orientation o142_s = orientation142(p1, p2); + + // first we consider the case where both Voronoi circles are in + // conflict; we want to determine if the entire edge is in + // conflict + + if ( b ) { + if ( o123_s != o142_s ) { + Orientation o123_1 = orientation123(p1, q); + Orientation o123_2 = orientation123(p2, q); + if ( o123_1 == POSITIVE && o123_2 == NEGATIVE ) { return true; } + + Orientation o142_1 = orientation142(p1, q); + Orientation o142_2 = orientation142(p2, q); + return (o142_1 == NEGATIVE && o142_2 == POSITIVE); + } + + if ( o123_s == POSITIVE ) { + Orientation o142_1 = orientation142(p1, q); + if ( o142_1 == NEGATIVE ) { return true; } + + Orientation o142_2 = orientation142(p2, q); + if ( o142_2 == POSITIVE ) { return true; } + + Orientation o123_1 = orientation123(p1, q); + if ( o123_1 != POSITIVE ) { return false; } + + Orientation o123_2 = orientation123(p2, q); + return o123_2 == NEGATIVE; + } + + if ( o123_s == NEGATIVE ) { + Orientation o123_1 = orientation123(p1, q); + if ( o123_1 == POSITIVE ) { return true; } + + Orientation o123_2 = orientation123(p2, q); + if ( o123_2 == NEGATIVE ) { return true; } + + Orientation o142_1 = orientation142(p1, q); + if ( o142_1 != NEGATIVE ) { return false; } + + Orientation o142_2 = orientation142(p2, q); + return o142_2 == POSITIVE; + } + + CGAL_assertion( o123_s == ZERO ); + return true; + } + + // now consider the case where the two Voronoi circles are not in + // conflict; we want to determine if part of the interior is in + // conflict + + if ( o123_s != o142_s ) { + Orientation o123_1 = orientation123(p1, q); + if ( o123_1 != POSITIVE ) { return false; } + + Orientation o123_2 = orientation123(p2, q); + if ( o123_2 != NEGATIVE ) { return false; } + + Orientation o142_1 = orientation142(p1, q); + if ( o142_1 != NEGATIVE ) { return false; } + + Orientation o142_2 = orientation142(p2, q); + return o142_2 == POSITIVE; + } + + if ( o123_s == POSITIVE ) { + Orientation o123_1 = orientation123(p1, q); + if ( o123_1 != POSITIVE ) { return false; } + + Orientation o123_2 = orientation123(p2, q); + if ( o123_2 != NEGATIVE ) { return false; } + + Orientation o142_1 = orientation142(p1, q); + if ( o142_1 == NEGATIVE ) { return true; } + + Orientation o142_2 = orientation142(p2, q); + return o142_2 == POSITIVE; + } + + if ( o123_s == NEGATIVE ) { + Orientation o142_1 = orientation142(p1, q); + if ( o142_1 != NEGATIVE ) { return false; } + + Orientation o142_2 = orientation142(p2, q); + if ( o142_2 != POSITIVE ) { return false; } + + Orientation o123_1 = orientation123(p1, q); + if ( o123_1 == POSITIVE ) { return true; } + + Orientation o123_2 = orientation123(p2, q); + return o123_2 == NEGATIVE; + } + + CGAL_assertion( o123_s == ZERO ); + return false; +#endif + } +}; + +//-------------------------------------------------------------------- + +template < class K, class MTag > +class Finite_edge_interior_conflict8 +{ +public: + typedef MTag Method_tag; + + typedef typename K::Site_2 Site_2; + typedef Weighted_point_inverter_2 Weighted_point_inverter; + typedef Inverted_weighted_point_2 Inverted_weighted_point; + typedef Voronoi_radius_2 Voronoi_radius; + typedef Voronoi_circle_2 Voronoi_circle; + typedef Bitangent_line_2 Bitangent_line; + typedef typename K::FT FT; + typedef typename K::Sign Sign; + typedef typename K::Bounded_side Bounded_side; + typedef typename K::Comparison_result Comparison_result; + + typedef Bounded_side_of_CCW_circle_2 Bounded_side_of_CCW_circle; + + typedef Sign_of_distance_from_bitangent_line_2 + Sign_of_distance_from_bitangent_line; + + typedef Sign_of_distance_from_CCW_circle_2 + Sign_of_distance_from_CCW_circle; + +public: + bool + operator()(const Site_2& p1, + const Site_2& p2, + const Site_2& p3, + const Site_2& p4, + const Site_2& q, bool b, const Method_tag& tag) const + { + typedef Inside_Voronoi_quadrilateral8 Inside_quadrilateral; + +#ifdef AG2_PROFILE_PREDICATES + ag2_predicate_profiler::shadow_region_type_counter++; +#endif + // + Weighted_point_inverter inverter(p1); + Inverted_weighted_point u2 = inverter(p2); + Inverted_weighted_point v = inverter(q); + // + Voronoi_radius vr_12q(u2, v); + Voronoi_radius vr_1q2 = vr_12q.get_symmetric(); + + Bounded_side bs1 = Bounded_side_of_CCW_circle()(vr_12q, tag ); + Bounded_side bs2 = Bounded_side_of_CCW_circle()(vr_1q2, tag ); + + bool is_bs1 = (bs1 == ON_UNBOUNDED_SIDE); + bool is_bs2 = (bs2 == ON_UNBOUNDED_SIDE); + + // both the ccw and cw circles do not exist + if ( !is_bs1 && !is_bs2 ) { + return b; + } + + // the ccw circle exists but not the cw + if ( is_bs1 && !is_bs2 ) { + return b; + } + + // the cw circle exists but not the ccw + if ( !is_bs1 && is_bs2 ) { + return b; + } + + + // both circles exist + + // check whether the shadow region is connected, i.e., whether it is + // of the form (a, b) or (-oo, a) U (b, +oo) + Bitangent_line bl_12(p1, p2); + + Sign stc = + Sign_of_distance_from_bitangent_line()(bl_12, q, tag); + + CGAL_assertion( stc != ZERO ); + bool is_shadow_region_connected = (stc == POSITIVE); + + if ( is_shadow_region_connected ) { + if ( b ) { return true; } + +#if 0 + Inverted_weighted_point u3 = inverter(p3); + Bitangent_line blinv_23(u2, u3); + + Voronoi_circle vc_123(blinv_23); + Voronoi_circle vc_12q(vr_12q); + + + Comparison_result r = + Order_on_finite_bisector()(vc_123, vc_12q, p1, p2, tag); + + if ( r != SMALLER ) { return false; } + + Inverted_weighted_point u4 = inverter(p4); + Bitangent_line blinv_42(u4, u2); + + Voronoi_circle vc_142(blinv_42); + Voronoi_circle vc_1q2(vr_1q2); + r = Order_on_finite_bisector()(vc_142, vc_1q2, p1, p2, tag); + + return ( r == LARGER ); +#else + return Inside_quadrilateral()(p1, p2, p3, p4, q, b, tag); +#endif + } + + // the shadow region is of the form (-oo, a) U (b, +oo) + if ( !b ) { return false; } + +#if 0 + Inverted_weighted_point u3 = inverter(p3); + Bitangent_line blinv_23(u2, u3); + + Voronoi_circle vc_123(blinv_23); + Voronoi_circle vc_1q2(vr_1q2); + Comparison_result r = + Order_on_finite_bisector()(vc_123, vc_1q2, p1, p2, tag); + + if ( r != SMALLER ) { return true; } + + Inverted_weighted_point u4 = inverter(p4); + Bitangent_line blinv_42(u4, u2); + + Voronoi_circle vc_142(blinv_42); + Voronoi_circle vc_12q(vr_12q); + r = Order_on_finite_bisector()(vc_142, vc_12q, p1, p2, tag); + + return ( r != LARGER ); +#else + return Inside_quadrilateral()(p1, p2, p3, p4, q, b, tag); +#endif + } +}; + +//-------------------------------------------------------------------- + +template < class K, class MTag > +class Finite_edge_interior_conflict_degenerated8 +{ +public: + typedef typename K::Site_2 Site_2; + typedef Weighted_point_inverter_2 Weighted_point_inverter; + typedef Inverted_weighted_point_2 Inverted_weighted_point; + typedef Voronoi_radius_2 Voronoi_radius; + typedef Voronoi_circle_2 Voronoi_circle; + typedef Bitangent_line_2 Bitangent_line; + typedef typename K::FT FT; + typedef typename K::Sign Sign; + typedef typename K::Comparison_result Comparison_result; + typedef typename K::Orientation Orientation; + typedef typename K::Bounded_side Bounded_side; + typedef typename K::Oriented_side Oriented_side; + + typedef Bounded_side_of_CCW_circle_2 Bounded_side_of_CCW_circle; + typedef Order_on_finite_bisector_2 Order_on_finite_bisector; + typedef Orientation8_C2 Orientation_2; + + typedef Sign_of_distance_from_bitangent_line_2 + Sign_of_distance_from_bitangent_line; + + typedef Sign_of_distance_from_CCW_circle_2 + Sign_of_distance_from_CCW_circle; + + typedef Oriented_side_of_bisector_2 Side_of_bisector_2; + +public: + template + bool + operator()(const Site_2& p1, const Site_2& p2, const Site_2& p3, + const Site_2& q, bool b, const Method_tag& tag) const + { +#ifdef AG2_PROFILE_PREDICATES + ag2_predicate_profiler::shadow_region_type_counter++; +#endif + // + Weighted_point_inverter inverter(p1); + Inverted_weighted_point u2 = inverter(p2); + Inverted_weighted_point v = inverter(q); + + Voronoi_radius vr_12q(u2, v); + Voronoi_radius vr_1q2 = vr_12q.get_symmetric(); + + Bounded_side bs1 = Bounded_side_of_CCW_circle()(vr_12q, tag ); + Bounded_side bs2 = Bounded_side_of_CCW_circle()(vr_1q2, tag ); + + bool is_bs1 = (bs1 == ON_UNBOUNDED_SIDE); + bool is_bs2 = (bs2 == ON_UNBOUNDED_SIDE); + + // both the ccw and cw circles do not exist + if ( !is_bs1 && !is_bs2 ) { + return b; + } + + // the ccw circle exists but not the cw + if ( is_bs1 && !is_bs2 ) { + return b; + } + + // the cw circle exists but not the ccw + if ( !is_bs1 && is_bs2 ) { + return b; + } + + // both circles exist + + // check whether the shadow region is connected, i.e., whether it is + // of the form (a, b) or (-oo, a) U (b, +oo) + Bitangent_line bl_12(p1, p2); + + Sign stc = Sign_of_distance_from_bitangent_line()(bl_12, q, tag); + + Inverted_weighted_point u3 = inverter(p3); + Bitangent_line blinv_23(u2, u3); + + CGAL_assertion( stc != ZERO ); + bool is_shadow_region_connected = (stc == POSITIVE); + + if ( is_shadow_region_connected ) { + // the shadow region is of the form (a, b) + if ( b ) { return false; } + + Voronoi_circle vc_123(blinv_23); + Voronoi_circle vc_12q(vr_12q); + + Comparison_result r = + Order_on_finite_bisector()(vc_123, vc_12q, p1, p2, tag); + + return ( r == SMALLER ); + } + + // the shadow region is of the form (-oo, a) U (b, +oo) + if ( !b ) { return false; } + + Voronoi_circle vc_123(blinv_23); + Voronoi_circle vc_1q2(vr_1q2); + Comparison_result r = + Order_on_finite_bisector()(vc_123, vc_1q2, p1, p2, tag); + + return ( r != SMALLER ); + } + + inline + Sign sqrt_ext_sign(const FT& A1, const FT& Dr, const FT& B, + const FT& Dx1, const FT& Dy1, + const FT& Dx2, const FT& Dy2, + const Field_with_sqrt_tag&) const + { + FT D = CGAL::square(Dx1) + CGAL::square(Dy1) - CGAL::square(Dr); + return CGAL::sign(A1 * Dr + B * CGAL::sqrt(D)); + } + + inline + Sign sqrt_ext_sign(const FT& A1, const FT& Dr, const FT& B, + const FT& Dx1, const FT& Dy1, + const FT& Dx2, const FT& Dy2, + const Integral_domain_without_division_tag&) const + { + Sign sA = CGAL::sign(A1) * CGAL::sign(Dr); + Sign sB = CGAL::sign(B); + + if ( sA == CGAL::ZERO ) { return sB; } + if ( sB == CGAL::ZERO ) { return sA; } + if ( sA == sB ) { return sA; } + + FT C = (CGAL::square(Dx2) + CGAL::square(Dy2)) * CGAL::square(Dr); + return sA * CGAL::sign(C - CGAL::square(B)); + } + + template + Orientation + orientation_wrt_bitangent_perp(const Site_2& p1, const Site_2& p2, + const Site_2& q1, const Site_2& q2, + const Method_tag& tag) const + { + // computes the orientation predicate of the line perpendicular to + // the bitangent of p1 and p2, passing through the center of q1, + // and the center of q2 + + FT Dx1 = p1.x() - p2.x(); + FT Dy1 = p1.y() - p2.y(); + FT Dr = p1.weight() - p2.weight(); + + FT Dx2 = q1.x() - q2.x(); + FT Dy2 = q1.y() - q2.y(); + + FT A1 = Dx1 * Dy2 - Dy1 * Dx2; + FT B = Dx1 * Dx2 + Dy1 * Dy2; + + return sqrt_ext_sign(A1, Dr, B, Dx1, Dy1, Dx2, Dy2, tag); + } + + + + template + bool + operator()(const Site_2& p1, const Site_2& p2, + const Site_2& q, bool b, const Method_tag& tag) const + { +#if 0 + Side_of_bisector_2 side_of_bisector; + Orientation o12_sym = Orientation_2()(p1, p2, q); + + Oriented_side os = side_of_bisector(p1, p2, q.point()); + + if ( o12_sym == CGAL::POSITIVE ) { + if ( os == ON_POSITIVE_SIDE ) { + Orientation o21_1 = orientation_wrt_bitangent_perp(p2, p1, p1, q, tag); + return o21_1 == NEGATIVE; + } + + Orientation o21_2 = orientation_wrt_bitangent_perp(p2, p1, p2, q, tag); + return o21_2 == POSITIVE; + + } else { + if ( os == ON_POSITIVE_SIDE ) { + Orientation o12_1 = orientation_wrt_bitangent_perp(p1, p2, p1, q, tag); + return o12_1 == POSITIVE; + } + + Orientation o12_2 = orientation_wrt_bitangent_perp(p1, p2, p2, q, tag); + return o12_2 == NEGATIVE; + } +#else + Orientation o12_sym = Orientation_2()(p1, p2, q); + + if ( o12_sym == CGAL::POSITIVE ) { + Orientation o21_1 = orientation_wrt_bitangent_perp(p2, p1, p1, q, tag); + + if ( o21_1 != NEGATIVE ) { return false; } + + Orientation o21_2 = orientation_wrt_bitangent_perp(p2, p1, p2, q, tag); + + return o21_2 == POSITIVE; + } else { + Orientation o12_1 = orientation_wrt_bitangent_perp(p1, p2, p1, q, tag); + + if ( o12_1 != POSITIVE ) { return false; } + + Orientation o12_2 = orientation_wrt_bitangent_perp(p1, p2, p2, q, tag); + + return o12_2 == NEGATIVE; + } +#endif +#ifdef AG2_PROFILE_PREDICATES + ag2_predicate_profiler::shadow_region_type_counter++; +#endif + } +}; + +//-------------------------------------------------------------------- + + +template +class Finite_edge_interior_conflict8_2 +{ +public: + typedef K Kernel; + typedef MTag Method_tag; + + typedef typename K::Site_2 Site_2; + +private: + typedef Finite_edge_interior_conflict_degenerated8 Test_degenerated; + typedef Finite_edge_interior_conflict8 Test; + +public: + typedef bool result_type; + struct argument_type {}; + + inline + bool operator()(const Site_2& p1, const Site_2& p2, + const Site_2& q, bool b) const + { + typedef Finite_edge_interior_conflict_2 Old_Test; + bool t = Test_degenerated()(p1, p2, q, b, Method_tag()); + // bool t = Old_Test()(p1, p2, q, b); +#ifndef NDEBUG + bool t_old = Old_Test()(p1, p2, q, b); + + if ( t != t_old ) { + std::cerr << std::endl; + std::cerr << "b: " << b << "; t: " << t + << "; t_old: " << t_old << std::endl; + std::cerr << "p1: " << p1 << std::endl; + std::cerr << "p2: " << p2 << std::endl; + std::cerr << "q: " << q << std::endl; + } + + CGAL_assertion( t == t_old ); +#endif + return t; + } + + inline + bool operator()(const Site_2& p1, const Site_2& p2, + const Site_2& p3, const Site_2& q, bool b) const + { + return Test_degenerated()(p1, p2, p3, q, b, Method_tag()); + } + + inline + bool operator()(const Site_2& p1, const Site_2& p2, + const Site_2& p3, const Site_2& p4, + const Site_2& q, bool b) const + { + typedef Finite_edge_interior_conflict_2 Old_Test; + bool t = Test()(p1, p2, p3, p4, q, b, Method_tag()); + // bool t = Old_Test()(p1, p2, p3, p4, q, b); +#ifndef NDEBUG + bool t_old = Old_Test()(p1, p2, p3, p4, q, b); + + if ( t != t_old ) { + Oriented_side_of_bisector_2 side_of_bisector; + + Oriented_side os = side_of_bisector(p1, p2, q.point()); + + std::cerr << "b: " << b << std::endl; + std::cerr << "t: " << t << "; t_old: " << t_old << std::endl; + std::cerr << "os: " << os << std::endl; + std::cerr << "p1: " << p1 << std::endl; + std::cerr << "p2: " << p2 << std::endl; + std::cerr << "p3: " << p3 << std::endl; + std::cerr << "p4: " << p4 << std::endl; + std::cerr << "q: " << q << std::endl; + } + + CGAL_assertion( t == t_old ); +#endif + return t; //Test()(p1, p2, p3, p4, q, b, Method_tag()); + } +}; + + +//-------------------------------------------------------------------- + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_FINITE_EDGE_TEST8_C2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Finite_edge_test_C2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Finite_edge_test_C2.h new file mode 100644 index 00000000000..4f4f9dcc7f0 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Finite_edge_test_C2.h @@ -0,0 +1,632 @@ +// Copyright (c) 2003,2004,2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_FINITE_EDGE_TEST_C2_H +#define CGAL_APOLLONIUS_GRAPH_2_FINITE_EDGE_TEST_C2_H + +#include + + +#include + +#include + +#include +#include + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +//-------------------------------------------------------------------- + +template< class K > +class Orientation_wrt_symmetry_axis_2 +{ +public: + typedef typename K::Point_2 Point_2; + typedef Voronoi_circle_2 Voronoi_circle; + typedef typename K::FT FT; + typedef typename K::Orientation Orientation; + +public: + + Orientation + operator()(const Voronoi_circle& vc, const Point_2& p1, + const Point_2& p2, const Field_with_sqrt_tag&) const + { + FT a = vc.a1() + vc.a2() * CGAL::sqrt(vc.delta()); + FT b = vc.b1() + vc.b2() * CGAL::sqrt(vc.delta()); + FT det = a * (p2.y() - p1.y()) - b * (p2.x() - p1.x()); + return CGAL::sign(det); + } + + Orientation + operator()(const Voronoi_circle& vc, const Point_2& p1, + const Point_2& p2, const Integral_domain_without_division_tag&) const + { + FT dx = p2.x() - p1.x(); + FT dy = p2.y() - p1.y(); + FT A = vc.a1() * dy - vc.b1() * dx; + FT B = vc.a2() * dy - vc.b2() * dx; + return sign_a_plus_b_x_sqrt_c(A, B, vc.delta()); + } +}; + + +//-------------------------------------------------------------------- + +template< class K > +class Compare_Voronoi_radii_2 +{ +public: + typedef Voronoi_circle_2 Voronoi_circle; + typedef typename K::FT FT; + typedef typename K::Sign Sign; + typedef typename K::Comparison_result Comparison_result; + +private: + + Sign sign_of_P4(const FT& u, const FT& v, + const FT& du, const FT& dv, const FT& dr, + const FT& Du, const FT& Dv, const FT& Dr) const + { + std::pair factors = factors_of_P4(u, v, du, dv, dr, + Du, Dv, Dr); + Sign s1 = CGAL::sign(factors.first); + Sign s2 = CGAL::sign(factors.second); + return s1 * s2; + } + + std::pair + factors_of_P4(const FT& u, const FT& v, + const FT& du, const FT& dv, const FT& dr, + const FT& Du, const FT& Dv, const FT& Dr) const + { + FT u2 = CGAL::square(u); + FT v2 = CGAL::square(v); + + FT du2 = CGAL::square(du); + FT Du2 = CGAL::square(Du); + + FT dv2 = CGAL::square(dv); + FT Dv2 = CGAL::square(Dv); + + FT dr2 = CGAL::square(dr); + FT Dr2 = CGAL::square(Dr); + + FT u2_P_v2 = u2 + v2; + FT u2_M_v2 = u2 - v2; + FT uv = FT(2) * u * v; + + FT drDr = FT(2) * dr * Dr; + + FT du2_P_dv2 = du2 + dv2; + FT Du2_P_Dv2 = Du2 + Dv2; + + FT uU_P_vV = du * Du + dv * Dv; + FT uU_M_vV = du * Du - dv * Dv; + + FT uV_P_Uv = du * Dv + Du * dv; + FT uV_M_Uv = du * Dv - Du * dv; + + + FT F1 = du2_P_dv2 * Dr2 + Du2_P_Dv2 * dr2 + - uU_P_vV * drDr - CGAL::square(uV_M_Uv); + + FT F2 = CGAL::square(u2_P_v2) * (du2_P_dv2 * Dr2 + Du2_P_Dv2 * dr2); + F2 -= u2_P_v2 * (u2_M_v2 * uU_M_vV + uv * uV_P_Uv) * drDr; + F2 -= CGAL::square(u2_M_v2 * uV_P_Uv - uv * uU_M_vV); + + std::pair factors(F1,F2); + return factors; + } + +public: + Comparison_result + operator()(const Voronoi_circle& vc1, const Voronoi_circle& vc2, + const Field_with_sqrt_tag&) const + { + FT c1 = (vc1.c1() + vc1.c2() * CGAL::sqrt(vc1.delta())) / vc1.d(); + FT c2 = (vc2.c1() + vc2.c2() * CGAL::sqrt(vc2.delta())) / vc2.d(); + + Comparison_result r = CGAL::compare(c2, c1); + return r; + } + + // this is the naive way but without divisions and square roots; the + // degree becomes 36 in this case. + /* + Comparison_result + operator()(const Voronoi_circle& vc1, const Voronoi_circle& vc2, + Integral_domain_without_division_tag) + { + FT A = vc1.c1() * vc2.d() - vc2.c1() * vc1.d(); + FT B = vc1.c2() * vc2.d(); + FT C = -vc2.c2() * vc1.d(); + FT E = vc1.delta(); + FT F = vc2.delta(); + + Sign s = sign_a_plus_b_x_sqrt_e_plus_c_x_sqrt_f(A,B,C,E,F); + + if ( s == ZERO ) { return EQUAL; } + return ( s == POSITIVE ) ? SMALLER : LARGER; + } + */ + + Comparison_result + operator()(const Voronoi_circle& vc1, const Voronoi_circle& vc2, + const Integral_domain_without_division_tag&) const + { + bool is_first_root1 = vc1.is_first_root(); + bool is_first_root2 = vc2.is_first_root(); + + CGAL_precondition( CGAL::is_positive(vc1.alpha()) ); + CGAL_precondition( CGAL::is_positive(vc2.alpha()) ); + + Comparison_result r; + if ( is_first_root1 && is_first_root2 ) { + r = ke_compare_l1_l2(vc1.alpha(), vc1.beta(), vc1.gamma(), + vc2.alpha(), vc2.beta(), vc2.gamma()); + } else if ( is_first_root1 && !is_first_root2 ) { + r = ke_compare_l1_r2(vc1.alpha(), vc1.beta(), vc1.gamma(), + vc2.alpha(), vc2.beta(), vc2.gamma()); + } else if ( !is_first_root1 && is_first_root2 ) { + r = ke_compare_r1_l2(vc1.alpha(), vc1.beta(), vc1.gamma(), + vc2.alpha(), vc2.beta(), vc2.gamma()); + } else { + r = ke_compare_r1_r2(vc1.alpha(), vc1.beta(), vc1.gamma(), + vc2.alpha(), vc2.beta(), vc2.gamma()); + } + +#ifdef COMPARATOR_PROFILER + if ( comparator_profiler::count_cases ) { + // count cases only for the tree r1-r2 + if ( !is_first_root1 && !is_first_root2 ) { + comparator_profiler::count_case(vc1.alpha(), vc1.beta(), + vc1.gamma(), + vc2.alpha(), vc2.beta(), + vc2.gamma()); + } + } +#endif + + if ( r == EQUAL ) { return EQUAL; } + return ( r == LARGER ) ? SMALLER : LARGER; + } + + // this uses the DFMT trees; slightly slower but same degree (20). + /* + Comparison_result + operator()(const Voronoi_circle& vc1, const Voronoi_circle& vc2, + Integral_domain_without_division_tag) + { + bool is_first_root1 = vc1.is_first_root(); + bool is_first_root2 = vc2.is_first_root(); + + CGAL_precondition( CGAL::is_positive(vc1.alpha()) ); + CGAL_precondition( CGAL::is_positive(vc2.alpha()) ); + + Comparison_result r; + if ( is_first_root1 && is_first_root2 ) { + r = dfmt_compare_l1_l2(vc1.alpha(), vc1.beta(), vc1.gamma(), + vc2.alpha(), vc2.beta(), vc2.gamma()); + } else if ( is_first_root1 && !is_first_root2 ) { + r = dfmt_compare_l1_r2(vc1.alpha(), vc1.beta(), vc1.gamma(), + vc2.alpha(), vc2.beta(), vc2.gamma()); + } else if ( !is_first_root1 && is_first_root2 ) { + r = dfmt_compare_r1_l2(vc1.alpha(), vc1.beta(), vc1.gamma(), + vc2.alpha(), vc2.beta(), vc2.gamma()); + } else { + r = dfmt_compare_r1_r2(vc1.alpha(), vc1.beta(), vc1.gamma(), + vc2.alpha(), vc2.beta(), vc2.gamma()); + } + + if ( r == EQUAL ) { return EQUAL; } + return ( r == LARGER ) ? SMALLER : LARGER; + } + */ +}; + + +//-------------------------------------------------------------------- + +template< class K > +class Order_on_finite_bisector_2 +{ +public: + typedef Voronoi_circle_2 Voronoi_circle; + typedef typename K::Site_2 Site_2; + typedef typename K::FT FT; + typedef typename K::Comparison_result Comparison_result; + typedef typename K::Orientation Orientation; + + typedef Compare_Voronoi_radii_2 Compare_Voronoi_radii; + + typedef Orientation_wrt_symmetry_axis_2 + Orientation_wrt_symmetry_axis; + +public: + template + Comparison_result + operator()(const Voronoi_circle& vc1, const Voronoi_circle& vc2, + const Site_2& p1, const Site_2& p2, + const Method_tag& tag) const + { +#ifdef AG2_PROFILE_PREDICATES + ag2_predicate_profiler::order_on_bisector_counter++; +#endif + + Orientation o1 = + Orientation_wrt_symmetry_axis()(vc1, p1.point(), p2.point(), tag); + Orientation o2 = + Orientation_wrt_symmetry_axis()(vc2, p1.point(), p2.point(), tag); + + Comparison_result cr; + if ( o1 == LEFT_TURN ) { + if ( o2 != LEFT_TURN ) { return SMALLER; } + Comparison_result r = Compare_Voronoi_radii()(vc1, vc2, tag); + + if ( r == EQUAL ) { + cr = EQUAL; + } else { + cr = (r == LARGER ) ? SMALLER : LARGER; + } + } else if ( o1 == COLLINEAR ) { + if ( o2 == COLLINEAR ) { + cr = EQUAL; + } else { + cr = (o2 == LEFT_TURN) ? LARGER : SMALLER; + } + } else { + if ( o2 != RIGHT_TURN ) { + cr = LARGER; + } else { + Comparison_result r = + Compare_Voronoi_radii()(vc1, vc2, tag); + cr = r; + } + } + + return cr; + } +}; + + +//-------------------------------------------------------------------- + +template < class K > +class Finite_edge_interior_conflict +{ +public: + typedef typename K::Site_2 Site_2; + typedef Weighted_point_inverter_2 Weighted_point_inverter; + typedef Inverted_weighted_point_2 Inverted_weighted_point; + typedef Voronoi_radius_2 Voronoi_radius; + typedef Voronoi_circle_2 Voronoi_circle; + typedef Bitangent_line_2 Bitangent_line; + typedef typename K::FT FT; + typedef typename K::Sign Sign; + typedef typename K::Bounded_side Bounded_side; + typedef typename K::Comparison_result Comparison_result; + + typedef Bounded_side_of_CCW_circle_2 Bounded_side_of_CCW_circle; + typedef Order_on_finite_bisector_2 Order_on_finite_bisector; + + typedef Sign_of_distance_from_bitangent_line_2 + Sign_of_distance_from_bitangent_line; + + typedef Sign_of_distance_from_CCW_circle_2 + Sign_of_distance_from_CCW_circle; + +public: + template + bool + operator()(const Site_2& p1, + const Site_2& p2, + const Site_2& p3, + const Site_2& p4, + const Site_2& q, bool b, const Method_tag& tag) const + { +#ifdef AG2_PROFILE_PREDICATES + ag2_predicate_profiler::shadow_region_type_counter++; +#endif + // + Weighted_point_inverter inverter(p1); + Inverted_weighted_point u2 = inverter(p2); + Inverted_weighted_point v = inverter(q); + // + Voronoi_radius vr_12q(u2, v); + Voronoi_radius vr_1q2 = vr_12q.get_symmetric(); + + Bounded_side bs1 = Bounded_side_of_CCW_circle()(vr_12q, tag ); + Bounded_side bs2 = Bounded_side_of_CCW_circle()(vr_1q2, tag ); + + bool is_bs1 = (bs1 == ON_UNBOUNDED_SIDE); + bool is_bs2 = (bs2 == ON_UNBOUNDED_SIDE); + + // both the ccw and cw circles do not exist + if ( !is_bs1 && !is_bs2 ) { + return b; + } + + // the ccw circle exists but not the cw + if ( is_bs1 && !is_bs2 ) { + return b; + } + + // the cw circle exists but not the ccw + if ( !is_bs1 && is_bs2 ) { + return b; + } + + + // both circles exist + + // check whether the shadow region is connected, i.e., whether it is + // of the form (a, b) or (-oo, a) U (b, +oo) + Bitangent_line bl_12(p1, p2); + + Sign stc = + Sign_of_distance_from_bitangent_line()(bl_12, q, tag); + + CGAL_assertion( stc != ZERO ); + bool is_shadow_region_connected = (stc == POSITIVE); + + if ( is_shadow_region_connected ) { + if ( b ) { return true; } + + Inverted_weighted_point u3 = inverter(p3); + Bitangent_line blinv_23(u2, u3); + + Voronoi_circle vc_123(blinv_23); + Voronoi_circle vc_12q(vr_12q); + + + Comparison_result r = + Order_on_finite_bisector()(vc_123, vc_12q, p1, p2, tag); + + if ( r != SMALLER ) { return false; } + + Inverted_weighted_point u4 = inverter(p4); + Bitangent_line blinv_42(u4, u2); + + Voronoi_circle vc_142(blinv_42); + Voronoi_circle vc_1q2(vr_1q2); + r = Order_on_finite_bisector()(vc_142, vc_1q2, p1, p2, tag); + + return ( r == LARGER ); + } + + // the shadow region is of the form (-oo, a) U (b, +oo) + if ( !b ) { return false; } + + Inverted_weighted_point u3 = inverter(p3); + Bitangent_line blinv_23(u2, u3); + + Voronoi_circle vc_123(blinv_23); + Voronoi_circle vc_1q2(vr_1q2); + Comparison_result r = + Order_on_finite_bisector()(vc_123, vc_1q2, p1, p2, tag); + + if ( r != SMALLER ) { return true; } + + Inverted_weighted_point u4 = inverter(p4); + Bitangent_line blinv_42(u4, u2); + + Voronoi_circle vc_142(blinv_42); + Voronoi_circle vc_12q(vr_12q); + r = Order_on_finite_bisector()(vc_142, vc_12q, p1, p2, tag); + + return ( r != LARGER ); + } +}; + +//-------------------------------------------------------------------- + +template < class K > +class Finite_edge_interior_conflict_degenerated +{ +public: + typedef typename K::Site_2 Site_2; + typedef Weighted_point_inverter_2 Weighted_point_inverter; + typedef Inverted_weighted_point_2 Inverted_weighted_point; + typedef Voronoi_radius_2 Voronoi_radius; + typedef Voronoi_circle_2 Voronoi_circle; + typedef Bitangent_line_2 Bitangent_line; + typedef typename K::FT FT; + typedef typename K::Sign Sign; + typedef typename K::Comparison_result Comparison_result; + typedef typename K::Bounded_side Bounded_side; + + typedef Bounded_side_of_CCW_circle_2 Bounded_side_of_CCW_circle; + typedef Order_on_finite_bisector_2 Order_on_finite_bisector; + + typedef Sign_of_distance_from_bitangent_line_2 + Sign_of_distance_from_bitangent_line; + + typedef Sign_of_distance_from_CCW_circle_2 + Sign_of_distance_from_CCW_circle; +public: + template + bool + operator()(const Site_2& p1, const Site_2& p2, const Site_2& p3, + const Site_2& q, bool b, const Method_tag& tag) const + { +#ifdef AG2_PROFILE_PREDICATES + ag2_predicate_profiler::shadow_region_type_counter++; +#endif + // + Weighted_point_inverter inverter(p1); + Inverted_weighted_point u2 = inverter(p2); + Inverted_weighted_point v = inverter(q); + + Voronoi_radius vr_12q(u2, v); + Voronoi_radius vr_1q2 = vr_12q.get_symmetric(); + + Bounded_side bs1 = Bounded_side_of_CCW_circle()(vr_12q, tag ); + Bounded_side bs2 = Bounded_side_of_CCW_circle()(vr_1q2, tag ); + + bool is_bs1 = (bs1 == ON_UNBOUNDED_SIDE); + bool is_bs2 = (bs2 == ON_UNBOUNDED_SIDE); + + // both the ccw and cw circles do not exist + if ( !is_bs1 && !is_bs2 ) { + return b; + } + + // the ccw circle exists but not the cw + if ( is_bs1 && !is_bs2 ) { + return b; + } + + // the cw circle exists but not the ccw + if ( !is_bs1 && is_bs2 ) { + return b; + } + + // both circles exist + + // check whether the shadow region is connected, i.e., whether it is + // of the form (a, b) or (-oo, a) U (b, +oo) + Bitangent_line bl_12(p1, p2); + + Sign stc = Sign_of_distance_from_bitangent_line()(bl_12, q, tag); + + Inverted_weighted_point u3 = inverter(p3); + Bitangent_line blinv_23(u2, u3); + + CGAL_assertion( stc != ZERO ); + bool is_shadow_region_connected = (stc == POSITIVE); + + if ( is_shadow_region_connected ) { + // the shadow region is of the form (a, b) + if ( b ) { return false; } + + Voronoi_circle vc_123(blinv_23); + Voronoi_circle vc_12q(vr_12q); + + Comparison_result r = + Order_on_finite_bisector()(vc_123, vc_12q, p1, p2, tag); + + return ( r == SMALLER ); + } + + // the shadow region is of the form (-oo, a) U (b, +oo) + if ( !b ) { return false; } + + Voronoi_circle vc_123(blinv_23); + Voronoi_circle vc_1q2(vr_1q2); + Comparison_result r = + Order_on_finite_bisector()(vc_123, vc_1q2, p1, p2, tag); + + return ( r != SMALLER ); + } + + + + + template + bool + operator()(const Site_2& p1, const Site_2& p2, + const Site_2& q, bool b, const Method_tag& tag) const + { +#ifdef AG2_PROFILE_PREDICATES + ag2_predicate_profiler::shadow_region_type_counter++; +#endif + // + Weighted_point_inverter inverter(p1); + Inverted_weighted_point u2 = inverter(p2); + Inverted_weighted_point v = inverter(q); + + Voronoi_radius vr_12q(u2, v); + Voronoi_radius vr_1q2 = vr_12q.get_symmetric(); + + Bounded_side bs1 = Bounded_side_of_CCW_circle()(vr_12q, tag ); + Bounded_side bs2 = Bounded_side_of_CCW_circle()(vr_1q2, tag ); + + bool is_bs1 = (bs1 == ON_UNBOUNDED_SIDE); + bool is_bs2 = (bs2 == ON_UNBOUNDED_SIDE); + + // both the ccw and cw circles do not exist + if ( !is_bs1 && !is_bs2 ) { + return b; + } + + // only the ccw circle exists + if ( is_bs1 && !is_bs2 ) { return false; } + + // only the cw circle exists + if ( !is_bs1 && is_bs2 ) { return false; } + + // both circles exist + + // check whether the shadow region is connected, i.e., whether it is + // of the form (a, b) or (-oo, a) U (b, +oo) + + return !b; + } +}; + +//-------------------------------------------------------------------- + + +template +class Finite_edge_interior_conflict_2 +{ +public: + typedef K Kernel; + typedef MTag Method_tag; + + typedef typename K::Site_2 Site_2; + +private: + typedef Finite_edge_interior_conflict_degenerated Test_degenerated; + typedef Finite_edge_interior_conflict Test; + +public: + typedef bool result_type; + struct argument_type {}; + + inline + bool operator()(const Site_2& p1, const Site_2& p2, + const Site_2& q, bool b) const + { + return Test_degenerated()(p1, p2, q, b, Method_tag()); + } + + inline + bool operator()(const Site_2& p1, const Site_2& p2, + const Site_2& p3, const Site_2& q, bool b) const + { + return Test_degenerated()(p1, p2, p3, q, b, Method_tag()); + } + + inline + bool operator()(const Site_2& p1, const Site_2& p2, + const Site_2& p3, const Site_2& p4, + const Site_2& q, bool b) const + { + return Test()(p1, p2, p3, p4, q, b, Method_tag()); + } +}; + + +//-------------------------------------------------------------------- + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_FINITE_EDGE_TEST_C2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Incircle8_C2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Incircle8_C2.h new file mode 100644 index 00000000000..dd2bc5cb7c5 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Incircle8_C2.h @@ -0,0 +1,132 @@ +// Copyright (c) 2007 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_INCIRCLE8_C2_H +#define CGAL_APOLLONIUS_GRAPH_2_INCIRCLE8_C2_H + +#include + + +#include +#include + + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +//-------------------------------------------------------------------- + +template < class K, class MTag > +class Vertex_conflict8_2 + : public Vertex_conflict_2 +{ +private: + typedef Vertex_conflict_2 Base; + +public: + typedef typename Base::Kernel Kernel; + typedef typename Base::Method_tag Method_tag; + typedef typename Base::Site_2 Site_2; + typedef typename Base::FT FT; + typedef typename Base::Sign Sign; + +public: + typedef Sign result_type; + typedef Site_2 argument_type; + +private: + inline + Sign predicate(const FT& Exp, const FT& Eyp, const FT& Erp, + const FT& Exrp, const FT& Eyrp, const FT& Exyp, + const Field_with_sqrt_tag&) const + { + FT G = CGAL::square(Exp) + CGAL::square(Eyp) - CGAL::square(Erp); + return CGAL::sign(Exp * Exrp + Eyp * Eyrp + Exyp * CGAL::sqrt(G)); + } + + inline + Sign predicate(const FT& Exp, const FT& Eyp, const FT& /* Erp */, + const FT& Exrp, const FT& Eyrp, const FT& Exyp, + const Integral_domain_without_division_tag&) const + { + Sign sA = CGAL::sign(Exp * Exrp + Eyp * Eyrp); + Sign sB = CGAL::sign(Exyp); + + if ( sA == CGAL::ZERO ) { return sB; } + if ( sB == CGAL::ZERO ) { return sA; } + if ( sA == sB ) { return sA; } + + Sign s = + CGAL::sign(CGAL::square(Exrp) + CGAL::square(Eyrp) - CGAL::square(Exyp)); + + return sA * s; + } + +public: + inline + Sign operator()(const Site_2& p1, const Site_2& p2, + const Site_2& p3, const Site_2& q) const + { +#ifdef AG2_PROFILE_PREDICATES + ag2_predicate_profiler::incircle_counter++; +#endif + + FT xj = p2.x() - p1.x(); + FT xk = p3.x() - p1.x(); + FT xl = q.x() - p1.x(); + + FT yj = p2.y() - p1.y(); + FT yk = p3.y() - p1.y(); + FT yl = q.y() - p1.y(); + + FT rj = p2.weight() - p1.weight(); + FT rk = p3.weight() - p1.weight(); + FT rl = q.weight() - p1.weight(); + + FT pj = CGAL::square(xj) + CGAL::square(yj) - CGAL::square(rj); + FT pk = CGAL::square(xk) + CGAL::square(yk) - CGAL::square(rk); + FT pl = CGAL::square(xl) + CGAL::square(yl) - CGAL::square(rl); + + FT Exp = determinant(xj, pj, xk, pk); + FT Eyp = determinant(yj, pj, yk, pk); + FT Erp = determinant(rj, pj, rk, pk); + + FT Exy = determinant(xj, yj, xk, yk); + FT Exr = determinant(xj, rj, xk, rk); + FT Eyr = determinant(yj, rj, yk, rk); + + FT Exyp = xl * Eyp - yl * Exp + pl * Exy; + FT Exrp = xl * Erp - rl * Exp + pl * Exr; + FT Eyrp = yl * Erp - rl * Eyp + pl * Eyr; + + return predicate(Exp, Eyp, Erp, Exrp, Eyrp, Exyp, Method_tag()); + } + + + inline + Sign operator()(const Site_2& p1, const Site_2& p2, + const Site_2& q) const + { + return Base::operator()(p1, p2, q); + } + +}; + +//-------------------------------------------------------------------- + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_INCIRCLE8_C2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Incircle_C2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Incircle_C2.h new file mode 100644 index 00000000000..1420c5dde5c --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Incircle_C2.h @@ -0,0 +1,243 @@ +// Copyright (c) 2003,2004,2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_INCIRCLE_C2_H +#define CGAL_APOLLONIUS_GRAPH_2_INCIRCLE_C2_H + +#include + + +#include + +#include + +#include + +#include + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +//-------------------------------------------------------------------- + +template< class K > +class Sign_of_distance_from_bitangent_line_2 +{ +public: + typedef Bitangent_line_2 Bitangent_line; + typedef typename K::Site_2 Site_2; + typedef Inverted_weighted_point_2 Inverted_weighted_point; + typedef typename K::FT FT; + typedef typename K::Sign Sign; + +public: + + inline Sign + operator()(const Bitangent_line& bl, const Site_2& q, + const Field_with_sqrt_tag&) const + { +#ifdef AG2_PROFILE_PREDICATES + ag2_predicate_profiler::distance_from_bitangent_counter++; +#endif + FT a = bl.a1() + bl.a2() * CGAL::sqrt(bl.delta()); + FT b = bl.b1() + bl.b2() * CGAL::sqrt(bl.delta()); + FT c = bl.c1() + bl.c2() * CGAL::sqrt(bl.delta()); + FT r = a * q.x() + b * q.y() + c - q.weight() * bl.d(); + return CGAL::sign(r); + } + + inline Sign + operator()(const Bitangent_line& bl, const Site_2& q, + const Integral_domain_without_division_tag&) const + { +#ifdef AG2_PROFILE_PREDICATES + ag2_predicate_profiler::distance_from_bitangent_counter++; +#endif + FT A = bl.a1() * q.x() + bl.b1() * q.y() + bl.c1() + - q.weight() * bl.d(); + FT B = bl.a2() * q.x() + bl.b2() * q.y() + bl.c2(); + return sign_a_plus_b_x_sqrt_c(A, B, bl.delta()); + } +}; + +//-------------------------------------------------------------------- + + +template< class K > +class Sign_of_distance_from_CCW_circle_2 +{ +public: + typedef Bitangent_line_2 Bitangent_line; + typedef Inverted_weighted_point_2 Inverted_weighted_point; + typedef typename K::FT FT; + typedef typename K::Sign Sign; + +public: + inline Sign + operator()(const Bitangent_line& bl, + const Inverted_weighted_point& v, + const Field_with_sqrt_tag&) const + { + FT a = bl.a1() + bl.a2() * CGAL::sqrt(bl.delta()); + FT b = bl.b1() + bl.b2() * CGAL::sqrt(bl.delta()); + FT c = bl.c1() + bl.c2() * CGAL::sqrt(bl.delta()); + FT r = a * v.x() + b * v.y() + c * v.p() - v.weight() * bl.d(); + return CGAL::sign(r); + } + + inline Sign + operator()(const Bitangent_line& bl, + const Inverted_weighted_point& v, + const Integral_domain_without_division_tag&) const + { + FT A = bl.a1() * v.x() + bl.b1() * v.y() + bl.c1() * v.p() + - v.weight() * bl.d(); + FT B = bl.a2() * v.x() + bl.b2() * v.y() + bl.c2() * v.p(); + + return sign_a_plus_b_x_sqrt_c(A, B, bl.delta()); + } +}; + + +template < class Weighted_point > +class Weighted_point_less_than +{ +public: + inline + bool operator()(const Weighted_point& p1, + const Weighted_point& p2) const + { + if ( p1.x() == p2.x() ) { + return p1.y() < p2.y(); + } + return p1.x() < p2.x(); + } +}; + +template < class K, class MTag > +class Vertex_conflict_2 +{ +public: + typedef K Kernel; + typedef MTag Method_tag; + + typedef typename K::Point_2 Point_2; + typedef typename K::Site_2 Site_2; + typedef Weighted_point_inverter_2 Weighted_point_inverter; + typedef Inverted_weighted_point_2 Inverted_weighted_point; + typedef Bitangent_line_2 Bitangent_line; + typedef Voronoi_radius_2 Voronoi_radius; + typedef typename K::FT FT; + typedef typename K::Orientation Orientation; + typedef typename K::Sign Sign; + typedef typename K::Bounded_side Bounded_side; + + typedef Bounded_side_of_CCW_circle_2 Bounded_side_of_CCW_circle; + + typedef Sign_of_distance_from_bitangent_line_2 + Sign_of_distance_from_bitangent_line; + + typedef Sign_of_distance_from_CCW_circle_2 + Sign_of_distance_from_CCW_circle; + +private: + inline Orientation + orientation(const Bitangent_line& l, const Point_2& p, + const Field_with_sqrt_tag&) const + { + FT A = l.a1() * p.x() + l.b1() * p.y() + l.c1(); + FT B = l.a2() * p.x() + l.b2() * p.y() + l.c2(); + FT P = A + B * CGAL::sqrt(l.delta()); + return CGAL::sign(P); + } + + inline Orientation + orientation(const Bitangent_line& l, const Point_2& p, + const Integral_domain_without_division_tag&) const + { + FT A = l.a1() * p.x() + l.b1() * p.y() + l.c1(); + FT B = l.a2() * p.x() + l.b2() * p.y() + l.c2(); + return sign_a_plus_b_x_sqrt_c(A, B, l.delta()); + } + + + inline Orientation + orientation(const Bitangent_line& l, + const Inverted_weighted_point& u) const + { + FT A = l.a1() * u.x() / u.p() + l.b1() * u.y() / u.p() + l.c1(); + FT B = l.a2() * u.x() / u.p() + l.b2() * u.y() / u.p() + l.c2(); + FT P = A + B * CGAL::sqrt(l.delta()); + return CGAL::sign(P); + } + +public: + typedef Sign result_type; + typedef Site_2 argument_type; + + inline + Sign operator()(const Site_2& p1, const Site_2& p2, + const Site_2& p3, const Site_2& q) const + { +#ifdef AG2_PROFILE_PREDICATES + ag2_predicate_profiler::incircle_counter++; +#endif + // + Method_tag tag; + Weighted_point_inverter inverter(p1); + Inverted_weighted_point u2 = inverter(p2); + Inverted_weighted_point u3 = inverter(p3); + + Voronoi_radius vr_123(u2, u3); + + Bounded_side bs = Bounded_side_of_CCW_circle()(vr_123, tag ); + + if ( bs != ON_UNBOUNDED_SIDE ) { return NEGATIVE; } + + Inverted_weighted_point v = inverter(q); + Bitangent_line blinv_23(u2, u3); + Sign s = Sign_of_distance_from_CCW_circle()(blinv_23, v, tag); + return s; + } + + inline + Sign operator()(const Site_2& p1, const Site_2& p2, + const Site_2& q) const + { + Method_tag tag; + // + Bitangent_line bl_21(p2, p1); + Sign s = Sign_of_distance_from_bitangent_line()(bl_21, q, tag); + if ( s != ZERO ) { return s; } + + Bitangent_line bl1_perp = bl_21.perpendicular(p1.point()); + Bitangent_line bl2_perp = bl_21.perpendicular(p2.point()); + Orientation o1 = orientation(bl1_perp, q.point(), tag); + Orientation o2 = orientation(bl2_perp, q.point(), tag); + + CGAL_assertion( o1 != COLLINEAR || o2 != COLLINEAR ); + if ( o1 == o2 ) { return POSITIVE; } + return NEGATIVE; + } + +}; + +//-------------------------------------------------------------------- + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_INCIRCLE_C2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Infinite_edge_test_C2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Infinite_edge_test_C2.h new file mode 100644 index 00000000000..2e97eed0c64 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Infinite_edge_test_C2.h @@ -0,0 +1,316 @@ +// Copyright (c) 2003,2004,2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_INFINITE_EDGE_TEST_C2_H +#define CGAL_APOLLONIUS_GRAPH_2_INFINITE_EDGE_TEST_C2_H + +#include + + +#include + +#include + + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +//-------------------------------------------------------------------- + +template< class K > +class Bounded_side_of_CCW_circular_arc_2 +{ +public: + typedef Weighted_point_inverter_2 Weighted_point_inverter; + typedef Inverted_weighted_point_2 Inverted_weighted_point; + typedef Voronoi_radius_2 Voronoi_radius; + typedef Voronoi_circle_2 Voronoi_circle; + typedef Bitangent_line_2 Bitangent_line; + typedef typename K::FT FT; + typedef typename K::Bounded_side Bounded_side; + typedef typename K::Orientation Orientation; + typedef typename K::Sign Sign; + +public: + template< class Method_tag > + Bounded_side operator()(const Bitangent_line& l1, + const Bitangent_line& l2, + const Bitangent_line& l3, Method_tag tag) const + { +#ifdef AG2_PROFILE_PREDICATES + ag2_predicate_profiler::inside_circular_arc_counter++; +#endif + // This function checks whether the direction (a3, b3) (defined in + // the unit circle) is inside the CCW circular arc defined on the + // unit circle by the directions (a1, b1) and (a2, b2). By CCW arc + // we mean that we walk on the unit circle in the CCW order from + // (a1,b1) to (a2, b2) to define the arc. + + + Orientation o = chi2(l1, l2, tag); + //sign_of_determinant(a1, b1, a2, b2); + + + if ( o == COLLINEAR ) { + Bitangent_line l2_rot = l2.get_rot90(); + Sign dot = chi2(l1, l2_rot, tag); + //sign_of_determinant(a1, b1, -b2, a2); + + CGAL_assertion( dot != ZERO ); + Orientation o1 = chi2(l1, l3, tag); + //sign_of_determinant(a1, b1, a3, b3); + + if ( dot == POSITIVE ) { + if ( o1 != COLLINEAR ) { return ON_UNBOUNDED_SIDE; } + Bitangent_line l3_rot = l3.get_rot90(); + Sign dot1 = chi2(l1, l3_rot, tag); + //sign_of_determinant(a1, b1, -b3, a3); + + CGAL_assertion( dot1 != ZERO ); + return ( dot1 == POSITIVE ) ? ON_BOUNDARY : ON_UNBOUNDED_SIDE; + } + + if ( o1 == LEFT_TURN ) { return ON_BOUNDED_SIDE; } + return ( o1 == COLLINEAR ) ? ON_BOUNDARY : ON_UNBOUNDED_SIDE; + } else if ( o == LEFT_TURN ) { + Orientation o1 = chi2(l1, l3, tag); + //sign_of_determinant(a1, b1, a3, b3); + Orientation o2 = chi2(l2, l3, tag); + //sign_of_determinant(a2, b2, a3, b3); + + // std::cout << "orientation(l1, l3): " << int(o1) << std::endl; + // std::cout << "orientation(l2, l3): " << int(o2) << std::endl; + + if ( o1 == LEFT_TURN ) { + if ( o2 == COLLINEAR ) { return ON_BOUNDARY; } + return ( o2 == RIGHT_TURN ) ? ON_BOUNDED_SIDE : ON_UNBOUNDED_SIDE; + } else if ( o1 == COLLINEAR ) { + CGAL_assertion( o2 != COLLINEAR ); + return ( o2 == RIGHT_TURN ) ? ON_BOUNDARY : ON_UNBOUNDED_SIDE; + } + return ON_UNBOUNDED_SIDE; + } + Orientation o1 = chi2(l1, l3, tag); + //sign_of_determinant(a1, b1, a3, b3); + Orientation o2 = chi2(l2, l3, tag); + //sign_of_determinant(a2, b2, a3, b3); + + // std::cout << "orientation(l1, l3): " << int(o1) << std::endl; + // std::cout << "orientation(l2, l3): " << int(o2) << std::endl; + + + if ( o1 == LEFT_TURN || o2 == RIGHT_TURN ) { return ON_BOUNDED_SIDE; } + if ( o1 == COLLINEAR || o2 == COLLINEAR ) { return ON_BOUNDARY; } + return ON_UNBOUNDED_SIDE; + } + + Sign chi2(const Bitangent_line& bl1, + const Bitangent_line& bl2, Field_with_sqrt_tag) const + { + FT sigma = bl1.dx() * bl2.dx() + bl1.dy() * bl2.dy(); + FT delta = bl1.dx() * bl2.dy() - bl1.dy() * bl2.dx(); + + // FT E1 = -bl2.dw() * sigma; + // FT E2 = bl1.dw() * sigma; + FT E1 = bl2.dw() * sigma; + FT E2 = -bl1.dw() * sigma; + FT E3 = delta; + FT E4 = bl1.dw() * bl2.dw() * delta; + FT p = bl1.delta(); + FT P = bl2.delta(); + + FT E = E1 * CGAL::sqrt(p) + E2 * CGAL::sqrt(P) + + E3 * CGAL::sqrt(p * P) + E4; + + return CGAL::sign(E); + } + + inline + Sign chi2(const Bitangent_line& bl1, + const Bitangent_line& bl2, Integral_domain_without_division_tag) const + { + return chi2(bl1.dx(), bl1.dy(), -bl1.dw(), bl1.d(), bl1.delta(), + bl2.dx(), bl2.dy(), -bl2.dw(), bl2.d(), bl2.delta()); + } + + Sign chi2(const FT& a, const FT& b, const FT& r, + const FT& d, const FT& p, + const FT& A, const FT& B, const FT& R, + const FT& D, const FT& P) const + { + FT sigma = a * A + b * B; + FT delta = determinant(a, b, A, B); + + Sign sign_sigma = CGAL::sign(sigma); + Sign sign_delta = CGAL::sign(delta); + Sign sign_r = CGAL::sign(r); + Sign sign_R = CGAL::sign(R); + + Sign sign_E1 = -sign_R * sign_sigma; + Sign sign_E2 = sign_r * sign_sigma; + Sign sign_E3 = sign_delta; + Sign sign_E4 = sign_r * sign_R * sign_delta; + + Sign sign_E1_plus_E3_P, sign_E4_plus_E2_P; + + // FT d = CGAL::square(a) + CGAL::square(b); + FT G = CGAL::square(R) * d; + FT delta2 = CGAL::square(delta); + + if ( sign_E3 == ZERO ) { + sign_E1_plus_E3_P = sign_E1; + } else { + if ( sign_E3 == sign_E1 ) { + sign_E1_plus_E3_P = sign_E3; + } else { + FT F1 = delta2 - G; + sign_E1_plus_E3_P = sign_E3 * CGAL::sign(F1); + } + } + + if ( sign_E2 == ZERO ) { + sign_E4_plus_E2_P = sign_E4; + } else { + if ( sign_E2 == sign_E4 ) { + sign_E4_plus_E2_P = sign_E2; + } else { + FT F2 = CGAL::square(sigma) - G; + if ( sign_r == ZERO ) { + sign_E4_plus_E2_P = ZERO; + } else { + sign_E4_plus_E2_P = sign_E2 * CGAL::sign(F2); + } + } + } + + if ( sign_E1_plus_E3_P == ZERO ) { return sign_E4_plus_E2_P; } + if ( sign_E1_plus_E3_P == sign_E4_plus_E2_P ) { + return sign_E1_plus_E3_P; + } + + Sign sign_E5 = -sign_R * sign_sigma * sign_delta; + + // FT D = CGAL::square(A) + CGAL::square(B); + // FT P = D - CGAL::square(R); + + FT F3 = P * delta2 + CGAL::square(R * sigma) - CGAL::square(r * D); + + Sign sign_E6 = CGAL::sign(F3); + + if ( sign_E5 == ZERO ) { + return sign_E1_plus_E3_P * sign_E6; + } + if ( sign_E5 == sign_E6 ) { + return sign_E1_plus_E3_P * sign_E5; + } + + // FT p = d - CGAL::square(r); + FT rR = r * R; + FT pP = p * P; + //error(); + FT F4 = CGAL::square(sigma - rR) - pP; + FT F5 = CGAL::square(sigma + rR) - pP; + + Sign sign_E7 = -CGAL::sign(F4) * CGAL::sign(F5); + + return sign_E1_plus_E3_P * sign_E5 * sign_E7; + } + +}; + + +//-------------------------------------------------------------------- + +template < class K, class MTag > +class Infinite_edge_interior_conflict_2 +{ +public: + typedef K Kernel; + typedef MTag Method_tag; + + typedef typename K::Site_2 Site_2; + typedef Weighted_point_inverter_2 Weighted_point_inverter; + typedef Inverted_weighted_point_2 Inverted_weighted_point; + typedef Voronoi_radius_2 Voronoi_radius; + typedef Voronoi_circle_2 Voronoi_circle; + typedef Bitangent_line_2 Bitangent_line; + typedef typename K::FT FT; + typedef typename K::Bounded_side Bounded_side; + + // typedef CGAL::Bounded_side_of_CCW_circle Bounded_side_of_CCW_circle; + // typedef CGAL::Sign_of_distance_from_bitangent_line + // Sign_of_distance_from_bitangent_line; + // typedef CGAL::Sign_of_distance_from_CCW_circle + // Sign_of_distance_from_CCW_circle; + // typedef CGAL::Order_on_finite_bisector Order_on_finite_bisector; + + typedef Bounded_side_of_CCW_circular_arc_2 + Bounded_side_of_CCW_circular_arc; + +public: + typedef bool result_type; + struct argument_type {}; + + + bool operator()(const Site_2& p2, const Site_2& p3, + const Site_2& p4, const Site_2& q, bool b) const + { + Method_tag tag = Method_tag(); + + Bitangent_line bl_32(p3, p2); + Bitangent_line bl_24(p2, p4); + Bitangent_line bl_2q(p2, q); + + Bounded_side bs1 = + Bounded_side_of_CCW_circular_arc()(bl_32, bl_24, bl_2q, tag); + + if ( b ) { + if ( bs1 == ON_BOUNDARY ) { + Bitangent_line bl_q2(q, p2); + Bounded_side bs2 = + Bounded_side_of_CCW_circular_arc()(bl_32, bl_24, bl_q2, tag); + + if ( bs2 != ON_BOUNDARY ) { + return ( bs2 != ON_BOUNDED_SIDE ); + } + return !b; + } + + return ( bs1 != ON_BOUNDED_SIDE ); + } + if ( bs1 == ON_BOUNDARY ) { + Bitangent_line bl_q2(q, p2); + Bounded_side bs2 = + Bounded_side_of_CCW_circular_arc()(bl_32, bl_24, bl_q2, tag); + + if ( bs2 != ON_BOUNDARY ) { + return ( bs2 == ON_BOUNDED_SIDE ); + } + return !b; + } + return ( bs1 == ON_BOUNDED_SIDE ); + } + +}; + + +//-------------------------------------------------------------------- + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + + +#endif // CGAL_APOLLONIUS_GRAPH_2_INFINITE_EDGE_TEST_C2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Is_degenerate_edge_C2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Is_degenerate_edge_C2.h new file mode 100644 index 00000000000..102ecca9e51 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Is_degenerate_edge_C2.h @@ -0,0 +1,95 @@ +// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_IS_DEGENERATE_EDGE_C2_H +#define CGAL_APOLLONIUS_GRAPH_2_IS_DEGENERATE_EDGE_C2_H + +#include + + +#include + +#include + +#include +#include + +namespace CGAL { + +namespace ApolloniusGraph_2 { + + +//-------------------------------------------------------------------- + +template < class K, class MTag > +class Is_degenerate_edge_2 +{ +public: + typedef K Kernel; + typedef MTag Method_tag; + + typedef typename K::Site_2 Site_2; + typedef Weighted_point_inverter_2 Weighted_point_inverter; + typedef Inverted_weighted_point_2 Inverted_weighted_point; + typedef Bitangent_line_2 Bitangent_line; + typedef Voronoi_circle_2 Voronoi_circle; + typedef typename K::FT FT; + typedef typename K::Sign Sign; + typedef typename K::Comparison_result Comparison_result; + + typedef Order_on_finite_bisector_2 Order_on_finite_bisector; + + typedef Sign_of_distance_from_CCW_circle_2 + Sign_of_distance_from_CCW_circle; + +public: + typedef Site_2 argument_type; + typedef bool result_type; + + bool operator()(const Site_2& p1, const Site_2& p2, + const Site_2& p3, const Site_2& p4) const + { + Method_tag tag; + + Weighted_point_inverter inverter(p1); + Inverted_weighted_point u2 = inverter(p2); + Inverted_weighted_point u3 = inverter(p3); + Inverted_weighted_point u4 = inverter(p4); + + Sign s; + + Bitangent_line blinv_23(u2, u3); + s = Sign_of_distance_from_CCW_circle()(blinv_23, u4, tag); + if ( s != ZERO ) { return false; } + + Bitangent_line blinv_42(u4, u2); + s = Sign_of_distance_from_CCW_circle()(blinv_42, u3, tag); + if ( s != ZERO ) { return false; } + + Voronoi_circle vc_123(blinv_23); + Voronoi_circle vc_142(blinv_42); + Comparison_result r = + Order_on_finite_bisector()(vc_123, vc_142, p1, p2, tag); + + return ( r == EQUAL ); + } +}; + +//-------------------------------------------------------------------- + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_IS_DEGENERATE_EDGE_C2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Is_hidden_C2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Is_hidden_C2.h new file mode 100644 index 00000000000..f98872befa4 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Is_hidden_C2.h @@ -0,0 +1,85 @@ +// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_IS_HIDDEN_C2_H +#define CGAL_APOLLONIUS_GRAPH_2_IS_HIDDEN_C2_H + +#include + + + +#include + + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +//-------------------------------------------------------------------- + + +template +class Is_hidden_2 +{ +public: + typedef K Kernel; + typedef MTag Method_tag; + typedef typename K::Site_2 Site_2; + typedef typename K::RT RT; + typedef typename K::Sign Sign; + +private: + bool is_hidden(const Site_2& p, const Site_2& q, + const Integral_domain_without_division_tag&) const + { + RT w1 = p.weight(); + RT w2 = q.weight(); + Sign s = CGAL::sign( CGAL::square(p.x() - q.x()) + + CGAL::square(p.y() - q.y()) + - CGAL::square(w1 - w2) + ); + if ( s == POSITIVE ) { return false; } + return (CGAL::compare(w1, w2) != SMALLER); + } + + bool is_hidden(const Site_2& p, const Site_2& q, + const Field_with_sqrt_tag&) const + { + RT d = CGAL::sqrt(CGAL::square(p.x() - q.x()) + + CGAL::square(p.y() - q.y())); + Sign s = CGAL::sign(d - p.weight() + q.weight()); + + return ( s != POSITIVE ); + } + +public: + typedef bool result_type; + typedef Site_2 argument_type; + + inline bool operator()(const Site_2 &p, const Site_2 &q) const { +#ifdef AG2_PROFILE_PREDICATES + ag2_predicate_profiler::is_trivial_counter++; +#endif + return is_hidden(p, q, Method_tag()); + } +}; + + +//-------------------------------------------------------------------- + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_IS_HIDDEN_C2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Kernel_wrapper_2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Kernel_wrapper_2.h new file mode 100644 index 00000000000..66b91c08ce1 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Kernel_wrapper_2.h @@ -0,0 +1,82 @@ +// Copyright (c) 2003,2004,2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_KERNEL_WRAPPER_2_H +#define CGAL_APOLLONIUS_GRAPH_2_KERNEL_WRAPPER_2_H + +#include + + +#include + +#include +//#include + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +template +class Apollonius_graph_kernel_wrapper_2 : public Kernel_base_2 +{ +public: + typedef CGAL::Apollonius_site_2 Site_2; + typedef Kernel_base_2 Base; +}; + + +template +class Apollonius_graph_cartesian_converter + : public Converter +{ +private: + typedef typename K2::Site_2 K2_Site_2; + typedef typename K2::Point_2 K2_Point_2; + typedef Converter Base; + typedef typename Converter::Number_type_converter NT_converter; + + +public: +#if defined(_MSC_VER) + bool operator()(bool b) const { + return Base::operator()(b); + } + + K2_Point_2 + operator()(const typename K1::Point_2& p) const + { + return Base::operator()(p); + } +#else + using Base::operator(); +#endif + + K2_Site_2 + operator()(const typename K1::Site_2& t) const + { + NT_converter nt_cv; + + return K2_Site_2( Base::operator()(t.point()), + nt_cv(t.weight()) + ); + } +}; + + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + + +#endif // CGAL_APOLLONIUS_GRAPH_2_KERNEL_WRAPPER_2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Orientation8_C2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Orientation8_C2.h new file mode 100644 index 00000000000..0b051120727 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Orientation8_C2.h @@ -0,0 +1,318 @@ +// Copyright (c) 2007 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + +#ifndef CGAL_APOLLONIUS_GRAPH_2_ORIENTATION8_C2_H +#define CGAL_APOLLONIUS_GRAPH_2_ORIENTATION8_C2_H + +#include + + +#include +#include + +//-------------------------------------------------------------------- + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +template +class Orientation8_C2 + : public Orientation_2 +{ +private: + typedef Orientation_2 Base; + +public: + typedef K Kernel; + typedef MTag Method_tag; + typedef typename K::Site_2 Site_2; + typedef typename K::Point_2 Point_2; + typedef typename K::Orientation Orientation; + typedef typename K::FT FT; + + typedef Orientation result_type; + typedef Site_2 argument_type; + +public: + inline + Orientation operator()(const Site_2& s1, const Site_2& s2, + const Site_2& s3) const + { + return Kernel().orientation_2_object()(s1.point(), s2.point(), + s3.point()); + } + + inline + Sign sqrt_ext_sign(const FT& A, const FT& B, + const FT& Exp, const FT& Eyp, const FT& Erp, + const FT& Exy2, const FT& Exr, const FT& Eyr, + const FT dx, const FT& dy, + const Field_with_sqrt_tag&) const + { + FT G = CGAL::square(Exp) + CGAL::square(Eyp) - CGAL::square(Erp); + return CGAL::sign(A + B * CGAL::sqrt(G)); + } + + inline + Sign sqrt_ext_sign(const FT& A, const FT& B, + const FT& Exp, const FT& Eyp, const FT& Erp, + const FT& Exy2, const FT& Exr, const FT& Eyr, + const FT dx, const FT& dy, + const Integral_domain_without_division_tag&) const + { + Sign sA = CGAL::sign(A); + Sign sB = CGAL::sign(B); + + if ( sA == CGAL::ZERO ) { return sB; } + if ( sB == CGAL::ZERO ) { return sA; } + if ( sA == sB ) { return sA; } + + Sign s = CGAL::sign(CGAL::square(Exy2 * Exr - Erp * dy) + + CGAL::square(Exy2 * Eyr + Erp * dx) + - CGAL::square(B)); + return sA * s; + } + + Orientation predicate(const Site_2& s1, const Site_2& s2, + const Site_2& s3, const Site_2& p1, + const Site_2& p2) const + { + // computes the orientation of the Voronoi vertex of s1, s2, s3 and + // the points p1 and p2 + FT xj = s2.x() - s1.x(); + FT xk = s3.x() - s1.x(); + + FT xl = p1.x() - s1.x(); + FT xm = p2.x() - s1.x(); + + + FT yj = s2.y() - s1.y(); + FT yk = s3.y() - s1.y(); + + FT yl = p1.y() - s1.y(); + FT ym = p2.y() - s1.y(); + + + FT dx = xl - xm; + FT dy = yl - ym; + + + FT rj = s2.weight() - s1.weight(); + FT rk = s3.weight() - s1.weight(); + + FT pj = CGAL::square(xj) + CGAL::square(yj) - CGAL::square(rj); + FT pk = CGAL::square(xk) + CGAL::square(yk) - CGAL::square(rk); + + FT Exp = determinant(xj, pj, xk, pk); + FT Eyp = determinant(yj, pj, yk, pk); + FT Erp = determinant(rj, pj, rk, pk); + + FT Exy = determinant(xj, yj, xk, yk); + FT Exr = determinant(xj, rj, xk, rk); + FT Eyr = determinant(yj, rj, yk, rk); + + FT Exy2 = 2 * determinant(xl, yl, xm, ym); + + FT A = (Exp * Exr + Eyp * Eyr) * Exy2 + (Eyp * dx - Exp * dy) * Erp; + FT B = Exy * Exy2 - Exp * dx - Eyp * dy; + + return sqrt_ext_sign(A, B, Exp, Eyp, Erp, + Exy2, Exr, Eyr, dx, dy, Method_tag()); + } + + Orientation operator()(const Site_2& s1, const Site_2& s2, + const Site_2& s3, const Site_2& p1, + const Site_2& p2) const + { + Orientation o = predicate(s1, s2, s3, p1, p2); +#ifndef NDEBUG + Orientation o_old = Base::operator()(s1, s2, s3, p1, p2); + + CGAL_assertion( o == o_old ); +#endif + return o; + } + +}; + +//-------------------------------------------------------------------- + +template +class Constructive_orientation8_C2 +{ +public: + typedef K Kernel; + typedef MTag Method_tag; + typedef typename K::Site_2 Site_2; + typedef typename K::Point_2 Point_2; + typedef typename K::Orientation Orientation; + typedef typename K::FT FT; + + typedef Orientation result_type; + typedef Site_2 argument_type; + +private: + FT s1x, s1y; + FT xj, xk, yj, yk, rj, rk, nj, nk, pj, pk, Exp, Eyp, Erp, Exy, Exr, Eyr, A1; + Orientation o_sym; + +public: + Constructive_orientation8_C2(const Site_2& s1, const Site_2& s2, + const Site_2& s3, bool use_xj) + { + s1x = s1.x(); + s1y = s1.y(); + + xj = s2.x() - s1.x(); + xk = s3.x() - s1.x(); + + yj = s2.y() - s1.y(); + yk = s3.y() - s1.y(); + + rj = s2.weight() - s1.weight(); + rk = s3.weight() - s1.weight(); + + nj = CGAL::square(xj) + CGAL::square(yj); + nk = CGAL::square(xk) + CGAL::square(yk); + + pj = nj - CGAL::square(rj); + pk = nk - CGAL::square(rk); + + Exp = determinant(xj, pj, xk, pk); + Eyp = determinant(yj, pj, yk, pk); + Erp = determinant(rj, pj, rk, pk); + + Exy = determinant(xj, yj, xk, yk); + Exr = determinant(xj, rj, xk, rk); + Eyr = determinant(yj, rj, yk, rk); + + A1 = Exp * Exr + Eyp * Eyr; + + FT A, B, norm; + if ( use_xj ) { + A = (-Eyp * xj + Exp * yj) * Erp; + B = Exp * xj + Eyp * yj; + norm = nj; + } else { + A = (-Eyp * xk + Exp * yk) * Erp; + B = Exp * xk + Eyp * yk; + norm = nk; + } + + o_sym = sqrt_ext_sign(A, B, norm, Method_tag()); + } + +private: + inline + Sign sqrt_ext_sign(const FT& A, const FT& B, const FT& Exy2, + const FT& dx, const FT& dy, + const Field_with_sqrt_tag&) const + { + FT G = CGAL::square(Exp) + CGAL::square(Eyp) - CGAL::square(Erp); + return CGAL::sign(A + B * CGAL::sqrt(G)); + } + + inline + Sign sqrt_ext_sign(const FT& A, const FT& B, const FT&, + const Field_with_sqrt_tag&) const + { + FT G = CGAL::square(Exp) + CGAL::square(Eyp) - CGAL::square(Erp); + return CGAL::sign(A + B * CGAL::sqrt(G)); + } + + + inline + Sign sqrt_ext_sign(const FT& A, const FT& B, const FT& norm, + const Integral_domain_without_division_tag&) const + { + Sign sA = CGAL::sign(A); + Sign sB = CGAL::sign(B); + + if ( sA == CGAL::ZERO ) { return sB; } + if ( sB == CGAL::ZERO ) { return sA; } + if ( sA == sB ) { return sA; } + + Sign s = CGAL::sign(CGAL::square(Erp) * norm - CGAL::square(B)); + return sA * s; + } + + + inline + Sign sqrt_ext_sign(const FT& A, const FT& B, const FT& Exy2, + const FT dx, const FT& dy, + const Integral_domain_without_division_tag&) const + { + Sign sA = CGAL::sign(A); + Sign sB = CGAL::sign(B); + + if ( sA == CGAL::ZERO ) { return sB; } + if ( sB == CGAL::ZERO ) { return sA; } + if ( sA == sB ) { return sA; } + + Sign s = CGAL::sign(CGAL::square(Exy2 * Exr - Erp * dy) + + CGAL::square(Exy2 * Eyr + Erp * dx) + - CGAL::square(B)); + return sA * s; + } + + Orientation predicate(const Site_2& p1, const Site_2& p2) const + { + // computes the orientation of the Voronoi vertex of s1, s2, s3 and + // the points p1 and p2 + FT xl = p1.x() - s1x; + FT xm = p2.x() - s1x; + + FT yl = p1.y() - s1y; + FT ym = p2.y() - s1y; + + FT dx = xl - xm; + FT dy = yl - ym; + + FT Exy2 = 2 * determinant(xl, yl, xm, ym); + + FT A = A1 * Exy2 + (Eyp * dx - Exp * dy) * Erp; + FT B = Exy * Exy2 - Exp * dx - Eyp * dy; + + return sqrt_ext_sign(A, B, Exy2, dx, dy, Method_tag()); + } + +public: + inline + Orientation operator()(const Site_2& s1, const Site_2& s2, + const Site_2& s3) const + { + return Kernel().orientation_2_object()(s1.point(), s2.point(), + s3.point()); + } + + inline + Orientation operator()(const Site_2& p1, const Site_2& p2) const + { + Orientation o = predicate(p1, p2); + return o; + } + + inline + Orientation operator()() const { + return o_sym; + } +}; + +//-------------------------------------------------------------------- + + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_ORIENTATION8_C2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Orientation_2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Orientation_2.h new file mode 100644 index 00000000000..5003be6de4d --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Orientation_2.h @@ -0,0 +1,109 @@ +// Copyright (c) 2003,2004,2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_ORIENTATION_2_H +#define CGAL_APOLLONIUS_GRAPH_2_ORIENTATION_2_H + +#include + + +#include + +#include + +//-------------------------------------------------------------------- + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +template +class Orientation_2 +{ +public: + typedef K Kernel; + typedef MTag Method_tag; + typedef typename K::Site_2 Site_2; + typedef typename K::Point_2 Point_2; + typedef typename K::Orientation Orientation; + + typedef Orientation result_type; + typedef Site_2 argument_type; + +private: + typedef Weighted_point_inverter_2 Weighted_point_inverter; + typedef Inverted_weighted_point_2 Inverted_weighted_point; + typedef Voronoi_circle_2 Voronoi_circle; + typedef Bitangent_line_2 Bitangent_line; + typedef typename Bitangent_line::FT FT; + +private: + Orientation vv_orientation(const Voronoi_circle& vc, const Point_2& sp1, + const Point_2& p1, const Point_2& p2, + const Field_with_sqrt_tag&) const + { + FT a = vc.a1() + vc.a2() * CGAL::sqrt(vc.delta()); + FT b = vc.b1() + vc.b2() * CGAL::sqrt(vc.delta()); + FT det1 = a * (p2.y() - p1.y()) - b * (p2.x() - p1.x()); + FT c = vc.c1() + vc.c2() * CGAL::sqrt(vc.delta()); + FT det2 = determinant(p1.x() - sp1.x(), p1.y() - sp1.y(), + p2.x() - sp1.x(), p2.y() - sp1.y()); + return CGAL::sign(det1 + FT(2) * c * det2); + } + + Orientation vv_orientation(const Voronoi_circle vc, const Point_2& sp1, + const Point_2& p1, const Point_2& p2, + const Integral_domain_without_division_tag&) const + { + FT dx = p2.x() - p1.x(); + FT dy = p2.y() - p1.y(); + FT det1 = determinant(p1.x() - sp1.x(), p1.y() - sp1.y(), + p2.x() - sp1.x(), p2.y() - sp1.y()); + FT A = vc.a1() * dy - vc.b1() * dx + FT(2) * vc.c1() * det1; + FT B = vc.a2() * dy - vc.b2() * dx + FT(2) * vc.c2() * det1; + return sign_a_plus_b_x_sqrt_c(A, B, vc.delta()); + } + +public: + inline + Orientation operator()(const Site_2& s1, const Site_2& s2, + const Site_2& s3) const + { + return Kernel().orientation_2_object()(s1.point(), s2.point(), + s3.point()); + } + + Orientation operator()(const Site_2& s1, const Site_2& s2, + const Site_2& s3, const Site_2& p1, + const Site_2& p2) const + { + // computes the operation of the Voronoi vertex of s1, s2, s3 and + // the points p1 and p2 + Weighted_point_inverter inverter(s1); + Inverted_weighted_point u2 = inverter(s2); + Inverted_weighted_point u3 = inverter(s3); + Bitangent_line blinv_23(u2, u3); + Voronoi_circle vc(blinv_23); + return + vv_orientation(vc, s1.point(), p1.point(), p2.point(), Method_tag()); + } +}; + +//-------------------------------------------------------------------- + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_ORIENTATION_2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Oriented_side_of_bisector_C2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Oriented_side_of_bisector_C2.h new file mode 100644 index 00000000000..d3ee22a5f19 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Oriented_side_of_bisector_C2.h @@ -0,0 +1,125 @@ +// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_ORIENTED_SIDE_OF_BISECTOR_C2_H +#define CGAL_APOLLONIUS_GRAPH_2_ORIENTED_SIDE_OF_BISECTOR_C2_H + +#include + + +#include +#include + + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +//-------------------------------------------------------------------- + +template +class Oriented_side_of_bisector_2 +{ +public: + typedef K Kernel; + typedef MTag Method_tag; + + typedef typename K::Point_2 Point_2; + typedef typename K::Site_2 Site_2; + typedef typename K::Comparison_result Comparison_result; + typedef typename K::Sign Sign; + typedef typename K::Oriented_side Oriented_side; + +private: + typedef typename Kernel::RT RT; + +private: + Comparison_result + compare_distances(const Site_2& p1, const Site_2& p2, + const Point_2& p, const Integral_domain_without_division_tag&) const + { +#ifdef AG2_PROFILE_PREDICATES + ag2_predicate_profiler::side_of_bisector_counter++; +#endif + + // this function compares the distances of the point(x, y) from the + // disks {(x1, y1), w1} and {(x2, y2), w2} + RT D1 = CGAL::square(p1.x() - p.x()) + CGAL::square(p1.y() - p.y()); + RT D2 = CGAL::square(p2.x() - p.x()) + CGAL::square(p2.y() - p.y()); + RT Dw = p2.weight() - p1.weight(); + + Sign sign_of_Dw = CGAL::sign(Dw); + Comparison_result R = CGAL::compare(D1, D2); + + if ( sign_of_Dw == ZERO ) { + return R; + } + if ( sign_of_Dw == POSITIVE ) { + if ( R != SMALLER ) return LARGER; + + Sign s = sign_a_plus_b_x_sqrt_c(D1 - D2 + CGAL::square(Dw), + RT(2) * Dw, D1); + return ((s == POSITIVE) ? LARGER : ((s == ZERO) ? EQUAL : SMALLER)); + } + + if ( R != LARGER ) return SMALLER; + Sign s = sign_a_plus_b_x_sqrt_c(D1 - D2 - CGAL::square(Dw), + RT(2) * Dw, D2); + + return ((s == POSITIVE) ? LARGER : ((s == ZERO) ? EQUAL : SMALLER)); + } + + Comparison_result + compare_distances(const Site_2& p1, const Site_2& p2, + const Point_2 &p, const Field_with_sqrt_tag&) const + { +#ifdef AG2_PROFILE_PREDICATES + ag2_predicate_profiler::side_of_bisector_counter++; +#endif + // this function compares the distances of the point(x, y) from the + // disks {(x1, y1), w1} and {(x2, y2), w2} + + RT D1 = CGAL::square(p1.x() - p.x()) + CGAL::square(p1.y() - p.y()); + RT D2 = CGAL::square(p2.x() - p.x()) + CGAL::square(p2.y() - p.y()); + + RT d1 = CGAL::sqrt(D1) - p1.weight(); + RT d2 = CGAL::sqrt(D2) - p2.weight(); + + return CGAL::compare(d1, d2); + } + +public: + typedef Oriented_side result_type; + struct argument_type {}; + + inline + Oriented_side operator()(const Site_2& p1, const Site_2& p2, + const Point_2 &p) const + { + Comparison_result r = compare_distances(p1, p2, p, Method_tag()); + + if ( r == EQUAL ) { return ON_ORIENTED_BOUNDARY; } + return ( r == LARGER ) ? ON_NEGATIVE_SIDE : ON_POSITIVE_SIDE; + } + +}; + + +//-------------------------------------------------------------------- + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_ORIENTED_SIDE_OF_BISECTOR_C2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Predicate_constructions_C2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Predicate_constructions_C2.h new file mode 100644 index 00000000000..5b9bce0829c --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Predicate_constructions_C2.h @@ -0,0 +1,358 @@ +// Copyright (c) 2003,2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_PREDICATE_CONSTRUCTIONS_2_H +#define CGAL_APOLLONIUS_GRAPH_2_PREDICATE_CONSTRUCTIONS_2_H 1 + +#include + + +#include + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +template< class K > +class Inverted_weighted_point_2 + : public K::Site_2 +{ +public: + typedef typename K::Site_2 K_Site_2; + typedef typename K::FT FT; +private: + FT _p; +public: + Inverted_weighted_point_2(const K_Site_2& wp, const FT& p) + : K_Site_2(wp), _p(p) {} + + inline FT p() const { return _p; } +}; + + +template< class K > +class Weighted_point_inverter_2 +{ +public: + typedef typename K::Point_2 Point_2; + typedef typename K::Site_2 Site_2; + typedef Inverted_weighted_point_2 Inverted_weighted_point; + typedef typename K::FT FT; +private: + Site_2 _pole; +public: + Weighted_point_inverter_2(const Site_2& pole) + : _pole(pole) {} + + Inverted_weighted_point operator()(const Site_2& wp) + { + FT xs = wp.x() - _pole.x(); + FT ys = wp.y() - _pole.y(); + FT ws = wp.weight() - _pole.weight(); + FT ps = CGAL::square(xs) + CGAL::square(ys) + - CGAL::square(ws); + + return + Inverted_weighted_point(Site_2(Point_2(xs, ys), ws), ps); + } + + Site_2 pole() const { return _pole; } +}; + + +template< class K > +class Voronoi_radius_2 +{ + // this class stores the coefficients for the tritangent circle + // radius equation. In particular we have: + // a x^2 - 2 b x + c = 0; + // x here represents the inverse of the radius +public: + typedef typename K::FT FT; + typedef Inverted_weighted_point_2 Inverted_weighted_point; + +private: + FT _a, _b, _c; + FT _c2, _delta; + FT _dxp, _dyp, _dwp; + + Voronoi_radius_2(FT a, FT b, FT c, FT c2, FT delta, + FT dxp, FT dyp, FT dwp) + : _a(a), _b(b), _c(c), _c2(c2), _delta(delta), _dxp(dxp), + _dyp(dyp), _dwp(dwp) {} + +public: + Voronoi_radius_2(const Inverted_weighted_point& u1, + const Inverted_weighted_point& u2) + { + FT dxp = determinant(u1.x(), u1.p(), u2.x(), u2.p()); + FT dyp = determinant(u1.y(), u1.p(), u2.y(), u2.p()); + FT dwp = determinant(u1.weight(), u1.p(), u2.weight(), u2.p()); + FT dxy = determinant(u1.x(), u1.y(), u2.x(), u2.y()); + FT dxw = determinant(u1.x(), u1.weight(), u2.x(), u2.weight()); + FT dyw = determinant(u1.y(), u1.weight(), u2.y(), u2.weight()); + + _a = CGAL::square(dxp) + CGAL::square(dyp); + _b = dxp * dxw + dyp * dyw; + _c = CGAL::square(dxw) + CGAL::square(dyw) - CGAL::square(dxy); + _c2 = dxy; + _delta = _a - CGAL::square(dwp); + _dxp = dxp; + _dyp = dyp; + _dwp = dwp; + } + + inline FT a() const { return _a; } + inline FT b() const { return _b; } + inline FT c() const { return _c; } + + inline FT c1() const { return _b; } + inline FT c2() const { return _c2; } + inline FT delta() const { return _delta; } + inline FT d() const { return _a; } + + inline FT dxp() const { return _dxp; } + inline FT dyp() const { return _dyp; } + inline FT dwp() const { return _dwp; } + + inline bool is_first_root() const { return CGAL::is_negative(_c2); } + + Voronoi_radius_2 get_symmetric() + { + return Voronoi_radius_2(_a, _b, _c, -_c2, _delta, -_dxp, -_dyp, -_dwp); + } +}; + + +template< class K > +class Bitangent_line_2 +{ + // this class computes and stores the data for the left bitangent + // line of the weighted points p1, p2 oriented from p1 to p2 + // or the left bitangent line of the inverted weighted point u1 and + // u2, oriented from u1 to u2 +public: + typedef typename K::Point_2 Point_2; + typedef typename K::Site_2 Site_2; + typedef Inverted_weighted_point_2 Inverted_weighted_point; + typedef typename K::FT FT; +protected: + FT _a1, _a2; + FT _b1, _b2; + FT _c1, _c2; + FT _delta; + FT _d; + FT _dw; + FT _dxw, _dyw; + + Bitangent_line_2(FT a1, FT a2, FT b1, FT b2, FT c1, FT c2, + FT delta, FT d, FT dw, FT dxw, FT dyw) + : _a1(a1), _a2(a2), _b1(b1), _b2(b2), _c1(c1), _c2(c2), + _delta(delta), _d(d), _dw(dw),_dxw(dxw), _dyw(dyw) {} + + inline void + store(FT dx, FT dy, FT dw) + { + _dw = dw; + _a1 = dx * dw; + _a2 = dy; + _b1 = dy * dw; + _b2 = -dx; + } + + inline void + store(FT dx, FT dy, FT dw, FT dxy, FT dxw, FT dyw) + { + store(dx, dy, dw); + _c1 = dx * dxw + dy * dyw; + _c2 = dxy; + _d = CGAL::square(dx) + CGAL::square(dy); + _delta = _d - CGAL::square(dw); + _dxw = dxw; + _dyw = dyw; + } + +public: + Bitangent_line_2(const Site_2& p1, const Site_2& p2) + { + FT dx = p1.x() - p2.x(); + FT dy = p1.y() - p2.y(); + FT dw = p1.weight() - p2.weight(); + FT dxy = determinant(p1.x(), p1.y(), p2.x(), p2.y()); + FT dxw = determinant(p1.x(), p1.weight(), p2.x(), p2.weight()); + FT dyw = determinant(p1.y(), p1.weight(), p2.y(), p2.weight()); + + store(dx, dy, dw, dxy, dxw, dyw); + } + + + Bitangent_line_2(const Inverted_weighted_point& u1, + const Inverted_weighted_point& u2) + { + FT dxp = determinant(u1.x(), u1.p(), u2.x(), u2.p()); + FT dyp = determinant(u1.y(), u1.p(), u2.y(), u2.p()); + FT dwp = determinant(u1.weight(), u1.p(), u2.weight(), u2.p()); + FT dxy = determinant(u1.x(), u1.y(), u2.x(), u2.y()); + FT dxw = determinant(u1.x(), u1.weight(), u2.x(), u2.weight()); + FT dyw = determinant(u1.y(), u1.weight(), u2.y(), u2.weight()); + + store(dxp, dyp, dwp, dxy, dxw, dyw); + } + + Bitangent_line_2 get_symmetric() const + { + return + Bitangent_line_2(_a1, -_a2, _b1, -_b2, _c1, -_c2, _delta, _d, + -_dw, -_dxw, -_dyw); + } + + Bitangent_line_2 get_rot90() const + { + return + Bitangent_line_2(-_b1, -_b2, _a1, _a2, _c1, _c2, _delta, _d, + _dw, -_dyw, _dxw); + } + + Bitangent_line_2 perpendicular(const Point_2& p) const + { + // THIS DOES NOT KEEP TRACK OF THE ADDITIONALLY STORED + // QUANTITIES; THIS IS INEVITABLE IN ANY CASE SINCE GIVEN p WE + // CANNOT ANY LONGER HOPE TO KEEP TRACK OF THOSE + Bitangent_line_2 rotated = get_rot90(); + rotated._c1 = _b1 * p.x() - _a1 * p.y(); + rotated._c2 = _b2 * p.x() - _a2 * p.y(); + + return rotated; + } + + Bitangent_line_2 perpendicular(const Inverted_weighted_point& u) const + { + // THIS DOES NOT KEEP TRACK OF THE ADDITIONALLY STORED + // QUANTITIES; THIS IS INEVITABLE IN ANY CASE SINCE GIVEN p WE + // CANNOT ANY LONGER HOPE TO KEEP TRACK OF THOSE + Bitangent_line_2 rotated = get_rot90(); + rotated._c1 = (_b1 * u.x() - _a1 * u.y()) * u.p(); + rotated._c2 = (_b2 * u.x() - _a2 * u.y()) * u.p(); + + return rotated; + } + + inline FT a1() const { return _a1; } + inline FT a2() const { return _a2; } + inline FT b1() const { return _b1; } + inline FT b2() const { return _b2; } + inline FT c1() const { return _c1; } + inline FT c2() const { return _c2; } + inline FT delta() const { return _delta; } + inline FT d() const { return _d; } + + inline FT dx() const { return -_b2; } + inline FT dy() const { return _a2; } + inline FT dw() const { return _dw; } + inline FT dxw() const { return _dxw; } + inline FT dyw() const { return _dyw; } +}; + + +template< class K > +class Voronoi_circle_2 : public Bitangent_line_2 +{ +public: + typedef Inverted_weighted_point_2 Inverted_weighted_point; + typedef Bitangent_line_2 Bitangent_line; + typedef Voronoi_radius_2 Voronoi_radius; + typedef typename Bitangent_line::FT FT; + +protected: + FT _gamma; + + inline + void compute_gamma() + { + _gamma = CGAL::square(this->_dxw) + CGAL::square(this->_dyw) + - CGAL::square(this->_c2); + } + +public: + Voronoi_circle_2(const Voronoi_radius& vr) + : Bitangent_line(FT(0), FT(0), FT(0), FT(0), vr.b(), vr.c2(), + vr.delta(), vr.d(), FT(0), FT(0), FT(0)), _gamma(vr.c()) + { + this->store(vr.dxp(), vr.dyp(), vr.dwp()); + } + + Voronoi_circle_2(const Bitangent_line& bl) + : Bitangent_line(bl.a1(), bl.a2(), bl.b1(), bl.b2(), bl.c1(), bl.c2(), + bl.delta(), bl.d(), bl.dw(), bl.dxw(), bl.dyw()) + { + compute_gamma(); + } + + inline FT alpha() const { return this->_d; } + inline FT beta() const { return this->_c1; } + inline FT gamma() const { return _gamma; } + + inline bool is_first_root() const { + return CGAL::is_negative(this->_c2); + } + + FT compute_P4(const Inverted_weighted_point& u1, + const Inverted_weighted_point& u2, + const Inverted_weighted_point& u3) const + { + FT dx1 = determinant(u2.x(), u2.p(), u1.x(), u1.p()); + FT dy1 = determinant(u2.y(), u2.p(), u1.y(), u1.p()); + FT dw1 = determinant(u2.weight(), u2.p(), u1.weight(), u1.p()); + + FT dx3 = determinant(u3.x(), u3.p(), u2.x(), u2.p()); + FT dy3 = determinant(u3.y(), u3.p(), u2.y(), u2.p()); + FT dw3 = determinant(u3.weight(), u3.p(), u2.weight(), u2.p()); + + FT u2Pv2 = CGAL::square(u2.x()) + CGAL::square(u2.y()); + FT u2Mv2 = CGAL::square(u2.x()) - CGAL::square(u2.y()); + FT u2v2 = FT(2) * u2.x() * u2.y(); + + + FT vvMuu = dy1 * dy3 - dx1 * dx3; + FT vuPuv = dy1 * dx3 + dx1 * dy3; + + FT dx2Pdy2_1 = CGAL::square(dx1) + CGAL::square(dy1); + FT dx2Pdy2_3 = CGAL::square(dx3) + CGAL::square(dy3); + + FT fr1_sq = CGAL::square(dw1) * dx2Pdy2_3; + FT fr3_sq = CGAL::square(dw3) * dx2Pdy2_1; + + FT f1 = (fr1_sq + fr3_sq) * CGAL::square(u2Pv2); + + FT f2 = FT(2) * dw1 * dw3 * u2Pv2 * (u2Mv2 * vvMuu - u2v2 * vuPuv ); + FT f3 = CGAL::square(u2Mv2 * vuPuv + u2v2 * vvMuu); + + FT F = f1 + f2 - f3; + + + FT uuPvv = dy1 * dy3 + dx1 * dx3; + FT vuMuv = dy1 * dx3 - dx1 * dy3; + + FT G = fr1_sq + fr3_sq - FT(2) * dw1 * dw3 * uuPvv + - CGAL::square(vuMuv); + + return (F * G); + } +}; + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_PREDICATE_CONSTRUCTIONS_2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Predicates_C2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Predicates_C2.h new file mode 100644 index 00000000000..c2072b9acb7 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Predicates_C2.h @@ -0,0 +1,33 @@ +// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_PREDICATES_C2_H +#define CGAL_APOLLONIUS_GRAPH_2_PREDICATES_C2_H + +#include + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#endif // CGAL_APOLLONIUS_GRAPH_2_PREDICATES_C2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Traits_wrapper_2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Traits_wrapper_2.h new file mode 100644 index 00000000000..fe38a0a7911 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/Traits_wrapper_2.h @@ -0,0 +1,50 @@ +// Copyright (c) 2003,2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_TRAITS_WRAPPER_2_H +#define CGAL_APOLLONIUS_GRAPH_2_TRAITS_WRAPPER_2_H + +#include + + + +#include + + + +namespace CGAL { + +namespace ApolloniusGraph_2 { + + +template +class Apollonius_graph_traits_wrapper_2 : public Gt_base +{ +public: + // struct Segment_2 {}; + struct Triangle_2 {}; + + Apollonius_graph_traits_wrapper_2() {} + Apollonius_graph_traits_wrapper_2(const Gt_base& gtb) + : Gt_base(gtb) {} + +}; + + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + + +#endif // CGAL_APOLLONIUS_GRAPH_2_TRAITS_WRAPPER_2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/basic.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/basic.h new file mode 100644 index 00000000000..15e872c32a4 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/basic.h @@ -0,0 +1,25 @@ +// Copyright (c) 2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + +#ifndef CGAL_APOLLONIUS_GRAPH_2_BASIC_H +#define CGAL_APOLLONIUS_GRAPH_2_BASIC_H 1 + +#include + + +#include +#include + +#define CGAL_APOLLONIUS_GRAPH_2_NS CGAL::ApolloniusGraph_2 + + +#endif // CGAL_APOLLONIUS_GRAPH_2_BASIC_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/compare_quadratic.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/compare_quadratic.h new file mode 100644 index 00000000000..621d35f6933 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/compare_quadratic.h @@ -0,0 +1,986 @@ +// Copyright (c) 2003,2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_COMPARE_QUADRATIC_H +#define CGAL_APOLLONIUS_GRAPH_2_COMPARE_QUADRATIC_H + +#include + + +#include +#include + +namespace CGAL { + +namespace ApolloniusGraph_2 { + +#ifdef COMPARATOR_PROFILER +#include +#endif + + +//-------------------------------------------------------------------- +// help functions for the compulation of various quantites + +template < class FT > +inline FT +value_of_D(const FT& a, const FT& b, const FT& c) +{ + return CGAL::square(b) - a * c; +} + +template < class FT > +inline FT +value_of_J(const FT& a1, const FT& b1, const FT& a2, const FT& b2) +{ + return (a1 * b2 - a2 * b1); +} + +template < class FT > +inline FT +value_of_Jp(const FT& b1, const FT& c1, const FT& b2, const FT& c2) +{ + return (b1 * c2 - b2 * c1); +} + +template < class FT > +inline FT +value_of_G(const FT& a1, const FT& c1, const FT& a2, const FT& c2) +{ + return (a1 * c2 - a2 * c1); +} + +template < class FT > +inline FT +value_of_K(const FT& a1c2, const FT& a2c1, const FT& b1b2) +{ + return a1c2 + a2c1 - FT(2) * b1b2; +} + +template < class FT > +inline FT +value_of_K(const FT& a1, const FT& b1, const FT& c1, + const FT& a2, const FT& b2, const FT& c2) +{ + return c1 * a2 + a1 * c2 - FT(2) * b1 * b2; +} + +template < class FT > +inline FT +value_of_R0(const FT& J, const FT& Jp, + const FT& a1, const FT& c1, + const FT& a2, const FT& c2) +{ + return CGAL::square(a1 * c2 - c1 * a2) - FT(4) * J * Jp; +} + +template < class FT > +inline FT +value_of_R0(const FT& D1, const FT& D2, const FT& K) +{ + return CGAL::square(K) - FT(4) * D1 * D2; +} + +template < class FT > +inline FT +value_of_P4(const FT& D1, const FT& D2, const FT& K) +{ + return FT(4) * D1 * D2 - CGAL::square(K); +} + +template < class FT > +inline FT +value_of_D(const FT& a1, const FT& D1, const FT& a2, const FT& D2) +{ + return D1 * CGAL::square(a2) - D2 * CGAL::square(a1); +} + +template < class FT > +inline FT +value_of_P3inf(const FT& a1, const FT& b1, const FT& J, const FT& G) +{ + return FT(2) * b1 * J - a1 * G; +} + +template < class FT > +inline FT +value_of_P3inf_bis(const FT& a1, const FT& K, const FT& a2, const FT& D1) +{ + return -(a1 * K + FT(2) * a2 * D1); +} + +template < class FT > +inline FT +value_of_P3pinf(const FT& c1, const FT& J, const FT& a1, const FT& Jp) +{ + return c1 * J - a1 * Jp; +} + +template < class FT > +inline FT +value_of_L(const FT& a1, const FT& c2, const FT& b1, const FT& b2) +{ + return (a1 * c2 - b1 * b2); +} + +template < class FT > +inline FT +value_of_Lp(const FT& a2, const FT& c1, const FT& b1, const FT& b2) +{ + return (a2 * c1 - b1 * b2); +} + +template < class FT > +inline FT +value_of_A(const FT& b1, const FT& J, const FT& a1, const FT& L) +{ + return b1 * J + a1 * L; +} + +template < class FT > +inline FT +value_of_Q3(const FT& b2, const FT& a2, const FT& J, const FT& L) +{ + return (b2 * J + a2 * L); +} + +template < class FT > +inline FT +value_of_Q3(const FT& a2, const FT& b2, const FT& J, const FT& G, + const FT& K) +{ + return FT(2) * b2 * J - a2 * (G - K); +} + +template < class FT > +inline FT +value_of_Q3p(const FT& a1, const FT& b1, const FT& J, const FT& G, + const FT& K) +{ + return a1 * (G + K) - FT(2) * b1 * J; +} + + +//-------------------------------------------------------------------- + +// the trivial method that uses square roots + +template < class FT > +inline +Comparison_result +sqrt_compare_l1_l2(const FT& a1, const FT& b1, const FT& c1, + const FT& a2, const FT& b2, const FT& c2) +{ + FT D1 = value_of_D(a1, b1, c1); + FT D2 = value_of_D(a2, b2, c2); + + FT l1 = ( b1 - CGAL::sqrt(D1) ) / a1; + FT l2 = ( b2 - CGAL::sqrt(D2) ) / a2; + + return CGAL::compare(l1, l2); +} + +template < class FT > +inline +Comparison_result +sqrt_compare_l1_r2(const FT& a1, const FT& b1, const FT& c1, + const FT& a2, const FT& b2, const FT& c2) +{ + FT D1 = value_of_D(a1, b1, c1); + FT D2 = value_of_D(a2, b2, c2); + + FT l1 = ( b1 - CGAL::sqrt(D1) ) / a1; + FT r2 = ( b2 + CGAL::sqrt(D2) ) / a2; + + return CGAL::compare(l1, r2); +} + + +template < class FT > +inline +Comparison_result +sqrt_compare_r1_l2(const FT& a1, const FT& b1, const FT& c1, + const FT& a2, const FT& b2, const FT& c2) +{ + FT D1 = value_of_D(a1, b1, c1); + FT D2 = value_of_D(a2, b2, c2); + + FT r1 = ( b1 + CGAL::sqrt(D1) ) / a1; + FT l2 = ( b2 - CGAL::sqrt(D2) ) / a2; + + return CGAL::compare(r1, l2); +} + +template < class FT > +inline +Comparison_result +sqrt_compare_r1_r2(const FT& a1, const FT& b1, const FT& c1, + const FT& a2, const FT& b2, const FT& c2) +{ + FT D1 = value_of_D(a1, b1, c1); + FT D2 = value_of_D(a2, b2, c2); + + FT r1 = ( b1 + CGAL::sqrt(D1) ) / a1; + FT r2 = ( b2 + CGAL::sqrt(D2) ) / a2; + + return CGAL::compare(r1, r2); +} + + + +//-------------------------------------------------------------------- + + +// the DFMT evaluation trees + +template < class FT > +inline +Comparison_result +dfmt_compare_l1_l2(const FT& a1, const FT& b1, const FT& c1, + const FT& a2, const FT& b2, const FT& c2) +{ + FT J = value_of_J(a1, b1, a2, b2); + FT K = value_of_K(a1, b1, c1, a2, b2, c2); + + if ( CGAL::is_positive(J) ) { + if ( CGAL::is_positive(K) ) return SMALLER; // l1 < l2 + + FT D1 = value_of_D(a1, b1, c1); + FT D2 = value_of_D(a2, b2, c2); + + FT D = value_of_D(a1, D1, a2, D2); + + if ( CGAL::is_positive(D) ) return SMALLER; // l1 < l2 + + FT Jp = value_of_Jp(b1, c1, b2, c2); + + if ( CGAL::is_negative(Jp) ) return LARGER; // l1 > l2 + + FT R0 = value_of_R0(D1, D2, K); + + Sign s_R0 = CGAL::sign(R0); + if ( s_R0 == NEGATIVE ) return SMALLER; // l1 < l2 + if ( s_R0 == POSITIVE ) return LARGER; // l1 > l2 + return EQUAL; + } else { // J<0 + if ( CGAL::is_positive(K) ) return LARGER; // l1 > l2 + + FT D1 = value_of_D(a1, b1, c1); + FT D2 = value_of_D(a2, b2, c2); + + FT D = value_of_D(a1, D1, a2, D2); + + if ( CGAL::is_negative(D) ) return LARGER; // l1 > l2 + + FT Jp = value_of_Jp(b1, c1, b2, c2); + + if ( CGAL::is_positive(Jp) ) return SMALLER; // l1 < l2 + + FT R0 = value_of_R0(D1, D2, K); + + Sign s_R0 = CGAL::sign(R0); + if ( s_R0 == NEGATIVE ) return LARGER; // l1 > l2 + if ( s_R0 == POSITIVE ) return SMALLER; // l1 < l2 + return EQUAL; + } +} + +template < class FT > +inline +Comparison_result +dfmt_compare_l1_r2(const FT& a1, const FT& b1, const FT& c1, + const FT& a2, const FT& b2, const FT& c2) +{ + FT J = value_of_J(a1, b1, a2, b2); + + if ( CGAL::is_positive(J) ) return SMALLER; // l1 < r2 + + FT K = value_of_K(a1, b1, c1, a2, b2, c2); + + if ( CGAL::is_negative(K) ) return SMALLER; // l1 < r2 + + FT Jp = value_of_Jp(b1, c1, b2, c2); + + if ( CGAL::is_positive(Jp) ) return LARGER; // l1 > r2 + + FT R0 = value_of_R0(J, Jp, a1, c1, a2, c2); + + Sign s_R0 = CGAL::sign(R0); + if ( s_R0 == NEGATIVE ) return SMALLER; // l1 < r2 + if ( s_R0 == POSITIVE ) return LARGER; // l1 > r2 + return EQUAL; +} + + + +template < class FT > +inline +Comparison_result +dfmt_compare_r1_l2(const FT& a1, const FT& b1, const FT& c1, + const FT& a2, const FT& b2, const FT& c2) +{ + FT J = value_of_J(a1, b1, a2, b2); + + if ( CGAL::is_negative(J) ) return LARGER; // r1 > l2 + + FT K = value_of_K(a1, b1, c1, a2, b2, c2); + + if ( CGAL::is_negative(K) ) return LARGER; // r1 > l2 + + FT Jp = value_of_Jp(b1, c1, b2, c2); + + if ( CGAL::is_negative(Jp) ) return SMALLER; // r1 < l2 + + FT R0 = value_of_R0(J, Jp, a1, c1, a2, c2); + + Sign s_R0 = CGAL::sign(R0); + if ( s_R0 == NEGATIVE ) return LARGER; // r1 > l2 + if ( s_R0 == POSITIVE ) return SMALLER; // r1 < l2 + return EQUAL; +} + +template < class FT > +inline +Comparison_result +dfmt_compare_r1_r2(const FT& a1, const FT& b1, const FT& c1, + const FT& a2, const FT& b2, const FT& c2) +{ +#ifdef COMPARATOR_PROFILER + comparator_profiler::counter_rr++; +#endif + + FT J = value_of_J(a1, b1, a2, b2); + FT K = value_of_K(a1, b1, c1, a2, b2, c2); + + if ( CGAL::is_positive(J) ){ + if ( CGAL::is_positive(K) ) return SMALLER; // r1 < r2 1,2 + +#ifdef COMPARATOR_PROFILER + comparator_profiler::counter_rr_e++; +#endif + + FT D1 = value_of_D(a1, b1, c1); + FT D2 = value_of_D(a2, b2, c2); + + FT D = value_of_D(a1, D1, a2, D2); + + if ( CGAL::is_negative(D) ) return SMALLER; // r1 < r2 2,3b + +#ifdef COMPARATOR_PROFILER + comparator_profiler::counter_rr_r0++; +#endif + + FT Jp = value_of_Jp(b1, c1, b2, c2); + + if ( CGAL::is_negative(Jp) ) return LARGER; // r1 > r2 3a + + FT R0 = value_of_R0(D1, D2, K); + + Sign s_R0 = CGAL::sign(R0); + if ( s_R0 == NEGATIVE ) return SMALLER; // r1 < r2 2 + if ( s_R0 == POSITIVE ) return LARGER; // r1 > r2 3a + return EQUAL; + } else { // J<0 + if ( CGAL::is_positive(K) ) return LARGER; // r1 > r2 4,5 + +#ifdef COMPARATOR_PROFILER + comparator_profiler::counter_rr_e++; +#endif + + FT D1 = value_of_D(a1, b1, c1); + FT D2 = value_of_D(a2, b2, c2); + + FT D = value_of_D(a1, D1, a2, D2); + + if ( CGAL::is_positive(D) ) return LARGER; // r1 > r2 3a,4 + +#ifdef COMPARATOR_PROFILER + comparator_profiler::counter_rr_r0++; +#endif + + FT Jp = value_of_Jp(b1, c1, b2, c2); + + if ( CGAL::is_positive(Jp) ) return SMALLER; // r1 < r2 3b + + FT R0 = value_of_P4(D1, D2, K); + + Sign s_R0 = CGAL::sign(R0); + if ( s_R0 == NEGATIVE ) return LARGER; // r1 > r2 4 + if ( s_R0 == POSITIVE ) return SMALLER; // r1 < r2 3b + return EQUAL; + } +} + +//-------------------------------------------------------------------- + +// the KE evaluation trees + +template < class FT > +inline +Comparison_result +ke_compare_l1_l2(const FT& a1, const FT& b1, const FT& c1, + const FT& a2, const FT& b2, const FT& c2) +{ + FT J = value_of_J(a1, b1, a2, b2); + Sign s_J = CGAL::sign(J); + + if ( s_J == ZERO ) { + Sign s_G = CGAL::sign( value_of_G(a1, c1, a2, c2) ); + if ( s_G == POSITIVE ) { return SMALLER; } + if ( s_G == NEGATIVE ) { return LARGER; } + return EQUAL; + } + + FT a1c2 = a1 * c2; + FT a2c1 = a2 * c1; + FT K = value_of_K(a1c2, a2c1, b1 * b2); + Sign s_K = CGAL::sign(K); + + if ( s_J == POSITIVE ) { + if ( s_K == POSITIVE ) { return SMALLER; } + + if ( s_K == ZERO ) { + FT D1 = value_of_D(a1, b1, c1); + if ( CGAL::is_zero(D1) ) { return EQUAL; } + + return SMALLER; + } + + FT G = a1c2 - a2c1; + FT P3inf = value_of_P3inf(a1, b1, J, G); + + if ( !(CGAL::is_positive(P3inf)) ) { return SMALLER; } + + FT Jp = value_of_Jp(b1, c1, b2, c2); + + if ( CGAL::is_negative(Jp) ) { return LARGER; } + + FT P4 = value_of_P4(J, Jp, G); + + Sign s_P4 = CGAL::sign(P4); + if ( s_P4 == POSITIVE ) { return SMALLER; } + if ( s_P4 == NEGATIVE ) { return LARGER; } + return EQUAL; + } + + // J < 0 + if ( s_K == POSITIVE ) { return LARGER; } + + if ( s_K == ZERO ) { + FT D2 = value_of_D(a2, b2, c2); + if ( CGAL::is_zero(D2) ) { return EQUAL; } + + return LARGER; + } + FT G = a1c2 - a2c1; + FT P3inf = value_of_P3inf(a1, b1, J, G); + + if ( !(CGAL::is_negative(P3inf)) ) { return LARGER; } + + FT Jp = value_of_Jp(b1, c1, b2, c2); + + if ( CGAL::is_positive(Jp) ) { return SMALLER; } + + FT P4 = value_of_P4(J, Jp, G); + + Sign s_P4 = CGAL::sign(P4); + if ( s_P4 == POSITIVE ) { return LARGER; } + if ( s_P4 == NEGATIVE ) { return SMALLER; } + return EQUAL; +} + +template < class FT > +inline +Comparison_result +ke_compare_l1_r2(const FT& a1, const FT& b1, const FT& c1, + const FT& a2, const FT& b2, const FT& c2) +{ + FT J = value_of_J(a1, b1, a2, b2); + Sign s_J = CGAL::sign(J); + +#if 0 + if ( s_J == ZERO ) { + FT D1 = value_of_D(a1, b1, c1); + if ( CGAL::is_positive(D1) ) { return SMALLER; } + + FT D2 = value_of_D(a2, b2, c2); + if ( CGAL::is_positive(D2) ) { return SMALLER; } + + return EQUAL; + } +#endif + + if ( s_J == POSITIVE ) { return SMALLER; } + + FT a1c2 = a1 * c2; + FT a2c1 = a2 * c1; + FT K = value_of_K(a1c2, a2c1, b1 * b2); + Sign s_K = CGAL::sign(K); + + if ( s_K == NEGATIVE ) { return SMALLER; } +#if 0 + if ( s_K == ZERO ) { + FT D1 = value_of_D(a1, b1, c1); + if ( CGAL::is_zero(D1) ) { return EQUAL; } + + FT D2 = value_of_D(a2, b2, c2); + if ( CGAL::is_zero(D2) ) { return EQUAL; } + + return SMALLER; + } +#endif + + FT Jp = value_of_Jp(b1, c1, b2, c2); + + if ( CGAL::is_positive(Jp) ) { return LARGER; } + + FT P4 = value_of_P4(J, Jp, a1c2 - a2c1); + + Sign s_P4 = CGAL::sign(P4); + if ( s_P4 == POSITIVE ) { return SMALLER; } + if ( s_P4 == NEGATIVE ) { return LARGER; } + return EQUAL; +} + +template < class FT > +inline +Comparison_result +ke_compare_r1_l2(const FT& a1, const FT& b1, const FT& c1, + const FT& a2, const FT& b2, const FT& c2) +{ + FT J = value_of_J(a1, b1, a2, b2); + Sign s_J = CGAL::sign(J); + +#if 0 + if ( s_J == ZERO ) { + FT D1 = value_of_D(a1, b1, c1); + if ( CGAL::is_positive(D1) ) { return LARGER; } + + FT D2 = value_of_D(a2, b2, c2); + if ( CGAL::is_positive(D2) ) { return LARGER; } + + return EQUAL; + } +#endif + + if ( s_J == NEGATIVE ) { return LARGER; } + + FT a1c2 = a1 * c2; + FT a2c1 = a2 * c1; + FT K = value_of_K(a1c2, a2c1, b1 * b2); + Sign s_K = CGAL::sign(K); + + if ( s_K == NEGATIVE ) { return LARGER; } + +#if 0 + if ( s_K == ZERO ) { + FT D1 = value_of_D(a1, b1, c1); + if ( CGAL::is_zero(D1) ) { return EQUAL; } + + FT D2 = value_of_D(a2, b2, c2); + if ( CGAL::is_zero(D2) ) { return EQUAL; } + + return LARGER; + } +#endif + + FT Jp = value_of_Jp(b1, c1, b2, c2); + + if ( CGAL::is_negative(Jp) ) { return SMALLER; } + + FT P4 = value_of_P4(J, Jp, a1c2 - a2c1); + + Sign s_P4 = CGAL::sign(P4); + if ( s_P4 == POSITIVE ) { return LARGER; } + if ( s_P4 == NEGATIVE ) { return SMALLER; } + return EQUAL; +} + +template < class FT > +inline +Comparison_result +ke_compare_r1_r2(const FT& a1, const FT& b1, const FT& c1, + const FT& a2, const FT& b2, const FT& c2) +{ +#ifdef COMPARATOR_PROFILER + comparator_profiler::counter_rr++; +#endif + + FT J = value_of_J(a1, b1, a2, b2); + Sign s_J = CGAL::sign(J); + + FT a1c2 = a1 * c2; + FT a2c1 = a2 * c1; + FT K = value_of_K(a1c2, a2c1, b1 * b2); + Sign s_K = CGAL::sign(K); + + if ( s_J == POSITIVE ) { + if ( s_K == POSITIVE ) { return SMALLER; } + else if ( s_K == NEGATIVE ) { + +#ifdef COMPARATOR_PROFILER + comparator_profiler::counter_rr_p3inf++; +#endif + + FT G = a1c2 - a2c1; + FT P3inf = value_of_P3inf(a1, b1, J, G); + + if ( !(CGAL::is_negative(P3inf)) ) { return SMALLER; } + +#ifdef COMPARATOR_PROFILER + comparator_profiler::counter_rr_p4++; +#endif + + FT Jp = value_of_Jp(b1, c1, b2, c2); + + if ( CGAL::is_negative(Jp) ) { return LARGER; } + + FT P4 = value_of_P4(J, Jp, G); + + Sign s_P4 = CGAL::sign(P4); + if ( s_P4 == POSITIVE ) { return SMALLER; } + if ( s_P4 == NEGATIVE ) { return LARGER; } + return EQUAL; + } else { // K = 0 + FT D2 = value_of_D(a2, b2, c2); + if ( CGAL::is_zero(D2) ) { return EQUAL; } + + return SMALLER; + } + } else if ( s_J == NEGATIVE ) { // J < 0 + if ( s_K == POSITIVE ) { return LARGER; } + else if ( s_K == NEGATIVE ) { + +#ifdef COMPARATOR_PROFILER + comparator_profiler::counter_rr_p3inf++; +#endif + + FT G = a1c2 - a2c1; + FT P3inf = value_of_P3inf(a1, b1, J, G); + + if ( !(CGAL::is_positive(P3inf)) ) { return LARGER; } + +#ifdef COMPARATOR_PROFILER + comparator_profiler::counter_rr_p4++; +#endif + + FT Jp = value_of_Jp(b1, c1, b2, c2); + + if ( CGAL::is_positive(Jp) ) { return SMALLER; } + + FT P4 = value_of_P4(J, Jp, G); + + Sign s_P4 = CGAL::sign(P4); + if ( s_P4 == POSITIVE ) { return LARGER; } + if ( s_P4 == NEGATIVE ) { return SMALLER; } + return EQUAL; + } else { // K = 0 + FT D1 = value_of_D(a1, b1, c1); + if ( CGAL::is_zero(D1) ) { return EQUAL; } + + return LARGER; + } + } + + // J = 0 + Sign s_G = CGAL::sign( value_of_G(a1, c1, a2, c2) ); + if ( s_G == NEGATIVE ) { return SMALLER; } + if ( s_G == POSITIVE ) { return LARGER; } + return EQUAL; +} + + +//-------------------------------------------------------------------- + +//-------------------------------------------------------------------- +//-------------------------------------------------------------------- +// the following functions do the filtering for the r1-r2 tree without +// using C++ exceptions + +template < class CT, class ET > +inline +Comparison_result +sqrt_compare_r1_r2_filtered(const CT& a1, const CT& b1, const CT& c1, + const CT& a2, const CT& b2, const CT& c2) +{ + typedef Interval_nt IT; + + FPU_CW_t backup = FPU_get_cw(); + FPU_set_cw(CGAL_FE_UPWARD); + + IT a1i(a1), b1i(b1), c1i(c1); + IT a2i(a2), b2i(b2), c2i(c2); + + IT D1 = value_of_D(a1i, b1i, c1i); + IT D2 = value_of_D(a2i, b2i, c2i); + + IT r1 = ( b1i + CGAL::sqrt(D1) ) / a1i; + IT r2 = ( b2i + CGAL::sqrt(D2) ) / a2i; + + FPU_set_cw(backup); + + if ( r1.sup() < r2.inf() ) { return SMALLER; } + if ( r1.inf() > r2.sup() ) { return LARGER; } + + return sqrt_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); +} + +//-------------------------------------------------------------------- + +template < class CT, class ET > +inline +Comparison_result +dfmt_compare_r1_r2_filtered(const CT& a1, const CT& b1, const CT& c1, + const CT& a2, const CT& b2, const CT& c2) +{ + typedef Interval_nt IT; + + FPU_CW_t backup = FPU_get_cw(); + FPU_set_cw(CGAL_FE_UPWARD); + + IT a1i(a1), b1i(b1), c1i(c1); + IT a2i(a2), b2i(b2), c2i(c2); + + IT J = value_of_J(a1i, b1i, a2i, b2i); + IT K = value_of_K(a1i, b1i, c1i, a2i, b2i, c2i); + + if ( J.inf() > 0 ){ + if ( K.inf() > 0 ) { + FPU_set_cw(backup); + return SMALLER; + } + if ( K.sup() > 0 ) { + FPU_set_cw(backup); + return dfmt_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); + } + + IT D1 = value_of_D(a1i, b1i, c1i); + IT D2 = value_of_D(a2i, b2i, c2i); + + IT D = value_of_D(a1i, D1, a2i, D2); + + if ( D.sup() < 0 ) { + FPU_set_cw(backup); + return SMALLER; + } + if ( D.inf() < 0 ) { + FPU_set_cw(backup); + return dfmt_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); + } + + IT Jp = value_of_Jp(b1i, c1i, b2i, c2i); + + if ( Jp.sup() < 0 ) { + FPU_set_cw(backup); + return LARGER; + } + if ( Jp.inf() < 0 ) { + FPU_set_cw(backup); + return dfmt_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); + } + + + IT R0 = value_of_R0(D1, D2, K); + FPU_set_cw(backup); + + if ( R0.sup() < 0 ) { return SMALLER; } + if ( R0.inf() > 0 ) { return LARGER; } + return dfmt_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); + } else if ( J.sup() > 0 ) { + FPU_set_cw(backup); + return dfmt_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); + } else { // J < 0 + if ( K.inf() > 0 ) { + FPU_set_cw(backup); + return LARGER; + } + if ( K.sup() > 0 ) { + FPU_set_cw(backup); + return dfmt_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); + } + + IT D1 = value_of_D(a1i, b1i, c1i); + IT D2 = value_of_D(a2i, b2i, c2i); + + IT D = value_of_D(a1i, D1, a2i, D2); + + if ( D.inf() > 0 ) { + FPU_set_cw(backup); + return LARGER; + } + if ( D.sup() > 0 ) { + FPU_set_cw(backup); + return dfmt_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); + } + + + IT Jp = value_of_Jp(b1i, c1i, b2i, c2i); + + if ( Jp.inf() > 0 ) { + FPU_set_cw(backup); + return SMALLER; + } + if ( Jp.sup() > 0 ) { + FPU_set_cw(backup); + return dfmt_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); + } + + IT R0 = value_of_P4(D1, D2, K); + FPU_set_cw(backup); + + if ( R0.sup() < 0 ) { return LARGER; } + if ( R0.inf() > 0 ) { return SMALLER; } + + return dfmt_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); + } +} + +//-------------------------------------------------------------------- + +template < class CT, class ET > +inline +Comparison_result +ke_compare_r1_r2_filtered(const CT& a1, const CT& b1, const CT& c1, + const CT& a2, const CT& b2, const CT& c2) +{ + typedef Interval_nt IT; + + FPU_CW_t backup = FPU_get_cw(); + FPU_set_cw(CGAL_FE_UPWARD); + + IT a1i(a1), b1i(b1), c1i(c1); + IT a2i(a2), b2i(b2), c2i(c2); + + IT J = value_of_J(a1i, b1i, a2i, b2i); + + IT a1c2 = a1i * c2i; + IT a2c1 = a2i * c1i; + + IT K = value_of_K(a1c2, a2c1, b1i * b2i); + + if ( J.inf() > 0 ) { + if ( K.inf() > 0 ) { + FPU_set_cw(backup); + return SMALLER; + } else if ( K.sup() < 0 ) { + IT G = a1c2 - a2c1; + IT P3inf = value_of_P3inf(a1i, b1i, J, G); + + if ( P3inf.inf() >= 0 ) { + FPU_set_cw(backup); + return SMALLER; + } + if ( P3inf.sup() > 0 ) { + FPU_set_cw(backup); + return ke_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); + } + + IT Jp = value_of_Jp(b1i, c1i, b2i, c2i); + + if ( Jp.sup() < 0 ) { + FPU_set_cw(backup); + return LARGER; + } + if ( Jp.inf() < 0 ) { + FPU_set_cw(backup); + return ke_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); + } + + IT P4 = value_of_P4(J, Jp, G); + FPU_set_cw(backup); + + if ( P4.inf() > 0 ) { return SMALLER; } + if ( P4.sup() < 0 ) { return LARGER; } + + return ke_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); + } else { + FPU_set_cw(backup); + return ke_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); + } + } else if ( J.sup() < 0 ) { // J < 0 + if ( K.inf() > 0 ) { + FPU_set_cw(backup); + return LARGER; + } else if ( K.sup() < 0 ) { + IT G = a1c2 - a2c1; + IT P3inf = value_of_P3inf(a1i, b1i, J, G); + + if ( P3inf.sup() <= 0 ) { + FPU_set_cw(backup); + return LARGER; + } + if ( P3inf.inf() < 0 ) { + FPU_set_cw(backup); + return ke_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); + } + + IT Jp = value_of_Jp(b1i, c1i, b2i, c2i); + + if ( Jp.inf() > 0 ) { + FPU_set_cw(backup); + return SMALLER; + } + if ( Jp.sup() > 0 ) { + FPU_set_cw(backup); + return ke_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); + } + + IT P4 = value_of_P4(J, Jp, G); + FPU_set_cw(backup); + + if ( P4.inf() > 0 ) { return LARGER; } + if ( P4.sup() < 0 ) { return SMALLER; } + + return ke_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); + } else { + FPU_set_cw(backup); + return ke_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); + } + } else { // J = ? + FPU_set_cw(backup); + return ke_compare_r1_r2(ET(a1), ET(b1), ET(c1), + ET(a2), ET(b2), ET(c2)); + } +} + + + + + +//-------------------------------------------------------------------- +//-------------------------------------------------------------------- + +} //namespace ApolloniusGraph_2 + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_COMPARE_QUADRATIC_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/uncertain/Uncertain_is_hidden_C2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/uncertain/Uncertain_is_hidden_C2.h new file mode 100644 index 00000000000..d62c21e558b --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/uncertain/Uncertain_is_hidden_C2.h @@ -0,0 +1,93 @@ +// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_UNCERTAIN_IS_HIDDEN_C2_H +#define CGAL_APOLLONIUS_GRAPH_2_UNCERTAIN_IS_HIDDEN_C2_H + +#include + + +#include +#include +#include + + +namespace CGAL { + +//-------------------------------------------------------------------- + + +template +class Ag2_uncertain_is_hidden_C2 +{ +public: + typedef K Kernel; + typedef MTag Method_tag; + typedef typename K::Site_2 Site_2; + typedef typename K::RT RT; + +private: + Uncertain is_hidden(const Site_2& p, const Site_2& q, + const Integral_domain_without_division_tag&) const + { + RT w1 = p.weight(); + RT w2 = q.weight(); + Uncertain s = CGAL::sign( CGAL::square(p.x() - q.x()) + + CGAL::square(p.y() - q.y()) + - CGAL::square(w1 - w2) + ); + if ( is_indeterminate(s) ) { + return Uncertain::indeterminate(); + } + if ( s == POSITIVE ) { return false; } + + Uncertain cr = CGAL::compare(w1, w2); + if ( is_indeterminate(cr) ) { + return Uncertain::indeterminate(); + } + return (cr != SMALLER); + } + + Uncertain is_hidden(const Site_2& p, const Site_2& q, + const Field_with_sqrt_tag&) const + { + RT d = CGAL::sqrt(CGAL::square(p.x() - q.x()) + + CGAL::square(p.y() - q.y())); + + Uncertain s = CGAL::sign(d - p.weight() + q.weight()); + if ( is_indeterminate(s) ) { + return Uncertain::indeterminate(); + } + return ( s != POSITIVE ); + } + +public: + typedef Uncertain result_type; + typedef Site_2 argument_type; + + inline bool operator()(const Site_2 &p, const Site_2 &q) const { +#ifdef AG2_PROFILE_PREDICATES + ag2_predicate_profiler::is_trivial_counter++; +#endif + return is_hidden(p, q, Method_tag()); + } +}; + + +//-------------------------------------------------------------------- + + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_UNCERTAIN_IS_HIDDEN_C2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/uncertain/Uncertain_oriented_side_of_bisector_C2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/uncertain/Uncertain_oriented_side_of_bisector_C2.h new file mode 100644 index 00000000000..6209c9060b8 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/uncertain/Uncertain_oriented_side_of_bisector_C2.h @@ -0,0 +1,121 @@ +// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_2_UNCERTAIN_ORIENTED_SIDE_OF_BISECTOR_C2_H +#define CGAL_APOLLONIUS_GRAPH_2_UNCERTAIN_ORIENTED_SIDE_OF_BISECTOR_C2_H + +#include + + +#include +#include +#include +#include + +namespace CGAL { + +//-------------------------------------------------------------------- + +template +class Ag2_uncertain_oriented_side_of_bisector_C2 +{ +public: + typedef K Kernel; + typedef MTag Method_tag; + + typedef typename K::Point_2 Point_2; + typedef typename K::Site_2 Site_2; + +private: + typedef typename Kernel::RT RT; + +private: + Uncertain + compare_distances(const Site_2& p1, const Site_2& p2, + const Point_2& p, const Integral_domain_without_division_tag&) const + { +#ifdef AG2_PROFILE_PREDICATES + ag2_predicate_profiler::side_of_bisector_counter++; +#endif + + // this function compares the distances of the point(x, y) from the + // disks {(x1, y1), w1} and {(x2, y2), w2} + RT D1 = CGAL::square(p1.x() - p.x()) + CGAL::square(p1.y() - p.y()); + RT D2 = CGAL::square(p2.x() - p.x()) + CGAL::square(p2.y() - p.y()); + RT Dw = p2.weight() - p1.weight(); + + Uncertain sign_of_Dw = CGAL::sign(Dw); + if ( is_indeterminate(sign_of_Dw) ) { + return Uncertain::indeterminate(); + } + + Uncertain R = CGAL::compare(D1, D2); + if ( is_indeterminate(R) ) { + return Uncertain::indeterminate(); + } + + if ( sign_of_Dw == ZERO ) { + return R; + } + if ( sign_of_Dw == POSITIVE ) { + if ( R != SMALLER ) return LARGER; + + return uncertain_sign_a_plus_b_x_sqrt_c(D1 - D2 + CGAL::square(Dw), + RT(2) * Dw, D1); + } + + if ( R != LARGER ) return SMALLER; + return uncertain_sign_a_plus_b_x_sqrt_c(D1 - D2 - CGAL::square(Dw), + RT(2) * Dw, D2); + } + + Comparison_result + compare_distances(const Site_2& p1, const Site_2& p2, + const Point_2 &p, const Field_with_sqrt_tag&) const + { +#ifdef AG2_PROFILE_PREDICATES + ag2_predicate_profiler::side_of_bisector_counter++; +#endif + // this function compares the distances of the point(x, y) from the + // disks {(x1, y1), w1} and {(x2, y2), w2} + + RT D1 = CGAL::square(p1.x() - p.x()) + CGAL::square(p1.y() - p.y()); + RT D2 = CGAL::square(p2.x() - p.x()) + CGAL::square(p2.y() - p.y()); + + RT d1 = CGAL::sqrt(D1) - p1.weight(); + RT d2 = CGAL::sqrt(D2) - p2.weight(); + + return CGAL::compare(d1, d2); + } + +public: + typedef Uncertain result_type; + struct argument_type {}; + + inline + Uncertain + operator()(const Site_2& p1, const Site_2& p2, + const Point_2 &p) const + { + return - compare_distances(p1, p2, p, Method_tag()); + } + +}; + + +//-------------------------------------------------------------------- + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_UNCERTAIN_ORIENTED_SIDE_OF_BISECTOR_C2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/uncertain/Uncertain_vertex_conflict_2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/uncertain/Uncertain_vertex_conflict_2.h new file mode 100644 index 00000000000..f82f5a8fd07 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/uncertain/Uncertain_vertex_conflict_2.h @@ -0,0 +1,403 @@ +// Copyright (c) 2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas +// Christophe Delage +// David Millman + +#ifndef CGAL_APOLLONIUS_GRAPH_2_UNCERTAIN_VERTEX_CONFLICT_2_H +#define CGAL_APOLLONIUS_GRAPH_2_UNCERTAIN_VERTEX_CONFLICT_2_H + +#include + + + +// FIXME: We include the old traits class file for now to get the functors. +#include +#include + +namespace CGAL { + +//----------------------------------------------------------------------- +// Vertex conflict +//----------------------------------------------------------------------- + +template < class K, class Method_tag > +class Uncertain_vertex_conflict_new_2 +{ +public: + typedef typename K::Site_2 Site_2; + typedef typename K::RT RT; + typedef Uncertain result_type; + +private: + + inline + Uncertain is_less (const Site_2 &p0, const Site_2 &p1) const + { + static const Uncertain uncertain_bool = + Uncertain::indeterminate(); + + Uncertain cr; + + cr = CGAL::compare( p0.weight(), p1.weight() ); + if ( is_indeterminate(cr) ) { return uncertain_bool; } + + if ( cr == SMALLER ) { return true; } + if ( cr == LARGER ) { return false; } + + cr = CGAL::compare(p0.x(), p1.x()); + if ( is_indeterminate(cr) ) { return uncertain_bool; } + + if ( cr == SMALLER ) { return true; } + if ( cr == LARGER ) { return false; } + + cr = CGAL::compare(p0.y(), p1.y()); + if ( is_indeterminate(cr) ) { return uncertain_bool; } + return cr == SMALLER; + } + + inline + int max_radius(const Site_2 &p0, const Site_2 &p1, + const Site_2 &p2, const Site_2 &p3) const + { + int i = 0; + const Site_2 *p = &p0; + + Uncertain b; + b = is_less (*p, p1); + if ( is_indeterminate(b) ) { + return -1; + } else if (b) { + i = 1; p = &p1; + } + + b = is_less(*p, p2); + if ( is_indeterminate(b) ) { + return -1; + } else if (b) { + i = 2; p = &p2; + } + + b = is_less(*p, p3); + if ( is_indeterminate(b) ) { + return -1; + } else if (b) { + i = 3; + } + + return i; + } + + inline + Uncertain + predicate(const Site_2 &p1, const Site_2 &p2, + const Site_2 &p3, const Site_2 &q, bool perturb) const + { + RT xq = q.x() - p1.x(); + RT yq = q.y() - p1.y(); + RT wq = q.weight() - p1.weight(); + RT aq = CGAL::square(xq) + CGAL::square(yq) - CGAL::square(wq); + + // q is hiding p1 + Uncertain s = CGAL::sign(aq); + if ( is_indeterminate(s) ) { return s; } + if (s != POSITIVE){ + // I BELIEVE MENELAOS RETURNS -1 in this case even when degernate + //if (sign (aq) == ZERO && ! perturb) return ZERO; + // return NEGATIVE; + return POSITIVE; + } + + RT x2 = p2.x() - p1.x(); + RT y2 = p2.y() - p1.y(); + RT w2 = p2.weight() - p1.weight(); + RT a2 = x2 * x2 + y2 * y2 - w2 * w2; + + CGAL_assertion (a2 > 0); + + RT x3 = p3.x() - p1.x(); + RT y3 = p3.y() - p1.y(); + RT w3 = p3.weight() - p1.weight(); + RT a3 = x3 * x3 + y3 * y3 - w3 * w3; + + CGAL_assertion (a3 > 0); + + RT ax3q = a3 * xq - x3 * aq; + RT ax2q = a2 * xq - x2 * aq; + RT ax23 = a2 * x3 - x2 * a3; + + RT ay23 = a2 * y3 - y2 * a3; + RT ay2q = a2 * yq - y2 * aq; + RT ay3q = a3 * yq - y3 * aq; + + RT axw23q = ax23 * wq - ax2q * w3 + ax3q * w2; + RT ayw23q = ay23 * wq - ay2q * w3 + ay3q * w2; + + RT axy23q = y2 * ax3q - y3 * ax2q + yq * ax23; + + // orientation + Uncertain orient = CGAL::sign(axy23q); + if ( is_indeterminate(orient) ) { return orient; } + + // orientation degenerate + if (orient == ZERO) { + Uncertain orient1 = CGAL::sign (ax23); + if ( is_indeterminate(orient1) ) { return orient1; } + + Sign power_test; + if ( orient1 == ZERO ) { + Uncertain s_ay23 = CGAL::sign(ay23); + if ( is_indeterminate(s_ay23) ) { return s_ay23; } + Uncertain s_ayw23q = CGAL::sign(ayw23q); + if ( is_indeterminate(s_ayw23q) ) { return s_ayw23q; } + + power_test = s_ay23 * s_ayw23q; + } else { + Uncertain s_axw23q = CGAL::sign(axw23q); + if ( is_indeterminate(s_axw23q) ) { return s_axw23q; } + + power_test = orient1 * s_axw23q; + } + + if (power_test != ZERO || ! perturb) { + return -power_test; + } + + int i = max_radius (p1, p2, p3, q); + if ( i == -1 ) { + return Uncertain::indeterminate(); + } + + if (i == 3) { return NEGATIVE; } + + Uncertain o23, o2q, o3q; + + if (orient1 == ZERO) { + o23 = CGAL::sign (ay23); + o2q = CGAL::sign (ay2q); + o3q = CGAL::sign (ay3q); + } else { + o23 = CGAL::sign (ax23); + o2q = CGAL::sign (ax2q); + o3q = CGAL::sign (ax3q); + } + if ( is_indeterminate(o23) || + is_indeterminate(o2q) || + is_indeterminate(o3q) ) { + return Uncertain::indeterminate(); + } + + if (o23 != o2q) { return i == 2 ? NEGATIVE : POSITIVE; } + + if (o23 == o3q) { return i == 1 ? NEGATIVE : POSITIVE; } + + return i == 0 ? NEGATIVE : POSITIVE; + } // if (orient == ZERO ) + + // radical side + RT rs23q = ax23 * axw23q + ay23 * ayw23q; + Uncertain radSide = CGAL::sign (rs23q); + if ( is_indeterminate(radSide) ) { return radSide; } + + if (radSide == ZERO || radSide != orient) { return orient; } + + // radical intersection + Uncertain radInt = + CGAL::sign(axw23q * axw23q + ayw23q * ayw23q - axy23q * axy23q); + if ( is_indeterminate(radInt) ) { return radInt; } + + // radical intersection degenerate + if (radInt == ZERO) { + Uncertain radSideQ = CGAL::sign(ax23 * axw23q + ay23 * ayw23q); + if ( is_indeterminate(radSideQ) ) { return radSideQ; } + + CGAL_assertion (radSideQ != ZERO); + + if (! perturb) { return (radSideQ == orient) ? Uncertain(ZERO) : orient; } + + int i = max_radius (p1, p2, p3, q); + if ( i == -1 ) { return Uncertain::indeterminate(); } + + if (i == 3) { + radInt = radSideQ; + } else if (i == 2) { + radInt = -CGAL::sign(ax2q * axw23q + ay2q * ayw23q); + if ( is_indeterminate(radInt) ) { return radInt; } + if (radInt == ZERO) { return NEGATIVE; } + } else if (i == 1) { + radInt = CGAL::sign(ax3q * axw23q + ay3q * ayw23q); + if ( is_indeterminate(radInt) ) { return radInt; } + if (radInt == ZERO) { return NEGATIVE; } + } else { + CGAL_assertion (i == 0); + Uncertain radSide1 = + -CGAL::sign(ax2q * axw23q + ay2q * ayw23q); + if ( is_indeterminate(radSide1) ) { return radSide1; } + + if (radSide1 == ZERO) { return NEGATIVE; } + + Uncertain radSide2 = CGAL::sign(ax3q * axw23q + ay3q * ayw23q); + if ( is_indeterminate(radSide2) ) { return radSide2; } + + if (radSide2 == ZERO) { return NEGATIVE; } + + radInt = -Sign( Sign(radSideQ) + Sign(radSide1) + Sign(radSide2) ); + } + } + + CGAL_assertion (!perturb || radInt != ZERO); + + if (radInt == NEGATIVE) { return orient; } + + return -radSide; + } + + + inline + Uncertain + predicate(const Site_2 &p1, const Site_2 &p2, + const Site_2 &q, bool perturb) const + { + // NOTE:*************************************** + // * the perturb boolean variable is not used + // * for consistancy with Menelaos + // NOTE:*************************************** + RT x2 = p2.x() - p1.x(); + RT y2 = p2.y() - p1.y(); + RT w2 = p2.weight() - p1.weight(); + RT xq = q.x() - p1.x(); + RT yq = q.y() - p1.y(); + RT wq = q.weight() - p1.weight(); + + RT xw2q = x2 * wq - xq * w2; + RT yw2q = y2 * wq - yq * w2; + RT xy2q = x2 * yq - xq * y2; + + // orientation + Uncertain orient = CGAL::sign(xy2q); + if ( is_indeterminate(orient) ) { return orient; } + + // orientation degenerate + if (orient == ZERO) { + Uncertain o12 = CGAL::sign(x2); + if ( is_indeterminate(o12) ) { return o12; } + + Uncertain o1q, o2q; + Uncertain power_test; + + if (o12 != ZERO) { + Uncertain s_xw2q = CGAL::sign(xw2q); + if ( is_indeterminate(s_xw2q) ) { return s_xw2q; } + power_test = o12 * s_xw2q; + + // this results is consistant with Menelaos + if (power_test != ZERO) { return -power_test; } + + // this result is consistant with the perturb on off idea + //if (power_test != ZERO || ! perturb) return -power_test; + + o1q = CGAL::sign(xq); + o2q = CGAL::sign(q.x() - p2.x()); + } else { + o12 = CGAL::sign(y2); + if ( is_indeterminate(o12) ) { return o12; } + Uncertain s_yw2q = CGAL::sign(yw2q); + if ( is_indeterminate(s_yw2q) ) { return s_yw2q; } + power_test = o12 * s_yw2q; + + // this results is consistant with Menelaos + if (power_test != ZERO) { return -power_test; } + + // this result is consistant with the perturb on off idea + //if (power_test != ZERO || ! perturb) return -power_test; + + o1q = CGAL::sign(yq); + o2q = CGAL::sign(q.y() - p2.y()); + } + + if ( is_indeterminate(o1q) || is_indeterminate(o2q) ) { + return Uncertain::indeterminate(); + } + + if (o1q != o12) { return POSITIVE; } + if (o2q == o12) { return POSITIVE; } + + return NEGATIVE; + } + + // radical side + RT rs12q = x2 * xw2q + y2 * yw2q; + Uncertain radSide = CGAL::sign(rs12q); + if ( is_indeterminate(radSide) ) { return radSide; } + + if (radSide == ZERO || radSide == orient) { + return -orient; + } + + // radical intersection + Uncertain radInt = + CGAL::sign(CGAL::square(xw2q) + CGAL::square(yw2q) + - CGAL::square(xy2q)); + if ( is_indeterminate(radInt) ) { return radInt; } + + // radical intersection degerate + if (radInt == ZERO) { + CGAL_assertion (radSide != ZERO); + + // this result is consistant with the perturb on off idea + //if (! perturb) return (radSide == orient) ? ZERO : orient; + + RT rs2q1 = (p2.x() - q.x()) * xw2q + (p2.y() - q.y()) * yw2q; + Uncertain radSide1 = CGAL::sign(rs2q1); + if ( is_indeterminate(radSide1) ) { return radSide1; } + if (radSide1 == ZERO) { return NEGATIVE; } + + RT rsq12 = xq * xw2q + yq * yw2q; + Uncertain radSide2 = CGAL::sign(rsq12); + if ( is_indeterminate(radSide2) ) { return radSide2; } + if (radSide2 == ZERO) { return NEGATIVE; } + + return -(radSide1 * radSide2); + } + + CGAL_assertion (!perturb || radInt != ZERO); + + if (radInt == POSITIVE) { return orient; } + return radSide; + } + +public: + inline + Uncertain operator()(const Site_2 &p1, const Site_2 &p2, + const Site_2 &p3, const Site_2 &q, + bool perturb = true) const + { + Uncertain newPred = predicate (p1, p2, p3, q, perturb); + if ( is_indeterminate(newPred) ) { return newPred; } + CGAL_assertion (! perturb || newPred != ZERO); + return newPred; + } + + inline + Uncertain operator()(const Site_2 &p1, const Site_2 &p2, + const Site_2 &q, bool perturb = true) const + { + Uncertain newPred = predicate (p1, p2, q, perturb); + if ( is_indeterminate(newPred) ) { return newPred; } + CGAL_assertion (! perturb || newPred != ZERO); + return newPred; + } +}; + + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_2_UNCERTAIN_VERTEX_CONFLICT_2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/uncertain/uncertain_functions_on_signs.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/uncertain/uncertain_functions_on_signs.h new file mode 100644 index 00000000000..5ae3dffa565 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_2/uncertain/uncertain_functions_on_signs.h @@ -0,0 +1,144 @@ +// Copyright (c) 2003 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_UNCERTAIN_FUNCTIONS_ON_SIGNS_H +#define CGAL_UNCERTAIN_FUNCTIONS_ON_SIGNS_H + +#include + + +#include +#include + +namespace CGAL { + +template < class RT > +Uncertain +uncertain_sign_a_plus_b_x_sqrt_c(const RT &a, const RT &b, const RT &c) +{ + // computes the sign of quantity: a + b * sqrt(c) + + CGAL_assertion( !(CGAL::is_negative(c)) ); + + Uncertain sa = CGAL::sign(a); + if ( is_indeterminate(sa) ) { + return Uncertain::indeterminate(); + } + + Uncertain sc = CGAL::sign(c); + if ( is_indeterminate(sc) ) { + return Uncertain::indeterminate(); + } + if ( sc == ZERO ) return sa; + + Uncertain sb = CGAL::sign(b); + if ( is_indeterminate(sb) ) { + return Uncertain::indeterminate(); + } + if ( sa == sb ) return sa; + if ( sa == ZERO ) return sb; + + Uncertain cr = + CGAL::compare( CGAL::square(a), c * CGAL::square(b) ); + if ( is_indeterminate(cr) ) { + return Uncertain::indeterminate(); + } + + return sa * cr; +} + +#if 0 +template < class RT > +Sign +sign_a_x_sqrt_c_plus_b_x_sqrt_d(const RT &a, const RT &b, + const RT &c, const RT &d) +{ + // computes the sign of quantity: a * sqrt(c) + b * sqrt(d) + + CGAL_assertion( !(CGAL::is_negative(c)) ); + CGAL_assertion( !(CGAL::is_negative(d)) ); + + Sign sb = CGAL::sign(b); + if ( CGAL::sign(d) == ZERO ) return CGAL::sign(a * c); + if ( CGAL::sign(c) == ZERO ) return sb; + + Sign sa = CGAL::sign(a); + if ( sa == sb ) return sa; + if ( sa == ZERO ) return sb; + + return sa * CGAL::compare( CGAL::square(a) * c, + CGAL::square(b) * d ); +} + +template < class RT > +Sign +sign_a_plus_b_x_sqrt_e_plus_c_x_sqrt_f(const RT &a, const RT &b, + const RT &c, const RT &e, + const RT &f) +{ + // computes the sign of quantity: a + b * sqrt(e) + c * sqrt(f) + + CGAL_assertion( !(CGAL::is_negative(e)) ); + CGAL_assertion( !(CGAL::is_negative(f)) ); + + Sign s_a_plus_b_x_sqrt_e = sign_a_plus_b_x_sqrt_c(a, b, e); + if ( CGAL::sign(f) == ZERO ) return s_a_plus_b_x_sqrt_e; + + Sign sc = CGAL::sign(c); + if ( s_a_plus_b_x_sqrt_e == sc ) return sc; + if ( s_a_plus_b_x_sqrt_e == ZERO ) return sc; + + return s_a_plus_b_x_sqrt_e * + sign_a_plus_b_x_sqrt_c(CGAL::square(a) + CGAL::square(b) * e + - CGAL::square(c) * f, + RT(2) * a * b, e); +} + +template < class RT > +Sign +sign_a_plus_b_x_sqrt_e_plus_c_x_sqrt_f_plus_d_sqrt_e_x_f(const RT &a, + const RT &b, + const RT &c, + const RT &d, + const RT &e, + const RT &f) +{ + // computes the sign of quantity: + // a + b * sqrt(e) + c * sqrt(f) + d * sqrt(e * f) + + CGAL_assertion( !(CGAL::is_negative(e)) ); + CGAL_assertion( !(CGAL::is_negative(f)) ); + + Sign s_a_plus_b_sqrt_e = sign_a_plus_b_x_sqrt_c(a, b, e); + Sign s_c_plus_d_sqrt_e = sign_a_plus_b_x_sqrt_c(c, d, e); + + if ( s_a_plus_b_sqrt_e == s_c_plus_d_sqrt_e ) + return s_a_plus_b_sqrt_e; + + if ( s_a_plus_b_sqrt_e == ZERO ) + return s_a_plus_b_sqrt_e; + + return s_a_plus_b_sqrt_e * + sign_a_plus_b_x_sqrt_c(CGAL::square(a) + CGAL::square(b) * e + - CGAL::square(c) * f + - CGAL::square(d) * e * f, + RT(2) * (a * b - c * d * f), + e); +} +#endif + +} //namespace CGAL + + +#endif // CGAL_UNCERTAIN_FUNCTIONS_ON_SIGNS_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_data_structure_2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_data_structure_2.h new file mode 100644 index 00000000000..60e0ba57ada --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_data_structure_2.h @@ -0,0 +1,36 @@ +// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_DATA_STRUCTURE_2_H +#define CGAL_APOLLONIUS_GRAPH_DATA_STRUCTURE_2_H + +#include + + +#include + + +namespace CGAL { + +// For backward compatibility + +template +class Apollonius_graph_data_structure_2 + : public Triangulation_data_structure_2 +{}; + + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_DATA_STRUCTURE_2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_filtered_traits_2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_filtered_traits_2.h new file mode 100644 index 00000000000..bbb169fbff7 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_filtered_traits_2.h @@ -0,0 +1,409 @@ +// Copyright (c) 2003,2004,2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_APOLLONIUS_GRAPH_FILTERED_TRAITS_2_H +#define CGAL_APOLLONIUS_GRAPH_FILTERED_TRAITS_2_H + +#include + + + +#include + +#include +#include + +// includes for the default parameters of the filtered traits +#include +#include +#include +#include +#include + +namespace CGAL { + + +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// the filtered Traits class +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- + +template, + class EK_MTag = CK_MTag, + class FK_t = Simple_cartesian< Interval_nt >, + class FK_MTag = CK_MTag, + class C2E_t = Cartesian_converter, + class C2F_t = + Cartesian_converter > > +class Apollonius_graph_filtered_traits_2 +{ +private: + typedef Apollonius_graph_traits_2 CK_traits; + typedef Apollonius_graph_traits_2 FK_traits; + typedef Apollonius_graph_traits_2 EK_traits; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Apollonius_graph_kernel_wrapper_2 CK; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Apollonius_graph_kernel_wrapper_2 FK; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Apollonius_graph_kernel_wrapper_2 EK; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS:: + Apollonius_graph_cartesian_converter C2E; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS:: + Apollonius_graph_cartesian_converter C2F; + +#if 0 + // the following typedefs have been made in the direction of + // providing filtered constructions; however, there is a problem, + // namely, the Construct_Apollonius_site_2 functor has two + // different operator()'s with two different return types; this + // functor should be split in two (along with the appropriate + // changes in the spec/concept); see also changes needed for the + // filtered construction below. + typedef Cartesian_converter > F2C_t; + typedef Cartesian_converter > E2C_t; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS:: + Apollonius_graph_cartesian_converter F2C; + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS:: + Apollonius_graph_cartesian_converter E2C; +#endif + + // Types for the construction kernel + typedef typename CK::Point_2 CK_Point_2; + typedef typename CK::Site_2 CK_Site_2; + + typedef typename CK::Line_2 CK_Line_2; + typedef typename CK::Ray_2 CK_Ray_2; + typedef typename CK::Segment_2 CK_Segment_2; + + typedef typename CK::FT CK_FT; + typedef typename CK::RT CK_RT; + + // Types for the exact kernel + typedef typename EK::Point_2 EK_Point_2; + typedef typename EK::Site_2 EK_Site_2; + + typedef typename EK::Line_2 EK_Line_2; + typedef typename EK::Ray_2 EK_Ray_2; + typedef typename EK::Segment_2 EK_Segment_2; + + typedef typename EK::FT EK_FT; + typedef typename EK::RT EK_RT; + + // Types for the filtering kernel + typedef typename FK::Point_2 FK_Point_2; + typedef typename FK::Site_2 FK_Site_2; + + typedef typename FK::Line_2 FK_Line_2; + typedef typename FK::Ray_2 FK_Ray_2; + typedef typename FK::Segment_2 FK_Segment_2; + + typedef typename FK::FT FK_FT; + typedef typename FK::RT FK_RT; + +public: + //----------------------------------------------------------------------- + // TYPE DEFINITIONS + //----------------------------------------------------------------------- + + // BASIC TYPES + //------------ + typedef CK_t R; + typedef CK_MTag Method_tag; + + typedef CK_traits Construction_traits; + typedef FK_traits Filtering_traits; + typedef EK_traits Exact_traits; + + typedef CK_MTag Construction_traits_method_tag; + typedef FK_MTag Filtering_traits_method_tag; + typedef EK_MTag Exact_traits_method_tag; + + typedef typename CK::Point_2 Point_2; + typedef typename CK::Site_2 Site_2; + + typedef typename CK::Line_2 Line_2; + typedef typename CK::Ray_2 Ray_2; + typedef typename CK::Segment_2 Segment_2; + + typedef typename CK::Object_2 Object_2; + typedef typename CK::FT FT; + typedef typename CK::RT RT; + + +public: + // OBJECT CONSTRUCTION & ASSIGNMENT + //--------------------------------- + typedef typename CK_traits::Construct_object_2 Construct_object_2; + typedef typename CK_traits::Assign_2 Assign_2; + typedef typename CK_traits::Construct_point_2 Construct_point_2; + + // CONSTRUCTIONS + //-------------- + // vertex and dual site +protected: + typedef typename CK_traits::Construct_Apollonius_vertex_2 + CK_Construct_Apollonius_vertex_2; + + typedef typename CK_traits::Construct_Apollonius_site_2 + CK_Construct_Apollonius_site_2; + + typedef typename FK_traits::Construct_Apollonius_vertex_2 + FK_Construct_Apollonius_vertex_2; + + typedef typename FK_traits::Construct_Apollonius_site_2 + FK_Construct_Apollonius_site_2; + + typedef typename EK_traits::Construct_Apollonius_vertex_2 + EK_Construct_Apollonius_vertex_2; + + typedef typename EK_traits::Construct_Apollonius_site_2 + EK_Construct_Apollonius_site_2; + +public: +#if 0 + // the following typedefs have been made in the direction of + // providing filtered constructions; however, there is a problem, + // namely, the Construct_Apollonius_site_2 functor has two + // different operator()'s with two different return types; this + // functor should be split in two (along with the appropriate + // changes in the spec/concept); see also changes needed for the + // filtered construction above. + typedef Filtered_construction + Construct_Apollonius_vertex_2; + + typedef Filtered_construction + Construct_Apollonius_site_2; +#else + typedef typename CK_traits::Construct_Apollonius_vertex_2 + Construct_Apollonius_vertex_2; + + typedef typename CK_traits::Construct_Apollonius_site_2 + Construct_Apollonius_site_2; +#endif + +private: + // PREDICATES FOR THE TWO KERNELS + //------------------------------- + + // Predicates for the filtering kernel + typedef typename FK_traits::Compare_x_2 FK_Compare_x_2; + typedef typename FK_traits::Compare_y_2 FK_Compare_y_2; + typedef typename FK_traits::Compare_weight_2 FK_Compare_weight_2; + typedef typename FK_traits::Orientation_2 FK_Orientation_2; + typedef typename FK_traits::Is_hidden_2 FK_Is_hidden_2; + + typedef typename FK_traits::Oriented_side_of_bisector_2 + FK_Oriented_side_of_bisector_2; + + typedef typename FK_traits::Vertex_conflict_2 FK_Vertex_conflict_2; + + typedef typename FK_traits::Finite_edge_interior_conflict_2 + FK_Finite_edge_interior_conflict_2; + + typedef typename FK_traits::Infinite_edge_interior_conflict_2 + FK_Infinite_edge_interior_conflict_2; + + typedef typename FK_traits::Is_degenerate_edge_2 + FK_Is_degenerate_edge_2; + + + // Predicates for the exact kernel + typedef typename EK_traits::Compare_x_2 EK_Compare_x_2; + typedef typename EK_traits::Compare_y_2 EK_Compare_y_2; + typedef typename EK_traits::Compare_weight_2 EK_Compare_weight_2; + typedef typename EK_traits::Orientation_2 EK_Orientation_2; + typedef typename EK_traits::Is_hidden_2 EK_Is_hidden_2; + + typedef typename EK_traits::Oriented_side_of_bisector_2 + EK_Oriented_side_of_bisector_2; + + typedef typename EK_traits::Vertex_conflict_2 EK_Vertex_conflict_2; + + typedef typename EK_traits::Finite_edge_interior_conflict_2 + EK_Finite_edge_interior_conflict_2; + + typedef typename EK_traits::Infinite_edge_interior_conflict_2 + EK_Infinite_edge_interior_conflict_2; + + typedef typename EK_traits::Is_degenerate_edge_2 + EK_Is_degenerate_edge_2; + +public: + // PREDICATES + //----------- + + typedef + Filtered_predicate + Compare_x_2; + + typedef + Filtered_predicate + Compare_y_2; + + typedef + Filtered_predicate + Compare_weight_2; + + typedef + Filtered_predicate + Orientation_2; + + + typedef + Filtered_predicate + Is_hidden_2; + + typedef + Filtered_predicate + Oriented_side_of_bisector_2; + + typedef + Filtered_predicate + Vertex_conflict_2; + + typedef + Filtered_predicate + Finite_edge_interior_conflict_2; + + typedef + Filtered_predicate + Infinite_edge_interior_conflict_2; + + typedef + Filtered_predicate + Is_degenerate_edge_2; + +public: + //----------------------------------------------------------------------- + // ACCESS TO OBJECTS + //----------------------------------------------------------------------- + + // OBJECT CONSTRUCTION & ASSIGNMENT + Assign_2 + assign_2_object() const { + return Assign_2(); + } + + Construct_object_2 + construct_object_2_object() const { + return Construct_object_2(); + } + + Construct_point_2 + construct_point_2_object() const { + return Construct_point_2(); + } + + // CONSTRUCTIONS + //-------------- + Construct_Apollonius_vertex_2 + construct_Apollonius_vertex_2_object() const { + return Construct_Apollonius_vertex_2(); + } + + Construct_Apollonius_site_2 + construct_Apollonius_site_2_object() const { + return Construct_Apollonius_site_2(); + } + + // PREDICATES + //----------- + Compare_x_2 + compare_x_2_object() const { + return Compare_x_2(); + } + + Compare_y_2 + compare_y_2_object() const { + return Compare_y_2(); + } + + Compare_weight_2 + compare_weight_2_object() const { + return Compare_weight_2(); + } + + Orientation_2 + orientation_2_object() const { + return Orientation_2(); + } + + Is_hidden_2 + is_hidden_2_object() const { + return Is_hidden_2(); + } + + Oriented_side_of_bisector_2 + oriented_side_of_bisector_2_object() const { + return Oriented_side_of_bisector_2(); + } + + Vertex_conflict_2 + vertex_conflict_2_object() const { + return Vertex_conflict_2(); + } + + Finite_edge_interior_conflict_2 + finite_edge_interior_conflict_2_object() const { + return Finite_edge_interior_conflict_2(); + } + + Infinite_edge_interior_conflict_2 + infinite_edge_interior_conflict_2_object() const { + return Infinite_edge_interior_conflict_2(); + } + + Is_degenerate_edge_2 + is_degenerate_edge_2_object() const { + return Is_degenerate_edge_2(); + } + +}; + + + +} //namespace CGAL + + +#endif // CGAL_APOLLONIUS_GRAPH_FILTERED_TRAITS_2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_hierarchy_2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_hierarchy_2.h new file mode 100644 index 00000000000..83ea0290baa --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_hierarchy_2.h @@ -0,0 +1,359 @@ +// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + +#ifndef CGAL_APOLLONIUS_GRAPH_HIERARCHY_2_H +#define CGAL_APOLLONIUS_GRAPH_HIERARCHY_2_H + +#include + + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +namespace CGAL { + + +// parameterization of the hierarchy +const unsigned int ag_hierarchy_2__ratio = 30; +const unsigned int ag_hierarchy_2__minsize = 20; +const unsigned int ag_hierarchy_2__maxlevel = 5; +// maximal number of points is 30^5 = 24 millions ! + +template < class Gt, + class Agds = Triangulation_data_structure_2< + Apollonius_graph_hierarchy_vertex_base_2< + Apollonius_graph_vertex_base_2 >, + Triangulation_face_base_2 >, + class LTag = Tag_false > +class Apollonius_graph_hierarchy_2 + : public Apollonius_graph_2< Gt, Agds, LTag > +{ +private: + typedef Apollonius_graph_2 Apollonius_graph_base; + typedef Apollonius_graph_base Ag_base; + +public: + typedef Gt Geom_traits; + typedef typename Gt::Site_2 Site_2; + typedef typename Gt::Point_2 Point_2; + + typedef typename Ag_base::Vertex_handle Vertex_handle; + typedef typename Ag_base::Face_handle Face_handle; + typedef typename Ag_base::Edge Edge; + + typedef typename Ag_base::Face_circulator Face_circulator; + typedef typename Ag_base::Edge_circulator Edge_circulator; + typedef typename Ag_base::Vertex_circulator Vertex_circulator; + + typedef typename Ag_base::All_faces_iterator All_faces_iterator; + typedef typename Ag_base::Finite_faces_iterator Finite_faces_iterator; + + typedef typename Ag_base::All_vertices_iterator All_vertices_iterator; + typedef typename Ag_base::Finite_vertices_iterator + Finite_vertices_iterator; + + typedef typename Ag_base::All_edges_iterator All_edges_iterator; + typedef typename Ag_base::Finite_edges_iterator Finite_edges_iterator; + + typedef typename Ag_base::Sites_iterator Sites_iterator; + typedef typename Ag_base::Visible_sites_iterator Visible_sites_iterator; + typedef typename Ag_base::Hidden_sites_iterator Hidden_sites_iterator; + + typedef typename Ag_base::size_type size_type; + + using Ag_base::insert_first; + using Ag_base::insert_second; + using Ag_base::insert_third; + using Ag_base::is_hidden; + using Ag_base::incircle; + using Ag_base::edge_interior; + using Ag_base::insert_degree_2; + using Ag_base::initialize_conflict_region; + using Ag_base::expand_conflict_region; + using Ag_base::retriangulate_conflict_region; + using Ag_base::is_infinite; + +public: + // CREATION + //--------- + Apollonius_graph_hierarchy_2 + (const Geom_traits& gt = Geom_traits()); + + template + Apollonius_graph_hierarchy_2(Input_iterator first, + Input_iterator beyond, + const Geom_traits& gt = Geom_traits()) + : Apollonius_graph_base(gt) + { + init_hierarchy(gt); + insert(first, beyond); + } + + Apollonius_graph_hierarchy_2 + (const Apollonius_graph_hierarchy_2& agh); + + Apollonius_graph_hierarchy_2& + operator=(const Apollonius_graph_hierarchy_2& agh); + + ~Apollonius_graph_hierarchy_2(); + +protected: + // used to initialize the hierarchy at construction time + void init_hierarchy(const Geom_traits& gt); + +public: + // INSERTION + //---------- + template < class Input_iterator > + size_type insert(Input_iterator first, Input_iterator beyond) + { + // copy the sites to a local container + typename Apollonius_graph_base::Site_list wp_list; + // Site_list wp_list; + for (Input_iterator it = first; it != beyond; ++it) { + wp_list.push_back(*it); + } + + // sort by decreasing weight + typename Apollonius_graph_base::Site_less_than_comparator + less_than(this->geom_traits()); + std::sort(wp_list.begin(), wp_list.end(), less_than); + + // now insert + typename Apollonius_graph_base::Site_list_iterator lit; + for (lit = wp_list.begin(); lit != wp_list.end(); ++lit) { + insert(*lit); + } + + + // store how many sites where in the range + std::size_t num = wp_list.size(); + + // clear the local container + wp_list.clear(); + + // return the number of sites in range + return num; + } + + Vertex_handle insert(const Site_2& p); + Vertex_handle insert(const Site_2& p, + Vertex_handle vnear) { + // the following statement has been added in order to avoid + // a g++3.2.1_FreeBSD-RELEASE warning + vnear = Vertex_handle(); + return insert(p); + } + +public: + // REMOVAL + //-------- + void remove(Vertex_handle v); + +public: + // NEAREST NEIGHBOR LOCATION + //-------------------------- +public: + Vertex_handle nearest_neighbor(const Point_2& p) const; + inline Vertex_handle nearest_neighbor(const Point_2& p, + Vertex_handle /* vnear */) const { + return nearest_neighbor(p); + } + +public: + // VALIDITY CHECK + //--------------- + bool is_valid(bool verbose = false, int level = 1) const; + +public: + // MISCELLANEOUS + //-------------- + void clear(); + void swap(Apollonius_graph_hierarchy_2& agh); + + // I/O + //---- + void file_input(std::istream& is); + void file_output(std::ostream& os) const; + +private: + // private methods + void + nearest_neighbor(const Point_2& p, + Vertex_handle vnear[ag_hierarchy_2__maxlevel]) const; + + int random_level(); + + void copy(const Apollonius_graph_hierarchy_2 &agh); + +private: + // class variables + // here is the stack of graphs which form the hierarchy + Apollonius_graph_base* hierarchy[ag_hierarchy_2__maxlevel]; + boost::rand48 random; // random generator + +public: + template + boost::tuples::tuple + get_conflicts_and_boundary_and_hidden_vertices(const Site_2& p, + OutputItFaces fit, + OutputItBoundaryEdges eit, + OutputItHiddenVertices vit, + Vertex_handle start = + Vertex_handle()) const + { + Vertex_handle vnearest = nearest_neighbor(p.point(), start); + return this->get_all(p, fit, eit, vit, vnearest, false); + } + + template + std::pair + get_conflicts_and_boundary(const Site_2& p, + OutputItFaces fit, + OutputItBoundaryEdges eit, + Vertex_handle start = + Vertex_handle()) const { + boost::tuples::tuple + tup = + get_conflicts_and_boundary_and_hidden_vertices(p, + fit, + eit, + Emptyset_iterator(), + start); + return std::make_pair( boost::tuples::get<0>(tup), + boost::tuples::get<1>(tup) ); + } + + + template + std::pair + get_boundary_of_conflicts_and_hidden_vertices(const Site_2& p, + OutputItBoundaryEdges eit, + OutputItHiddenVertices vit, + Vertex_handle start = + Vertex_handle()) const { + boost::tuples::tuple + tup = + get_conflicts_and_boundary_and_hidden_vertices(p, + Emptyset_iterator(), + eit, + vit, + start); + return std::make_pair( boost::tuples::get<1>(tup), + boost::tuples::get<2>(tup) ); + } + + + template + std::pair + get_conflicts_and_hidden_vertices(const Site_2& p, + OutputItFaces fit, + OutputItHiddenVertices vit, + Vertex_handle start = + Vertex_handle()) const { + boost::tuples::tuple + tup = + get_conflicts_and_boundary_and_hidden_vertices(p, + fit, + Emptyset_iterator(), + vit, + start); + return std::make_pair( boost::tuples::get<0>(tup), + boost::tuples::get<2>(tup) ); + } + + template + OutputItFaces get_conflicts(const Site_2& p, + OutputItFaces fit, + Vertex_handle start = Vertex_handle()) const { + boost::tuples::tuple + tup = + get_conflicts_and_boundary_and_hidden_vertices(p, + fit, + Emptyset_iterator(), + Emptyset_iterator(), + start); + return boost::tuples::get<0>(tup); + } + + template + OutputItBoundaryEdges + get_boundary_of_conflicts(const Site_2& p, + OutputItBoundaryEdges eit, + Vertex_handle start = Vertex_handle()) const { + boost::tuples::tuple + tup = + get_conflicts_and_boundary_and_hidden_vertices(p, + Emptyset_iterator(), + eit, + Emptyset_iterator(), + start); + return boost::tuples::get<1>(tup); + } + + template + OutputItHiddenVertices + get_hidden_vertices(const Site_2& p, + OutputItHiddenVertices vit, + Vertex_handle start = Vertex_handle()) const { + boost::tuples::tuple + tup = + get_conflicts_and_boundary_and_hidden_vertices(p, + Emptyset_iterator(), + Emptyset_iterator(), + vit, + start); + return boost::tuples::get<2>(tup); + } +}; + + +template +std::ostream& operator<<(std::ostream& os, + const Apollonius_graph_hierarchy_2& agh) +{ + agh.file_output(os); + return os; +} + +template +std::istream& operator>>(std::istream& is, + Apollonius_graph_hierarchy_2& agh) +{ + agh.file_input(is); + return is; +} + +} //namespace CGAL + + +#include + + +#endif // CGAL_APOLLONIUS_GRAPH_HIERARCHY_2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_hierarchy_vertex_base_2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_hierarchy_vertex_base_2.h new file mode 100644 index 00000000000..c2848c94c4b --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_hierarchy_vertex_base_2.h @@ -0,0 +1,66 @@ +// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + +#ifndef CGAL_APOLLONIUS_GRAPH_HIERARCHY_VERTEX_BASE_2_H +#define CGAL_APOLLONIUS_GRAPH_HIERARCHY_VERTEX_BASE_2_H + +#include + + +#include + +namespace CGAL { + +template < class Vbb > +class Apollonius_graph_hierarchy_vertex_base_2 + : public Vbb +{ + typedef Vbb Base; + typedef typename Base::Apollonius_graph_data_structure_2 Agds; + +public: + typedef typename Base::Site_2 Site_2; + typedef Agds Apollonius_graph_data_structure_2; + typedef typename Agds::Vertex_handle Vertex_handle; + typedef typename Agds::Face_handle Face_handle; + + template < typename AGDS2 > + struct Rebind_TDS { + typedef typename Vbb::template Rebind_TDS::Other Vb2; + typedef Apollonius_graph_hierarchy_vertex_base_2 Other; + }; + + Apollonius_graph_hierarchy_vertex_base_2() + : Base(), _up(), _down() + {} + Apollonius_graph_hierarchy_vertex_base_2(const Site_2& p, + Face_handle f) + : Base(p,f), _up(), _down() + {} + Apollonius_graph_hierarchy_vertex_base_2(const Site_2& p) + : Base(p), _up(), _down() + {} + + Vertex_handle up() {return _up;} + Vertex_handle down() {return _down;} + void set_up(Vertex_handle u) {_up=u;} + void set_down(Vertex_handle d) {_down=d;} + + + private: + Vertex_handle _up; // same vertex one level above + Vertex_handle _down; // same vertex one level below +}; + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_HIERARCHY_VERTEX_BASE_2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_traits_2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_traits_2.h new file mode 100644 index 00000000000..e5a9eb31f6d --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_traits_2.h @@ -0,0 +1,221 @@ +// Copyright (c) 2003,2004,2006 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + +#ifndef CGAL_APOLLONIUS_GRAPH_TRAITS_2_H +#define CGAL_APOLLONIUS_GRAPH_TRAITS_2_H + +#include + + +#include +#include +#include +#ifdef CGAL_APOLLONIUS_GRAPH_D8_TRAITS_2 +#include +#include +#endif + +#include +#include + +namespace CGAL { + +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// the Traits class +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +template < class Rep, class MTag = Integral_domain_without_division_tag > +class Apollonius_graph_traits_2 +{ +public: + //----------------------------------------------------------------------- + // TYPE DEFINITIONS + //----------------------------------------------------------------------- + + // BASIC TYPES + //------------ +private: + typedef Apollonius_graph_traits_2 Self; + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Apollonius_graph_kernel_wrapper_2 Kernel; + +public: + typedef Rep R; + typedef MTag Method_tag; + typedef typename Kernel::Point_2 Point_2; + typedef typename Kernel::Site_2 Site_2; + + typedef typename Kernel::Line_2 Line_2; + typedef typename Kernel::Ray_2 Ray_2; + typedef typename Rep::Segment_2 Segment_2; + + typedef typename Kernel::Object_2 Object_2; + typedef typename Kernel::FT FT; + typedef typename Kernel::RT RT; + +public: + // OBJECT CONSTRUCTION & ASSIGNMENT + //--------------------------------- + typedef typename Kernel::Construct_object_2 Construct_object_2; + typedef typename Kernel::Assign_2 Assign_2; + + // CONSTRUCTIONS + //-------------- + typedef typename Kernel::Construct_point_2 Construct_point_2; + + // vertex and dual site + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Construct_Apollonius_vertex_2 + /* */ Construct_Apollonius_vertex_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Construct_Apollonius_site_2 + /* */ Construct_Apollonius_site_2; + + + // PREDICATES + //----------- + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Compare_x_2 Compare_x_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Compare_y_2 Compare_y_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Compare_weight_2 + Compare_weight_2; + +#ifdef CGAL_APOLLONIUS_GRAPH_D8_TRAITS_2 + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Orientation8_C2 + Orientation_2; +#else + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Orientation_2 + Orientation_2; +#endif + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Is_hidden_2 Is_hidden_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Oriented_side_of_bisector_2 + /* */ Oriented_side_of_bisector_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Vertex_conflict8_2 + /* */ Vertex_conflict_2; + +#ifdef CGAL_APOLLONIUS_GRAPH_D8_TRAITS_2 + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Finite_edge_interior_conflict8_2 + /* */ Finite_edge_interior_conflict_2; +#else + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Finite_edge_interior_conflict_2 + /* */ Finite_edge_interior_conflict_2; +#endif + + typedef + CGAL_APOLLONIUS_GRAPH_2_NS::Infinite_edge_interior_conflict_2 + /* */ Infinite_edge_interior_conflict_2; + + typedef CGAL_APOLLONIUS_GRAPH_2_NS::Is_degenerate_edge_2 + /* */ Is_degenerate_edge_2; + + +public: + //----------------------------------------------------------------------- + // ACCESS TO OBJECTS + //----------------------------------------------------------------------- + + // OBJECT CONSTRUCTION & ASSIGNMENT + Assign_2 + assign_2_object() const { + return Assign_2(); + } + + Construct_object_2 + construct_object_2_object() const { + return Construct_object_2(); + } + + Construct_point_2 + construct_point_2_object() const { + return Construct_point_2(); + } + + // CONSTRUCTIONS + //-------------- + Construct_Apollonius_vertex_2 + construct_Apollonius_vertex_2_object() const { + return Construct_Apollonius_vertex_2(); + } + + Construct_Apollonius_site_2 + construct_Apollonius_site_2_object() const { + return Construct_Apollonius_site_2(); + } + + + // PREDICATES + //----------- + Compare_x_2 + compare_x_2_object() const { + return Compare_x_2(); + } + + Compare_y_2 + compare_y_2_object() const { + return Compare_y_2(); + } + + Compare_weight_2 + compare_weight_2_object() const { + return Compare_weight_2(); + } + + Orientation_2 + orientation_2_object() const { + return Orientation_2(); + } + + Is_hidden_2 + is_hidden_2_object() const { + return Is_hidden_2(); + } + + Oriented_side_of_bisector_2 + oriented_side_of_bisector_2_object() const { + return Oriented_side_of_bisector_2(); + } + + Vertex_conflict_2 + vertex_conflict_2_object() const { + return Vertex_conflict_2(); + } + + Finite_edge_interior_conflict_2 + finite_edge_interior_conflict_2_object() const { + return Finite_edge_interior_conflict_2(); + } + + Infinite_edge_interior_conflict_2 + infinite_edge_interior_conflict_2_object() const { + return Infinite_edge_interior_conflict_2(); + } + + Is_degenerate_edge_2 + is_degenerate_edge_2_object() const { + return Is_degenerate_edge_2(); + } + +}; + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_TRAITS_2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_graph_vertex_base_2.h b/Apollonius_graph_2/include/CGAL/Apollonius_graph_vertex_base_2.h new file mode 100644 index 00000000000..c16c2f1903f --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_graph_vertex_base_2.h @@ -0,0 +1,150 @@ +// Copyright (c) 2003 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + +#ifndef CGAL_APOLLONIUS_GRAPH_VERTEX_BASE_2_H +#define CGAL_APOLLONIUS_GRAPH_VERTEX_BASE_2_H + +#include + + +#include + +#include +#include + +namespace CGAL { + +template +struct Apollonius_graph_vertex_base_nested_iterator_traits +{ + typedef AGVB2_Iterator Base_iterator; + typedef typename + Base_iterator::value_type::Hidden_sites_iterator Iterator; + + Iterator begin(Base_iterator it) const + { + return it->hidden_sites_begin(); + } + + Iterator end(Base_iterator it) const + { + return it->hidden_sites_end(); + } + +}; + + + +template > +class Apollonius_graph_vertex_base_2 + : public Vb +{ +private: + typedef typename Vb::Triangulation_data_structure AGDS; +public: + // TYPES + //------ + typedef Gt Geom_traits; + typedef Vb Base; + typedef typename Gt::Point_2 Point; + typedef typename Gt::Site_2 Site_2; + typedef AGDS Apollonius_graph_data_structure_2; + typedef typename AGDS::Face_handle Face_handle; + typedef typename AGDS::Vertex_handle Vertex_handle; + + enum {Store_hidden = StoreHidden}; + + template < typename AGDS2 > + struct Rebind_TDS { + typedef typename Vb::template Rebind_TDS::Other Vb2; + typedef Apollonius_graph_vertex_base_2 Other; + }; + + +private: + // local types + typedef std::list Container; + +public: + // TYPES (continued) + //------------------ + // typedef Container Hidden_sites_container; + typedef typename Container::iterator Hidden_sites_iterator; + +public: + // CREATION + //--------- + Apollonius_graph_vertex_base_2() : Vb() {} + Apollonius_graph_vertex_base_2(const Site_2& p) : Vb(), _p(p) {} + Apollonius_graph_vertex_base_2(const Site_2& p, Face_handle f) + : Vb(f), _p(p) {} + + ~Apollonius_graph_vertex_base_2() + { + clear_hidden_sites_container(); + } + + + // ACCESS METHODS + //--------------- + const Site_2& site() const { return _p; } + Site_2& site() { return _p; } + + Face_handle face() const { return Vb::face(); } + + std::size_t number_of_hidden_sites() const { + return hidden_site_list.size(); + } + + Hidden_sites_iterator hidden_sites_begin() { + return hidden_site_list.begin(); + } + + Hidden_sites_iterator hidden_sites_end() { + return hidden_site_list.end(); + } + +public: + // SETTING AND UNSETTING + //---------------------- + void set_site(const Site_2& p) { _p = p; } + + + void add_hidden_site(const Site_2& p) + { + if ( StoreHidden ) { + hidden_site_list.push_back(p); + } + } + + void clear_hidden_sites_container() + { + hidden_site_list.clear(); + } + +public: + // VALIDITY CHECK + bool is_valid(bool verbose = false, int level = 0) const { + return Vb::is_valid(verbose, level); + } + +private: + // class variables + Container hidden_site_list; + Site_2 _p; +}; + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_GRAPH_VERTEX_BASE_2_H diff --git a/Apollonius_graph_2/include/CGAL/Apollonius_site_2.h b/Apollonius_graph_2/include/CGAL/Apollonius_site_2.h new file mode 100644 index 00000000000..abb7cbf272a --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Apollonius_site_2.h @@ -0,0 +1,81 @@ +// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + +#ifndef CGAL_APOLLONIUS_SITE_2_H +#define CGAL_APOLLONIUS_SITE_2_H + +#include + + +#include +#include + +namespace CGAL { + + +template < class K > +class Apollonius_site_2 +{ +public: + typedef K Kernel; + typedef typename K::Point_2 Point_2; + typedef Apollonius_site_2 Self; + typedef typename K::FT Weight; + typedef typename K::RT RT; + typedef Weight FT; + + +public: + Apollonius_site_2(const Point_2& p = Point_2(), + const Weight& w = Weight(0)) + : _p(p), _w(w) {} + + const Point_2& point() const { return _p; } + const Weight& weight() const { return _w; } + RT x() const { return _p.x(); } + RT y() const { return _p.y(); } + + bool operator==(const Apollonius_site_2& other) const + { + return ( _p == other._p && _w == other._w ); + } + +private: + Point_2 _p; + Weight _w; + +}; + +template +std::ostream& +operator<<(std::ostream &os, const Apollonius_site_2& wp) +{ + return os << wp.point() << " " << wp.weight(); +} + +template +std::istream& +operator>>(std::istream& is, Apollonius_site_2& wp) +{ + typename Apollonius_site_2::Weight weight (0.); + typename Apollonius_site_2::Point_2 p (0., 0.); + is >> p >> weight; + if(is) { + wp = Apollonius_site_2(p, weight); + } + return is; +} + + +} //namespace CGAL + +#endif // CGAL_APOLLONIUS_SITE_2_H diff --git a/Apollonius_graph_2/include/CGAL/Hyperbola_2.h b/Apollonius_graph_2/include/CGAL/Hyperbola_2.h new file mode 100644 index 00000000000..b8bc9b8e23d --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Hyperbola_2.h @@ -0,0 +1,313 @@ +// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_HYPERBOLA_2_H +#define CGAL_HYPERBOLA_2_H + +#include + + +#include +#include + +#include +#include + +namespace CGAL { + +template < class Gt > +class Hyperbola_2 +{ +public: + typedef Gt Geom_traits; + typedef typename Gt::Site_2 Site_2; + typedef typename Gt::Segment_2 Segment_2; + typedef typename Gt::Point_2 Point_2; + typedef typename Gt::FT FT; +#if 0 + typedef typename Kernel_traits::Kernel Kernel; + typedef CGAL::Apollonius_site_2 Site_2; + typedef typename Kernel::Segment_2 Segment_2; + typedef Point Point_2; + typedef typename Kernel::FT FT; +#endif + // typedef typename R::RT FT; + // typedef double FT; + // typedef CGAL::Point_2< Cartesian > Point_2; + // typedef CGAL::Segment_2< Cartesian< double > > Segment_2; + +protected: + FT STEP; + + Point_2 f1, f2; + FT r; + Point_2 o; + + inline + Point_2 lchain(const FT &t) const + { + std::vector< Point_2 > p = compute_points(t); + if ( right(p[0]) ) return p[1]; + return p[0]; + } + + inline + Point_2 rchain(const FT &t) const + { + std::vector< Point_2 > p = compute_points(t); + if ( right(p[0]) ) return p[0]; + return p[1]; + } + + inline + FT norm2(const Point_2& p) const + { + return (CGAL::square(p.x()) + CGAL::square(p.y())); + } + + inline + FT distance2(const Point_2& p1, const Point_2& p2) const + { + FT dx = p1.x()-p2.x(); + FT dy = p1.y()-p2.y(); + return (CGAL::square(dx) + CGAL::square(dy)); + } + + inline + FT distance(const Point_2& p1, const Point_2& p2) const + { + return CGAL::sqrt( distance2(p1, p2) ); + } + + void compute_origin() + { + FT dx = f2.x() - f1.x(); + FT dy = f2.y() - f1.y(); + FT a = CGAL::sqrt(CGAL::square(dx) + CGAL::square(dy)); + FT t = (FT(1) + r / a) / FT(2); + + o = Point_2(dx * t + f1.x(), dy * t + f1.y()); + } + + std::vector< Point_2 > compute_points(const FT &d) const { + FT d1 = distance(o, f1) + d; + FT d2 = distance(o, f2) + d; + d1 *= d1; + d2 *= d2; + + Point_2 df = Point_2(f2.x() - f1.x(), f2.y()-f1.y()); + + std::vector< Point_2 > p; + + if ( CGAL::is_negative(d) ) return p; + + if ( CGAL::is_zero(df.x()) ) { + FT y = (d1 - d2 + norm2(f2) - norm2(f1)) / (FT(2) * df.y()); + + FT D = d1 - CGAL::square(y - f1.y()); + + D = CGAL::abs(D); + + FT x1 = CGAL::sqrt(D) + f1.x(); + FT x2 = -CGAL::sqrt(D) + f1.x(); + + p.push_back(Point_2(x1, y)); + p.push_back(Point_2(x2, y)); + + return p; + } + + FT gamma = (d1 - d2 + norm2(f2) - norm2(f1)) / (FT(2) * df.x()); + FT gamma1 = gamma - f1.x(); + FT beta = df.y() / df.x(); + + FT a = FT(1) + CGAL::square(beta); + FT b = -FT(2) * (gamma1 * beta + f1.y()); + FT c = CGAL::square(f1.y()) + CGAL::square(gamma1) - d1; + + FT D = CGAL::square(b) - FT(4) * a * c; + + D = CGAL::abs(D); + + FT y1 = (-b + CGAL::sqrt(D)) / (FT(2) * a); + FT y2 = (-b - CGAL::sqrt(D)) / (FT(2) * a); + + FT x1 = gamma - beta * y1; + FT x2 = gamma - beta * y2; + + p.push_back(Point_2(x1, y1)); + p.push_back(Point_2(x2, y2)); + + return p; + } + + bool right(const Point_2& p) const + { + return + CGAL::is_negative( determinant(f1.x(), f1.y(), 1, + f2.x(), f2.y(), 1, + p.x(), p.y(), 1) ); + } + + inline + Point_2 midpoint(const Point_2& p1, const Point_2& p2) const + { + FT t1 = t(p1); + FT t2 = t(p2); + FT midt = (t1+t2)/2; + return f(midt); + } + + inline + Point_2 f(FT t) const + { + if ( CGAL::is_negative(t) ) return rchain(-t); + return lchain(t); + } + + inline + FT t(const Point_2 &p) const + { + FT tt = distance(f1, p) - distance(f1, o); + if ( right(p) ) return -tt; + return tt; + } + +public: + Hyperbola_2() { STEP = FT(2); } + + Hyperbola_2(const Site_2 &ff1, const Site_2 &ff2) + { + STEP = FT(2); + this->r = ff1.weight() - ff2.weight(); + + this->f1 = ff1.point(); + this->f2 = ff2.point(); + + compute_origin(); + } + + Oriented_side + side_of_hyperbola(const Point_2 &p) const + { + double dist = distance(p, f1) - distance(p, f2) - r; + if ( dist < 0 ) return ON_NEGATIVE_SIDE; + if ( dist > 0 ) return ON_POSITIVE_SIDE; + return ON_ORIENTED_BOUNDARY; + } + + + template + void generate_points_qt(const QTWIDGET& W, + std::vector& pleft, + std::vector& pright) const + { + std::vector< Point_2 > p; + + pleft.push_back(o); + pright.push_back(o); + + double width = W.x_max() - W.x_min(); + double height = W.y_max() - W.y_min(); + + FT STEP; + if ( width < height ) { + STEP = width / 500.0; + } else { + STEP = height / 500.0; + } + // double mind = distance(o, f1) - r1; + for (int i = 1; i <= 100; i++) { + p = compute_points(FT(i * i) * STEP); + + if ( p.size() > 0 ) { + if ( right(p[0]) ) { + pright.push_back(p[0]); + pleft.push_back(p[1]); + } else { + pright.push_back(p[1]); + pleft.push_back(p[0]); + } + } + } + } + + template + void draw_qt(QTWIDGET& W) const + { + std::vector< Point_2 > pleft, pright; + generate_points_qt(pleft, pright); + + for (unsigned int i = 0; i < pleft.size() - 1; i++) { + W << Segment_2(pleft[i], pleft[i+1]); + } + + for (unsigned int i = 0; i < pright.size() - 1; i++) { + W << Segment_2(pright[i], pright[i+1]); + } + } + + void generate_points(std::vector& pleft, + std::vector& pright) const + { + std::vector< Point_2 > p; + + pleft.push_back(o); + pright.push_back(o); + + // double mind = distance(o, f1) - r1; + for (int i = 1; i <= 100; i++) { + p = compute_points(FT(i * i) * STEP); + + if ( p.size() > 0 ) { + if ( right(p[0]) ) { + pright.push_back(p[0]); + pleft.push_back(p[1]); + } else { + pright.push_back(p[1]); + pleft.push_back(p[0]); + } + } + } + } + + template< class Stream > + void draw(Stream &W) const + { + std::vector< Point_2 > pleft, pright; + generate_points(pleft,pright); + + for (unsigned int i = 0; i < pleft.size() - 1; i++) { + W << Segment_2(pleft[i], pleft[i+1]); + } + + for (unsigned int i = 0; i < pright.size() - 1; i++) { + W << Segment_2(pright[i], pright[i+1]); + } + } + +}; + +template< class Stream, class Gt > +inline +Stream& operator<<(Stream& s, const Hyperbola_2 &H) +{ + H.draw(s); + return s; +} + + +} //namespace CGAL + +#endif // CGAL_HYPERBOLA_2_H diff --git a/Apollonius_graph_2/include/CGAL/Hyperbola_ray_2.h b/Apollonius_graph_2/include/CGAL/Hyperbola_ray_2.h index 490d320d11d..bbd6c7b089b 100644 --- a/Apollonius_graph_2/include/CGAL/Hyperbola_ray_2.h +++ b/Apollonius_graph_2/include/CGAL/Hyperbola_ray_2.h @@ -44,12 +44,20 @@ public: using Base::f; protected: - +#if defined(__POWERPC__) && \ + defined(__GNUC__) && (__GNUC__ == 3 ) && (__GNUC_MINOR__ == 4) + // hack to avoid nasty warning for G++ 3.4 on Darwin + static FT OFFSET() + { + return FT(10000); + } +#else static const FT& OFFSET() { static const FT offset_(10000); return offset_; } +#endif template< class Stream > inline diff --git a/Apollonius_graph_2/include/CGAL/Hyperbola_segment_2.h b/Apollonius_graph_2/include/CGAL/Hyperbola_segment_2.h new file mode 100644 index 00000000000..629c7d9a353 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Hyperbola_segment_2.h @@ -0,0 +1,191 @@ +// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_HYPERBOLA_SEGMENT_2_H +#define CGAL_HYPERBOLA_SEGMENT_2_H + +#include + + +#include + +namespace CGAL { + +template < class Gt > +class Hyperbola_segment_2 : public Hyperbola_2< Gt > +{ +public: + typedef CGAL::Hyperbola_2 Base; + typedef typename Base::Site_2 Site_2; + typedef typename Base::Point_2 Point_2; + typedef typename Base::Segment_2 Segment_2; + typedef typename Base::FT FT; + + using Base::t; + using Base::f; + +#if 0 + typedef CGAL::Hyperbola_2 Base; + typedef typename Base::Weighted_point Weighted_point; +#endif + // typedef typename R::RT FT; + // typedef double FT; + // typedef CGAL::Point_2< Cartesian > Point_2; + // typedef CGAL::Segment_2< Cartesian > Segment_2; + +protected: + Point_2 p1, p2; + + template< class Stream > + inline + void draw_line(Stream &W) const + { +#if 0 + FT s[2]; + + s[0] = t(p1); + s[1] = t(p2); + + Point_2 p[2]; + for (int i = 0; i < 2; i++) p[i] = f(s[i]); + + W << Segment_2(p[0], p[1]); +#else + W << Segment_2(p1, p2); +#endif + } + + inline + Point_2 midpoint() const + { + return Hyperbola_2< Gt >::midpoint(p1, p2); + } + +public: + Hyperbola_segment_2() : Hyperbola_2< Gt >() {} + + Hyperbola_segment_2(const Site_2 &f1, const Site_2 &f2, + const Point_2 &p1, const Point_2 &p2) + : Hyperbola_2< Gt >(f1, f2) + { + this->p1 = p1; + this->p2 = p2; + } + + int compute_k(const FT tt) const { + return int(CGAL::to_double(CGAL::sqrt(tt / this->STEP))); + } + + void generate_points(std::vector& p) const + { + if ( CGAL::is_zero(this->r) ) { + p.push_back(p1); + p.push_back(p2); + return; + } + + FT s0, s1; + + s0 = t(p1); + s1 = t(p2); + + if (CGAL::compare(s0, s1) == LARGER) + std::swap(s0, s1); + + p.clear(); + + if ( !(CGAL::is_positive(s0)) && !(CGAL::is_negative(s1)) ) + { + FT tt = FT(-this->STEP); + int k = -1; + + p.push_back( this->o ); + + while ( CGAL::compare(tt, s0) == LARGER ) + { + p.insert( p.begin(), f(tt) ); + --k; + tt = - FT(k * k) * this->STEP; + } + + p.insert( p.begin(), f(s0) ); + + k = 1; + tt = FT(this->STEP); + while ( CGAL::compare(tt, s1) == SMALLER ) + { + p.push_back( f(tt) ); + ++k; + tt = FT(k * k) * this->STEP; + } + p.push_back( f(s1) ); + } + else if ( !(CGAL::is_negative(s0)) && !(CGAL::is_negative(s1)) ) + { + FT tt = s0; + int k = - compute_k(-tt); + + do + { + p.push_back( f(tt) ); + ++k; + tt = FT(k * k) * this->STEP; + } + while ( CGAL::compare(tt, s0) == LARGER && CGAL::compare(tt, s1) == SMALLER ); + + p.push_back( f(s1) ); + } + else + { + FT tt = s1; + int k = compute_k(tt); + + do + { + p.push_back( f(tt) ); + --k; + tt = - FT(k * k) * this->STEP; + } + while ( CGAL::compare(tt, s0) == LARGER && CGAL::compare(tt, s1) == SMALLER ); + + p.push_back( f(s0) ); + } + } + + template< class Stream > + void draw(Stream &W) const + { + std::vector p; + generate_points(p); + + for (unsigned int i = 0; i < p.size() - 1; i++) { + W << Segment_2(p[i], p[i+1]); + } + } + + +}; + + +template< class Stream, class Gt > +inline +Stream& operator<<(Stream &s, const Hyperbola_segment_2& H) +{ + H.draw(s); + return s; +} + +} //namespace CGAL + +#endif // CGAL_HYPERBOLA_SEGMENT_2_H diff --git a/Apollonius_graph_2/include/CGAL/Parabola_2.h b/Apollonius_graph_2/include/CGAL/Parabola_2.h new file mode 100644 index 00000000000..4cc53f95020 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Parabola_2.h @@ -0,0 +1,331 @@ +// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_PARABOLA_2_H +#define CGAL_PARABOLA_2_H + +#include + + +#include +#include +#include +#include + +namespace CGAL { + + +template < class Gt > +class Parabola_2 +{ +private: + typedef Parabola_2 Self; +public: + typedef typename Gt::Site_2 Site_2; + typedef typename Gt::Point_2 Point_2; + typedef typename Gt::Segment_2 Segment_2; + typedef typename Gt::Line_2 Line_2; + typedef typename Gt::FT FT; + // typedef CGAL::Point_2< Cartesian > Point_2; + // typedef CGAL::Segment_2< Cartesian > Segment_2; + // typedef CGAL::Line_2< Cartesian > Line_2; +private: + typedef Algebraic_structure_traits AST; +protected: + + // inline static + // FT square(const FT &x) + // { + // return x * x; + // } + + inline static + FT divide(const FT& x, const FT& y, Integral_domain_without_division_tag) { + return FT(CGAL::to_double(x) / CGAL::to_double(y)); + } + + inline static + FT divide(const FT& x, const FT& y, Field_tag) { + return x / y; + } + + inline static + FT divide(const FT& x, const FT& y) { + return divide(x,y, typename AST::Algebraic_category()); + } + + inline static + FT sqrt(const FT& x, Integral_domain_without_division_tag) { + return CGAL::sqrt(CGAL::to_double(x)); + } + + inline static + FT sqrt(const FT& x, Field_with_sqrt_tag) { + return CGAL::sqrt(x); + } + + inline static + FT sqrt(const FT& x) { + return sqrt(x, typename AST::Algebraic_category()); + } + + inline static + FT norm2(const Point_2& p) + { + return CGAL::square(p.x()) + CGAL::square(p.y()); + } + + inline static + FT distance2(const Point_2& p1, const Point_2& p2) + { + FT dx = p1.x()-p2.x(); + FT dy = p1.y()-p2.y(); + return CGAL::square(dx) + CGAL::square(dy); + } + + inline static + FT distance(const Point_2& p1, const Point_2& p2) + { + return sqrt( distance2(p1, p2) ); + } + + + inline static + FT distance(const Point_2& p, const Line_2& l) + { + return divide( p.x() * l.a() + p.y() * l.b() + l.c(), + sqrt( CGAL::square(l.a()) + CGAL::square(l.b()) ) ); + } + + + + // instance stuff + Point_2 c; + Line_2 l; + Point_2 o; + + inline + Point_2 lchain(const FT &t) const + { + std::vector< Point_2 > p = compute_points(t); + if ( right(p[0]) ) return p[1]; + return p[0]; + } + + inline + Point_2 rchain(const FT &t) const + { + std::vector< Point_2 > p = compute_points(t); + if ( right(p[0]) ) return p[0]; + return p[1]; + } + + std::vector< Point_2 > compute_points(const FT &d) const + { + CGAL_assertion(d >= 0); + FT d1 = distance(o, c) + d; + FT d2 = distance(o, l) + d; + d2 = d1; + d1 *= d1; + + std::vector< Point_2 > p; + + if ( l.a() == FT(0) ) { + FT y = d2 * int(CGAL::sign(l.b())) - divide(l.c(), l.b()); + + FT C = CGAL::square(y) - FT(2) * c.y() * y + + CGAL::square(c.x()) + CGAL::square(c.y()) - d1; + + FT D = CGAL::square(c.x()) - C; + + D = CGAL::abs(D); + + FT x1 = sqrt(D) + c.x(); + FT x2 = -sqrt(D) + c.x(); + + p.push_back(Point_2(x1, y)); + p.push_back(Point_2(x2, y)); + + return p; + } + + FT A = d2 * sqrt( CGAL::square(l.a()) + CGAL::square(l.b()) ) - l.c(); + FT B = CGAL::square(c.x()) + CGAL::square(c.y()) - d1; + + FT alpha = FT(1) + CGAL::square(divide(l.b(), l.a())); + FT beta = divide(A * l.b(), CGAL::square(l.a())) + c.y() + - divide(c.x() * l.b(), l.a()); + FT gamma = CGAL::square(divide(A, l.a())) + B + - divide(FT(2) * c.x() * A, l.a()); + + FT D = CGAL::square(beta) - alpha * gamma; + + D = CGAL::abs(D); + + FT y1 = divide((beta + sqrt(D)), alpha); + FT y2 = divide((beta - sqrt(D)), alpha); + + FT x1 = divide(A - l.b() * y1, l.a()); + FT x2 = divide(A - l.b() * y2, l.a()); + + p.push_back(Point_2(x1, y1)); + p.push_back(Point_2(x2, y2)); + + return p; + } + + bool right(const Point_2& p) const + { + return + CGAL::is_positive( determinant(c.x(), c.y(), FT(1), + o.x(), o.y(), FT(1), + p.x(), p.y(), FT(1)) ); + } + + inline + Point_2 midpoint(const Point_2& p1, const Point_2& p2) const + { + FT t1 = t(p1); + FT t2 = t(p2); + FT midt = divide(t1+t2, FT(2)); + return f(midt); + } + + inline + Point_2 f(FT t) const + { + if ( CGAL::is_negative(t) ) return rchain(-t); + return lchain(t); + } + + inline + FT t(const Point_2 &p) const + { + FT tt = distance(p, c) - distance(c, o); + if ( right(p) ) return -tt; + return tt; + } + + void compute_origin() + { + FT d = divide(l.a() * c.x() + l.b() * c.y() + l.c(), + FT(2) * ( CGAL::square(l.a()) + CGAL::square(l.b()) ) ); + o = Point_2(c.x() - l.a() * d, c.y() - l.b() * d); + } + +public: + Parabola_2() {} + + template + Parabola_2(const ApolloniusSite &p, const Line_2 &l1) + { + this->c = p.point(); + + FT d_a = CGAL::to_double(l1.a()); + FT d_b = CGAL::to_double(l1.b()); + FT len = sqrt(CGAL::square(d_a) + CGAL::square(d_b)); + + FT r = p.weight() * len; + + this->l = Line_2(-l1.a(), -l1.b(), -l1.c() + r); + compute_origin(); + } + + Parabola_2(const Point_2 &p, const Line_2 &line) + { + this->c = p; + + if ( line.has_on_positive_side(p) ) { + this->l = line; + } else { + this->l = line.opposite(); + } + compute_origin(); + } + + + Oriented_side + side_of_parabola(const Point_2& p) const + { + Point_2 q(CGAL::to_double(p.x()), CGAL::to_double(p.y())); + + FT d = distance(q, c) - CGAL::abs(distance(q, l)); + if ( d < 0 ) return ON_NEGATIVE_SIDE; + if ( d > 0 ) return ON_POSITIVE_SIDE; + return ON_ORIENTED_BOUNDARY; + } + + + inline Line_2 line() const + { + return l; + } + + inline Point_2 center() const + { + return c; + } + + template< class Stream > + void draw(Stream& W) const + { + std::vector< Point_2 > p; + std::vector< Point_2 > pleft, pright; + + pleft.push_back(o); + pright.push_back(o); + const FT STEP(2); + for (int i = 1; i <= 100; i++) { + p = compute_points(i * i * STEP); + + W << p[0]; + W << p[1]; + + if ( p.size() > 0 ) { + if ( right(p[0]) ) { + pright.push_back(p[0]); + pleft.push_back(p[1]); + } else { + pright.push_back(p[1]); + pleft.push_back(p[0]); + } + } + } + + for (unsigned int i = 0; i < pleft.size() - 1; i++) { + W << Segment_2(pleft[i], pleft[i+1]); + } + + for (unsigned int i = 0; i < pright.size() - 1; i++) { + W << Segment_2(pright[i], pright[i+1]); + } + + W << o; + } +}; + +template< class Stream, class Gt > +inline +Stream& operator<<(Stream& s, const Parabola_2 &P) +{ + P.draw(s); + return s; +} + + + + +} //namespace CGAL + +#endif // CGAL_PARABOLA_2_H diff --git a/Apollonius_graph_2/include/CGAL/Parabola_segment_2.h b/Apollonius_graph_2/include/CGAL/Parabola_segment_2.h new file mode 100644 index 00000000000..7c03ff5d5e5 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/Parabola_segment_2.h @@ -0,0 +1,189 @@ +// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_PARABOLA_SEGMENT_2_H +#define CGAL_PARABOLA_SEGMENT_2_H + +#include + + +#include + +namespace CGAL { + +namespace Qt { + template class PainterOstream; +} + +template < class Gt > +class Parabola_segment_2 : public Parabola_2< Gt > +{ + typedef CGAL::Parabola_2 Base; + typedef typename Base::Site_2 Site_2; + typedef typename Base::FT FT; + typedef typename Base::Point_2 Point_2; + typedef typename Base::Segment_2 Segment_2; + typedef typename Base::Line_2 Line_2; + + using Base::t; + using Base::f; + +protected: + Point_2 p1, p2; + +public: + Parabola_segment_2() : Parabola_2< Gt >() {} + + template + Parabola_segment_2(const ApolloniusSite &p, const Line_2 &l, + const Point_2 &p1, const Point_2 &p2) + : Parabola_2< Gt >(p, l) + { + this->p1 = p1; + this->p2 = p2; + } + + Parabola_segment_2(const Point_2 &p, const Line_2 &l, + const Point_2 &p1, const Point_2 &p2) + : Parabola_2< Gt >(p, l) + { + this->p1 = p1; + this->p2 = p2; + } + + int compute_k(const FT tt, const FT STEP) const { + return int(CGAL::to_double(CGAL::sqrt(tt / STEP))); + } + + // s0 and s1 define a desired drawing "range" + void generate_points(std::vector& p, + const FT STEP, + FT s0, FT s1) const + { + CGAL_precondition(STEP > 0); + + p.clear(); + + if (CGAL::compare(s0, s1) == LARGER) + std::swap(s0, s1); + + // This is a parabola segment that exists between only between p1 and p2 so we gotta crop + // the desired range to actually fit the parabola segment + FT tp1 = t(p1), tp2 = t(p2); + + if (CGAL::compare(tp1, tp2) == LARGER) + std::swap(tp1, tp2); + + if(tp2 < s0 || s1 < tp1) // nothing to draw because the ranges are completely disjoint + return; + + s0 = (std::max)(s0, tp1); + s1 = (std::min)(s1, tp2); + + if ( !(CGAL::is_positive(s0)) && !(CGAL::is_negative(s1)) ) + { + FT tt = - STEP; + int k = -1; + + p.push_back( this->o ); + + // no need to check tt < s1 since we have tt < 0, s1 >= 0 and tt is moving towards -inf + while ( CGAL::compare(tt, s0) == LARGER ) + { + p.insert( p.begin(), f(tt) ); + --k; + tt = - FT(k * k) * STEP; + } + p.insert( p.begin(), f(s0) ); + + k = 1; + tt = STEP; + + // no need to check tt > s0 since we have tt > 0, s0 <= 0 and tt is moving towards +inf + while ( CGAL::compare(tt, s1) == SMALLER ) + { + p.push_back( f(tt) ); + ++k; + tt = FT(k * k) * STEP; + } + p.push_back( f(s1) ); + } + else if ( !(CGAL::is_negative(s0)) && !(CGAL::is_negative(s1)) ) + { + FT tt = s0; + int k = compute_k(tt, STEP); + + do + { + p.push_back( f(tt) ); + ++k; + tt = FT(k * k) * STEP; + } + while ( CGAL::compare(tt, s0) == LARGER && CGAL::compare(tt, s1) == SMALLER ); + + p.push_back( f(s1) ); + } + else + { + FT tt = s1; + int k = - compute_k(-tt, STEP); + + do + { + p.push_back( f(tt) ); + --k; + tt = - FT(k * k) * STEP; + } + while ( CGAL::compare(tt, s0) == LARGER && CGAL::compare(tt, s1) == SMALLER ); + + p.push_back( f(s0) ); + } + } + + void generate_points(std::vector& p, + const FT STEP = FT(2)) const + { + return generate_points(p, STEP, t(p1), t(p2)); + } + + template< class Stream > + void draw(Stream& W) const + { + std::vector< Point_2 > p; + generate_points(p); + + for (unsigned int i = 0; i < p.size() - 1; i++) { + W << Segment_2(p[i], p[i+1]); + } + } + + template< class K > + void draw(CGAL::Qt::PainterOstream& stream) const { + stream.draw_parabola_segment(this->center(), this->line(), p1, p2); + } +}; + + + +template< class Stream, class Gt > +inline +Stream& operator<<(Stream &s, const Parabola_segment_2 &P) +{ + P.draw(s); + return s; +} + +} //namespace CGAL + +#endif // CGAL_PARABOLA_SEGMENT_2_H diff --git a/Apollonius_graph_2/include/CGAL/functions_on_signs.h b/Apollonius_graph_2/include/CGAL/functions_on_signs.h new file mode 100644 index 00000000000..6cf97ee58a8 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/functions_on_signs.h @@ -0,0 +1,137 @@ +// Copyright (c) 2003 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_FUNCTIONS_ON_SIGNS_H +#define CGAL_FUNCTIONS_ON_SIGNS_H + +#include + + +#include +#include + +namespace CGAL { +#if 0 +inline +Sign +operator*(const Sign &s1, const Sign &s2) +{ + if ( s1 == ZERO || s2 == ZERO ) return ZERO; + if ( s1 == s2 ) return POSITIVE; + return NEGATIVE; +} +#endif + +template < class RT > +Sign +sign_a_plus_b_x_sqrt_c(const RT &a, const RT &b, const RT &c) +{ + // computes the sign of quantity: a + b * sqrt(c) + + CGAL_assertion( !(CGAL::is_negative(c)) ); + + Sign sa = CGAL::sign(a); + if ( CGAL::sign(c) == ZERO ) return sa; + + Sign sb = CGAL::sign(b); + if ( sa == sb ) return sa; + if ( sa == ZERO ) return sb; + + return sa * CGAL::compare( CGAL::square(a), + c * CGAL::square(b) ); +} + +template < class RT > +Sign +sign_a_x_sqrt_c_plus_b_x_sqrt_d(const RT &a, const RT &b, + const RT &c, const RT &d) +{ + // computes the sign of quantity: a * sqrt(c) + b * sqrt(d) + + CGAL_assertion( !(CGAL::is_negative(c)) ); + CGAL_assertion( !(CGAL::is_negative(d)) ); + + Sign sb = CGAL::sign(b); + if ( CGAL::sign(d) == ZERO ) return CGAL::sign(a * c); + if ( CGAL::sign(c) == ZERO ) return sb; + + Sign sa = CGAL::sign(a); + if ( sa == sb ) return sa; + if ( sa == ZERO ) return sb; + + return sa * CGAL::compare( CGAL::square(a) * c, + CGAL::square(b) * d ); +} + +template < class RT > +Sign +sign_a_plus_b_x_sqrt_e_plus_c_x_sqrt_f(const RT &a, const RT &b, + const RT &c, const RT &e, + const RT &f) +{ + // computes the sign of quantity: a + b * sqrt(e) + c * sqrt(f) + + CGAL_assertion( !(CGAL::is_negative(e)) ); + CGAL_assertion( !(CGAL::is_negative(f)) ); + + Sign s_a_plus_b_x_sqrt_e = sign_a_plus_b_x_sqrt_c(a, b, e); + if ( CGAL::sign(f) == ZERO ) return s_a_plus_b_x_sqrt_e; + + Sign sc = CGAL::sign(c); + if ( s_a_plus_b_x_sqrt_e == sc ) return sc; + if ( s_a_plus_b_x_sqrt_e == ZERO ) return sc; + + return s_a_plus_b_x_sqrt_e * + sign_a_plus_b_x_sqrt_c(CGAL::square(a) + CGAL::square(b) * e + - CGAL::square(c) * f, + RT(2) * a * b, e); +} + +template < class RT > +Sign +sign_a_plus_b_x_sqrt_e_plus_c_x_sqrt_f_plus_d_sqrt_e_x_f(const RT &a, + const RT &b, + const RT &c, + const RT &d, + const RT &e, + const RT &f) +{ + // computes the sign of quantity: + // a + b * sqrt(e) + c * sqrt(f) + d * sqrt(e * f) + + CGAL_assertion( !(CGAL::is_negative(e)) ); + CGAL_assertion( !(CGAL::is_negative(f)) ); + + Sign s_a_plus_b_sqrt_e = sign_a_plus_b_x_sqrt_c(a, b, e); + Sign s_c_plus_d_sqrt_e = sign_a_plus_b_x_sqrt_c(c, d, e); + + if ( s_a_plus_b_sqrt_e == s_c_plus_d_sqrt_e ) + return s_a_plus_b_sqrt_e; + + if ( s_a_plus_b_sqrt_e == ZERO ) + return s_a_plus_b_sqrt_e; + + return s_a_plus_b_sqrt_e * + sign_a_plus_b_x_sqrt_c(CGAL::square(a) + CGAL::square(b) * e + - CGAL::square(c) * f + - CGAL::square(d) * e * f, + RT(2) * (a * b - c * d * f), + e); +} + +} //namespace CGAL + +#include + +#endif // CGAL_FUNCTIONS_ON_SIGNS_H diff --git a/Apollonius_graph_2/include/CGAL/in_place_edge_list.h b/Apollonius_graph_2/include/CGAL/in_place_edge_list.h new file mode 100644 index 00000000000..262bf298f44 --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/in_place_edge_list.h @@ -0,0 +1,201 @@ +// Copyright (c) 2003,2004 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_IN_PLACE_EDGE_LIST_H +#define CGAL_IN_PLACE_EDGE_LIST_H + +#include + + +namespace CGAL { + +template +class In_place_edge_list { +private: + typedef typename Edge::first_type Face_handle; + typedef typename Face_handle::value_type Face; + +private: + Edge _front; + unsigned int _size; + +private: + inline void increase_size() { + _size++; + } + + inline void decrease_size() { + _size--; + } + +public: + bool is_valid() const { return true; } + + inline unsigned int size() const { + return _size; + } + + inline void push_first(const Edge& e) { + _front = e; + set_next(e, e); + set_previous(e, e); + increase_size(); + } + + inline Edge next(const Edge& e) const { + CGAL_precondition( is_in_list(e) ); + return e.first->next(e.second); + } + + inline Edge previous(const Edge& e) const { + CGAL_precondition( is_in_list(e) ); + return e.first->previous(e.second); + } + + inline void set_next(const Edge& e, const Edge& next) { + Edge _next(next.first, next.second); + e.first->set_next(e.second, _next); + } + + inline void set_previous(const Edge& e, const Edge& prev) { + Edge _prev(prev.first, prev.second); + e.first->set_previous(e.second, _prev); + } + + inline bool is_first(const Edge& e) const { + return ( (e.first == _front.first && + e.second == _front.second) ); + } + +public: + inline bool is_singleton() const { + CGAL_precondition( !is_empty() ); + return (size() == 1); + } + +public: + In_place_edge_list(const Edge& e = Edge(Face_handle(),-1) ) + : _size(0) { + _front = e; + } + + inline Edge front() const { + CGAL_precondition( !is_empty() ); + return _front; + } + + inline Edge back() const { + CGAL_precondition( !is_empty() ); + return previous(_front); + } + + inline bool is_empty() const { + return ( _front.first == Face_handle() ); + } + + inline void pop() { + CGAL_precondition( !is_empty() ); + remove(front()); // it is important here that I do not pass the + // variable _front but rather a copy of it... + } + + inline void push_front(const Edge& e) { + CGAL_precondition( !is_in_list(e) ); + push(e); + _front = e; + } + + inline void push_back(const Edge& e) { + push(e); + } + + void push(const Edge& e) { + CGAL_precondition( !is_in_list(e) ); + + if ( is_empty() ) { + push_first(e); + return; + } + Edge last_edge = back(); + set_next(last_edge, e); + set_next(e, _front); + set_previous(e, last_edge); + set_previous(_front, e); + + increase_size(); + } + + inline void insert_after(const Edge& e, const Edge& new_e) { + CGAL_precondition( is_in_list(e) ); + Edge old_front = _front; + _front = next(e); + push_front(new_e); + _front = old_front; + } + + inline void insert_before(const Edge& e, const Edge& new_e) { + CGAL_precondition( is_in_list(e) ); + Edge old_front = _front; + _front = e; + push(new_e); + _front = old_front; + } + + inline void replace(const Edge& e, const Edge& new_e) { + insert_before(e, new_e); + remove(e); + } + + void remove(const Edge& e) { + CGAL_precondition( is_in_list(e) ); + static const Edge SENTINEL_QUEUE_EDGE = Edge(Face_handle(), -1); + + if ( is_singleton() ) { + _front = SENTINEL_QUEUE_EDGE; + set_next(e, SENTINEL_QUEUE_EDGE); + set_previous(e, SENTINEL_QUEUE_EDGE); + decrease_size(); + return; + } + + Edge _next = next(e); + Edge _prev = previous(e); + + if ( is_first(e) ) { + _front = _next; + } + + set_next(e, SENTINEL_QUEUE_EDGE); + set_previous(e, SENTINEL_QUEUE_EDGE); + + set_next(_prev, _next); + set_previous(_next, _prev); + decrease_size(); + } + + bool is_in_list(const Edge& e) const { + return e.first->is_in_list(e.second); + } + + void clear() { + while ( !is_empty() ) { + pop(); + } + } +}; + +} //namespace CGAL + + +#endif // CGAL_IN_EDGE_PLACE_LIST_H diff --git a/Apollonius_graph_2/include/CGAL/more_functions_on_signs.h b/Apollonius_graph_2/include/CGAL/more_functions_on_signs.h new file mode 100644 index 00000000000..d9d8af7b91c --- /dev/null +++ b/Apollonius_graph_2/include/CGAL/more_functions_on_signs.h @@ -0,0 +1,59 @@ +// Copyright (c) 2003 INRIA Sophia-Antipolis (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s) : Menelaos Karavelas + + + +#ifndef CGAL_MORE_FUNCTIONS_ON_SIGNS_H +#define CGAL_MORE_FUNCTIONS_ON_SIGNS_H + +#include + + +#include + +namespace CGAL { +inline +Sign +sign_of_first_root(const Sign &sb, const Sign &sc) +{ + // this method computes the sign of the second root of the quadratic + // equation: a x^2 - b x + c == 0. It is assumed that the sign of a + // is +1. + + if ( sc == NEGATIVE ) + return NEGATIVE; + + if ( sb == POSITIVE ) return sc; + if ( sb == NEGATIVE ) return NEGATIVE; + return opposite(sc); +} + + +inline +Sign +sign_of_second_root(const Sign &sb, const Sign &sc) +{ + // this method computes the sign of the first root of the quadratic + // equation: a x^2 - b x + c == 0. It is assumed that the sign of a + // is +1. + + if ( sc == NEGATIVE ) + return POSITIVE; + + if ( sb == POSITIVE ) return POSITIVE; + if ( sb == NEGATIVE ) return opposite(sc); + return sc; +} + +} //namespace CGAL + +#endif // CGAL_MORE_FUNCTIONS_ON_SIGNS_H diff --git a/Apollonius_graph_2/package_info/Apollonius_graph_2/copyright b/Apollonius_graph_2/package_info/Apollonius_graph_2/copyright new file mode 100644 index 00000000000..8932b3233d2 --- /dev/null +++ b/Apollonius_graph_2/package_info/Apollonius_graph_2/copyright @@ -0,0 +1,2 @@ +INRIA Sophia-Antipolis (France) + diff --git a/Apollonius_graph_2/package_info/Apollonius_graph_2/dependencies b/Apollonius_graph_2/package_info/Apollonius_graph_2/dependencies new file mode 100644 index 00000000000..326f1dd8070 --- /dev/null +++ b/Apollonius_graph_2/package_info/Apollonius_graph_2/dependencies @@ -0,0 +1,24 @@ +Algebraic_foundations +Apollonius_graph_2 +Arithmetic_kernel +Cartesian_kernel +Circulator +Distance_2 +Distance_3 +Filtered_kernel +Hash_map +Installation +Intersections_2 +Intersections_3 +Interval_support +Kernel_23 +Modular_arithmetic +Number_types +Polygon +Profiling_tools +Property_map +STL_Extension +Spatial_sorting +Stream_support +TDS_2 +Triangulation_2 diff --git a/Apollonius_graph_2/package_info/Apollonius_graph_2/description.txt b/Apollonius_graph_2/package_info/Apollonius_graph_2/description.txt new file mode 100644 index 00000000000..a28ce71c2fe --- /dev/null +++ b/Apollonius_graph_2/package_info/Apollonius_graph_2/description.txt @@ -0,0 +1,3 @@ +This package offers a dynamic algorithm for the construction of the +Apollonius graph in 2D which is the dual of the Apollonius diagram +(also known as the Additively weighted Voronoi diagram). diff --git a/Apollonius_graph_2/package_info/Apollonius_graph_2/license.txt b/Apollonius_graph_2/package_info/Apollonius_graph_2/license.txt new file mode 100644 index 00000000000..8bb8efcb72b --- /dev/null +++ b/Apollonius_graph_2/package_info/Apollonius_graph_2/license.txt @@ -0,0 +1 @@ +GPL (v3 or later) diff --git a/Apollonius_graph_2/package_info/Apollonius_graph_2/maintainer b/Apollonius_graph_2/package_info/Apollonius_graph_2/maintainer new file mode 100644 index 00000000000..b172ee135bb --- /dev/null +++ b/Apollonius_graph_2/package_info/Apollonius_graph_2/maintainer @@ -0,0 +1 @@ +Menelaos Karavelas diff --git a/Apollonius_graph_2/test/Apollonius_graph_2/CMakeLists.txt b/Apollonius_graph_2/test/Apollonius_graph_2/CMakeLists.txt new file mode 100644 index 00000000000..21fdc4f6f58 --- /dev/null +++ b/Apollonius_graph_2/test/Apollonius_graph_2/CMakeLists.txt @@ -0,0 +1,18 @@ +# Created by the script cgal_create_cmake_script +# This is the CMake script for compiling a CGAL application. + +cmake_minimum_required(VERSION 3.1...3.20) +project(Apollonius_graph_2_Tests) + +find_package(CGAL REQUIRED) + +include_directories(BEFORE "include") + +# create a target per cppfile +file( + GLOB cppfiles + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) +foreach(cppfile ${cppfiles}) + create_single_source_cgal_program("${cppfile}") +endforeach() diff --git a/Apollonius_graph_2/test/Apollonius_graph_2/data/algo.dat b/Apollonius_graph_2/test/Apollonius_graph_2/data/algo.dat new file mode 100644 index 00000000000..42fd245c11c --- /dev/null +++ b/Apollonius_graph_2/test/Apollonius_graph_2/data/algo.dat @@ -0,0 +1,9 @@ +20.0 -20 5 +9 -9 15. +1000 -1000 20 +10.0 5.0 5 +1.0 1.0 10 +-10 -10 11 +95 67 33 +-99 -100 -31 + diff --git a/Apollonius_graph_2/test/Apollonius_graph_2/data/hierarchy.dat b/Apollonius_graph_2/test/Apollonius_graph_2/data/hierarchy.dat new file mode 100644 index 00000000000..5de3093d381 --- /dev/null +++ b/Apollonius_graph_2/test/Apollonius_graph_2/data/hierarchy.dat @@ -0,0 +1,500 @@ +-199.259 28.7176 0.613542 +141.606 166.862 1.13775 +-5.56519 -156.845 3.31008 +50.3311 161.726 1.07564 +-64.7456 -87.8027 4.06628 +14.8532 105.665 2.20139 +76.5577 90.566 0.840065 +-49.4694 41.2512 3.67553 +-174.917 128.685 2.38958 +188.251 -109.254 1.15084 +16.9685 -57.0234 1.1601 +-16.1697 -7.94008 0.430175 +26.9857 83.0797 2.86061 +-11.288 -52.1136 0.989749 +100.909 33.9376 2.68043 +6.5738 -40.7596 0.366094 +-102.86 135.351 3.82307 +138.391 -197.444 0.704697 +67.0764 96.5988 1.01824 +157.823 -112.234 0.871374 +-99.2007 -20.1674 3.58348 +92.8592 72.6406 0.881359 +-24.0611 107.055 3.71868 +123.825 -64.0966 1.07758 +-42.2371 15.0832 4.83895 +117.003 -170.482 2.42112 +52.3544 -141.195 3.63537 +54.9108 164.65 2.86525 +-48.4905 -178.974 1.20371 +39.2751 -97.515 0.676493 +-180.892 -27.805 1.93648 +91.7483 -141.127 0.597223 +-1.19714 -70.6179 2.79646 +134.706 -173.123 1.84428 +-50.2105 -86.9171 3.81631 +-20.693 -99.8014 2.77885 +38.112 93.8881 0.933284 +2.76229 -15.2827 4.11967 +23.7883 -186.062 1.01354 +126.273 -89.7657 4.00448 +-101.532 -35.6463 4.24332 +-42.6583 119.272 2.89018 +86.7238 167.05 0.375211 +113.6 -9.23294 4.55904 +-173.317 138.309 1.43141 +-73.1181 43.6142 3.67274 +-179.23 -134.078 1.64915 +5.48731 -59.4149 4.18367 +19.4249 -129.841 1.98103 +129.659 -48.7584 1.05945 +-105.987 -128.4 2.2903 +-186.715 -188.935 4.25707 +180.336 42.2795 2.84112 +-28.8974 72.2964 1.76112 +-90.5882 37.0195 2.09466 +153.026 151.532 3.68069 +-181.052 45.3517 3.94031 +-40.4665 177.283 1.5089 +29.6921 111.977 4.25171 +180.934 -129.54 3.37245 +-147.467 -44.7849 4.54762 +-136.401 138.439 4.71368 +105.878 79.0047 4.46788 +-21.8252 -93.7059 1.60666 +-184.806 47.184 2.97431 +166.727 -185.243 2.38713 +12.0782 109.212 2.62399 +-10.6384 24.4369 4.61816 +-98.6612 145.149 2.48931 +-28.2016 85.2863 2.25098 +127.013 -44.9173 2.90765 +65.4525 -81.108 3.70263 +-55.5428 -104.013 2.52612 +50.7513 -146.583 4.7533 +-102.065 -18.0503 4.94323 +-87.3077 -180.106 4.52731 +-178.096 10.865 2.17829 +46.3413 -179.216 4.54531 +-8.50957 190.237 0.812045 +-123.223 -10.6186 2.95952 +31.8595 169.46 2.04719 +150.751 2.0718 0.365349 +-153.262 -101.717 2.17106 +-99.845 100.372 0.305455 +82.1047 80.6358 1.52965 +101.999 76.0943 2.9383 +-87.1359 38.2792 3.2121 +-66.3517 -187.458 1.29137 +-76.115 176.167 3.685 +113.266 -158.869 4.64471 +82.7263 77.8927 2.54295 +-115.202 -158.332 1.92735 +-16.9193 -129.104 2.51157 +-116.548 44.5811 3.76351 +164.088 69.0175 2.28982 +40.1826 191.389 1.06481 +-121.538 26.4532 2.47561 +-108.996 -116.578 4.14621 +-132.829 -13.2689 0.694777 +-91.698 -118.469 4.61061 +186.195 -146.892 3.14469 +-172.137 56.5441 4.20466 +-101.241 -189.268 1.49317 +143.34 11.6578 2.53633 +12.3573 -87.2613 2.08743 +3.74654 95.9243 0.0897139 +-169.8 181.109 1.07049 +-86.3787 -20.842 2.20804 +100.352 -89.1449 3.04768 +181.883 -33.5627 4.40146 +-165.009 -64.7142 4.22889 +91.5355 186.861 4.57717 +102.267 123.234 0.811658 +-86.0748 -157.313 0.103406 +26.6639 45.5936 2.75787 +-77.4118 -187.412 0.304705 +-96.3027 -180.235 0.682201 +82.8553 -94.5959 2.10247 +193.71 82.0472 0.856872 +-39.8523 -74.1384 0.630415 +95.4336 -122.022 1.06781 +82.2942 -183.711 4.712 +5.52791 182.463 3.49034 +48.2153 -152.604 4.91441 +-106.191 -144.332 2.74771 +-93.6031 76.298 4.28006 +-73.8378 100.674 0.576277 +31.5663 155.25 4.11197 +-86.3865 -76.5521 4.03335 +39.4751 -8.0024 1.0352 +117.453 42.4308 4.72811 +133.742 127.855 3.25679 +116.205 104.816 0.825892 +163.601 -15.957 3.92858 +-180.731 -22.8043 0.101193 +95.5669 197.012 1.43116 +-3.75869 139.417 3.00818 +-48.5082 185.519 0.902761 +74.9397 114.477 2.32293 +-133.063 37.1446 0.316367 +109.368 119.96 4.28453 +37.2235 98.2094 3.45631 +-57.961 -41.2472 2.40887 +126.082 24.8242 1.95388 +-96.7223 -60.8892 2.19474 +-99.71 -52.7938 0.889331 +-160.293 61.6986 3.34235 +-174.774 -97.6468 0.235995 +139.703 -25.4259 3.67274 +-23.1525 160.408 4.50946 +-103.192 185.718 3.37656 +195.017 128.48 1.34185 +-46.2301 4.9848 3.11734 +178.594 197.695 2.19336 +-82.2952 -45.9948 3.48434 +64.9111 129.585 4.73796 +-73.3903 -199.269 0.234298 +28.9629 68.119 0.549627 +-196.463 86.9986 4.79591 +163.945 -19.1822 2.00651 +149.663 -58.4257 3.2166 +78.1433 -188.301 3.15432 +-116.872 -80.9531 0.0764394 +-119.177 168.434 4.80886 +34.8278 -56.0969 1.28018 +-35.5875 -177.35 4.59156 +-34.8563 -198.313 1.17418 +-166.737 -179.569 4.03622 +120.261 -135.599 4.08043 +-98.9209 -151.926 3.62975 +42.6534 8.59436 3.00054 +54.3523 -134.077 1.47733 +173.399 118.268 2.51643 +141.833 124.383 3.52671 +-114.264 109.092 1.46206 +-91.6138 -188.494 3.51722 +-89.927 178.831 0.581516 +-69.4964 -127.234 0.9973 +-5.09564 195.664 0.000566293 +42.9782 122.098 1.26406 +-148.427 12.4784 4.29722 +-82.5049 -147.478 2.47663 +-164.237 -29.2921 2.14412 +160.146 172.022 1.41703 +69.238 54.1596 2.48874 +80.7442 171.125 3.84356 +59.5755 52.502 0.219476 +132.342 99.0233 1.85077 +128.005 178.807 4.28708 +50.1037 178.853 2.3243 +-137.418 -120.023 2.96896 +-84.8963 -176.245 4.43765 +85.8117 21.8849 4.88468 +57.8341 193.414 4.38651 +-88.0063 -93.2232 2.75198 +-116.882 105.876 1.26129 +135.62 13.3607 4.50598 +34.6435 30.9187 3.66025 +13.4508 178.98 2.76032 +-7.69665 121.946 0.886613 +72.2804 -92.1095 1.66889 +96.0352 145.407 3.10769 +-82.0799 100.419 1.68033 +-88.6656 91.1938 4.90326 +18.1112 42.1145 1.30318 +-76.0132 -137.727 2.34216 +137.347 -36.8239 1.53741 +-31.7339 -76.3455 4.47045 +-52.7535 -183.526 2.13859 +-130.807 37.2997 4.54238 +-22.9166 108.229 2.94588 +-77.5094 -158.26 1.64632 +-177.09 90.3548 3.12033 +114.104 -175.219 4.51201 +-43.7819 -182.958 2.23839 +18.4912 -78.7035 3.78823 +181.667 108.669 3.00507 +-94.6783 -168.338 0.108398 +-78.2039 189.298 1.94898 +159.096 -39.6151 2.81389 +67.3245 -76.2247 0.0274314 +109.064 159.446 1.55856 +-0.580817 -108.848 1.84494 +24.2006 140.778 0.771231 +41.2427 101.738 2.72396 +162.539 -119.19 0.455097 +71.2081 183.868 0.225937 +102.87 24.2739 1.54246 +92.1677 32.9458 3.06491 +-147.447 188.864 2.55361 +-23.6721 13.9753 0.895164 +-64.2261 16.1698 4.75847 +26.9257 140.855 2.25121 +-32.2964 -111.55 0.0537161 +-130.558 -49.8517 3.06925 +-49.7482 168.065 2.60099 +-65.88 -195.527 0.99109 +158.394 -177.452 4.77696 +-8.66023 -54.0558 3.42906 +-19.7961 191.137 4.08597 +194.179 -4.57438 1.29007 +10.349 67.0388 2.98724 +-48.7961 47.7163 0.823812 +39.6537 -172.187 2.92011 +189.802 -167.89 3.78813 +157.867 77.6502 0.666279 +162.339 -114.271 2.34278 +184.887 -34.9835 1.8227 +-69.1688 -52.8265 4.21445 +-78.0318 -178.502 1.467 +117.394 148.376 1.39424 +-15.5675 -148.419 4.0236 +-167.851 90.5603 0.913651 +-140.038 156.465 3.90932 +-107.928 -9.92617 3.78185 +169.722 -106.876 3.25518 +-144.548 -53.5733 2.78443 +20.4682 133.849 2.59551 +167.642 -120.335 4.2309 +189.14 -183.179 0.755505 +137.516 -65.8187 4.72293 +189.097 45.7205 2.02833 +79.657 -32.3914 2.43019 +36.1223 40.7007 3.17972 +-173.804 -46.5535 4.33062 +-80.6796 -144.006 3.95215 +65.7471 116.409 4.64529 +-0.403869 -60.8368 2.40114 +79.2614 146.804 1.99667 +96.0828 85.2766 1.86092 +-169.736 145.717 1.07986 +75.9847 123.551 0.943572 +-156.407 -114.182 4.43928 +84.294 80.2336 2.39081 +-162.26 -65.3891 2.71826 +-106.265 -118.94 4.20977 +-189.856 197.232 2.53161 +-50.6931 168.856 0.0265606 +-103.889 -39.0528 3.51733 +181.388 120.68 2.21836 +127.105 -130.446 2.59667 +50.656 -44.0573 1.04647 +136.474 31.4285 1.59139 +16.7076 -13.4288 0.145065 +151.319 177.836 0.616821 +-167.621 -4.70256 1.78851 +-170.389 -67.921 1.9153 +198.467 134.608 3.78164 +-40.5861 136.733 4.98303 +-119.906 18.1189 4.75038 +-50.3519 195.588 3.83919 +105.591 3.32129 1.97239 +-62.9807 87.0392 1.17831 +123.591 -185.649 3.88716 +101.427 -174.044 3.27864 +-103.276 -124.699 3.68337 +28.8033 18.3818 4.05351 +-36.5889 171.606 4.03435 +-99.8563 74.1371 1.02702 +118.263 72.7794 2.0282 +113.851 52.8096 3.8988 +-82.8281 -40.0555 2.71869 +-195.789 117.735 4.43143 +-181.438 -188 3.47631 +-155.483 122.973 2.24414 +-80.1812 -14.736 3.4532 +138.201 -120.066 1.31324 +109.807 -195.785 3.35588 +-16.0563 126.963 4.60767 +-143.277 -190.876 3.58595 +109.533 -28.6197 2.50909 +-130.523 -116.716 3.97373 +187.213 100.779 4.02637 +199.213 55.2933 4.25839 +122.186 -66.602 4.81486 +-92.5501 112.929 1.31259 +-12.6162 -10.8148 0.540102 +-8.40121 94.2442 4.41268 +-81.4385 -37.2857 1.71198 +-72.3142 -68.6719 2.42102 +99.0661 -181.796 1.29018 +182.35 18.9313 2.15864 +83.1297 -63.17 1.9988 +-61.577 -141.06 1.98896 +71.821 199.611 1.01629 +-15.2495 184.8 2.35941 +173.936 -110.192 4.70171 +68.1799 -66.9843 2.09669 +-169.106 -113.97 3.57871 +-37.7777 22.9888 0.174783 +-19.5733 -183.33 3.91311 +199.358 -80.1157 3.69249 +-63.8121 92.5755 2.23161 +-4.87228 -147.521 3.9619 +-5.26103 11.5961 2.35966 +-20.461 92.899 4.66904 +69.3466 -118.348 4.34324 +-197.638 -142.212 2.69549 +-111.607 25.5236 3.08166 +111.382 -88.1795 0.109442 +128.052 -74.1968 2.36478 +-152.064 -161.148 2.35675 +140.512 134.251 4.0591 +192.991 -87.22 1.4982 +4.58696 -170.268 3.93243 +-102.514 18.5048 1.17667 +-20.8624 -7.97184 4.5435 +36.9259 -60.5128 4.57303 +-137.55 155.126 0.677942 +-25.73 1.65912 4.57021 +100.073 10.4145 3.67086 +138.925 199.597 4.27006 +73.1762 -11.8635 3.52645 +185.956 -87.1356 3.43884 +-184.312 32.72 0.996175 +34.193 -52.6854 2.21475 +-173.779 41.4482 4.45397 +-34.2916 4.92842 2.41554 +-79.1656 -29.229 3.19616 +122.494 25.0063 0.374536 +-67.092 -9.37676 4.12545 +-67.4954 -115.708 3.36201 +120.641 -174.103 1.77672 +-166.495 108.013 1.60117 +66.2255 -16.8802 1.79727 +-186.46 62.8138 4.72469 +54.9883 -160.006 0.0524522 +-140.083 196.311 2.12381 +30.6877 -10.4454 3.63424 +-144.306 -154.752 2.66541 +46.3173 -124.79 4.32676 +130.609 -194.754 0.983063 +156.506 74.2077 4.99108 +64.5186 -183.655 0.409895 +-152.362 -55.5612 3.73771 +110.452 88.2207 3.90696 +150.446 66.1956 2.09432 +146.757 70.3918 2.84328 +-63.6882 -159.704 0.726874 +-18.4407 131.035 1.42305 +56.7697 -55.7323 4.50202 +62.0162 -109.592 3.63463 +-63.7761 -30.9468 3.09095 +-47.4311 -31.6606 1.39743 +97.0077 1.13095 1.99291 +-14.7717 -99.8519 0.873568 +-148.576 -187.295 0.254143 +121.816 -19.7493 4.58861 +162.112 -192.287 1.29251 +93.1475 -134.137 3.562 +-162.585 -20.2932 1.77162 +-72.1766 -60.132 0.0468209 +96.8767 -169.362 1.74962 +-134.784 77.9146 3.65673 +66.347 189.709 2.36933 +166.495 -50.8575 4.68468 +179.2 19.0279 0.327481 +-40.549 39.3593 4.35018 +-32.836 6.44796 3.87658 +33.0268 109.848 2.54092 +-187.266 -5.19188 3.00861 +-47.3983 136.538 4.60641 +-16.7599 140.283 3.31736 +-138.845 -119.747 4.13256 +-149.136 172.791 2.4619 +0.00640806 -37.6626 2.04309 +-180.966 -62.8882 1.78309 +58.3937 -36.6897 3.77623 +-135.158 -88.6754 0.865781 +174.69 -178.549 3.77862 +-30.5019 24.7249 3.93779 +-93.9643 -134.586 0.845307 +-153.681 -166.074 3.13581 +-73.4283 99.3156 3.90024 +-100.637 29.9208 4.53604 +61.7003 -173.127 2.03612 +198.812 -9.67982 2.27405 +-37.8776 132.968 0.50397 +73.447 35.0661 1.31449 +94.898 104.329 0.998115 +-80.3772 6.61785 3.11684 +-14.9632 -78.3592 4.44229 +18.9633 -10.7346 0.0212741 +-81.7211 -159.87 1.60342 +148.2 152.149 2.84546 +175.073 115.032 1.11671 +-34.6071 -122.078 1.10186 +-101.639 59.8459 3.12839 +133.427 100.164 1.54648 +37.7553 -194.677 0.232704 +-155.627 -114.828 1.72799 +-33.9861 134.519 4.04095 +155.279 89.9022 1.77799 +195.409 91.6041 3.25648 +147.559 -180.122 2.60897 +62.591 47.5143 2.29738 +140.513 136.851 4.36479 +0.358935 -175 0.594302 +-99.4775 75.2715 4.76214 +-94.1548 198.99 2.73408 +-8.98291 -182.394 3.28874 +-74.4637 -44.1547 0.363914 +-184.561 -120.879 4.8049 +107.043 21.3604 4.74752 +126.92 -118.121 4.092 +-25.5652 90.5964 2.37439 +-88.714 -125.613 1.6308 +-63.7139 -176.429 4.13529 +-188.442 -128.885 0.391819 +-189.452 -147.914 1.71488 +-171.846 70.8118 4.1026 +-16.001 -66.089 0.671801 +63.1202 -36.9759 0.864783 +-115.519 -52.5835 4.70282 +-33.6409 -72.7818 3.78932 +-143.044 -145.422 0.969758 +-68.6574 44.5294 2.36083 +-45.0868 174.994 4.06441 +26.028 105.817 4.20888 +78.1137 137.162 4.34072 +-51.0745 -125.647 4.69265 +82.8366 -197.439 1.99263 +-154.139 -143.695 0.281635 +-6.72277 -74.5127 1.33764 +120.495 -98.2873 3.41713 +175.074 -195.142 4.12907 +19.6032 -117.561 0.770857 +-5.40327 71.3057 2.70727 +-99.5867 -3.54152 0.532623 +-162.425 -66.8311 4.00904 +-88.0717 -119.573 0.870613 +-85.5111 -144.161 4.40607 +-29.2065 15.2491 4.97933 +96.2809 37.7799 2.39529 +197.994 144.791 1.40149 +-197.148 18.1617 1.08991 +-114.709 -51.5123 3.83495 +156.597 10.1562 1.26741 +-46.9446 -173.262 2.52257 +86.2243 -130.652 2.99227 +166.651 190.071 4.39137 +-177.51 -140.28 0.822481 +37.7388 -187.794 2.9574 +-124.481 -189.448 1.66091 +-179.69 2.17599 1.63583 +38.4717 114.295 1.67148 +186.959 -198.512 2.73762 +-2.88438 108.283 2.19508 +23.8536 -190.324 4.10827 +93.2015 11.4819 2.68608 +83.2728 -149.137 2.26922 +142.993 -197.827 2.55034 +155.199 -132.029 0.522073 +165.752 104.563 1.46606 +-32.0722 -162.564 1.71993 +-117.777 -31.6971 4.70083 +-116.29 102.021 4.53782 +191.994 -78.9689 2.00176 +-198.33 96.6377 4.79993 +13.1517 25.2997 3.46495 diff --git a/Apollonius_graph_2/test/Apollonius_graph_2/data/traits.dat b/Apollonius_graph_2/test/Apollonius_graph_2/data/traits.dat new file mode 100644 index 00000000000..f98f2043c84 --- /dev/null +++ b/Apollonius_graph_2/test/Apollonius_graph_2/data/traits.dat @@ -0,0 +1,4 @@ +10.0 -10 20 +9 -9 19. +1000000 -1000000 0 +10.0 5.0 5 diff --git a/Apollonius_graph_2/test/Apollonius_graph_2/include/IO/Null_output_stream.h b/Apollonius_graph_2/test/Apollonius_graph_2/include/IO/Null_output_stream.h new file mode 100644 index 00000000000..31e3225bbde --- /dev/null +++ b/Apollonius_graph_2/test/Apollonius_graph_2/include/IO/Null_output_stream.h @@ -0,0 +1,51 @@ +// ====================================================================== +// +// Copyright (c) 2003 The CGAL Consortium +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------- +// +// release : +// release_date : +// +// file : include/CGAL/IO/Null_output_stream.h +// package : IO +// source : $URL$ +// revision : $Id$ +// revision_date : $Date$ +// author(s) : Menelaos Karavelas +// +// coordinator : +// +// ====================================================================== + + +#ifndef CGAL_NULL_OUTPUT_STREAM_H +#define CGAL_NULL_OUTPUT_STREAM_H + + +namespace CGAL { + + +struct Null_output_stream {}; + +#if defined(__INTEL_COMPILER) +template +Null_output_stream& +operator<<(Null_output_stream& nos, const T&); +#endif + +template +Null_output_stream& +operator<<(Null_output_stream& nos, const T&) +{ + return nos; +} + + +} //namespace CGAL + +#endif // CGAL_NULL_OUTPUT_STREAM_H diff --git a/Apollonius_graph_2/test/Apollonius_graph_2/include/test.h b/Apollonius_graph_2/test/Apollonius_graph_2/include/test.h new file mode 100644 index 00000000000..6d973d3c6df --- /dev/null +++ b/Apollonius_graph_2/test/Apollonius_graph_2/include/test.h @@ -0,0 +1,984 @@ +#ifndef CGAL_APOLLONIUS_GRAPH_2_TEST_H +#define CGAL_APOLLONIUS_GRAPH_2_TEST_H + +#include +#include +#include + +#include // this is done in order to avoid error +// when the Segment_2_Segment_2_intersection.h file is included from +// the Triangulation_euclidean_traits_2.h file. + +#include +#include +#include +#include +//#include + +#include "IO/Null_output_stream.h" + + +namespace CGAL { + +bool dummy(bool b) { + assert( b ); + return b; +} + +#if defined(__INTEL_COMPILER) +template +bool test_traits_base(const Traits& = Traits()); + +template +bool test_algo_generic(InputStream& is, const AG& = AG()); + +template +bool test_algo(InputStream& is, const Kernel& = Kernel(), + const Method_tag& = Method_tag()); + +template +bool test_hierarchy_algo(InputStream& is, const Kernel& = Kernel(), + const Method_tag& = Method_tag()); + +template +bool test_filtered_traits_algo(InputStream& is, + const CK& = CK(), const CKM& = CKM(), + const EK& = EK(), + const EKM& = EKM()); + +template +bool test_filtered_traits_hierarchy_algo(InputStream& is, + const CK& = CK(), + const CKM& = CKM(), + const EK& = EK(), + const EKM& = EKM()); +#endif + + +template +struct Traits_tester +{ + typedef Apollonius_graph_traits_2 Traits; + + bool operator()(int = 0) const { + return test_traits_base( Traits() ); + } +}; + +template +struct Filtered_traits_tester +{ + typedef + Apollonius_graph_filtered_traits_2 + Traits; + + bool operator()(int = 0) const { + return test_traits_base( Traits() ); + } +}; + + +//template +#if defined(__INTEL_COMPILER) +template +bool test_traits_base(const Traits&) +#else +template +bool test_traits_base(const Traits& = Traits()) +#endif + //bool test_traits(InputStream& is) +{ + // typedef Apollonius_graph_traits_2 Traits; + + // testing typedefs + //-------------------------------------------------------------------- + typedef typename Traits::FT FT; + typedef typename Traits::RT RT; + typedef typename Traits::Point_2 Point_2; + typedef typename Traits::Site_2 Site_2; + typedef typename Traits::Object_2 Object_2; + typedef typename Traits::Line_2 Line_2; + typedef typename Traits::Ray_2 Ray_2; + typedef typename Traits::Segment_2 Segment_2; + // typedef typename Traits::Parabola_segment_2 Parabola_segment_2; + // typedef typename Traits::Hyperbola_2 Hyperbola_2; + // typedef typename Traits::Hyperbola_ray_2 Hyperbola_ray_2; + // typedef typename Traits::Hyperbola_segment_2 Hyperbola_segment_2; + + typedef typename Traits::Construct_object_2 Construct_object_2; + typedef typename Traits::Assign_2 Assign_2; + + typedef typename Traits::Construct_Apollonius_vertex_2 + Construct_Apollonius_vertex_2; + typedef typename Traits::Construct_Apollonius_site_2 + Construct_Apollonius_site_2; + + typedef typename Traits::Compare_x_2 Compare_x_2; + typedef typename Traits::Compare_y_2 Compare_y_2; + typedef typename Traits::Compare_weight_2 Compare_weight_2; + typedef typename Traits::Orientation_2 Orientation_2; + typedef typename Traits::Is_hidden_2 Is_hidden_2; + typedef typename Traits::Oriented_side_of_bisector_2 + Oriented_side_of_bisector_2; + typedef typename Traits::Vertex_conflict_2 Vertex_conflict_2; + typedef typename Traits::Finite_edge_interior_conflict_2 + Finite_edge_interior_conflict_2; + typedef typename Traits::Infinite_edge_interior_conflict_2 + Infinite_edge_interior_conflict_2; + typedef typename Traits::Is_degenerate_edge_2 + Is_degenerate_edge_2; + + CGAL_USE_TYPE(FT); + CGAL_USE_TYPE(RT); + CGAL_USE_TYPE(Object_2); + CGAL_USE_TYPE(Line_2); + CGAL_USE_TYPE(Ray_2); + CGAL_USE_TYPE(Segment_2); + + // testing constructors + //-------------------------------------------------------------------- + Traits tr; + // tr = Traits(); // to avoid compiler-warning that variable was not initialized; + Traits tr1(tr); + tr1 = tr; + tr = tr1; + + + // testing access to predicates objects + //-------------------------------------------------------------------- + Compare_x_2 compare_x = tr.compare_x_2_object(); + Compare_y_2 compare_y = tr.compare_y_2_object(); + Compare_weight_2 compare_w = tr.compare_weight_2_object(); + Orientation_2 orientation = tr.orientation_2_object(); + Is_hidden_2 is_hidden = tr.is_hidden_2_object(); + Oriented_side_of_bisector_2 oriented_side_of_bisector = + tr.oriented_side_of_bisector_2_object(); + Vertex_conflict_2 vertex_conflict = tr.vertex_conflict_2_object(); + Finite_edge_interior_conflict_2 finite_edge_interior_conflict = + tr.finite_edge_interior_conflict_2_object(); + Infinite_edge_interior_conflict_2 infinite_edge_interior_conflict = + tr.infinite_edge_interior_conflict_2_object(); + Is_degenerate_edge_2 is_degenerate_edge = + tr.is_degenerate_edge_2_object(); + + // testing access to constructor objects + //-------------------------------------------------------------------- + Assign_2 assign_2 = tr.assign_2_object(); + CGAL_USE(assign_2); + + Construct_object_2 construct_object_2 = + tr.construct_object_2_object(); + CGAL_USE(construct_object_2); + + Construct_Apollonius_vertex_2 apollonius_vertex = + tr.construct_Apollonius_vertex_2_object(); + CGAL_USE(apollonius_vertex); + + Construct_Apollonius_site_2 apollonius_site = + tr.construct_Apollonius_site_2_object(); + CGAL_USE(apollonius_site); + + // testing correctness of predicates; + //-------------------------------------------------------------------- + bool b; + Point_2 p1__icc(10.0,-10); + Site_2 + wp1(p1__icc,20), + wp2(Point_2(9,-9),19.), + wp3(Point_2(1000000,-1000000),0), + wp4(Point_2(10.0,5.0),5), + wp5; + + // testing coordinate comparison + //-------------------------------------------------------------------- + assert( compare_x(wp1, wp1) == EQUAL ); + assert( compare_y(wp1, wp1) == EQUAL ); + assert( compare_w(wp1, wp1) == EQUAL ); + + assert( compare_x(wp1, wp2) == LARGER ); + assert( compare_y(wp1, wp2) == SMALLER ); + assert( compare_w(wp1, wp2) == LARGER ); + + // testing orientation + //-------------------------------------------------------------------- + assert( orientation(wp1, wp2, wp3) == COLLINEAR ); + + // testing is_hidden + //-------------------------------------------------------------------- + assert( is_hidden(wp1, wp4) == true ); + assert( is_hidden(wp4, wp1) == false ); + + // testing oriented_side_of_bisector + //-------------------------------------------------------------------- + Point_2 p = wp2.point(); + assert( oriented_side_of_bisector(wp1, wp3, p) == + ON_POSITIVE_SIDE ); + + + // testing vertex_conflict + //-------------------------------------------------------------------- + + // first we consider the case where all vertices are finite + wp1 = Site_2(Point_2(0,0),0); + wp2 = Site_2(Point_2(1,1),1); + wp3 = Site_2(Point_2(2,4),4); + wp4 = Site_2(Point_2(3,9),9); + + assert( vertex_conflict(wp1, wp2, wp3, wp4) == ZERO ); + assert( vertex_conflict(wp2, wp3, wp4, wp1) == ZERO ); + + wp4 = Site_2(Point_2(3,9),9.0001); + + assert( vertex_conflict(wp1, wp2, wp3, wp4) == NEGATIVE ); + assert( vertex_conflict(wp2, wp3, wp4, wp1) == POSITIVE ); + + + // then we consider the case where v3 is the vertex at infinity + wp1 = Site_2(Point_2(1,100),49); + wp2 = Site_2(Point_2(0,-100),50); + + wp3 = Site_2(Point_2(0,0),0); + assert( vertex_conflict(wp1, wp2, wp3) == POSITIVE ); + + wp3 = Site_2(Point_2(-100000,0),0); + assert( vertex_conflict(wp1, wp2, wp3) == POSITIVE ); + + wp3 = Site_2(Point_2(100000,0),1000); + assert( vertex_conflict(wp1, wp2, wp3) == NEGATIVE ); + + wp3 = Site_2(Point_2(-1,0),51); + assert( vertex_conflict(wp1, wp2, wp3) == NEGATIVE ); + + wp3 = Site_2(Point_2(-1,200),51); + assert( vertex_conflict(wp1, wp2, wp3) == POSITIVE ); + + wp3 = Site_2(Point_2(-1,-200),51); + assert( vertex_conflict(wp1, wp2, wp3) == POSITIVE ); + + + // testing finite_edge_interior_conflict + //-------------------------------------------------------------------- + + wp1 = Site_2(Point_2(0,-100),50); + wp2 = Site_2(Point_2(0,100),51); + wp3 = Site_2(Point_2(-150,0),49); + wp4 = Site_2(Point_2(150,0),48); + + + // first we look at the case where all vertices of the edge are + // finite... + + // endpoints are not in conflict but the interior is + wp5 = Site_2(Point_2(0,-49),0); + + assert( vertex_conflict(wp1, wp2, wp3, wp5) == POSITIVE ); + assert( vertex_conflict(wp1, wp4, wp2, wp5) == POSITIVE ); + + b = finite_edge_interior_conflict(wp1, wp2, wp3, wp4, wp5, false); + + assert( b ); + + // both endpoints and interior are in conflict + wp5 = Site_2(Point_2(0,-49),10); + + assert( vertex_conflict(wp1, wp2, wp3, wp5) == NEGATIVE ); + assert( vertex_conflict(wp1, wp4, wp2, wp5) == NEGATIVE ); + + b = finite_edge_interior_conflict(wp1, wp2, wp3, wp4, wp5, true); + + assert( b ); + + // endpoints are in conflict but the interior isn't + wp5 = Site_2(Point_2(0,-150),99); + + assert( vertex_conflict(wp1, wp2, wp3, wp5) == NEGATIVE ); + assert( vertex_conflict(wp1, wp4, wp2, wp5) == NEGATIVE ); + + b = finite_edge_interior_conflict(wp1, wp2, wp3, wp4, wp5, true); + + assert( !b ); + + // finally endpoints are not in conflict and interior is not in + // conflict + wp5 = Site_2(Point_2(0,-150),70); + + assert( vertex_conflict(wp1, wp2, wp3, wp5) == POSITIVE ); + assert( vertex_conflict(wp1, wp4, wp2, wp5) == POSITIVE ); + + b = finite_edge_interior_conflict(wp1, wp2, wp3, wp4, wp5, true); + + assert( !b ); + + + // then we consider the case where v4 is the vertex at infinity + wp1 = Site_2(Point_2(0,-100),50); + wp2 = Site_2(Point_2(1,100),49); + wp3 = Site_2(Point_2(-150,0),51); + + // endpoints are not in conflict but interior is + wp4 = Site_2(Point_2(0,-48),0); + assert( vertex_conflict(wp1, wp2, wp3, wp4) == POSITIVE ); + assert( vertex_conflict(wp2, wp1, wp4) == POSITIVE ); + + b = finite_edge_interior_conflict(wp1, wp2, wp3, wp4, false); + assert( b ); + + // both endpoints and interior are in conflict + wp4 = Site_2(Point_2(-1,0),51); + assert( vertex_conflict(wp1, wp2, wp3, wp4) == NEGATIVE ); + assert( vertex_conflict(wp2, wp1, wp4) == NEGATIVE ); + + b = finite_edge_interior_conflict(wp1, wp2, wp3, wp4, true); + assert( b ); + + // endpoints are in conflict but interior isn't + wp4 = Site_2(Point_2(-1,200),149); + assert( vertex_conflict(wp1, wp2, wp3, wp4) == NEGATIVE ); + assert( vertex_conflict(wp2, wp1, wp4) == NEGATIVE ); + + b = finite_edge_interior_conflict(wp1, wp2, wp3, wp4, true); + assert( !b ); + + // neither the endpoints nor the interior are in conflict + wp4 = Site_2(Point_2(-1,200),51); + + assert( vertex_conflict(wp1, wp2, wp3, wp4) == POSITIVE ); + assert( vertex_conflict(wp2, wp1, wp4) == POSITIVE ); + + b = finite_edge_interior_conflict(wp1, wp2, wp3, wp4, false); + assert( !b ); + + + // finally consider the case where both v3 and v4 are the vertex at + // infinity. + + wp1 = Site_2(Point_2(10,0),5); + wp2 = Site_2(Point_2(100,0),50); + + // endpoints are not in conflict but the interior is + wp3 = Site_2(Point_2(20,0),0); + + assert( vertex_conflict(wp1, wp2, wp3) == POSITIVE ); + assert( vertex_conflict(wp2, wp1, wp3) == POSITIVE ); + + b = finite_edge_interior_conflict(wp1, wp2, wp3, false); + assert( b ); + + // endpoints are in conflict and so is the interior + wp3 = Site_2(Point_2(20,0),10); + + assert( vertex_conflict(wp1, wp2, wp3) == NEGATIVE ); + assert( vertex_conflict(wp2, wp1, wp3) == NEGATIVE ); + + b = finite_edge_interior_conflict(wp1, wp2, wp3, true); + assert( b ); + + // both the endpoints and the interior are not in conflict + wp3 = Site_2(Point_2(4,0),2); + + assert( vertex_conflict(wp1, wp2, wp3) == POSITIVE ); + assert( vertex_conflict(wp2, wp1, wp3) == POSITIVE ); + + b = finite_edge_interior_conflict(wp1, wp2, wp3, false); + assert( !b ); + + // the endpoints are in conflict but the interior isn't + wp3 = Site_2(Point_2(4,0),3); + + assert( vertex_conflict(wp1, wp2, wp3) == NEGATIVE ); + assert( vertex_conflict(wp2, wp1, wp3) == NEGATIVE ); + + b = finite_edge_interior_conflict(wp1, wp2, wp3, true); + assert( !b ); + + // testing infinite_edge_interior_conflict + //-------------------------------------------------------------------- + + + wp2 = Site_2(Point_2(0,0),100); + wp3 = Site_2(Point_2(-100,200),5); + wp4 = Site_2(Point_2(100,300),4); + + // the endpoints are not in conflict but the interior is + wp5 = Site_2(Point_2(0,-150),2); + + assert( vertex_conflict(wp2, wp3, wp5) == POSITIVE ); + assert( vertex_conflict(wp4, wp2, wp5) == POSITIVE ); + + b = infinite_edge_interior_conflict(wp2, wp3, wp4, wp5, false); + assert( b ); + + + // the endpoints are in conflict but the interior isn't + wp5 = Site_2(Point_2(0,150),150); + + assert( vertex_conflict(wp2, wp3, wp5) == NEGATIVE ); + assert( vertex_conflict(wp4, wp2, wp5) == NEGATIVE ); + + b = infinite_edge_interior_conflict(wp2, wp3, wp4, wp5, true); + assert( !b ); + + + // the endpoints are in conflict as well as the interior + wp5 = Site_2(Point_2(0,-150),150); + + assert( vertex_conflict(wp2, wp3, wp5) == NEGATIVE ); + assert( vertex_conflict(wp4, wp2, wp5) == NEGATIVE ); + + b = infinite_edge_interior_conflict(wp2, wp3, wp4, wp5, true); + assert( b ); + + + // neither the endpoints nor the interior are in conflict + wp5 = Site_2(Point_2(0,150),50); + + assert( vertex_conflict(wp2, wp3, wp5) == POSITIVE ); + assert( vertex_conflict(wp4, wp2, wp5) == POSITIVE ); + + b = infinite_edge_interior_conflict(wp2, wp3, wp4, wp5, false); + assert( !b ); + + + + // testing is_degenerate_edge + //-------------------------------------------------------------------- + wp1 = Site_2(Point_2(2,4),4); + wp2 = Site_2(Point_2(10,100),100); + wp3 = Site_2(Point_2(5,25),25); + wp4 = Site_2(Point_2(20,400),400); + + b = is_degenerate_edge(wp1, wp2, wp3, wp4); + + assert( b ); + + wp1 = Site_2(Point_2(2,4),4); + wp2 = Site_2(Point_2(10,100),100); + wp3 = Site_2(Point_2(5,25),25); + wp4 = Site_2(Point_2(20,400),399); + + b = is_degenerate_edge(wp1, wp2, wp3, wp4); + + assert( !b ); + + return true; +} + + +#if defined(__INTEL_COMPILER) +template +bool test_algo_generic(InputStream& is, const AG&) +#else +template +bool test_algo_generic(InputStream& is) +#endif +{ + typedef AG Apollonius_graph; + typedef typename Apollonius_graph::Geom_traits Traits; + + // testing typedefs + //-------------------------------------------------------------------- + typedef typename Apollonius_graph::Data_structure Data_structure; + typedef typename Apollonius_graph::Geom_traits Geom_traits; + typedef typename Apollonius_graph::Point_2 Point_2; + typedef typename Apollonius_graph::Site_2 Site_2; + + typedef typename Apollonius_graph::Edge Edge; + typedef typename Apollonius_graph::Vertex_handle Vertex_handle; + typedef typename Apollonius_graph::Face_handle Face_handle; + + typedef typename Apollonius_graph::Edge_circulator Edge_circulator; + typedef typename Apollonius_graph::Vertex_circulator Vertex_circulator; + typedef typename Apollonius_graph::Face_circulator Face_circulator; + + typedef typename Apollonius_graph::All_vertices_iterator + All_vertices_iterator; + typedef typename Apollonius_graph::Finite_vertices_iterator + Finite_vertices_iterator; + + typedef typename Apollonius_graph::All_faces_iterator + All_faces_iterator; + typedef typename Apollonius_graph::Finite_faces_iterator + Finite_faces_iterator; + + typedef typename Apollonius_graph::All_edges_iterator + All_edges_iterator; + typedef typename Apollonius_graph::Finite_edges_iterator + Finite_edges_iterator; + + typedef typename Apollonius_graph::Sites_iterator Sites_iterator; + typedef typename Apollonius_graph::Visible_sites_iterator + Visible_sites_iterator; + typedef typename Apollonius_graph::Hidden_sites_iterator + Hidden_sites_iterator; + + typedef typename Apollonius_graph::size_type size_type; + + CGAL_USE_TYPE(Data_structure); + CGAL_USE_TYPE(Point_2); + CGAL_USE_TYPE(Edge); + + Null_output_stream nos; + + // testing creation/constructors + //-------------------------------------------------------------------- + + Apollonius_graph ag; + Traits gt = Traits(); + Apollonius_graph ag1(gt); + Apollonius_graph ag2(ag); + + std::vector wp_list; + Site_2 wp; + while ( is >> wp ) { + wp_list.push_back(wp); + } + + Apollonius_graph ag3(wp_list.begin(), wp_list.end(), Traits()); + + ag = ag3; + ag2 = ag3; + + // testing access functions + //-------------------------------------------------------------------- + Geom_traits tr = ag.geom_traits(); + size_type num_vertices = ag.number_of_vertices(); + size_type num_all = num_vertices + ag.number_of_hidden_sites(); + // passing this to a dummy function to avoid warning when + // CGAL_NO_ASSERTIONS is defined. + dummy( static_cast(num_all) == wp_list.size() ); + + CGAL_USE(tr); + + Face_handle inf_f = ag.infinite_face(); + Vertex_handle v1 = ag.infinite_vertex(); + Vertex_handle v2 = ag.finite_vertex(); + + // testing traversal - iterators + //-------------------------------------------------------------------- + + // finite faces, edges and vertices + Finite_vertices_iterator fvit = ag.finite_vertices_begin(); + size_type n_fvertices = 0; + for (; fvit != ag.finite_vertices_end(); ++fvit) { + n_fvertices++; + } + assert( n_fvertices == num_vertices ); + + Finite_edges_iterator feit = ag.finite_edges_begin(); + size_type n_fedges = 0; + for (; feit != ag.finite_edges_end(); ++feit) { + n_fedges++; + } + + Finite_faces_iterator ffit = ag.finite_faces_begin(); + size_type n_ffaces = 0; + for (; ffit != ag.finite_faces_end(); ++ffit) { + n_ffaces++; + } + + // all faces, edges and vertices + All_vertices_iterator avit = ag.all_vertices_begin(); + size_type n_avertices = 0; + for (; avit != ag.all_vertices_end(); ++avit) { + n_avertices++; + } + assert( n_avertices == num_vertices + 1 ); + + All_edges_iterator aeit = ag.all_edges_begin(); + size_type n_aedges = 0; + for (; aeit != ag.all_edges_end(); ++aeit) { + n_aedges++; + } + + All_faces_iterator afit = ag.all_faces_begin(); + size_type n_afaces = 0; + for (; afit != ag.all_faces_end(); ++afit) { + n_afaces++; + } + + + assert( 2 * n_aedges == 3 * n_afaces ); + assert( n_avertices - n_aedges + n_afaces == 2 ); + + // site iterators + size_type n_sites(0), n_hidden_sites(0), n_visible_sites(0); + + for (Sites_iterator sit = ag.sites_begin(); + sit != ag.sites_end(); sit++) { + n_sites++; + nos << *sit; + nos << sit->point(); + } + + for (Hidden_sites_iterator sit = ag.hidden_sites_begin(); + sit != ag.hidden_sites_end(); sit++) { + n_hidden_sites++; + nos << *sit; + nos << sit->point(); + } + + for (Visible_sites_iterator sit = ag.visible_sites_begin(); + sit != ag.visible_sites_end(); sit++) { + n_visible_sites++; + nos << *sit; + nos << sit->point(); + } + + assert( n_sites == n_visible_sites + n_hidden_sites ); + + // testing traversal - circulators + //-------------------------------------------------------------------- + + // vertex circulators + for (avit = ag.all_vertices_begin(); + avit != ag.all_vertices_end(); + ++avit) { + Vertex_handle v(avit); + Vertex_circulator vc_start = ag.incident_vertices(v); + Vertex_circulator vc = vc_start; + size_type deg = 0; + do { + deg++; + vc++; + } while ( vc != vc_start ); + + assert( deg == ag.data_structure().degree(v) ); + } + + for (avit = ag.all_vertices_begin(); + avit != ag.all_vertices_end(); + ++avit) { + Vertex_handle v(avit); + Vertex_circulator vc_start = ag.incident_vertices(v, v->face()); + Vertex_circulator vc = vc_start; + size_type deg = 0; + do { + deg++; + vc++; + } while ( vc != vc_start ); + + assert( deg == ag.data_structure().degree(v) ); + } + + // face circulators + for (avit = ag.all_vertices_begin(); + avit != ag.all_vertices_end(); + ++avit) { + Vertex_handle v(avit); + Face_circulator fc_start = ag.incident_faces(v); + Face_circulator fc = fc_start; + size_type deg = 0; + do { + deg++; + fc++; + } while ( fc != fc_start ); + + assert( deg == ag.data_structure().degree(v) ); + } + + for (avit = ag.all_vertices_begin(); + avit != ag.all_vertices_end(); + ++avit) { + Vertex_handle v(avit); + Face_circulator fc_start = ag.incident_faces(v, v->face()); + Face_circulator fc = fc_start; + size_type deg = 0; + do { + deg++; + fc++; + } while ( fc != fc_start ); + + assert( deg == ag.data_structure().degree(v) ); + } + + // edge circulators + for (avit = ag.all_vertices_begin(); + avit != ag.all_vertices_end(); + ++avit) { + Vertex_handle v(avit); + Edge_circulator ec_start = ag.incident_edges(v); + Edge_circulator ec = ec_start; + size_type deg = 0; + do { + deg++; + ec++; + } while ( ec != ec_start ); + + assert( deg == ag.data_structure().degree(v) ); + } + + for (avit = ag.all_vertices_begin(); + avit != ag.all_vertices_end(); + ++avit) { + Vertex_handle v(avit); + Edge_circulator ec_start = ag.incident_edges(v, v->face()); + Edge_circulator ec = ec_start; + size_type deg = 0; + do { + deg++; + ec++; + } while ( ec != ec_start ); + + assert( deg == ag.data_structure().degree(v) ); + } + + + // testing predicates + //-------------------------------------------------------------------- + assert( ag.is_infinite(inf_f) ); + assert( ag.is_infinite(v1) ); + assert( !ag.is_infinite(v2) ); + { + Edge_circulator ec = ag.incident_edges(ag.infinite_vertex()); + assert( ag.is_infinite(*ec) ); + assert( ag.is_infinite(ec) ); + assert( ag.is_infinite(ec->first, ec->second) ); + } + + // testing insertion + //-------------------------------------------------------------------- + ag.clear(); + ag.insert(wp_list.begin(), wp_list.end()); + assert( ag.is_valid() ); + + ag.clear(); + typename std::vector::iterator it; + for (it = wp_list.begin(); it != wp_list.end(); ++it) { + ag.insert(*it); + } + assert( ag.is_valid() ); + + { + ag.clear(); + Vertex_handle v; + typename std::vector::iterator it; + for (it = wp_list.begin(); it != wp_list.end(); ++it) { + if ( it == wp_list.begin() ) { + v = ag.insert(*it); + } else { + v = ag.insert(*it, v); + } + } + assert( ag.is_valid() ); + } + + // testing removal + //-------------------------------------------------------------------- + ag.clear(); + ag.insert(wp_list.begin(), wp_list.end()); + assert( ag.is_valid() ); + { + while ( ag.number_of_vertices() > 0 ) { + Vertex_handle v(ag.finite_vertices_begin()); + ag.remove(v); + assert( ag.is_valid() ); + } + } + + // testing nearest neighbor location + //-------------------------------------------------------------------- + ag.clear(); + ag.insert(wp_list.begin(), wp_list.end()); + assert( ag.is_valid() ); + for (fvit = ag.finite_vertices_begin(); + fvit != ag.finite_vertices_end(); ++fvit) { + Site_2 wp = fvit->site(); + Vertex_handle nn = ag.nearest_neighbor(wp.point()); + assert( wp == nn->site() ); + } + + // testing swap + //-------------------------------------------------------------------- + ag.clear(); + ag.swap(ag2); + assert( ag.number_of_vertices() + + ag.number_of_hidden_sites() == wp_list.size() ); + assert( ag2.number_of_vertices() == 0 ); + + + // drawing methods + //-------------------------------------------------------------------- + ag.draw_primal(nos); + ag.draw_dual(nos); + +#if 0 + for (fvit = ag.finite_vertices_begin(); + fvit != ag.finite_vertices_end(); ++fvit) { + ag.draw_primal_vertex(fvit, nos); + } + + for (ffit = ag.finite_faces_begin(); + ffit != ag.finite_faces_end(); ++ffit) { + ag.draw_dual_vertex(ffit, nos); + } +#endif + + for (feit = ag.finite_edges_begin(); + feit != ag.finite_edges_end(); ++feit) { + ag.draw_primal_edge(feit, nos); + ag.draw_dual_edge(feit, nos); + } + + for (aeit = ag.all_edges_begin(); + aeit != ag.all_edges_end(); ++aeit) { + ag.draw_primal_edge(aeit, nos); + } + +#if 0 + for (afit = ag.all_faces_begin(); + afit != ag.all_faces_end(); ++afit) { + ag.draw_primal_face(afit, nos); + } + + for (avit = ag.all_vertices_begin(); + avit != ag.all_vertices_end(); ++avit) { + ag.draw_dual_face(avit, nos); + } +#endif + + // file I/O methods + //-------------------------------------------------------------------- + { + std::ofstream ofs("ag_testsuite.tmp"); + assert( ofs ); + ag.file_output(ofs); + ofs.close(); + + std::ifstream ifs("ag_testsuite.tmp"); + assert( ifs ); + ag.file_input(ifs); + ifs.close(); + assert( ag.is_valid() ); + } + { + std::ofstream ofs("ag_testsuite.tmp"); + assert( ofs ); + ofs << ag; + ofs.close(); + + std::ifstream ifs("ag_testsuite.tmp"); + assert( ifs ); + ifs >> ag; + ifs.close(); + assert( ag.is_valid() ); + } + return true; +} + +#if defined(__INTEL_COMPILER) +template +bool test_algo(InputStream& is, const Kernel&, + const Method_tag&) +#else +template +bool test_algo(InputStream& is) +#endif +{ + typedef Apollonius_graph_traits_2 Traits; +#if defined( _MSC_VER ) + // Patch for the Microsoft compiler so that it does not produce the + // nasty warning about decorated name length + // Basically what I do here is create typedefs for the default + // template paramaters so as to give them shorter names + typedef Apollonius_graph_vertex_base_2 Vb; + typedef Triangulation_face_base_2 Fb; + typedef Triangulation_data_structure_2 Agds; + typedef Apollonius_graph_2 Apollonius_graph; +#else + typedef Apollonius_graph_2 Apollonius_graph; +#endif + + return test_algo_generic(is); +} + +#if defined(__INTEL_COMPILER) +template +bool test_hierarchy_algo(InputStream& is, const Kernel&, const Method_tag&) +#else +template +bool test_hierarchy_algo(InputStream& is) +#endif +{ + typedef Apollonius_graph_traits_2 Traits; +#if defined( _MSC_VER ) + // Patch for the Microsoft compiler so that it does not produce the + // nasty warning about decorated name length + // Basically what I do here is create typedefs for the default + // template paramaters so as to give them shorter names + typedef Apollonius_graph_vertex_base_2 Vb; + typedef Apollonius_graph_hierarchy_vertex_base_2 HVb; + typedef Triangulation_face_base_2 Fb; + typedef Triangulation_data_structure_2 Agds; + typedef Apollonius_graph_hierarchy_2 + Apollonius_graph_hierarchy; +#else + typedef Apollonius_graph_hierarchy_2 Apollonius_graph_hierarchy; +#endif + + return test_algo_generic(is); +} + + + +#if defined(__INTEL_COMPILER) +template +bool test_filtered_traits_algo(InputStream& is, const CK&, + const CKM&, const EK&, const EKM&) +#else +template +bool test_filtered_traits_algo(InputStream& is) +#endif +{ + typedef Apollonius_graph_filtered_traits_2 Traits; +#if defined( _MSC_VER ) + // Patch for the Microsoft compiler so that it does not produce the + // nasty warning about decorated name length + // Basically what I do here is create typedefs for the default + // template paramaters so as to give them shorter names + typedef Apollonius_graph_vertex_base_2 Vb; + typedef Triangulation_face_base_2 Fb; + typedef Triangulation_data_structure_2 Agds; + typedef Apollonius_graph_2 Apollonius_graph; +#else + typedef Apollonius_graph_2 Apollonius_graph; +#endif + + return test_algo_generic(is); +} + +#if defined(__INTEL_COMPILER) +template +bool test_filtered_traits_hierarchy_algo(InputStream& is, + const CK&, const CKM&, + const EK&, const EKM&) +#else +template +bool test_filtered_traits_hierarchy_algo(InputStream& is) +#endif +{ + typedef Apollonius_graph_filtered_traits_2 Traits; +#if defined( _MSC_VER ) + // Patch for the Microsoft compiler so that it does not produce the + // nasty warning about decorated name length + // Basically what I do here is create typedefs for the default + // template paramaters so as to give them shorter names + typedef Apollonius_graph_vertex_base_2 Vb; + typedef Apollonius_graph_hierarchy_vertex_base_2 HVb; + typedef Triangulation_face_base_2 Fb; + typedef Triangulation_data_structure_2 Agds; + typedef Apollonius_graph_hierarchy_2 + Apollonius_graph_hierarchy; +#else + typedef Apollonius_graph_hierarchy_2 Apollonius_graph_hierarchy; +#endif + + return test_algo_generic(is); +} + + + +} //namespace CGAL + + + +#endif // CGAL_APOLLONIUS_GRAPH_2_TEST_H diff --git a/Apollonius_graph_2/test/Apollonius_graph_2/include/test_three_sites.h b/Apollonius_graph_2/test/Apollonius_graph_2/include/test_three_sites.h new file mode 100644 index 00000000000..d8797deda4c --- /dev/null +++ b/Apollonius_graph_2/test/Apollonius_graph_2/include/test_three_sites.h @@ -0,0 +1,103 @@ +#ifndef TEST_AG_THREE_SITES_H +#define TEST_AG_THREE_SITES_H 1 + +typedef enum { MIDDLE_ON_CONVEX_HULL, MIDDLE_NOT_ON_CONVEX_HULL } Middle_t; + +template +int number_of_infinite_edges(const AG& ag, typename AG::Vertex_handle v) +{ + int count(0); + + typename AG::Edge_circulator ec_start = ag.incident_edges(v); + typename AG::Edge_circulator ec = ec_start; + + do { + if ( ag.is_infinite(*ec) ) { ++count; } + ++ec; + } while ( ec != ec_start ); + + return count; +} + +template +int number_of_infinite_faces(const AG& ag, typename AG::Vertex_handle v) +{ + int count(0); + + typename AG::Face_circulator fc_start = ag.incident_faces(v); + typename AG::Face_circulator fc = fc_start; + + do { + if ( ag.is_infinite(fc) ) { ++count; } + ++fc; + } while ( fc != fc_start ); + + return count; +} + +template +int number_of_infinite_vertices(const AG& ag, typename AG::Vertex_handle v) +{ + int count(0); + + typename AG::Vertex_circulator vc_start = ag.incident_vertices(v); + typename AG::Vertex_circulator vc = vc_start; + + do { + if ( ag.is_infinite(vc) ) { ++count; } + ++vc; + } while ( vc != vc_start ); + + return count; +} + + +template +bool test_three_sites(const AG& ag, + typename AG::Vertex_handle v1, + typename AG::Vertex_handle v2, + typename AG::Vertex_handle v3, + Middle_t mid_type) +{ + std::cout << "Site 1: " << v1->site() << std::endl; + std::cout << "Site 2: " << v2->site() << std::endl; + std::cout << "Site 3: " << v3->site() << std::endl; + std::cout << std::endl; + + if ( !ag.is_valid() ) { return false; } + + if ( number_of_infinite_vertices(ag, v1) != 1 ) { return false; } + if ( number_of_infinite_vertices(ag, v3) != 1 ) { return false; } + + if ( number_of_infinite_edges(ag, v1) != 1 ) { return false; } + if ( number_of_infinite_edges(ag, v3) != 1 ) { return false; } + + if ( number_of_infinite_faces(ag, v1) != 2 ) { return false; } + if ( number_of_infinite_faces(ag, v3) != 2 ) { return false; } + + if ( mid_type == MIDDLE_ON_CONVEX_HULL ) { + if ( number_of_infinite_vertices(ag, v2) != 2 ) { return false; } + if ( number_of_infinite_edges(ag, v2) != 2 ) { return false; } + if ( number_of_infinite_faces(ag, v2) != 4 ) { return false; } + + if ( ag.tds().degree(v1) != 2 ) { return false; } + if ( ag.tds().degree(v3) != 2 ) { return false; } + if ( ag.tds().degree(v2) != 4 ) { return false; } + + if ( ag.tds().degree(ag.infinite_vertex()) != 4 ) { return false; } + } else { + if ( number_of_infinite_vertices(ag, v2) != 0 ) { return false; } + if ( number_of_infinite_edges(ag, v2) != 0 ) { return false; } + if ( number_of_infinite_faces(ag, v2) != 0 ) { return false; } + + if ( ag.tds().degree(v1) != 4 ) { return false; } + if ( ag.tds().degree(v3) != 4 ) { return false; } + if ( ag.tds().degree(v2) != 2 ) { return false; } + + if ( ag.tds().degree(ag.infinite_vertex()) != 2 ) { return false; } + } + + return true; +} + +#endif // TEST_AG_THREE_SITES_H diff --git a/Apollonius_graph_2/test/Apollonius_graph_2/test_ag2.cpp b/Apollonius_graph_2/test/Apollonius_graph_2/test_ag2.cpp new file mode 100644 index 00000000000..9b338b30edb --- /dev/null +++ b/Apollonius_graph_2/test/Apollonius_graph_2/test_ag2.cpp @@ -0,0 +1,33 @@ + +#include +#include +#include + + +// choose number type +#include + +typedef double inexact_type; +typedef CGAL::MP_Float exact_type; + +#include + +typedef CGAL::Integral_domain_without_division_tag Method_tag; + +#include "./include/test.h" + +typedef CGAL::Simple_cartesian CK; +typedef CGAL::Simple_cartesian EK; + +int main() +{ + std::ifstream ifs_algo("./data/algo.dat"); + assert( ifs_algo ); + + std::cout << "testing the Apollonius graph class" << " with filtered traits..." << std::flush; + bool algo_ok = CGAL::test_filtered_traits_algo(ifs_algo); + assert( algo_ok ); + std::cout << " done!" << std::endl; + + return 0; +} diff --git a/Apollonius_graph_2/test/Apollonius_graph_2/test_ag_hierarchy_2.cpp b/Apollonius_graph_2/test/Apollonius_graph_2/test_ag_hierarchy_2.cpp new file mode 100644 index 00000000000..9bb7f335333 --- /dev/null +++ b/Apollonius_graph_2/test/Apollonius_graph_2/test_ag_hierarchy_2.cpp @@ -0,0 +1,33 @@ + +#include +#include +#include + +// choose number type +#include + +typedef double inexact_type; +typedef CGAL::MP_Float exact_type; + +#include + +typedef CGAL::Integral_domain_without_division_tag Method_tag; + +#include "./include/test.h" + +typedef CGAL::Simple_cartesian CK; +typedef CGAL::Simple_cartesian EK; + +int main() +{ + std::ifstream ifs_hierarchy("./data/hierarchy.dat"); + assert( ifs_hierarchy ); + + std::cout << "testing the Apollonius graph hierarchy class" << " with filtered traits..." << std::flush; + bool hierarchy_ok = CGAL::test_filtered_traits_hierarchy_algo(ifs_hierarchy); + + assert( hierarchy_ok ); + std::cout << " done!" << std::endl; + + return 0; +} diff --git a/Apollonius_graph_2/test/Apollonius_graph_2/test_ag_three_sites_2.cpp b/Apollonius_graph_2/test/Apollonius_graph_2/test_ag_three_sites_2.cpp new file mode 100644 index 00000000000..d2720d79a60 --- /dev/null +++ b/Apollonius_graph_2/test/Apollonius_graph_2/test_ag_three_sites_2.cpp @@ -0,0 +1,131 @@ +#include +#include + +#include +#include +#include +#include + +#include "test_three_sites.h" + +typedef CGAL::Exact_rational exact_nt; + +typedef CGAL::Simple_cartesian Rep; + +typedef CGAL::Integral_domain_without_division_tag Method_tag; + +typedef CGAL::Apollonius_graph_traits_2 Gt; + +typedef CGAL::Apollonius_graph_2 AG2; +typedef AG2::Point_2 Point_2; +typedef AG2::Site_2 Site_2; +typedef AG2::Vertex_handle Vertex_handle; + +int main() +{ + std::cout << "testing the Apollonius graph class for three sites..." + << std::endl; + + Site_2 s1(Point_2(100,100),5), s2(Point_2(150,150),10), + s3(Point_2(200,200),15); + + AG2 ag; + + { + ag.clear(); + Vertex_handle v1 = ag.insert(s1); + Vertex_handle v2 = ag.insert(s2); + Vertex_handle v3 = ag.insert(s3); + bool b = test_three_sites(ag, v1, v2, v3, MIDDLE_ON_CONVEX_HULL); + std::cout << "Is AG okay? " << (b ? "YES" : "NO") << std::endl; + std::cout << std::endl << "-------------------" << std::endl << std::endl; + assert( b ); + } + + { + ag.clear(); + Vertex_handle v1 = ag.insert(s1); + Vertex_handle v3 = ag.insert(s3); + Vertex_handle v2 = ag.insert(s2); + bool b = test_three_sites(ag, v1, v2, v3, MIDDLE_ON_CONVEX_HULL); + std::cout << "Is AG okay? " << (b ? "YES" : "NO") << std::endl; + std::cout << std::endl << "-------------------" << std::endl << std::endl; + assert( b ); + } + + Site_2 t1(Point_2(100,100),20), t2(Point_2(150,150),20), + t3(Point_2(200,200),20); + + { + ag.clear(); + Vertex_handle v1 = ag.insert(t1); + Vertex_handle v2 = ag.insert(t2); + Vertex_handle v3 = ag.insert(t3); + bool b = test_three_sites(ag, v1, v2, v3, MIDDLE_ON_CONVEX_HULL); + std::cout << "Is AG okay? " << (b ? "YES" : "NO") << std::endl; + std::cout << std::endl << "-------------------" << std::endl << std::endl; + assert( b ); + } + + { + ag.clear(); + Vertex_handle v1 = ag.insert(t1); + Vertex_handle v3 = ag.insert(t3); + Vertex_handle v2 = ag.insert(t2); + bool b = test_three_sites(ag, v1, v2, v3, MIDDLE_ON_CONVEX_HULL); + std::cout << "Is AG okay? " << (b ? "YES" : "NO") << std::endl; + std::cout << std::endl << "-------------------" << std::endl << std::endl; + assert( b ); + } + + { + ag.clear(); + Site_2 q(Point_2(150,150),25); + Vertex_handle v1 = ag.insert(t1); + Vertex_handle v2 = ag.insert(q); + Vertex_handle v3 = ag.insert(t3); + bool b = test_three_sites(ag, v1, v2, v3, MIDDLE_ON_CONVEX_HULL); + std::cout << "Is AG okay? " << (b ? "YES" : "NO") << std::endl; + std::cout << std::endl << "-------------------" << std::endl << std::endl; + assert( b ); + } + + { + ag.clear(); + Site_2 q(Point_2(150,150),25); + Vertex_handle v1 = ag.insert(t1); + Vertex_handle v3 = ag.insert(t3); + Vertex_handle v2 = ag.insert(q); + bool b = test_three_sites(ag, v1, v2, v3, MIDDLE_ON_CONVEX_HULL); + std::cout << "Is AG okay? " << (b ? "YES" : "NO") << std::endl; + std::cout << std::endl << "-------------------" << std::endl << std::endl; + assert( b ); + } + + { + ag.clear(); + Site_2 q(Point_2(150,150),15); + Vertex_handle v1 = ag.insert(t1); + Vertex_handle v2 = ag.insert(q); + Vertex_handle v3 = ag.insert(t3); + bool b = test_three_sites(ag, v1, v2, v3, MIDDLE_NOT_ON_CONVEX_HULL); + std::cout << "Is AG okay? " << (b ? "YES" : "NO") << std::endl; + std::cout << std::endl << "-------------------" << std::endl << std::endl; + assert( b ); + } + + { + ag.clear(); + Site_2 q(Point_2(150,150),15); + Vertex_handle v1 = ag.insert(t1); + Vertex_handle v3 = ag.insert(t3); + Vertex_handle v2 = ag.insert(q); + bool b = test_three_sites(ag, v1, v2, v3, MIDDLE_NOT_ON_CONVEX_HULL); + std::cout << "Is AG okay? " << (b ? "YES" : "NO") << std::endl; + std::cout << std::endl << "-------------------" << std::endl << std::endl; + assert( b ); + } + + std::cout << "... testing is done!" << std::endl; + return 0; +} diff --git a/Apollonius_graph_2/test/Apollonius_graph_2/test_ag_traits_2.cpp b/Apollonius_graph_2/test/Apollonius_graph_2/test_ag_traits_2.cpp new file mode 100644 index 00000000000..1a8d4781bd9 --- /dev/null +++ b/Apollonius_graph_2/test/Apollonius_graph_2/test_ag_traits_2.cpp @@ -0,0 +1,34 @@ +#include +#include +#include + +// choose number type +#include + +typedef double inexact_type; +typedef CGAL::MP_Float exact_type; + +#include + +typedef CGAL::Integral_domain_without_division_tag Method_tag; + +#include "./include/test.h" + +typedef CGAL::Simple_cartesian CK; +typedef CGAL::Simple_cartesian EK; + +int main() +{ + std::ifstream ifs_traits("./data/traits.dat"); + assert( ifs_traits ); + + std::cout << "testing the filtered traits class..." << std::flush; + + CGAL::Filtered_traits_tester test_traits; + bool traits_ok = test_traits(); + assert( traits_ok ); + + std::cout << " done!" << std::endl; + + return 0; +}