Эх сурвалжийг харах

Still some weird compilation issues.

Former-commit-id: 42e534e3ae90a48618dd76e75c5bdcbfe9a7ab2f
Amir Vaxman 7 жил өмнө
parent
commit
9a86061b8e

+ 4 - 2
include/igl/shapeup.cpp

@@ -31,7 +31,7 @@ namespace igl
                                            const Eigen::PlainObjectBase<DerivedS>& E,
                                            const Eigen::PlainObjectBase<Derivedb>& b,
                                            const Eigen::PlainObjectBase<Derivedw>& w,
-                                           const std::function<bool(const Eigen::PlainObjectBase<DerivedP>&, const Eigen::PlainObjectBase<DerivedSC>&, const Eigen::PlainObjectBase<DerivedS>&,  Eigen::PlainObjectBase<Derivedb>&)>& local_projection,
+                                           const std::function<bool(const Eigen::PlainObjectBase<DerivedP>&, const Eigen::PlainObjectBase<DerivedSC>&, const Eigen::PlainObjectBase<DerivedS>&,  Eigen::PlainObjectBase<DerivedP>&)>& local_projection,
                                            ShapeupData & sudata)
     {
         using namespace std;
@@ -149,7 +149,9 @@ namespace igl
     }
 }
 
+
 /*#ifdef IGL_STATIC_LIBRARY
+template bool igl::shapeup_precomputation<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, igl::ARAPData&);
 template bool igl::shapeup_solve<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, igl::ARAPData&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
-template bool igl::arap_precomputation<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, igl::ARAPData&);
+
 #endif*/

+ 1 - 1
include/igl/shapeup.h

@@ -84,7 +84,7 @@ namespace igl
                                            const Eigen::PlainObjectBase<DerivedS>& E,
                                            const Eigen::PlainObjectBase<Derivedb>& b,
                                            const Eigen::PlainObjectBase<Derivedw>& w,
-                                           const std::function<bool(const Eigen::PlainObjectBase<DerivedP>&, const Eigen::PlainObjectBase<DerivedSC>&, const Eigen::PlainObjectBase<DerivedS>&,  Eigen::PlainObjectBase<Derivedb>&)>& local_projection,
+                                           const std::function<bool(const Eigen::PlainObjectBase<DerivedP>&, const Eigen::PlainObjectBase<DerivedSC>&, const Eigen::PlainObjectBase<DerivedS>&,  Eigen::PlainObjectBase<DerivedP>&)>& local_projection,
                                            ShapeupData & sudata);
     
     //This function solve the shapeup project optimization. shapeup_precompute must be called before with the same sudata, or results are unpredictable

+ 12 - 7
tutorial/801_ShapeUp/main.cpp

@@ -39,7 +39,8 @@ bool key_down(igl::viewer::Viewer& viewer, unsigned char key, int modifier)
 
   // Plot the original quad mesh
   if (key == '1')
