Comments (2)
Oh interesting, I think what is happening here is:
- Mesh in question has some degenerate faces which are still 3 unique vertices (so not caught by the remove_degenerate_faces which just checks for 3 unique indices per face on load), but those vertices are colinear (up to way more than tol.zero, 1e-12)
- The face normals are from the STL file input
- Face normals are stored in the cache, which is cleared when vertices or faces are altered
- When mesh.rezero is called it alters vertices, triggering a cache clear
- is_watertight asks for faces, which checks to make sure face_normals are populated to ensure consistency in the shape of mesh.faces and mesh.face_normals
- the generation of face_normals via cross products detects and removes the degenerate face
- mesh is no longer topologically watertight
So it is totally a little janky to be inconsistent like this. A quick hack to ensure consistency is:
m = trimesh.load('rezero-test.stl')
m.face_normals = None #force the Trimesh object to regenerate/validate face normals
m.is_watertight
I also just added a bit to mesh.rezero that maintains face normals, as they're not going to be changed by a translation.
I'm not sure what the right way to deal with this is globally however. If we just threw out face normals from input files it would keep everything consistent, but in a lot of meshes generating the face normal from cross products is pretty expensive (though I just checked and it looked like it was ~15% of total load/process time). Another option is to add a strict flag:
m = trimesh.load('rezero-test.stl', strict=True)
Which would just throw away input normals, or at least validate them. I'm not in love with adding another esoteric boolean flag though, I'm definitely open to suggestions.
I've found trimesh.repair.broken_faces to be pretty useful for seeing whats happening for stuff like this btw.
from trimesh.
Upon reflection, those faces should really have been removed in initial processing. There is already a remove_degenerate_faces function called in there, however it was only covering the case where a face has two of the same vertex (aka [0,1,0]), not the case where there were three unique vertices that all happened to be colinear. I pushed a fix in d0685ac which is slower than the old function, but its like .015 -> .023s on my machine, which is probably worth it for being more robust.
from trimesh.
Related Issues (20)
- How to export a scene to SVG? HOT 2
- USD(a,c,z) support
- Area of filled polygons in a 2D slice
- some vertices are missing when importing an OBJ file HOT 2
- How to convert mesh to voxels with a specific shape, say, 32x32x32 ?
- Unexpected visualisation and texture concatenation behaviour
- `No FCL Available!` on Mac M3 despite python-fcl being installed HOT 2
- Processing meshes with "holes" flips the inner normals HOT 2
- Save image error on mac 'CocoaAlternateEventLoop' HOT 2
- Error when loading .obj where only some objects have colors HOT 1
- pyglet Viewer not working - ImportError: `trimesh.viewer.windowed` requires `pip install "pyglet<2"` HOT 2
- Issue with Inconsistent Transformation Application using `add_geometry` in trimesh Scene
- How to export a mesh as a ply file, with some customized attributes?
- trimesh texture loading with PIL is toooo slow HOT 3
- Crashed in pyrender's scene render function when texture size/number is large HOT 1
- How to export obj with specific faces colored? HOT 1
- Skip loading texture HOT 3
- Why the rendered orientation of the mesh is different from orientation in the homogenous transformation matrix? HOT 1
- vertex_indices_to_resulting_edges HOT 1
- GLB is not rendered correctly HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trimesh.