Tree — material nodes
- class pyvcad.Convolution
A node that applies a discrete convolution to its child node. This can be used with a kernel to apply a filter to design. This include blurring, sharpening, edge detection, and more. See the paper(https://doi.org/10.1016/j.addma.2023.103912) for details.
- static BlendKernel(x: SupportsInt, y: SupportsInt, z: SupportsInt) list[list[list[int]]]
Creates a kernel that averages all values (blends). This means all values are one, including the center value.
- Parameters:
x (int) – The x dimension of the kernel.
y (int) – The y dimension of the kernel.
z (int) – The z dimension of the kernel.
- static PassKernel(x: SupportsInt, y: SupportsInt, z: SupportsInt) list[list[list[int]]]
Creates a kernel that passes all values through. This means all values are zero except for the center value which is one.
- Parameters:
x (int) – The x dimension of the kernel.
y (int) – The y dimension of the kernel.
z (int) – The z dimension of the kernel.
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pyvcad.pyvcad.Convolution, kernel: collections.abc.Sequence[collections.abc.Sequence[collections.abc.Sequence[typing.SupportsInt]]]) -> None
Constructor. Creates a Convolution with a kernel.
- Parameters:
kernel (Convolution::Kernel) – The convolution kernel, a 3D matrix of integers. The kernel must be odd in all dimensions.
__init__(self: pyvcad.pyvcad.Convolution, kernel: collections.abc.Sequence[collections.abc.Sequence[collections.abc.Sequence[typing.SupportsInt]]], child: pyvcad.pyvcad.Node) -> None
Constructor. Creates a Convolution with a kernel and a child node.
- Parameters:
kernel (Convolution::Kernel) – The convolution kernel, a 3D matrix of integers. The kernel must be odd in all dimensions.
child (Node) – The child node.
- class pyvcad.FGrade
A node that applies grading functions to a child. The grading functions are probability density functions that must all sum to 1 for any given point. The functions are evaluated, and the material is chosen based on the discrete probability of the location in space. The syntax for the expressions must follow the same format as the Function class. The node has two modes: Probability mode and Threshold mode. This node is unary and must have a single child. It runs in O(n) time, where n is tokens in the longest expression.
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pyvcad.pyvcad.FGrade, functions: collections.abc.Sequence[str], materials: collections.abc.Sequence[typing.SupportsInt], prob_mode: bool) -> None
Constructor. Creates a FGrade with a list of expressions, corresponding materials, and a mode.
- Parameters:
functions (std::vector<std::string>) – A list of expressions that are probability density functions.
materials (std::vector<uint8_t>) – A list of materials that correspond to the expressions.
prob_mode (bool) – If true, the node runs in probability mode. If false, the node runs in threshold mode.
Example
>>> import pyvcad as pv >>> materials = pv.MaterialDefs('configs/default.json') >>> bar = pv.RectPrism(pv.Vec3(0,0,0), pv.Vec3(100,50,10), materials.id('gray')) >>> root = pv.FGrade(['x/100 + 0.5', '-x/100 + 0.5'], [materials.id('red'), materials.id('blue')], False) >>> root.set_child(bar)
__init__(self: pyvcad.pyvcad.FGrade, functions: collections.abc.Sequence[str], materials: collections.abc.Sequence[typing.SupportsInt], prob_mode: bool, child: pyvcad.pyvcad.Node) -> None
Constructor. Creates a FGrade with a list of expressions, corresponding materials, a mode, and a child node.
- Parameters:
functions (std::vector<std::string>) – A list of expressions that are probability density functions.
materials (std::vector<uint8_t>) – A list of materials that correspond to the expressions.
prob_mode (bool) – If true, the node runs in probability mode. If false, the node runs in threshold mode.
child (Node) – The child node.
Example
>>> import pyvcad as pv >>> materials = pv.MaterialDefs('configs/default.json') >>> bar = pv.RectPrism(pv.Vec3(0,0,0), pv.Vec3(100,50,10), materials.id('gray')) >>> root = pv.FGrade(['x/100 + 0.5', '-x/100 + 0.5'], [materials.id('red'), materials.id('blue')], False, bar)
__init__(self: pyvcad.pyvcad.FGrade, functions: collections.abc.Sequence[collections.abc.Callable[[typing.SupportsFloat, typing.SupportsFloat, typing.SupportsFloat, typing.SupportsFloat, typing.SupportsFloat, typing.SupportsFloat, typing.SupportsFloat, typing.SupportsFloat, typing.SupportsFloat], float]], materials: collections.abc.Sequence[typing.SupportsInt], prob_mode: bool) -> None
Constructor. Creates a FGrade with a list of lambda functions, corresponding materials, and a mode.
- Parameters:
functions (std::vector<std::function<double(double x, double y, double z, double rho, double phic, double r, double theta, double phis)>>) – A list of lambda functions that are volume fraction functions. They should all sum to one for any location in space. The functions must each take three parameters (all vec3): xyz, cylindrical coordinates, and spherical coordinates.
materials (std::vector<uint8_t>) – A list of materials that correspond to the functions.
prob_mode (bool) – If true, the node runs in probability mode. If false, the node runs in threshold mode.
Example
>>> import pyvcad as pv >>> materials = pv.MaterialDefs('configs/default.json') >>> bar = pv.RectPrism(pv.Vec3(0,0,0), pv.Vec3(100,50,10), materials.id('gray')) >>> def func_a(x, y, z, rho, phic, r, theta, phis): ... return x/100 + 0.5 >>> def func_b(x, y, z, rho, phic, r, theta, phis): ... return -x/100 + 0.5 >>> root = pv.FGrade([func_a, func_b], [materials.id('red'), materials.id('blue')], False) >>> root.set_child(bar)
__init__(self: pyvcad.pyvcad.FGrade, functions: collections.abc.Sequence[collections.abc.Callable[[typing.SupportsFloat, typing.SupportsFloat, typing.SupportsFloat, typing.SupportsFloat, typing.SupportsFloat, typing.SupportsFloat, typing.SupportsFloat, typing.SupportsFloat, typing.SupportsFloat], float]], materials: collections.abc.Sequence[typing.SupportsInt], prob_mode: bool, child: pyvcad.pyvcad.Node) -> None
Constructor. Creates a FGrade with a list of lambda functions, corresponding materials, a mode, and a child node.
- Parameters:
functions (List<function<double(double x, double y, double z, double rho, double phic, double r, double theta, double phis)>>) – A list of lambda functions that are volume fraction functions. They should all sum to one for any location in space. The functions must each take parameters: xyz, cylindrical coordinates, and spherical coordinates.
materials (List<uint8_t>) – A list of materials that correspond to the functions.
prob_mode (bool) – If true, the node runs in probability mode. If false, the node runs in threshold mode.
child (Node) – The child node.
Example
>>> import pyvcad as pv >>> materials = pv.MaterialDefs('configs/default.json') >>> bar = pv.RectPrism(pv.Vec3(0,0,0), pv.Vec3(100,50,10), materials.id('gray')) >>> def func_a(x, y, z, rho, phic, r, theta, phis, d): ... return x/100 + 0.5 >>> def func_b(x, y, z, rho, phic, r, theta, phis, d): ... return -x/100 + 0.5 >>> root = pv.FGrade([func_a, func_b], [materials.id('red'), materials.id('blue')], False, bar)
- class pyvcad.Blend
A node that blends the material distributions of its child node over a specified radius.
- __init__(*args, **kwargs)
Overloaded function.
__init__(self: pyvcad.pyvcad.Blend, radius: typing.SupportsFloat) -> None
Constructor. Creates a Blend with a specified radius.
- Parameters:
radius (double) – The radius over which to blend the material distributions.
__init__(self: pyvcad.pyvcad.Blend, radius: typing.SupportsFloat, child: pyvcad.pyvcad.Node) -> None
Constructor. Creates a Blend with a specified radius and a child node.
- Parameters:
radius (double) – The radius over which to blend the material distributions.
child (Node) – The child node.