<jupyter_start><jupyter_text>import libraries<jupyter_code>from compas.geometry import Point, Sphere
from compas_vol.microstructures import Voronoi
from compas_vol.primitives import VolSphere
from compas_vol.combinations import Intersection
import numpy as np
import meshplot as mp
from skimage.measure import marching_cubes
from compas_vol.utilities import bbox_edges<jupyter_output><empty_output><jupyter_text>random points cloud generation<jupyter_code>nbr_pts = 16
coordinates = np.random.uniform(-30, 30, (nbr_pts,3))
pts = [Point(px,py,pz) for (px,py,pz) in coordinates]<jupyter_output><empty_output><jupyter_text>create volumetric object (CSG tree)<jupyter_code>s = Sphere(Point(0,0,0), 25)
vs = VolSphere (s)
v = Voronoi(pts, thickness=2.0)
u = Intersection(vs, v)<jupyter_output><empty_output><jupyter_text>workspace (dense grid)<jupyter_code>#workspace initialization
# lower and upper bounds
lbx, ubx = -30.0, 30.0
lby, uby = -30.0, 30.0
lbz, ubz = -30.0, 30.0
# resolution(s)
nx, ny, nz = 100, 100, 100
x, y, z = np.ogrid[lbx:ubx:nx*1j, lby:uby:ny*1j, lbz:ubz:nz*1j]
#voxel dimensions
gx = (ubx-lbx)/nx
gy = (uby-lby)/ny
gz = (ubz-lbz)/nz<jupyter_output><empty_output><jupyter_text>sample at discrete interval<jupyter_code>dm = u.get_distance_numpy(x, y, z)<jupyter_output><empty_output><jupyter_text>generate isosurface(marching cube)<jupyter_code>v, f, n, l = marching_cubes(dm, 0, spacing=(gx, gy, gz))
v += [lbx,lby,lbz]<jupyter_output><empty_output><jupyter_text>display mesh<jupyter_code>print('use fc slider for cutting plane')
p = mp.plot(v, f, c=np.array([0,0.57,0.82]), shading={"flat":True, "roughness":0.4, "metalness":0.01, "reflectivity":1.0})
vs,ve = bbox_edges(lbx,ubx,lby,uby,lbz,ubz)
p.add_lines(np.array(vs), np.array(ve))

@mp.interact(fc=(0,120000))
def facefilter(fc=120000):
    p.update_object(faces=f[:fc])<jupyter_output>use fc slider for cutting plane
{'fraction_non_alphanumeric': 0.14761904761904762, 'fraction_numerical': 0.0380952380952381, 'mean_word_length': 7.836448598130841, 'pattern_counts': {'":': 4, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '553023', 'license': 'MIT', 'n_tokens_mistral': 848, 'n_tokens_neox': 786, 'n_words': 148, 'path': 'examples/notebooks/voronoi.ipynb', 'repo_name': 'dbt-ethz/compas_vol', 'size': '1890'}