|
HDK
|
#include <controllerBuilder.h>
Public Types | |
| using | Callback = ExecIrResult(*)(const VdfContext &) |
| The type for forward and inverse controller computation calbacks. More... | |
Public Member Functions | |
| EXECIR_API | ExecIrControllerBuilder (ExecComputationBuilder &self, Callback forwardCallback, Callback inverseCallback) |
| template<typename ValueType > | |
| void | InvertibleInputAttribute (const TfToken &attributeName) |
| template<typename ValueType > | |
| void | NonInvertibleInputAttribute (const TfToken &attributeName) |
| template<typename ValueType > | |
| void | InvertibleOutputAttribute (const TfToken &attributeName) |
| template<typename ValueType > | |
| void | SwitchAttribute (const TfToken &attributeName) |
| template<typename ValueType > | |
| void | PassthroughAttribute (const TfToken &attributeName) |
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.
```cpp
// Forward declare forward and inverse functions. static ExecIrResult _ForwardCompute(const VdfContext &ctx); static ExecIrResult _InverseCompute(const VdfContext &ctx);
EXEC_REGISTER_COMPUTATIONS_FOR_SCHEMA(MyAddOneController) { 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. // static ExecIrResult _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. // static ExecIrResult _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; } ```
Definition at line 108 of file controllerBuilder.h.
| using ExecIrControllerBuilder::Callback = ExecIrResult(*)(const VdfContext &) |
The type for forward and inverse controller computation calbacks.
Definition at line 112 of file controllerBuilder.h.
| EXECIR_API ExecIrControllerBuilder::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.
| void ExecIrControllerBuilder::InvertibleInputAttribute | ( | const TfToken & | attributeName | ) |
Registers an invertible input attribute.
Definition at line 199 of file controllerBuilder.h.
| void ExecIrControllerBuilder::InvertibleOutputAttribute | ( | const TfToken & | attributeName | ) |
Registers an invertible output attribute; the output is inverible if invertible is true.
TODO: Non-invertible output attributes are not yet implemented.
Definition at line 226 of file controllerBuilder.h.
| void ExecIrControllerBuilder::NonInvertibleInputAttribute | ( | const TfToken & | attributeName | ) |
Registers a non-invertible input attribute.
Definition at line 211 of file controllerBuilder.h.
| void ExecIrControllerBuilder::PassthroughAttribute | ( | const TfToken & | attributeName | ) |
Registers a passthrough attribute.
Definition at line 283 of file controllerBuilder.h.
| void ExecIrControllerBuilder::SwitchAttribute | ( | const TfToken & | attributeName | ) |
Registers a switch attribute.
Switch attributes hold values that change the behavior of the forward and inverse computations.
Definition at line 271 of file controllerBuilder.h.