//file: examples/Polyhedron_IO/terr_trian.C // Delaunay Triangulation of a set of 3D points in the xy-plane. // (Terrain triangulation) #include #include #include #include #include #include #include #include #include #include #include #include #include #include "triangulation_print_OFF.h" using namespace std; template class Indexed_point: public CGAL::Point_3 { typedef CGAL::Point_3 Point_3; public: int* index; Indexed_point() {} Indexed_point( Point_3 p) : Point_3(p) {} Indexed_point( double x, double y, double z, int* i) : Point_3(x,y,z), index(i) {} }; typedef CGAL::Simple_cartesian SC; typedef CGAL::Filtered_kernel Kernel; typedef Indexed_point IPoint; typedef CGAL::Triangulation_euclidean_traits_xy_3 Gtraits; struct Gt : public Gtraits { typedef IPoint Point; }; typedef CGAL::Triangulation_2 Triangulation; typedef CGAL::Delaunay_triangulation_2 Delaunay_triangulation; bool verbose = false; bool binary = false; bool noc = false; bool delaunay = false; bool incr = false; // main function with standard unix commandline arguments // ------------------------------------------------------ int main( int argc, char **argv) { int n = 0; // number of filenames char *filename[2]; bool help = false; for (int i = 1; i < argc; i++) { // check commandline options if ( strcmp( "-v", argv[i]) == 0) verbose = true; else if ( strcmp( "-b", argv[i]) == 0) binary = true; else if ( strcmp( "-noc", argv[i]) == 0) noc = true; else if ( strcmp( "-delaunay", argv[i]) == 0) delaunay = true; else if ( strcmp( "-incr", argv[i]) == 0) incr = true; else if ( (strcmp( "-h", argv[i]) == 0) || (strcmp( "-help", argv[i]) == 0)) help = true; else if ( n < 2 ) { filename[ n++] = argv[i]; } else { ++n; break; } } if ((n > 2) || help) { if ( ! help) cerr << "Error: in parameter list" << endl; cerr << "Usage: " << argv[0] << " [] [ []]" << endl; cerr << " Terrain triangulation in the xy-plane." << endl; cerr << " -delaunay Delaunay triangulation (default)." << endl; cerr << " -incr Incremental insertion (no flips)." << endl; cerr << " -b binary output (default is ASCII)." << endl; cerr << " -noc no comments in file." << endl; cerr << " -v verbose." << endl; exit( ! help); } CGAL::Verbose_ostream vout( verbose); vout << argv[0] << ": verbosity on." << endl; const char* iname = "cin"; istream* p_in = &cin; ifstream in; if ( n > 0) { in.open( filename[0]); p_in = ∈ iname = filename[0]; } if ( !*p_in) { cerr << argv[0] << ": error: cannot open file '" << iname << "' for reading." < 1) { out.open( filename[1]); p_out = &out; oname = filename[1]; } if ( !*p_out) { cerr << argv[0] << ": error: cannot open file '"<< oname << "' for writing." <