diff --git a/GraphicsView/demo/Polygon/Polygon_2.cpp b/GraphicsView/demo/Polygon/Polygon_2.cpp index 37bec41a75c..7a75cbcebf1 100644 --- a/GraphicsView/demo/Polygon/Polygon_2.cpp +++ b/GraphicsView/demo/Polygon/Polygon_2.cpp @@ -9,6 +9,7 @@ #include #include #include +#include // Qt headers #include @@ -52,7 +53,7 @@ private: CGAL::Qt::Converter convert; - Polygon poly; + Polygon poly, kgon; QGraphicsScene scene; CGAL::Qt::PolygonGraphicsItem * pgi; @@ -65,6 +66,8 @@ private: std::list offsetGraphicsItems; CGAL::Qt::LineGraphicsItem* lgi; + CGAL::Qt::PolygonGraphicsItem * kgongi; + public: MainWindow(); @@ -78,6 +81,7 @@ public slots: void on_actionSavePolygon_triggered(); void on_actionRecenter_triggered(); + void on_actionMaximumAreaKGon_triggered(); void on_actionInnerSkeleton_triggered(); void on_actionOuterOffset_triggered(); void on_actionLinearLeastSquaresFitting_triggered(); @@ -116,7 +120,12 @@ MainWindow::MainWindow() pgi->setVerticesPen(QPen(Qt::red, 3, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); scene.addItem(pgi); - + kgongi = new CGAL::Qt::PolygonGraphicsItem(&kgon); + kgongi->setEdgesPen(QPen(Qt::blue, 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + kgongi->hide(); + scene.addItem(kgongi); + + lgi = new CGAL::Qt::LineGraphicsItem(); lgi->setPen(QPen(Qt::blue, 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); lgi->hide(); @@ -360,6 +369,25 @@ MainWindow::on_actionOuterOffset_triggered() } } +void +MainWindow::on_actionMaximumAreaKGon_triggered() +{ + if( (poly.size()>2) && poly.is_convex()){ + clear(); + + kgon.clear(); + std::vector points(poly.vertices_begin(), + poly.vertices_end()); + CGAL::maximum_area_inscribed_k_gon_2(points.begin(), + points.end(), + 3, + std::back_inserter(kgon)); + + kgongi->modelChanged(); + kgongi->show(); + } +} + void MainWindow::on_actionLinearLeastSquaresFitting_triggered() { @@ -484,6 +512,7 @@ MainWindow::clear() clearSkeleton(); clearOffset(); lgi->hide(); + kgongi->hide(); } diff --git a/GraphicsView/demo/Polygon/Polygon_2.ui b/GraphicsView/demo/Polygon/Polygon_2.ui index 977082c89e3..0fc3a3c92cf 100644 --- a/GraphicsView/demo/Polygon/Polygon_2.ui +++ b/GraphicsView/demo/Polygon/Polygon_2.ui @@ -1,8 +1,9 @@ - + + GeometryFactory Polygon_2 - - + + 0 0 @@ -10,37 +11,37 @@ 325 - + CGAL 2D Polygon - - + + :/cgal/logos/cgal_icon:/cgal/logos/cgal_icon - - + + - - + + Qt::Horizontal - - - + + + 2 0 - + Qt::StrongFocus - + Qt::ScrollBarAlwaysOn - + Qt::ScrollBarAlwaysOn - + QGraphicsView::NoAnchor @@ -48,185 +49,191 @@ - - - + + + File Tools - + TopToolBarArea - + false - - - + + + - - + + Visualization Tools - + TopToolBarArea - + false - + - - + + 0 0 568 - 19 + 26 - - + + &File - - - - - - + + + + + + - - + + &Algorithms - - - - - - - - - + + + + + + + + + + - - + + - - + + &About - - + + About &CGAL - - + + &Quit - + Ctrl+Q - - - + + + :/cgal/fileToolbar/fileNew.png:/cgal/fileToolbar/fileNew.png - + &Clear - + Ctrl+C - - - + + + :/cgal/fileToolbar/fileOpen.png:/cgal/fileToolbar/fileOpen.png - + &Load Polygon - + Ctrl+L - - - + + + :/cgal/fileToolbar/fileSave.png:/cgal/fileToolbar/fileSave.png - + &Save Polygon - + Ctrl+S - - - + + + :/cgal/Input/zoom-best-fit:/cgal/Input/zoom-best-fit - + Re&center the viewport - + Ctrl+R - - + + Y-monotone Partition - - + + true - + Create Input Polygon - - + + Inner Skeleton - - + + Outer Offset - - + + Optimal Convex Partition - - + + Approximate Convex Partition - - + + Linear Least Squares Fitting of Points - - + + Linear Least Squares Fitting of Segments + + + Maximum Area K-gon + + - - - - + + + +