From 1d41d99cf3f41bafec550b5c74a3ea2d66ec1cfc Mon Sep 17 00:00:00 2001 From: Mariette Yvinec Date: Tue, 17 Aug 1999 12:39:25 +0000 Subject: [PATCH] merge from branch b6aout to main trunc --- .../examples/Triangulation_2/README | 14 + .../examples/Triangulation_2/cgal_test | 75 ++++ .../examples/Triangulation_2/data/points.cin | 7 + .../examples/Triangulation_2/data/replay | 7 + .../examples/Triangulation_2/example.C | 247 +++++++++++++ .../examples/Triangulation_2/example.cin | 2 + .../examples/Triangulation_2/example.cmd | 1 + .../examples/Triangulation_2/makefile | 65 ++++ .../examples/Triangulation_2/points.C | 52 +++ .../examples/Triangulation_2/points.cmd | 1 + .../examples/Triangulation_2/points.h | 347 ++++++++++++++++++ .../examples/Triangulation_2/voronoi.C | 184 ++++++++++ .../examples/Triangulation_2/voronoi.cmd | 1 + 13 files changed, 1003 insertions(+) create mode 100644 Packages/Triangulation_2/examples/Triangulation_2/README create mode 100755 Packages/Triangulation_2/examples/Triangulation_2/cgal_test create mode 100644 Packages/Triangulation_2/examples/Triangulation_2/data/points.cin create mode 100644 Packages/Triangulation_2/examples/Triangulation_2/data/replay create mode 100644 Packages/Triangulation_2/examples/Triangulation_2/example.C create mode 100644 Packages/Triangulation_2/examples/Triangulation_2/example.cin create mode 100644 Packages/Triangulation_2/examples/Triangulation_2/example.cmd create mode 100644 Packages/Triangulation_2/examples/Triangulation_2/makefile create mode 100644 Packages/Triangulation_2/examples/Triangulation_2/points.C create mode 100644 Packages/Triangulation_2/examples/Triangulation_2/points.cmd create mode 100644 Packages/Triangulation_2/examples/Triangulation_2/points.h create mode 100644 Packages/Triangulation_2/examples/Triangulation_2/voronoi.C create mode 100644 Packages/Triangulation_2/examples/Triangulation_2/voronoi.cmd diff --git a/Packages/Triangulation_2/examples/Triangulation_2/README b/Packages/Triangulation_2/examples/Triangulation_2/README new file mode 100644 index 00000000000..e7bc28f4a51 --- /dev/null +++ b/Packages/Triangulation_2/examples/Triangulation_2/README @@ -0,0 +1,14 @@ + +example: +Illustrates features of the triangulation package. +It has no graphical IO and does not depend on any other library. + + +voronoi: +Illustrate the use of a Delaunay triangulation and +takes the dual of the triangulation. + +points: +Illustrates how to input user defined points and a user provided traits +class in a Triangulation + diff --git a/Packages/Triangulation_2/examples/Triangulation_2/cgal_test b/Packages/Triangulation_2/examples/Triangulation_2/cgal_test new file mode 100755 index 00000000000..e3ab4522e93 --- /dev/null +++ b/Packages/Triangulation_2/examples/Triangulation_2/cgal_test @@ -0,0 +1,75 @@ +#! /bin/sh + +# This is a script for the CGAL test suite. Such a script must obey +# the following rules: +# +# - the name of the script is cgal_test +# - for every target two one line messages are written to the file 'error.txt' +# the first one indicates if the compilation was successful +# the second one indicates if the execution was successful +# if one of the two was not successful, the line should start with 'ERROR:' +# - running the script should not require any user interaction +# - the script should clean up object files and executables + +ERRORFILE=error.txt + +#---------------------------------------------------------------------# +# compile_and_run +#---------------------------------------------------------------------# + +compile_and_run() +{ + echo "Compiling $1 ... " + if eval 'make CGAL_MAKEFILE=$CGAL_MAKEFILE \ + TESTSUITE_CXXFLAGS="$TESTSUITE_CXXFLAGS" \ + TESTSUITE_LDFLAGS="$TESTSUITE_LDFLAGS" $1' ; then + echo " compilation of $1 succeeded" >> $ERRORFILE + else + echo " ERROR: compilation of $1 failed" >> $ERRORFILE + fi + + if [ -f $1 ] ; then + OUTPUTFILE=ProgramOutput.$1.$PLATFORM + rm -f $OUTPUTFILE + COMMAND="./$1" + if [ -f $1.cmd ] ; then + COMMAND="$COMMAND `cat $1.cmd`" + fi + if [ -f $1.cin ] ; then + COMMAND="echo `cat $1.cin` | $COMMAND" + fi + echo "Executing $1 ... $COMMAND" + echo + if eval 2>&1 $COMMAND > $OUTPUTFILE ; then + echo " execution of $1 succeeded" >> $ERRORFILE + else + echo " ERROR: execution of $1 failed" >> $ERRORFILE + fi + else + echo " ERROR: could not execute $1" >> $ERRORFILE + fi + + eval "2>&1 make CGAL_MAKEFILE=$CGAL_MAKEFILE clean > /dev/null " +} + +#---------------------------------------------------------------------# +# remove the previous error file +#---------------------------------------------------------------------# + +rm -f $ERRORFILE +touch $ERRORFILE + +#---------------------------------------------------------------------# +# compile and run the tests +#---------------------------------------------------------------------# + +if [ $# -ne 0 ] ; then + for file in $* ; do + compile_and_run $file + done +else + compile_and_run example + compile_and_run points + compile_and_run voronoi +fi + diff --git a/Packages/Triangulation_2/examples/Triangulation_2/data/points.cin b/Packages/Triangulation_2/examples/Triangulation_2/data/points.cin new file mode 100644 index 00000000000..289a24781a1 --- /dev/null +++ b/Packages/Triangulation_2/examples/Triangulation_2/data/points.cin @@ -0,0 +1,7 @@ +6 +0.528 -0.3245 1 0.891 -0.0825 1 +-0.748 -0.451 1 -0.022 -0.4895 1 +0.5115 0.055 1 -0.55 -0.0715 1 +-0.682 0.374 1 -0.165 0.363 1 +0.737 0.4125 1 -0.264 0.1485 1 +-0.4345 0.913 1 -0.0605 0.55 1 diff --git a/Packages/Triangulation_2/examples/Triangulation_2/data/replay b/Packages/Triangulation_2/examples/Triangulation_2/data/replay new file mode 100644 index 00000000000..289a24781a1 --- /dev/null +++ b/Packages/Triangulation_2/examples/Triangulation_2/data/replay @@ -0,0 +1,7 @@ +6 +0.528 -0.3245 1 0.891 -0.0825 1 +-0.748 -0.451 1 -0.022 -0.4895 1 +0.5115 0.055 1 -0.55 -0.0715 1 +-0.682 0.374 1 -0.165 0.363 1 +0.737 0.4125 1 -0.264 0.1485 1 +-0.4345 0.913 1 -0.0605 0.55 1 diff --git a/Packages/Triangulation_2/examples/Triangulation_2/example.C b/Packages/Triangulation_2/examples/Triangulation_2/example.C new file mode 100644 index 00000000000..1b541b83e70 --- /dev/null +++ b/Packages/Triangulation_2/examples/Triangulation_2/example.C @@ -0,0 +1,247 @@ + +#include +#include +#include +#include +#include +#include +#include +#include + +// Define shorter names to please linker (g++/egcs) +#define Cartesian C +#define Homogeneous H + +//#include +#include +//#include + + +#include +#include +#include + +class Options { +public: + Options() + : file_input(false) + + {} + + char program[100]; + char fname[100]; + bool file_input; +}; + + + +void usage(char* program) +{ + cerr << "\nNAME\n " + << program << " - Triangulation of a point set\n\n"; + cerr << "SYNOPSIS\n " + << program << " [-file fname]\n"; + + cerr << "\nDESCRIPTION\n" + << " Triangulates a point set that comes from a file or stdin.\n"; + cerr << "\nOPTIONS\n" + << " All options can be abbreviated by their first character\n\n"; +} + + +bool +parse(int argc, char* argv[], Options &opt) +{ + strcpy(opt.program, argv[0]); + --argc; + argv++; + + while ((argc > 0) && (argv[0][0] == '-')){ + if ((!strcmp(argv[0], "-f")) || (!strcmp(argv[0], "-file"))) { + strcpy(opt.fname, argv[1]); + opt.file_input = true; + argv += 2; + argc -= 2; + } + else if ((!strcmp(argv[0], "-?")) || + (!strcmp(argv[0], "-h")) || + (!strcmp(argv[0], "-help"))) { + usage(opt.program); + return false; + } + else { + cerr << "Unrecognized option " << argv[0] << endl; + usage(opt.program); + return false; + } + } + if(argc > 0){ + cerr << "Unrecognized option " << argv[0] << endl; + usage(opt.program); + return false; + } + return true; +} + + +typedef double coord_type; +//typedef leda_integer coord_type; +//typedef CGAL::Gmpz coord_type; +//typedef CGAL::Fixed coord_type; + +typedef CGAL::Cartesian Rpst; +//typedef CGAL::Homogeneous Rpst; + +typedef CGAL::Triangulation_euclidean_traits_2 Gt; +typedef CGAL::Triangulation_vertex_base_2 Vb; +typedef CGAL::Triangulation_face_base_2 Fb; +typedef CGAL::Triangulation_default_data_structure_2 Tds; +typedef CGAL::Triangulation_2 Triangulation; +//typedef CGAL::Delaunay_triangulation_2 Delaunay_triangulation_2; + +typedef Gt::Point Point; +typedef Triangulation::Face Face; +typedef Triangulation::Vertex Vertex; +typedef Triangulation::Face_handle Face_handle; +typedef Triangulation::Vertex_handle Vertex_handle; + +typedef Triangulation::Face_circulator Face_circulator; +typedef Triangulation::Vertex_circulator Vertex_circulator; + +typedef Triangulation::Locate_type Locate_type; + +typedef Triangulation::Face_iterator Face_iterator; +typedef Triangulation::Vertex_iterator Vertex_iterator; +typedef Triangulation::Edge_iterator Edge_iterator; +typedef Triangulation::Line_face_circulator Line_face_circulator; + + + +void input_from_file(Triangulation &T, + const Options& opt) +{ + if(! opt.file_input){ + return; + } + + ifstream is(opt.fname); + CGAL::set_ascii_mode(is); + + int n; + is >> n; + cout << "Reading " << n << " points" << endl; + + istream_iterator begin(is); + istream_iterator end; + T.insert(begin, end); +} + +void input_from_range(Triangulation &T) +{ + std::list L; + L.push_front(Point(0,0)); + L.push_front(Point(1,0)); + L.push_front(Point(1,1)); + + int n =T.insert(L.begin(), L.end()); + cout << n << " points inserted from a list." << endl; + + std::vector V(3); + V[0] = Point(0, 0); + V[1] = Point(0.4, 0.4); + V[2] = Point(0.3, 0.3); + + n = T.insert(V.begin(), V.end()); + cout << n << " points inserted from a vector." << endl; +} + + +void faces_along_line(Triangulation &T) +{ + Point p(0.2, 0.6), q(0.7, 0.4); + + cin >> p >> q; + Face_handle f = T.locate(p); + Line_face_circulator lfc = T.line_walk(p, q, f), + done(lfc); + if(lfc == (CGAL_NULL_TYPE) NULL){ + cout << "Line does not intersect convex hull" << endl; + } else { + int count = 0; + do{ + if(! T.is_infinite(lfc)){ + count++; + } + }while(++lfc != done); + cout << "The line intersects " << count << " finite faces" << endl; + } +} + +void convex_hull(Triangulation &T) +{ + Point p, q; + + Vertex_circulator chc = T.infinite_vertex()->incident_vertices(), + done(chc); + if(chc == (CGAL_NULL_TYPE)NULL) { + cout << "convex hull is empty" << endl; + } else { + p = chc->point(); + do { + --chc; + q = chc->point(); + p = q; + } while(chc != done); + + } +} + +void fileIO(Triangulation &T, + const Options& opt) +{ + cout << "The triangulation will be written to a file and read again\n"; + { + ofstream out("tr"); + CGAL::set_ascii_mode(out); + out << T << endl; + } + Triangulation T2; + + ifstream in("tr"); + CGAL::set_ascii_mode(in); + in >> T2; + assert( T2.is_valid() ); +} + +int +main(int argc, char* argv[]) +{ + Options opt; + parse(argc, argv, opt); + + Triangulation T; + + input_from_range(T); + input_from_file(T, opt); + + std::list L; + L.push_front(Point(0,0)); + L.push_front(Point(1,0)); + L.push_front(Point(1,1)); + + int n = T.insert(L.begin(), L.end()); + cout << n << " points inserted from a list." << endl; + + + T.insert(Point(0,0)); + T.is_valid(); + + faces_along_line(T); + + convex_hull(T); + + fileIO(T, opt); + + return 0; +} + diff --git a/Packages/Triangulation_2/examples/Triangulation_2/example.cin b/Packages/Triangulation_2/examples/Triangulation_2/example.cin new file mode 100644 index 00000000000..71db002aa52 --- /dev/null +++ b/Packages/Triangulation_2/examples/Triangulation_2/example.cin @@ -0,0 +1,2 @@ +0.743 0.34 0.523 0.234 + diff --git a/Packages/Triangulation_2/examples/Triangulation_2/example.cmd b/Packages/Triangulation_2/examples/Triangulation_2/example.cmd new file mode 100644 index 00000000000..331aaba5aca --- /dev/null +++ b/Packages/Triangulation_2/examples/Triangulation_2/example.cmd @@ -0,0 +1 @@ +-file data/replay diff --git a/Packages/Triangulation_2/examples/Triangulation_2/makefile b/Packages/Triangulation_2/examples/Triangulation_2/makefile new file mode 100644 index 00000000000..3e6ebc5a8fe --- /dev/null +++ b/Packages/Triangulation_2/examples/Triangulation_2/makefile @@ -0,0 +1,65 @@ +# This is the makefile for compiling a CGAL application. + +#---------------------------------------------------------------------# +# include platform specific settings +#---------------------------------------------------------------------# +# Choose the right include file from the /make directory. + +include $(CGAL_MAKEFILE) + + +#---------------------------------------------------------------------# +# compiler flags +#---------------------------------------------------------------------# + + +CXXFLAGS = -I../../include\ + $(CGAL_CXXFLAGS)\ + $(LONG_NAME_PROBLEM_CXXFLAGS) +# -B$(UTIL)/Binutils/SunOS/bin/ +# $(LONG_NAME_PROBLEM_CXXFLAGS) +# \ +# -g + + +#---------------------------------------------------------------------# +# linker flags +#---------------------------------------------------------------------# + +LDFLAGS = \ + $(TESTSUITE_LDFLAGS) \ + $(LONG_NAME_PROBLEM_LDFLAGS) \ + $(CGAL_LDFLAGS) + + + +#---------------------------------------------------------------------# +# target entries +#---------------------------------------------------------------------# + +# QUANTIFY = quantify + +all: points example voronoi + +points: points.o + $(CGAL_CXX) -o points points.o $(LDFLAGS) + +example: example.o + $(CGAL_CXX) -o example example.o $(LDFLAGS) + +voronoi: voronoi.o + $(CGAL_CXX) -o voronoi voronoi.o $(LDFLAGS) + + +clean: + rm -rf *~ *.o core tr + +realclean: clean + rm -rf points example voronoi Program* Compiler* Error* error.txt + +#---------------------------------------------------------------------# +# suffix rules +#---------------------------------------------------------------------# + +.C.o: + $(CGAL_CXX) $(CXXFLAGS) -c $< diff --git a/Packages/Triangulation_2/examples/Triangulation_2/points.C b/Packages/Triangulation_2/examples/Triangulation_2/points.C new file mode 100644 index 00000000000..2bf50ae8b29 --- /dev/null +++ b/Packages/Triangulation_2/examples/Triangulation_2/points.C @@ -0,0 +1,52 @@ + +#include +#include +#include +#include +#include // for the orientation + +#include "points.h" + +#include +#include + + +typedef Euclidean_2 Gt; +typedef CGAL::Triangulation_vertex_base_2 Vb; +typedef CGAL::Triangulation_face_base_2 Fb; +typedef CGAL::Triangulation_default_data_structure_2 Tds; +typedef CGAL::Triangulation_2 Triangulation; +typedef CGAL::Delaunay_triangulation_2 Delaunay_triangulation; + +int main(int argc, char* argv[]) +{ + + Triangulation T; + + PVector V; + + ifstream data(argv[1]); + + if(data.bad()){ + cout << "Problem with file " << argv[1] << endl; + } + data >> V; + + cout << V.size() << endl; + + int count = 0; + cout << "Start insertion" << endl; + for(int i = 0; ix()-p->x() ), _y( q->y()-p->y() ) {} + + double x() const { return _x; } + double y() const { return _y; } + + dir perpendicular() const { return dir(y(),-x()); } +}; + + +ostream& operator<< (ostream& os, const dir& d) +{ + os << "(" << d.x() << ", " << d.y() << ")"; + return os; +} + + + +class segment{ +public: + segment(point* s, point* t) + : _s(s), _t(t) + {} + + segment() + : _s(0), _t(0) + {} + + segment(const segment& s) + : _s(s._s), _t(s._t) + {} + + point* source() const + { + return _s; + } + + point* target() const + { + return _t; + } + + bool operator==(const segment& s) const + { + return *source() == *s.source() && *target() == *s.target(); + } + + bool operator!=(const segment& s) const + { + return *source() != *s.source() || *target() != *s.target(); + } + + dir direction() const + { + return dir(source(),target()); + } + +private: + point *_s, *_t; +}; + +ostream& operator<<(ostream& os, const segment& s) +{ + os << "(" << *(s.source()) << ", " << *(s.target()) << ")"; + return os; +} + + + + +class triangle{ +public: + triangle(point* p, point* q, point* r) + : _p(p), _q(q), _r(r) + {} + + triangle() + : _p(0), _q(0), _r(0) + {} + + triangle(const triangle& t) + : _p(t._p), _q(t._q), _r(t._r) + {} + + point* vertex(int i) const + { + switch(i){ + case 0: + return _p; + case 1: + return _q; + } + return _r; + } + + + bool operator==(const triangle& t) const + { + return vertex(0) == t.vertex(0) && vertex(1) == t.vertex(1) && vertex(2) == t.vertex(2) ; + } + + bool operator!=(const triangle& t) const + { + return vertex(0) != t.vertex(0) || vertex(1) != t.vertex(1) || vertex(2) != t.vertex(2) ; + } + +private: + point *_p, *_q, *_r; +}; + +ostream& operator<<(ostream& os, const triangle& t) +{ + os << "(" << t.vertex(0) << ", " << t.vertex(1) << ", " << t.vertex(2) << ")"; + return os; +} + + +class ray +{ +friend ostream& operator<< (ostream&, const ray&); + +protected: + point _p; + dir _d; +public: + ray() {} + ray(const point& p, const dir& d) : _p(p), _d(d) {} + + point p() const { return _p; } + dir d() const { return _d; } +}; + +ostream& operator<<(ostream& os, const ray& r) +{ + os << r.p() << "+" << r.d(); + return os; +} + + + +class PVector { +public: + PVector() + : V(NULL), _size(0) + {} + + ~PVector() + { + if(V == NULL){ + delete []V; + } + } + + int size() + { + return _size; + } + + point* operator[](int i) const + { + return V+i; + } + + void reserve(int n) + { + if(V == NULL){ + delete []V; + } + V = new point[n]; + _size = n; + } + + void read(istream& is) + { + int n; + is >> n; + + reserve(n); + double x,y; + point* ptr = V; + for(;n>0;n--){ + is >> x >> y; + ptr->_x = x; + ptr->_y = y; + ++ptr; + } + } + +private: + point* V; + int _size; +}; + +istream& operator>>(istream& is, PVector &pv) +{ + pv.read(is); + return is; +} + + +#include +#include +#include + + + +class Euclidean_2 { +public: + typedef point* Point; + typedef segment Segment; + typedef triangle Triangle; + typedef dir Direction; + typedef ray Ray; + + + bool compare(const Point &p, const Point &q) const + { + return (p == q); + } + + CGAL::Comparison_result compare_x(const Point &p, const Point &q) const + { + return CGAL::compare(p->x(), q->x()); + } + + CGAL::Comparison_result compare_y(const Point &p, const Point &q) const + { + return CGAL::compare(p->y(), q->y()); + } + + CGAL::Orientation orientation(const Point &p, + const Point &q, + const Point &r) const + { + if(*p==*q || *p == *r || *q == *r){ + cout << "coll" << endl; + return CGAL::COLLINEAR; + } + return CGAL::orientationC2(p->x(), p->y(), q->x(), q->y(), r->x(), r->y()); + } + + + CGAL::Orientation extremal(const Point &p, + const Point &q, + const Point &r) const + { + if(*p==*q || *p == *r || *q == *r){ + cout << "coll" << endl; + return CGAL::COLLINEAR; + } + return CGAL::orientationC2(p->x(), p->y(), q->x(), q->y(), r->x(), r->y()); + } + + point circumcenter(const point& p, const point& q, const point& r) + { + double px( p.x()); + double py( p.y()); + double qx( q.x()); + double qy( q.y()); + double rx( r.x()); + double ry( r.y()); + + double px_qx( px - qx); + double py_qy( py - qy); + double qx_rx( qx - rx); + double qy_ry( qy - ry); + double rx_px( rx - px); + double ry_py( ry - py); + + double px2_py2( px*px + py*py); + double qx2_qy2( qx*qx + qy*qy); + double rx2_ry2( rx*rx + ry*ry); + + double num_x( px2_py2*qy_ry + qx2_qy2*ry_py + rx2_ry2*py_qy); + double num_y( px2_py2*qx_rx + qx2_qy2*rx_px + rx2_ry2*px_qx); + + double den_x( ( px*qy_ry + qx*ry_py + rx*py_qy) * 2.0); + double den_y( ( py*qx_rx + qy*rx_px + ry*px_qx) * 2.0); + + return point(num_x/den_x, num_y/den_y); + } +}; + diff --git a/Packages/Triangulation_2/examples/Triangulation_2/voronoi.C b/Packages/Triangulation_2/examples/Triangulation_2/voronoi.C new file mode 100644 index 00000000000..cb4931713e8 --- /dev/null +++ b/Packages/Triangulation_2/examples/Triangulation_2/voronoi.C @@ -0,0 +1,184 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +// Define shorter names to please linker (g++/egcs) +#define Cartesian Cart + +#include + +#include // to avoid a g++ problem +#include +#include +#include +#include + +#include +#include + +class Options { +public: + Options() + : file_input(false) + + {} + + char program[100]; + char fname[100]; + bool file_input; +}; + + + +void usage(char* program) +{ + cerr << "\nNAME\n " + << program << " - Triangulation of a point set\n\n"; + cerr << "SYNOPSIS\n " + << program << " [-file fname]\n"; + + cerr << "\nDESCRIPTION\n" + << " Triangulates a point set that comes from a file or stdin.\n"; + cerr << "\nOPTIONS\n" + << " All options can be abbreviated by their first character\n\n"; +} + + +bool +parse(int argc, char* argv[], Options &opt) +{ + strcpy(opt.program, argv[0]); + --argc; + argv++; + + while ((argc > 0) && (argv[0][0] == '-')){ + if ((!strcmp(argv[0], "-f")) || (!strcmp(argv[0], "-file"))) { + strcpy(opt.fname, argv[1]); + opt.file_input = true; + argv += 2; + argc -= 2; + } + else if ((!strcmp(argv[0], "-?")) || + (!strcmp(argv[0], "-h")) || + (!strcmp(argv[0], "-help"))) { + usage(opt.program); + return false; + } + else { + cerr << "Unrecognized option " << argv[0] << endl; + usage(opt.program); + return false; + } + } + if(argc > 0){ + cerr << "Unrecognized option " << argv[0] << endl; + usage(opt.program); + return false; + } + return true; +} + + + + + +//typedef leda_integer coord_type; +typedef double coord_type; +//typedef CGAL::Fixed coord_type; + +typedef CGAL::Cartesian Rpst; +//typedef CGAL::Homogeneous Rpst; + +typedef CGAL::Point_2 Point; +typedef CGAL::Segment_2 Segment; +typedef CGAL::Ray_2 Ray; +typedef CGAL::Line_2 Line; +typedef CGAL::Triangle_2 Triangle; + +typedef CGAL::Triangulation_euclidean_traits_2 Gt; +typedef CGAL::Triangulation_vertex_base_2 Vb; +typedef CGAL::Triangulation_face_base_2 Fb; +typedef CGAL::Triangulation_default_data_structure_2 Tds; +typedef CGAL::Delaunay_triangulation_2 Triangulation; + +typedef Triangulation::Face Face; +typedef Triangulation::Vertex Vertex; +typedef Triangulation::Face_handle Face_handle; +typedef Triangulation::Vertex_handle Vertex_handle; + +typedef Triangulation::Face_circulator Face_circulator; +typedef Triangulation::Vertex_circulator Vertex_circulator; + +typedef Triangulation::Locate_type Locate_type; + +typedef Triangulation::Face_iterator Face_iterator; +typedef Triangulation::Vertex_iterator Vertex_iterator; +typedef Triangulation::Edge_iterator Edge_iterator; +typedef Triangulation::Line_face_circulator Line_face_circulator; + + + + +void input_from_file(Triangulation &T, + const Options& opt) +{ + if(! opt.file_input){ + return; + } + + ifstream is(opt.fname); + CGAL::set_ascii_mode(is); + + int n; + is >> n; + cout << "Reading " << n << " points" << endl; + + istream_iterator begin(is); + istream_iterator end; + T.insert(begin, end); +} + +int +main(int argc, char* argv[]) +{ + Options opt; + parse(argc, argv, opt); + + Triangulation T; + + input_from_file(T, opt); + + cout << "Vertices :" << endl << "=============" << endl; + Face_iterator fit, fbegin=T.faces_begin(), fend=T.faces_end(); + for (fit=fbegin; fit != fend; ++fit) + cout << T.dual(fit) << endl; + + cout << "Segment :" << endl << "=============" << endl; + { + Edge_iterator eit, ebegin=T.edges_begin(), eend=T.edges_end(); + for (eit=ebegin; eit != eend; ++eit) + { + CGAL::Object o = T.dual(eit); + Triangulation::Segment s; + if (CGAL::assign(s,o)) cout << s << endl; + } + } + + cout << "Rays :" << endl << "=============" << endl; + { + Edge_iterator eit, ebegin=T.edges_begin(), eend=T.edges_end(); + for (eit=ebegin; eit != eend; ++eit) + { + CGAL::Object o = T.dual(eit); + Triangulation::Ray r; + if (CGAL::assign(r,o)) cout << r << endl; + } + } + + return 0; +} diff --git a/Packages/Triangulation_2/examples/Triangulation_2/voronoi.cmd b/Packages/Triangulation_2/examples/Triangulation_2/voronoi.cmd new file mode 100644 index 00000000000..331aaba5aca --- /dev/null +++ b/Packages/Triangulation_2/examples/Triangulation_2/voronoi.cmd @@ -0,0 +1 @@ +-file data/replay