Browse Source

reorganizing

Former-commit-id: 7e326a35e16ff7bb5ab1eeeeb61950eae8b9dc3b
Olga Diamanti 11 years ago
parent
commit
0d1f0ccefb

+ 1 - 1
examples/shadow-mapping/example.cpp

@@ -28,7 +28,7 @@
 #include <igl/boost/components.h>
 #include <igl/boost/bfs_orient.h>
 #include <igl/orient_outward.h>
-#include <igl/embree/orient_outward_ao.h>
+//#include <igl/embree/orient_outward_ao.h>
 #include <igl/unique_simplices.h>
 #include <igl/C_STR.h>
 #include <igl/write.h>

+ 36 - 38
include/igl/mixed_integer_quadrangulate.cpp → include/igl/comiso/mixed_integer_quadrangulate.cpp

@@ -13,8 +13,6 @@
 #include <ConstrainedSolver.hh>
 #include <MISolver.hh>
 #include <GMM_Tools.hh>
-//#include "auxmath.h"
-//#include "sparsesystemdata.h"
 #include "doublearea.h"
 #include "per_face_normals.h"
 
@@ -34,17 +32,17 @@ namespace igl {
   protected:
     unsigned int m_nrows;
     unsigned int m_ncols;
-    vector<unsigned int> m_rowind;
-    vector<unsigned int> m_colind;
-    vector<double>       m_vals;
+    std::vector<unsigned int> m_rowind;
+    std::vector<unsigned int> m_colind;
+    std::vector<double>       m_vals;
     
   public:
     unsigned int   nrows()    { return m_nrows      ; }
     unsigned int   ncols()    { return m_ncols      ; }
     unsigned int   nentries() { return m_vals.size(); }
-    vector<unsigned int>&  rowind()   { return m_rowind     ; }
-    vector<unsigned int>&  colind()   { return m_colind     ; }
-    vector<double>&        vals()     { return m_vals       ; }
+    std::vector<unsigned int>&  rowind()   { return m_rowind     ; }
+    std::vector<unsigned int>&  colind()   { return m_colind     ; }
+    std::vector<double>&        vals()     { return m_vals       ; }
     
     // create an empty matrix with a fixed number of rows
     SparseMatrixData()
@@ -300,8 +298,8 @@ namespace igl {
                       bool direct_round=true,
                       int localIter=0,
                       bool _integer_rounding=true,
-                      vector<int> roundVertices = vector<int>(),
-                      vector<vector<int> > hardFeatures = vector<vector<int> >());
+                      std::vector<int> roundVertices = std::vector<int>(),
+                      std::vector<std::vector<int> > hardFeatures = std::vector<std::vector<int> >());
     
     PoissonSolver(const Eigen::PlainObjectBase<DerivedV> &_V,
                   const Eigen::PlainObjectBase<DerivedF> &_F,
@@ -486,7 +484,7 @@ namespace igl {
     //set the singularity round to integer location
     void AddSingularityRound();
     
-    void AddToRoundVertices(vector<int> ids);
+    void AddToRoundVertices(std::vector<int> ids);
     
     ///START GENERIC SYSTEM FUNCTIONS
     //build the laplacian matrix cyclyng over all rangemaps
@@ -565,19 +563,19 @@ namespace igl {
                    Eigen::PlainObjectBase<DerivedF> &FUV_out);
     
   private:
-    int NumFlips(const MatrixXd& WUV);
+    int NumFlips(const Eigen::MatrixXd& WUV);
     
-    double Distortion(int f, double h, const MatrixXd& WUV);
+    double Distortion(int f, double h, const Eigen::MatrixXd& WUV);
     
-    double LaplaceDistortion(const int f, double h, const MatrixXd& WUV);
+    double LaplaceDistortion(const int f, double h, const Eigen::MatrixXd& WUV);
     
-    bool updateStiffeningJacobianDistorsion(double grad_size, const MatrixXd& WUV);
+    bool updateStiffeningJacobianDistorsion(double grad_size, const Eigen::MatrixXd& WUV);
     
-    inline bool IsFlipped(const Vector2d &uv0,
-                          const Vector2d &uv1,
-                          const Vector2d &uv2);
+    inline bool IsFlipped(const Eigen::Vector2d &uv0,
+                          const Eigen::Vector2d &uv1,
+                          const Eigen::Vector2d &uv2);
     
-    inline bool IsFlipped(const int i, const MatrixXd& WUV);
+    inline bool IsFlipped(const int i, const Eigen::MatrixXd& WUV);
     
   };
 };
