Tree — composition nodes

Transforms, tiling, boolean CSG, offsets, shells, and mapping helpers.

class pyvcad.Rotate

Rotates a child node around a point. The rotation is specified by a pitch, yaw, and roll angles and a point around which the rotation is performed. The rotation is performed in the order: roll, yaw, pitch. By default, rotation is around the point (0, 0, 0), but you can specify a different point in the constructor.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.Rotate) -> None

Default constructor. Defaults to no rotation.

Example

>>> from libvcad import pyvcad as pv
>>> rect_prism = pv.RectPrism(pv.vec3(0, 0, 0), pv.vec3(2, 2, 2), 1)
>>> rotate = pv.Rotate()
>>> rotate.set_child(rect_prism)
  1. __init__(self: pyvcad.pyvcad.Rotate, pitch: typing.SupportsFloat, yaw: typing.SupportsFloat, roll: typing.SupportsFloat, around: pyvcad.pyvcad.Vec3 = <pyvcad.pyvcad.Vec3 object at 0x106cfb330>) -> None

Constructor. Creates a Rotate with pitch, yaw, roll angles, and a point around which the rotation is performed.

Parameters:
  • pitch (double) – Pitch angle in degrees.

  • yaw (double) – Yaw angle in degrees.

  • roll (double) – Roll angle in degrees.

  • around (glm::vec3) – Point around which the rotation is performed. Defaults to (0, 0, 0).

Example

>>> from libvcad import pyvcad as pv
>>> pitch = 30
>>> yaw = 45
>>> roll = 60
>>> around = pv.vec3(1, 1, 1)
>>> rect_prism = pv.RectPrism(pv.vec3(0, 0, 0), pv.vec3(2, 2, 2), 1)
>>> rotate = pv.Rotate(pitch, yaw, roll, around)
>>> rotate.set_child(rect_prism)
  1. __init__(self: pyvcad.pyvcad.Rotate, pitch: typing.SupportsFloat, yaw: typing.SupportsFloat, roll: typing.SupportsFloat, around: pyvcad.pyvcad.Vec3, child: pyvcad.pyvcad.Node) -> None

Constructor. Creates a Rotate with pitch, yaw, roll angles, a point around which the rotation is performed, and a child node.

Parameters:
  • pitch (double) – Pitch angle in degrees.

  • yaw (double) – Yaw angle in degrees.

  • roll (double) – Roll angle in degrees.

  • around (glm::vec3) – Point around which the rotation is performed.

  • child (std::shared_ptr<Node>) – The child node.

Example

>>> from libvcad import pyvcad as pv
>>> pitch = 30
>>> yaw = 45
>>> roll = 60
>>> around = pv.vec3(1, 1, 1)
>>> rect_prism = pv.RectPrism(pv.vec3(0, 0, 0), pv.vec3(2, 2, 2), 1)
>>> rotate = pv.Rotate(pitch, yaw, roll, around, rect_prism)
class pyvcad.Scale

Scales a child by a factor in each dimension. This node is unary, therefore can only have one child. The scale is applied during evaluate() and performs the inverse of the scaling on the point.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.Scale) -> None

Default constructor. Sets the scale to 1.0 in each dimension.

Example

>>> from libvcad import pyvcad as pv
>>> rect_prism = pv.RectPrism(pv.vec3(0, 0, 0), pv.vec3(2, 2, 2), 1)
>>> scale = pv.Scale()
>>> scale.set_child(rect_prism)
  1. __init__(self: pyvcad.pyvcad.Scale, x: typing.SupportsFloat, y: typing.SupportsFloat, z: typing.SupportsFloat) -> None

Constructor. Sets the scale to the supplied values.

Parameters:
  • x (double) – The scale in the x dimension.

  • y (double) – The scale in the y dimension.

  • z (double) – The scale in the z dimension.

Example

