mirror of https://github.com/CGAL/cgal
Cleaned up. Replaced local definition of exact rational with CGAL::Exact_rational
This commit is contained in:
parent
86b9fbb22a
commit
a4cf9f5f12
|
|
@ -1,23 +0,0 @@
|
|||
#ifndef CGAL_ARR_RATIONAL_NT_H
|
||||
#define CGAL_ARR_RATIONAL_NT_H
|
||||
|
||||
#include <CGAL/basic.h>
|
||||
|
||||
#ifdef CGAL_USE_GMP
|
||||
|
||||
// GMP is installed. Use the GMP rational number-type.
|
||||
#include <CGAL/Gmpq.h>
|
||||
|
||||
typedef CGAL::Gmpq Number_type;
|
||||
|
||||
#else
|
||||
|
||||
// GMP is not installed. Use CGAL's exact rational number-type.
|
||||
#include <CGAL/MP_Float.h>
|
||||
#include <CGAL/Quotient.h>
|
||||
|
||||
typedef CGAL::Quotient<CGAL::MP_Float> Number_type;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
//! \file examples/Arrangement_on_surface_2/bgl_dual_adapter.cpp
|
||||
// Adapting the dual of an arrangement to a BGL graph.
|
||||
|
||||
#include "arr_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Arr_segment_traits_2.h>
|
||||
#include <CGAL/Arr_extended_dcel.h>
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
|
|
@ -38,7 +38,7 @@ public:
|
|||
{ key->set_data(val); }
|
||||
};
|
||||
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
|
||||
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
|
||||
typedef CGAL::Arr_face_extended_dcel<Traits_2, unsigned int> Dcel;
|
||||
typedef CGAL::Arrangement_2<Traits_2, Dcel> Ex_arrangement;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
//! \file examples/Arrangement_on_surface_2/bgl_primal_adapter.cpp
|
||||
// Adapting an arrangement to a BGL graph.
|
||||
|
||||
#include "arr_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Arr_segment_traits_2.h>
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
#include <CGAL/graph_traits_Arrangement_2.h>
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#include <CGAL/property_map.h>
|
||||
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
|
||||
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
|
||||
typedef Traits_2::Point_2 Point_2;
|
||||
typedef Traits_2::X_monotone_curve_2 Segment_2;
|
||||
|
|
@ -92,7 +92,7 @@ class Arr_vertex_index_map_boost :
|
|||
template<class Arrangement>
|
||||
unsigned int
|
||||
get(const boost::Arr_vertex_index_map_boost<Arrangement> & index_map,
|
||||
typename Arrangement::Vertex_handle v)
|
||||
typename Arrangement::Vertex_handle v)
|
||||
{
|
||||
const CGAL::Arr_vertex_index_map<Arrangement> & index_map_tmp =
|
||||
static_cast<const CGAL::Arr_vertex_index_map<Arrangement> &>(index_map);
|
||||
|
|
@ -100,15 +100,15 @@ get(const boost::Arr_vertex_index_map_boost<Arrangement> & index_map,
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
Arrangement_2 arr;
|
||||
|
||||
|
||||
// Construct an arrangement of seven intersecting line segments.
|
||||
// We keep a handle for the vertex v_0 that corresponds to the point (1,1).
|
||||
Arrangement_2::Halfedge_handle e =
|
||||
insert_non_intersecting_curve (arr, Segment_2 (Point_2 (1, 1),
|
||||
insert_non_intersecting_curve (arr, Segment_2 (Point_2 (1, 1),
|
||||
Point_2 (7, 1)));
|
||||
Arrangement_2::Vertex_handle v0 = e->source();
|
||||
insert (arr, Segment_2 (Point_2 (1, 1), Point_2 (3, 7)));
|
||||
|
|
@ -121,16 +121,16 @@ int main()
|
|||
// Create a mapping of the arrangement vertices to indices.
|
||||
CGAL::Arr_vertex_index_map<Arrangement_2> index_map_tmp(arr);
|
||||
boost::Arr_vertex_index_map_boost<Arrangement_2> index_map(index_map_tmp);
|
||||
|
||||
|
||||
// Perform Dijkstra's algorithm from the vertex v0.
|
||||
Edge_length_func edge_length;
|
||||
|
||||
|
||||
boost::vector_property_map<double, boost::Arr_vertex_index_map_boost<Arrangement_2> > dist_map(static_cast<unsigned int>(arr.number_of_vertices()), index_map);
|
||||
boost::dijkstra_shortest_paths(arr, v0,
|
||||
boost::vertex_index_map(index_map).
|
||||
weight_map(edge_length).
|
||||
distance_map(dist_map));
|
||||
|
||||
|
||||
// Print the results:
|
||||
Arrangement_2::Vertex_iterator vit;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
//! \file examples/Arrangement_on_surface_2/circles.cpp
|
||||
// Constructing an arrangement of circles using the conic-arc traits.
|
||||
|
||||
#include "arr_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Arr_circle_segment_traits_2.h>
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
|
||||
typedef Kernel::Circle_2 Circle_2;
|
||||
typedef CGAL::Arr_circle_segment_traits_2<Kernel> Traits_2;
|
||||
typedef Traits_2::CoordNT CoordNT;
|
||||
|
|
@ -14,37 +14,37 @@ typedef Traits_2::Point_2 Point_2;
|
|||
typedef Traits_2::Curve_2 Curve_2;
|
||||
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
|
||||
|
||||
int main ()
|
||||
int main()
|
||||
{
|
||||
// Create a circle centered at the origin with radius 5.
|
||||
Kernel::Point_2 c1 = Kernel::Point_2 (0, 0);
|
||||
Number_type sqr_r1 = Number_type (25); // = 5^2
|
||||
Circle_2 circ1 = Circle_2 (c1, sqr_r1, CGAL::CLOCKWISE);
|
||||
Curve_2 cv1 = Curve_2 (circ1);
|
||||
Kernel::Point_2 c1 = Kernel::Point_2(0, 0);
|
||||
CGAL::Exact_rational sqr_r1 = CGAL::Exact_rational(25); // = 5^2
|
||||
Circle_2 circ1 = Circle_2(c1, sqr_r1, CGAL::CLOCKWISE);
|
||||
Curve_2 cv1 = Curve_2(circ1);
|
||||
|
||||
// Create a circle centered at (7,7) with radius 5.
|
||||
Kernel::Point_2 c2 = Kernel::Point_2 (7, 7);
|
||||
Number_type sqr_r2 = Number_type (25); // = 5^2
|
||||
Circle_2 circ2 = Circle_2 (c2, sqr_r2, CGAL::CLOCKWISE);
|
||||
Curve_2 cv2 = Curve_2 (circ2);
|
||||
Kernel::Point_2 c2 = Kernel::Point_2(7, 7);
|
||||
CGAL::Exact_rational sqr_r2 = CGAL::Exact_rational(25); // = 5^2
|
||||
Circle_2 circ2 = Circle_2(c2, sqr_r2, CGAL::CLOCKWISE);
|
||||
Curve_2 cv2 = Curve_2(circ2);
|
||||
|
||||
// Create a circle centered at (4,-0.5) with radius 3.5 (= 7/2).
|
||||
Kernel::Point_2 c3 = Kernel::Point_2 (4, Number_type (-1,2));
|
||||
Number_type sqr_r3 = Number_type (49, 4); // = 3.5^2
|
||||
Circle_2 circ3 = Circle_2 (c3, sqr_r3, CGAL::CLOCKWISE);
|
||||
Curve_2 cv3 = Curve_2 (circ3);
|
||||
Kernel::Point_2 c3 = Kernel::Point_2(4, CGAL::Exact_rational(-1,2));
|
||||
CGAL::Exact_rational sqr_r3 = CGAL::Exact_rational(49, 4); // = 3.5^2
|
||||
Circle_2 circ3 = Circle_2(c3, sqr_r3, CGAL::CLOCKWISE);
|
||||
Curve_2 cv3 = Curve_2(circ3);
|
||||
|
||||
// Construct the arrangement of the three circles.
|
||||
Arrangement_2 arr;
|
||||
Arrangement_2 arr;
|
||||
|
||||
insert(arr, cv1);
|
||||
insert(arr, cv2);
|
||||
insert(arr, cv3);
|
||||
|
||||
insert (arr, cv1);
|
||||
insert (arr, cv2);
|
||||
insert (arr, cv3);
|
||||
|
||||
// Locate the vertex with maximal degree.
|
||||
Arrangement_2::Vertex_const_iterator vit;
|
||||
Arrangement_2::Vertex_const_handle v_max;
|
||||
std::size_t max_degree = 0;
|
||||
Arrangement_2::Vertex_const_iterator vit;
|
||||
Arrangement_2::Vertex_const_handle v_max;
|
||||
std::size_t max_degree = 0;
|
||||
|
||||
for (vit = arr.vertices_begin(); vit != arr.vertices_end(); ++vit) {
|
||||
if (vit->degree() > max_degree) {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
//! \file examples/Arrangement_on_surface_2/circular_arc.cpp
|
||||
// Constructing an arrangement of various circular arcs and line segments.
|
||||
|
||||
#include "arr_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Arr_circle_segment_traits_2.h>
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
|
||||
typedef Kernel::Circle_2 Circle_2;
|
||||
typedef Kernel::Segment_2 Segment_2;
|
||||
typedef CGAL::Arr_circle_segment_traits_2<Kernel> Traits_2;
|
||||
|
|
@ -15,78 +15,80 @@ typedef Traits_2::Point_2 Point_2;
|
|||
typedef Traits_2::Curve_2 Curve_2;
|
||||
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
|
||||
|
||||
int main ()
|
||||
int main()
|
||||
{
|
||||
std::list<Curve_2> curves;
|
||||
|
||||
// Create a circle centered at the origin with squared radius 2.
|
||||
Kernel::Point_2 c1 = Kernel::Point_2 (0, 0);
|
||||
Circle_2 circ1 = Circle_2 (c1, Number_type (2));
|
||||
|
||||
curves.push_back (Curve_2 (circ1));
|
||||
Kernel::Point_2 c1 = Kernel::Point_2(0, 0);
|
||||
Circle_2 circ1 = Circle_2(c1, CGAL::Exact_rational(2));
|
||||
|
||||
curves.push_back(Curve_2(circ1));
|
||||
|
||||
// Create a circle centered at (2,3) with radius 3/2 - note that
|
||||
// as the radius is rational we use a different curve constructor.
|
||||
Kernel::Point_2 c2 = Kernel::Point_2 (2, 3);
|
||||
|
||||
curves.push_back (Curve_2 (c2, Number_type(3, 2)));
|
||||
Kernel::Point_2 c2 = Kernel::Point_2(2, 3);
|
||||
|
||||
curves.push_back(Curve_2(c2, CGAL::Exact_rational(3, 2)));
|
||||
|
||||
// Create a segment of the line (y = x) with rational endpoints.
|
||||
Kernel::Point_2 s3 = Kernel::Point_2 (-2, -2);
|
||||
Kernel::Point_2 t3 = Kernel::Point_2 (2, 2);
|
||||
Segment_2 seg3 = Segment_2 (s3, t3);
|
||||
Kernel::Point_2 s3 = Kernel::Point_2(-2, -2);
|
||||
Kernel::Point_2 t3 = Kernel::Point_2(2, 2);
|
||||
Segment_2 seg3 = Segment_2(s3, t3);
|
||||
|
||||
curves.push_back (Curve_2 (seg3));
|
||||
curves.push_back(Curve_2(seg3));
|
||||
|
||||
// Create a line segment with the same supporting line (y = x), but
|
||||
// having one endpoint with irrational coefficients.
|
||||
CoordNT sqrt_15 = CoordNT (0, 1, 15); // = sqrt(15)
|
||||
Point_2 s4 = Point_2 (3, 3);
|
||||
Point_2 t4 = Point_2 (sqrt_15, sqrt_15);
|
||||
CoordNT sqrt_15 = CoordNT(0, 1, 15); // = sqrt(15)
|
||||
Point_2 s4 = Point_2(3, 3);
|
||||
Point_2 t4 = Point_2(sqrt_15, sqrt_15);
|
||||
|
||||
curves.push_back (Curve_2 (seg3.supporting_line(), s4, t4));
|
||||
curves.push_back(Curve_2(seg3.supporting_line(), s4, t4));
|
||||
|
||||
// Create a circular arc that correspond to the upper half of the
|
||||
// circle centered at (1,1) with squared radius 3. We create the
|
||||
// circle with clockwise orientation, so the arc is directed from
|
||||
// (1 - sqrt(3), 1) to (1 + sqrt(3), 1).
|
||||
Kernel::Point_2 c5 = Kernel::Point_2 (1, 1);
|
||||
Circle_2 circ5 = Circle_2 (c5, 3, CGAL::CLOCKWISE);
|
||||
CoordNT one_minus_sqrt_3 = CoordNT (1, -1, 3);
|
||||
CoordNT one_plus_sqrt_3 = CoordNT (1, 1, 3);
|
||||
Point_2 s5 = Point_2 (one_minus_sqrt_3, CoordNT (1));
|
||||
Point_2 t5 = Point_2 (one_plus_sqrt_3, CoordNT (1));
|
||||
Kernel::Point_2 c5 = Kernel::Point_2(1, 1);
|
||||
Circle_2 circ5 = Circle_2(c5, 3, CGAL::CLOCKWISE);
|
||||
CoordNT one_minus_sqrt_3 = CoordNT(1, -1, 3);
|
||||
CoordNT one_plus_sqrt_3 = CoordNT(1, 1, 3);
|
||||
Point_2 s5 = Point_2(one_minus_sqrt_3, CoordNT(1));
|
||||
Point_2 t5 = Point_2(one_plus_sqrt_3, CoordNT(1));
|
||||
|
||||
curves.push_back (Curve_2 (circ5, s5, t5));
|
||||
curves.push_back(Curve_2(circ5, s5, t5));
|
||||
|
||||
// Create a circular arc of the unit circle, directed clockwise from
|
||||
// (-1/2, sqrt(3)/2) to (1/2, sqrt(3)/2). Note that we orient the
|
||||
// supporting circle accordingly.
|
||||
Kernel::Point_2 c6 = Kernel::Point_2 (0, 0);
|
||||
CoordNT sqrt_3_div_2 = CoordNT (Number_type(0), Number_type(1,2), Number_type(3));
|
||||
Point_2 s6 = Point_2 (Number_type (-1, 2), sqrt_3_div_2);
|
||||
Point_2 t6 = Point_2 (Number_type (1, 2), sqrt_3_div_2);
|
||||
|
||||
curves.push_back (Curve_2 (c6, 1, CGAL::CLOCKWISE, s6, t6));
|
||||
Kernel::Point_2 c6 = Kernel::Point_2(0, 0);
|
||||
CoordNT sqrt_3_div_2 = CoordNT(CGAL::Exact_rational(0),
|
||||
CGAL::Exact_rational(1,2),
|
||||
CGAL::Exact_rational(3));
|
||||
Point_2 s6 = Point_2(CGAL::Exact_rational(-1, 2), sqrt_3_div_2);
|
||||
Point_2 t6 = Point_2(CGAL::Exact_rational(1, 2), sqrt_3_div_2);
|
||||
|
||||
curves.push_back(Curve_2(c6, 1, CGAL::CLOCKWISE, s6, t6));
|
||||
|
||||
// Create a circular arc defined by two endpoints and a midpoint,
|
||||
// all having rational coordinates. This arc is the upper-right
|
||||
// quarter of a circle centered at the origin with radius 5.
|
||||
Kernel::Point_2 s7 = Kernel::Point_2 (0, 5);
|
||||
Kernel::Point_2 mid7 = Kernel::Point_2 (3, 4);
|
||||
Kernel::Point_2 t7 = Kernel::Point_2 (5, 0);
|
||||
Kernel::Point_2 s7 = Kernel::Point_2(0, 5);
|
||||
Kernel::Point_2 mid7 = Kernel::Point_2(3, 4);
|
||||
Kernel::Point_2 t7 = Kernel::Point_2(5, 0);
|
||||
|
||||
curves.push_back (Curve_2 (s7, mid7, t7));
|
||||
curves.push_back(Curve_2(s7, mid7, t7));
|
||||
|
||||
// Construct the arrangement of the curves.
|
||||
Arrangement_2 arr;
|
||||
Arrangement_2 arr;
|
||||
|
||||
insert(arr, curves.begin(), curves.end());
|
||||
|
||||
insert (arr, curves.begin(), curves.end());
|
||||
|
||||
// Print the size of the arrangement.
|
||||
std::cout << "The arrangement size:" << std::endl
|
||||
<< " V = " << arr.number_of_vertices()
|
||||
<< ", E = " << arr.number_of_edges()
|
||||
<< ", E = " << arr.number_of_edges()
|
||||
<< ", F = " << arr.number_of_faces() << std::endl;
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
// Associating a color attribute with segments using the consolidated
|
||||
// curve-data traits.
|
||||
|
||||
#include "arr_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Arr_segment_traits_2.h>
|
||||
#include <CGAL/Arr_consolidated_curve_data_traits_2.h>
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
|
|
@ -14,7 +14,7 @@ enum Segment_color {
|
|||
BLUE
|
||||
};
|
||||
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
|
||||
typedef CGAL::Arr_segment_traits_2<Kernel> Segment_traits_2;
|
||||
typedef Segment_traits_2::Curve_2 Segment_2;
|
||||
typedef CGAL::Arr_consolidated_curve_data_traits_2
|
||||
|
|
@ -79,7 +79,7 @@ int main ()
|
|||
// Print the vertex only if incident RED and BLUE edges were found.
|
||||
if (has_red && has_blue)
|
||||
{
|
||||
std::cout << "Red-blue intersection at (" << vit->point() << ")"
|
||||
std::cout << "Red-blue intersection at (" << vit->point() << ")"
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ int main ()
|
|||
if (*dit == RED)
|
||||
has_red = true;
|
||||
else if (*dit == BLUE)
|
||||
has_blue = true;
|
||||
has_blue = true;
|
||||
}
|
||||
|
||||
// Print the edge only if it corresponds to a red-blue overlap.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
//! \file examples/Arrangement_on_surface_2/curve_history.cpp
|
||||
// Constructing an arrangement with curve history.
|
||||
|
||||
#include "arr_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Arr_segment_traits_2.h>
|
||||
|
||||
#include <CGAL/Arrangement_on_surface_with_history_2.h>
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "point_location_utils.h"
|
||||
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
|
||||
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
|
||||
typedef Traits_2::Point_2 Point_2;
|
||||
typedef Traits_2::Curve_2 Segment_2;
|
||||
|
|
@ -44,7 +44,7 @@ int main()
|
|||
<< arr.number_of_curves() << " curves:" << std::endl;
|
||||
for (cit = arr.curves_begin(); cit != arr.curves_end(); ++cit)
|
||||
std::cout << "Curve [" << *cit << "] induces "
|
||||
<< arr.number_of_induced_edges(cit) << " edges." << std::endl;
|
||||
<< arr.number_of_induced_edges(cit) << " edges." << std::endl;
|
||||
|
||||
// Print the arrangement edges, along with the list of curves that
|
||||
// induce each edge.
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
//! \file examples/Arrangement_on_surface_2/dcel_extension.cpp
|
||||
// Extending all DCEL records (vertices, edges and faces).
|
||||
|
||||
#include "arr_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Arr_segment_traits_2.h>
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
#include <CGAL/Arr_extended_dcel.h>
|
||||
|
||||
enum Color {BLUE, RED, WHITE};
|
||||
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
|
||||
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
|
||||
typedef Traits_2::Point_2 Point_2;
|
||||
typedef Traits_2::X_monotone_curve_2 Segment_2;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
//! \file examples/Arrangement_on_surface_2/dcel_extension_io.cpp
|
||||
// Using the I/O operators for arrangements with extended DCEL records.
|
||||
|
||||
#include "arr_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Arr_segment_traits_2.h>
|
||||
#include <CGAL/Arr_extended_dcel.h>
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
|
|
@ -39,7 +39,7 @@ std::istream& operator>> (std::istream& is, Color& color)
|
|||
return (is);
|
||||
}
|
||||
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
|
||||
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
|
||||
typedef Traits_2::Point_2 Point_2;
|
||||
typedef Traits_2::X_monotone_curve_2 Segment_2;
|
||||
|
|
|
|||
|
|
@ -2,27 +2,27 @@
|
|||
// Checking whether there are three collinear points in a given input set
|
||||
// using the arrangement of the dual lines.
|
||||
|
||||
#include "arr_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Arr_linear_traits_2.h>
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
#include <cstdlib>
|
||||
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
|
||||
typedef CGAL::Arr_linear_traits_2<Kernel> Traits_2;
|
||||
typedef Traits_2::Point_2 Point_2;
|
||||
typedef Traits_2::Line_2 Line_2;
|
||||
typedef Traits_2::X_monotone_curve_2 X_monotone_curve_2;
|
||||
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Get the name of the input file from the command line, or use the default
|
||||
// points.dat file if no command-line parameters are given.
|
||||
const char * filename = (argc > 1) ? argv[1] : "points.dat";
|
||||
const char* filename = (argc > 1) ? argv[1] : "points.dat";
|
||||
|
||||
// Open the input file.
|
||||
std::ifstream in_file (filename);
|
||||
std::ifstream in_file(filename);
|
||||
|
||||
if (! in_file.is_open()) {
|
||||
std::cerr << "Failed to open " << filename << "!" << std::endl;
|
||||
|
|
@ -36,43 +36,43 @@ int main (int argc, char *argv[])
|
|||
// <x_2> <y_2> // point #2.
|
||||
// : : : :
|
||||
// <x_n> <y_n> // point #n.
|
||||
std::vector<Point_2> points;
|
||||
std::list<X_monotone_curve_2> dual_lines;
|
||||
std::vector<Point_2> points;
|
||||
std::list<X_monotone_curve_2> dual_lines;
|
||||
|
||||
unsigned int n;
|
||||
size_t n;
|
||||
in_file >> n;
|
||||
points.resize(n);
|
||||
unsigned int k;
|
||||
for (k = 0; k < n; ++k) {
|
||||
int px, py;
|
||||
in_file >> px >> py;
|
||||
points[k] = Point_2 (px, py);
|
||||
points[k] = Point_2(px, py);
|
||||
|
||||
// The line dual to the point (p_x, p_y) is y = p_x*x - p_y,
|
||||
// or: p_x*x - y - p_y = 0:
|
||||
dual_lines.push_back (Line_2 (Number_type(px),
|
||||
Number_type(-1),
|
||||
Number_type(-py)));
|
||||
dual_lines.push_back(Line_2(CGAL::Exact_rational(px),
|
||||
CGAL::Exact_rational(-1),
|
||||
CGAL::Exact_rational(-py)));
|
||||
}
|
||||
in_file.close();
|
||||
|
||||
// Construct the dual arrangement by aggragately inserting the lines.
|
||||
Arrangement_2 arr;
|
||||
Arrangement_2 arr;
|
||||
|
||||
insert (arr, dual_lines.begin(), dual_lines.end());
|
||||
insert(arr, dual_lines.begin(), dual_lines.end());
|
||||
|
||||
std::cout << "The dual arrangement size:" << std::endl
|
||||
<< "V = " << arr.number_of_vertices()
|
||||
<< " (+ " << arr.number_of_vertices_at_infinity()
|
||||
<< " at infinity)"
|
||||
<< ", E = " << arr.number_of_edges()
|
||||
<< ", E = " << arr.number_of_edges()
|
||||
<< ", F = " << arr.number_of_faces()
|
||||
<< " (" << arr.number_of_unbounded_faces()
|
||||
<< " unbounded)" << std::endl;
|
||||
|
||||
// Look for a vertex whose degree is greater than 4.
|
||||
Arrangement_2::Vertex_const_iterator vit;
|
||||
bool found_collinear = false;
|
||||
Arrangement_2::Vertex_const_iterator vit;
|
||||
bool found_collinear = false;
|
||||
|
||||
for (vit = arr.vertices_begin(); vit != arr.vertices_end(); ++vit) {
|
||||
if (vit->degree() > 4) {
|
||||
|
|
@ -89,15 +89,14 @@ int main (int argc, char *argv[])
|
|||
|
||||
// Pick two points from the input set, compute their midpoint and insert
|
||||
// its dual line into the arrangement.
|
||||
Kernel ker;
|
||||
const int k1 = std::rand() % n, k2 = (k1 + 1) % n;
|
||||
Point_2 p_mid = ker.construct_midpoint_2_object() (points[k1],
|
||||
points[k2]);
|
||||
X_monotone_curve_2 dual_p_mid = Line_2 (Number_type(p_mid.x()),
|
||||
Number_type(-1),
|
||||
Number_type(-p_mid.y()));
|
||||
Kernel ker;
|
||||
const int k1 = std::rand() % n, k2 = (k1 + 1) % n;
|
||||
Point_2 p_mid = ker.construct_midpoint_2_object()(points[k1], points[k2]);
|
||||
X_monotone_curve_2 dual_p_mid = Line_2(CGAL::Exact_rational(p_mid.x()),
|
||||
CGAL::Exact_rational(-1),
|
||||
CGAL::Exact_rational(-p_mid.y()));
|
||||
|
||||
insert (arr, dual_p_mid);
|
||||
insert(arr, dual_p_mid);
|
||||
|
||||
// Make sure that we now have three collinear points.
|
||||
found_collinear = false;
|
||||
|
|
@ -107,6 +106,7 @@ int main (int argc, char *argv[])
|
|||
break;
|
||||
}
|
||||
}
|
||||
CGAL_assertion (found_collinear);
|
||||
CGAL_assertion(found_collinear);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,29 +2,29 @@
|
|||
// Checking whether there are three collinear points in a given input set
|
||||
// using the arrangement of the dual lines.
|
||||
|
||||
#include "arr_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Arr_linear_traits_2.h>
|
||||
#include <CGAL/Arr_curve_data_traits_2.h>
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
|
||||
typedef CGAL::Arr_linear_traits_2<Kernel> Linear_traits_2;
|
||||
typedef Linear_traits_2::Point_2 Point_2;
|
||||
typedef Linear_traits_2::Line_2 Line_2;
|
||||
typedef CGAL::Arr_curve_data_traits_2<Linear_traits_2,
|
||||
unsigned int> Traits_2;
|
||||
unsigned int> Traits_2;
|
||||
typedef Traits_2::X_monotone_curve_2 X_monotone_curve_2;
|
||||
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Get the name of the input file from the command line, or use the default
|
||||
// points.dat file if no command-line parameters are given.
|
||||
const char * filename = (argc > 1) ? argv[1] : "coll_points.dat";
|
||||
|
||||
// Open the input file.
|
||||
std::ifstream in_file (filename);
|
||||
std::ifstream in_file(filename);
|
||||
|
||||
if (! in_file.is_open()) {
|
||||
std::cerr << "Failed to open " << filename << " ..." << std::endl;
|
||||
|
|
@ -35,35 +35,35 @@ int main (int argc, char *argv[])
|
|||
std::vector<Point_2> points;
|
||||
std::list<X_monotone_curve_2> dual_lines;
|
||||
|
||||
unsigned int n;
|
||||
size_t n;
|
||||
in_file >> n;
|
||||
points.resize (n);
|
||||
unsigned int k;
|
||||
points.resize(n);
|
||||
size_t k;
|
||||
for (k = 0; k < n; ++k) {
|
||||
int px, py;
|
||||
in_file >> px >> py;
|
||||
points[k] = Point_2 (px, py);
|
||||
points[k] = Point_2(px, py);
|
||||
|
||||
// The line dual to the point (p_x, p_y) is y = p_x*x - p_y,
|
||||
// or: p_x*x - y - p_y = 0:
|
||||
Line_2 dual_line = Line_2(Number_type(px),
|
||||
Number_type(-1),
|
||||
Number_type(-py));
|
||||
Line_2 dual_line = Line_2(CGAL::Exact_rational(px),
|
||||
CGAL::Exact_rational(-1),
|
||||
CGAL::Exact_rational(-py));
|
||||
|
||||
// Generate the x-monotone curve based on the line and the point index.
|
||||
dual_lines.push_back (X_monotone_curve_2 (dual_line, k));
|
||||
dual_lines.push_back(X_monotone_curve_2(dual_line, k));
|
||||
}
|
||||
in_file.close();
|
||||
|
||||
// Construct the dual arrangement by aggragately inserting the lines.
|
||||
Arrangement_2 arr;
|
||||
Arrangement_2 arr;
|
||||
|
||||
insert (arr, dual_lines.begin(), dual_lines.end());
|
||||
insert(arr, dual_lines.begin(), dual_lines.end());
|
||||
|
||||
// Look for vertices whose degree is greater than 4.
|
||||
Arrangement_2::Vertex_const_iterator vit;
|
||||
Arrangement_2::Halfedge_around_vertex_const_circulator circ;
|
||||
unsigned int d;
|
||||
Arrangement_2::Vertex_const_iterator vit;
|
||||
Arrangement_2::Halfedge_around_vertex_const_circulator circ;
|
||||
size_t d;
|
||||
|
||||
for (vit = arr.vertices_begin(); vit != arr.vertices_end(); ++vit) {
|
||||
if (vit->degree() > 4) {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
//! \file examples/Arrangement_on_surface_2/edge_manipulation_curve_history.cpp
|
||||
// Removing curves and manipulating edges in an arrangement with history.
|
||||
|
||||
#include "arr_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Arr_circle_segment_traits_2.h>
|
||||
#include <CGAL/Arrangement_with_history_2.h>
|
||||
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
|
||||
typedef Kernel::Point_2 Rat_point_2;
|
||||
typedef Kernel::Circle_2 Circle_2;
|
||||
typedef CGAL::Arr_circle_segment_traits_2<Kernel> Traits_2;
|
||||
|
|
@ -14,17 +14,17 @@ typedef Traits_2::Point_2 Point_2;
|
|||
typedef Traits_2::Curve_2 Curve_2;
|
||||
typedef CGAL::Arrangement_with_history_2<Traits_2> Arr_with_hist_2;
|
||||
typedef Arr_with_hist_2::Curve_handle Curve_handle;
|
||||
typedef CGAL::Arr_walk_along_line_point_location<Arr_with_hist_2>
|
||||
typedef CGAL::Arr_walk_along_line_point_location<Arr_with_hist_2>
|
||||
Point_location;
|
||||
|
||||
int main()
|
||||
{
|
||||
// Construct an arrangement containing nine circles: C[0] of radius 2 and
|
||||
// C[1], ..., C[8] of radius 1.
|
||||
const Number_type _7_halves = Number_type(7, 2);
|
||||
Arr_with_hist_2 arr;
|
||||
Curve_2 C[9];
|
||||
Curve_handle handles[9];
|
||||
const CGAL::Exact_rational _7_halves = CGAL::Exact_rational(7, 2);
|
||||
Arr_with_hist_2 arr;
|
||||
Curve_2 C[9];
|
||||
Curve_handle handles[9];
|
||||
|
||||
C[0] = Circle_2(Rat_point_2(_7_halves, _7_halves), 4, CGAL::CLOCKWISE);
|
||||
C[1] = Circle_2(Rat_point_2(_7_halves, 6), 1, CGAL::CLOCKWISE);
|
||||
|
|
@ -36,23 +36,23 @@ int main()
|
|||
C[7] = Circle_2(Rat_point_2(1, _7_halves), 1, CGAL::CLOCKWISE);
|
||||
C[8] = Circle_2(Rat_point_2(2, 5), 1, CGAL::CLOCKWISE);
|
||||
|
||||
unsigned int k;
|
||||
size_t k;
|
||||
for (k = 0; k < 9; k++)
|
||||
handles[k] = insert(arr, C[k]);
|
||||
|
||||
std::cout << "The initial arrangement size:" << std::endl
|
||||
<< " V = " << arr.number_of_vertices()
|
||||
<< ", E = " << arr.number_of_edges()
|
||||
<< ", E = " << arr.number_of_edges()
|
||||
<< ", F = " << arr.number_of_faces() << std::endl;
|
||||
|
||||
// Remove the large circle C[0].
|
||||
std::cout << "Removing C[0] : ";
|
||||
std::cout << remove_curve(arr, handles[0])
|
||||
std::cout << remove_curve(arr, handles[0])
|
||||
<< " edges have been removed." << std::endl;
|
||||
|
||||
std::cout << "The arrangement size:" << std::endl
|
||||
<< " V = " << arr.number_of_vertices()
|
||||
<< ", E = " << arr.number_of_edges()
|
||||
<< ", E = " << arr.number_of_edges()
|
||||
<< ", F = " << arr.number_of_faces() << std::endl;
|
||||
|
||||
// Locate the point q, which should be on an edge e.
|
||||
|
|
@ -63,16 +63,16 @@ int main()
|
|||
|
||||
CGAL_assertion_code(bool success = ) CGAL::assign(e, obj);
|
||||
CGAL_assertion(success);
|
||||
|
||||
|
||||
// Split the edge e to two edges e1 and e2;
|
||||
Arr_with_hist_2::Halfedge_handle e1, e2;
|
||||
Arr_with_hist_2::Halfedge_handle e1, e2;
|
||||
|
||||
e1 = arr.split_edge(arr.non_const_handle(e), q);
|
||||
e2 = e1->next();
|
||||
|
||||
std::cout << "After edge split: "
|
||||
<< "V = " << arr.number_of_vertices()
|
||||
<< ", E = " << arr.number_of_edges()
|
||||
<< ", E = " << arr.number_of_edges()
|
||||
<< ", F = " << arr.number_of_faces() << std::endl;
|
||||
|
||||
// Merge back the two split edges.
|
||||
|
|
@ -80,7 +80,7 @@ int main()
|
|||
|
||||
std::cout << "After edge merge: "
|
||||
<< "V = " << arr.number_of_vertices()
|
||||
<< ", E = " << arr.number_of_edges()
|
||||
<< ", E = " << arr.number_of_edges()
|
||||
<< ", F = " << arr.number_of_faces() << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
//! \file examples/Arrangement_on_surface_2/face_extension.cpp
|
||||
// Extending the arrangement-face records.
|
||||
|
||||
#include "arr_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Arr_segment_traits_2.h>
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
#include <CGAL/Arr_extended_dcel.h>
|
||||
#include <CGAL/Arr_observer.h>
|
||||
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
|
||||
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
|
||||
typedef Traits_2::Point_2 Point_2;
|
||||
typedef Traits_2::X_monotone_curve_2 Segment_2;
|
||||
|
|
@ -29,7 +29,7 @@ public:
|
|||
n_faces (0)
|
||||
{
|
||||
CGAL_precondition (arr.is_empty());
|
||||
|
||||
|
||||
arr.unbounded_face()->set_data (0);
|
||||
n_faces++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
//! \file examples/Arrangement_on_surface_2/face_extension_overlay.cpp
|
||||
// A face overlay of two arrangements with extended face records.
|
||||
|
||||
#include "arr_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Arr_segment_traits_2.h>
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
#include <CGAL/Arr_extended_dcel.h>
|
||||
#include <CGAL/Arr_overlay_2.h>
|
||||
#include <CGAL/Arr_default_overlay_traits.h>
|
||||
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
|
||||
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
|
||||
typedef Traits_2::Point_2 Point_2;
|
||||
typedef Traits_2::X_monotone_curve_2 Segment_2;
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
// Associating a name attribute with segments using the generic curve-data
|
||||
// traits.
|
||||
|
||||
#include "arr_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Arr_segment_traits_2.h>
|
||||
#include <CGAL/Arr_polyline_traits_2.h>
|
||||
#include <CGAL/Arr_curve_data_traits_2.h>
|
||||
|
|
@ -21,7 +21,7 @@ struct Merge_names
|
|||
}
|
||||
};
|
||||
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
|
||||
typedef CGAL::Arr_segment_traits_2<Kernel> Segment_traits_2;
|
||||
typedef CGAL::Arr_polyline_traits_2<Segment_traits_2> Polyline_traits_2;
|
||||
typedef Polyline_traits_2::Curve_2 Polyline_2;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
//! \file examples/Arrangement_on_surface_2/io.cpp
|
||||
// Using the arrangement I/O operators.
|
||||
|
||||
#include "arr_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Arr_segment_traits_2.h>
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
#include <CGAL/IO/Arr_iostream.h>
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include "point_location_utils.h"
|
||||
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
|
||||
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
|
||||
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
//! \file examples/Arrangement_on_surface_2/io_curve_history.cpp
|
||||
// Using the arrangement-with-history I/O operators.
|
||||
|
||||
#include "arr_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Arr_segment_traits_2.h>
|
||||
#include <CGAL/Arrangement_with_history_2.h>
|
||||
#include <CGAL/IO/Arr_with_history_iostream.h>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
|
||||
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
|
||||
typedef Traits_2::Point_2 Point_2;
|
||||
typedef Traits_2::Curve_2 Segment_2;
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
//! \file examples/Arrangement_2/io_unbounded.cpp
|
||||
// Using the I/O operators with an arrangement of unbounded curves.
|
||||
|
||||
#include "arr_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Arr_linear_traits_2.h>
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
#include <CGAL/IO/Arr_iostream.h>
|
||||
#include <list>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
|
||||
typedef CGAL::Arr_linear_traits_2<Kernel> Traits_2;
|
||||
typedef Traits_2::Point_2 Point_2;
|
||||
typedef Traits_2::Segment_2 Segment_2;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
//! \file examples/Arrangement_on_surface_2/overlay.cpp
|
||||
// A simple overlay of two arrangements.
|
||||
|
||||
#include "arr_rational_nt.h"
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Exact_rational.h>
|
||||
#include <CGAL/Arr_segment_traits_2.h>
|
||||
#include <CGAL/Arrangement_2.h>
|
||||
#include <CGAL/Arr_overlay_2.h>
|
||||
#include <CGAL/Arr_default_overlay_traits.h>
|
||||
|
||||
typedef CGAL::Cartesian<Number_type> Kernel;
|
||||
typedef CGAL::Cartesian<CGAL::Exact_rational> Kernel;
|
||||
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
|
||||
typedef Traits_2::Point_2 Point_2;
|
||||
typedef Traits_2::X_monotone_curve_2 Segment_2;
|
||||
|
|
@ -52,7 +52,7 @@ int main ()
|
|||
// Print the size of the overlaid arrangement.
|
||||
std::cout << "The overlaid arrangement size:" << std::endl
|
||||
<< " V = " << overlay_arr.number_of_vertices()
|
||||
<< ", E = " << overlay_arr.number_of_edges()
|
||||
<< ", E = " << overlay_arr.number_of_edges()
|
||||
<< ", F = " << overlay_arr.number_of_faces() << std::endl;
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue