Geometric Primitive Nodes - MacCurdyLab/OpenVCAD-Public GitHub Wiki

Overview

In the OpenVCAD tree, leaf nodes are always geometric primitives. A geometric primitive an a node type that defines geometry. All geometric primitives have parameters that define their geometry and a material ID.


Function

The function node is a geometric primitive that allows the user to specify a shape using an expression. The user defined expression should evaluate as a zero-bounded iso-surface. For example the equation of a sphere would be expressed as x^2 + y^2 + z^2 - R^2. When evaluated, OpenVCAD assumes that the inside of the surface is less than or equal to the expression. Therefore it is necessary to convert all expressions to this form.

Note: Boolean operators such as ==, <, or <= can be used in expressions to classify geometry. However, when visualized using iso-surface mode, the objects will be rendered poorly.

OpenVCAD supports numerous operators in its expressions. For a full list of support operators and constants see this documentation.

Syntax

function("expression", "material_name");, where the expression is a string surrounded by quotes in the form above and the material id corresponds to a saved ID.

Examples

function("x^2 + y^2 + z^2 - 4^2", "red"); draws a sphere with radius of 4. function("(x^2 + y^2 + z^2 + 3^2 - 2^2)^2 - 4(3)^2(x^2 + y^2)", "blue"); draws a torus with outer radius 3 and an inner ring radius of 2.


Sphere

The sphere node defines the geometry of a sphere centered at (0, 0, 0).

Syntax

sphere(radius, "material_name");, where radius is r and the material id corresponds to a saved ID.

Examples

sphere(3, "blue"); draws a sphere with radius 3. sphere(10, "red"); draws a sphere with radius 10.


Rectangular Prism

The rectangular prism node has two forms rectprism and cube. The former draws a rectangular prism by specifying each side length. The latter is a shorthand that draws a symmetric rectangular prism. Both are centered at (0, 0, 0)

Syntax

rectprism(x_length, y_length, z_length, "material_name");, where the x,y, & z lengths are the side lengths, and the material id corresponds to a saved ID.

cube(side_length, "material_name");, where side length is used for all sides.

Examples

rectprism(3,6,10, "red") draws a rectangular prism with side lengths of 3,6, and 10 using material 1.


Strut Node

The strut node is a geometric primitive that draws a strut. A strut is a cylinder with rounded caps at each end. Struts are drawn from points A to B. The radius of the strut is specified by a parameter. A blend factor can also be used to control how the shape is blended in a scalar field. The lower the blend parameter, the more the strut will be blended into the surrounding geometry. Multiple struts can be combined with the sum node to create organic lattice structures.

See the Lattice Structures page for more information on lattice structures in OpenVCAD.

Syntax

strut((x, y, z), (x, y, z), radius, blend, "material_name");, where A and B are the start and end points of the strut, radius is the radius of the strut, blend is the blend factor, and the material id corresponds to a saved ID.

Examples

strut((0, 0, 0), (0, 0, 10), 1, 1000, "red"); draws a strut from (0, 0, 0) to (0, 0, 10) with a radius of 1 and a high (non-globby) blend factor. strut((0, 0, 0), (0, 0, 10), 1, 5, "red"); draws a strut from (0, 0, 0) to (0, 0, 10) with a radius of 1 and a low (globby) blend factor.


Strutmesh Node

The strutmesh node is a geometric primitive that draws a strutmesh. A strutmesh is a lattice of struts generated from a mesh. Struts are drawn from points A to B. The radius of the strut is specified by a parameter. A blend factor can also be used to control how the shape is blended in a scalar field. The lower the blend parameter, the more the strut will be blended into the surrounding geometry. See the Lattice Structures page for more information on lattice structures in OpenVCAD and an example.