question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stray voxels occurring when voxelizing a mesh

See original GitHub issue

Describe 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() image

Here is also a side by side comparison for examples.download_cow() image

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:open
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
adeakcommented, Sep 24, 2022

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.

1reaction
banesullivancommented, Mar 4, 2022

Ah! That’s a great find and will help us figure out how to mitigate this

Read more comments on GitHub >

github_iconTop Results From Across the Web

Voxelize a Surface Mesh — PyVista 0.37.0 documentation
Create a voxel model (like legos) of a closed surface or volumetric mesh. This example also demonstrates how to compute an implicit distance...
Read more >
Extending the Spatial Coverage of a Voxel-Based Navigation ...
With voxels, a navmesh can be generated, which conforms greatly to the physical volume of a world, resulting in a navmesh that closely...
Read more >
Nonlinear voxel-based finite element model for strength ...
A nonlinear voxel-based FE model was evaluated to assess femoral bone strength. •. Both healthy and metastatic femurs were evaluated.
Read more >
3D computational domains with different sizes. The voxel ...
Download scientific diagram | 3D computational domains with different sizes. The voxel mesh is identical to the FE mesh. The side lengths are...
Read more >
009 Game Dev Voxel Mesh - YouTube
https://www.sidefx.com/https://www.youtube.com/channel/UCWiZI2dglzpaCYNnjcejS-Q/playlistshttps://www.twitch.tv/pavmikehttps://gumroad.com/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found