Tree — composition
Transforms, boolean CSG, and other composition operators.
Transforms and warps
-
class Rotate : public Unary
- #include <rotate.h>
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 following order: roll, yaw, pitch. The rotation is performed around the point (0, 0, 0) by default, but can be changed by specifying a different point in the constructor. To affect a rotation on child geometry, the sample point in evaluate() or material() is transformed by the inverse of the rotation matrix.
Public Functions
-
virtual std::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
See also
-
virtual double evaluate(double x, double y, double z) override
See also
-
virtual std::vector<uint8_t> material_list() override
See also
-
Rotate() = default
Default constructor. Defaults to no rotation.
Constructor with child.
- Parameters:
pitch – Pitch angle in degrees
yaw – Yaw angle in degrees
roll – Roll angle in degrees
around – Point around which the rotation is performed
child – Child node
-
virtual std::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
-
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::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
See also
-
virtual double evaluate(double x, double y, double z) override
See also
-
virtual std::vector<uint8_t> material_list() override
See also
-
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.
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.
-
virtual std::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
-
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::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
See also
-
virtual double evaluate(double x, double y, double z) override
See also
-
virtual std::vector<uint8_t> material_list() override
Returns a list of all the materials used by the node and its children.
- Returns:
A list of all the material IDs used by the node and its children.
-
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.
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.
-
virtual std::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
-
class Offset : public Unary
- #include <offset.h>
Shifts the signed distance reported by its child by a constant offset.
Public Functions
-
virtual std::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
See also
-
virtual double evaluate(double x, double y, double z) override
See also
-
virtual std::vector<uint8_t> material_list() override
See also
-
Offset() = default
Default constructor with zero offset.
-
explicit Offset(double offset)
Constructor with offset.
Constructor with offset and child.
Private Members
-
double m_offset = 0.0
-
virtual std::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
-
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
Clones the node and returns a new instance of the node.
Note
This may be called before or after prepare() is called, however it is always more efficient to call it after. This is because the prepare() function must be called on all clones of the node separately. If you call prepare() first and then clone the node, the clone() operation will copy from memory instead of re-reading from disk.
- Returns:
A new instance of the node
-
virtual std::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
Returns the material distribution at the given point.
- Parameters:
x – The x coordinate of the point to evaluate.
y – The y coordinate of the point to evaluate.
z – The z coordinate of the point to evaluate.
- Returns:
A list of pairs each containing the material ID and the probability distribution of that material.
-
virtual double evaluate(double x, double y, double z) override
Evaluates the node at the given point.
- Parameters:
x – The x coordinate of the point to evaluate.
y – The y coordinate of the point to evaluate.
z – The z coordinate of the point to evaluate.
- Returns:
The distance to the surface at the given point.
-
virtual std::vector<uint8_t> material_list() override
Returns a list of all the materials used by the node and its children.
- Returns:
A list of all the material IDs used by the node and its children.
-
virtual void prepare(const glm::vec3 &voxel_size, double interior_bandwidth, double exterior_bandwidth) override
See also
-
Shell() = default
-
explicit Shell(double thickness)
Constructor with shell thickness. Thickness must be positive.
Constructor with shell thickness and child.
Private Functions
-
void build_subtree()
-
virtual std::shared_ptr<Node> clone() override
-
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 to preserve expected pattern scale without precompute.
Public Functions
-
virtual std::shared_ptr<Node> clone() override
Clones the node and returns a new instance of the node.
Note
This may be called before or after prepare() is called, however it is always more efficient to call it after. This is because the prepare() function must be called on all clones of the node separately. If you call prepare() first and then clone the node, the clone() operation will copy from memory instead of re-reading from disk.
- Returns:
A new instance of the node
-
ConformalMap() = default
-
virtual std::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
Returns the material distribution at the given point.
- Parameters:
x – The x coordinate of the point to evaluate.
y – The y coordinate of the point to evaluate.
z – The z coordinate of the point to evaluate.
- Returns:
A list of pairs each containing the material ID and the probability distribution of that material.
-
virtual double evaluate(double x, double y, double z) override
Evaluates the node at the given point.
- Parameters:
x – The x coordinate of the point to evaluate.
y – The y coordinate of the point to evaluate.
z – The z coordinate of the point to evaluate.
- Returns:
The distance to the surface at the given point.
-
virtual std::vector<uint8_t> material_list() override
Returns a list of all the materials used by the node and its children.
- Returns:
A list of all the material IDs used by the node and its children.
-
virtual void prepare(const glm::vec3 &voxel_size, double interior_bandwidth, double exterior_bandwidth) override
See also
-
inline void setArcScale(float s)
-
inline void setArcScale(float su, float sv)
Private Functions
-
void compute_anchor()
-
virtual std::shared_ptr<Node> clone() override
-
class Map : public Leaf
- #include <map.h>
Public Functions
-
virtual std::shared_ptr<Node> clone() override
Clones the node and returns a new instance of the node.
Note
This may be called before or after prepare() is called, however it is always more efficient to call it after. This is because the prepare() function must be called on all clones of the node separately. If you call prepare() first and then clone the node, the clone() operation will copy from memory instead of re-reading from disk.
- Returns:
A new instance of the node
-
virtual std::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
Returns the material distribution at the given point.
- Parameters:
x – The x coordinate of the point to evaluate.
y – The y coordinate of the point to evaluate.
z – The z coordinate of the point to evaluate.
- Returns:
A list of pairs each containing the material ID and the probability distribution of that material.
-
virtual double evaluate(double x, double y, double z) override
Evaluates the node at the given point.
- Parameters:
x – The x coordinate of the point to evaluate.
y – The y coordinate of the point to evaluate.
z – The z coordinate of the point to evaluate.
- Returns:
The distance to the surface at the given point.
-
Map(const std::string &surface_path, const std::string &closed_mesh_path)
-
virtual std::vector<uint8_t> material_list() override
Returns a list of all the materials used by the node and its children.
- Returns:
A list of all the material IDs used by the node and its children.
Private Members
-
std::shared_ptr<SurfaceParamerterizer> m_paramerterizer
-
virtual std::shared_ptr<Node> clone() override
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::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
See also
-
virtual double evaluate(double x, double y, double z) final
See also
-
virtual std::vector<uint8_t> material_list() override
See also
-
Sum() = default
Default constructor.
-
Sum(double iso_value)
Constructor.
- Parameters:
iso_value – The iso value of the sum.
Constructor.
- Parameters:
iso_value – The iso value of the sum.
children – The children of the sum.
Private Members
-
double m_iso_value = 0.0
-
virtual std::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
-
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::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
See also
Note
Node::tile will tile child distribution in a grid the same way it tiles geometry
-
virtual double evaluate(double x, double y, double z) override
See also
-
virtual std::vector<uint8_t> material_list() override
See also
-
virtual void prepare(const glm::vec3 &voxel_size, double interior_bandwidth, double exterior_bandwidth) override
See also
-
Tile() = default
Default Constructor.
Note
The cell dimensions will be calculated from the child node when prepare is called
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
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
-
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
-
virtual std::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
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. Whenk > 0, the difference uses smooth subtraction to produce rounded transitions.Public Functions
-
Difference() = default
Default constructor.
-
explicit Difference(double k)
Constructor for smooth difference.
- Parameters:
k – The smoothing radius. When k > 0, produces a smooth subtraction.
Constructor for smooth difference with children.
- Parameters:
k – The smoothing radius.
left – The left child node.
right – The right child node.
-
virtual std::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
See also
-
virtual double evaluate(double x, double y, double z) final
See also
-
virtual std::vector<uint8_t> material_list() override
See also
Private Members
-
double m_smooth_k = 0.0
The smoothing radius for smooth difference. 0 = sharp (default).
-
Difference() = default
-
class Intersection : public N_ary
- #include <intersection.h>
Intersection of two or more nodes.
Supports an optional smooth blending radius
k. Whenk > 0, the intersection uses smooth intersection to produce rounded transitions.Public Functions
-
virtual std::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
See also
-
virtual double evaluate(double x, double y, double z) final
See also
Constructor with children.
- Parameters:
intersect_distribution – If true, the distribution will be intersected. If false, the distribution will be summed.
children – The children nodes
-
Intersection(bool intersect_distribution = false)
Default constructor.
Constructor for smooth intersection with children.
- Parameters:
k – The smoothing radius.
intersect_distribution – If true, the distribution will be intersected.
children – The children nodes.
-
Intersection(double k, bool intersect_distribution = false)
Constructor for smooth intersection.
- Parameters:
k – The smoothing radius. When k > 0, produces a smooth blend.
intersect_distribution – If true, the distribution will be intersected.
-
virtual std::vector<uint8_t> material_list() override
See also
-
virtual std::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
-
class Union : public N_ary
- #include <union.h>
A union of two or more nodes.
This is equivalent to the summing of the children.
Supports an optional smooth blending radius
k. Whenk > 0, the union uses a quadratic smooth-min to produce rounded transitions between children.Public Functions
-
virtual std::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
See also
-
virtual double evaluate(double x, double y, double z) final
See also
-
virtual std::vector<uint8_t> material_list() override
See also
-
explicit Union(bool should_union_distribution = false)
Default constructor.
Constructor for smooth union with children.
- Parameters:
k – The smoothing radius.
should_union_distribution – If true, the distribution will be unioned.
children – The children nodes.
-
Union(double k, bool should_union_distribution = false)
Constructor for smooth union.
- Parameters:
k – The smoothing radius. When k > 0, produces a smooth blend between children.
should_union_distribution – If true, the distribution will be unioned.
-
virtual std::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
-
class BBoxUnion : public N_ary
- #include <bbox_union.h>
Public Functions
Trys to add a child to the node, if the node is full then it returns false.
- Parameters:
child – The child to add to the node
- Returns:
True if the child was added, false otherwise
-
BBoxUnion()
-
virtual std::shared_ptr<Node> clone() override
Clones the node and returns a new instance of the node.
Note
This may be called before or after prepare() is called, however it is always more efficient to call it after. This is because the prepare() function must be called on all clones of the node separately. If you call prepare() first and then clone the node, the clone() operation will copy from memory instead of re-reading from disk.
- Returns:
A new instance of the node
-
virtual std::unordered_map<uint8_t, float> distribution(double x, double y, double z) override
Returns the material distribution at the given point.
- Parameters:
x – The x coordinate of the point to evaluate.
y – The y coordinate of the point to evaluate.
z – The z coordinate of the point to evaluate.
- Returns:
A list of pairs each containing the material ID and the probability distribution of that material.
-
virtual double evaluate(double x, double y, double z) override
Evaluates the node at the given point.
- Parameters:
x – The x coordinate of the point to evaluate.
y – The y coordinate of the point to evaluate.
z – The z coordinate of the point to evaluate.
- Returns:
The distance to the surface at the given point.
-
virtual std::vector<uint8_t> material_list() override
Returns a list of all the materials used by the node and its children.
- Returns:
A list of all the material IDs used by the node and its children.
Private Members
-
std::shared_ptr<AABBVCADTree> m_aabb_tree