Procházet zdrojové kódy

resize(X.rows(),X.cols()) --> resizeLike(X)

Former-commit-id: 173cf01aa4d8e828de5a52f7cab21e76409066a3
Alec Jacobson před 8 roky
rodič
revize
85a56e391b

+ 1 - 1
include/igl/AABB.cpp

@@ -460,7 +460,7 @@ IGL_INLINE void igl::AABB<DerivedV,DIM>::squared_distance(
   assert(P.cols() == V.cols() && "cols in P should match dim of cols in V");
   sqrD.resize(P.rows(),1);
   I.resize(P.rows(),1);
-  C.resize(P.rows(),P.cols());
+  C.resizeLike(P);
   // O( #P * log #Ele ), where log #Ele is really the depth of this AABB
   // hierarchy
   for(int p = 0;p<P.rows();p++)

+ 1 - 1
include/igl/collapse_small_triangles.cpp

@@ -91,7 +91,7 @@ void igl::collapse_small_triangles(
     }
   }
 
-  FF.resize(rF.rows(),rF.cols());
+  FF.resizeLike(rF);
   int num_face_collapses=0;
   // Only keep uncollapsed faces
   {

+ 1 - 1
include/igl/copyleft/cgal/assign.cpp

@@ -13,7 +13,7 @@ IGL_INLINE void igl::copyleft::cgal::assign(
   const Eigen::PlainObjectBase<DerivedC> & C,
   Eigen::PlainObjectBase<DerivedD> & D)
 {
-  D.resize(C.rows(),C.cols());
+  D.resizeLike(C);
   for(int i = 0;i<C.rows();i++)
   {
     for(int j = 0;j<C.cols();j++)

+ 1 - 1
include/igl/copyleft/cgal/snap_rounding.cpp

@@ -195,7 +195,7 @@ IGL_INLINE void igl::copyleft::cgal::snap_rounding(
   }
 
 
-  VI.resize(VE.rows(),VE.cols());
+  VI.resizeLike(VE);
   for(int i = 0;i<VE.rows();i++)
   {
     for(int j = 0;j<VE.cols();j++)

+ 1 - 1
include/igl/cumsum.cpp

@@ -17,7 +17,7 @@ IGL_INLINE void igl::cumsum(
 {
   using namespace Eigen;
   using namespace std;
-  Y.resize(X.rows(),X.cols());
+  Y.resizeLike(X);
   // get number of columns (or rows)
   int num_outer = (dim == 1 ? X.cols() : X.rows() );
   // get number of rows (or columns)

+ 1 - 1
include/igl/dqs.cpp

@@ -26,7 +26,7 @@ IGL_INLINE void igl::dqs(
   assert(W.cols() == (int)vQ.size());
   assert(W.cols() == (int)vT.size());
   // resize output
-  U.resize(V.rows(),V.cols());
+  U.resizeLike(V);
 
   // Convert quats + trans into dual parts
   vector<Q> vD(vQ.size());

+ 2 - 2
include/igl/faces_first.cpp

@@ -66,7 +66,7 @@ IGL_INLINE void igl::faces_first(
   {
     IM(NU(i)) = i+U.size();
   }
-  RF.resize(F.rows(),F.cols());
+  RF.resizeLike(F);
   // Reindex faces
   for(int i = 0; i<F.rows(); i++)
   {
@@ -75,7 +75,7 @@ IGL_INLINE void igl::faces_first(
       RF(i,j) = IM(F(i,j));
     }
   }
-  RV.resize(V.rows(),V.cols());
+  RV.resizeLike(V);
   // Reorder vertices
   for(int i = 0;i<V.rows();i++)
   {

+ 1 - 1
include/igl/hsv_to_rgb.cpp

@@ -48,7 +48,7 @@ void igl::hsv_to_rgb(
   Eigen::PlainObjectBase<DerivedR> & R)
 {
   assert(H.cols() == 3);
-  R.resize(H.rows(),H.cols());
+  R.resizeLike(H);
   for(typename DerivedH::Index r = 0;r<H.rows();r++)
   {
     typename DerivedH::Scalar hsv[3];

+ 1 - 1
include/igl/internal_angles.cpp

@@ -34,7 +34,7 @@ IGL_INLINE void igl::internal_angles(
   }else
   {
     assert(V.cols() == 3 && "If F contains non-triangle facets, V must be 3D");
-    K.resize(F.rows(),F.cols());
+    K.resizeLike(F);
     auto corner = [](
       const typename DerivedV::ConstRowXpr & x, 
       const typename DerivedV::ConstRowXpr & y, 

+ 2 - 2
include/igl/ismember.cpp

@@ -24,9 +24,9 @@ IGL_INLINE void igl::ismember(
 {
   using namespace Eigen;
   using namespace std;
-  IA.resize(A.rows(),A.cols());
+  IA.resizeLike(A);
   IA.setConstant(false);
-  LOCB.resize(A.rows(),A.cols());
+  LOCB.resizeLike(A);
   LOCB.setConstant(-1);
   // boring base cases
   if(A.size() == 0)

+ 1 - 1
include/igl/mod.cpp

@@ -13,7 +13,7 @@ IGL_INLINE void igl::mod(
   const int base,
   Eigen::PlainObjectBase<DerivedB> & B)
 {
-  B.resize(A.rows(),A.cols());
+  B.resizeLike(A);
   for(int i = 0;i<A.rows();i++)
   {
     for(int j = 0;j<A.cols();j++)

+ 1 - 1
include/igl/normalize_row_lengths.cpp

@@ -13,7 +13,7 @@ IGL_INLINE void igl::normalize_row_lengths(
   Eigen::PlainObjectBase<DerivedV> & B)
 {
   // Resize output
-  B.resize(A.rows(),A.cols());
+  B.resizeLike(A);
 
   // loop over rows
   for(int i = 0; i < A.rows();i++)

+ 1 - 1
include/igl/remove_duplicate_vertices.cpp

@@ -55,7 +55,7 @@ IGL_INLINE void igl::remove_duplicate_vertices(
   using namespace Eigen;
   using namespace std;
   remove_duplicate_vertices(V,epsilon,SV,SVI,SVJ);
-  SF.resize(F.rows(),F.cols());
+  SF.resizeLike(F);
   for(int f = 0;f<F.rows();f++)
   {
     for(int c = 0;c<F.cols();c++)

+ 1 - 1
include/igl/remove_duplicates.cpp

@@ -62,7 +62,7 @@ IGL_INLINE void igl::remove_duplicates(
 
   count = 0;
   std::vector<typename DerivedF::Scalar> face;
-  NF.resize(F.rows(),F.cols());
+  NF.resizeLike(F);
   for (int i =0; i <F.rows(); ++i)
   {
     face.clear();

+ 1 - 1
include/igl/rgb_to_hsv.cpp

@@ -77,7 +77,7 @@ IGL_INLINE void igl::rgb_to_hsv(
   Eigen::PlainObjectBase<DerivedH> & H)
 {
   assert(R.cols() == 3);
-  H.resize(R.rows(),R.cols());
+  H.resizeLike(R);
   for(typename DerivedR::Index r = 0;r<R.rows();r++)
   {
     typename DerivedR::Scalar rgb[3];

+ 1 - 1
include/igl/round.cpp

@@ -21,7 +21,7 @@ IGL_INLINE void igl::round(
   const Eigen::PlainObjectBase<DerivedX>& X,
   Eigen::PlainObjectBase<DerivedY>& Y)
 {
-  Y.resize(X.rows(),X.cols());
+  Y.resizeLike(X);
   // loop over rows
   for(int i = 0;i<X.rows();i++)
   {

+ 6 - 6
include/igl/sort.cpp

@@ -43,8 +43,8 @@ IGL_INLINE void igl::sort(
   // dim must be 2 or 1
   assert(dim == 1 || dim == 2);
   // Resize output
-  Y.resize(X.rows(),X.cols());
-  IX.resize(X.rows(),X.cols());
+  Y.resizeLike(X);
+  IX.resizeLike(X);
   // idea is to process each column (or row) as a std vector
   // loop over columns (or rows)
   for(int i = 0; i<num_outer;i++)
@@ -106,8 +106,8 @@ IGL_INLINE void igl::sort_new(
   // dim must be 2 or 1
   assert(dim == 1 || dim == 2);
   // Resize output
-  Y.resize(X.rows(),X.cols());
-  IX.resize(X.rows(),X.cols());
+  Y.resizeLike(X);
+  IX.resizeLike(X);
   // idea is to process each column (or row) as a std vector
   // loop over columns (or rows)
   for(int i = 0; i<num_outer;i++)
@@ -166,7 +166,7 @@ IGL_INLINE void igl::sort2(
   int num_inner = (dim == 1 ? X.rows() : X.cols() );
   assert(num_inner == 2);(void)num_inner;
   typedef typename DerivedIX::Scalar Index;
-  IX.resize(X.rows(),X.cols());
+  IX.resizeLike(X);
   if(dim==1)
   {
     IX.row(0).setConstant(0);// = DerivedIX::Zero(1,IX.cols());
@@ -209,7 +209,7 @@ IGL_INLINE void igl::sort3(
   int num_inner = (dim == 1 ? X.rows() : X.cols() );
   assert(num_inner == 3);(void)num_inner;
   typedef typename DerivedIX::Scalar Index;
-  IX.resize(X.rows(),X.cols());
+  IX.resizeLike(X);
   if(dim==1)
   {
     IX.row(0).setConstant(0);// = DerivedIX::Zero(1,IX.cols());

+ 1 - 1
include/igl/sortrows.cpp

@@ -39,7 +39,7 @@
 //  // Perform sort on rows
 //  igl::sort(rows,ascending,sorted,index_map);
 //  // Resize output
-//  Y.resize(X.rows(),X.cols());
+//  Y.resizeLike(X);
 //  IX.resize(X.rows(),1);
 //  // Convert to eigen
 //  for(int i = 0;i<X.rows();i++)