Tree — composition#

Transforms, boolean CSG, and other composition operators.

Transforms and warps#

class Identity : public Unary#
#include <identity.h>

A pass-through identity node that implements no transformations or operations of its own.

This node operates identically to the base Unary node. Its primary use case is to act as an attachment point for AttributeModifiers without affecting the global coordinate space of the attributes, which is useful when its child node contains an arbitrary transformation.

Public Functions

virtual std::shared_ptr<Node> clone() final#

See also

Node::clone()

inline virtual Node::DiagramFamily diagram_family() const override#

inline virtual std::string diagram_label() const override#

Identity() = default#

Default constructor.

explicit Identity(const std::shared_ptr<Node> &child)#

Constructor with child.

Parameters:

child – The child node

class Rotate : public Unary#
#include <rotate.h>

Rotates a child node around the child’s bounding box center.

The rotation is specified by pitch, yaw, and roll (Euler angles in degrees).

The rotation order is roll, then yaw, then pitch. The rotation center is the child’s bounding box center. This is available before prepare() so bounding_box() is safe before prepare(), but you must still call prepare() before evaluate() or sample(). To apply the rotation, the sample point in evaluate() and sample() is transformed by the inverse of the rotation matrix around that center.

Public Functions

virtual std::shared_ptr<Node> clone() final#

See also

Node::clone

inline virtual Node::DiagramFamily diagram_family() const override#

inline virtual std::string diagram_label() const override#

virtual std::optional<double> evaluate(double x, double y, double z) final#

See also

Node::evaluate

Rotate() = default#

Default constructor. Defaults to no rotation.

Rotate(double pitch, double yaw, double roll)#

Constructor.

Parameters:
  • pitch – Pitch angle in degrees

  • yaw – Yaw angle in degrees

  • roll – Roll angle in degrees

Rotate(double pitch, double yaw, double roll, const std::shared_ptr<Node> &child)#

Constructor with child.

Parameters:
  • pitch – Pitch angle in degrees

  • yaw – Yaw angle in degrees

  • roll – Roll angle in degrees

  • child – Child node

Rotate(glm::vec3 rotation_angles)#

Constructor.

Parameters:

rotation_angles – Euler angles in degrees (pitch, yaw, roll)

Rotate(glm::vec3 rotation_angles, const std::shared_ptr<Node> &child)#

Constructor with child.

Parameters:
  • rotation_angles – Euler angles in degrees (pitch, yaw, roll)

  • child – Child node

virtual TreeSample sample(double x, double y, double z) final#

See also

Node::sample

Private Functions

virtual void prepare_bounding_box() override#

void set_rotation(double pitch, double yaw, double roll)#

Private Members

glm::vec3 m_around = glm::vec3(0.0f, 0.0f, 0.0f)#

Point around which the rotation is performed.

glm::quat m_inverse_rotation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f)#

Inverse rotation quaternion.

glm::quat m_rotation = glm::quat(1.0f, 0.0f, 0.0f, 0.0f)#

Rotation quaternion.

class Scale : public Unary#
#include <scale.h>

Scale a child by a factor in each dimension.

This node is unary, therefore can only have one child.

The Scale class is a node that scales a node by a factor in each dimension. This node is unary, therefore can only have one child. The scale is actually applied when evaluate() is called and performs the inverse of the scaling on the supplied point.

Public Functions

virtual std::shared_ptr<Node> clone() final#

See also

Node::clone()

inline virtual Node::DiagramFamily diagram_family() const override#

inline virtual std::string diagram_label() const override#

virtual std::optional<double> evaluate(double x, double y, double z) final#

See also

Node::evaluate()

virtual TreeSample sample(double x, double y, double z) final#

See also

Node::sample()

Scale() = default#

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

Scale(double x, double y, double z)#

Constructor.

Sets the scale to the supplied values.

Parameters:
  • x – The scale in the x dimension.

  • y – The scale in the y dimension.

  • z – The scale in the z dimension.

Scale(double x, double y, double z, const std::shared_ptr<Node> &child)#

Constructor with child.

Sets the scale to the supplied values.

Parameters:
  • x – The scale in the x dimension.

  • y – The scale in the y dimension.

  • z – The scale in the z dimension.

  • child – The child node.

Private Functions

virtual void prepare_bounding_box() override#

Private Members

double m_x = 1.0#

The scale in the x dimension.

double m_y = 1.0#

The scale in the y dimension.

double m_z = 1.0#

The scale in the z dimension.

class Translate : public Unary#
#include <translate.h>

Translate a child in cartesian space by a given amount.

This node is unary, so it may only have one child.

This node performs the inverse translation on the coordinates sampled in material() and evaluate().

Public Functions

virtual std::shared_ptr<Node> clone() final#

See also

Node::clone()

inline virtual Node::DiagramFamily diagram_family() const override#

inline virtual std::string diagram_label() const override#

virtual std::optional<double> evaluate(double x, double y, double z) final#

See also

Node::evaluate()

virtual TreeSample sample(double x, double y, double z) final#

See also

Node::sample()

Translate() = default#

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

Translate(double x, double y, double z)#

Constructor.

Sets the translation to the given values.

Parameters:
  • x – The amount to translate in the x direction.

  • y – The amount to translate in the y direction.

  • z – The amount to translate in the z direction.

Translate(double x, double y, double z, const std::shared_ptr<Node> &child)#

Constructor.

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

Parameters:
  • x – The amount to translate in the x direction.

  • y – The amount to translate in the y direction.

  • z – The amount to translate in the z direction.

  • child – The child to set.

Private Functions

virtual void prepare_bounding_box() override#

Private Members

double m_x = 0#

The amount to translate in the x direction.

double m_y = 0#

The amount to translate in the y direction.

double m_z = 0#

The amount to translate in the z direction.

class Offset : public Unary#
#include <offset.h>

Shifts the signed distance reported by its child by a constant offset.

Public Functions

virtual std::shared_ptr<Node> clone() override#

See also

Node::clone()

inline virtual Node::DiagramFamily diagram_family() const override#

inline virtual std::string diagram_label() const override#

virtual std::optional<double> evaluate(double x, double y, double z) final#

See also

Node::evaluate()

Offset() = default#

Default constructor with zero offset.

explicit Offset(double offset)#

Constructor with offset.

Offset(double offset, const std::shared_ptr<Node> &child)#

Constructor with offset and child.

virtual void prepare(const glm::vec3 &voxel_size, double bandwidth) final#

See also

Node::prepare()

virtual void prepare_bounding_box() override#

virtual TreeSample sample(double x, double y, double z) override#

See also

Node::sample()

Private Members

double m_offset = 0.0#
class Shell : public Unary#
#include <shell.h>

Computes an inward shell of a child node by subtracting an inward offset from the original.

The shell is obtained as Difference(child, Offset(child)).

Public Functions

virtual std::shared_ptr<Node> clone() override#

See also

Node::clone()

inline virtual Node::DiagramFamily diagram_family() const override#

inline virtual std::string diagram_label() const override#

virtual std::optional<double> evaluate(double x, double y, double z) final#

See also

Node::evaluate()

virtual void prepare(const glm::vec3 &voxel_size, double bandwidth) final#

See also

Node::prepare()

virtual void prepare_bounding_box() override#

virtual Node::TreeSample sample(double x, double y, double z) final#

See also

Node::sample()

Shell() = default#
explicit Shell(double thickness)#

Constructor with shell thickness. Thickness must be positive.

Shell(double thickness, const std::shared_ptr<Node> &child)#

Constructor with shell thickness and child.

Private Functions

void build_subtree()#

Private Members

std::shared_ptr<Node> m_shell_diff#
double m_thickness = 0.0#
class ConformalMap : public Binary#
#include <conformal_map.h>

Maps a pattern node onto the surface of a base node by warping coordinates.

Builds a local frame from the base surface, transports the anchor frame to the query by shortest rotation, and computes (u,v) from a rotation vector (axis*angle). Angle->length is auto-calibrated at the anchor during prepare() to preserve expected pattern scale without precompute.