>>> from libvcad import pyvcad as pv
>>> rect_prism = pv.RectPrism(pv.vec3(0, 0, 0), pv.vec3(2, 2, 2), 1)
>>> scale = pv.Scale(2.0, 2.0, 2.0)
>>> scale.set_child(rect_prism)
  1. __init__(self: pyvcad.pyvcad.Scale, x: typing.SupportsFloat, y: typing.SupportsFloat, z: typing.SupportsFloat, child: pyvcad.pyvcad.Node) -> None

Constructor. Sets the scale to the supplied values and sets the child.

Parameters:
  • x (double) – The scale in the x dimension.

  • y (double) – The scale in the y dimension.

  • z (double) – The scale in the z dimension.

  • child (std::shared_ptr<Node>) – The child node.

Example

>>> from libvcad import pyvcad as pv
>>> rect_prism = pv.RectPrism(pv.vec3(0, 0, 0), pv.vec3(2, 2, 2), 1)
>>> scale = pv.Scale(2.0, 2.0, 2.0, rect_prism)
class pyvcad.Translate

Translates a child in Cartesian space by a given amount. This node is unary, with only one child, and performs the inverse translation on coordinates during material() and evaluate().

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.Translate) -> None

Default constructor. Sets the translation to 0, 0, 0.

Example

>>> from libvcad import pyvcad as pv
>>> rect_prism = pv.RectPrism(pv.vec3(0, 0, 0), pv.vec3(2, 2, 2), 1)
>>> translate = pv.Translate()
>>> translate.set_child(rect_prism)
  1. __init__(self: pyvcad.pyvcad.Translate, x: typing.SupportsFloat, y: typing.SupportsFloat, z: typing.SupportsFloat) -> None

Constructor. Sets the translation to given values in Cartesian space.

Parameters:
  • x (double) – Translation in the x direction.

  • y (double) – Translation in the y direction.

  • z (double) – Translation in the z direction.

Example

>>> from libvcad import pyvcad as pv
>>> rect_prism = pv.RectPrism(pv.vec3(0, 0, 0), pv.vec3(2, 2, 2), 1)
>>> translate = pv.Translate(1.0, 2.0, 3.0)
>>> translate.set_child(rect_prism)
  1. __init__(self: pyvcad.pyvcad.Translate, x: typing.SupportsFloat, y: typing.SupportsFloat, z: typing.SupportsFloat, child: pyvcad.pyvcad.Node) -> None

Constructor. Sets the translation to given values and sets the child.

Parameters:
  • x (double) – Translation in the x direction.

  • y (double) – Translation in the y direction.

  • z (double) – Translation in the z direction.

  • child (std::shared_ptr<Node>) – The child to set.

Example

>>> from libvcad import pyvcad as pv
>>> rect_prism = pv.RectPrism(pv.vec3(0, 0, 0), pv.vec3(2, 2, 2), 1)
>>> translate = pv.Translate(1.0, 2.0, 3.0, rect_prism)
class pyvcad.Sum

A node that sums all child Signed Distance Fields (SDFs). This node is N-ary, meaning it can have multiple children. The sum is calculated during evaluate() and results in the combined sum of all child SDFs.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.Sum) -> None

Default constructor.

  1. __init__(self: pyvcad.pyvcad.Sum, iso_value: typing.SupportsFloat) -> None

Constructor. Sets the iso value for the sum node.

Parameters:

iso_value (double) – The iso value for the sum node.

  1. __init__(self: pyvcad.pyvcad.Sum, iso_value: typing.SupportsFloat, children: collections.abc.Sequence[pyvcad.pyvcad.Node]) -> None

Constructor. Sets the iso value and the children for the sum node.

Parameters:
  • iso_value (double) – The iso value for the sum node.

  • children (std::vector<std::shared_ptr<Node>>) – The children of the sum node.

class pyvcad.Tile

A node that tiles a child geometry in a grid pattern. This unary operator repeats a geometry based on specified cell dimensions. The tiling occurs when evaluate() or material() is called, which can be used to create lattice structures.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.Tile) -> None

Default constructor. The cell dimensions will be calculated from the child node when prepare is called.

Example

