I'm trying to use LibIgl to get the squared distance from a point to the mesh. Here's a code snippet I'm trying to run:
// load a mesh
std::ifstream fileStream;
std::string filePath = R"(C:\path\to\stl\1x1x1Cube.stl)";
Eigen::MatrixXd Vs;
Eigen::MatrixXi Fs;
Eigen::MatrixXd Ns;
igl::readSTL(filePath, Vs, Fs, Ns);
// build the AABB tree for the mesh
igl::AABB<Eigen::MatrixXd, 3> tree;
tree.init(Vs, Fs);
Eigen::MatrixXd queryPoint = (Eigen::MatrixXd(1, 3) << 0.5, 0.5, 0.5).finished();
Eigen::VectorXd sqrD;
{
Eigen::VectorXi I;
Eigen::VectorXd C;
tree.squared_distance(Vs, Fs, queryPoint, sqrD, I, C);
}
However, when I run this code, it fails on the call to tree.squared_distance()
. It's failed an assert somewhere deep inside Eigen. The failed assert is in the Eigen library, in Block.h when it's trying to run the Dynamic-size constructor inline Block()
.
For what it's worth, the assert that fails is eigen_assert(a_startRow <= xpr.rows() - blockRows)
I'm new to both LibIgl and Eigen. Is there something obvious that I'm missing?