Public Functions

virtual std::shared_ptr<Node> clone() override#

See also

Node::clone()

ConformalMap() = default#
ConformalMap(const std::shared_ptr<Node> &base, const std::shared_ptr<Node> &pattern)#
ConformalMap(const std::shared_ptr<Node> &base, const std::shared_ptr<Node> &pattern, const glm::vec3 &ref_dir)#
inline virtual std::vector<Node::DiagramChildLink> diagram_child_links() const override#

inline virtual Node::DiagramFamily diagram_family() const override#

inline virtual std::string diagram_label() const override#

virtual std::optional<double> evaluate(double x, double y, double z) override#

See also

Node::evaluate()

virtual void prepare(const glm::vec3 &voxel_size, double bandwidth) override#

See also

Node::prepare()

virtual void prepare_bounding_box() override#

virtual Node::TreeSample sample(double x, double y, double z) override#

See also

Node::sample()

inline void setArcScale(float s)#

Set angle->length scale (units per radian) uniformly.

Parameters:

s – The arc scale to apply to both U and V patterns.

inline void setArcScale(float su, float sv)#

Set angle->length scale (units per radian) separately.

Parameters:
  • su – The arc scale for U.

  • sv – The arc scale for V.

Private Functions

void compute_anchor()#
glm::vec3 map_to_pattern_coords(double x, double y, double z) const#

Private Members

glm::vec3 m_anchor = {0, 0, 0}#
float m_arc_scale_u = 1.0f#
float m_arc_scale_v = 1.0f#
glm::vec3 m_Na = {0, 0, 1}#
glm::vec3 m_ref_dir = {0, 0, 1}#
glm::vec3 m_Ua = {1, 0, 0}#
glm::vec3 m_Va = {0, 1, 0}#
class Map : public Leaf#
#include <map.h>

Maps an existing object onto a parameterizer coordinate system.

Public Functions

virtual std::shared_ptr<Node> clone() override#

See also

Node::clone()

inline virtual Node::DiagramFamily diagram_family() const override#

inline virtual std::string diagram_label() const override#

virtual std::optional<double> evaluate(double x, double y, double z) override#

See also

Node::evaluate()

Map(const std::string &surface_path, const std::string &closed_mesh_path)#
virtual void prepare_bounding_box() override#

virtual TreeSample sample(double x, double y, double z) override#

See also

Node::sample()

Private Members

std::shared_ptr<BBoxUnion> m_bbox_union#
std::shared_ptr<SurfaceParamerterizer> m_paramerterizer#

N-ary composition#

class Sum : public N_ary#
#include <sum.h>

A sum node.

The sum is taken as the sum of all child SDFs.

Public Functions

virtual std::shared_ptr<Node> clone() final#

See also

Node::clone()

inline virtual Node::DiagramFamily diagram_family() const override#

inline virtual std::string diagram_label() const override#

virtual std::optional<double> evaluate(double x, double y, double z) final#

See also

Node::evaluate()

virtual TreeSample sample(double x, double y, double z) final#

See also

Node::sample()

Sum() = default#

Default constructor.

Sum(double iso_value)#

Constructor.

Parameters:

iso_value – The iso value of the sum.

Sum(double iso_value, const std::vector<std::shared_ptr<Node>> &children)#

Constructor.

Parameters:
  • iso_value – The iso value of the sum.

  • children – The children of the sum.

Private Functions

virtual void prepare_bounding_box() override#

Private Members

double m_iso_value = 0.0#
class Tile : public Unary#
#include <tile.h>

A tile is a unary operator that repeats a geometry as a pattern in a grid.

Public Functions

virtual std::shared_ptr<Node> clone() final#

See also

Node::clone

inline virtual Node::DiagramFamily diagram_family() const override#

inline virtual std::string diagram_label() const override#

virtual std::optional<double> evaluate(double x, double y, double z) final#

See also

Node::evaluate

virtual void prepare(const glm::vec3 &voxel_size, double bandwidth) final#

See also

