|
@@ -6,6 +6,7 @@
|
|
|
// 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,
|
|
@@ -16,23 +17,30 @@ IGL_INLINE void igl::grid(
|
|
|
{
|
|
|
using namespace Eigen;
|
|
|
typedef typename DerivedGV::Scalar Scalar;
|
|
|
- GV.resize(res(0)*res(1)*res(2),3);
|
|
|
- for(int zi = 0;zi<res(2);zi++)
|
|
|
+ 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++)
|
|
|
{
|
|
|
- const auto lerp =
|
|
|
- [&](const Scalar di, const int d)->Scalar{return di/(Scalar)(res(d)-1);};
|
|
|
- const Scalar z = lerp(zi,2);
|
|
|
- for(int yi = 0;yi<res(1);yi++)
|
|
|
+ // omg, I'm implementing addition...
|
|
|
+ for(int c = 0;c<res.size()-1;c++)
|
|
|
{
|
|
|
- const Scalar y = lerp(yi,1);
|
|
|
- for(int xi = 0;xi<res(0);xi++)
|
|
|
+ if(sub(c)>=res(c))
|
|
|
{
|
|
|
- const Scalar x = lerp(xi,0);
|
|
|
- const int gi = xi+res(0)*(yi + res(1)*zi);
|
|
|
- GV.row(gi) =
|
|
|
- Eigen::Matrix<Scalar,1,3>(x,y,z);
|
|
|
+ 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)++;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -40,6 +48,8 @@ IGL_INLINE void igl::grid(
|
|
|
#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> >&);
|