Forráskód Böngészése

removed unnecessary file shapeup_local_projections.h/.cpp

Former-commit-id: 8bf80967c4dd709b5c2c3f54c6fbad9a4092ac20
Daniele Panozzo 7 éve
szülő
commit
c7b35bca80

+ 55 - 0
include/igl/shapeup.cpp

@@ -16,7 +16,62 @@
 
 namespace igl
 {
+    
+  //This projection does nothing but render points into projP. Mostly used for "echoing" the global step
+  IGL_INLINE bool shapeup_identity_projection(const Eigen::PlainObjectBase<Eigen::MatrixXd>& P, const Eigen::PlainObjectBase<Eigen::VectorXi>& SC, const Eigen::PlainObjectBase<Eigen::MatrixXi>& S,  Eigen::PlainObjectBase<Eigen::MatrixXd>& projP){
+    projP.conservativeResize(SC.rows(), 3*SC.maxCoeff());
+    for (int i=0;i<S.rows();i++){
+      Eigen::RowVector3d avgCurrP=Eigen::RowVector3d::Zero();
+      for (int j=0;j<SC(i);j++)
+        avgCurrP+=P.row(S(i,j))/(double)(SC(i));
+  
+      for (int j=0;j<SC(i);j++)
+        projP.block(i,3*j,1,3)=P.row(S(i,j))-avgCurrP;
+    }
+    return true;
+  }
+  
+  
+  //the projection assumes that the sets are vertices of polygons in order
+  IGL_INLINE bool shapeup_regular_face_projection(const Eigen::PlainObjectBase<Eigen::MatrixXd>& P, const Eigen::PlainObjectBase<Eigen::VectorXi>& SC, const Eigen::PlainObjectBase<Eigen::MatrixXi>& S,  Eigen::PlainObjectBase<Eigen::MatrixXd>& projP){
+    projP.conservativeResize(SC.rows(), 3*SC.maxCoeff());
+    for (int currRow=0;currRow<SC.rows();currRow++){
+    //computing average
+      int N=SC(currRow);
+      const Eigen::RowVectorXi SRow=S.row(currRow);
+      Eigen::RowVector3d avgCurrP=Eigen::RowVector3d::Zero();
+      Eigen::MatrixXd targetPolygon(N, 3);
+      Eigen::MatrixXd sourcePolygon(N, 3);
+      for (int j=0;j<N;j++)
+        avgCurrP+=P.row(SRow(j))/(double)(N);
+  
+      for (int j=0;j<N;j++)
+        targetPolygon.row(j)=P.row(SRow(j))-avgCurrP;
   
+      //creating perfectly regular source polygon
+      for (int j=0;j<N;j++)
+        sourcePolygon.row(j)<<cos(2*M_PI*(double)j/(double(N))), sin(2*M_PI*(double)j/(double(N))),0.0;
+  
+      //finding closest similarity transformation between source and target
+      Eigen::MatrixXd corrMat=sourcePolygon.transpose()*targetPolygon;
+      Eigen::JacobiSVD<Eigen::Matrix3d> svd(corrMat, Eigen::ComputeFullU | Eigen::ComputeFullV);
+      Eigen::MatrixXd R=svd.matrixU()*svd.matrixV().transpose();
+      //getting scale by edge length change average. TODO: by singular values
+      Eigen::VectorXd sourceEdgeLengths(N);
+      Eigen::VectorXd targetEdgeLengths(N);
+      for (int j=0;j<N;j++){
+        sourceEdgeLengths(j)=(sourcePolygon.row((j+1)%N)-sourcePolygon.row(j)).norm();
+        targetEdgeLengths(j)=(targetPolygon.row((j+1)%N)-targetPolygon.row(j)).norm();
+      }
+      double scale=(targetEdgeLengths.cwiseQuotient(sourceEdgeLengths)).mean();
+  
+      for (int j=0;j<N;j++)
+        projP.block(currRow,3*j,1,3)=sourcePolygon.row(j)*R*scale;
+    }
+  
+    return true;
+  }
+
   template <
   typename DerivedP,
   typename DerivedSC,

+ 16 - 2
include/igl/shapeup.h

@@ -8,7 +8,6 @@
 #ifndef IGL_SHAPEUP_H
 #define IGL_SHAPEUP_H
 
-#include <igl/shapeup_local_projections.h>
 #include <igl/min_quad_with_fixed.h>
 #include <igl/igl_inline.h>
 #include <igl/setdiff.h>
@@ -48,7 +47,22 @@ namespace igl
     smoothCoeff(0.0){}
   };
       
