Rumba C++ SDK
maquina::WeightedComponent Class Reference

This class is a helper to iterate over a geometry component, with an weight per component element. More...

#include <WeightedComponent.h>

Classes

class  Iterator
 The component iterator. More...
 

Public Member Functions

 WeightedComponent (const Points &inputGeometry, const char *weights_name, float weight, Shape::Topology topology)
 Build a WeightedComponent object using a points geometry with an optional weight mask. More...
 
 WeightedComponent (const Points &inputGeometry, float weight)
 Build a WeightedComponent object from a geometry. More...
 
 WeightedComponent (const SparseBufferConstFloat &weights, float weight)
 Build a WeightedComponent object from a weight mask. More...
 
bool has_weights () const
 
Iterator begin () const
 The begin iterator. More...
 
Iterator end () const
 The end iterator. More...
 
uint32_t size () const
 Return the number of component element to iterate. More...
 

Detailed Description

This class is a helper to iterate over a geometry component, with an weight per component element.

Using the same WeightedComponent interface, it is possible to iterate over the whole component or a subset of component elements, using an index and a weight.

// This sample code shows how to write a simple vertex deformation node using a global weight and per vertex optional weights
// Get the input geometry
const Points inputGeometry(ctx.value(Dep_inputGeometry));
const auto &points = points_in.span();
// Get the global deformer weight
const float weight = ctx.as_float(Dep_weight);
// Get the weights attribute name to use
const std::string &weights_name = ctx.as_string(Dep_weights_name);
// Build a component iterator
const WeightedComponent component(inputGeometry, weights_name.c_str(), weight, Shape::Topology::vertex);
for(const auto &ite : component)
{
// The point index
const uint32_t index = ite.first;
// The point weight
const float weight = ite.second;
// The point
const Imath::V3f &p = points[index];
// Do some computation with p and weight ....
}

Constructor & Destructor Documentation

◆ WeightedComponent() [1/3]

maquina::WeightedComponent::WeightedComponent ( const Points inputGeometry,
const char *  weights_name,
float  weight,
Shape::Topology  topology 
)
inline

Build a WeightedComponent object using a points geometry with an optional weight mask.

Parameters
inputGeometryThe input geometry with the component to iterator.
weights_nameThe optional weight attribute name to use for the iteration. Set an empty string to iterate the whole component.
weightThe global weight, which will multiply the optional per element weight.
topologyThe components type to iterate.

◆ WeightedComponent() [2/3]

maquina::WeightedComponent::WeightedComponent ( const Points inputGeometry,
float  weight 
)
inline

Build a WeightedComponent object from a geometry.

Parameters
inputGeometryThe input geometry with the component to iterator.
weightThe global weight, which will multiply the optional per element weight.

◆ WeightedComponent() [3/3]

maquina::WeightedComponent::WeightedComponent ( const SparseBufferConstFloat weights,
float  weight 
)
inline

Build a WeightedComponent object from a weight mask.

Parameters
weightsThe weight mask to use for the iteration.
weightThe global weight, which will multiply the per element weight.

Member Function Documentation

◆ begin()

Iterator maquina::WeightedComponent::begin ( ) const
inline

The begin iterator.

◆ end()

Iterator maquina::WeightedComponent::end ( ) const
inline

The end iterator.

◆ has_weights()

bool maquina::WeightedComponent::has_weights ( ) const
inline

◆ size()

uint32_t maquina::WeightedComponent::size ( ) const
inline

Return the number of component element to iterate.


The documentation for this class was generated from the following file: