Closed efahl closed 4 years ago
I should have noted that the mass properties are fine, identical in both versions, it's just the 'is_checked' that's firing off the 'not closed' message that is the issue.
The check is a very simple sanity check to see if a mesh is likely to be closed which is often going to be wrong unfortunately. The problem is that if the mesh is not closed the methods are going to give completely wrong numbers: https://github.com/WoLpH/numpy-stl/issues/69
With the normalized normals the check was actually broken since it expects the normals to be non-normalized.
You can safely ignore it if you feel that it's wrong in your case. But be sure to check if the output looks sane. Perhaps I should add an easy way of hiding the warnings...
I have just had the same issue, and I think it's an easy fix. The current check is:
if (self.normals.sum(axis=0) >= 1e-4).any():
return False
Change it to:
if (numpy.abs(self.normals.sum(axis=0)) >= 1e-4).any():
This gives me correct behaviour for a closed sphere (True) and a single triangle with normal vector (0,0,-1) (False).
Alternatively you can use isclose in numpy:
"""Check the mesh is closed or not"""
if np.isclose(self.normals.sum(axis=0), 0, atol=1e-4).all():
return True
else:
return False
I can make a PR if you agree with this fix.
I'm happy with any fix that works well and provides good results. A pull request would be greatly appreciated @James-Archer!
The new release is online :)
In 2.10.1, reading STL and getting mass properties was silent, suddenly getting the 'Your mesh is not closed' message when reading with 2.11.0. Looks like it's related to #122 - normalized normals...
Dug into the check, and extracted its logic to see what's going on:
In 2.10.1 this produces
But in 2.11.0 it gives very large values, triggering the message output and reporting as non-closed.