From 25097caed9d16e6209cf547c0df2fd64a29f16d9 Mon Sep 17 00:00:00 2001 From: Pedro Machado Manhaes de Castro Date: Mon, 28 Jul 2008 17:48:01 +0000 Subject: [PATCH] The actual circular_kernel_2 demo --- .../Circular_kernel_2/Qt_widget_get_arc.h | 7 +- .../demo/Circular_kernel_2/demo.cpp | 294 ++++------ .../demo_Lazy_line_circle.cpp | 547 ------------------ .../demo/Circular_kernel_2/demo_circle.cpp | 479 --------------- .../demo/Circular_kernel_2/demo_elias.cpp | 486 ---------------- .../demo/Circular_kernel_2/demo_line.cpp | 486 ---------------- .../demo/Circular_kernel_2/demo_viewer.cpp | 375 ------------ .../demo/Circular_kernel_2/help/index.html | 109 +--- .../demo/Circular_kernel_2/makefile | 2 +- 9 files changed, 111 insertions(+), 2674 deletions(-) delete mode 100644 Circular_kernel_2/demo/Circular_kernel_2/demo_Lazy_line_circle.cpp delete mode 100644 Circular_kernel_2/demo/Circular_kernel_2/demo_circle.cpp delete mode 100644 Circular_kernel_2/demo/Circular_kernel_2/demo_elias.cpp delete mode 100644 Circular_kernel_2/demo/Circular_kernel_2/demo_line.cpp delete mode 100644 Circular_kernel_2/demo/Circular_kernel_2/demo_viewer.cpp diff --git a/Circular_kernel_2/demo/Circular_kernel_2/Qt_widget_get_arc.h b/Circular_kernel_2/demo/Circular_kernel_2/Qt_widget_get_arc.h index 87c6a67a059..c0ecfb14874 100644 --- a/Circular_kernel_2/demo/Circular_kernel_2/Qt_widget_get_arc.h +++ b/Circular_kernel_2/demo/Circular_kernel_2/Qt_widget_get_arc.h @@ -358,11 +358,8 @@ public: Line l2 (second_point, center); return Circular_arc_2 (circ, - // FIXME which one is newer? - //l1, compare_lexicographically_xy(first_point, center) == CGAL::SMALLER, - //l2, compare_lexicographically_xy(second_point, center) == CGAL::SMALLER); - l1, CGAL::compare_xy(first_point, center) == CGAL::SMALLER, - l2, CGAL::compare_xy(second_point, center) == CGAL::SMALLER); + l1, CGAL::compare_xy(first_point, center) == CGAL::SMALLER, + l2, CGAL::compare_xy(second_point, center) == CGAL::SMALLER); } private: diff --git a/Circular_kernel_2/demo/Circular_kernel_2/demo.cpp b/Circular_kernel_2/demo/Circular_kernel_2/demo.cpp index d334c18a12d..2fdf2dc0379 100644 --- a/Circular_kernel_2/demo/Circular_kernel_2/demo.cpp +++ b/Circular_kernel_2/demo/Circular_kernel_2/demo.cpp @@ -26,12 +26,8 @@ int main() { return 0; } #else - -#include - -#include -#include #include +#include #include #include #include @@ -55,109 +51,100 @@ int main() { #include #include - #include "Qt_widget_get_segment.h" #include "Qt_widget_get_arc.h" #include "sweeper.xpm" #include "trash.xpm" #include "get_arc.xpm" -#include "planar_map_icon.xpm" #include "lines_icon.xpm" #include - #include -// #include -#include - -#include -#include -#include +#include typedef CGAL::Quotient NT; -//typedef CGAL::Quotient NT; -//typedef CGAL::Lazy_exact_nt NT; -//typedef boost::variant< Circular_arc_2, Line_arc_2 > Arc_2; -//typedef std::vector + typedef CGAL::Cartesian Linear_k; typedef CGAL::Algebraic_kernel_for_circles_2_2 Algebraic_k; typedef CGAL::Circular_kernel_2 Circular_k; -// typedef CGAL::Exact_circular_kernel_2 Circular_k; typedef Circular_k::Line_arc_2 Line_arc_2; typedef Circular_k::Segment_2 Segment; typedef Circular_k::Circular_arc_2 Circular_arc_2; +typedef Circular_k::Circular_arc_point_2 Circular_arc_point_2; -typedef CGAL::Arr_circular_line_arc_traits Traits; +typedef std::vector ArcContainer; -typedef Traits::Point_2 Point_2; -typedef Traits::Curve_2 Curve_2; -//typedef boost::variant< Circular_arc_2, Line_arc_2 > Arc_2; -//typedef std::vector -typedef std::vector ArcContainer; - -typedef CGAL::Arrangement_2 Pmwx; -typedef CGAL::Arr_naive_point_location Point_location; - -const QString my_title_string("Planar Map of Intersecting Circular Arcs"); +const QString my_title_string("CGAL :: " + "Intersecting Circles, Line Arcs, Circular Arcs"); // This layer controls the drawing of the Planar Map. -class Qt_layer_do_sweep +class Qt_layer_show_intersections : public CGAL::Qt_widget_layer { - Pmwx _pm; - Point_location _pl; - bool show_pmwx; + ArcContainer _ac; + bool show_intersections; public: - Qt_layer_do_sweep() - : _pm(), _pl(_pm), show_pmwx(true) {} + Qt_layer_show_intersections() + : _ac(), show_intersections(true) {} - void swap_show() { show_pmwx = ! show_pmwx; } + void swap_show() { show_intersections = ! show_intersections; } - const Pmwx & pm() const { return _pm; } - Pmwx & pm() { return _pm; } - - const Point_location & pl() const { return _pl; } - Point_location & pl() { return _pl; } + const ArcContainer & arc_container() const { return _ac; } + ArcContainer & arc_container() { return _ac; } void draw() { - if (! show_pmwx) + if (!show_intersections) return; + *widget << CGAL::RED; + int l = _ac.size(); - *widget << CGAL::GREEN; - for (Pmwx::Halfedge_const_iterator ei = pm().halfedges_begin(); - ei != pm().halfedges_end (); ++ei) { - if(const Line_arc_2* line = boost::get( &(ei->curve()))) { - *widget << Segment(Circular_k::Point_2(to_double(line->source().x()), - to_double(line->source().y())), - Circular_k::Point_2(to_double(line->target().x()), - to_double(line->target().y()))); - } - else if (const Circular_arc_2* arc - = boost::get( &(ei->curve()))) { - *widget << *arc; - } - } - *widget << CGAL::RED; - for (Pmwx::Vertex_const_iterator vi = pm().vertices_begin(); - vi != pm().vertices_end(); ++vi) - *widget << vi->point(); + for(int i=0; i res; + Circular_arc_2 ca1, ca2; + Line_arc_2 la1, la2; + if(assign(ca1, _ac[i])) { + if(assign(ca2, _ac[j])) { + CGAL::intersection(ca1, ca2, std::back_inserter(res)); + } else { + CGAL::intersection(ca1, la2, std::back_inserter(res)); + } + } else { + if(assign(ca2, _ac[j])) { + CGAL::intersection(la1, ca2, std::back_inserter(res)); + } else { + CGAL::intersection(la1, la2, std::back_inserter(res)); + } + } + for(unsigned k=0; k pair; + Circular_arc_2 ca; + Line_arc_2 la; + if(assign(pair, res[k])) *widget << pair.first; + else if(assign(ca, res[k])) *widget << ca; + else if(assign(la, res[k])) { + *widget << Segment(Circular_k::Point_2(to_double(la.source().x()), + to_double(la.source().y())), + Circular_k::Point_2(to_double(la.target().x()), + to_double(la.target().y()))); + } + } + } + } } }; - // This layer controls the drawing of the arc_container. struct Qt_layer_show_ch : public CGAL::Qt_widget_layer { - ArcContainer _arc_container; + ArcContainer _ac; bool show_arcs; public: @@ -165,10 +152,9 @@ public: Qt_layer_show_ch() : show_arcs(true) {} - const ArcContainer & - arc_container() const { return _arc_container; } - ArcContainer & - arc_container() { return _arc_container; } + const ArcContainer & arc_container() const { return _ac; } + + ArcContainer & arc_container() { return _ac; } void swap_show() { show_arcs = ! show_arcs; } @@ -176,25 +162,22 @@ public: { if (!show_arcs) return; - *widget << CGAL::BLUE; - for (ArcContainer::const_iterator cit = arc_container().begin(); - cit != arc_container().end(); ++cit){ - if(const Line_arc_2* line = boost::get( &(*cit))){ - *widget << Segment(Circular_k::Point_2(to_double(line->source().x()), - to_double(line->source().y())), - Circular_k::Point_2(to_double(line->target().x()), - to_double(line->target().y()))); - } - else if (const Circular_arc_2* arc - = boost::get( &(*cit))) { - *widget << *arc; + int l = _ac.size(); + for (int i=0; iinsertItem("&New", this, SLOT(new_instance()), CTRL+Key_N); file->insertItem("New &Window", this, SLOT(new_window()), CTRL+Key_W); file->insertSeparator(); - file->insertItem("&Load Arcs", this, SLOT(load_arcs()), CTRL+Key_L); - file->insertItem("&Save Arcs", this, SLOT(save_arcs()), CTRL+Key_S); - file->insertSeparator(); file->insertItem("Print", widget, SLOT(print_to_ps()), CTRL+Key_P); file->insertSeparator(); file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_X ); @@ -243,19 +223,19 @@ public: QToolBar * layers_toolbar = new QToolBar("Tools", this, QMainWindow::Top, TRUE, "Tools"); - // the sweep button - QToolButton * sweep_button = + // the show intersections button + QToolButton * show_intersections_button = new QToolButton(QPixmap((const char**)::sweeper_xpm ), - "Let's do the Sweep", + "Showing Intersections", 0, this, - SLOT(update_pmwx()), + SLOT(show_intersections()), layers_toolbar, - "Let's do the Sweep"); + "Showing Intersections"); - widget->attach(&do_sweep_layer); - connect(sweep_button, SIGNAL(stateChanged(int)), - &do_sweep_layer, SLOT(stateChanged(int))); + widget->attach(&show_intersections_layer); + connect(show_intersections_button, SIGNAL(stateChanged(int)), + &show_intersections_layer, SLOT(stateChanged(int))); // the button controlling if we show the input arcs QToolButton * show_container_button = @@ -272,22 +252,6 @@ public: connect(show_container_button, SIGNAL(stateChanged(int)), &testlayer, SLOT(stateChanged(int))); - // the button controlling if we show the planar map - QToolButton * show_pmwx_button = - new QToolButton(QPixmap((const char**)::planar_map_icon), - "Show Computed Planar Map", - 0, - this, - SLOT(show_pmwx_arcs()), - layers_toolbar, - "Show Computed Planar Map"); - show_pmwx_button->setToggleButton(true); - - show_pmwx_button->toggle(); - connect(show_pmwx_button, SIGNAL(stateChanged(int)), - &testlayer, SLOT(stateChanged(int))); - - // the button controlling if we use circular arcs or line QToolButton * line_circle_button = new QToolButton(QPixmap((const char**)::lines_icon), @@ -301,9 +265,7 @@ public: line_circle_button->setToggleButton(true); arc_circle = true; - - - // this button clears the content of the arc container and the PMWX. + // this button clears the content of the arc container QToolButton * clear_button = new QToolButton(QPixmap((const char**)trash), "Clear", @@ -316,7 +278,6 @@ public: connect(clear_button, SIGNAL(stateChanged(int)), &testlayer, SLOT(stateChanged(int))); - *widget << CGAL::LineWidth(2) << CGAL::BackgroundColor(CGAL::WHITE); resize(w,h); @@ -340,36 +301,23 @@ public slots: widget->lock(); widget->clear_history(); widget->set_window(-1.1, 1.1, -1.1, 1.1); - // set the Visible Area to the Interval widget->unlock(); something_changed = true; } void get_arc() { - Curve_2 v; - if (arc_circle){ - v = get_arc_layer->get_circular_arc(); + CGAL::Object o; + if (arc_circle) { + Circular_arc_2 ca = get_arc_layer->get_circular_arc(); + o = make_object(ca); } - else{ - v = get_segment_layer->get_line_arc(); - } - arc_container().push_back(v); - insert_curve(pm(),arc_container().back(),pl()); - something_changed = true; - widget->redraw(); - } - - void update_pmwx() - { - std::cout << " Recomputing the Planar Map using a sweep." << std::endl; - if (arc_container().size() != 0) { // because currently it crashes... - pm().clear(); - for (ArcContainer::const_iterator it=arc_container().begin(); - it != arc_container().end(); ++it) { - insert_curve(pm(),*it,pl()); - }; + else { + Line_arc_2 la = get_segment_layer->get_line_arc(); + o = make_object(la); } + arc_container().push_back(o); + intersections_container().push_back(o); something_changed = true; widget->redraw(); } @@ -381,9 +329,9 @@ public slots: widget->redraw(); } - void show_pmwx_arcs() + void show_intersections() { - do_sweep_layer.swap_show(); + show_intersections_layer.swap_show(); something_changed = true; widget->redraw(); } @@ -405,7 +353,7 @@ public slots: void clear_container() { arc_container().clear(); - pm().clear(); + intersections_container().clear(); something_changed = true; widget->redraw(); } @@ -414,9 +362,7 @@ private slots: void about() { - QMessageBox::about(this, my_title_string, - "This is a demo of CGAL's Planar Map of intersecting Circle Arcs\n" - "Using the Circular_kernel by Sylvain Pion and Monique Teillaud"); + QMessageBox::about(this, my_title_string, "This is a demo of the CGAL's Circular_kernel_2.\n Particularly, the intersection functionality."); } void aboutQt() @@ -450,67 +396,27 @@ private slots: something_changed = false; } - void load_arcs() - { - QString s( QFileDialog::getOpenFileName( QString::null, - "DXF files (*.dxf)", this ) ); - if ( s.isEmpty() ) - return; - - //std::ifstream in(s); - //CGAL::set_ascii_mode(in); - - //std::istream_iterator begin(in), end; - //ArcContainer arcs(begin, end); - //arc_container().swap(arcs); - - //to read dxf files - std::ifstream in(s); - CGAL::set_ascii_mode(in); - ArcContainer arcs; - CGAL::variant_load(in, std::back_inserter(arcs)); - arc_container().swap(arcs); - - - update_pmwx(); - stoolbar->clear_history(); - something_changed = true; - } - - void save_arcs() - { - QString fileName = - QFileDialog::getSaveFileName( "arcs.cgal", - "CGAL files (*.cgal)", this ); - if ( !fileName.isNull() ) { - // got a file name - std::ofstream out(fileName); - CGAL::set_ascii_mode(out); - // std::copy(arc_container().begin(), arc_container().end(), - // std::ostream_iterator(out, "\n")); - } - } - private: bool arc_circle; - Pmwx const & pm() const { return do_sweep_layer.pm(); } - Pmwx & pm() { return do_sweep_layer.pm(); } - - Point_location const & pl() const { return do_sweep_layer.pl(); } - Point_location & pl() { return do_sweep_layer.pl(); } - const ArcContainer & arc_container() const { return testlayer.arc_container(); } + ArcContainer & arc_container() { return testlayer.arc_container(); } - CGAL::Qt_widget *widget; - CGAL::Qt_widget_standard_toolbar *stoolbar; - bool something_changed; - Qt_layer_show_ch testlayer; - Qt_layer_do_sweep do_sweep_layer; - CGAL::Qt_widget_get_segment *get_segment_layer; + const ArcContainer & intersections_container() const + { return show_intersections_layer.arc_container(); } + + ArcContainer & intersections_container() + { return show_intersections_layer.arc_container(); } + + CGAL::Qt_widget *widget; + CGAL::Qt_widget_standard_toolbar *stoolbar; + bool something_changed; + Qt_layer_show_ch testlayer; + Qt_layer_show_intersections show_intersections_layer; + CGAL::Qt_widget_get_segment *get_segment_layer; CGAL::Qt_widget_get_arc *get_arc_layer; }; diff --git a/Circular_kernel_2/demo/Circular_kernel_2/demo_Lazy_line_circle.cpp b/Circular_kernel_2/demo/Circular_kernel_2/demo_Lazy_line_circle.cpp deleted file mode 100644 index 55ca30ed350..00000000000 --- a/Circular_kernel_2/demo/Circular_kernel_2/demo_Lazy_line_circle.cpp +++ /dev/null @@ -1,547 +0,0 @@ -// Copyright (c) 2003-2008 INRIA Sophia-Antipolis (France) and -// Max-Planck-Institute Saarbruecken (Germany). -// All rights reserved. -// -// $URL$ -// $Id$ -// -// Authors : Monique Teillaud, Sylvain Pion, Radu Ursu -// -// Partially supported by the IST Programme of the EU as a Shared-cost -// RTD (FET Open) Project under Contract No IST-2000-26473 -// (CGAL - Effective Computational Geometry for Curves and Surfaces) - -// TODO : -// - Add the possibility to input full circles. -// - locate the cell containing a point. -// - Move more basic IO routines in include/CGAL/IO/ -// - File menu - -#include - -// if QT is not installed, a message will be issued at runtime. -#ifndef CGAL_USE_QT -#include -int main() { - std::cout << "Sorry, this demo needs QT..." << std::endl; - return 0; -} -#else - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "Qt_widget_get_segment.h" -#include "Qt_widget_get_arc.h" -#include "sweeper.xpm" -#include "trash.xpm" -#include "get_arc.xpm" -#include "planar_map_icon.xpm" -#include "lines_icon.xpm" - -#include - -#include -#include -#include -#include - - -#include -#include -#include - -typedef CGAL::Quotient NT1; -typedef CGAL::Cartesian Linear_k1; -typedef CGAL::Algebraic_kernel_for_circles_2_2 Algebraic_k1; -typedef CGAL::Circular_kernel_2 CK1_; - -typedef CGAL::Interval_nt_advanced NT2; -typedef CGAL::Cartesian Linear_k2; -typedef CGAL::Algebraic_kernel_for_circles_2_2 Algebraic_k2; -typedef CGAL::Circular_kernel_2 CK2_; -typedef CGAL::Lazy_circular_kernel_2 Circular_k; - -typedef Circular_k::Line_arc_2 Line_arc_2; -typedef Circular_k::Segment_2 Segment; -typedef Circular_k::Circular_arc_2 Circular_arc_2; -typedef boost::variant< Circular_arc_2, Line_arc_2 > Arc_2; -typedef std::vector ArcContainer; - -#ifndef CGAL_CURVED_KERNEL_DEBUG -typedef CGAL::Arr_circular_line_arc_traits - Traits; -#else -typedef CGAL::Arr_circular_line_arc_traits - Traits0; -typedef CGAL::Circular_arc_traits_tracer Traits; -#endif - -typedef Traits::Point_2 Point_2; -typedef Traits::Curve_2 Conic_arc_2; -typedef CGAL::Arrangement_2 Pmwx; -typedef CGAL::Arr_naive_point_location Point_location; - -typedef Traits::X_monotone_curve_2 X_monotone_curve_2; - - - -const QString my_title_string("CGAL :: " - "Planar Map of Intersecting Circular Arcs"); - -// This layer controls the drawing of the Planar Map. -class Qt_layer_do_sweep - : public CGAL::Qt_widget_layer -{ - Pmwx _pm; - Point_location _pl; - bool show_pmwx; - -public: - - Qt_layer_do_sweep() - : _pm(), _pl(_pm), show_pmwx(true) {} - - void swap_show() { show_pmwx = ! show_pmwx; } - - const Pmwx & pm() const { return _pm; } - Pmwx & pm() { return _pm; } - - const Point_location & pl() const { return _pl; } - Point_location & pl() { return _pl; } - - void draw() - { - if (! show_pmwx) - return; - - *widget << CGAL::GREEN; - for (Pmwx::Halfedge_const_iterator ei = pm().halfedges_begin(); - ei != pm().halfedges_end (); ++ei){ - if(const Line_arc_2* line = boost::get( &(ei->curve()))){ - *widget << Segment(Circular_k::Point_2(to_double(line->source().x()), - to_double(line->source().y())), - Circular_k::Point_2(to_double(line->target().x()), - to_double(line->target().y()))); -// std::cout << " source line " << Circular_k::Point_2(to_double(line->source().x()), -// to_double(line->source().y())).approx() << std::endl; -// std::cout << " target line" << Circular_k::Point_2(to_double(line->target().x()), -// to_double(line->target().y())).approx() << std::endl; - - } - else if (const Circular_arc_2* arc = boost::get( &(ei->curve()))){ - *widget << *arc; -// std::cout << " source arc" << arc->source().approx() << std::endl; -// std::cout << " target arc" << arc->target().approx() << std::endl; - } - } - *widget << CGAL::RED; - for (Pmwx::Vertex_const_iterator vi = pm().vertices_begin(); - vi != pm().vertices_end(); ++vi) - *widget << vi->point(); - } -}; - - -// This layer controls the drawing of the arc_container. -struct Qt_layer_show_ch - : public CGAL::Qt_widget_layer -{ - ArcContainer _arc_container; - bool show_arcs; - -public: - - Qt_layer_show_ch() - : show_arcs(true) {} - - const ArcContainer & - arc_container() const { return _arc_container; } - ArcContainer & - arc_container() { return _arc_container; } - - void swap_show() { show_arcs = ! show_arcs; } - - void draw() - { - if (!show_arcs) - return; - - *widget << CGAL::BLUE; - for (ArcContainer::const_iterator cit = arc_container().begin(); - cit != arc_container().end(); ++cit){ - if(const Line_arc_2* line = boost::get( &(*cit))){ - *widget << Segment(Circular_k::Point_2(to_double(line->source().x()), - to_double(line->source().y())), - Circular_k::Point_2(to_double(line->target().x()), - to_double(line->target().y()))); - } - else if (const Circular_arc_2* arc = boost::get( &(*cit))){ - *widget << *arc; - } - } - } -}; - - -class MyWindow - : public QMainWindow -{ - Q_OBJECT - -public: - - MyWindow(int w, int h) - : something_changed(true) - { - widget = new CGAL::Qt_widget(this); - setCentralWidget(widget); - - // create a timer for checking if something changed - QTimer *timer = new QTimer( this ); - connect( timer, SIGNAL(timeout()), this, SLOT(timer_done()) ); - timer->start( 200, FALSE ); - - // file menu - QPopupMenu * file = new QPopupMenu( this ); - menuBar()->insertItem( "&File", file ); - file->insertItem("&New", this, SLOT(new_instance()), CTRL+Key_N); - file->insertItem("New &Window", this, SLOT(new_window()), CTRL+Key_W); - file->insertSeparator(); - file->insertItem("&Load Arcs", this, SLOT(load_arcs()), CTRL+Key_L); - file->insertItem("&Save Arcs", this, SLOT(save_arcs()), CTRL+Key_S); - file->insertSeparator(); - file->insertItem("Print", widget, SLOT(print_to_ps()), CTRL+Key_P); - file->insertSeparator(); - file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_X ); - file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q ); - - - // help menu - QPopupMenu * help = new QPopupMenu( this ); - menuBar()->insertItem( "&Help", help ); - help->insertItem("How To", this, SLOT(howto()), Key_F1); - help->insertSeparator(); - help->insertItem("&About", this, SLOT(about()), CTRL+Key_A ); - help->insertItem("About &Qt", this, SLOT(aboutQt()) ); - - // the standard toolbar - stoolbar = new CGAL::Qt_widget_standard_toolbar (widget, this, "ST"); - - // my tool bar - QToolBar * layers_toolbar = new QToolBar("Tools", this, - QMainWindow::Top, TRUE, "Tools"); - - // the sweep button - QToolButton * sweep_button = - new QToolButton(QPixmap((const char**)::sweeper_xpm ), - "Let's do the Sweep", - 0, - this, - SLOT(update_pmwx()), - layers_toolbar, - "Let's do the Sweep"); - - widget->attach(&do_sweep_layer); - connect(sweep_button, SIGNAL(stateChanged(int)), - &do_sweep_layer, SLOT(stateChanged(int))); - - // the button controlling if we show the input arcs - QToolButton * show_container_button = - new QToolButton(QPixmap((const char**)::get_arc), - "Show Original arcs", - 0, - this, - SLOT(show_original_arcs()), - layers_toolbar, - "Show Original arcs"); - show_container_button->setToggleButton(true); - - show_container_button->toggle(); - connect(show_container_button, SIGNAL(stateChanged(int)), - &testlayer, SLOT(stateChanged(int))); - - // the button controlling if we show the planar map - QToolButton * show_pmwx_button = - new QToolButton(QPixmap((const char**)::planar_map_icon), - "Show Computed Planar Map", - 0, - this, - SLOT(show_pmwx_arcs()), - layers_toolbar, - "Show Computed Planar Map"); - show_pmwx_button->setToggleButton(true); - - show_pmwx_button->toggle(); - connect(show_pmwx_button, SIGNAL(stateChanged(int)), - &testlayer, SLOT(stateChanged(int))); - - - // the button controlling if we use circular arcs or line - QToolButton * line_circle_button = - new QToolButton(QPixmap((const char**)::lines_icon), - "Use Line", - 0, - this, - SLOT(change_line_circle()), - layers_toolbar, - "Use Circular arc"); - - line_circle_button->setToggleButton(true); - arc_circle = true; - - - - // this button clears the content of the arc container and the PMWX. - QToolButton * clear_button = - new QToolButton(QPixmap((const char**)trash), - "Clear", - 0, - this, - SLOT(clear_container()), - layers_toolbar, - "Clear"); - - connect(clear_button, SIGNAL(stateChanged(int)), - &testlayer, SLOT(stateChanged(int))); - - - *widget << CGAL::LineWidth(2) << CGAL::BackgroundColor(CGAL::WHITE); - - resize(w,h); - widget->set_window(-1, 1, -1, 1); - widget->setMouseTracking(TRUE); - - // layers - widget->attach(&testlayer); - get_arc_layer = new CGAL::Qt_widget_get_arc; - get_segment_layer = new CGAL::Qt_widget_get_segment; - widget->attach(get_arc_layer); - connect(get_arc_layer, SIGNAL(new_object_time()), this, SLOT(get_arc())); - connect(get_segment_layer, SIGNAL(new_object_time()), this, SLOT(get_arc())); - } - -public slots: - - void new_instance() - { - widget->lock(); - widget->clear_history(); - widget->set_window(-1.1, 1.1, -1.1, 1.1); - // set the Visible Area to the Interval - widget->unlock(); - something_changed = true; - } - - void get_arc() - { - X_monotone_curve_2 v; - if (arc_circle){ - v = get_arc_layer->get_circular_arc(); - } - else{ - v = get_segment_layer->get_line_arc(); - } - arc_container().push_back(v); - insert_curve(pm(),arc_container().back(),pl()); - something_changed = true; - widget->redraw(); - } - - void update_pmwx() - { - std::cout << " Recomputing the Planar Map using a sweep." << std::endl; -// if (arc_container().size() != 0) { // because currently it crashes... - pm().clear(); -// for (ArcContainer::const_iterator it=arc_container().begin(); -// it != arc_container().end(); ++it) { -// insert(pm(),*it,pl()); -// }; -// } - insert_curves(pm(),arc_container().begin(), arc_container().end()); - std::cout << pm().number_of_vertices() << std::endl; - std::cout << pm().number_of_halfedges() << std::endl; - something_changed = true; - widget->redraw(); - } - - void show_original_arcs() - { - testlayer.swap_show(); - something_changed = true; - widget->redraw(); - } - - void show_pmwx_arcs() - { - do_sweep_layer.swap_show(); - something_changed = true; - widget->redraw(); - } - - void change_line_circle(){ - arc_circle = ! arc_circle; - if(arc_circle){ - widget->detach(get_segment_layer); - widget->attach(get_arc_layer); - } - else{ - widget->detach(get_arc_layer); - widget->attach(get_segment_layer); - } - something_changed = true; - widget->redraw(); - } - - void clear_container() - { - arc_container().clear(); - pm().clear(); - something_changed = true; - widget->redraw(); - } - -private slots: - - void about() - { - QMessageBox::about(this, my_title_string, - "This is a demo of CGAL's Planar Map of intersecting Circle Arcs\n" - "Using the Circular_kernel by Sylvain Pion and Monique Teillaud"); - } - - void aboutQt() - { - QMessageBox::aboutQt(this, my_title_string); - } - - void howto() - { - CGAL::Qt_help_window *help = - new CGAL::Qt_help_window("help/index.html", ".", 0, "help viewer"); - help->resize(400, 400); - help->setCaption("Demo HowTo"); - help->show(); - } - - void new_window() - { - MyWindow *ed = new MyWindow(500, 500); - ed->setCaption("Layer"); - ed->widget->clear_history(); - ed->widget->set_window(-1.1, 1.1, -1.1, 1.1); - ed->show(); - something_changed = true; - } - - void timer_done() - { - if (something_changed) - widget->redraw(); - something_changed = false; - } - - void load_arcs() - { - QString s( QFileDialog::getOpenFileName( QString::null, - "DXF files (*.dxf)", this ) ); - if ( s.isEmpty() ) - return; - - //std::ifstream in(s); - //CGAL::set_ascii_mode(in); - - //std::istream_iterator begin(in), end; - //ArcContainer arcs(begin, end); - //arc_container().swap(arcs); - - //to read dxf files - std::ifstream in(s); - CGAL::set_ascii_mode(in); - ArcContainer arcs; - CGAL::variant_load(in, std::back_inserter(arcs)); - arc_container().swap(arcs); - - - update_pmwx(); - stoolbar->clear_history(); - something_changed = true; - } - - void save_arcs() - { - QString fileName = - QFileDialog::getSaveFileName( "arcs.cgal", - "CGAL files (*.cgal)", this ); - if ( !fileName.isNull() ) { - // got a file name - std::ofstream out(fileName); - CGAL::set_ascii_mode(out); - // std::copy(arc_container().begin(), arc_container().end(), - // std::ostream_iterator(out, "\n")); - } - } - -private: - bool arc_circle; - Pmwx const & pm() const { return do_sweep_layer.pm(); } - Pmwx & pm() { return do_sweep_layer.pm(); } - - Point_location const & pl() const { return do_sweep_layer.pl(); } - Point_location & pl() { return do_sweep_layer.pl(); } - - - const ArcContainer & arc_container() const - { return testlayer.arc_container(); } - ArcContainer & arc_container() - { return testlayer.arc_container(); } - - CGAL::Qt_widget *widget; - CGAL::Qt_widget_standard_toolbar *stoolbar; - bool something_changed; - Qt_layer_show_ch testlayer; - Qt_layer_do_sweep do_sweep_layer; - CGAL::Qt_widget_get_segment *get_segment_layer; - CGAL::Qt_widget_get_arc *get_arc_layer; -}; - -#include "demo_Lazy_line_circle.moc" - -int -main(int argc, char **argv) -{ - QApplication app(argc, argv); - MyWindow widget(800, 700); // physical window size - app.setMainWidget(&widget); - widget.setCaption(my_title_string); - widget.setMouseTracking(TRUE); - widget.show(); - return app.exec(); -} - -#endif // CGAL_USE_QT diff --git a/Circular_kernel_2/demo/Circular_kernel_2/demo_circle.cpp b/Circular_kernel_2/demo/Circular_kernel_2/demo_circle.cpp deleted file mode 100644 index d0a23fc7c22..00000000000 --- a/Circular_kernel_2/demo/Circular_kernel_2/demo_circle.cpp +++ /dev/null @@ -1,479 +0,0 @@ -// Copyright (c) 2003-2008 INRIA Sophia-Antipolis (France) and -// Max-Planck-Institute Saarbruecken (Germany). -// All rights reserved. -// -// $URL$ -// $Id$ -// -// Authors : Monique Teillaud, Sylvain Pion, Radu Ursu -// -// Partially supported by the IST Programme of the EU as a Shared-cost -// RTD (FET Open) Project under Contract No IST-2000-26473 -// (CGAL - Effective Computational Geometry for Curves and Surfaces) - -// TODO : -// - Add the possibility to input full circles. -// - locate the cell containing a point. -// - Move more basic IO routines in include/CGAL/IO/ -// - File menu - -#include - -// if QT is not installed, a message will be issued at runtime. -#ifndef CGAL_USE_QT -#include -int main() { - std::cout << "Sorry, this demo needs QT..." << std::endl; - return 0; -} -#else - -#include - -#include -#include - -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "Qt_widget_get_arc.h" -#include "sweeper.xpm" -#include "trash.xpm" -#include "get_arc.xpm" -#include "planar_map_icon.xpm" - -#include - -#include -#include -#include - -#include -#include - -typedef CGAL::Quotient NT; - -typedef CGAL::Cartesian Linear_k; - -typedef CGAL::Algebraic_kernel_for_circles_2_2 Algebraic_k; -typedef CGAL::Circular_kernel_2 Circular_k; - -typedef Circular_k::Circular_arc_2 Arc_2; -typedef std::vector ArcContainer; - -#ifndef CGAL_CURVED_KERNEL_DEBUG -typedef CGAL::Arr_circular_arc_traits Traits; -#else -typedef CGAL::Arr_circular_arc_traits Traits0; -typedef CGAL::Circular_arc_traits_tracer Traits; -#endif - -typedef Traits::Point_2 Point_2; -typedef Traits::Curve_2 Conic_arc_2; -typedef CGAL::Arrangement_2 Pmwx; -typedef CGAL::Arr_naive_point_location Point_location; - -typedef Traits::X_monotone_curve_2 X_monotone_curve_2; - -const QString my_title_string("CGAL :: " - "Planar Map of Intersecting Circular Arcs"); - -// This layer controls the drawing of the Planar Map. -class Qt_layer_do_sweep - : public CGAL::Qt_widget_layer -{ - Pmwx _pm; - Point_location _pl; - bool show_pmwx; - -public: - - Qt_layer_do_sweep() - : _pm(), _pl(_pm), show_pmwx(true) {} - - void swap_show() { show_pmwx = ! show_pmwx; } - - const Pmwx & pm() const { return _pm; } - Pmwx & pm() { return _pm; } - - const Point_location & pl() const { return _pl; } - Point_location & pl() { return _pl; } - - void draw() - { - if (! show_pmwx) - return; - - *widget << CGAL::GREEN; - for (Pmwx::Halfedge_const_iterator ei = pm().halfedges_begin(); - ei != pm().halfedges_end (); ++ei) - *widget << ei->curve(); - - *widget << CGAL::RED; - for (Pmwx::Vertex_const_iterator vi = pm().vertices_begin(); - vi != pm().vertices_end(); ++vi) - *widget << vi->point(); - } -}; - - -// This layer controls the drawing of the arc_container. -struct Qt_layer_show_ch - : public CGAL::Qt_widget_layer -{ - ArcContainer _arc_container; - bool show_arcs; - -public: - - Qt_layer_show_ch() - : show_arcs(true) {} - - const ArcContainer & - arc_container() const { return _arc_container; } - ArcContainer & - arc_container() { return _arc_container; } - - void swap_show() { show_arcs = ! show_arcs; } - - void draw() - { - if (!show_arcs) - return; - - *widget << CGAL::BLUE; - for (ArcContainer::const_iterator cit = arc_container().begin(); - cit != arc_container().end(); ++cit) - *widget << *cit; - } -}; - - -class MyWindow - : public QMainWindow -{ - Q_OBJECT - -public: - - MyWindow(int w, int h) - : something_changed(true) - { - widget = new CGAL::Qt_widget(this); - setCentralWidget(widget); - - // create a timer for checking if something changed - QTimer *timer = new QTimer( this ); - connect( timer, SIGNAL(timeout()), this, SLOT(timer_done()) ); - timer->start( 200, FALSE ); - - // file menu - QPopupMenu * file = new QPopupMenu( this ); - menuBar()->insertItem( "&File", file ); - file->insertItem("&New", this, SLOT(new_instance()), CTRL+Key_N); - file->insertItem("New &Window", this, SLOT(new_window()), CTRL+Key_W); - file->insertSeparator(); - file->insertItem("&Load Arcs", this, SLOT(load_arcs()), CTRL+Key_L); - file->insertItem("&Save Arcs", this, SLOT(save_arcs()), CTRL+Key_S); - file->insertSeparator(); - file->insertItem("Print", widget, SLOT(print_to_ps()), CTRL+Key_P); - file->insertSeparator(); - file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_X ); - file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q ); - - - // help menu - QPopupMenu * help = new QPopupMenu( this ); - menuBar()->insertItem( "&Help", help ); - help->insertItem("How To", this, SLOT(howto()), Key_F1); - help->insertSeparator(); - help->insertItem("&About", this, SLOT(about()), CTRL+Key_A ); - help->insertItem("About &Qt", this, SLOT(aboutQt()) ); - - // the standard toolbar - stoolbar = new CGAL::Qt_widget_standard_toolbar (widget, this, "ST"); - - // my tool bar - QToolBar * layers_toolbar = new QToolBar("Tools", this, - QMainWindow::Top, TRUE, "Tools"); - - // the sweep button - QToolButton * sweep_button = - new QToolButton(QPixmap((const char**)::sweeper_xpm ), - "Let's do the Sweep", - 0, - this, - SLOT(update_pmwx()), - layers_toolbar, - "Let's do the Sweep"); - - widget->attach(&do_sweep_layer); - connect(sweep_button, SIGNAL(stateChanged(int)), - &do_sweep_layer, SLOT(stateChanged(int))); - - // the button controlling if we show the input arcs - QToolButton * show_container_button = - new QToolButton(QPixmap((const char**)::get_arc), - "Show Original arcs", - 0, - this, - SLOT(show_original_arcs()), - layers_toolbar, - "Show Original arcs"); - show_container_button->setToggleButton(true); - - show_container_button->toggle(); - connect(show_container_button, SIGNAL(stateChanged(int)), - &testlayer, SLOT(stateChanged(int))); - - // the button controlling if we show the planar map - QToolButton * show_pmwx_button = - new QToolButton(QPixmap((const char**)::planar_map_icon), - "Show Computed Planar Map", - 0, - this, - SLOT(show_pmwx_arcs()), - layers_toolbar, - "Show Computed Planar Map"); - show_pmwx_button->setToggleButton(true); - - show_pmwx_button->toggle(); - connect(show_pmwx_button, SIGNAL(stateChanged(int)), - &testlayer, SLOT(stateChanged(int))); - - // this button clears the content of the arc container and the PMWX. - QToolButton * clear_button = - new QToolButton(QPixmap((const char**)trash), - "Clear", - 0, - this, - SLOT(clear_container()), - layers_toolbar, - "Clear"); - - connect(clear_button, SIGNAL(stateChanged(int)), - &testlayer, SLOT(stateChanged(int))); - - - *widget << CGAL::LineWidth(2) << CGAL::BackgroundColor(CGAL::WHITE); - - resize(w,h); - widget->set_window(-1, 1, -1, 1); - widget->setMouseTracking(TRUE); - - // layers - widget->attach(&testlayer); - get_arc_layer = new CGAL::Qt_widget_get_arc; - widget->attach(get_arc_layer); - connect(get_arc_layer, SIGNAL(new_object_time()), this, SLOT(get_arc())); - } - -public slots: - - void new_instance() - { - widget->lock(); - widget->clear_history(); - widget->set_window(-1.1, 1.1, -1.1, 1.1); - // set the Visible Area to the Interval - widget->unlock(); - something_changed = true; - } - - void get_arc() - { - arc_container().push_back(get_arc_layer->get_circular_arc()); - //insert(pm(),pl(),arc_container().back()); - insert_curve(pm(),arc_container().back(),pl()); - something_changed = true; - widget->redraw(); - } - - void update_pmwx() - { - std::cout << " Recomputing the Planar Map using a sweep." << std::endl; - if (arc_container().size() != 0) { // because currently it crashes... - pm().clear(); - for (ArcContainer::const_iterator it=arc_container().begin(); - it != arc_container().end(); ++it) { - //insert(pm(),pl(),*it); - insert_curve(pm(),*it,pl()); - }; - // pm().arr_insert(arc_container().begin(), arc_container().end()); - } - something_changed = true; - widget->redraw(); - } - - void show_original_arcs() - { - testlayer.swap_show(); - something_changed = true; - widget->redraw(); - } - - void show_pmwx_arcs() - { - do_sweep_layer.swap_show(); - something_changed = true; - widget->redraw(); - } - - void clear_container() - { - arc_container().clear(); - pm().clear(); - something_changed = true; - widget->redraw(); - } - -private slots: - - void about() - { - QMessageBox::about(this, my_title_string, - "This is a demo of CGAL's Planar Map of intersecting Circle Arcs\n" - "Using the Circular_kernel by Sylvain Pion and Monique Teillaud"); - } - - void aboutQt() - { - QMessageBox::aboutQt(this, my_title_string); - } - - void howto() - { - CGAL::Qt_help_window *help = - new CGAL::Qt_help_window("help/index.html", ".", 0, "help viewer"); - help->resize(400, 400); - help->setCaption("Demo HowTo"); - help->show(); - } - - void new_window() - { - MyWindow *ed = new MyWindow(500, 500); - ed->setCaption("Layer"); - ed->widget->clear_history(); - ed->widget->set_window(-1.1, 1.1, -1.1, 1.1); - ed->show(); - something_changed = true; - } - - void timer_done() - { - if (something_changed) - widget->redraw(); - something_changed = false; - } - - void load_arcs() - { - QString s( QFileDialog::getOpenFileName( QString::null, - "CGAL files (*.cgal)", this ) ); - if ( s.isEmpty() ) - return; - - std::ifstream in(s); - CGAL::set_ascii_mode(in); - std::istream_iterator begin(in), end; - ArcContainer arcs(begin, end); - arc_container().swap(arcs); - - update_pmwx(); - - /* Compute a bounding box... - Add a generic bounding_box(iterator...) ? - Vertex_iterator it = tr1.vertices_begin(); - xmin = xmax = (*it).point().x(); - ymin = ymax = (*it).point().y(); - while(it != tr1.vertices_end()) { - if(xmin > (*it).point().x()) - xmin = (*it).point().x(); - if(xmax < (*it).point().x()) - xmax = (*it).point().x(); - if(ymin > (*it).point().y()) - ymin = (*it).point().y(); - if(ymax < (*it).point().y()) - ymax = (*it).point().y(); - it++; - } - */ - stoolbar->clear_history(); - //widget->set_window(xmin, xmax, ymin, ymax); - something_changed = true; - } - - void save_arcs() - { - QString fileName = - QFileDialog::getSaveFileName( "arcs.cgal", - "CGAL files (*.cgal)", this ); - if ( !fileName.isNull() ) { - // got a file name - std::ofstream out(fileName); - CGAL::set_ascii_mode(out); - std::copy(arc_container().begin(), arc_container().end(), - std::ostream_iterator(out, "\n")); - } - } - -private: - - Pmwx const & pm() const { return do_sweep_layer.pm(); } - Pmwx & pm() { return do_sweep_layer.pm(); } - - Point_location const & pl() const { return do_sweep_layer.pl(); } - Point_location & pl() { return do_sweep_layer.pl(); } - - - const ArcContainer & arc_container() const - { return testlayer.arc_container(); } - ArcContainer & arc_container() - { return testlayer.arc_container(); } - - CGAL::Qt_widget *widget; - CGAL::Qt_widget_standard_toolbar *stoolbar; - bool something_changed; - Qt_layer_show_ch testlayer; - Qt_layer_do_sweep do_sweep_layer; - CGAL::Qt_widget_get_arc *get_arc_layer; -}; - -#include "demo.circle.moc" - -int -main(int argc, char **argv) -{ - QApplication app(argc, argv); - MyWindow widget(800, 700); // physical window size - app.setMainWidget(&widget); - widget.setCaption(my_title_string); - widget.setMouseTracking(TRUE); - widget.show(); - return app.exec(); -} - -#endif // CGAL_USE_QT diff --git a/Circular_kernel_2/demo/Circular_kernel_2/demo_elias.cpp b/Circular_kernel_2/demo/Circular_kernel_2/demo_elias.cpp deleted file mode 100644 index 1f68a55334f..00000000000 --- a/Circular_kernel_2/demo/Circular_kernel_2/demo_elias.cpp +++ /dev/null @@ -1,486 +0,0 @@ -// Copyright (c) 2003-2008 INRIA Sophia-Antipolis (France) and -// Max-Planck-Institute Saarbruecken (Germany). -// All rights reserved. -// -// $URL$ -// $Id$ -// -// Authors : Monique Teillaud, Sylvain Pion, Radu Ursu -// -// Partially supported by the IST Programme of the EU as a Shared-cost -// RTD (FET Open) Project under Contract No IST-2000-26473 -// (CGAL - Effective Computational Geometry for Curves and Surfaces) - -// TODO : -// - Add the possibility to input full circles. -// - locate the cell containing a point. -// - Move more basic IO routines in include/CGAL/IO/ -// - File menu - -#include - -// if QT is not installed, a message will be issued at runtime. -#ifndef CGAL_USE_QT -#include -int main() { - std::cout << "Sorry, this demo needs QT..." << std::endl; - return 0; -} -#else - -#include - -#include -#include - -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "Qt_widget_get_arc.h" -#include "sweeper.xpm" -#include "trash.xpm" -#include "get_arc.xpm" -#include "planar_map_icon.xpm" - -#include - -#include -#include -#include - -#include -#include - -typedef SYNAPS::QQ NT; -typedef SYNAPS::ZZ RT; - -typedef CGAL::Cartesian Linear_k; - -typedef SYNAPS::Algebraic_kernel_2 Algebraic_k; -typedef CGAL::Circular_kernel_2 Curved_k; - - -typedef Curved_k::Circular_arc_2 Arc_2; -typedef std::vector ArcContainer; - -#ifndef CGAL_CURVED_KERNEL_DEBUG -typedef CGAL::Circular_arc_traits Traits; -#else -typedef CGAL::Circular_arc_traits Traits0; -typedef CGAL::Circular_arc_traits_tracer Traits; -#endif - -typedef Traits::Point_2 Point_2; -typedef Traits::Curve_2 Conic_arc_2; -typedef CGAL::Arrangement_2 Pmwx; -typedef CGAL::Arr_naive_point_location Point_location; - -typedef Traits::X_monotone_curve_2 X_monotone_curve_2; - -// typedef CGAL::Pm_default_dcel Dcel; -// typedef CGAL::Planar_map_2 Planar_map_2; -// typedef CGAL::Planar_map_with_intersections_2 Pmwx; - - -const QString my_title_string("CGAL :: " - "Planar Map of Intersecting Circular Arcs"); - -// This layer controls the drawing of the Planar Map. -class Qt_layer_do_sweep - : public CGAL::Qt_widget_layer -{ - Pmwx _pm; - Point_location _pl; - bool show_pmwx; - -public: - - Qt_layer_do_sweep() - : _pm(), _pl(_pm), show_pmwx(true) {} - - void swap_show() { show_pmwx = ! show_pmwx; } - - const Pmwx & pm() const { return _pm; } - Pmwx & pm() { return _pm; } - - const Point_location & pl() const { return _pl; } - Point_location & pl() { return _pl; } - - void draw() - { - if (! show_pmwx) - return; - - *widget << CGAL::GREEN; - for (Pmwx::Halfedge_const_iterator ei = pm().halfedges_begin(); - ei != pm().halfedges_end (); ++ei) - *widget << ei->curve(); - - *widget << CGAL::RED; - for (Pmwx::Vertex_const_iterator vi = pm().vertices_begin(); - vi != pm().vertices_end(); ++vi) - *widget << vi->point(); - } -}; - - -// This layer controls the drawing of the arc_container. -struct Qt_layer_show_ch - : public CGAL::Qt_widget_layer -{ - ArcContainer _arc_container; - bool show_arcs; - -public: - - Qt_layer_show_ch() - : show_arcs(true) {} - - const ArcContainer & - arc_container() const { return _arc_container; } - ArcContainer & - arc_container() { return _arc_container; } - - void swap_show() { show_arcs = ! show_arcs; } - - void draw() - { - if (!show_arcs) - return; - - *widget << CGAL::BLUE; - for (ArcContainer::const_iterator cit = arc_container().begin(); - cit != arc_container().end(); ++cit) - *widget << *cit; - } -}; - - -class MyWindow - : public QMainWindow -{ - Q_OBJECT - -public: - - MyWindow(int w, int h) - : something_changed(true) - { - widget = new CGAL::Qt_widget(this); - setCentralWidget(widget); - - // create a timer for checking if something changed - QTimer *timer = new QTimer( this ); - connect( timer, SIGNAL(timeout()), this, SLOT(timer_done()) ); - timer->start( 200, FALSE ); - - // file menu - QPopupMenu * file = new QPopupMenu( this ); - menuBar()->insertItem( "&File", file ); - file->insertItem("&New", this, SLOT(new_instance()), CTRL+Key_N); - file->insertItem("New &Window", this, SLOT(new_window()), CTRL+Key_W); - file->insertSeparator(); - file->insertItem("&Load Arcs", this, SLOT(load_arcs()), CTRL+Key_L); - file->insertItem("&Save Arcs", this, SLOT(save_arcs()), CTRL+Key_S); - file->insertSeparator(); - file->insertItem("Print", widget, SLOT(print_to_ps()), CTRL+Key_P); - file->insertSeparator(); - file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_X ); - file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q ); - - - // help menu - QPopupMenu * help = new QPopupMenu( this ); - menuBar()->insertItem( "&Help", help ); - help->insertItem("How To", this, SLOT(howto()), Key_F1); - help->insertSeparator(); - help->insertItem("&About", this, SLOT(about()), CTRL+Key_A ); - help->insertItem("About &Qt", this, SLOT(aboutQt()) ); - - // the standard toolbar - stoolbar = new CGAL::Qt_widget_standard_toolbar (widget, this, "ST"); - - // my tool bar - QToolBar * layers_toolbar = new QToolBar("Tools", this, - QMainWindow::Top, TRUE, "Tools"); - - // the sweep button - QToolButton * sweep_button = - new QToolButton(QPixmap((const char**)::sweeper_xpm ), - "Let's do the Sweep", - 0, - this, - SLOT(update_pmwx()), - layers_toolbar, - "Let's do the Sweep"); - - widget->attach(&do_sweep_layer); - connect(sweep_button, SIGNAL(stateChanged(int)), - &do_sweep_layer, SLOT(stateChanged(int))); - - // the button controlling if we show the input arcs - QToolButton * show_container_button = - new QToolButton(QPixmap((const char**)::get_arc), - "Show Original arcs", - 0, - this, - SLOT(show_original_arcs()), - layers_toolbar, - "Show Original arcs"); - show_container_button->setToggleButton(true); - - show_container_button->toggle(); - connect(show_container_button, SIGNAL(stateChanged(int)), - &testlayer, SLOT(stateChanged(int))); - - // the button controlling if we show the planar map - QToolButton * show_pmwx_button = - new QToolButton(QPixmap((const char**)::planar_map_icon), - "Show Computed Planar Map", - 0, - this, - SLOT(show_pmwx_arcs()), - layers_toolbar, - "Show Computed Planar Map"); - show_pmwx_button->setToggleButton(true); - - show_pmwx_button->toggle(); - connect(show_pmwx_button, SIGNAL(stateChanged(int)), - &testlayer, SLOT(stateChanged(int))); - - // this button clears the content of the arc container and the PMWX. - QToolButton * clear_button = - new QToolButton(QPixmap((const char**)trash), - "Clear", - 0, - this, - SLOT(clear_container()), - layers_toolbar, - "Clear"); - - connect(clear_button, SIGNAL(stateChanged(int)), - &testlayer, SLOT(stateChanged(int))); - - - *widget << CGAL::LineWidth(2) << CGAL::BackgroundColor(CGAL::WHITE); - - resize(w,h); - widget->set_window(-1, 1, -1, 1); - widget->setMouseTracking(TRUE); - - // layers - widget->attach(&testlayer); - get_arc_layer = new CGAL::Qt_widget_get_arc; - widget->attach(get_arc_layer); - connect(get_arc_layer, SIGNAL(new_object_time()), this, SLOT(get_arc())); - } - -public slots: - - void new_instance() - { - widget->lock(); - widget->clear_history(); - widget->set_window(-1.1, 1.1, -1.1, 1.1); - // set the Visible Area to the Interval - widget->unlock(); - something_changed = true; - } - - void get_arc() - { - arc_container().push_back(get_arc_layer->get_circular_arc()); - arr_insert(pm(),pl(),arc_container().back()); - // pm().insert(arc_container().back()); - - something_changed = true; - widget->redraw(); - } - - void update_pmwx() - { - std::cout << " Recomputing the Planar Map using a sweep." << std::endl; - if (arc_container().size() != 0) { // because currently it crashes... - pm().clear(); - for (ArcContainer::const_iterator it=arc_container().begin(); - it != arc_container().end(); ++it) { - arr_insert(pm(),pl(),*it); - }; - // pm().insert(arc_container().begin(), arc_container().end()); - } - something_changed = true; - widget->redraw(); - } - - void show_original_arcs() - { - testlayer.swap_show(); - something_changed = true; - widget->redraw(); - } - - void show_pmwx_arcs() - { - do_sweep_layer.swap_show(); - something_changed = true; - widget->redraw(); - } - - void clear_container() - { - arc_container().clear(); - pm().clear(); - something_changed = true; - widget->redraw(); - } - -private slots: - - void about() - { - QMessageBox::about(this, my_title_string, - "This is a demo of CGAL's Planar Map of intersecting Circle Arcs\n" - "Using the Curved_kernel by Sylvain Pion and Monique Teillaud"); - } - - void aboutQt() - { - QMessageBox::aboutQt(this, my_title_string); - } - - void howto() - { - CGAL::Qt_help_window *help = - new CGAL::Qt_help_window("help/index.html", ".", 0, "help viewer"); - help->resize(400, 400); - help->setCaption("Demo HowTo"); - help->show(); - } - - void new_window() - { - MyWindow *ed = new MyWindow(500, 500); - ed->setCaption("Layer"); - ed->widget->clear_history(); - ed->widget->set_window(-1.1, 1.1, -1.1, 1.1); - ed->show(); - something_changed = true; - } - - void timer_done() - { - if (something_changed) - widget->redraw(); - something_changed = false; - } - - void load_arcs() - { - QString s( QFileDialog::getOpenFileName( QString::null, - "CGAL files (*.cgal)", this ) ); - if ( s.isEmpty() ) - return; - - std::ifstream in(s); - CGAL::set_ascii_mode(in); - std::istream_iterator begin(in), end; - ArcContainer arcs(begin, end); - arc_container().swap(arcs); - - update_pmwx(); - - /* Compute a bounding box... - Add a generic bounding_box(iterator...) ? - Vertex_iterator it = tr1.vertices_begin(); - xmin = xmax = (*it).point().x(); - ymin = ymax = (*it).point().y(); - while(it != tr1.vertices_end()) { - if(xmin > (*it).point().x()) - xmin = (*it).point().x(); - if(xmax < (*it).point().x()) - xmax = (*it).point().x(); - if(ymin > (*it).point().y()) - ymin = (*it).point().y(); - if(ymax < (*it).point().y()) - ymax = (*it).point().y(); - it++; - } - */ - stoolbar->clear_history(); - //widget->set_window(xmin, xmax, ymin, ymax); - something_changed = true; - } - - void save_arcs() - { - QString fileName = - QFileDialog::getSaveFileName( "arcs.cgal", - "CGAL files (*.cgal)", this ); - if ( !fileName.isNull() ) { - // got a file name - std::ofstream out(fileName); - CGAL::set_ascii_mode(out); - std::copy(arc_container().begin(), arc_container().end(), - std::ostream_iterator(out, "\n")); - } - } - -private: - - Pmwx const & pm() const { return do_sweep_layer.pm(); } - Pmwx & pm() { return do_sweep_layer.pm(); } - - Point_location const & pl() const { return do_sweep_layer.pl(); } - Point_location & pl() { return do_sweep_layer.pl(); } - - - const ArcContainer & arc_container() const - { return testlayer.arc_container(); } - ArcContainer & arc_container() - { return testlayer.arc_container(); } - - CGAL::Qt_widget *widget; - CGAL::Qt_widget_standard_toolbar *stoolbar; - bool something_changed; - Qt_layer_show_ch testlayer; - Qt_layer_do_sweep do_sweep_layer; - CGAL::Qt_widget_get_arc *get_arc_layer; -}; - -#include "demo.moc" - -int -main(int argc, char **argv) -{ - QApplication app(argc, argv); - MyWindow widget(800, 700); // physical window size - app.setMainWidget(&widget); - widget.setCaption(my_title_string); - widget.setMouseTracking(TRUE); - widget.show(); - return app.exec(); -} - -#endif // CGAL_USE_QT diff --git a/Circular_kernel_2/demo/Circular_kernel_2/demo_line.cpp b/Circular_kernel_2/demo/Circular_kernel_2/demo_line.cpp deleted file mode 100644 index 2c0de74c506..00000000000 --- a/Circular_kernel_2/demo/Circular_kernel_2/demo_line.cpp +++ /dev/null @@ -1,486 +0,0 @@ -// Copyright (c) 2003-2008 INRIA Sophia-Antipolis (France) and -// Max-Planck-Institute Saarbruecken (Germany). -// All rights reserved. -// -// $URL$ -// $Id$ -// -// Authors : Monique Teillaud, Sylvain Pion, Radu Ursu -// -// Partially supported by the IST Programme of the EU as a Shared-cost -// RTD (FET Open) Project under Contract No IST-2000-26473 -// (CGAL - Effective Computational Geometry for Curves and Surfaces) - -// TODO : -// - Add the possibility to input full circles. -// - locate the cell containing a point. -// - Move more basic IO routines in include/CGAL/IO/ -// - File menu - -#include - -// if QT is not installed, a message will be issued at runtime. -#ifndef CGAL_USE_QT -#include -int main() { - std::cout << "Sorry, this demo needs QT..." << std::endl; - return 0; -} -#else - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "Qt_widget_get_segment.h" -#include "sweeper.xpm" -#include "trash.xpm" -#include "get_arc.xpm" -#include "planar_map_icon.xpm" - -#include -#include -#include -#include - - -#include -#include - - -typedef CGAL::Quotient NT; - -typedef CGAL::Cartesian Linear_k; - -typedef CGAL::Algebraic_kernel_for_circles_2_2 Algebraic_k; -typedef CGAL::Circular_kernel_2 Circular_k; - -typedef Circular_k::Line_arc_2 Arc_2; -typedef Circular_k::Segment_2 Segment; -typedef std::vector ArcContainer; - -#ifndef CGAL_CURVED_KERNEL_DEBUG -typedef CGAL::Arr_line_arc_traits Traits; -#else -typedef CGAL::Arr_line_arc_traits Traits0; -typedef CGAL::Circular_arc_traits_tracer Traits; -#endif - -typedef Traits::Point_2 Point_2; -typedef Traits::Curve_2 Conic_arc_2; -typedef CGAL::Arrangement_2 Pmwx; -typedef CGAL::Arr_naive_point_location Point_location; - -typedef Traits::X_monotone_curve_2 X_monotone_curve_2; - - - -const QString my_title_string("CGAL :: " - "Planar Map of Intersecting Circular Arcs"); - -// This layer controls the drawing of the Planar Map. -class Qt_layer_do_sweep - : public CGAL::Qt_widget_layer -{ - Pmwx _pm; - Point_location _pl; - bool show_pmwx; - -public: - - Qt_layer_do_sweep() - : _pm(), _pl(_pm), show_pmwx(true) {} - - void swap_show() { show_pmwx = ! show_pmwx; } - - const Pmwx & pm() const { return _pm; } - Pmwx & pm() { return _pm; } - - const Point_location & pl() const { return _pl; } - Point_location & pl() { return _pl; } - - void draw() - { - if (! show_pmwx) - return; - - *widget << CGAL::GREEN; - for (Pmwx::Halfedge_const_iterator ei = pm().halfedges_begin(); - ei != pm().halfedges_end (); ++ei) - *widget << Segment(Circular_k::Point_2(to_double(ei->curve().source().x()), - to_double(ei->curve().source().y())), - Circular_k::Point_2(to_double(ei->curve().target().x()), - to_double(ei->curve().target().y()))) - ; - - *widget << CGAL::RED; - for (Pmwx::Vertex_const_iterator vi = pm().vertices_begin(); - vi != pm().vertices_end(); ++vi) - *widget << vi->point(); - } -}; - - -// This layer controls the drawing of the arc_container. -struct Qt_layer_show_ch - : public CGAL::Qt_widget_layer -{ - ArcContainer _arc_container; - bool show_arcs; - -public: - - Qt_layer_show_ch() - : show_arcs(true) {} - - const ArcContainer & - arc_container() const { return _arc_container; } - ArcContainer & - arc_container() { return _arc_container; } - - void swap_show() { show_arcs = ! show_arcs; } - - void draw() - { - if (!show_arcs) - return; - - *widget << CGAL::BLUE; - for (ArcContainer::const_iterator cit = arc_container().begin(); - cit != arc_container().end(); ++cit) - *widget << Segment(Circular_k::Point_2(to_double(cit->source().x()), - to_double(cit->source().y())), - Circular_k::Point_2(to_double(cit->target().x()), - to_double(cit->target().y()))); - } -}; - - -class MyWindow - : public QMainWindow -{ - Q_OBJECT - -public: - - MyWindow(int w, int h) - : something_changed(true) - { - widget = new CGAL::Qt_widget(this); - setCentralWidget(widget); - - // create a timer for checking if something changed - QTimer *timer = new QTimer( this ); - connect( timer, SIGNAL(timeout()), this, SLOT(timer_done()) ); - timer->start( 200, FALSE ); - - // file menu - QPopupMenu * file = new QPopupMenu( this ); - menuBar()->insertItem( "&File", file ); - file->insertItem("&New", this, SLOT(new_instance()), CTRL+Key_N); - file->insertItem("New &Window", this, SLOT(new_window()), CTRL+Key_W); - file->insertSeparator(); - file->insertItem("&Load Arcs", this, SLOT(load_arcs()), CTRL+Key_L); - file->insertItem("&Save Arcs", this, SLOT(save_arcs()), CTRL+Key_S); - file->insertSeparator(); - file->insertItem("Print", widget, SLOT(print_to_ps()), CTRL+Key_P); - file->insertSeparator(); - file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_X ); - file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q ); - - - // help menu - QPopupMenu * help = new QPopupMenu( this ); - menuBar()->insertItem( "&Help", help ); - help->insertItem("How To", this, SLOT(howto()), Key_F1); - help->insertSeparator(); - help->insertItem("&About", this, SLOT(about()), CTRL+Key_A ); - help->insertItem("About &Qt", this, SLOT(aboutQt()) ); - - // the standard toolbar - stoolbar = new CGAL::Qt_widget_standard_toolbar (widget, this, "ST"); - - // my tool bar - QToolBar * layers_toolbar = new QToolBar("Tools", this, - QMainWindow::Top, TRUE, "Tools"); - - // the sweep button - QToolButton * sweep_button = - new QToolButton(QPixmap((const char**)::sweeper_xpm ), - "Let's do the Sweep", - 0, - this, - SLOT(update_pmwx()), - layers_toolbar, - "Let's do the Sweep"); - - widget->attach(&do_sweep_layer); - connect(sweep_button, SIGNAL(stateChanged(int)), - &do_sweep_layer, SLOT(stateChanged(int))); - - // the button controlling if we show the input arcs - QToolButton * show_container_button = - new QToolButton(QPixmap((const char**)::get_arc), - "Show Original arcs", - 0, - this, - SLOT(show_original_arcs()), - layers_toolbar, - "Show Original arcs"); - show_container_button->setToggleButton(true); - - show_container_button->toggle(); - connect(show_container_button, SIGNAL(stateChanged(int)), - &testlayer, SLOT(stateChanged(int))); - - // the button controlling if we show the planar map - QToolButton * show_pmwx_button = - new QToolButton(QPixmap((const char**)::planar_map_icon), - "Show Computed Planar Map", - 0, - this, - SLOT(show_pmwx_arcs()), - layers_toolbar, - "Show Computed Planar Map"); - show_pmwx_button->setToggleButton(true); - - show_pmwx_button->toggle(); - connect(show_pmwx_button, SIGNAL(stateChanged(int)), - &testlayer, SLOT(stateChanged(int))); - - // this button clears the content of the arc container and the PMWX. - QToolButton * clear_button = - new QToolButton(QPixmap((const char**)trash), - "Clear", - 0, - this, - SLOT(clear_container()), - layers_toolbar, - "Clear"); - - connect(clear_button, SIGNAL(stateChanged(int)), - &testlayer, SLOT(stateChanged(int))); - - - *widget << CGAL::LineWidth(2) << CGAL::BackgroundColor(CGAL::WHITE); - - resize(w,h); - widget->set_window(-1, 1, -1, 1); - widget->setMouseTracking(TRUE); - - // layers - widget->attach(&testlayer); - get_arc_layer = new CGAL::Qt_widget_get_segment; - widget->attach(get_arc_layer); - connect(get_arc_layer, SIGNAL(new_object_time()), this, SLOT(get_arc())); - } - -public slots: - - void new_instance() - { - widget->lock(); - widget->clear_history(); - widget->set_window(-1.1, 1.1, -1.1, 1.1); - // set the Visible Area to the Interval - widget->unlock(); - something_changed = true; - } - - void get_arc() - { - arc_container().push_back(get_arc_layer->get_line_arc()); - //insert(pm(),pl(),arc_container().back()); - insert_curve(pm(),arc_container().back(),pl()); - something_changed = true; - widget->redraw(); - } - - void update_pmwx() - { - std::cout << " Recomputing the Planar Map using a sweep." << std::endl; - if (arc_container().size() != 0) { // because currently it crashes... - pm().clear(); - for (ArcContainer::const_iterator it=arc_container().begin(); - it != arc_container().end(); ++it) { - //insert(pm(),pl(),*it); - insert_curve(pm(),*it,pl()); - }; - // pm().arr_insert(arc_container().begin(), arc_container().end()); - } - something_changed = true; - widget->redraw(); - } - - void show_original_arcs() - { - testlayer.swap_show(); - something_changed = true; - widget->redraw(); - } - - void show_pmwx_arcs() - { - do_sweep_layer.swap_show(); - something_changed = true; - widget->redraw(); - } - - void clear_container() - { - arc_container().clear(); - pm().clear(); - something_changed = true; - widget->redraw(); - } - -private slots: - - void about() - { - QMessageBox::about(this, my_title_string, - "This is a demo of CGAL's Planar Map of intersecting Circle Arcs\n" - "Using the Circular_kernel by Sylvain Pion and Monique Teillaud"); - } - - void aboutQt() - { - QMessageBox::aboutQt(this, my_title_string); - } - - void howto() - { - CGAL::Qt_help_window *help = - new CGAL::Qt_help_window("help/index.html", ".", 0, "help viewer"); - help->resize(400, 400); - help->setCaption("Demo HowTo"); - help->show(); - } - - void new_window() - { - MyWindow *ed = new MyWindow(500, 500); - ed->setCaption("Layer"); - ed->widget->clear_history(); - ed->widget->set_window(-1.1, 1.1, -1.1, 1.1); - ed->show(); - something_changed = true; - } - - void timer_done() - { - if (something_changed) - widget->redraw(); - something_changed = false; - } - - void load_arcs() - { - QString s( QFileDialog::getOpenFileName( QString::null, - "CGAL files (*.cgal)", this ) ); - if ( s.isEmpty() ) - return; - - std::ifstream in(s); - CGAL::set_ascii_mode(in); - std::istream_iterator begin(in), end; - ArcContainer arcs(begin, end); - arc_container().swap(arcs); - - update_pmwx(); - - /* Compute a bounding box... - Add a generic bounding_box(iterator...) ? - Vertex_iterator it = tr1.vertices_begin(); - xmin = xmax = (*it).point().x(); - ymin = ymax = (*it).point().y(); - while(it != tr1.vertices_end()) { - if(xmin > (*it).point().x()) - xmin = (*it).point().x(); - if(xmax < (*it).point().x()) - xmax = (*it).point().x(); - if(ymin > (*it).point().y()) - ymin = (*it).point().y(); - if(ymax < (*it).point().y()) - ymax = (*it).point().y(); - it++; - } - */ - stoolbar->clear_history(); - //widget->set_window(xmin, xmax, ymin, ymax); - something_changed = true; - } - - void save_arcs() - { - QString fileName = - QFileDialog::getSaveFileName( "arcs.cgal", - "CGAL files (*.cgal)", this ); - if ( !fileName.isNull() ) { - // got a file name - std::ofstream out(fileName); - CGAL::set_ascii_mode(out); - std::copy(arc_container().begin(), arc_container().end(), - std::ostream_iterator(out, "\n")); - } - } - -private: - - Pmwx const & pm() const { return do_sweep_layer.pm(); } - Pmwx & pm() { return do_sweep_layer.pm(); } - - Point_location const & pl() const { return do_sweep_layer.pl(); } - Point_location & pl() { return do_sweep_layer.pl(); } - - - const ArcContainer & arc_container() const - { return testlayer.arc_container(); } - ArcContainer & arc_container() - { return testlayer.arc_container(); } - - CGAL::Qt_widget *widget; - CGAL::Qt_widget_standard_toolbar *stoolbar; - bool something_changed; - Qt_layer_show_ch testlayer; - Qt_layer_do_sweep do_sweep_layer; - CGAL::Qt_widget_get_segment *get_arc_layer; -}; - -#include "demo_line.moc" - -int -main(int argc, char **argv) -{ - QApplication app(argc, argv); - MyWindow widget(800, 700); // physical window size - app.setMainWidget(&widget); - widget.setCaption(my_title_string); - widget.setMouseTracking(TRUE); - widget.show(); - return app.exec(); -} - -#endif // CGAL_USE_QT diff --git a/Circular_kernel_2/demo/Circular_kernel_2/demo_viewer.cpp b/Circular_kernel_2/demo/Circular_kernel_2/demo_viewer.cpp deleted file mode 100644 index 832147ac08b..00000000000 --- a/Circular_kernel_2/demo/Circular_kernel_2/demo_viewer.cpp +++ /dev/null @@ -1,375 +0,0 @@ -// Copyright (c) 2003-2008 INRIA Sophia-Antipolis (France) and -// Max-Planck-Institute Saarbruecken (Germany). -// All rights reserved. -// -// $URL$ -// $Id$ -// -// Authors : Monique Teillaud, Sylvain Pion, Radu Ursu -// -// Partially supported by the IST Programme of the EU as a Shared-cost -// RTD (FET Open) Project under Contract No IST-2000-26473 -// (CGAL - Effective Computational Geometry for Curves and Surfaces) - - -// TODO : -// - Add the possibility to input full circles. -// - locate the cell containing a point. -// - Move more basic IO routines in include/CGAL/IO/ -// - File menu - -#include - -// if QT is not installed, a message will be issued at runtime. -#ifndef CGAL_USE_QT -#include -int main() { - std::cout << "Sorry, this demo needs QT..." << std::endl; - return 0; -} -#else - -#include - -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - - -#include "Qt_widget_get_segment.h" -#include "Qt_widget_get_arc.h" -#include "trash.xpm" -#include "get_arc.xpm" - -#include -#include -#include -#include - -typedef CGAL::Quotient NT; -typedef CGAL::Cartesian Linear_k; -typedef CGAL::Algebraic_kernel_for_circles_2_2 Algebraic_k; -typedef CGAL::Circular_kernel_2 Circular_k; - -typedef Circular_k::Line_arc_2 Line_arc_2; -typedef Circular_k::Segment_2 Segment; -typedef Circular_k::Circular_arc_2 Circular_arc_2; -typedef boost::variant< Circular_arc_2, Line_arc_2 > Arc_2; -typedef std::vector ArcContainer; - -#ifndef CGAL_CURVED_KERNEL_DEBUG -typedef CGAL::Arr_circular_line_arc_traits - Traits; -#else -typedef CGAL::Arr_circular_line_arc_traits - Traits0; -typedef CGAL::Circular_arc_traits_tracer Traits; -#endif - -typedef Traits::Point_2 Point_2; -typedef Traits::Curve_2 Conic_arc_2; - -typedef Traits::X_monotone_curve_2 X_monotone_curve_2; - - - -const QString my_title_string("CGAL :: " - "Planar Map of Intersecting Circular Arcs"); - -// This layer controls the drawing of the arc_container. -struct Qt_layer_show_ch - : public CGAL::Qt_widget_layer -{ - ArcContainer _arc_container; - bool show_arcs; - -public: - - Qt_layer_show_ch() - : show_arcs(true) {} - - const ArcContainer & - arc_container() const { return _arc_container; } - ArcContainer & - arc_container() { return _arc_container; } - - void swap_show() { show_arcs = ! show_arcs; } - - void draw() - { - if (!show_arcs) - return; - - *widget << CGAL::BLUE; - for (ArcContainer::const_iterator cit = arc_container().begin(); - cit != arc_container().end(); ++cit){ - if(const Line_arc_2* line = boost::get( &(*cit))){ - *widget << Segment(Circular_k::Point_2(to_double(line->source().x()), - to_double(line->source().y())), - Circular_k::Point_2(to_double(line->target().x()), - to_double(line->target().y()))); - } - else if (const Circular_arc_2* arc = boost::get( &(*cit))){ - *widget << *arc; - } - } - } -}; - - -class MyWindow - : public QMainWindow -{ - Q_OBJECT - -public: - - MyWindow(int w, int h) - : something_changed(true) - { - widget = new CGAL::Qt_widget(this); - setCentralWidget(widget); - - // create a timer for checking if something changed - QTimer *timer = new QTimer( this ); - connect( timer, SIGNAL(timeout()), this, SLOT(timer_done()) ); - timer->start( 200, FALSE ); - - // file menu - QPopupMenu * file = new QPopupMenu( this ); - menuBar()->insertItem( "&File", file ); - file->insertItem("&New", this, SLOT(new_instance()), CTRL+Key_N); - file->insertItem("New &Window", this, SLOT(new_window()), CTRL+Key_W); - file->insertSeparator(); - file->insertItem("&Load Arcs", this, SLOT(load_arcs()), CTRL+Key_L); - file->insertItem("&Save Arcs", this, SLOT(save_arcs()), CTRL+Key_S); - file->insertSeparator(); - file->insertItem("Print", widget, SLOT(print_to_ps()), CTRL+Key_P); - file->insertSeparator(); - file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_X ); - file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q ); - - - // help menu - QPopupMenu * help = new QPopupMenu( this ); - menuBar()->insertItem( "&Help", help ); - help->insertItem("How To", this, SLOT(howto()), Key_F1); - help->insertSeparator(); - help->insertItem("&About", this, SLOT(about()), CTRL+Key_A ); - help->insertItem("About &Qt", this, SLOT(aboutQt()) ); - - // the standard toolbar - stoolbar = new CGAL::Qt_widget_standard_toolbar (widget, this, "ST"); - - // my tool bar - QToolBar * layers_toolbar = new QToolBar("Tools", this, - QMainWindow::Top, TRUE, "Tools"); - - - // the button controlling if we show the input arcs - QToolButton * show_container_button = - new QToolButton(QPixmap((const char**)::get_arc), - "Show Original arcs", - 0, - this, - SLOT(show_original_arcs()), - layers_toolbar, - "Show Original arcs"); - show_container_button->setToggleButton(true); - - show_container_button->toggle(); - connect(show_container_button, SIGNAL(stateChanged(int)), - &testlayer, SLOT(stateChanged(int))); - - // this button clears the content of the arc container and the PMWX. - QToolButton * clear_button = - new QToolButton(QPixmap((const char**)trash), - "Clear", - 0, - this, - SLOT(clear_container()), - layers_toolbar, - "Clear"); - - connect(clear_button, SIGNAL(stateChanged(int)), - &testlayer, SLOT(stateChanged(int))); - - - *widget << CGAL::LineWidth(2) << CGAL::BackgroundColor(CGAL::WHITE); - - resize(w,h); - widget->set_window(-1, 1, -1, 1); - widget->setMouseTracking(TRUE); - - // layers - widget->attach(&testlayer); - get_arc_layer = new CGAL::Qt_widget_get_arc; - get_segment_layer = new CGAL::Qt_widget_get_segment; - // connect(get_arc_layer, SIGNAL(new_object_time()), this, SLOT(get_arc())); - // connect(get_segment_layer, SIGNAL(new_object_time()), this, SLOT(get_arc())); - } - -public slots: - - void new_instance() - { - widget->lock(); - widget->clear_history(); - widget->set_window(-1.1, 1.1, -1.1, 1.1); - // set the Visible Area to the Interval - widget->unlock(); - something_changed = true; - } - - - void show_original_arcs() - { - testlayer.swap_show(); - something_changed = true; - widget->redraw(); - } - - void clear_container() - { - arc_container().clear(); - something_changed = true; - widget->redraw(); - } - -private slots: - - void about() - { - QMessageBox::about(this, my_title_string, - "This is a demo of CGAL's Planar Map of intersecting Circle Arcs\n" - "Using the Circular_kernel by Sylvain Pion and Monique Teillaud"); - } - - void aboutQt() - { - QMessageBox::aboutQt(this, my_title_string); - } - - void howto() - { - CGAL::Qt_help_window *help = - new CGAL::Qt_help_window("help/index.html", ".", 0, "help viewer"); - help->resize(400, 400); - help->setCaption("Demo HowTo"); - help->show(); - } - - void new_window() - { - MyWindow *ed = new MyWindow(500, 500); - ed->setCaption("Layer"); - ed->widget->clear_history(); - ed->widget->set_window(-1.1, 1.1, -1.1, 1.1); - ed->show(); - something_changed = true; - } - - void timer_done() - { - if (something_changed) - widget->redraw(); - something_changed = false; - } - - void load_arcs() - { - QString s( QFileDialog::getOpenFileName( QString::null, - "DXF files (*.dxf)", this ) ); - if ( s.isEmpty() ) - return; - - //std::ifstream in(s); - //CGAL::set_ascii_mode(in); - - //std::istream_iterator begin(in), end; - //ArcContainer arcs(begin, end); - //arc_container().swap(arcs); - - //to read dxf files - std::ifstream in(s); - CGAL::set_ascii_mode(in); - ArcContainer arcs; - CGAL::variant_load(in, std::back_inserter(arcs)); - arc_container().swap(arcs); - - - //update_pmwx(); - stoolbar->clear_history(); - something_changed = true; - } - - void save_arcs() - { - QString fileName = - QFileDialog::getSaveFileName( "arcs.cgal", - "CGAL files (*.cgal)", this ); - if ( !fileName.isNull() ) { - // got a file name - std::ofstream out(fileName); - CGAL::set_ascii_mode(out); - // std::copy(arc_container().begin(), arc_container().end(), - // std::ostream_iterator(out, "\n")); - } - } - -private: - - const ArcContainer & arc_container() const - { return testlayer.arc_container(); } - ArcContainer & arc_container() - { return testlayer.arc_container(); } - - CGAL::Qt_widget *widget; - CGAL::Qt_widget_standard_toolbar *stoolbar; - bool something_changed; - Qt_layer_show_ch testlayer; - - CGAL::Qt_widget_get_segment *get_segment_layer; - CGAL::Qt_widget_get_arc *get_arc_layer; -}; - -#include "demo_viewer.moc" - -int -main(int argc, char **argv) -{ - QApplication app(argc, argv); - MyWindow widget(800, 700); // physical window size - app.setMainWidget(&widget); - widget.setCaption(my_title_string); - widget.setMouseTracking(TRUE); - widget.show(); - return app.exec(); -} - -#endif // CGAL_USE_QT diff --git a/Circular_kernel_2/demo/Circular_kernel_2/help/index.html b/Circular_kernel_2/demo/Circular_kernel_2/help/index.html index f367ff478e0..330fc18c119 100644 --- a/Circular_kernel_2/demo/Circular_kernel_2/help/index.html +++ b/Circular_kernel_2/demo/Circular_kernel_2/help/index.html @@ -1,41 +1,27 @@ - Alpha_shapes_2 + Circular Kernel 2D -

How to use the

"CGAL::PMWX using -Curved_kernel"

Demo

+

How to use the

"Circular Kernel 2D"

Demo


-This demo illustrates the Planar Map With Intersection class of CGAL, -applied to the circular arcs provided by Curved_kernel. +This demo illustrates the intersection functionality provided by the CGAL's Circular_kernel_2.

-You can input circular arcs easily using the mouse, and they will be -immediately inserted into the current PMWX. The first click is the center +You can easily input circular arcs and segments using the mouse. The first click is the center of the supporting circle, the second will select the radius, then you have to enter two rays delimiting the arc. Pressing the 'c' key while entering the second ray will take the opposite arc (the yellow part).

-There are two large entities handled in this demo : the arcs container, which -stores the arcs you have entered, and the current PMWX, which is the Planar Map -With Intersections of the arcs stored in the arcs container. -

-It is possible to call the sweep algorithm (i.e. rebuild the current PMWX -using the so-called agreggate method) by clicking on the sweeper icon. Note -that you won't (shouldn't :) see any change on the screen. +Clicking in this icon will toggle the intersections visibility.