-    
+  //Every function here defines a local projection for ShapeUp, and must have the following structure to qualify:
+  //Input:
+  //	P		#P by 3				the set of points, either the initial solution, or from previous iteration.
+  //  SC		#Set by 1           cardinalities of sets in S
+  //  S		#Sets by max(SC)    independent sets where the local projection applies. Values beyond column SC(i)-1 in row S(i,:) are "don't care"
+  //Output:
+  //	projP	#S by 3*max(SC) in format xyzxyzxyz,  where the projected points correspond to each set in S in the same order.
+  typedef std::function<bool(const Eigen::PlainObjectBase<Eigen::MatrixXd>&, const Eigen::PlainObjectBase<Eigen::VectorXi>&, const Eigen::PlainObjectBase<Eigen::MatrixXi>&, Eigen::PlainObjectBase<Eigen::MatrixXd>&)> shapeup_projection_function;
+
+  
+  //This projection does nothing but render points into projP. Mostly used for "echoing" the global step
+  IGL_INLINE bool shapeup_identity_projection(const Eigen::PlainObjectBase<Eigen::MatrixXd>& P, const Eigen::PlainObjectBase<Eigen::VectorXi>& SC, const Eigen::PlainObjectBase<Eigen::MatrixXi>& S,  Eigen::PlainObjectBase<Eigen::MatrixXd>& projP);
+  
+  //the projection assumes that the sets are vertices of polygons in cyclic order
+  IGL_INLINE bool shapeup_regular_face_projection(const Eigen::PlainObjectBase<Eigen::MatrixXd>& P, const Eigen::PlainObjectBase<Eigen::VectorXi>& SC, const Eigen::PlainObjectBase<Eigen::MatrixXi>& S,  Eigen::PlainObjectBase<Eigen::MatrixXd>& projP);
+
     
   //This function precomputation the necessary matrices for the ShapeUp process, and prefactorizes them.
     

+ 0 - 78
include/igl/shapeup_local_projections.cpp

@@ -1,78 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-//
-// Copyright (C) 2017 Amir Vaxman <avaxman@gmail.com>
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can
-// obtain one at http://mozilla.org/MPL/2.0/.
-
-#include <igl/shapeup_local_projections.h>
-#include <igl/igl_inline.h>
-#include <igl/setdiff.h>
-#include <igl/cat.h>
-#include <Eigen/Core>
-#include <vector>
-
-
-//This file implements several basic local projection functions for the shapeup algorithm in shapeup.h
-
-namespace igl
-{
-  
-  //This projection does nothing but render points into projP. Mostly used for "echoing" the global step
-  IGL_INLINE bool shapeup_identity_projection(const Eigen::PlainObjectBase<Eigen::MatrixXd>& P, const Eigen::PlainObjectBase<Eigen::VectorXi>& SC, const Eigen::PlainObjectBase<Eigen::MatrixXi>& S,  Eigen::PlainObjectBase<Eigen::MatrixXd>& projP){
-    projP.conservativeResize(SC.rows(), 3*SC.maxCoeff());
-    for (int i=0;i<S.rows();i++){
-      Eigen::RowVector3d avgCurrP=Eigen::RowVector3d::Zero();
-      for (int j=0;j<SC(i);j++)
-        avgCurrP+=P.row(S(i,j))/(double)(SC(i));
-  
-      for (int j=0;j<SC(i);j++)
-        projP.block(i,3*j,1,3)=P.row(S(i,j))-avgCurrP;
-    }
-    return true;
-  }
-  
-  
-  //the projection assumes that the sets are vertices of polygons in order
-  IGL_INLINE bool shapeup_regular_face_projection(const Eigen::PlainObjectBase<Eigen::MatrixXd>& P, const Eigen::PlainObjectBase<Eigen::VectorXi>& SC, const Eigen::PlainObjectBase<Eigen::MatrixXi>& S,  Eigen::PlainObjectBase<Eigen::MatrixXd>& projP){
-    projP.conservativeResize(SC.rows(), 3*SC.maxCoeff());
-    for (int currRow=0;currRow<SC.rows();currRow++){
-    //computing average
-      int N=SC(currRow);
-      const Eigen::RowVectorXi SRow=S.row(currRow);
-      Eigen::RowVector3d avgCurrP=Eigen::RowVector3d::Zero();
-      Eigen::MatrixXd targetPolygon(N, 3);
-      Eigen::MatrixXd sourcePolygon(N, 3);
-      for (int j=0;j<N;j++)
-        avgCurrP+=P.row(SRow(j))/(double)(N);
-  
-      for (int j=0;j<N;j++)
-        targetPolygon.row(j)=P.row(SRow(j))-avgCurrP;
-  
-      //creating perfectly regular source polygon
-      for (int j=0;j<N;j++)
-        sourcePolygon.row(j)<<cos(2*M_PI*(double)j/(double(N))), sin(2*M_PI*(double)j/(double(N))),0.0;
-  
-      //finding closest similarity transformation between source and target
-      Eigen::MatrixXd corrMat=sourcePolygon.transpose()*targetPolygon;
-      Eigen::JacobiSVD<Eigen::Matrix3d> svd(corrMat, Eigen::ComputeFullU | Eigen::ComputeFullV);
-      Eigen::MatrixXd R=svd.matrixU()*svd.matrixV().transpose();
-      //getting scale by edge length change average. TODO: by singular values
-      Eigen::VectorXd sourceEdgeLengths(N);
-      Eigen::VectorXd targetEdgeLengths(N);
-      for (int j=0;j<N;j++){
-        sourceEdgeLengths(j)=(sourcePolygon.row((j+1)%N)-sourcePolygon.row(j)).norm();
-        targetEdgeLengths(j)=(targetPolygon.row((j+1)%N)-targetPolygon.row(j)).norm();
-      }
-      double scale=(targetEdgeLengths.cwiseQuotient(sourceEdgeLengths)).mean();
-  
-      for (int j=0;j<N;j++)
-        projP.block(currRow,3*j,1,3)=sourcePolygon.row(j)*R*scale;
-    }
-  
-    return true;
-  }
-
-}
-

