12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- // This file is part of libigl, a simple c++ geometry processing library.
- //
- // Copyright (C) 2016 Alec Jacobson <alecjacobson@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 "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++)
- {
- // omg, I'm implementing addition...
- for(int c = 0;c<res.size()-1;c++)
- {
- if(sub(c)>=res(c))
- {
- sub(c) = 0;
- // roll over
- sub(c+1)++;
- }
- }
- for(int c = 0;c<res.size();c++)
- {
- GV(gi,c) = lerp(sub(c),c);
- }
- sub(0)++;
- }
- }
- #ifdef IGL_STATIC_LIBRARY
- // Explicit template instantiation
- // generated by autoexplicit.sh
- 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> >&);
- // generated by autoexplicit.sh
- 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> >&);
- // generated by autoexplicit.sh
- 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> >&);
- // generated by autoexplicit.sh
- 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> >&);
- // generated by autoexplicit.sh
- 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
|