Use Qtwidget << Polygon_2 instead of redoing a suboptimal loop

ourselves here (which additionnaly triggered a warning with -O2).
This commit is contained in:
Sylvain Pion 2008-01-01 15:12:11 +00:00
parent 97054e3e8d
commit 6467abc8ff
1 changed files with 5 additions and 28 deletions

View File

@ -23,7 +23,6 @@
#ifndef CGAL_USE_QT #ifndef CGAL_USE_QT
#include <iostream> #include <iostream>
int main(int, char*) int main(int, char*)
{ {
@ -36,15 +35,14 @@ int main(int, char*)
#else #else
#include <fstream> #include <fstream>
#include <stack>
#include <set>
#include <string>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/convex_hull_2.h> #include <CGAL/convex_hull_2.h>
#include <CGAL/Polygon_2_algorithms.h> #include <CGAL/Polygon_2_algorithms.h>
#include <CGAL/point_generators_2.h> #include <CGAL/point_generators_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/IO/Qt_widget_Polygon_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>
@ -93,38 +91,17 @@ public:
*widget << (*itp++); *widget << (*itp++);
} }
std::list<Point_2> out; CGAL::Polygon_2<Rep> out;
std::list<Segment> Sl;
CGAL::convex_hull_points_2(list_of_points.begin(), CGAL::convex_hull_points_2(list_of_points.begin(),
list_of_points.end(), list_of_points.end(),
std::back_inserter(out)); std::back_inserter(out));
if( out.size() > 1 ) { *widget << CGAL::BLUE << out;
Point_2 pakt,prev,pstart;
std::list<Point_2>::const_iterator it;
it=out.begin();
prev= *it; pstart=prev;
it++;
for(; it != out.end(); ++it) {
pakt= *it;
Sl.push_back(Segment(prev,pakt));
prev=pakt;
}
Sl.push_back(Segment(pakt,pstart));
*widget << CGAL::BLUE;
std::list<Segment>::iterator its = Sl.begin();
while(its!=Sl.end())
{
*widget << (*its++);
}
}
widget->unlock(); widget->unlock();
}; };
};//end class };
class MyWindow : public QMainWindow class MyWindow : public QMainWindow
{ {