瀏覽代碼

improved templating

Former-commit-id: 4c6ae62ca1efc7653cc5b64eaf8341efc86cbfb0
Alec Jacobson 8 年之前
父節點
當前提交
8083680dc8
共有 2 個文件被更改,包括 21 次插入21 次删除
  1. 13 13
      include/igl/slice_mask.cpp
  2. 8 8
      include/igl/slice_mask.h

+ 13 - 13
include/igl/slice_mask.cpp

@@ -8,12 +8,12 @@
 #include "slice_mask.h"
 #include <cassert>
 
-template <typename DerivedX>
+template <typename DerivedX,typename DerivedY>
 IGL_INLINE void igl::slice_mask(
-  const Eigen::PlainObjectBase<DerivedX> & X,
+  const Eigen::MatrixBase<DerivedX> & X,
   const Eigen::Array<bool,Eigen::Dynamic,1> & R,
   const Eigen::Array<bool,Eigen::Dynamic,1> & C,
-  Eigen::PlainObjectBase<DerivedX> & Y)
+  Eigen::PlainObjectBase<DerivedY> & Y)
 {
   int xm = X.rows();
   int xn = X.cols();
@@ -43,12 +43,12 @@ IGL_INLINE void igl::slice_mask(
   }
 }
 
-template <typename DerivedX>
+template <typename DerivedX, typename DerivedY>
 IGL_INLINE void igl::slice_mask(
-  const Eigen::PlainObjectBase<DerivedX> & X,
+  const Eigen::MatrixBase<DerivedX> & X,
   const Eigen::Array<bool,Eigen::Dynamic,1> & R,
   const int dim,
-  Eigen::PlainObjectBase<DerivedX> & Y)
+  Eigen::PlainObjectBase<DerivedY> & Y)
 {
   switch(dim)
   {
@@ -95,7 +95,7 @@ IGL_INLINE void igl::slice_mask(
 
 template <typename DerivedX>
 IGL_INLINE DerivedX igl::slice_mask(
-  const Eigen::PlainObjectBase<DerivedX> & X,
+  const Eigen::MatrixBase<DerivedX> & X,
   const Eigen::Array<bool,Eigen::Dynamic,1> & R,
   const Eigen::Array<bool,Eigen::Dynamic,1> & C)
 {
@@ -106,7 +106,7 @@ IGL_INLINE DerivedX igl::slice_mask(
 
 template <typename DerivedX>
 IGL_INLINE DerivedX igl::slice_mask(
-  const Eigen::PlainObjectBase<DerivedX>& X,
+  const Eigen::MatrixBase<DerivedX>& X,
   const Eigen::Array<bool,Eigen::Dynamic,1> & R,
   const int dim)
 {
@@ -116,9 +116,9 @@ IGL_INLINE DerivedX igl::slice_mask(
 }
 
 #ifdef IGL_STATIC_LIBRARY
-template void igl::slice_mask<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Array<bool, -1, 1, 0, -1, 1> const&, int, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
-template void igl::slice_mask<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Array<bool, -1, 1, 0, -1, 1> const&, Eigen::Array<bool, -1, 1, 0, -1, 1> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
-template void igl::slice_mask<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Array<bool, -1, 1, 0, -1, 1> const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
-template void igl::slice_mask<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Array<bool, -1, 1, 0, -1, 1> const&, Eigen::Array<bool, -1, 1, 0, -1, 1> const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
-template void igl::slice_mask<Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::Array<bool, -1, 1, 0, -1, 1> const&, int, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::slice_mask<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Array<bool, -1, 1, 0, -1, 1> const&, int, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
+template void igl::slice_mask<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Array<bool, -1, 1, 0, -1, 1> const&, Eigen::Array<bool, -1, 1, 0, -1, 1> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
+template void igl::slice_mask<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Array<bool, -1, 1, 0, -1, 1> const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
+template void igl::slice_mask<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Array<bool, -1, 1, 0, -1, 1> const&, Eigen::Array<bool, -1, 1, 0, -1, 1> const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
+template void igl::slice_mask<Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::Array<bool, -1, 1, 0, -1, 1> const&, int, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 #endif

+ 8 - 8
include/igl/slice_mask.h

@@ -25,18 +25,18 @@ namespace igl
   //
   // See also: slice_mask
   
-  template <typename DerivedX>
+  template <typename DerivedX,typename DerivedY>
   IGL_INLINE void slice_mask(
-    const Eigen::PlainObjectBase<DerivedX> & X,
+    const Eigen::MatrixBase<DerivedX> & X,
     const Eigen::Array<bool,Eigen::Dynamic,1> & R,
     const Eigen::Array<bool,Eigen::Dynamic,1> & C,
-    Eigen::PlainObjectBase<DerivedX> & Y);
-  template <typename DerivedX>
+    Eigen::PlainObjectBase<DerivedY> & Y);
+  template <typename DerivedX,typename DerivedY>
   IGL_INLINE void slice_mask(
-    const Eigen::PlainObjectBase<DerivedX> & X,
+    const Eigen::MatrixBase<DerivedX> & X,
     const Eigen::Array<bool,Eigen::Dynamic,1> & R,
     const int dim,
-    Eigen::PlainObjectBase<DerivedX> & Y);
+    Eigen::PlainObjectBase<DerivedY> & Y);
   //
   // This templating is bad because the return type might not have the same
   // size as `DerivedX`. This will probably only work if DerivedX has Dynamic
@@ -44,12 +44,12 @@ namespace igl
   // the number of rows in `DerivedX`.
   template <typename DerivedX>
   IGL_INLINE DerivedX slice_mask(
-    const Eigen::PlainObjectBase<DerivedX> & X,
+    const Eigen::MatrixBase<DerivedX> & X,
     const Eigen::Array<bool,Eigen::Dynamic,1> & R,
     const Eigen::Array<bool,Eigen::Dynamic,1> & C);
   template <typename DerivedX>
   IGL_INLINE DerivedX slice_mask(
-    const Eigen::PlainObjectBase<DerivedX> & X,
+    const Eigen::MatrixBase<DerivedX> & X,
     const Eigen::Array<bool,Eigen::Dynamic,1> & R,
     const int dim);
 }