-  {
+  {
+      cout<<"before setting mesh 1"<<endl;
     // Draw the triangulated quad mesh
     viewer.data.set_mesh(VQC, FQCtri);
 
@@ -62,7 +63,8 @@ bool key_down(igl::viewer::Viewer& viewer, unsigned char key, int modifier)
   // Plot the planarized quad mesh
   if (key == '2')
   {
-    // Draw the triangulated quad mesh
+    // Draw the triangulated quad mesh
+      cout<<"before setting mesh 2"<<endl;
     viewer.data.set_mesh(VQCregular, FQCtri);
 
     // Assign a color to each quad that corresponds to its planarity
@@ -90,7 +92,7 @@ int main(int argc, char *argv[])
   using namespace std;
 
   // Load a quad mesh
-  igl::readOFF(TUTORIAL_SHARED_PATH "/halftunnel.off", VQC, FQC);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/halftunnel.off", VQC, FQC);
 
   // Convert it in a triangle mesh
   FQCtri.resize(2*FQC.rows(), 3);
@@ -113,9 +115,12 @@ int main(int argc, char *argv[])
   VectorXd bc;
     
   VectorXi array_of_fours=VectorXi::Constant(FQC.rows(),4);
-   
-  //shapeup_precomputation(VQC, array_of_fours,FQC,E,b,w, igl::shapeup_identity_projection,su_data);
-  //shapeup_solve(bc,VQC,su_data,VQCregular);
+    cout<<"before pre-computation"<<endl;
+    shapeup_precomputation(VQC, array_of_fours,FQC,E,b,w, std::function<bool(const MatrixXd&, const VectorXi&, const MatrixXi&, MatrixXd&)>(igl::shapeup_identity_projection),su_data);
+    cout<<"after pre-computation"<<endl;
+  shapeup_solve(bc,VQC,su_data,VQCregular);
+    cout<<"after computation"<<endl;
+    
 
   // Convert the planarized mesh to triangles
   igl::slice( VQCregular, FQC.col(0).eval(), 1, PQC0regular);
@@ -125,7 +130,7 @@ int main(int argc, char *argv[])
 
   // Launch the viewer
   igl::viewer::Viewer viewer;
-  key_down(viewer,'2',0);
+  key_down(viewer,'1',0);
   viewer.core.invert_normals = true;
   viewer.core.show_lines = false;
   viewer.callback_key_down = &key_down;

+ 4 - 5
tutorial/802_ShapeUp/CMakeLists.txt → tutorial/802_LevenbergMarquadt/CMakeLists.txt

@@ -1,5 +1,5 @@
-cmake_minimum_required(VERSION 2.6) 
-project(shape-up)
+cmake_minimum_required(VERSION 2.8.12)
+project(levenberg-marquadt)
 
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
 
@@ -24,10 +24,9 @@ else()
   # Libigl requires a modern C++ compiler that supports c++11
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 
   set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "." )
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
 endif()
 
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
-
 # libigl options: choose between header only and compiled static library
 # Header-only is preferred for small projects. For larger projects the static build
 # considerably reduces the compilation times
@@ -39,7 +38,7 @@ option(LIBIGL_WITH_NANOGUI     "Use Nanogui menu"   OFF)
 # libigl options: choose your dependencies (by default everything is OFF except opengl) 
 option(LIBIGL_WITH_VIEWER      "Use OpenGL viewer"  ON)
 option(LIBIGL_WITH_OPENGL      "Use OpenGL"         ON)
-option(LIBIGL_WITH_GLFW        "Use GLFW"           ON)
+option(LIBIGL_WITH_OPENGL_GLFW "Use GLFW"           ON)
 option(LIBIGL_WITH_BBW         "Use BBW"            OFF)
 option(LIBIGL_WITH_EMBREE      "Use Embree"         OFF)
 option(LIBIGL_WITH_PNG         "Use PNG"            OFF)

+ 0 - 0
tutorial/802_ShapeUp/cmake/FindLIBHEDRA.cmake → tutorial/802_LevenbergMarquadt/cmake/FindLIBHEDRA.cmake


+ 0 - 0
tutorial/802_ShapeUp/cmake/FindLIBIGL.cmake → tutorial/802_LevenbergMarquadt/cmake/FindLIBIGL.cmake


+ 21 - 48
tutorial/802_ShapeUp/main.cpp → tutorial/802_LevenbergMarquadt/main.cpp

@@ -1,22 +1,23 @@
 #include <igl/unproject_onto_mesh.h>
 #include <igl/viewer/Viewer.h>
+#include <igl/readDMAT.h>
+#include <igl/jet.h>
 #include <hedra/polygonal_read_OFF.h>
 #include <hedra/triangulate_mesh.h>
 #include <hedra/polygonal_edge_topology.h>
 #include <hedra/point_spheres.h>
-#include <hedra/shapeup.h>
-#include <hedra/planarity.h>
-#include <hedra/concyclity.h>
-#include <hedra/regularity.h>
 #include <hedra/scalar2RGB.h>
-
-enum ViewingMode{PLANARITY, CONCYCLITY, REGULARITY} ViewingMode;
+#include <hedra/LMSolver.h>
+#include <hedra/EigenSolverWrapper.h>
+#include <hedra/DiscreteShellsTraits.h>
+#include <Eigen/SparseCholesky>
+#include <hedra/check_traits.h>
 
 
 std::vector<int> Handles;
 std::vector<Eigen::RowVector3d> HandlePoses;
 int CurrentHandle;
-Eigen::MatrixXd VOrig, V, C;
+Eigen::MatrixXd VOrig, V;
 Eigen::MatrixXi F, T;
 Eigen::VectorXi D, TF;
 Eigen::MatrixXi EV, EF, FE, EFi;
@@ -26,12 +27,10 @@ Eigen::Vector3d spans;
 bool Editing=false;
 bool ChoosingHandleMode=false;
 double CurrWinZ;
-
-Eigen::VectorXd planarity, concyclity, regularity;
-
-hedra::ShapeupData sudata;
-Eigen::MatrixXi SFaceRegular;
-Eigen::VectorXi SDFaceRegular;
+typedef hedra::optimization::EigenSolverWrapper<Eigen::SimplicialLLT<Eigen::SparseMatrix<double> > > LinearSolver;
+hedra::optimization::DiscreteShellsTraits dst;
+LinearSolver esw;
+hedra::optimization::LMSolver<LinearSolver, hedra::optimization::DiscreteShellsTraits> lmSolver;
 
 
 
@@ -40,10 +39,6 @@ bool UpdateCurrentView(igl::viewer::Viewer & viewer)
     using namespace Eigen;
     using namespace std;
     
-    hedra::planarity(V,D,F,planarity);
-    hedra::concyclity(V,D,F,concyclity);
-    hedra::regularity(V,D,F,regularity);
-    
     MatrixXd sphereV;
     MatrixXi sphereT;
     MatrixXd sphereTC;
@@ -51,12 +46,7 @@ bool UpdateCurrentView(igl::viewer::Viewer & viewer)
     for (int i=0;i<Handles.size();i++)
         bc.row(i)=HandlePoses[i].transpose();
     
-    switch(ViewingMode){
-        case PLANARITY: hedra::scalar2RGB(planarity, 0.0,1.0, C); break;
-        case CONCYCLITY:  hedra::scalar2RGB(concyclity, 0.0,5.0, C); break;
-        case REGULARITY:  hedra::scalar2RGB(regularity, 0.0,1.0, C); break;
-    }
- 
+    
     double sphereRadius=spans.sum()/200.0;
     MatrixXd sphereGreens(Handles.size(),3);
     sphereGreens.col(0).setZero();
@@ -67,10 +57,6 @@ bool UpdateCurrentView(igl::viewer::Viewer & viewer)
     
     Eigen::MatrixXd bigV(V.rows()+sphereV.rows(),3);
     Eigen::MatrixXi bigT(T.rows()+sphereT.rows(),3);
-    Eigen::MatrixXd bigTC(C.rows()+sphereTC.rows(),3);
-    for (int i=0;i<T.rows();i++)
-        bigTC.row(i)=C.row(TF(i));
-    bigTC.block(T.rows(),0,sphereTC.rows(),3)=sphereTC;
     if (sphereV.rows()!=0){
         bigV<<V, sphereV;
         bigT<<T, sphereT+Eigen::MatrixXi::Constant(sphereT.rows(), sphereT.cols(), V.rows());
@@ -87,7 +73,6 @@ bool UpdateCurrentView(igl::viewer::Viewer & viewer)
     
     viewer.data.clear();
     viewer.data.set_mesh(bigV,bigT);
-    viewer.data.set_colors(bigTC);
     viewer.data.compute_normals();
     viewer.data.set_edges(V,EV,OrigEdgeColors);
     return true;
@@ -112,7 +97,9 @@ bool mouse_move(igl::viewer::Viewer& viewer, int mouse_x, int mouse_y)
     for (int i=0;i<Handles.size();i++)
         bc.row(i)=HandlePoses[i].transpose();
     
-   
+    dst.qh=bc;
+    lmSolver.solve(true);
+    V=dst.fullSolution;
     UpdateCurrentView(viewer);
     return true;
 
@@ -172,8 +159,8 @@ bool mouse_down(igl::viewer::Viewer& viewer, int button, int modifier)
         for (int i=0;i<Handles.size();i++)
             b(i)=Handles[i];
         
-        //hedra::shapeup_precompute(V,D, F,SDFaceRegular,SFaceRegular, b,1.0,100.0, sudata);
-
+        dst.init(VOrig, T, b, EV, EF, EFi,innerEdges);
+        lmSolver.init(&esw, &dst, 250, 10e-6);
         UpdateCurrentView(viewer);
     }
     return true;
@@ -186,12 +173,7 @@ bool key_up(igl::viewer::Viewer& viewer, unsigned char key, int modifiers)
             
         case '1': ChoosingHandleMode=false;
             break;
-        case '2': ViewingMode=PLANARITY; break;
-        case '3': ViewingMode=CONCYCLITY; break;
-        case '4': ViewingMode=REGULARITY; break;
-
     }
-    UpdateCurrentView(viewer);
     return false;
 }
 
