diff --git a/.gitattributes b/.gitattributes index 8e37e0a3baf..5c896149b09 100644 --- a/.gitattributes +++ b/.gitattributes @@ -419,6 +419,7 @@ Developers_manual/doc_tex/Developers_manual/fig/reference_counting.pdf -text svn Developers_manual/doc_tex/Developers_manual/fig/use_real.eps -text svneol=unset#application/postscript Developers_manual/doc_tex/Developers_manual/fig/use_real.gif -text svneol=unset#image/gif Developers_manual/doc_tex/Developers_manual/fig/use_real.pdf -text svneol=unset#application/pdf +Envelope_2/examples/Envelope_2/example1.C -text Generator/demo/Generator/help/index.html svneol=native#text/html Generator/doc_tex/Generator/Segment_generator_prog1.gif -text svneol=unset#image/gif Generator/doc_tex/Generator/Segment_generator_prog1.pdf -text svneol=unset#application/pdf diff --git a/Envelope_2/examples/Envelope_2/example1.C b/Envelope_2/examples/Envelope_2/example1.C new file mode 100644 index 00000000000..2de06514083 --- /dev/null +++ b/Envelope_2/examples/Envelope_2/example1.C @@ -0,0 +1,85 @@ +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include + + +//typedef CGAL::Gmpq NT; +typedef CGAL::Quotient NT; +typedef CGAL::Cartesian Kernel; +typedef CGAL::Arr_segment_traits_2 Traits_2; + +typedef Traits_2::Point_2 Point_2; +typedef Traits_2::Curve_2 Curve_2; +typedef Traits_2::X_monotone_curve_2 X_monotone_curve_2; + +typedef CGAL::Envelope_2 Env_2; + +typedef std::vector CurveVector; + + + +int main(int argc,char **argv) +{ + if (argc<2) + { + std::cerr<< "Missing file name\n"; + return -1; + } + std::ifstream in_file(argv[1]); + if (!in_file.is_open()) { + std::cerr << "Cannot open file: " << argv[1] << "!" << std::endl; + return -1; + } + + CurveVector curves; + int num_of_curves; + + in_file >> num_of_curves; + curves.resize(num_of_curves); + for(int i = 0 ; i < num_of_curves ; i++) + { + NT x1 , y1 , x2 , y2; +#ifdef MACHINE_NATIVE + read_native(in_file, x1); + read_native(in_file, y1); + read_native(in_file, x2); + read_native(in_file, y2); +#else + in_file >> x1 >> y1 >> x2 >> y2; +#endif + + curves[i] = Curve_2(Point_2(x1,y1), Point_2(x2,y2)); + } + + + Env_2 env; + + env.insert (curves.begin(), curves.end(), Env_2::LOWER); + Env_2::Vertex_iterator vi = env.begin(); + Env_2::Vertex_iterator vi_end = env.end(); + + + while (vi != vi_end) + { + std::cout<<"( " <<*vi<<" )" << " => "; + if(vi.right() == NULL) + std::cout<<"NULL => "; + else + std::cout<<(*(vi.right()))<<" => "; + ++vi; + } + std::cout<<"\n"; + + + return 0; +} +