Tree — attribute nodes#

Unary attribute operators (modifier, convolution) on the attribute tree.

class AttributeModifier : public Unary#
#include <attribute_modifier.h>

A unary node that modifies or converts attributes produced by its child tree.

Public Functions

AttributeModifier(const std::shared_ptr<AttributeConverterBase> &converter, std::shared_ptr<Node> child)#

Constructor.

Parameters:
  • converter – The converter logic that modifies samples coming from the child node.

  • child – The child node to modify the attributes of.

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

See also

Node::clone

virtual std::vector<Node::DiagramAttributeArtifact> diagram_attributes() const override#

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

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

virtual std::shared_ptr<Attribute> get_attribute(const std::string &name) override#

This node modifies existing child attributes; it throws std::runtime_error if you attempt to retrieve attributes from it directly.

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

Samples the child node and applies the converter to its attribute samples.

See also

Node::sample

virtual void set_attribute(const std::string &name, const std::shared_ptr<Attribute> &attribute) override#

This node modifies existing child attributes; it throws std::runtime_error if you attempt to set standard attributes directly on it.

Protected Functions

virtual std::vector<std::string> node_attribute_list() override#

Returns the list of output attributes generated by the inner converter.

Private Members

std::shared_ptr<AttributeConverterBase> m_converter#
class Convolve : public Unary#
#include <convolve.h>

A unary node that convolves the attributes of its child node using a defined kernel.

This node intercepts sample() calls to blend/convolve attributes over a local area. The signed distance field (geometry) is passed through unmodified.

Public Functions

size_t cache_capacity() const#

Gets the cache capacity.

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

See also

Node::clone()

Convolve(const std::shared_ptr<Node> &child, const std::vector<std::string> &attributes, const std::shared_ptr<ConvolveKernel> &kernel, const glm::vec3 &physical_radius)#

Constructs a Convolve node.

Parameters:
  • child – The child node containing the attributes to convolve.

  • attributes – The names of the attributes to target. If empty, all valid continuous attributes are targeted.

  • kernel – The convolution kernel (weights and extents).

  • physical_radius – The physical world-space radius (in mm) that the kernel spans along X, Y, and Z.

Convolve(const std::shared_ptr<Node> &child, const std::vector<std::string> &attributes, const std::shared_ptr<ConvolveKernel> &kernel, const glm::vec3 &physical_radius, bool enable_cache)#

Constructs a Convolve node with cache control.

Parameters:
  • child – The child node containing the attributes to convolve.

  • attributes – The names of the attributes to target. If empty, all valid continuous attributes are targeted.

  • kernel – The convolution kernel (weights and extents).

  • physical_radius – The physical world-space radius (in mm) that the kernel spans along X, Y, and Z.

  • enable_cache – Whether to use the LRU cache (defaults to true).

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

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

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

See also

Node::prepare()

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

Computes the convolved attributes at the requested coordinate.

See also

Node::sample()

void set_cache_capacity(size_t capacity)#

Sets the cache capacity.

Parameters:

capacity – Maximum number of node samples to store in the cache.

void set_use_cache(bool enabled)#

Toggles the internal LRU cache.

Parameters:

enabled – True to use the cache, false to sample the child directly every time.

bool use_cache() const#

Gets whether the cache is enabled.

Protected Functions

virtual void prepare_bounding_box() override#

Private Functions

TreeSample get_child_sample(double x, double y, double z, const glm::ivec3 &grid_coord)#

Internal helper to get a sample, either from cache or directly from the child.

Private Members

std::shared_ptr<LRUCache<glm::ivec3, TreeSample>> m_cache#
size_t m_cache_capacity = 100000#
double m_expanded_bandwidth#
std::shared_ptr<ConvolveKernel> m_kernel#
glm::vec3 m_physical_radius#
std::vector<std::string> m_target_attributes#
std::set<std::string> m_target_attributes_set#
bool m_use_cache = true#
glm::vec3 m_voxel_size#
class BoxKernel : public ConvolveKernel#
#include <convolve_kernel.h>

A simple box average kernel where all weights are equal to 1.0 (normalization happens later in the node).

Public Functions

inline explicit BoxKernel(int r)#

Constructor.

Parameters:

r – Radius of the box kernel

inline BoxKernel(int rx, int ry, int rz)#

Constructor.

Parameters:
  • rx – X radius

  • ry – Y radius

  • rz – Z radius

inline virtual int get_radius_x() const override#

Gets the X radius (number of voxels positive and negative from center).

inline virtual int get_radius_y() const override#

Gets the Y radius (number of voxels positive and negative from center).

inline virtual int get_radius_z() const override#

Gets the Z radius (number of voxels positive and negative from center).

inline virtual double get_weight(int i, int j, int k) const override#

Return the weight at the integer coordinate offset (i, j, k) relative to the center of the kernel (0, 0, 0).

Private Members

int m_rx#
int m_ry#
int m_rz#
class ConvolveKernel#
#include <convolve_kernel.h>

Base interface for a convolution kernel used by the Convolve node.

Subclassed by BoxKernel, CustomKernel

Public Functions

virtual int get_radius_x() const = 0#

Gets the X radius (number of voxels positive and negative from center).

virtual int get_radius_y() const = 0#

Gets the Y radius (number of voxels positive and negative from center).

virtual int get_radius_z() const = 0#

Gets the Z radius (number of voxels positive and negative from center).

virtual double get_weight(int i, int j, int k) const = 0#

Return the weight at the integer coordinate offset (i, j, k) relative to the center of the kernel (0, 0, 0).

virtual ~ConvolveKernel() = default#
class CustomKernel : public ConvolveKernel#
#include <convolve_kernel.h>

A custom dense volume kernel initialized usually from Python (numpy array).

Public Functions

inline CustomKernel(const std::vector<double> &weights, int rx, int ry, int rz)#

Constructor.

Parameters:
  • weights – 1D vector representing the flattened 3D array.

  • rx – The half-size (radius) in X (total size = 2*rx + 1)

  • ry – The half-size (radius) in Y

  • rz – The half-size (radius) in Z

inline virtual int get_radius_x() const override#

Gets the X radius (number of voxels positive and negative from center).

inline virtual int get_radius_y() const override#

Gets the Y radius (number of voxels positive and negative from center).

inline virtual int get_radius_z() const override#

Gets the Z radius (number of voxels positive and negative from center).

inline virtual double get_weight(int i, int j, int k) const override#

Return the weight at the integer coordinate offset (i, j, k) relative to the center of the kernel (0, 0, 0).

Private Members

int m_rx#
int m_ry#
int m_rz#
std::vector<double> m_weights#