From c6b789ca60db3162b7f5ef6b0ff46f95ee01aafe Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 27 Sep 2011 15:12:34 +0000 Subject: [PATCH] Allow to load a .cgal file (result of the operator<< of a CDT) --- .../Constrained_Delaunay_triangulation_2.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/GraphicsView/demo/Triangulation_2/Constrained_Delaunay_triangulation_2.cpp b/GraphicsView/demo/Triangulation_2/Constrained_Delaunay_triangulation_2.cpp index af3a4f973d6..fa8e2ece336 100644 --- a/GraphicsView/demo/Triangulation_2/Constrained_Delaunay_triangulation_2.cpp +++ b/GraphicsView/demo/Triangulation_2/Constrained_Delaunay_triangulation_2.cpp @@ -234,6 +234,8 @@ public slots: void on_actionLoadConstraints_triggered(); + void loadFile(QString); + void loadPolygonConstraints(QString); void loadEdgConstraints(QString); @@ -423,7 +425,10 @@ void MainWindow::open(QString fileName) { if(! fileName.isEmpty()){ - if(fileName.endsWith(".plg")){ + if(fileName.endsWith(".cgal")){ + loadFile(fileName); + this->addToRecentFiles(fileName); + } else if(fileName.endsWith(".plg")){ loadPolygonConstraints(fileName); this->addToRecentFiles(fileName); } else if(fileName.endsWith(".edg")){ @@ -444,6 +449,18 @@ MainWindow::on_actionLoadConstraints_triggered() open(fileName); } +void +MainWindow::loadFile(QString fileName) +{ + std::ifstream ifs(qPrintable(fileName)); + ifs >> cdt; + if(!ifs) abort(); + initializeID(cdt); + discoverComponents(cdt); + emit(changed()); + actionRecenter->trigger(); +} + void MainWindow::loadPolygonConstraints(QString fileName) {