diff --git a/.gitattributes b/.gitattributes index 5a6183a5bfe..f3188cd2506 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3105,6 +3105,7 @@ Polyhedron/demo/Polyhedron/MainWindow.ui -text Polyhedron/demo/Polyhedron/Polyhedron_3.qrc -text Polyhedron/demo/Polyhedron/data/anchor.off -text svneol=unset#application/octet-stream Polyhedron/demo/Polyhedron/data/cow.off -text svneol=unset#application/octet-stream +Polyhedron/demo/Polyhedron/data/cross.off -text svneol=unset#application/octet-stream Polyhedron/demo/Polyhedron/data/cube_tri.off -text svneol=unset#application/octet-stream Polyhedron/demo/Polyhedron/data/ellipsoid.off -text svneol=unset#application/octet-stream Polyhedron/demo/Polyhedron/data/knot.off -text svneol=unset#application/octet-stream diff --git a/Polyhedron/demo/Polyhedron/MainWindow.h b/Polyhedron/demo/Polyhedron/MainWindow.h index aafe0eaf325..95cb281f824 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.h +++ b/Polyhedron/demo/Polyhedron/MainWindow.h @@ -50,6 +50,7 @@ protected slots: void on_actionActivatePolyhedron_triggered(); void on_actionSetPolyhedronA_triggered(); void on_actionSetPolyhedronB_triggered(); + void on_actionInsideOut_triggered(); // save // TODO: save all, save current (do we store the current file name?) diff --git a/Polyhedron/demo/Polyhedron/MainWindow.ui b/Polyhedron/demo/Polyhedron/MainWindow.ui index 843cf452591..dbf2627f1d5 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.ui +++ b/Polyhedron/demo/Polyhedron/MainWindow.ui @@ -188,7 +188,7 @@ - + @@ -536,7 +536,7 @@ Ctrl+B - + Inside-out diff --git a/Polyhedron/demo/Polyhedron/MainWindow_inside_out.cpp b/Polyhedron/demo/Polyhedron/MainWindow_inside_out.cpp new file mode 100644 index 00000000000..874859a3841 --- /dev/null +++ b/Polyhedron/demo/Polyhedron/MainWindow_inside_out.cpp @@ -0,0 +1,19 @@ +#include "MainWindow.h" +#include "Scene.h" + +void MainWindow::on_actionInsideOut_triggered() +{ + if(onePolygonIsSelected()) + { + // get selected polyhedron + int index = getSelectedPolygonIndex(); + Polyhedron* pMesh = scene->polyhedron(index); + + // inside out + pMesh->inside_out(); + + // update scene + scene->polyhedronChanged(index); + QApplication::restoreOverrideCursor(); + } +} diff --git a/Polyhedron/demo/Polyhedron/MainWindow_kernel.cpp b/Polyhedron/demo/Polyhedron/MainWindow_kernel.cpp index d6612eb193c..ab0f851732d 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow_kernel.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow_kernel.cpp @@ -28,7 +28,7 @@ void MainWindow::on_actionKernel_triggered() // solve LP std::cout << "Solve linear program..."; Polyhedron_kernel kernel; - if(kernel.solve(triangles.begin(),triangles.end())) + if(!kernel.solve(triangles.begin(),triangles.end())) { std::cout << "empty kernel" << std::endl; return; diff --git a/Polyhedron/demo/Polyhedron/data/cross.off b/Polyhedron/demo/Polyhedron/data/cross.off new file mode 100644 index 00000000000..9623f6f97ed --- /dev/null +++ b/Polyhedron/demo/Polyhedron/data/cross.off @@ -0,0 +1,118 @@ +OFF +40 76 114 +-4.44089e-016 3 0 +1 3 0 +2 3 0 +2 4 0 +2 5 0 +3 5 0 +3 4 0 +3 3 0 +4 3 0 +5 3 0 +5 2 0 +4 2 0 +3 2 0 +3 1 0 +3 -4.44089e-016 0 +2 -4.44089e-016 0 +2 1 0 +2 2 0 +1 2 0 +-4.44089e-016 2 0 +-4.44089e-016 3 1 +1 3 1 +2 3 1 +2 4 1 +2 5 1 +3 5 1 +3 4 1 +3 3 1 +4 3 1 +5 3 1 +5 2 1 +4 2 1 +3 2 1 +3 1 1 +3 -4.44089e-016 1 +2 -4.44089e-016 1 +2 1 1 +2 2 1 +1 2 1 +-4.44089e-016 2 1 +3 19 0 1 +3 18 1 2 +3 17 2 7 +3 7 2 3 +3 6 3 4 +3 12 7 8 +3 11 8 9 +3 17 12 13 +3 16 13 14 +3 21 1 0 +3 22 2 1 +3 23 3 2 +3 24 4 3 +3 25 5 4 +3 26 6 5 +3 27 7 6 +3 28 8 7 +3 29 9 8 +3 30 10 9 +3 31 11 10 +3 32 12 11 +3 33 13 12 +3 34 14 13 +3 35 15 14 +3 36 16 15 +3 37 17 16 +3 38 18 17 +3 39 19 18 +3 20 0 19 +3 20 39 38 +3 21 38 37 +3 22 37 32 +3 22 27 26 +3 23 26 25 +3 27 32 31 +3 28 31 30 +3 32 37 36 +3 33 36 35 +3 1 18 19 +3 2 17 18 +3 7 12 17 +3 3 6 7 +3 4 5 6 +3 8 11 12 +3 9 10 11 +3 13 16 17 +3 14 15 16 +3 0 20 21 +3 1 21 22 +3 2 22 23 +3 3 23 24 +3 4 24 25 +3 5 25 26 +3 6 26 27 +3 7 27 28 +3 8 28 29 +3 9 29 30 +3 10 30 31 +3 11 31 32 +3 12 32 33 +3 13 33 34 +3 14 34 35 +3 15 35 36 +3 16 36 37 +3 17 37 38 +3 18 38 39 +3 19 39 20 +3 38 21 20 +3 37 22 21 +3 32 27 22 +3 26 23 22 +3 25 24 23 +3 31 28 27 +3 30 29 28 +3 36 33 32 +3 35 34 33 diff --git a/Polyhedron/demo/Polyhedron/include/CGAL/Polyhedron_kernel.h b/Polyhedron/demo/Polyhedron/include/CGAL/Polyhedron_kernel.h index 4715591b84a..1d62d95b0c5 100644 --- a/Polyhedron/demo/Polyhedron/include/CGAL/Polyhedron_kernel.h +++ b/Polyhedron/demo/Polyhedron/include/CGAL/Polyhedron_kernel.h @@ -2,7 +2,6 @@ #include #include - // Taken from http://www.qhull.org/html/qhalf.htm // If you do not know an interior point for the halfspaces, use linear programming @@ -74,7 +73,7 @@ public: int j = 0; InputIterator it; - for(it = begin; it != end; it++) + for(it = begin; it != end; it++, j++) { const Triangle& triangle = *it; const Point& a = triangle[0]; @@ -94,7 +93,7 @@ public: lp.set_a(index_x4, j, -1.0); // -x4 // right hand side (>= -dj) - FT dj = distance_to_origin(plane); + FT dj = distance_to_origin(plane) * CGAL::sign(plane.d()); lp.set_b(j, -dj); } diff --git a/Polyhedron/demo/Polyhedron/main.cpp b/Polyhedron/demo/Polyhedron/main.cpp index 233092b5260..91ed400e3ea 100644 --- a/Polyhedron/demo/Polyhedron/main.cpp +++ b/Polyhedron/demo/Polyhedron/main.cpp @@ -36,6 +36,7 @@ int main(int argc, char **argv) #include "MainWindow_subdivision_methods.cpp" #include "MainWindow_self_intersection.cpp" #include "MainWindow_convex_hull.cpp" +#include "MainWindow_inside_out.cpp" #include "MainWindow_simplify.cpp" #include "MainWindow_kernel.cpp" #include "MainWindow_pca.cpp"