HDK
|
#include <CVEX_Context.h>
Static Public Member Functions | |
static void | clearAllFunctions () |
static void | clearFunction (const UT_StringRef &fn_name) |
Removes the given function from the CVEX context. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from UT_NonCopyableNS::UT_NonCopyable | |
UT_NonCopyable ()=default | |
~UT_NonCopyable ()=default | |
UT_NonCopyable (const UT_NonCopyable &)=delete | |
UT_NonCopyable & | operator= (const UT_NonCopyable &)=delete |
Call VEX from C++.
The CVEX_Context class provides the main interface to let C++ code call VEX to perform computations. This allows users to modify algorithms by performing computations in VEX.
Definition at line 203 of file CVEX_Context.h.
CVEX_ContextT< PREC >::CVEX_ContextT | ( | ) |
CVEX_ContextT< PREC >::~CVEX_ContextT | ( | ) |
bool CVEX_ContextT< PREC >::addConstantInput | ( | const UT_StringHolder & | name, |
CVEX_Type | type, | ||
void * | data, | ||
int | array_size | ||
) |
Adds a constant input. You should still maintain the reference but the data may be constant folded into the assemble, so the values must be set ahead of time and possibly will not update if you change the original.
bool CVEX_ContextT< PREC >::addConstantInput | ( | const UT_StringHolder & | name, |
CVEX_StringArray & | strings | ||
) |
bool CVEX_ContextT< PREC >::addConstantInput | ( | const UT_StringHolder & | name, |
UT_PackedArrayOfArrays< VEXint< PREC > > & | intdata | ||
) |
Add Constant Integer 32 Arrays.
bool CVEX_ContextT< PREC >::addInput | ( | const UT_StringHolder & | name, |
CVEX_Type | type, | ||
bool | varying | ||
) |
Add possible input parameters to the function. These are parameters whose values are overridden by values you pass in. If the user's VEX function has these parameters the C++ code should assign the values after calling load(), but before calling run().
Calling this version of addInput() allows you to defer computing the value of the variable until you know whether it will actually be used by the VEX function.
bool CVEX_ContextT< PREC >::addInput | ( | const UT_StringHolder & | name, |
CVEX_Type | type, | ||
void * | data, | ||
int | array_size | ||
) |
If you know the value beforehand, you can add the symbol and it's value at the same time. Note: The data is referenced, not copied, so keep it live until after run() has been called.
bool CVEX_ContextT< PREC >::addInput | ( | const UT_StringHolder & | name, |
CVEX_StringArray & | strings | ||
) |
Add an "string <name>" input. An array length of 1 makes the variable uniform. Note: The strings are referenced, not copied, so keep it live until after run() has been called.
bool CVEX_ContextT< PREC >::addRequiredOutput | ( | const UT_StringHolder & | name, |
CVEX_Type | type | ||
) |
Add a required output. If no required output is specified, all exports/outputs are computed. Note: Due to the varying/uniform state of an output depending significantly on the inputs' varying/uniform state – and operations performed – then, unlike addInput, no storage can be allocated until after load. Note: If no storage is allocated, the output is still computed but the result is thrown away.
void CVEX_ContextT< PREC >::clear | ( | ) |
|
static |
calling clearAllFunctions() will force all CVEX object code to be flushed out of memory and to be reloaded. Be cautioned that this may have side-effects, and should only be called at a safe time.
|
static |
Removes the given function from the CVEX context.
void CVEX_ContextT< PREC >::clearVexErrors | ( | ) |
}
Clear the errors reported by getVexErrors() / getVexWarnings().
|
inline |
Find an input by name/type.
Definition at line 318 of file CVEX_Context.h.
|
inline |
Definition at line 320 of file CVEX_Context.h.
|
inline |
Find an input by name.
Definition at line 324 of file CVEX_Context.h.
|
inline |
Definition at line 326 of file CVEX_Context.h.
|
inline |
Find an output by name/type.
Definition at line 340 of file CVEX_Context.h.
|
inline |
Definition at line 342 of file CVEX_Context.h.
|
inline |
Find and output by name.
Definition at line 346 of file CVEX_Context.h.
|
inline |
Definition at line 348 of file CVEX_Context.h.
|
inline |
The list of input parameters to the function. It's possible that these values may be shared between the input and output lists.
Definition at line 314 of file CVEX_Context.h.
|
inline |
Definition at line 315 of file CVEX_Context.h.
|
inline |
If load() or run() return false, this will return the error that triggered the CVEX failure. Note that this is distinct from errors
Definition at line 391 of file CVEX_Context.h.
|
inline |
The list of output parameters from the function. After the function has been run, the output parameters will have their values written to by VEX.
If the output has not had CVEX_Value::setData() called, then the data will have been written to internal storage and can be retrieved calling CVEX_Value::getData().
Definition at line 336 of file CVEX_Context.h.
|
inline |
Definition at line 337 of file CVEX_Context.h.
void CVEX_ContextT< PREC >::getParameterDefaults | ( | const UT_StringRef & | name, |
CVEX_Type | ctype, | ||
UT_DoubleArray & | values | ||
) | const |
Initializes the values array with the defaults of the given parameter. Leaves values empty if it can't find the parameter.
const UT_String& CVEX_ContextT< PREC >::getVexErrors | ( | ) | const |
If load() or run() failed or reported warnings, these methods will return the errors reported by VEX. {
const UT_String& CVEX_ContextT< PREC >::getVexWarnings | ( | ) | const |
bool CVEX_ContextT< PREC >::hasFunction | ( | const UT_StringRef & | name | ) | const |
Checks if the VEX function by the given name already exists.
bool CVEX_ContextT< PREC >::isLoaded | ( | ) | const |
Quick test to see if the function has been loaded.
bool CVEX_ContextT< PREC >::isValid | ( | ) | const |
This method will return true if the code referenced by the context has been deleted (see ()). If you've cached a CVEX_Context, then this can be used to see if it's still valid.
bool CVEX_ContextT< PREC >::load | ( | int | argc, |
const char *const | argv[] | ||
) |
Load the VEX function. Inputs must be specified before this function is called. After loading, the input list will have flags set telling you whether the input parameter is used. At this point, you should set the data for all used inputs.
The list of outputs will also be defined, meaning that you can figure out what's going to be written by the VEX function.
bool CVEX_ContextT< PREC >::loadFunction | ( | CVEX_Function | function, |
int | argc, | ||
const char *const | argv[] | ||
) |
With load function we already have pre-loaded the CVEX_Function so the argv[0] is ignored.
bool CVEX_ContextT< PREC >::preloadFile | ( | UT_IStream & | is, |
const char * | name, | ||
UT_String * | actual_name, | ||
bool | override_old | ||
) |
Load the definition of the VEX function. Usually VEX functions are loaded from compiled VEX code stored in files on the search path. But, callers can use this method to define a VEX function from the stream. The module name can be optionally overriden with a name argument (if it's NULL, the name in the stream is used implicitly). The final name of the module is returned in actual_name (if not NULL). If override_old is true, if the old function by that name is found, then it will be overriden and updated with the new one.
CVEX_Function CVEX_ContextT< PREC >::preloadFunction | ( | const UT_StringHolder & | snippet | ) |
Loads the given file. Instead of registering the loaded function in the global function table, returns it as a CVEX_Function
CVEX_Function CVEX_ContextT< PREC >::preloadFunction | ( | UT_IStream & | is | ) |
CVEX_Function CVEX_ContextT< PREC >::preloadGlobalFunction | ( | const char * | funcname | ) |
Loads the functin form the global function table.
CVEX_ProbeResult CVEX_ContextT< PREC >::probeOutput | ( | const UT_StringRef & | name, |
CVEX_Type | type | ||
) | const |
Query the assignment status of an output. This must be called after the code has been loaded.
bool CVEX_ContextT< PREC >::run | ( | int | array_size, |
bool | interruptable, | ||
CVEX_RunDataT< PREC > * | rundata = nullptr |
||
) |
Run the VEX function given a list of input variables and a list of output parameters. Each input/output parameter under your control should have an array size of either 1 or at least the array_size given to the run() method. It's possible to run on fewer array elements than have been allocated, but an error will be returned if there are input parameters which don't have enough allocation.
Pass in true for interruptable when running from within Houdini.
The run() function may be called multiple times, provided that the input parameters don't change. So, if you need to evaluate the data in chunks, you can do this by re-initializing the input parameter data between calls to run(). However, you should not change the uniform/varying state of any input parameters without doing a re-load of the VEX function.
array_size | The size of varying arrays. All varying arrays must be this size. |
interruptable | If true, VEX will check the state of the UT_Interrupt. This should be enabled when called from within Houdini. If interruptable is false, then the user will not be able to break out of endless loops in VEX. It's better to leave it true if you are unsure. |
rundata | Data that matches the precision PREC. |