Node::prepare

virtual Node::TreeSample sample(double x, double y, double z) final#

See also

Node::sample()

Tile() = default#

Default Constructor.

Note

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

Tile(const std::shared_ptr<Node> &child)#

Constructor.

Note

The cell dimensions will be calculated from the child node

Parameters:

child – The child node

Tile(double cell_x, double cell_y, double cell_z)#

Constructor.

Note

The child node’s size will be ignored and the supplied cell dimensions will be used instead

Parameters:
  • cell_x – The x dimension of a cell the grid

  • cell_y – The y dimension of a cell the grid

  • cell_z – The z dimension of a cell the grid

Tile(double cell_x, double cell_y, double cell_z, const std::shared_ptr<Node> &child)#

Constructor.

Parameters:
  • cell_x – The x dimension of a cell the grid

  • cell_y – The y dimension of a cell the grid

  • cell_z – The z dimension of a cell the grid

  • child – The child node

Private Functions

virtual void prepare_bounding_box() override#
std::tuple<double, double, double> world_to_cell_coords(double x, double y, double z) const#

Converts world coordinates to cell coordinates.

This takes the modulus of the world coordinates

Parameters:
  • x – coord in world space

  • y – coord in world space

  • z – coord in world space

Returns:

a tuple of x,y,z coordinates in cell space

Private Members

double m_cell_x = -1#

The x dimension of a cell the grid.

double m_cell_y = -1#

The y dimension of a cell the grid.

double m_cell_z = -1#

The z dimension of a cell the grid.

Boolean CSG#

class Difference : public Binary#
#include <difference.h>

A difference binary node.

The difference is taken as the left child minus the right child.

Supports an optional smooth blending radius k. When k > 0, the difference uses smooth subtraction to produce rounded transitions.

Public Functions

virtual std::shared_ptr<Node> clone() final#

See also

Node::clone()

inline virtual std::vector<Node::DiagramChildLink> diagram_child_links() const override#

inline virtual Node::DiagramFamily diagram_family() const override#

inline virtual std::string diagram_label() const override#

Difference() = default#

Default constructor.

Difference(const std::shared_ptr<Node> &left, const std::shared_ptr<Node> &right)#
explicit Difference(double k)#

Constructor for smooth difference.

Parameters:

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

Difference(double k, const std::shared_ptr<Node> &left, const std::shared_ptr<Node> &right)#

Constructor for smooth difference with children.

Parameters:
  • k – The smoothing radius.

  • left – The left child node.

  • right – The right child node.

virtual std::optional<double> evaluate(double x, double y, double z) final#

See also

Node::evaluate()

virtual TreeSample sample(double x, double y, double z) final#

See also

Node::sample()

Private Functions

virtual void prepare_bounding_box() override#

Private Members

double m_smooth_k = 0.0#

The smoothing radius for smooth difference. 0 = sharp (default).

Private Static Functions

static std::optional<double> DifferenceSDFImpl(std::optional<double> lhs, std::optional<double> rhs, double smooth_k)#
class Intersection : public N_ary#
#include <intersection.h>

Intersection of two or more nodes.

Supports an optional smooth blending radius k. When k > 0, the intersection uses smooth intersection to produce rounded transitions.

Public Functions

virtual std::shared_ptr<Node> clone() final#

See also

Node::clone()

inline virtual Node::DiagramFamily diagram_family() const override#

inline virtual std::string diagram_label() const override#

virtual std::optional<double> evaluate(double x, double y, double z) final#

See also

Node::evaluate()

Intersection()#

Default constructor.

Intersection(const std::shared_ptr<Node> &lhs, const std::shared_ptr<Node> &rhs)#

Constructor with children.

Parameters:
  • lhs – Left child node

  • rhs – Right child node

explicit Intersection(double k)#

Constructor for smooth intersection.

Parameters:

k – The smoothing radius. When k > 0, produces a smooth blend.

Intersection(double k, const std::vector<std::shared_ptr<Node>> &children)#

Constructor for smooth intersection with children.

