mirror of https://github.com/CGAL/cgal
The actual circular_kernel_2 demo
This commit is contained in:
parent
da4a9f4fd4
commit
25097caed9
|
|
@ -358,11 +358,8 @@ public:
|
||||||
Line l2 (second_point, center);
|
Line l2 (second_point, center);
|
||||||
|
|
||||||
return Circular_arc_2 (circ,
|
return Circular_arc_2 (circ,
|
||||||
// FIXME which one is newer?
|
l1, CGAL::compare_xy(first_point, center) == CGAL::SMALLER,
|
||||||
//l1, compare_lexicographically_xy(first_point, center) == CGAL::SMALLER,
|
l2, CGAL::compare_xy(second_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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,8 @@ int main() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include <CGAL/Cartesian.h>
|
|
||||||
#include <CGAL/point_generators_2.h>
|
|
||||||
#include <CGAL/MP_Float.h>
|
#include <CGAL/MP_Float.h>
|
||||||
|
#include <CGAL/Cartesian.h>
|
||||||
#include <CGAL/Algebraic_kernel_for_circles_2_2.h>
|
#include <CGAL/Algebraic_kernel_for_circles_2_2.h>
|
||||||
#include <CGAL/IO/Qt_widget.h>
|
#include <CGAL/IO/Qt_widget.h>
|
||||||
#include <CGAL/IO/Qt_widget_standard_toolbar.h>
|
#include <CGAL/IO/Qt_widget_standard_toolbar.h>
|
||||||
|
|
@ -55,109 +51,100 @@ int main() {
|
||||||
#include <CGAL/IO/Qt_widget_circular_arc_2.h>
|
#include <CGAL/IO/Qt_widget_circular_arc_2.h>
|
||||||
#include <CGAL/IO/Qt_widget_circular_arc_endpoint_2.h>
|
#include <CGAL/IO/Qt_widget_circular_arc_endpoint_2.h>
|
||||||
|
|
||||||
|
|
||||||
#include "Qt_widget_get_segment.h"
|
#include "Qt_widget_get_segment.h"
|
||||||
#include "Qt_widget_get_arc.h"
|
#include "Qt_widget_get_arc.h"
|
||||||
#include "sweeper.xpm"
|
#include "sweeper.xpm"
|
||||||
#include "trash.xpm"
|
#include "trash.xpm"
|
||||||
#include "get_arc.xpm"
|
#include "get_arc.xpm"
|
||||||
#include "planar_map_icon.xpm"
|
|
||||||
#include "lines_icon.xpm"
|
#include "lines_icon.xpm"
|
||||||
|
|
||||||
#include <CGAL/intersections.h>
|
#include <CGAL/intersections.h>
|
||||||
|
|
||||||
#include <CGAL/Circular_kernel_2.h>
|
#include <CGAL/Circular_kernel_2.h>
|
||||||
// #include <CGAL/Exact_circular_kernel_2.h>
|
#include <CGAL/Object.h>
|
||||||
#include <CGAL/Arr_circular_line_arc_traits.h>
|
|
||||||
|
|
||||||
#include <CGAL/Arrangement_2.h>
|
|
||||||
#include <CGAL/Arr_naive_point_location.h>
|
|
||||||
#include <CGAL/IO/Dxf_variant_reader.h>
|
|
||||||
|
|
||||||
typedef CGAL::Quotient<CGAL::MP_Float> NT;
|
typedef CGAL::Quotient<CGAL::MP_Float> NT;
|
||||||
//typedef CGAL::Quotient<CGAL::MP_Float> NT;
|
|
||||||
//typedef CGAL::Lazy_exact_nt<CGAL::Gmpq> NT;
|
|
||||||
//typedef boost::variant< Circular_arc_2, Line_arc_2 > Arc_2;
|
|
||||||
//typedef std::vector<Arc_2>
|
|
||||||
|
|
||||||
typedef CGAL::Cartesian<NT> Linear_k;
|
typedef CGAL::Cartesian<NT> Linear_k;
|
||||||
|
|
||||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT> Algebraic_k;
|
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT> Algebraic_k;
|
||||||
typedef CGAL::Circular_kernel_2<Linear_k,Algebraic_k> Circular_k;
|
typedef CGAL::Circular_kernel_2<Linear_k,Algebraic_k> Circular_k;
|
||||||
// typedef CGAL::Exact_circular_kernel_2 Circular_k;
|
|
||||||
|
|
||||||
typedef Circular_k::Line_arc_2 Line_arc_2;
|
typedef Circular_k::Line_arc_2 Line_arc_2;
|
||||||
typedef Circular_k::Segment_2 Segment;
|
typedef Circular_k::Segment_2 Segment;
|
||||||
typedef Circular_k::Circular_arc_2 Circular_arc_2;
|
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<Circular_k,
|
typedef std::vector<CGAL::Object> ArcContainer;
|
||||||
Circular_arc_2,
|
|
||||||
Line_arc_2> Traits;
|
|
||||||
|
|
||||||
typedef Traits::Point_2 Point_2;
|
const QString my_title_string("CGAL :: "
|
||||||
typedef Traits::Curve_2 Curve_2;
|
"Intersecting Circles, Line Arcs, Circular Arcs");
|
||||||
//typedef boost::variant< Circular_arc_2, Line_arc_2 > Arc_2;
|
|
||||||
//typedef std::vector<Arc_2>
|
|
||||||
typedef std::vector<Curve_2> ArcContainer;
|
|
||||||
|
|
||||||
typedef CGAL::Arrangement_2<Traits> Pmwx;
|
|
||||||
typedef CGAL::Arr_naive_point_location<Pmwx> Point_location;
|
|
||||||
|
|
||||||
const QString my_title_string("Planar Map of Intersecting Circular Arcs");
|
|
||||||
|
|
||||||
// This layer controls the drawing of the Planar Map.
|
// This layer controls the drawing of the Planar Map.
|
||||||
class Qt_layer_do_sweep
|
class Qt_layer_show_intersections
|
||||||
: public CGAL::Qt_widget_layer
|
: public CGAL::Qt_widget_layer
|
||||||
{
|
{
|
||||||
Pmwx _pm;
|
ArcContainer _ac;
|
||||||
Point_location _pl;
|
bool show_intersections;
|
||||||
bool show_pmwx;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Qt_layer_do_sweep()
|
Qt_layer_show_intersections()
|
||||||
: _pm(), _pl(_pm), show_pmwx(true) {}
|
: _ac(), show_intersections(true) {}
|
||||||
|
|
||||||
void swap_show() { show_pmwx = ! show_pmwx; }
|
void swap_show() { show_intersections = ! show_intersections; }
|
||||||
|
|
||||||
const Pmwx & pm() const { return _pm; }
|
const ArcContainer & arc_container() const { return _ac; }
|
||||||
Pmwx & pm() { return _pm; }
|
ArcContainer & arc_container() { return _ac; }
|
||||||
|
|
||||||
const Point_location & pl() const { return _pl; }
|
|
||||||
Point_location & pl() { return _pl; }
|
|
||||||
|
|
||||||
void draw()
|
void draw()
|
||||||
{
|
{
|
||||||
if (! show_pmwx)
|
if (!show_intersections)
|
||||||
return;
|
return;
|
||||||
|
*widget << CGAL::RED;
|
||||||
|
int l = _ac.size();
|
||||||
|
|
||||||
*widget << CGAL::GREEN;
|
for(int i=0; i<l; i++) {
|
||||||
for (Pmwx::Halfedge_const_iterator ei = pm().halfedges_begin();
|
for(int j=i+1; j<l; j++) {
|
||||||
ei != pm().halfedges_end (); ++ei) {
|
std::vector< CGAL::Object > res;
|
||||||
if(const Line_arc_2* line = boost::get<Line_arc_2>( &(ei->curve()))) {
|
Circular_arc_2 ca1, ca2;
|
||||||
*widget << Segment(Circular_k::Point_2(to_double(line->source().x()),
|
Line_arc_2 la1, la2;
|
||||||
to_double(line->source().y())),
|
if(assign(ca1, _ac[i])) {
|
||||||
Circular_k::Point_2(to_double(line->target().x()),
|
if(assign(ca2, _ac[j])) {
|
||||||
to_double(line->target().y())));
|
CGAL::intersection(ca1, ca2, std::back_inserter(res));
|
||||||
}
|
} else {
|
||||||
else if (const Circular_arc_2* arc
|
CGAL::intersection(ca1, la2, std::back_inserter(res));
|
||||||
= boost::get<Circular_arc_2>( &(ei->curve()))) {
|
}
|
||||||
*widget << *arc;
|
} else {
|
||||||
}
|
if(assign(ca2, _ac[j])) {
|
||||||
}
|
CGAL::intersection(la1, ca2, std::back_inserter(res));
|
||||||
*widget << CGAL::RED;
|
} else {
|
||||||
for (Pmwx::Vertex_const_iterator vi = pm().vertices_begin();
|
CGAL::intersection(la1, la2, std::back_inserter(res));
|
||||||
vi != pm().vertices_end(); ++vi)
|
}
|
||||||
*widget << vi->point();
|
}
|
||||||
|
for(unsigned k=0; k<res.size(); k++) {
|
||||||
|
std::pair<Circular_arc_point_2, unsigned> 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.
|
// This layer controls the drawing of the arc_container.
|
||||||
struct Qt_layer_show_ch
|
struct Qt_layer_show_ch
|
||||||
: public CGAL::Qt_widget_layer
|
: public CGAL::Qt_widget_layer
|
||||||
{
|
{
|
||||||
ArcContainer _arc_container;
|
ArcContainer _ac;
|
||||||
bool show_arcs;
|
bool show_arcs;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -165,10 +152,9 @@ public:
|
||||||
Qt_layer_show_ch()
|
Qt_layer_show_ch()
|
||||||
: show_arcs(true) {}
|
: show_arcs(true) {}
|
||||||
|
|
||||||
const ArcContainer &
|
const ArcContainer & arc_container() const { return _ac; }
|
||||||
arc_container() const { return _arc_container; }
|
|
||||||
ArcContainer &
|
ArcContainer & arc_container() { return _ac; }
|
||||||
arc_container() { return _arc_container; }
|
|
||||||
|
|
||||||
void swap_show() { show_arcs = ! show_arcs; }
|
void swap_show() { show_arcs = ! show_arcs; }
|
||||||
|
|
||||||
|
|
@ -176,25 +162,22 @@ public:
|
||||||
{
|
{
|
||||||
if (!show_arcs)
|
if (!show_arcs)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
*widget << CGAL::BLUE;
|
*widget << CGAL::BLUE;
|
||||||
for (ArcContainer::const_iterator cit = arc_container().begin();
|
int l = _ac.size();
|
||||||
cit != arc_container().end(); ++cit){
|
for (int i=0; i<l; i++){
|
||||||
if(const Line_arc_2* line = boost::get<Line_arc_2>( &(*cit))){
|
Circular_arc_2 ca;
|
||||||
*widget << Segment(Circular_k::Point_2(to_double(line->source().x()),
|
Line_arc_2 la;
|
||||||
to_double(line->source().y())),
|
if(assign(ca, _ac[i])) *widget << ca;
|
||||||
Circular_k::Point_2(to_double(line->target().x()),
|
else if(assign(la, _ac[i])) {
|
||||||
to_double(line->target().y())));
|
*widget << Segment(Circular_k::Point_2(to_double(la.source().x()),
|
||||||
}
|
to_double(la.source().y())),
|
||||||
else if (const Circular_arc_2* arc
|
Circular_k::Point_2(to_double(la.target().x()),
|
||||||
= boost::get<Circular_arc_2>( &(*cit))) {
|
to_double(la.target().y())));
|
||||||
*widget << *arc;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class MyWindow
|
class MyWindow
|
||||||
: public QMainWindow
|
: public QMainWindow
|
||||||
{
|
{
|
||||||
|
|
@ -219,9 +202,6 @@ public:
|
||||||
file->insertItem("&New", this, SLOT(new_instance()), CTRL+Key_N);
|
file->insertItem("&New", this, SLOT(new_instance()), CTRL+Key_N);
|
||||||
file->insertItem("New &Window", this, SLOT(new_window()), CTRL+Key_W);
|
file->insertItem("New &Window", this, SLOT(new_window()), CTRL+Key_W);
|
||||||
file->insertSeparator();
|
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->insertItem("Print", widget, SLOT(print_to_ps()), CTRL+Key_P);
|
||||||
file->insertSeparator();
|
file->insertSeparator();
|
||||||
file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_X );
|
file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_X );
|
||||||
|
|
@ -243,19 +223,19 @@ public:
|
||||||
QToolBar * layers_toolbar = new QToolBar("Tools", this,
|
QToolBar * layers_toolbar = new QToolBar("Tools", this,
|
||||||
QMainWindow::Top, TRUE, "Tools");
|
QMainWindow::Top, TRUE, "Tools");
|
||||||
|
|
||||||
// the sweep button
|
// the show intersections button
|
||||||
QToolButton * sweep_button =
|
QToolButton * show_intersections_button =
|
||||||
new QToolButton(QPixmap((const char**)::sweeper_xpm ),
|
new QToolButton(QPixmap((const char**)::sweeper_xpm ),
|
||||||
"Let's do the Sweep",
|
"Showing Intersections",
|
||||||
0,
|
0,
|
||||||
this,
|
this,
|
||||||
SLOT(update_pmwx()),
|
SLOT(show_intersections()),
|
||||||
layers_toolbar,
|
layers_toolbar,
|
||||||
"Let's do the Sweep");
|
"Showing Intersections");
|
||||||
|
|
||||||
widget->attach(&do_sweep_layer);
|
widget->attach(&show_intersections_layer);
|
||||||
connect(sweep_button, SIGNAL(stateChanged(int)),
|
connect(show_intersections_button, SIGNAL(stateChanged(int)),
|
||||||
&do_sweep_layer, SLOT(stateChanged(int)));
|
&show_intersections_layer, SLOT(stateChanged(int)));
|
||||||
|
|
||||||
// the button controlling if we show the input arcs
|
// the button controlling if we show the input arcs
|
||||||
QToolButton * show_container_button =
|
QToolButton * show_container_button =
|
||||||
|
|
@ -272,22 +252,6 @@ public:
|
||||||
connect(show_container_button, SIGNAL(stateChanged(int)),
|
connect(show_container_button, SIGNAL(stateChanged(int)),
|
||||||
&testlayer, SLOT(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
|
// the button controlling if we use circular arcs or line
|
||||||
QToolButton * line_circle_button =
|
QToolButton * line_circle_button =
|
||||||
new QToolButton(QPixmap((const char**)::lines_icon),
|
new QToolButton(QPixmap((const char**)::lines_icon),
|
||||||
|
|
@ -301,9 +265,7 @@ public:
|
||||||
line_circle_button->setToggleButton(true);
|
line_circle_button->setToggleButton(true);
|
||||||
arc_circle = true;
|
arc_circle = true;
|
||||||
|
|
||||||
|
// this button clears the content of the arc container
|
||||||
|
|
||||||
// this button clears the content of the arc container and the PMWX.
|
|
||||||
QToolButton * clear_button =
|
QToolButton * clear_button =
|
||||||
new QToolButton(QPixmap((const char**)trash),
|
new QToolButton(QPixmap((const char**)trash),
|
||||||
"Clear",
|
"Clear",
|
||||||
|
|
@ -316,7 +278,6 @@ public:
|
||||||
connect(clear_button, SIGNAL(stateChanged(int)),
|
connect(clear_button, SIGNAL(stateChanged(int)),
|
||||||
&testlayer, SLOT(stateChanged(int)));
|
&testlayer, SLOT(stateChanged(int)));
|
||||||
|
|
||||||
|
|
||||||
*widget << CGAL::LineWidth(2) << CGAL::BackgroundColor(CGAL::WHITE);
|
*widget << CGAL::LineWidth(2) << CGAL::BackgroundColor(CGAL::WHITE);
|
||||||
|
|
||||||
resize(w,h);
|
resize(w,h);
|
||||||
|
|
@ -340,36 +301,23 @@ public slots:
|
||||||
widget->lock();
|
widget->lock();
|
||||||
widget->clear_history();
|
widget->clear_history();
|
||||||
widget->set_window(-1.1, 1.1, -1.1, 1.1);
|
widget->set_window(-1.1, 1.1, -1.1, 1.1);
|
||||||
// set the Visible Area to the Interval
|
|
||||||
widget->unlock();
|
widget->unlock();
|
||||||
something_changed = true;
|
something_changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_arc()
|
void get_arc()
|
||||||
{
|
{
|
||||||
Curve_2 v;
|
CGAL::Object o;
|
||||||
if (arc_circle){
|
if (arc_circle) {
|
||||||
v = get_arc_layer->get_circular_arc();
|
Circular_arc_2 ca = get_arc_layer->get_circular_arc();
|
||||||
|
o = make_object(ca);
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
v = get_segment_layer->get_line_arc();
|
Line_arc_2 la = get_segment_layer->get_line_arc();
|
||||||
}
|
o = make_object(la);
|
||||||
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());
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
arc_container().push_back(o);
|
||||||
|
intersections_container().push_back(o);
|
||||||
something_changed = true;
|
something_changed = true;
|
||||||
widget->redraw();
|
widget->redraw();
|
||||||
}
|
}
|
||||||
|
|
@ -381,9 +329,9 @@ public slots:
|
||||||
widget->redraw();
|
widget->redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_pmwx_arcs()
|
void show_intersections()
|
||||||
{
|
{
|
||||||
do_sweep_layer.swap_show();
|
show_intersections_layer.swap_show();
|
||||||
something_changed = true;
|
something_changed = true;
|
||||||
widget->redraw();
|
widget->redraw();
|
||||||
}
|
}
|
||||||
|
|
@ -405,7 +353,7 @@ public slots:
|
||||||
void clear_container()
|
void clear_container()
|
||||||
{
|
{
|
||||||
arc_container().clear();
|
arc_container().clear();
|
||||||
pm().clear();
|
intersections_container().clear();
|
||||||
something_changed = true;
|
something_changed = true;
|
||||||
widget->redraw();
|
widget->redraw();
|
||||||
}
|
}
|
||||||
|
|
@ -414,9 +362,7 @@ private slots:
|
||||||
|
|
||||||
void about()
|
void about()
|
||||||
{
|
{
|
||||||
QMessageBox::about(this, my_title_string,
|
QMessageBox::about(this, my_title_string, "This is a demo of the CGAL's Circular_kernel_2.\n Particularly, the intersection functionality.");
|
||||||
"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()
|
void aboutQt()
|
||||||
|
|
@ -450,67 +396,27 @@ private slots:
|
||||||
something_changed = false;
|
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<Arc_2> 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<Circular_k, Circular_arc_2, Line_arc_2>(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<Arc_2>(out, "\n"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool arc_circle;
|
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
|
const ArcContainer & arc_container() const
|
||||||
{ return testlayer.arc_container(); }
|
{ return testlayer.arc_container(); }
|
||||||
|
|
||||||
ArcContainer & arc_container()
|
ArcContainer & arc_container()
|
||||||
{ return testlayer.arc_container(); }
|
{ return testlayer.arc_container(); }
|
||||||
|
|
||||||
CGAL::Qt_widget *widget;
|
const ArcContainer & intersections_container() const
|
||||||
CGAL::Qt_widget_standard_toolbar *stoolbar;
|
{ return show_intersections_layer.arc_container(); }
|
||||||
bool something_changed;
|
|
||||||
Qt_layer_show_ch testlayer;
|
ArcContainer & intersections_container()
|
||||||
Qt_layer_do_sweep do_sweep_layer;
|
{ return show_intersections_layer.arc_container(); }
|
||||||
CGAL::Qt_widget_get_segment<Circular_k> *get_segment_layer;
|
|
||||||
|
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<Circular_k> *get_segment_layer;
|
||||||
CGAL::Qt_widget_get_arc<Circular_k> *get_arc_layer;
|
CGAL::Qt_widget_get_arc<Circular_k> *get_arc_layer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 <CGAL/basic.h>
|
|
||||||
|
|
||||||
// if QT is not installed, a message will be issued at runtime.
|
|
||||||
#ifndef CGAL_USE_QT
|
|
||||||
#include <iostream>
|
|
||||||
int main() {
|
|
||||||
std::cout << "Sorry, this demo needs QT..." << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include <CGAL/Cartesian.h>
|
|
||||||
#include <CGAL/point_generators_2.h>
|
|
||||||
#include <CGAL/MP_Float.h>
|
|
||||||
#include <CGAL/Algebraic_kernel_for_circles_2_2.h>
|
|
||||||
#include <CGAL/IO/Qt_widget.h>
|
|
||||||
#include <CGAL/IO/Qt_widget_standard_toolbar.h>
|
|
||||||
#include <CGAL/IO/Qt_help_window.h>
|
|
||||||
#include <CGAL/IO/Qt_widget_layer.h>
|
|
||||||
|
|
||||||
#include <qplatinumstyle.h>
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <qmainwindow.h>
|
|
||||||
#include <qstatusbar.h>
|
|
||||||
#include <qfiledialog.h>
|
|
||||||
#include <qmessagebox.h>
|
|
||||||
#include <qpopupmenu.h>
|
|
||||||
#include <qmenubar.h>
|
|
||||||
#include <qtoolbutton.h>
|
|
||||||
#include <qtoolbar.h>
|
|
||||||
#include <qfiledialog.h>
|
|
||||||
#include <qtimer.h>
|
|
||||||
|
|
||||||
#include <CGAL/IO/Qt_widget_circular_arc_2.h>
|
|
||||||
#include <CGAL/IO/Qt_widget_circular_arc_endpoint_2.h>
|
|
||||||
|
|
||||||
#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 <CGAL/intersections.h>
|
|
||||||
|
|
||||||
#include <CGAL/Circular_kernel_2.h>
|
|
||||||
#include <CGAL/Lazy_circular_kernel_2.h>
|
|
||||||
#include <CGAL/Arr_circular_line_arc_traits.h>
|
|
||||||
#include <CGAL/Arr_circular_arc_traits_tracer.h>
|
|
||||||
|
|
||||||
|
|
||||||
#include <CGAL/Arrangement_2.h>
|
|
||||||
#include <CGAL/Arr_naive_point_location.h>
|
|
||||||
#include <CGAL/IO/Dxf_variant_reader.h>
|
|
||||||
|
|
||||||
typedef CGAL::Quotient<CGAL::MP_Float> NT1;
|
|
||||||
typedef CGAL::Cartesian<NT1> Linear_k1;
|
|
||||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT1> Algebraic_k1;
|
|
||||||
typedef CGAL::Circular_kernel_2<Linear_k1,Algebraic_k1> CK1_;
|
|
||||||
|
|
||||||
typedef CGAL::Interval_nt_advanced NT2;
|
|
||||||
typedef CGAL::Cartesian<NT2> Linear_k2;
|
|
||||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT2> Algebraic_k2;
|
|
||||||
typedef CGAL::Circular_kernel_2<Linear_k2,Algebraic_k2> CK2_;
|
|
||||||
typedef CGAL::Lazy_circular_kernel_2<CK1_,CK2_> 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<Arc_2> ArcContainer;
|
|
||||||
|
|
||||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
|
||||||
typedef CGAL::Arr_circular_line_arc_traits
|
|
||||||
<Circular_k, Circular_arc_2, Line_arc_2> Traits;
|
|
||||||
#else
|
|
||||||
typedef CGAL::Arr_circular_line_arc_traits
|
|
||||||
<Circular_k, Circular_arc_2, Line_arc_2> Traits0;
|
|
||||||
typedef CGAL::Circular_arc_traits_tracer<Traits0> Traits;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef Traits::Point_2 Point_2;
|
|
||||||
typedef Traits::Curve_2 Conic_arc_2;
|
|
||||||
typedef CGAL::Arrangement_2<Traits> Pmwx;
|
|
||||||
typedef CGAL::Arr_naive_point_location<Pmwx> 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<Line_arc_2>( &(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<Circular_arc_2>( &(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<Line_arc_2>( &(*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<Circular_arc_2>( &(*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<Circular_k>;
|
|
||||||
get_segment_layer = new CGAL::Qt_widget_get_segment<Circular_k>;
|
|
||||||
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<Arc_2> 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<Circular_k, Circular_arc_2, Line_arc_2>(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<Arc_2>(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<Circular_k> *get_segment_layer;
|
|
||||||
CGAL::Qt_widget_get_arc<Circular_k> *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
|
|
||||||
|
|
@ -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 <CGAL/basic.h>
|
|
||||||
|
|
||||||
// if QT is not installed, a message will be issued at runtime.
|
|
||||||
#ifndef CGAL_USE_QT
|
|
||||||
#include <iostream>
|
|
||||||
int main() {
|
|
||||||
std::cout << "Sorry, this demo needs QT..." << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include <CGAL/Cartesian.h>
|
|
||||||
#include <CGAL/point_generators_2.h>
|
|
||||||
|
|
||||||
#include <CGAL/MP_Float.h>
|
|
||||||
|
|
||||||
#include <CGAL/Algebraic_kernel_for_circles_2_2.h>
|
|
||||||
|
|
||||||
#include <CGAL/IO/Qt_widget.h>
|
|
||||||
#include <CGAL/IO/Qt_widget_standard_toolbar.h>
|
|
||||||
#include <CGAL/IO/Qt_help_window.h>
|
|
||||||
#include <CGAL/IO/Qt_widget_layer.h>
|
|
||||||
|
|
||||||
#include <qplatinumstyle.h>
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <qmainwindow.h>
|
|
||||||
#include <qstatusbar.h>
|
|
||||||
#include <qfiledialog.h>
|
|
||||||
#include <qmessagebox.h>
|
|
||||||
#include <qpopupmenu.h>
|
|
||||||
#include <qmenubar.h>
|
|
||||||
#include <qtoolbutton.h>
|
|
||||||
#include <qtoolbar.h>
|
|
||||||
#include <qfiledialog.h>
|
|
||||||
#include <qtimer.h>
|
|
||||||
|
|
||||||
#include <CGAL/IO/Qt_widget_circular_arc_2.h>
|
|
||||||
#include <CGAL/IO/Qt_widget_circular_arc_endpoint_2.h>
|
|
||||||
|
|
||||||
#include "Qt_widget_get_arc.h"
|
|
||||||
#include "sweeper.xpm"
|
|
||||||
#include "trash.xpm"
|
|
||||||
#include "get_arc.xpm"
|
|
||||||
#include "planar_map_icon.xpm"
|
|
||||||
|
|
||||||
#include <CGAL/intersections.h>
|
|
||||||
|
|
||||||
#include <CGAL/Circular_kernel_2.h>
|
|
||||||
#include <CGAL/Arr_circular_arc_traits.h>
|
|
||||||
#include <CGAL/Arr_circular_arc_traits_tracer.h>
|
|
||||||
|
|
||||||
#include <CGAL/Arrangement_2.h>
|
|
||||||
#include <CGAL/Arr_naive_point_location.h>
|
|
||||||
|
|
||||||
typedef CGAL::Quotient<CGAL::MP_Float> NT;
|
|
||||||
|
|
||||||
typedef CGAL::Cartesian<NT> Linear_k;
|
|
||||||
|
|
||||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT> Algebraic_k;
|
|
||||||
typedef CGAL::Circular_kernel_2<Linear_k,Algebraic_k> Circular_k;
|
|
||||||
|
|
||||||
typedef Circular_k::Circular_arc_2 Arc_2;
|
|
||||||
typedef std::vector<Arc_2> ArcContainer;
|
|
||||||
|
|
||||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
|
||||||
typedef CGAL::Arr_circular_arc_traits<Circular_k> Traits;
|
|
||||||
#else
|
|
||||||
typedef CGAL::Arr_circular_arc_traits<Circular_k> Traits0;
|
|
||||||
typedef CGAL::Circular_arc_traits_tracer<Traits0> Traits;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef Traits::Point_2 Point_2;
|
|
||||||
typedef Traits::Curve_2 Conic_arc_2;
|
|
||||||
typedef CGAL::Arrangement_2<Traits> Pmwx;
|
|
||||||
typedef CGAL::Arr_naive_point_location<Pmwx> 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<Circular_k>;
|
|
||||||
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<Arc_2> 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<Arc_2>(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<Circular_k> *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
|
|
||||||
|
|
@ -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 <CGAL/basic.h>
|
|
||||||
|
|
||||||
// if QT is not installed, a message will be issued at runtime.
|
|
||||||
#ifndef CGAL_USE_QT
|
|
||||||
#include <iostream>
|
|
||||||
int main() {
|
|
||||||
std::cout << "Sorry, this demo needs QT..." << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include <CGAL/Cartesian.h>
|
|
||||||
#include <CGAL/point_generators_2.h>
|
|
||||||
|
|
||||||
#include <CGAL/gmpxx.h>
|
|
||||||
|
|
||||||
#include <synaps/arithm/algebraic/AK/SAK_2.h>
|
|
||||||
|
|
||||||
#include <CGAL/IO/Qt_widget.h>
|
|
||||||
#include <CGAL/IO/Qt_widget_standard_toolbar.h>
|
|
||||||
#include <CGAL/IO/Qt_help_window.h>
|
|
||||||
#include <CGAL/IO/Qt_widget_layer.h>
|
|
||||||
|
|
||||||
#include <qplatinumstyle.h>
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <qmainwindow.h>
|
|
||||||
#include <qstatusbar.h>
|
|
||||||
#include <qfiledialog.h>
|
|
||||||
#include <qmessagebox.h>
|
|
||||||
#include <qpopupmenu.h>
|
|
||||||
#include <qmenubar.h>
|
|
||||||
#include <qtoolbutton.h>
|
|
||||||
#include <qtoolbar.h>
|
|
||||||
#include <qfiledialog.h>
|
|
||||||
#include <qtimer.h>
|
|
||||||
|
|
||||||
#include <CGAL/IO/Qt_widget_circular_arc_2.h>
|
|
||||||
#include <CGAL/IO/Qt_widget_circular_arc_endpoint_2.h>
|
|
||||||
|
|
||||||
#include "Qt_widget_get_arc.h"
|
|
||||||
#include "sweeper.xpm"
|
|
||||||
#include "trash.xpm"
|
|
||||||
#include "get_arc.xpm"
|
|
||||||
#include "planar_map_icon.xpm"
|
|
||||||
|
|
||||||
#include <CGAL/intersections.h>
|
|
||||||
|
|
||||||
#include <CGAL/Circular_kernel_2.h>
|
|
||||||
#include <CGAL/Circular_arc_traits.h>
|
|
||||||
#include <CGAL/Circular_arc_traits_tracer.h>
|
|
||||||
|
|
||||||
#include <CGAL/Arrangement_2.h>
|
|
||||||
#include <CGAL/Arr_naive_point_location.h>
|
|
||||||
|
|
||||||
typedef SYNAPS::QQ NT;
|
|
||||||
typedef SYNAPS::ZZ RT;
|
|
||||||
|
|
||||||
typedef CGAL::Cartesian<NT> Linear_k;
|
|
||||||
|
|
||||||
typedef SYNAPS::Algebraic_kernel_2<RT> Algebraic_k;
|
|
||||||
typedef CGAL::Circular_kernel_2<Linear_k,Algebraic_k> Curved_k;
|
|
||||||
|
|
||||||
|
|
||||||
typedef Curved_k::Circular_arc_2 Arc_2;
|
|
||||||
typedef std::vector<Arc_2> ArcContainer;
|
|
||||||
|
|
||||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
|
||||||
typedef CGAL::Circular_arc_traits<Curved_k> Traits;
|
|
||||||
#else
|
|
||||||
typedef CGAL::Circular_arc_traits<Curved_k> Traits0;
|
|
||||||
typedef CGAL::Circular_arc_traits_tracer<Traits0> Traits;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef Traits::Point_2 Point_2;
|
|
||||||
typedef Traits::Curve_2 Conic_arc_2;
|
|
||||||
typedef CGAL::Arrangement_2<Traits> Pmwx;
|
|
||||||
typedef CGAL::Arr_naive_point_location<Pmwx> Point_location;
|
|
||||||
|
|
||||||
typedef Traits::X_monotone_curve_2 X_monotone_curve_2;
|
|
||||||
|
|
||||||
// typedef CGAL::Pm_default_dcel<Traits> Dcel;
|
|
||||||
// typedef CGAL::Planar_map_2<Dcel,Traits> Planar_map_2;
|
|
||||||
// typedef CGAL::Planar_map_with_intersections_2<Planar_map_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<Curved_k>;
|
|
||||||
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<Arc_2> 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<Arc_2>(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<Curved_k> *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
|
|
||||||
|
|
@ -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 <CGAL/basic.h>
|
|
||||||
|
|
||||||
// if QT is not installed, a message will be issued at runtime.
|
|
||||||
#ifndef CGAL_USE_QT
|
|
||||||
#include <iostream>
|
|
||||||
int main() {
|
|
||||||
std::cout << "Sorry, this demo needs QT..." << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <CGAL/Cartesian.h>
|
|
||||||
#include <CGAL/point_generators_2.h>
|
|
||||||
#include <CGAL/MP_Float.h>
|
|
||||||
#include <CGAL/Algebraic_kernel_for_circles_2_2.h>
|
|
||||||
#include <CGAL/IO/Qt_widget.h>
|
|
||||||
#include <CGAL/IO/Qt_widget_standard_toolbar.h>
|
|
||||||
#include <CGAL/IO/Qt_help_window.h>
|
|
||||||
#include <CGAL/IO/Qt_widget_layer.h>
|
|
||||||
|
|
||||||
#include <qplatinumstyle.h>
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <qmainwindow.h>
|
|
||||||
#include <qstatusbar.h>
|
|
||||||
#include <qfiledialog.h>
|
|
||||||
#include <qmessagebox.h>
|
|
||||||
#include <qpopupmenu.h>
|
|
||||||
#include <qmenubar.h>
|
|
||||||
#include <qtoolbutton.h>
|
|
||||||
#include <qtoolbar.h>
|
|
||||||
#include <qfiledialog.h>
|
|
||||||
#include <qtimer.h>
|
|
||||||
|
|
||||||
#include <CGAL/IO/Qt_widget_circular_arc_2.h>
|
|
||||||
#include <CGAL/IO/Qt_widget_circular_arc_endpoint_2.h>
|
|
||||||
|
|
||||||
#include "Qt_widget_get_segment.h"
|
|
||||||
#include "sweeper.xpm"
|
|
||||||
#include "trash.xpm"
|
|
||||||
#include "get_arc.xpm"
|
|
||||||
#include "planar_map_icon.xpm"
|
|
||||||
|
|
||||||
#include <CGAL/intersections.h>
|
|
||||||
#include <CGAL/Circular_kernel_2.h>
|
|
||||||
#include <CGAL/Arr_line_arc_traits.h>
|
|
||||||
#include <CGAL/Arr_circular_arc_traits_tracer.h>
|
|
||||||
|
|
||||||
|
|
||||||
#include <CGAL/Arrangement_2.h>
|
|
||||||
#include <CGAL/Arr_naive_point_location.h>
|
|
||||||
|
|
||||||
|
|
||||||
typedef CGAL::Quotient<CGAL::MP_Float> NT;
|
|
||||||
|
|
||||||
typedef CGAL::Cartesian<NT> Linear_k;
|
|
||||||
|
|
||||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT> Algebraic_k;
|
|
||||||
typedef CGAL::Circular_kernel_2<Linear_k,Algebraic_k> Circular_k;
|
|
||||||
|
|
||||||
typedef Circular_k::Line_arc_2 Arc_2;
|
|
||||||
typedef Circular_k::Segment_2 Segment;
|
|
||||||
typedef std::vector<Arc_2> ArcContainer;
|
|
||||||
|
|
||||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
|
||||||
typedef CGAL::Arr_line_arc_traits<Circular_k> Traits;
|
|
||||||
#else
|
|
||||||
typedef CGAL::Arr_line_arc_traits<Circular_k> Traits0;
|
|
||||||
typedef CGAL::Circular_arc_traits_tracer<Traits0> Traits;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef Traits::Point_2 Point_2;
|
|
||||||
typedef Traits::Curve_2 Conic_arc_2;
|
|
||||||
typedef CGAL::Arrangement_2<Traits> Pmwx;
|
|
||||||
typedef CGAL::Arr_naive_point_location<Pmwx> 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<Circular_k>;
|
|
||||||
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<Arc_2> 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<Arc_2>(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<Circular_k> *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
|
|
||||||
|
|
@ -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 <CGAL/basic.h>
|
|
||||||
|
|
||||||
// if QT is not installed, a message will be issued at runtime.
|
|
||||||
#ifndef CGAL_USE_QT
|
|
||||||
#include <iostream>
|
|
||||||
int main() {
|
|
||||||
std::cout << "Sorry, this demo needs QT..." << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include <CGAL/Cartesian.h>
|
|
||||||
#include <CGAL/point_generators_2.h>
|
|
||||||
|
|
||||||
#include <CGAL/MP_Float.h>
|
|
||||||
#include <CGAL/Gmpq.h>
|
|
||||||
|
|
||||||
#include <CGAL/Algebraic_kernel_for_circles_2_2.h>
|
|
||||||
|
|
||||||
#include <CGAL/IO/Qt_widget.h>
|
|
||||||
#include <CGAL/IO/Qt_widget_standard_toolbar.h>
|
|
||||||
#include <CGAL/IO/Qt_help_window.h>
|
|
||||||
#include <CGAL/IO/Qt_widget_layer.h>
|
|
||||||
|
|
||||||
#include <qplatinumstyle.h>
|
|
||||||
#include <qapplication.h>
|
|
||||||
#include <qmainwindow.h>
|
|
||||||
#include <qstatusbar.h>
|
|
||||||
#include <qfiledialog.h>
|
|
||||||
#include <qmessagebox.h>
|
|
||||||
#include <qpopupmenu.h>
|
|
||||||
#include <qmenubar.h>
|
|
||||||
#include <qtoolbutton.h>
|
|
||||||
#include <qtoolbar.h>
|
|
||||||
#include <qfiledialog.h>
|
|
||||||
#include <qtimer.h>
|
|
||||||
|
|
||||||
#include <CGAL/IO/Qt_widget_circular_arc_2.h>
|
|
||||||
#include <CGAL/IO/Qt_widget_circular_arc_endpoint_2.h>
|
|
||||||
|
|
||||||
|
|
||||||
#include "Qt_widget_get_segment.h"
|
|
||||||
#include "Qt_widget_get_arc.h"
|
|
||||||
#include "trash.xpm"
|
|
||||||
#include "get_arc.xpm"
|
|
||||||
|
|
||||||
#include <CGAL/Circular_kernel_2.h>
|
|
||||||
#include <CGAL/Arr_circular_line_arc_traits.h>
|
|
||||||
#include <CGAL/Arr_circular_arc_traits_tracer.h>
|
|
||||||
#include <CGAL/IO/Dxf_variant_reader.h>
|
|
||||||
|
|
||||||
typedef CGAL::Quotient<CGAL::MP_Float> NT;
|
|
||||||
typedef CGAL::Cartesian<NT> Linear_k;
|
|
||||||
typedef CGAL::Algebraic_kernel_for_circles_2_2<NT> Algebraic_k;
|
|
||||||
typedef CGAL::Circular_kernel_2<Linear_k,Algebraic_k> 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<Arc_2> ArcContainer;
|
|
||||||
|
|
||||||
#ifndef CGAL_CURVED_KERNEL_DEBUG
|
|
||||||
typedef CGAL::Arr_circular_line_arc_traits
|
|
||||||
<Circular_k, Circular_arc_2, Line_arc_2> Traits;
|
|
||||||
#else
|
|
||||||
typedef CGAL::Arr_circular_line_arc_traits
|
|
||||||
<Circular_k, Circular_arc_2, Line_arc_2> Traits0;
|
|
||||||
typedef CGAL::Circular_arc_traits_tracer<Traits0> 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<Line_arc_2>( &(*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<Circular_arc_2>( &(*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<Circular_k>;
|
|
||||||
get_segment_layer = new CGAL::Qt_widget_get_segment<Circular_k>;
|
|
||||||
// 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<Arc_2> 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<Circular_k, Circular_arc_2, Line_arc_2>(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<Arc_2>(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<Circular_k> *get_segment_layer;
|
|
||||||
CGAL::Qt_widget_get_arc<Circular_k> *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
|
|
||||||
|
|
@ -1,41 +1,27 @@
|
||||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Alpha_shapes_2</title>
|
<title>Circular Kernel 2D</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<P align="center"><FONT size="5">How to use the<p>"CGAL::PMWX using
|
<P align="center"><FONT size="5">How to use the<p>"Circular Kernel 2D"<p>Demo</FONT></P>
|
||||||
Curved_kernel"<p>Demo</FONT></P>
|
|
||||||
<br>
|
<br>
|
||||||
This demo illustrates the Planar Map With Intersection class of CGAL,
|
This demo illustrates the intersection functionality provided by the CGAL's Circular_kernel_2.
|
||||||
applied to the circular arcs provided by Curved_kernel.
|
|
||||||
<p>
|
<p>
|
||||||
You can input circular arcs easily using the mouse, and they will be
|
You can easily input circular arcs and segments using the mouse. The first click is the center
|
||||||
immediately inserted into the current PMWX. The first click is the center
|
|
||||||
of the supporting circle, the second will select the radius, then you have
|
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
|
to enter two rays delimiting the arc. Pressing the 'c' key while entering
|
||||||
the second ray will take the opposite arc (the yellow part).
|
the second ray will take the opposite arc (the yellow part).
|
||||||
<p>
|
<p>
|
||||||
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.
|
|
||||||
<p>
|
|
||||||
<IMG SRC="help/sweeper.jpeg" HEIGHT=30>
|
<IMG SRC="help/sweeper.jpeg" HEIGHT=30>
|
||||||
It is possible to call the sweep algorithm (i.e. rebuild the current PMWX
|
Clicking in this icon will toggle the intersections visibility.
|
||||||
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.
|
|
||||||
<p>
|
<p>
|
||||||
<IMG SRC="help/trash.jpeg" HEIGHT=30>
|
<IMG SRC="help/trash.jpeg" HEIGHT=30>
|
||||||
To erase the current PMWX as well as the content of the arcs container,
|
To erase the content of the arcs container, just click on the trash.
|
||||||
just click on the trash.
|
|
||||||
<p>
|
|
||||||
By default, both the content of the arcs container (in blue) and the current
|
|
||||||
PMWX (in green and red) are displayed.
|
|
||||||
<p>
|
<p>
|
||||||
<IMG SRC="help/planar_map_icon.jpeg" HEIGHT=30>
|
<IMG SRC="help/planar_map_icon.jpeg" HEIGHT=30>
|
||||||
This button toggles the display of the PMWX (it is still computed even when it
|
Toggling this button will change the object you are inserting between circular arcs and segments.
|
||||||
is now displayed).
|
|
||||||
<p>
|
<p>
|
||||||
<IMG SRC="help/get_arc.jpeg" HEIGHT=30>
|
<IMG SRC="help/get_arc.jpeg" HEIGHT=30>
|
||||||
This button toggles the display of the arcs container.
|
This button toggles the display of the arcs container.
|
||||||
|
|
@ -50,18 +36,7 @@ This button toggles the display of the arcs container.
|
||||||
<LI><A href="#close_window">Close the current window</A></LI>
|
<LI><A href="#close_window">Close the current window</A></LI>
|
||||||
<LI><A href="#quit">Quit the application</A></LI>
|
<LI><A href="#quit">Quit the application</A></LI>
|
||||||
</UL><br>
|
</UL><br>
|
||||||
<!--
|
|
||||||
Editing
|
|
||||||
<UL>
|
|
||||||
<LI><A href="#gen_tr">Generate Delaunay triangulation</A></LI>
|
|
||||||
<LI><A href="#insert_vertex">Insert a new vertex</A></LI>
|
|
||||||
</UL>
|
|
||||||
Persistance
|
|
||||||
<UL>
|
|
||||||
<LI><A href="#save_triangulation">Save the current triangulation</A></LI>
|
|
||||||
<LI><A href="#load_triangulation">Load an existing triangulation</A></LI>
|
|
||||||
</UL>
|
|
||||||
-->
|
|
||||||
<P align="left"><STRONG><FONT size="5"></FONT></STRONG> </P>
|
<P align="left"><STRONG><FONT size="5"></FONT></STRONG> </P>
|
||||||
<P align="left"><STRONG><FONT size="5"></FONT></STRONG> </P>
|
<P align="left"><STRONG><FONT size="5"></FONT></STRONG> </P>
|
||||||
<P align="left"><STRONG><FONT size="5"></FONT></STRONG> </P>
|
<P align="left"><STRONG><FONT size="5"></FONT></STRONG> </P>
|
||||||
|
|
@ -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
|
When you quit the application, all the windows you have created will
|
||||||
be destroyed.
|
be destroyed.
|
||||||
|
|
||||||
|
|
||||||
<!--
|
|
||||||
<P align="left"><STRONG><FONT color="#3300cc" size="4">
|
|
||||||
<A name="gen_tr"></A></FONT></STRONG> </P>
|
|
||||||
<P align="left"><STRONG><FONT color="#3300cc" size="4">
|
|
||||||
</FONT></STRONG> </P>
|
|
||||||
<P align="left"><STRONG>
|
|
||||||
<FONT color="#3300cc" size="3">Generate Delaunay triangulation</FONT>
|
|
||||||
</STRONG></P>
|
|
||||||
To generate a Delaunay triangulation, go to Edit menu and choose
|
|
||||||
"Generate Triangulation" button, or press Ctrl+G combination keys.
|
|
||||||
Each time you generate the triangulation, the old one will be erased.
|
|
||||||
|
|
||||||
<P align="left"><STRONG><FONT color="#3300cc" size="4">
|
|
||||||
<A name="insert_vertex"></A></FONT></STRONG> </P>
|
|
||||||
<P align="left"><STRONG><FONT color="#3300cc" size="4">
|
|
||||||
</FONT></STRONG> </P>
|
|
||||||
<P align="left"><STRONG>
|
|
||||||
<FONT color="#3300cc" size="3">Insert a new vertex</FONT></STRONG></P>
|
|
||||||
<IMG SRC="help/input_point_layer.gif"></IMG>
|
|
||||||
Left click on the "Input point" layer. Be sure there is no layer
|
|
||||||
activated in standard toolbar that eat events. To be sure, press the
|
|
||||||
arrow button situated on the standard toolbar. Left Click anywhere on the
|
|
||||||
application's drawing area (the black rectangle) to insert the vertex.
|
|
||||||
The vertex is inserted in the triangulation. To see the conflict zone
|
|
||||||
keep the left mouse button pressed. The vertex is inserted when you
|
|
||||||
release the button.<br>
|
|
||||||
<table border=0><tr><td><IMG SRC="help/conflict_zone.gif" HEIGHT=70></IMG>
|
|
||||||
</td><td><IMG SRC="help/conflict_zone_after.gif" HEIGHT=70></IMG></td>
|
|
||||||
</tr></table>
|
|
||||||
To insert more than one vertex, keep clicking on the rectangle without
|
|
||||||
deactivating the "Input point" layer. To deactivate this layer, just
|
|
||||||
press the arrow button situated on the same toolbar.
|
|
||||||
|
|
||||||
|
|
||||||
<P align="left"><STRONG><FONT color="#3300cc" size="4">
|
|
||||||
<A name="save_triangulation"></A></FONT></STRONG> </P>
|
|
||||||
<P align="left"><STRONG><FONT color="#3300cc" size="4"></FONT>
|
|
||||||
</STRONG> </P>
|
|
||||||
<P align="left"><STRONG>
|
|
||||||
<FONT color="#3300cc" size="3">Save the current triangulation</FONT>
|
|
||||||
</STRONG></P>
|
|
||||||
Press Ctrl+S combination keys or go to File menu, then choose
|
|
||||||
"Save Triangulation". A save file dialog will appear, the default name
|
|
||||||
given is "triangulation.cgal". You may change the name then press "Save"
|
|
||||||
or hit "Enter" key. To cancel the save process just press Esc key.<br>
|
|
||||||
<FONT SIZE=3 COLOR="#0000FF"> The triangulation saved does not contain
|
|
||||||
the visible area.</FONT>
|
|
||||||
|
|
||||||
|
|
||||||
<P align="left"><STRONG><FONT color="#3300cc" size="4">
|
|
||||||
<A name="load_triangulation"></A></FONT></STRONG> </P>
|
|
||||||
<P align="left"><STRONG><FONT color="#3300cc" size="4"></FONT>
|
|
||||||
</STRONG> </P>
|
|
||||||
<P align="left"><STRONG>
|
|
||||||
<FONT color="#3300cc" size="3">Load an existing triangulation</FONT>
|
|
||||||
</STRONG></P>
|
|
||||||
Press Ctrl+L combination keys or go to File menu and choose "Load
|
|
||||||
Triangulation". A load file dialog will appear, having a filter that
|
|
||||||
displays only the files with "cgal" extension. Choose a file then press
|
|
||||||
"Open" button or hit "Enter" key.<br>
|
|
||||||
<FONT SIZE=3 COLOR="#0000FF"> The triangulation saved does not contain
|
|
||||||
the visible area. The application will change the current visible area
|
|
||||||
to fit the bounding box of the triangualtion.</FONT>
|
|
||||||
<P align="left"><STRONG><FONT size="5"></FONT></STRONG> </P>
|
|
||||||
<P align="left"><STRONG><FONT size="5"></FONT></STRONG> </P>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
<hr>
|
<hr>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ CXXFLAGS = \
|
||||||
-I../../include \
|
-I../../include \
|
||||||
-I../../../Algebraic_kernel_for_circles/include \
|
-I../../../Algebraic_kernel_for_circles/include \
|
||||||
$(CGAL_CXXFLAGS) \
|
$(CGAL_CXXFLAGS) \
|
||||||
$(LONG_NAME_PROBLEM_CXXFLAGS)
|
$(LONG_NAME_PROBLEM_CXXFLAGS)
|
||||||
|
|
||||||
#---------------------------------------------------------------------#
|
#---------------------------------------------------------------------#
|
||||||
# linker flags
|
# linker flags
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue