Loading...
Searching...
No Matches
ExecIrControllerBuilder Class Reference

Builder class used to register invertible controller computations. More...

#include <controllerBuilder.h>

Public Types

using Callback = ExecIrResult(*)(const VdfContext &)
 The type for forward and inverse controller computation calbacks.
 

Public Member Functions

EXECIR_API ExecIrControllerBuilder (ExecComputationBuilder &self, Callback forwardCallback, Callback inverseCallback)
 Constructs a builder that is used to register computations that implement an invertible controller.
 
template<typename ValueType >
void InvertibleInputAttribute (const TfToken &attributeName)
 Registers an invertible input attribute.
 
template<typename ValueType >
void NonInvertibleInputAttribute (const TfToken &attributeName)
 Registers a non-invertible input attribute.
 
template<typename ValueType >
void InvertibleOutputAttribute (const TfToken &attributeName)
 Registers an invertible output attribute; the output is inverible if invertible is true.
 
template<typename ValueType >
void SwitchAttribute (const TfToken &attributeName)
 Registers a switch attribute.
 
template<typename ValueType >
void PassthroughAttribute (const TfToken &attributeName)
 Registers a passthrough attribute.
 

Detailed Description

Builder class used to register invertible controller computations.

This class can only be used in the context of schema computation registration. The constructor takes the self builder object that is defined by the EXEC_REGISTER_COMPUTATIONS_FOR_SCHEMA macro. The constructor also takes the callbacks that implement the forward and inverse computations for the controller. The client uses member functions to register controller atributes as inputs, outputs, switches, etc. (see the documentation on the corresonding registration methods for details). These registrations, in turn, generate the computation inputs for the callbacks (as documented in the class function documentation), as well as other computations that are required to implement invertible controllers within OpenExec.

Example

// Forward declare forward and inverse functions.
static ExecIrResult _ForwardCompute(const VdfContext &ctx);
static ExecIrResult _InverseCompute(const VdfContext &ctx);
{
auto builder = ExecIrControllerBuilder(
self, _ForwardCompute, _InverseCompute);
// Register one invertible input and one invertible output.
builder.InvertibleInputAttribute(_tokens->input);
builder.InvertibleOutputAttribute(_tokens->output);
}
// The forward compute callback function.
//
// The VdfContext provides values for all inputs. The function is
// responsible for computing all output values, returning the values in a
// map from output name to VtValue.
//
_ForwardCompute(const VdfContext & ctx)
{
// Extract the input value.
const double input = ctx.GetInputValue<double>(_tokens->input);
// Create a map to store the results.
ExecIrResult result;
// Compute and store the output value.
result[_tokens->output] = input + 1.0;
return result;
}
// The inverse compute callback function.
//
// The context provides desired values for all invertible outputs. The
// function is responsible for computing the invertible input values that
// satisfy the desired output values, returning the values in a map from
// invertible input name to VtValue.
//
_InverseCompute(const VdfContext & ctx)
{
// Extract the output value.
const double output = ctx.GetInputValue<double>(_tokens->output);
// Create a map to store the results
ExecIrResult result;
// Compute and store the input value
result[_tokens->input] = output - 1.0;
return result;
}
Builder class used to register invertible controller computations.
This is a space efficient container that mimics the TfHashMap API that uses a vector for storage when...
Definition: denseHashMap.h:41
A context is the parameter bundle passed to callbacks of computations.
Definition: context.h:40
VdfByValueOrConstRef< T > GetInputValue(const TfToken &name) const
Returns a value from the input named name of type T.
Definition: context.h:300
#define EXEC_REGISTER_COMPUTATIONS_FOR_SCHEMA(SchemaType)
Initiates registration of exec computations for the schema SchemaType.

Definition at line 108 of file controllerBuilder.h.

Member Typedef Documentation

◆ Callback

using Callback = ExecIrResult(*)(const VdfContext &)

The type for forward and inverse controller computation calbacks.

Definition at line 112 of file controllerBuilder.h.

Constructor & Destructor Documentation

◆ ExecIrControllerBuilder()

EXECIR_API ExecIrControllerBuilder ( ExecComputationBuilder self,
Callback  forwardCallback,
Callback  inverseCallback 
)

Constructs a builder that is used to register computations that implement an invertible controller.

self is the builder that is defined by EXEC_REGISTER_COMPUTATIONS_FOR_SCHEMA. forwardCallback and inverseCallback are the callbacks that define the forward and inverse computations that implement the controller to be registered by the constructed instance.

Member Function Documentation

◆ InvertibleInputAttribute()

void InvertibleInputAttribute ( const TfToken attributeName)

Registers an invertible input attribute.

  • Invertible input attributes provide input to the forward computation.
  • Invertible input values are produced by the inverse computation.

Definition at line 199 of file controllerBuilder.h.

◆ InvertibleOutputAttribute()

void InvertibleOutputAttribute ( const TfToken attributeName)

Registers an invertible output attribute; the output is inverible if invertible is true.

  • Output attributes produce computed values that are the results of the forward computation and provide input to the inverse computation.

TODO: Non-invertible output attributes are not yet implemented.

Definition at line 226 of file controllerBuilder.h.

◆ NonInvertibleInputAttribute()

void NonInvertibleInputAttribute ( const TfToken attributeName)

Registers a non-invertible input attribute.

  • All input attributes provide input to the forward computation.
  • Non-invertible input attributes also provide input to the inverse computation.

Definition at line 211 of file controllerBuilder.h.

◆ PassthroughAttribute()

void PassthroughAttribute ( const TfToken attributeName)

Registers a passthrough attribute.

  • Passthrough attributes provide input to both the forward and the inverse computation.

Definition at line 283 of file controllerBuilder.h.

◆ SwitchAttribute()

void SwitchAttribute ( const TfToken attributeName)

Registers a switch attribute.

Switch attributes hold values that change the behavior of the forward and inverse computations.

  • Switch attributes provide input to both the forward and the inverse computation.

Definition at line 271 of file controllerBuilder.h.


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