@@ -213,23 +195,14 @@ int main(int argc, char *argv[])
     using namespace std;
     using namespace Eigen;
     
-    std::cout<<R"(
-    1 choose handles (with right mouse button)
-    2 Show planarity between [0,1]
-    3 Show concyclity between [0,5]
-    4 Show regularity between [0,1]
-    )";
-    
-    hedra::polygonal_read_OFF(DATA_PATH "/intersection.off", V, D, F);
-    hedra::polygonal_edge_topology(D, F, EV, FE, EF,EFi,FEs,innerEdges);
+    hedra::polygonal_read_OFF(DATA_PATH "/moomoo.off", V, D, F);
     hedra::triangulate_mesh(D, F, T, TF);
-
-    
+    VectorXi DT=VectorXi::Constant(T.rows(),3);
+    hedra::polygonal_edge_topology(DT, T, EV, FE, EF,EFi,FEs,innerEdges);
     
     spans=V.colwise().maxCoeff()-V.colwise().minCoeff();
     
     VOrig=V;
-    ViewingMode=REGULARITY;
     igl::viewer::Viewer viewer;
     viewer.callback_mouse_down = &mouse_down;
     viewer.callback_mouse_move = &mouse_move;

+ 1 - 0
tutorial/shared/intersection_quads.off.REMOVED.git-id

@@ -0,0 +1 @@
+5413a91923d24198f4b8212185bd59a70c02a5db