>>> from libvcad import pyvcad as pv
>>> tile = pv.Tile()
  1. __init__(self: pyvcad.pyvcad.Tile, child: pyvcad.pyvcad.Node) -> None

Constructor. Sets the child node. The cell dimensions will be calculated from the child node.

Parameters:

child (std::shared_ptr<Node>) – The child node.

Example

>>> from libvcad import pyvcad as pv
>>> rect_prism = pv.RectPrism(pv.Vec3(0, 0, 0), pv.Vec3(2, 2, 2), 1)
>>> tile = pv.Tile(rect_prism)
  1. __init__(self: pyvcad.pyvcad.Tile, cell_x: typing.SupportsFloat, cell_y: typing.SupportsFloat, cell_z: typing.SupportsFloat) -> None

Constructor. Sets the dimensions of a cell in the grid.

Parameters:
  • cell_x (double) – The x dimension of a cell.

  • cell_y (double) – The y dimension of a cell.

  • cell_z (double) – The z dimension of a cell.

Example

>>> from libvcad import pyvcad as pv
>>> tile = pv.Tile(1.0, 1.0, 1.0)
  1. __init__(self: pyvcad.pyvcad.Tile, cell_x: typing.SupportsFloat, cell_y: typing.SupportsFloat, cell_z: typing.SupportsFloat, child: pyvcad.pyvcad.Node) -> None

Constructor. Sets the dimensions of a cell in the grid and sets the child.

Parameters:
  • cell_x (double) – The x dimension of a cell.

  • cell_y (double) – The y dimension of a cell.

  • cell_z (double) – The z dimension of a cell.

  • child (std::shared_ptr<Node>) – The child node.

Example

>>> from libvcad import pyvcad as pv
>>> rect_prism = pv.RectPrism(pv.Vec3(0, 0, 0), pv.Vec3(2, 2, 2), 1)
>>> tile = pv.Tile(1.0, 1.0, 1.0, rect_prism)
class pyvcad.Difference

A difference binary node. The difference is taken as the left child minus the right child. This node is binary, so it can have two children. Supports optional smooth blending with a radius parameter k.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.Difference) -> None

Default constructor. Creates a Difference node.

Example

>>> from libvcad import pyvcad as pv
>>> radius = 5
>>> left_sphere = pv.Sphere(pv.Vec3(-radius/2, 0, 0), radius, 1)
>>> right_sphere = pv.Sphere(pv.Vec3(radius/2, 0, 0), radius, 1)
>>> difference = pv.Difference()
>>> difference.set_left(left_sphere)
>>> difference.set_right(right_sphere)
  1. __init__(self: pyvcad.pyvcad.Difference, left: pyvcad.pyvcad.Node, right: pyvcad.pyvcad.Node) -> None

Constructor. Creates a Difference node with the given left and right children.

Parameters:
  • left (Node) – The left child node.

  • right (Node) – The right child node.

Example

>>> from libvcad import pyvcad as pv
>>> radius = 5
>>> left_sphere = pv.Sphere(pv.Vec3(-radius/2, 0, 0), radius, 1)
>>> right_sphere = pv.Sphere(pv.Vec3(radius/2, 0, 0), radius, 1)
>>> difference = pv.Difference(left_sphere, right_sphere)
  1. __init__(self: pyvcad.pyvcad.Difference, k: typing.SupportsFloat) -> None

Constructor for smooth difference.

Parameters:

k (float) – The smoothing radius. When k > 0, produces a smooth subtraction.

Example

>>> from libvcad import pyvcad as pv
>>> smooth_diff = pv.Difference(1.0)
>>> smooth_diff.set_left(left_sphere)
>>> smooth_diff.set_right(right_sphere)
  1. __init__(self: pyvcad.pyvcad.Difference, k: typing.SupportsFloat, left: pyvcad.pyvcad.Node, right: pyvcad.pyvcad.Node) -> None

Constructor for smooth difference with children.

Parameters:
  • k (float) – The smoothing radius. When k > 0, produces a smooth subtraction.

  • left (Node) – The left child node.

  • right (Node) – The right child node.

Example

