|
@@ -127,7 +127,7 @@ IGL_INLINE void grad_tri(
|
|
|
// Number of faces
|
|
|
const int m = F.rows();
|
|
|
// Number of vertices
|
|
|
- const int n = V.rows();
|
|
|
+ const int nv = V.rows();
|
|
|
// Number of dimensions
|
|
|
const int dims = V.cols();
|
|
|
Eigen::Matrix<typename DerivedV::Scalar,Eigen::Dynamic,3>
|
|
@@ -141,10 +141,14 @@ IGL_INLINE void grad_tri(
|
|
|
int i3 = F(i,2);
|
|
|
|
|
|
// #F x 3 matrices of triangle edge vectors, named after opposite vertices
|
|
|
- Eigen::Matrix<typename DerivedV::Scalar, 1, 3> v32 = V.row(i3) - V.row(i2);
|
|
|
- Eigen::Matrix<typename DerivedV::Scalar, 1, 3> v13 = V.row(i1) - V.row(i3);
|
|
|
- Eigen::Matrix<typename DerivedV::Scalar, 1, 3> v21 = V.row(i2) - V.row(i1);
|
|
|
- Eigen::Matrix<typename DerivedV::Scalar, 1, 3> n = v32.cross(v13);
|
|
|
+ typedef Eigen::Matrix<typename DerivedV::Scalar, 1, 3> RowVector3S;
|
|
|
+ RowVector3S v32 = RowVector3S::Zero(1,3);
|
|
|
+ RowVector3S v13 = RowVector3S::Zero(1,3);
|
|
|
+ RowVector3S v21 = RowVector3S::Zero(1,3);
|
|
|
+ v32.head(V.cols()) = V.row(i3) - V.row(i2);
|
|
|
+ v13.head(V.cols()) = V.row(i1) - V.row(i3);
|
|
|
+ v21.head(V.cols()) = V.row(i2) - V.row(i1);
|
|
|
+ RowVector3S n = v32.cross(v13);
|
|
|
// area of parallelogram is twice area of triangle
|
|
|
// area of parallelogram is || v1 x v2 ||
|
|
|
// This does correct l2 norm of rows, so that it contains #F list of twice
|
|
@@ -184,7 +188,7 @@ IGL_INLINE void grad_tri(
|
|
|
}
|
|
|
|
|
|
// create sparse gradient operator matrix
|
|
|
- G.resize(dims*m,n);
|
|
|
+ G.resize(dims*m,nv);
|
|
|
std::vector<Eigen::Triplet<typename DerivedV::Scalar> > Gijv;
|
|
|
Gijv.reserve(4*dims*m);
|
|
|
for(int f = 0;f<F.rows();f++)
|
|
@@ -221,6 +225,8 @@ IGL_INLINE void igl::grad(
|
|
|
|
|
|
#ifdef IGL_STATIC_LIBRARY
|
|
|
// Explicit template instantiation
|
|
|
+// generated by autoexplicit.sh
|
|
|
+template void igl::grad<Eigen::Matrix<double, -1, 2, 0, -1, 2>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 2, 0, -1, 2> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<Eigen::Matrix<double, -1, 2, 0, -1, 2>::Scalar, 0, int>&, bool);
|
|
|
template void igl::grad<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<Eigen::Matrix<double, -1, -1, 0, -1, -1>::Scalar, 0, int>&, bool);
|
|
|
template void igl::grad<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::SparseMatrix<Eigen::Matrix<double, -1, 3, 0, -1, 3>::Scalar, 0, int>&, bool);
|
|
|
#endif
|