<jupyter_start><jupyter_text>import libraries<jupyter_code>from compas_vol.microstructures import TPMS
from compas.geometry import Point, Frame, Box
from compas_vol.primitives import VolBox
from compas_vol.combinations import Intersection, Subtraction
from compas_vol.modifications import Shell
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>create volumetric object (CSG tree)<jupyter_code>tpms = TPMS(tpmstype='schwartzP', wavelength=4.5)
vb = VolBox(Box(Frame(Point(0, 0, 0), [1, 0, 0], [0, 1, 0]), 26, 22, 18))
s = Shell(tpms, 0.5, 1.0)
i = Intersection(s, vb)<jupyter_output><empty_output><jupyter_text>workspace (dense grid)<jupyter_code>#workspace initialization
# lower and upper bounds
lbx, ubx = -14.0, 14.0
lby, uby = -12.0, 12.0
lbz, ubz = -10.0, 10.0
# resolution(s)
nx, ny, nz = 168, 144, 120
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 = i.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>p = mp.plot(v, f, c=np.array([0,0.57,0.82]), shading={"flat":False, "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))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15240963855421688, 'fraction_numerical': 0.03975903614457831, 'mean_word_length': 7.606217616580311, 'pattern_counts': {'":': 4, '<': 25, '<?xml version=': 0, '>': 25, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '36286', 'license': 'MIT', 'n_tokens_mistral': 764, 'n_tokens_neox': 701, 'n_words': 137, 'path': 'examples/notebooks/tpms.ipynb', 'repo_name': 'dbt-ethz/compas_vol', 'size': '1660'}