kyle-gh / LeastSquaresConformalMaps

Implementation of Least Squares Conformal Maps for Automatic Texture Atlas Generation by Levy et al.
30 stars 5 forks source link

out of bound of MatrixXx1 #1

Open guihuazgh opened 4 years ago

guihuazgh commented 4 years ago

error: lscm: /usr/local/include/eigen3/Eigen/src/SparseCore/SparseMatrix.h:935: void Eigen::internal::set_from_triplets(const InputIterator&, const InputIterator&, SparseMatrixType&, DupFunctor) [with InputIterator = __gnu_cxx::__normal_iterator<Eigen::Triplet*, std::vector<Eigen::Triplet > >; SparseMatrixType = Eigen::SparseMatrix<double, 0, int>; DupFunctor = Eigen::internal::scalar_sum_op<double, double>]: Assertion `it->row()>=0 && it->row()<mat.rows() && it->col()>=0 && it->col()<mat.cols()' failed.

I have positioned the problem and the error location is Parameterizer. CPP assigns values to _fx[vid. u] and _FX [vid. v] in line 155.Where the size of _fx is 4, while the values of vid. u and vid. v have exceeded 4.

kyle-gh commented 4 years ago

Thanks for getting in touch! It seems your assertion message (SparseMatrix set_from_triplets) and referenced code (Matrix operator[]) don't quite align. Would you be able to provide any additional context or the perhaps the mesh you're using?

guihuazgh commented 4 years ago

Thank you for your reply! Sorry, I copied the assertion incorrectly.The mesh I'm using is the bunny in the program. In lines 151 and 152, Parameterizer. CPP, an error that crosses a boundary occurs. Error message: "LSCM: / usr/local/include/eigen3 / Eigen/SRC/Core/DenseCoeffsBase. H: 408: Eigen: : DenseCoeffsBase<Derived, 1>::Scalar& Eigen::DenseCoeffsBase<Derived, 1>::operator [with Derived = Eigen::Matrix<double, -1, 1>; Eigen::DenseCoeffsBase<Derived, 1>::Scalar = double; Eigen::Index = long int]: Assertion `index >= 0 && index < The size () 'failed." I tried to print some messages: the size of _fx is 4, and the maximum value of "vid. u" is 4, and the maximum value of "vid. v" is 5. This leads to _fx crossing the line when assigning values. When I define the size of _fx to be "_amap.size()*3" this is where the program will pass.

Proceed to run the program, and an error occurs at line 69 of the file Parameterizer. CPP. Error message:"LSCM: / usr/local/include/eigen3 / Eigen/SRC/SparseCore SparseMatrix. H: 935:void Eigen::internal::set_from_triplets(const InputIterator&, const InputIterator&, SparseMatrixType&, DupFunctor) [with InputIterator = __gnu_cxx::__normal_iterator<Eigen::Triplet*, std::vector<Eigen::Triplet > >; SparseMatrixType = Eigen::SparseMatrix<double, 0, int>; DupFunctor = Eigen::internal::scalar_sum_op<double, double>]: Assertion `it->row()>=0 && it->row()<mat.rows() && it->col()>=0 && it->col()<mat.cols()' failed."

I tried to print the size of _A is 11648, and the size of _a is 69872. _a is much larger than _A, so the program reported the above error when initializing the matrix _A.

Since I'm not very familiar with Eigen3, I don't know if they are because I'm not installing the right version. Would it be convenient for you to tell me about your configuration environment?Thank you very much!

kyle-gh commented 4 years ago

Thank you for the additional info! Are you using the default settings/values when running?

I'm using Eigen3 versions 3.3.7 on OSX and 3.3.8 on Ubuntu , and the latest OpenMesh built with the default configuration on both platforms. Both are using the default buildchains with CMake.

kyle-gh commented 4 years ago

I've committed a fix that I believe handles the error. Please try it out and let me know. I'm still curious about the circumstances that's leading to your error. I don't think I was able to repro the error in the way you are seeing it.

guihuazgh commented 4 years ago

Thank you for your reply. I think I found the mistake. _amap[Anchor.h] = _amap.size() * 2; In the above code, when you assign _amap[anchor. h]with_amap.size()*2, the compiler changes _amap.size() directly from 0 to 1.So the _amap container puts 2 and 4 instead of 0 and 2.The same is true for the assignment of _fmap and _vmap. So you should get_amap.size()before you use it. So here's my code change. After modification, there are no errors.

_Int size = _amap. The size ();
_amap [anchor. h] = size * 2;_

I'm also confused as to why this error was generated on my computer environment.

kyle-gh commented 4 years ago

This is an unexpected issue. I've committed a fix for your issue. What environment are you working in?

guihuazgh commented 4 years ago

I'm running Ubuntu16.0.4 on a VMware virtual machine. Using Cmake versions 3.18.4, Openmesh versions 8.1. and Eigen3 versions 3.3.8.