@@ -963,8 +961,8 @@ void igl::PoissonSolver<DerivedV, DerivedF>::SolvePoisson(Eigen::VectorXd Stiffn
                                                           bool direct_round,
                                                           int localIter,
                                                           bool _integer_rounding,
-                                                          vector<int> roundVertices,
-                                                          vector<vector<int> > hardFeatures)
+                                                          std::vector<int> roundVertices,
+                                                          std::vector<std::vector<int> > hardFeatures)
 {
   Handle_Stiffness = Stiffness;
   
@@ -1373,7 +1371,7 @@ void igl::PoissonSolver<DerivedV, DerivedF>::FindFixedVertField()
   ///if anything fixed fix the first
   AddFixedVertex(0); // TODO HERE IT ISSSSSS
   UV.row(0) << 0,0;
-  cerr << "No vertices to fix, I am fixing the first vertex to the origin!" << endl;
+  std::cerr << "No vertices to fix, I am fixing the first vertex to the origin!" << std::endl;
 }
 
 ///find hard constraint depending if using or not
@@ -1444,12 +1442,12 @@ void igl::PoissonSolver<DerivedV, DerivedF>::AddSingularityRound()
 }
 
 template <typename DerivedV, typename DerivedF>
-void igl::PoissonSolver<DerivedV, DerivedF>::AddToRoundVertices(vector<int> ids)
+void igl::PoissonSolver<DerivedV, DerivedF>::AddToRoundVertices(std::vector<int> ids)
 {
   for (int i = 0; i < ids.size(); ++i)
   {
     if (ids[i] < 0 || ids[i] >= V.rows())
-      cerr << "WARNING: Ignored round vertex constraint, vertex " << ids[i] << " does not exist in the mesh." << endl;
+      std::cerr << "WARNING: Ignored round vertex constraint, vertex " << ids[i] << " does not exist in the mesh." << std::endl;
     int index0 = GetFirstVertexIndex(ids[i]);
     ids_to_round.push_back( index0*2   );
     ids_to_round.push_back((index0*2)+1);
@@ -1788,7 +1786,7 @@ template <typename DerivedV, typename DerivedF>
 void igl::PoissonSolver<DerivedV, DerivedF>::addSharpEdgeConstraint(int fid, int vid)
 {
   // prepare constraint
-  vector<int> c(Handle_SystemInfo.num_vert_variables*2 + 1);
+  std::vector<int> c(Handle_SystemInfo.num_vert_variables*2 + 1);
   
   for (int i = 0; i < c.size(); ++i)
   {
@@ -1894,7 +1892,7 @@ F(F_)
                                             VInd.HandleS_Index,
                                             VInd.Handle_Singular,
                                             VInd.Handle_SystemInfo);
-  Handle_Stiffness = VectorXd::Constant(F.rows(),1);
+  Handle_Stiffness = Eigen::VectorXd::Constant(F.rows(),1);
   
   
   if (iter > 0) // do stiffening
@@ -1991,7 +1989,7 @@ void igl::MIQ<DerivedV, DerivedF, DerivedU>::extractUV(Eigen::PlainObjectBase<De
 }
 
 template <typename DerivedV, typename DerivedF, typename DerivedU>
-int igl::MIQ<DerivedV, DerivedF, DerivedU>::NumFlips(const MatrixXd& WUV)
+int igl::MIQ<DerivedV, DerivedF, DerivedU>::NumFlips(const Eigen::MatrixXd& WUV)
 {
   int numFl=0;
   for (unsigned int i=0;i<F.rows();i++)
@@ -2003,11 +2001,11 @@ int igl::MIQ<DerivedV, DerivedF, DerivedU>::NumFlips(const MatrixXd& WUV)
 }
 
 template <typename DerivedV, typename DerivedF, typename DerivedU>
-double igl::MIQ<DerivedV, DerivedF, DerivedU>::Distortion(int f, double h, const MatrixXd& WUV)
+double igl::MIQ<DerivedV, DerivedF, DerivedU>::Distortion(int f, double h, const Eigen::MatrixXd& WUV)
 {
   assert(h > 0);
   
-  Vector2d uv0,uv1,uv2;
+  Eigen::Vector2d uv0,uv1,uv2;
   
   uv0 << WUV(f,0), WUV(f,1);
   uv1 << WUV(f,2), WUV(f,3);
@@ -2091,7 +2089,7 @@ double igl::MIQ<DerivedV, DerivedF, DerivedU>::Distortion(int f, double h, const
 //  @return     distortion laplacian for f
 ///////////////////////////////////////////////////////////////////////////
 template <typename DerivedV, typename DerivedF, typename DerivedU>
-double igl::MIQ<DerivedV, DerivedF, DerivedU>::LaplaceDistortion(const int f, double h, const MatrixXd& WUV)
+double igl::MIQ<DerivedV, DerivedF, DerivedU>::LaplaceDistortion(const int f, double h, const Eigen::MatrixXd& WUV)
 {
   double mydist = Distortion(f, h, WUV);
   double lapl=0;
@@ -2104,7 +2102,7 @@ double igl::MIQ<DerivedV, DerivedF, DerivedU>::LaplaceDistortion(const int f, do
 }
 
 template <typename DerivedV, typename DerivedF, typename DerivedU>
-bool igl::MIQ<DerivedV, DerivedF, DerivedU>::updateStiffeningJacobianDistorsion(double grad_size, const MatrixXd& WUV)
+bool igl::MIQ<DerivedV, DerivedF, DerivedU>::updateStiffeningJacobianDistorsion(double grad_size, const Eigen::MatrixXd& WUV)
 {
   bool flipped = NumFlips(WUV)>0;
   
@@ -2140,21 +2138,21 @@ bool igl::MIQ<DerivedV, DerivedF, DerivedU>::updateStiffeningJacobianDistorsion(
 }
 
 template <typename DerivedV, typename DerivedF, typename DerivedU>
-inline bool igl::MIQ<DerivedV, DerivedF, DerivedU>::IsFlipped(const Vector2d &uv0,
-                                                              const Vector2d &uv1,
-                                                              const Vector2d &uv2)
+inline bool igl::MIQ<DerivedV, DerivedF, DerivedU>::IsFlipped(const Eigen::Vector2d &uv0,
+                                                              const Eigen::Vector2d &uv1,
+                                                              const Eigen::Vector2d &uv2)
 {
-  Vector2d e0 = (uv1-uv0);
-  Vector2d e1 = (uv2-uv0);
+  Eigen::Vector2d e0 = (uv1-uv0);
+  Eigen::Vector2d e1 = (uv2-uv0);
   
   double Area = e0(0)*e1(1) - e0(1)*e1(0);
   return (Area<=0);
 }
 
 template <typename DerivedV, typename DerivedF, typename DerivedU>
-inline bool igl::MIQ<DerivedV, DerivedF, DerivedU>::IsFlipped(const int i, const MatrixXd& WUV)
+inline bool igl::MIQ<DerivedV, DerivedF, DerivedU>::IsFlipped(const int i, const Eigen::MatrixXd& WUV)
 {
-  Vector2d uv0,uv1,uv2;
+  Eigen::Vector2d uv0,uv1,uv2;
   uv0 << WUV(i,0), WUV(i,1);
   uv1 << WUV(i,2), WUV(i,3);
   uv2 << WUV(i,4), WUV(i,5);

+ 1 - 1
include/igl/mixed_integer_quadrangulate.h → include/igl/comiso/mixed_integer_quadrangulate.h

@@ -55,7 +55,7 @@ namespace igl
                                               int localIter = 5, bool DoRound = true,
                                               std::vector<int> roundVertices = std::vector<int>(),
                                               std::vector<std::vector<int> > hardFeatures = std::vector<std::vector<int> >());
-}
+};
 #ifdef IGL_HEADER_ONLY
 #include "mixed_integer_quadrangulate.cpp"
 #endif

+ 1 - 1
tutorial/103_DrawMesh/main.cpp

@@ -11,6 +11,6 @@ int main(int argc, char *argv[])
 
   // Plot the mesh
   igl::Viewer viewer;
-  viewer.draw_mesh(V, F);
+  viewer.set_mesh(V, F);
   viewer.launch();
 }

+ 15 - 0
tutorial/505_MIQ/CMakeLists.txt

@@ -0,0 +1,15 @@
+cmake_minimum_required(VERSION 2.6)
+project(XXX_MIQ)
+
+include("../CMakeLists.shared")
+include_directories("/Users/olkido/Documents/igl/MIQ/src/CoMISo/Solver")
+include_directories("/Users/olkido/Documents/igl/MIQ/src/CoMISo/gmm/include")
+include_directories("/Users/olkido/Documents/igl/MIQ/src")
+set(SOURCES
+${PROJECT_SOURCE_DIR}/main.cpp
+)
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DINCLUDE_TEMPLATES")
+
+add_executable(XXX_MIQ ${SOURCES} ${SHARED_SOURCES})
+target_link_libraries(XXX_MIQ ${SHARED_LIBRARIES} "/Users/olkido/Documents/igl/MIQ/src/CoMISo/build/libCoMISo.dylib")

+ 137 - 0
tutorial/505_MIQ/main.cpp

@@ -0,0 +1,137 @@
+#define IGL_HEADER_ONLY
+#include <igl/readOBJ.h>
+#include <igl/viewer/Viewer.h>
+#include <igl/mixed_integer_quadrangulate.h>
+#include <igl/barycenter.h>
+#include <igl/avg_edge_length.h>
+#include <sstream>
+
+
+void line_texture(Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic> &texture_R,
+                  Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic> &texture_G,
+                  Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic> &texture_B)
+  {
+    unsigned size = 128;
+    unsigned size2 = size/2;
+    unsigned lineWidth = 3;
+    texture_R.setConstant(size, size, 255);
+    for (unsigned i=0; i<size; ++i)
+      for (unsigned j=size2-lineWidth; j<=size2+lineWidth; ++j)
+        texture_R(i,j) = 0;
+    for (unsigned i=size2-lineWidth; i<=size2+lineWidth; ++i)
+      for (unsigned j=0; j<size; ++j)
+        texture_R(i,j) = 0;
+
+    texture_G = texture_R;
+    texture_B = texture_R;
+  }
+
+
+bool readPolyVf(const char *fname,
+                Eigen::VectorXi &isConstrained,
+                std::vector<Eigen::MatrixXd> &polyVF)
+{
+  FILE *fp = fopen(fname,"r");
+  if (!fp)
+    return false;
+  int degree, numF;
+  if (fscanf(fp,"%d %d", &degree, &numF) !=2)
+    return false;
+  polyVF.resize(degree, Eigen::MatrixXd::Zero(numF, 3));
+  isConstrained.setZero(numF,1);
+  int vali; float u0,u1,u2;
+  for (int i = 0; i<numF; ++i)
+  {
+    if (fscanf(fp,"%d", &vali)!=1)
+      return false;
+    isConstrained[i] = vali;
+    for (int j = 0; j<degree; ++j)
+    {
+      if (fscanf(fp,"%g %g %g", &u0, &u1, &u2) !=3)
+        return false;
+      polyVF[j](i,0) = u0;
+      polyVF[j](i,1) = u1;
+      polyVF[j](i,2) = u2;
+    }
+  }
+  fclose(fp);
+  return true;
+}
+
+void writePolyVf(const char *fname,
+                 const Eigen::VectorXi &isConstrained,
+                 const std::vector<Eigen::MatrixXd> &polyVF)
+{
+  int numF = polyVF[0].rows();
+  int degree = polyVF.size();
+  FILE *fp = fopen(fname,"w");
+  fprintf(fp,"%d %d\n", degree,numF);
+  for (int i = 0; i<numF; ++i)
+  {
+    fprintf(fp,"%d ", isConstrained[i]);
+    for (int j = 0; j<degree; ++j)
+      fprintf(fp,"%.15g %.15g %.15g ", polyVF[j](i,0), polyVF[j](i,1), polyVF[j](i,2));
+    fprintf(fp, "\n");
+  }
+  fclose(fp);
+  
+}
+
+
+int main(int argc, char *argv[])
+{
+  Eigen::MatrixXd V;
+  Eigen::MatrixXi F;
+  // Load a mesh in OFF format
+  igl::readOBJ("../shared/lilium.obj", V, F);
+
+
+  // Load a frame field
+  Eigen::VectorXi isConstrained;
+  std::vector<Eigen::MatrixXd> polyVF;
+  readPolyVf("../shared/lilium.crossfield", isConstrained, polyVF);
+  
+  Eigen::MatrixXd UV;
+  Eigen::MatrixXi FUV;
+
+  double gradientSize = 50;
+  double quadIter = 0;
+  double stiffness = 5.0;
+  bool directRound = 1;
+  igl::mixed_integer_quadrangulate(V,
+                                 F,
+                                 polyVF[0],
+                                 polyVF[1],
+                                 UV,
+                                 FUV,
+                                 gradientSize,
+                                 stiffness,
+                                 directRound,
+                                 quadIter);
+
+
+  // Face barycenters
+  Eigen::MatrixXd MF;
+  igl::barycenter(V, F, MF);
+
+  double scale =  .5*igl::avg_edge_length(V, F);
+
+  // Plot the mesh
+  igl::Viewer viewer;
+  viewer.set_mesh(V, F);
+
+  // Plot the field
+  viewer.add_edges (MF, MF+scale*polyVF[0],Eigen::RowVector3d(1,0,1));
+  viewer.add_edges (MF, MF+scale*polyVF[1],Eigen::RowVector3d(1,0,1));
+  viewer.set_uv(UV,FUV);
+  viewer.options.show_texture = true;
+
+  Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic> texture_R, texture_G, texture_B;
+  line_texture(texture_R, texture_G, texture_B);
+  viewer.set_texture(texture_R, texture_B, texture_G);
+  // Increase the thickness of the lines
+  viewer.options.line_width = 2.0f;
+
+  // Launch the viewer
+  viewer.launch();
+}

+ 1 - 0
tutorial/shared/lilium.crossfield.REMOVED.git-id

@@ -0,0 +1 @@
+7a76795232c55cd71eefe7fc9a3368f9b62bf51c

+ 1 - 0
tutorial/shared/lilium.obj.REMOVED.git-id

@@ -0,0 +1 @@
+1b8b8b556105b6103bd2d77736451f968ba5a823