-To erase the current PMWX as well as the content of the arcs container, -just click on the trash. -

-By default, both the content of the arcs container (in blue) and the current -PMWX (in green and red) are displayed. +To erase the content of the arcs container, just click on the trash.

-This button toggles the display of the PMWX (it is still computed even when it -is now displayed). +Toggling this button will change the object you are inserting between circular arcs and segments.

This button toggles the display of the arcs container. @@ -50,18 +36,7 @@ This button toggles the display of the arcs container.

  • Close the current window
  • Quit the application

  • - +

     

     

     

    @@ -120,74 +95,6 @@ This button toggles the display of the arcs container. When you quit the application, all the windows you have created will be destroyed. - - -

    diff --git a/Circular_kernel_2/demo/Circular_kernel_2/makefile b/Circular_kernel_2/demo/Circular_kernel_2/makefile index bc43d431afd..b53fd7e75d8 100644 --- a/Circular_kernel_2/demo/Circular_kernel_2/makefile +++ b/Circular_kernel_2/demo/Circular_kernel_2/makefile @@ -17,7 +17,7 @@ CXXFLAGS = \ -I../../include \ -I../../../Algebraic_kernel_for_circles/include \ $(CGAL_CXXFLAGS) \ - $(LONG_NAME_PROBLEM_CXXFLAGS) + $(LONG_NAME_PROBLEM_CXXFLAGS) #---------------------------------------------------------------------# # linker flags