Parameters:
  • k – The smoothing radius.

  • children – The children nodes.

virtual TreeSample sample(double x, double y, double z) final#

See also

Node::sample()

Private Functions

virtual void prepare_bounding_box() final#

Private Members

double m_smooth_k = 0.0#

The smoothing radius for smooth intersection. 0 = sharp (default).

class BBoxIntersection : public N_ary#
#include <bbox_intersection.h>

An accelerated n-ary boolean intersection node utilizing an internal Axis-Aligned Bounding Box (AABB) tree.

This node drastically improves performance when sampling intersections of many spatially distinct children by only evaluating children whose bounding boxes overlap the sample point.

Public Functions

virtual bool addChild(std::shared_ptr<Node> child) override#

BBoxIntersection()#
BBoxIntersection(std::vector<std::shared_ptr<Node>> children)#
virtual std::shared_ptr<Node> clone() override#

See also

Node::clone()

inline virtual Node::DiagramFamily diagram_family() const override#

inline virtual std::string diagram_label() const override#

virtual std::optional<double> evaluate(double x, double y, double z) override#

See also

Node::evaluate()

virtual void prepare(const glm::vec3 &voxel_size, double bandwidth) override#

See also

Node::prepare()

virtual void prepare_bounding_box() override#

virtual TreeSample sample(double x, double y, double z) override#

See also

Node::sample()

Private Members

std::shared_ptr<AABBVCADTree> m_aabb_tree#
double m_bandwidth = 1.0#
std::unordered_map<VCADNodeBBoxPrimitive::Id, size_t> m_node_added_order#
class Union : public N_ary#
#include <union.h>

Supports an optional smooth blending radius k. When k > 0, the union uses a quadratic smooth-min to produce rounded transitions between children.

Public Functions

virtual std::shared_ptr<Node> clone() final#

See also

Node::clone()

inline virtual Node::DiagramFamily diagram_family() const override#

inline virtual std::string diagram_label() const override#

virtual std::optional<double> evaluate(double x, double y, double z) final#

See also

Node::evaluate()

virtual TreeSample sample(double x, double y, double z) final#

See also

Node::sample()

Union()#

Default constructor.

Union(const std::shared_ptr<Node> &lhs, const std::shared_ptr<Node> &rhs)#

Constructor with children.

Parameters:
  • lhs – Left child node

  • rhs – Right child node

explicit Union(double k)#

Constructor for smooth union.

Parameters:

k – The smoothing radius. When k > 0, produces a smooth blend between children.

Union(double k, const std::vector<std::shared_ptr<Node>> &children)#

Constructor for smooth union with children.

Parameters:
  • k – The smoothing radius.

  • children – The children nodes.

Private Functions

virtual void prepare_bounding_box() final#

Private Members

double m_smooth_k = 0.0#

The smoothing radius for smooth union. 0 = sharp (default).

class BBoxUnion : public N_ary#
#include <bbox_union.h>

An accelerated n-ary boolean union node utilizing an internal Axis-Aligned Bounding Box (AABB) tree.

This node drastically improves performance when sampling unions of many spatially distinct children by only evaluating children whose bounding boxes overlap the sample point.

Public Functions

virtual bool addChild(std::shared_ptr<Node> child) override#

BBoxUnion()#
BBoxUnion(std::vector<std::shared_ptr<Node>> children)#
virtual std::shared_ptr<Node> clone() override#

See also

Node::clone()

inline virtual Node::DiagramFamily diagram_family() const override#

inline virtual std::string diagram_label() const override#

virtual std::optional<double> evaluate(double x, double y, double z) override#

See also

Node::evaluate()

virtual void prepare(const glm::vec3 &voxel_size, double bandwidth) override#

See also

Node::prepare()

virtual void prepare_bounding_box() override#

virtual TreeSample sample(double x, double y, double z) override#

See also

Node::sample()

Private Members

std::shared_ptr<AABBVCADTree> m_aabb_tree#
double m_bandwidth = 1.0#
std::unordered_map<VCADNodeBBoxPrimitive::Id, size_t> m_node_added_order#