>>> from libvcad import pyvcad as pv
>>> left_sphere = pv.Sphere(pv.Vec3(-2, 0, 0), 3, 1)
>>> right_sphere = pv.Sphere(pv.Vec3(2, 0, 0), 3, 1)
>>> smooth_diff = pv.Difference(1.0, left_sphere, right_sphere)
class pyvcad.Intersection

Intersection of two or more nodes. This node is N-ary, so it can have multiple children. Supports optional smooth blending with a radius parameter k.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.Intersection) -> None

Default constructor. Creates an Intersection node.

Example

>>> from libvcad import pyvcad as pv
>>> radius = 5
>>> sphere1 = pv.Sphere(pv.Vec3(-radius/2, 0, 0), radius, 1)
>>> sphere2 = pv.Sphere(pv.Vec3(radius/2, 0, 0), radius, 1)
>>> intersection = pv.Intersection()
>>> intersection.add_child(sphere1)
>>> intersection.add_child(sphere2)
  1. __init__(self: pyvcad.pyvcad.Intersection, intersect_distribution: bool) -> None

Constructor. Creates an Intersection node with the option to intersect the distribution.

Parameters:

intersect_distribution (bool) – If true, the distribution will be intersected. If false, the distribution will be summed.

Example

>>> from libvcad import pyvcad as pv
>>> radius = 5
>>> sphere1 = pv.Sphere(pv.Vec3(-radius/2, 0, 0), radius, 1)
>>> sphere2 = pv.Sphere(pv.Vec3(radius/2, 0, 0), radius, 1)
>>> intersection = pv.Intersection(True)
>>> intersection.add_child(sphere1)
>>> intersection.add_child(sphere2)
  1. __init__(self: pyvcad.pyvcad.Intersection, intersect_distribution: bool, children: collections.abc.Sequence[pyvcad.pyvcad.Node]) -> None

Constructor. Creates an Intersection node with the option to intersect the distribution and sets the children.

Parameters:
  • intersect_distribution (bool) – If true, the distribution will be intersected. If false, the distribution will be summed.

  • children (list[Node]) – The children nodes.

Example

>>> from libvcad import pyvcad as pv
>>> radius = 5
>>> sphere1 = pv.Sphere(pv.Vec3(-radius/2, 0, 0), radius, 1)
>>> sphere2 = pv.Sphere(pv.Vec3(radius/2, 0, 0), radius, 1)
>>> intersection = pv.Intersection(True, [sphere1, sphere2])
  1. __init__(self: pyvcad.pyvcad.Intersection, k: typing.SupportsFloat, intersect_distribution: bool = False) -> None

Constructor for smooth intersection.

Parameters:
  • k (float) – The smoothing radius. When k > 0, produces a smooth blend.

  • intersect_distribution (bool) – If true, the distribution will be intersected.

Example

>>> from libvcad import pyvcad as pv
>>> sphere1 = pv.Sphere(pv.Vec3(-2, 0, 0), 3, 1)
>>> sphere2 = pv.Sphere(pv.Vec3(2, 0, 0), 3, 1)
>>> smooth_inter = pv.Intersection(1.0, False)
>>> smooth_inter.add_child(sphere1)
>>> smooth_inter.add_child(sphere2)
  1. __init__(self: pyvcad.pyvcad.Intersection, k: typing.SupportsFloat, intersect_distribution: bool, children: collections.abc.Sequence[pyvcad.pyvcad.Node]) -> None

Constructor for smooth intersection with children.

Parameters:
  • k (float) – The smoothing radius. When k > 0, produces a smooth blend.

  • intersect_distribution (bool) – If true, the distribution will be intersected.

  • children (list[Node]) – The children nodes.

Example

>>> from libvcad import pyvcad as pv
>>> sphere1 = pv.Sphere(pv.Vec3(-2, 0, 0), 3, 1)
>>> sphere2 = pv.Sphere(pv.Vec3(2, 0, 0), 3, 1)
>>> smooth_inter = pv.Intersection(1.0, False, [sphere1, sphere2])
class pyvcad.Union

A union of two or more nodes. This is equivalent to the summing of the children. This node is N-ary, so it can have multiple children. Supports optional smooth blending with a radius parameter k.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.Union) -> None

Default constructor. Creates a Union node with no children.

Example

>>> from libvcad import pyvcad as pv
>>> radius = 5
>>> sphere1 = pv.Sphere(pv.Vec3(-radius/2, 0, 0), radius, 1)
>>> sphere2 = pv.Sphere(pv.Vec3(radius/2, 0, 0), radius, 1)
>>> union_node = pv.Union()
>>> union_node.add_child(sphere1)
>>> union_node.add_child(sphere2)
  1. __init__(self: pyvcad.pyvcad.Union, should_union_distribution: bool) -> None

Constructor. Creates a Union node with an option to union distributions.

Parameters:

should_union_distribution (bool) – If true, the distribution will be unioned. If false, the distribution will be summed.

Example

>>> from libvcad import pyvcad as pv
>>> radius = 5
>>> sphere1 = pv.Sphere(pv.Vec3(-radius/2, 0, 0), radius, 1)
>>> sphere2 = pv.Sphere(pv.Vec3(radius/2, 0, 0), radius, 1)
>>> union_node = pv.Union(True)
>>> union_node.add_child(sphere1)
>>> union_node.add_child(sphere2)
  1. __init__(self: pyvcad.pyvcad.Union, should_union_distribution: bool, children: collections.abc.Sequence[pyvcad.pyvcad.Node]) -> None

Constructor. Creates a Union node with an option to union distributions and sets the children.

Parameters:
  • should_union_distribution (bool) – If true, the distribution will be unioned. If false, the distribution will be summed.

  • children (list[Node]) – The children nodes.

Example

>>> from libvcad import pyvcad as pv
>>> radius = 5
>>> sphere1 = pv.Sphere(pv.Vec3(-radius/2, 0, 0), radius, 1)
>>> sphere2 = pv.Sphere(pv.Vec3(radius/2, 0, 0), radius, 1)
>>> union_node = pv.Union(True, [sphere1, sphere2])
  1. __init__(self: pyvcad.pyvcad.Union, k: typing.SupportsFloat, should_union_distribution: bool = False) -> None

Constructor for smooth union.

Parameters:
  • k (float) – The smoothing radius. When k > 0, produces a smooth blend between children.

  • should_union_distribution (bool) – If true, the distribution will be unioned.

Example

>>> from libvcad import pyvcad as pv
>>> sphere1 = pv.Sphere(pv.Vec3(-2, 0, 0), 3, 1)
>>> sphere2 = pv.Sphere(pv.Vec3(2, 0, 0), 3, 1)
>>> smooth_union = pv.Union(1.0, False)
>>> smooth_union.add_child(sphere1)
>>> smooth_union.add_child(sphere2)
  1. __init__(self: pyvcad.pyvcad.Union, k: typing.SupportsFloat, should_union_distribution: bool, children: collections.abc.Sequence[pyvcad.pyvcad.Node]) -> None

Constructor for smooth union with children.

Parameters:
  • k (float) – The smoothing radius. When k > 0, produces a smooth blend between children.

  • should_union_distribution (bool) – If true, the distribution will be unioned.

  • children (list[Node]) – The children nodes.

Example

>>> from libvcad import pyvcad as pv
>>> sphere1 = pv.Sphere(pv.Vec3(-2, 0, 0), 3, 1)
>>> sphere2 = pv.Sphere(pv.Vec3(2, 0, 0), 3, 1)
>>> smooth_union = pv.Union(1.0, False, [sphere1, sphere2])
class pyvcad.BBoxUnion

An n-ary node that represents the union of bounding boxes.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.BBoxUnion) -> None

Default constructor for BBoxUnion.

Example

>>> union_node = pv.BBoxUnion()
  1. __init__(self: pyvcad.pyvcad.BBoxUnion, children: collections.abc.Sequence[pyvcad.pyvcad.Node]) -> None

