Tree — base classes
Hierarchy and container nodes used by all geometry/material graphs. Leaf nodes live on Tree — leaf nodes.
- class pyvcad.Node
Base class for all nodes in the tree. NOTE: the VCAD tree is NOT thread-safe. You must use a separate tree for each thread (see Node.clone()).
- __init__(*args, **kwargs)
- attribute_list(self: pyvcad.pyvcad.Node) list[str]
Returns a list of the attributes in use by this node and its children.
- bounding_box(self: pyvcad.pyvcad.Node) tuple[pyvcad.pyvcad.Vec3, pyvcad.pyvcad.Vec3]
Returns the bounding box of the node as a tuple of min and max points.
- clone(self: pyvcad.pyvcad.Node) pyvcad.pyvcad.Node
Clones the node and returns a pointer to the new node.
- evaluate(self: pyvcad.pyvcad.Node, x: SupportsFloat, y: SupportsFloat, z: SupportsFloat) float | None
Evaluates the node at the given point. Returns the distance to the surface at the given point. May return None if point is out of bounds.
- Parameters:
x (double) – The x-coordinate of the point to evaluate.
y (double) – The y-coordinate of the point to evaluate.
z (double) – The z-coordinate of the point to evaluate.
- get_attribute(self: pyvcad.pyvcad.Node, name: str) Attribute
Returns the attribute function for the given attribute name.
- Parameters:
name (str) – The name of the attribute to get.
- get_gradient_epsilon(self: pyvcad.pyvcad.Node) float
Gets the currently configured gradient epsilon.
- gradient(*args, **kwargs)
Overloaded function.
gradient(self: pyvcad.pyvcad.Node, x: typing.SupportsFloat, y: typing.SupportsFloat, z: typing.SupportsFloat) -> pyvcad.pyvcad.Vec3
Returns the gradient of the signed distance field at the given point.
- Parameters:
x (double) – The x-coordinate of the point to evaluate.
y (double) – The y-coordinate of the point to evaluate.
z (double) – The z-coordinate of the point to evaluate.
gradient(self: pyvcad.pyvcad.Node, p: pyvcad.pyvcad.Vec3) -> pyvcad.pyvcad.Vec3
Returns the gradient of the signed distance field at the given point.
- Parameters:
p (Vec3) – The point to evaluate.
- prepare(self: pyvcad.pyvcad.Node, voxel_size: pyvcad.pyvcad.Vec3, bandwidth: SupportsFloat) None
Performs any single-run operations that need to be done before the tree is evaluated.
- Parameters:
voxel_size (vec3) – The size of the voxels.
bandwidth (double) – The bandwidth of the tree we are sampling.
- sample(self: pyvcad.pyvcad.Node, x: SupportsFloat, y: SupportsFloat, z: SupportsFloat) tuple[float | None, AttributeSamples | None]
Samples the node at the given point. Returns a tuple containing the signed distance (or None) and a list of attribute samples.
- Parameters:
x (double) – The x-coordinate of the point to sample.
y (double) – The y-coordinate of the point to sample.
z (double) – The z-coordinate of the point to sample.
- set_attribute(self: pyvcad.pyvcad.Node, name: str, attribute: Attribute) None
Sets an attribute function for the node.
- Parameters:
name (str) – The name of the attribute.
attribute (std::shared_ptr<Attribute>) – The attribute function to set.
- set_gradient_epsilon(self: pyvcad.pyvcad.Node, eps: SupportsFloat) None
Sets the epsilon to use for central difference gradient calculation.
- snap(self: pyvcad.pyvcad.Node, point: pyvcad.pyvcad.Vec3) pyvcad.pyvcad.Vec3
Snaps a given point to the nearest point on the surface.
- class pyvcad.Unary
A node with a single child.
- __init__(*args, **kwargs)
- child(self: pyvcad.pyvcad.Unary) pyvcad.pyvcad.Node
Returns the one and only child of this node.
- set_child(self: pyvcad.pyvcad.Unary, child: pyvcad.pyvcad.Node) None
Sets the one and only child of this node.
- Parameters:
child (Node) – The child node to be set.
- class pyvcad.Binary
A binary node with exactly two children. The children can be added via a constructor or via set_left() and set_right() methods. Children can be queried with left() and right().
- __init__(*args, **kwargs)
- left(self: pyvcad.pyvcad.Binary) pyvcad.pyvcad.Node
Returns the left child of this node.
- right(self: pyvcad.pyvcad.Binary) pyvcad.pyvcad.Node
Returns the right child of this node.
- set_left(self: pyvcad.pyvcad.Binary, left: pyvcad.pyvcad.Node) None
Sets the left child of this node.
- Parameters:
left (Node) – The left child to set for this node.
- set_right(self: pyvcad.pyvcad.Binary, right: pyvcad.pyvcad.Node) None
Sets the right child of this node.
- Parameters:
right (Node) – The right child to set for this node.
- class pyvcad.NAry
A node with an arbitrary number of children.
- __init__(*args, **kwargs)
- add_child(self: pyvcad.pyvcad.NAry, child: pyvcad.pyvcad.Node) bool
Tries to add a child to the node. If the node is full, it returns false.
- Parameters:
child (Node) – The child to add to the node.
- child(self: pyvcad.pyvcad.NAry, index: SupportsInt) pyvcad.pyvcad.Node
Returns the child at the given index.
- Parameters:
index (uint8_t) – The index of the child to return.
- Returns:
The child at the given index.
- Return type:
- children(self: pyvcad.pyvcad.NAry) list[pyvcad.pyvcad.Node]
Returns the list of children for this node.
- num_children(self: pyvcad.pyvcad.NAry) int
Returns the number of children this node has.