changed number types

Committing in .

 Modified Files:
 	example10.C example11.C example12.C example7.C example8.C
 	example9.C
This commit is contained in:
Eran Leiserowitz 2002-03-18 12:45:26 +00:00
parent 22bef01be3
commit ae35c54870
6 changed files with 76 additions and 89 deletions

View File

@ -7,47 +7,43 @@
#define Arr_polyline_traits APT
#include <CGAL/Cartesian.h>
#include <CGAL/MP_Float.h>
#include <CGAL/Quotient.h>
#include <CGAL/Arr_2_bases.h>
#include <CGAL/Arr_2_default_dcel.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Arr_polyline_traits.h>
//#include <CGAL/leda_real.h>
//typedef leda_real NT;
// We use here double instead of leda_real to enable compilation without LEDA.
// This is not recommended generally.
// Read more in the README file or in the manual.
typedef double NT;
typedef CGAL::Cartesian<NT> Rep;
typedef CGAL::Arr_polyline_traits<Rep> Traits;
typedef CGAL::Quotient<CGAL::MP_Float> NT;
typedef CGAL::Cartesian<NT> Kernel;
typedef CGAL::Arr_polyline_traits<Kernel> Traits;
typedef Traits::Point Point;
typedef Traits::X_curve X_curve;
typedef Traits::Curve Curve;
typedef CGAL::Arr_base_node<Curve> Base_node;
typedef CGAL::Arr_2_default_dcel<Traits> Dcel;
typedef CGAL::Arrangement_2<Dcel,Traits,Base_node > Arr_2;
int main() {
int main()
{
Arr_2 arr;
Curve in_curve;
// curve #1, not x monotone
// Curve #1, not x monotone
in_curve.push_back(Point( 0, 0));
in_curve.push_back(Point( 10, 10));
in_curve.push_back(Point( 0, 20));
arr.insert(in_curve);
// curve #2, x monotone
// Curve #2, x monotone
in_curve.clear();
in_curve.push_back(Point(100, 0));
in_curve.push_back(Point(150, 50));
in_curve.push_back(Point(200, 0));
arr.insert(in_curve);
// curve #1 is broken into two edges. Point (10,10) turns into a vertex.
// Curve #1 is broken into two edges. Point (10,10) turns into a vertex.
Arr_2::Locate_type lt;
arr.locate(Point(10, 10), lt);
CGAL_assertion(lt == Arr_2::VERTEX);

View File

@ -1,15 +1,13 @@
// examples/Arrangement_2/example11
#include <CGAL/Quotient.h>
#include <CGAL/Cartesian.h>
#include <CGAL/MP_Float.h>
#include <CGAL/Quotient.h>
#include <CGAL/Arr_2_bases.h>
#include <CGAL/Arr_2_default_dcel.h>
#include <CGAL/Arr_segment_exact_traits.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/IO/Arr_iostream.h>
#include <iostream>
@ -17,12 +15,10 @@
#include <CGAL/IO/Arr_Postscript_file_stream.h>
#endif
typedef CGAL::Quotient<int> NT;
typedef CGAL::Cartesian<NT> R;
typedef CGAL::Arr_segment_exact_traits<R> Traits;
typedef CGAL::Quotient<CGAL::MP_Float> NT;
typedef CGAL::Cartesian<NT> Kernel;
typedef CGAL::Arr_segment_exact_traits<Kernel> Traits;
typedef Traits::Point Point;
typedef Traits::X_curve X_curve;
typedef Traits::Curve Curve;
typedef CGAL::Arr_2_default_dcel<Traits> Dcel;
@ -48,10 +44,10 @@ int main()
// printing to Postscript file.
#ifdef CGAL_USE_LEDA
CGAL::Postscript_file_stream LPF(500, 500 ,"arr.ps");
LPF.init(-3,3,-3);
LPF.set_line_width( 1);
LPF << arr;
// CGAL::Postscript_file_stream LPF(500, 500 ,"arr.ps");
// LPF.init(-3,3,-3);
// LPF.set_line_width( 1);
// LPF << arr;
#endif
return 0;

View File

@ -1,23 +1,21 @@
//examples/Arrangement_2/example12
#include <CGAL/Cartesian.h>
#include <CGAL/MP_Float.h>
#include <CGAL/Quotient.h>
#include <CGAL/Arr_2_bases.h>
#include <CGAL/Arr_2_default_dcel.h>
#include <CGAL/Arrangement_2.h>
#include <iostream>
#include <CGAL/Arr_polyline_traits.h>
#include <CGAL/IO/Arr_iostream.h>
typedef CGAL::Quotient<int> NT;
typedef CGAL::Cartesian<NT> R;
typedef CGAL::Arr_polyline_traits<R> Traits;
typedef CGAL::Quotient<CGAL::MP_Float> NT;
typedef CGAL::Cartesian<NT> Kernel;
typedef CGAL::Arr_polyline_traits<Kernel> Traits;
typedef Traits::Point Point;
typedef Traits::X_curve X_curve;
typedef Traits::Curve Curve;
typedef CGAL::Arr_2_default_dcel<Traits> Dcel;

View File

@ -12,7 +12,6 @@ typedef CGAL::Cartesian<NT> Kernel;
typedef CGAL::Arr_segment_exact_traits<Kernel> Traits;
typedef Traits::Point Point;
typedef Traits::X_curve X_curve;
typedef Traits::Curve Curve;
// A global variable to keep track of when we inserted the edges.

View File

@ -7,18 +7,14 @@
#define Arr_segment_exact_traits ASET
#include <CGAL/Homogeneous.h>
#include <CGAL/MP_Float.h>
#include <CGAL/Arr_2_default_dcel.h>
#include <CGAL/Arrangement_2.h>
//#include <CGAL/leda_integer.h>
#include <CGAL/Arr_segment_exact_traits.h>
//typedef leda_integer NT;
typedef long NT;
typedef CGAL::Homogeneous<NT> R;
typedef CGAL::Arr_segment_exact_traits<R> Traits;
typedef CGAL::MP_Float NT;
typedef CGAL::Homogeneous<NT> Kernel;
typedef CGAL::Arr_segment_exact_traits<Kernel> Traits;
typedef Traits::Point Point;
typedef Traits::X_curve X_curve;
@ -31,11 +27,14 @@ int main(int argc, char* argv[])
{
Arr_2 arr;
// Read the segments
int num_curves;
int x,y;
std::cout << "Enter number of segments: " ;
std::cin >> num_curves;
while (num_curves--) {
while (num_curves--)
{
std::cout << "Enter source coordinates (2 integers): " ;
std::cin >> x >> y;
Point s(x,y);
@ -48,6 +47,8 @@ int main(int argc, char* argv[])
arr.insert(seg);
}
// Do the ray shooting
std::cout << "Enter point for ray shooting (2 integers): " ;
std::cin >> x >> y;
Point p(x,y);
@ -56,12 +57,15 @@ int main(int argc, char* argv[])
Arr_2::Locate_type lt;
e = arr.vertical_ray_shoot(p,lt,true);
if (lt==Arr_2::UNBOUNDED_FACE) {
// Check the location type
if (lt == Arr_2::UNBOUNDED_FACE)
{
std::cout << "UNBOUNDED_FACE" << std::endl;
}
else {
std::cout << "The halfedge shot is :" << std::endl;
std::cout << "(Using homogeneous coordinates <hx, hy, hw>, ";
else
{
std::cout << "The half-edge shot is :" << std::endl;
std::cout << "(Using homogeneous coordinates <hx, hy, hw> ";
std::cout << "where <x, y>=<hx/hw, hy/hw>)" << std::endl;
std::cout << e->source()->point() << " -> " << e->target()->point();
std::cout << std::endl;

View File

@ -7,62 +7,56 @@
#define Arr_polyline_traits APT
#include <CGAL/Cartesian.h>
#include <CGAL/MP_Float.h>
#include <CGAL/Quotient.h>
#include <CGAL/Arr_2_bases.h>
#include <CGAL/Arr_2_default_dcel.h>
#include <CGAL/Arr_polyline_traits.h>
#include <CGAL/Arrangement_2.h>
//#include <CGAL/leda_real.h>
//typedef leda_real NT;
// We use here double instead of leda_real to enable compilation without LEDA.
// This is not recommended generally.
// Read more in the README file or in the manual.
typedef double NT;
typedef CGAL::Cartesian<NT> Rep;
typedef CGAL::Arr_polyline_traits<Rep> Traits;
typedef CGAL::Quotient<CGAL::MP_Float> NT;
typedef CGAL::Cartesian<NT> Kernel;
typedef CGAL::Arr_polyline_traits<Kernel> Traits;
typedef Traits::Point Point;
typedef Traits::X_curve X_curve;
typedef Traits::Curve Curve;
typedef CGAL::Arr_base_node<Curve> Base_node;
typedef CGAL::Arr_2_default_dcel<Traits> Dcel;
typedef CGAL::Arrangement_2<Dcel,Traits,Base_node > Arr_2;
int main() {
int main()
{
Arr_2 arr;
Curve in_curve;
// we insert two intersecting squares
in_curve.push_back(Point( 0, 50));
in_curve.push_back(Point( 50, 50));
in_curve.push_back(Point( 50, 0));
in_curve.push_back(Point( 0, 0));
in_curve.push_back(Point( 0, 50));
arr.insert(in_curve);
in_curve.clear();
in_curve.push_back(Point( 25, 75));
in_curve.push_back(Point( 75, 75));
in_curve.push_back(Point( 75, 25));
in_curve.push_back(Point( 25, 25));
in_curve.push_back(Point( 25, 75));
arr.insert(in_curve);
// upward vertical ray shooting
// the edge <25,50>-<50,50> is supposed to be have been created
Arr_2::Locate_type lt;
Arr_2::Halfedge_handle e=arr.vertical_ray_shoot(Point(30,30),lt,true);
CGAL_assertion(e->source()->point()==Point(50,50));
CGAL_assertion(e->target()->point()==Point(25,50));
// we expect <50,25> to be an intersection (of the polylines)
e = arr.locate(Point(50,25), lt);
CGAL_assertion(lt == Arr_2::VERTEX);
return 0;
// We insert two intersecting squares
in_curve.push_back(Point( 0, 50));
in_curve.push_back(Point( 50, 50));
in_curve.push_back(Point( 50, 0));
in_curve.push_back(Point( 0, 0));
in_curve.push_back(Point( 0, 50));
arr.insert(in_curve);
in_curve.clear();
in_curve.push_back(Point( 25, 75));
in_curve.push_back(Point( 75, 75));
in_curve.push_back(Point( 75, 25));
in_curve.push_back(Point( 25, 25));
in_curve.push_back(Point( 25, 75));
arr.insert(in_curve);
// Upward vertical ray shooting
// the edge <25,50>-<50,50> is supposed to be have been created
Arr_2::Locate_type lt;
Arr_2::Halfedge_handle e=arr.vertical_ray_shoot(Point(30,30),lt,true);
CGAL_assertion(e->source()->point()==Point(50,50));
CGAL_assertion(e->target()->point()==Point(25,50));
// We expect <50,25> to be an intersection (of the polylines)
e = arr.locate(Point(50,25), lt);
CGAL_assertion(lt == Arr_2::VERTEX);
return 0;
}