Skip to content

stl to voxel #2009

Answered by Grantim
jvbelenky asked this question in Q&A
Discussion options

You must be logged in to vote

Hello!
We are not really familar with paraview import but you can extract mesh and voxels in numpy like this

from meshlib impoer mrmeshpy as mm
from meshlib impoer mrmeshnumpy as mn
import numpy as np

# load mesh from stl
mesh = mm.loadMesh( "path_to_mesh.stl" )

# configure parameters for voxel conversion
params = mm.MeshToDistanceVolumeParams()
voxelSize = 0.01
box = mesh .computeBoundingBox()
expansion = mm.Vector3f.diagonal( 3*voxelSize )
params.origin = box.min - expansion
params.voxelSize = mm.Vector3f.diagonal(0.01)
dimensionsF = ( box.max + expansion - params.origin ) / voxelSize
params.dimensions = mm.Vector3i(int(dimensionsF.x),int(dimensionsF.y),int(dimensionsF.z)) + mm.Vector3i.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Fedr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants