Stray voxels occurring when voxelizing a mesh
See original GitHub issueDescribe the bug, what’s wrong, and what you expect:
A clear and concise description of what the bug is.
When applying pv.voxelize( ) to a mesh, there are voxels occurring outside of the mesh. For example here is a side by side comparison of the mesh and resultant voxels of pv.Sphere()
Here is also a side by side comparison for examples.download_cow()
A clear and concise description of what you expected to happen. I expect the voxels to match the shape of the mesh, without any outlier cubes.
To Reproduce
Below is the code to replicate the cow voxel.
import numpy as np
import pyvista as pv
from pyvista import examples
mesh = examples.download_cow()
density = mesh.length/100
voxels = pv.voxelize(mesh, density)
plotter = pv.Plotter()
plotter.add_mesh(voxels, opacity = 0.5)
plotter.show()
It is also worth noting that running the exact same code on my friend’s computer produced a voxel with way less outlier cubes. There were still outliers present but the shape of the cow could be made out.
I also only began to notice this bug after a few days of using the pyvista library. Objects such as the sphere used to be perfect but then randomly started to display these outliers in the voxel.
System Information: Please run the following code wherever you are experiencing the bug and paste the output below. This report helps us track down bugs and it is critical to addressing your bug:
# Get system info
import pyvista as pv
print(pv.Report())
--------------------------------------------------------------------------------
Date: Sat Oct 23 01:18:14 2021 Cen. Australia Summer Time
OS : Windows
CPU(s) : 32
Machine : AMD64
Architecture : 64bit
RAM : 63.9 GiB
Environment : Python
GPU Vendor : NVIDIA Corporation
GPU Renderer : NVIDIA GeForce RTX 3090/PCIe/SSE2
GPU Version : 4.5.0 NVIDIA 496.13
Python 3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)]
pyvista : 0.32.1
vtk : 9.0.1
numpy : 1.21.2
imageio : 2.9.0
appdirs : 1.4.4
scooby : 0.5.7
meshio : 4.4.6
matplotlib : 3.2.2
PyQt5 : 5.9.2
IPython : 7.16.1
scipy : 1.5.0
tqdm : 4.47.0
Intel(R) Math Kernel Library Version 2019.0.4 Product Build 20190411 for
Intel(R) 64 architecture applications
--------------------------------------------------------------------------------
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (5 by maintainers)
Cross-posting for visibility: triangulating your meshes will probably help with the artifacts (but there’s a chance some might stick around based on some of the comments here). See https://github.com/pyvista/pyvista/pull/3361 where I’m trying to address this.
Ah! That’s a great find and will help us figure out how to mitigate this