+ 0 - 46
include/igl/shapeup_local_projections.h

@@ -1,46 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-//
-// Copyright (C) 2017 Amir Vaxman <avaxman@gmail.com>
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_SHAPEUP_LOCAL_PROJECTIONS_H
-#define IGL_SHAPEUP_LOCAL_PROJECTIONS_H
-
-#include <igl/igl_inline.h>
-#include <igl/setdiff.h>
-#include <igl/cat.h>
-#include <Eigen/Core>
-#include <vector>
-
-
-
-
-namespace igl
-{
-
-	//Every function here defines a local projection for ShapeUp, and must have the following structure to qualify:
-	//Input:
-	//	P		#P by 3				the set of points, either the initial solution, or from previous iteration.
-	//  SC		#Set by 1           cardinalities of sets in S
-	//  S		#Sets by max(SC)    independent sets where the local projection applies. Values beyond column SC(i)-1 in row S(i,:) are "don't care"
-	//Output:
-	//	projP	#S by 3*max(SC) in format xyzxyzxyz,  where the projected points correspond to each set in S in the same order.
-	typedef std::function<bool(const Eigen::PlainObjectBase<Eigen::MatrixXd>&, const Eigen::PlainObjectBase<Eigen::VectorXi>&, const Eigen::PlainObjectBase<Eigen::MatrixXi>&, Eigen::PlainObjectBase<Eigen::MatrixXd>&)> shapeup_projection_function;
-
-  
-  //This projection does nothing but render points into projP. Mostly used for "echoing" the global step
-  IGL_INLINE bool shapeup_identity_projection(const Eigen::PlainObjectBase<Eigen::MatrixXd>& P, const Eigen::PlainObjectBase<Eigen::VectorXi>& SC, const Eigen::PlainObjectBase<Eigen::MatrixXi>& S,  Eigen::PlainObjectBase<Eigen::MatrixXd>& projP);
-  
-  //the projection assumes that the sets are vertices of polygons in cyclic order
-  IGL_INLINE bool shapeup_regular_face_projection(const Eigen::PlainObjectBase<Eigen::MatrixXd>& P, const Eigen::PlainObjectBase<Eigen::VectorXi>& SC, const Eigen::PlainObjectBase<Eigen::MatrixXi>& S,  Eigen::PlainObjectBase<Eigen::MatrixXd>& projP);
-  
- 
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#include "shapeup_local_projections.cpp"
-#endif
-
-#endif

+ 0 - 1
tutorial/713_ShapeUp/main.cpp

@@ -2,7 +2,6 @@
 #include <igl/barycenter.h>
 #include <igl/jet.h>
 #include <igl/shapeup.h>
-#include <igl/shapeup_local_projections.h>
 #include <igl/quad_planarity.h>
 #include <igl/readDMAT.h>
 #include <igl/readOFF.h>