Utilities
- class pyvcad.MaterialDefs
Class representing material definitions that translates between material names, colors, and ids.
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pyvcad.pyvcad.MaterialDefs) -> None
Default constructor mapping void material to id 0.
__init__(self: pyvcad.pyvcad.MaterialDefs, arg0: str) -> None
Constructor that takes a string as the path to the material configuration file.
- color(*args, **kwargs)
Overloaded function.
color(self: pyvcad.pyvcad.MaterialDefs, arg0: typing.SupportsInt) -> pyvcad.pyvcad.Vec4
Returns the color of the material given the id.
color(self: pyvcad.pyvcad.MaterialDefs, arg0: str) -> pyvcad.pyvcad.Vec4
Returns the color of the material given the name.
- contains(self: pyvcad.pyvcad.MaterialDefs, arg0: str) bool
Returns true if the material exists given the name.
- id(*args, **kwargs)
Overloaded function.
id(self: pyvcad.pyvcad.MaterialDefs, arg0: str) -> int
Returns the id of the material given the name.
id(self: pyvcad.pyvcad.MaterialDefs, arg0: pyvcad.pyvcad.Vec4) -> int
Returns the id of the material given the color.
- name(self: pyvcad.pyvcad.MaterialDefs, arg0: SupportsInt) str
Returns the name of the material given the id.
- num_materials(self: pyvcad.pyvcad.MaterialDefs) int
Returns the number of materials.
- palette(self: pyvcad.pyvcad.MaterialDefs) list[pyvcad.pyvcad.Vec4]
Returns a list of colors that are in the floating point range [0, 1]. The list contains 4-component colors (RGBA).
- prescaled_color_list(self: pyvcad.pyvcad.MaterialDefs) list[pyvcad.pyvcad.Vec4]
Returns a list of colors that are prescaled to the range [0, 255]. The list contains 4-component colors (RGBA).
- update_color(self: pyvcad.pyvcad.MaterialDefs, arg0: SupportsInt, arg1: pyvcad.pyvcad.Vec4) None
Updates the color of the material given the id. The new color of the material is specified as a 4-component color (RGBA).
- class pyvcad.ColorMap
- __init__(self: pyvcad.pyvcad.ColorMap) None
- add_color(self: pyvcad.pyvcad.ColorMap, value: SupportsFloat, color: pyvcad.pyvcad.Vec3) None
- static create_grayscale() pyvcad.pyvcad.ColorMap
- static create_inferno() pyvcad.pyvcad.ColorMap
- static create_plasma() pyvcad.pyvcad.ColorMap
- static create_viridis() pyvcad.pyvcad.ColorMap
- get_color(self: pyvcad.pyvcad.ColorMap, value: SupportsFloat) pyvcad.pyvcad.Vec3
- class pyvcad.TreeSampler
Utility for sampling a Node into voxel-based representations.
Changing root, voxel_size, or material_defs requires constructing a new TreeSampler. Call sample_dimensions() to query the grid shape.
- __init__(self: pyvcad.pyvcad.TreeSampler, root: pyvcad.pyvcad.Node, voxel_size: pyvcad.pyvcad.Vec3, material_defs: pyvcad.pyvcad.MaterialDefs = None) None
Create a TreeSampler for a given root node and voxel size.
- Parameters:
root (Node) – Root node of the tree to sample.
voxel_size (vec3) – Size of a voxel in world units.
material_defs (MaterialDefs, optional) – Material definitions used for color mapping.
- as_float_array(self: pyvcad.pyvcad.TreeSampler, attribute: str, progress: object = None) numpy.typing.NDArray[numpy.float32]
Sample an attribute into a Float voxel grid.
- Parameters:
attribute (str) – Attribute name to sample.
progress (callable, optional) – Progress callback taking an int 0-100.
- Returns:
numpy_array of float32.
- as_rgba_array(self: pyvcad.pyvcad.TreeSampler, attribute: str, color_map: pyvcad.pyvcad.ColorMap, blend: bool = True, progress: object = None) numpy.ndarray
Sample an attribute into an RGBA voxel grid.
- Parameters:
attribute (str) – Attribute name to sample.
color_map (ColorMap) – Color map used to convert attributes to RGBA.
blend (bool) – Whether to blend multi-material voxels.
progress (callable, optional) – Progress callback taking an int 0-100.
- Returns:
(nx, ny, nz, numpy_array) with numpy_array of shape (nx*ny*nz*4,) and dtype uint8.
- Return type:
tuple
- as_signed_distance_array(self: pyvcad.pyvcad.TreeSampler, progress: object = None) numpy.ndarray
Sample the tree into a signed distance field.
- Parameters:
progress (callable, optional) – Progress callback taking an int 0-100.
- Returns:
(nx, ny, nz, numpy_array) with numpy_array of shape (nx*ny*nz,) and dtype float32.
- Return type:
tuple
- as_vec3_array(self: pyvcad.pyvcad.TreeSampler, attribute: str, progress: object = None) numpy.typing.NDArray[numpy.float32]
Sample an attribute into a Vec3 voxel grid.
- Parameters:
attribute (str) – Attribute name to sample.
progress (callable, optional) – Progress callback taking an int 0-100.
- Returns:
numpy_array of float32.
- as_vec4_array(self: pyvcad.pyvcad.TreeSampler, attribute: str, progress: object = None) numpy.typing.NDArray[numpy.float32]
Sample an attribute into a Vec4 voxel grid.
- Parameters:
attribute (str) – Attribute name to sample.
progress (callable, optional) – Progress callback taking an int 0-100.
- Returns:
numpy_array of float32.
- get_double_attribute_min_max(self: pyvcad.pyvcad.TreeSampler) tuple[float, float]
Get the min and max values of the last sampled double attribute.
- Returns:
(min, max) as floats.
- Return type:
pair
- sample_dimensions(self: pyvcad.pyvcad.TreeSampler) tuple[int, int, int]
Return the sample grid dimensions as (nx, ny, nz).
- sample_points_to_colors(self: pyvcad.pyvcad.TreeSampler, points: collections.abc.Sequence[pyvcad.pyvcad.Vec3], attribute: str, color_map: pyvcad.pyvcad.ColorMap, blend: bool = True, progress: object = None) list[pyvcad.pyvcad.Vec3]
Sample colors at arbitrary points in space.
- Parameters:
- Returns:
RGB colors for each point.
- Return type:
list[vec3]
- sample_points_to_float_array(self: pyvcad.pyvcad.TreeSampler, points: collections.abc.Sequence[pyvcad.pyvcad.Vec3], attribute: str, progress: object = None) list[float]
Sample float attributes at arbitrary points in space.
- Parameters:
points (list[vec3]) – Points to sample.
attribute (str) – Attribute name to sample.
progress (callable, optional) – Progress callback taking an int 0-100.
- Returns:
sampled values for each point.
- Return type:
list[float]
- sample_points_to_vec3_array(self: pyvcad.pyvcad.TreeSampler, points: collections.abc.Sequence[pyvcad.pyvcad.Vec3], attribute: str, progress: object = None) list[pyvcad.pyvcad.Vec3]
Sample vec3 attributes at arbitrary points in space.
- sample_points_to_vec4_array(self: pyvcad.pyvcad.TreeSampler, points: collections.abc.Sequence[pyvcad.pyvcad.Vec3], attribute: str, progress: object = None) list[pyvcad.pyvcad.Vec4]
Sample vec4 attributes at arbitrary points in space.
- set_undefined_attribute_pattern_enabled(self: pyvcad.pyvcad.TreeSampler, enabled: bool) None
Enable or disable the undefined-attribute stripe pattern.
When enabled (default True), inside voxels/points missing the selected attribute are rendered with a subtle world-space stripe pattern instead of plain gray.
- Parameters:
enabled (bool) – True to show the pattern, False for plain gray.