Skip to content

From CAD (STL/STEP) through voxel to pore network - how to make it? #1888

Answered by jgostick
pashaLyb asked this question in Q&A
Discussion options

You must be logged in to vote

OK, here is a script that works. I had to play a bit because the m.voxelized method of the mesh objects in trimesh only do the 'surface' mesh not the total volume.

import porespy as ps
from skimage.measure import marching_cubes
import scipy.ndimage as spim
import trimesh
import numpy as np


# Generate a basic image for testing
im1 = np.zeros(shape=[60, 60, 60], dtype=bool)
im1[tuple((slice(20, 40, None), slice(20, 40, None), slice(20, 40, None)))] = 1
im1[tuple((slice(30, 50, None), slice(30, 50, None), slice(30, 50, None)))] = 1

# Obtain a mesh from the boolean image.  
im1 = np.pad(im1, 3, mode='constant', constant_values=0)
im2 = spim.convolve(im1*1.0, weights=ps.tools.ps_round(1, im1.

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@jgostick
Comment options

@pashaLyb
Comment options

@jgostick
Comment options

@jgostick
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by jgostick
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