Constructor that creates a BBoxUnion node with the given list of child nodes.

Parameters:

children (list of Node) – The list of child nodes.

Example

>>> children = [child1, child2]
>>> union_node = pv.BBoxUnion(children)
class pyvcad.Offset

Shifts a child’s signed distance by a constant value. Negative offset moves the surface inward and positive offset moves it outward.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.Offset) -> None

Default constructor with zero offset.

  1. __init__(self: pyvcad.pyvcad.Offset, arg0: typing.SupportsFloat) -> None

Constructor with a specified offset.

Parameters:

offset (double) – The offset to apply to the signed distance.

  1. __init__(self: pyvcad.pyvcad.Offset, arg0: typing.SupportsFloat, arg1: pyvcad.pyvcad.Node) -> None

Constructor with a specified offset and a child node.

Parameters:
  • offset (double) – The offset to apply to the signed distance.

  • child (Node) – The child node.

set_child(self: pyvcad.pyvcad.Offset, child: pyvcad.pyvcad.Node) None

Sets the single child of this node.

class pyvcad.Shell

Computes an inward shell of a child node using a specified thickness.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.Shell, thickness: typing.SupportsFloat) -> None

Constructor with shell thickness. Thickness must be positive.

  1. __init__(self: pyvcad.pyvcad.Shell, thickness: typing.SupportsFloat, child: pyvcad.pyvcad.Node) -> None

Constructor with shell thickness and a child node. Thickness must be positive.

class pyvcad.ConformalMap

A conformal map node that wraps a pattern node onto the surface of a base node. This mapping preserves angles during the transformation. The base node serves as the surface to wrap onto (left child) while the pattern node (right child) is mapped onto this surface.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pyvcad.pyvcad.ConformalMap) -> None

Default constructor. Creates an empty ConformalMap node.

Example

>>> from libvcad import pyvcad as pv
>>> base_surface = pv.Sphere(pv.Vec3(0, 0, 0), 10.0, 1)
>>> pattern = pv.RectPrism(pv.Vec3(-1, -1, -0.2), pv.Vec3(1, 1, 0.2), 2)
>>> conformal = pv.ConformalMap()
>>> conformal.set_left(base_surface)
>>> conformal.set_right(pattern)
  1. __init__(self: pyvcad.pyvcad.ConformalMap, base: pyvcad.pyvcad.Node, pattern: pyvcad.pyvcad.Node) -> None

Constructor that sets the base surface and pattern children.

Parameters:
  • base (std::shared_ptr<Node>) – The base surface node to wrap onto (left child).

  • pattern (std::shared_ptr<Node>) – The pattern node to be wrapped onto the base surface (right child).

Example

>>> from libvcad import pyvcad as pv
>>> base_surface = pv.Sphere(pv.Vec3(0, 0, 0), 10.0, 1)
>>> pattern = pv.RectPrism(pv.Vec3(-1, -1, -0.2), pv.Vec3(1, 1, 0.2), 2)
>>> conformal = pv.ConformalMap(base_surface, pattern)
  1. __init__(self: pyvcad.pyvcad.ConformalMap, base: pyvcad.pyvcad.Node, pattern: pyvcad.pyvcad.Node, ref_dir: pyvcad.pyvcad.Vec3) -> None

Constructor with explicit reference direction.

Parameters:
  • base (std::shared_ptr<Node>) – The base surface node to wrap onto (left child).

  • pattern (std::shared_ptr<Node>) – The pattern node to be wrapped onto the base surface (right child).

  • ref_dir (Vec3) – A reference direction vector used to orient the mapping.

Example

>>> from libvcad import pyvcad as pv
>>> base_surface = pv.Sphere(pv.Vec3(0, 0, 0), 10.0, 1)
>>> pattern = pv.RectPrism(pv.Vec3(-1, -1, -0.2), pv.Vec3(1, 1, 0.2), 2)
>>> ref_direction = pv.Vec3(0, 1, 0)  # Use Y-axis as reference
>>> conformal = pv.ConformalMap(base_surface, pattern, ref_direction)