12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #include "grid.h"
- #include <cassert>
- template <
- typename Derivedres,
- typename DerivedGV>
- IGL_INLINE void igl::grid(
- const Eigen::MatrixBase<Derivedres> & res,
- Eigen::PlainObjectBase<DerivedGV> & GV)
- {
- using namespace Eigen;
- typedef typename DerivedGV::Scalar Scalar;
- GV.resize(res.array().prod(),res.size());
- const auto lerp =
- [&res](const Scalar di, const int d)->Scalar{return di/(Scalar)(res(d)-1);};
- int gi = 0;
- Derivedres sub;
- sub.resizeLike(res);
- sub.setConstant(0);
- for(int gi = 0;gi<GV.rows();gi++)
- {
-
- for(int c = 0;c<res.size()-1;c++)
- {
- if(sub(c)>=res(c))
- {
- sub(c) = 0;
-
- sub(c+1)++;
- }
- }
- for(int c = 0;c<res.size();c++)
- {
- GV(gi,c) = lerp(sub(c),c);
- }
- sub(0)++;
- }
- }
- #ifdef IGL_STATIC_LIBRARY
- template void igl::grid<Eigen::Matrix<int, 2, 1, 0, 2, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<int, 2, 1, 0, 2, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
- template void igl::grid<Eigen::Matrix<int, 1, 3, 1, 1, 3>, Eigen::Matrix<float, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<int, 1, 3, 1, 1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> >&);
- template void igl::grid<Eigen::Matrix<int, 3, 1, 0, 3, 1>, Eigen::Matrix<float, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<int, 3, 1, 0, 3, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> >&);
- template void igl::grid<Eigen::Matrix<int, 3, 1, 0, 3, 1>, Eigen::Matrix<float, -1, 3, 1, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<int, 3, 1, 0, 3, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> >&);
- template void igl::grid<Eigen::Matrix<int, 3, 1, 0, 3, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<int, 3, 1, 0, 3, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
- template void igl::grid<Eigen::Matrix<int, 1, 3, 1, 1, 3>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<int, 1, 3, 1, 1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
- #endif
|