Call VEX from C++.
More...
#include <CVEX_Context.h>
|
| CVEX_ContextT () |
|
| ~CVEX_ContextT () |
|
void | clear () |
|
bool | isValid () const |
|
bool | addInput (const UT_StringHolder &name, CVEX_Type type, bool varying) |
|
bool | addInput (const UT_StringHolder &name, CVEX_Type type, void *data, int array_size) |
|
bool | addConstantInput (const UT_StringHolder &name, CVEX_Type type, void *data, int array_size) |
|
bool | addConstantInput (const UT_StringHolder &name, CVEX_StringArray &strings) |
|
bool | addInput (const UT_StringHolder &name, CVEX_StringArray &strings) |
|
bool | addRequiredOutput (const UT_StringHolder &name, CVEX_Type type) |
|
bool | hasFunction (const UT_StringRef &name) const |
| Checks if the VEX function by the given name already exists. More...
|
|
bool | preloadFile (UT_IStream &is, const char *name, UT_String *actual_name, bool override_old) |
|
CVEX_Function | preloadFunction (const UT_StringHolder &snippet) |
|
CVEX_Function | preloadFunction (UT_IStream &is) |
|
CVEX_Function | preloadGlobalFunction (const char *funcname) |
| Loads the functin form the global function table. More...
|
|
bool | load (int argc, const char *const argv[]) |
|
bool | loadFunction (CVEX_Function function, int argc, const char *const argv[]) |
|
bool | isLoaded () const |
| Quick test to see if the function has been loaded. More...
|
|
CVEX_ValueListT< PREC > & | getInputList () |
|
const CVEX_ValueListT< PREC > & | getInputList () const |
|
const CVEX_ValueT< PREC > * | findInput (const UT_StringRef &name, CVEX_Type type) const |
| Find an input by name/type. More...
|
|
CVEX_ValueT< PREC > * | findInput (const UT_StringRef &name, CVEX_Type type) |
|
const CVEX_ValueT< PREC > * | findInput (const UT_StringRef &name) const |
| Find an input by name. More...
|
|
CVEX_ValueT< PREC > * | findInput (const UT_StringRef &name) |
|
const CVEX_ValueListT< PREC > & | getOutputList () const |
|
CVEX_ValueListT< PREC > & | getOutputList () |
|
const CVEX_ValueT< PREC > * | findOutput (const UT_StringRef &name, CVEX_Type type) const |
| Find an output by name/type. More...
|
|
CVEX_ValueT< PREC > * | findOutput (const UT_StringRef &name, CVEX_Type type) |
|
const CVEX_ValueT< PREC > * | findOutput (const UT_StringRef &name) const |
| Find and output by name. More...
|
|
CVEX_ValueT< PREC > * | findOutput (const UT_StringRef &name) |
|
CVEX_ProbeResult | probeOutput (const UT_StringRef &name, CVEX_Type type) const |
|
void | getParameterDefaults (const UT_StringRef &name, CVEX_Type ctype, UT_DoubleArray &values) const |
|
bool | run (int array_size, bool interruptable, CVEX_RunDataT< PREC > *rundata=nullptr) |
|
const char * | getLastError () const |
|
const UT_String & | getVexErrors () const |
|
const UT_String & | getVexWarnings () const |
|
void | clearVexErrors () |
| } More...
|
|
bool | addConstantInput (const UT_StringHolder &name, UT_PackedArrayOfArrays< VEXint< PREC > > &intdata) |
| Add Constant Integer 32 Arrays. More...
|
|
template<VEX_Precision PREC>
class CVEX_ContextT< PREC >
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.
- VEX automatically takes advantage of SSE
- VEX can perform run-time optimization
- Examples:
- CVEX/cvexsample.C, CVEX/simple.C, SOP/SOP_PrimVOP.C, and SOP/SOP_PrimVOP.h.
Definition at line 203 of file CVEX_Context.h.
template<VEX_Precision PREC>
template<VEX_Precision PREC>
template<VEX_Precision PREC>
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.
template<VEX_Precision PREC>
template<VEX_Precision PREC>
Add Constant Integer 32 Arrays.
template<VEX_Precision PREC>
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.
- Examples:
- CVEX/cvexsample.C, CVEX/simple.C, and SOP/SOP_PrimVOP.C.
template<VEX_Precision PREC>
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.
template<VEX_Precision PREC>
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.
template<VEX_Precision PREC>
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.
template<VEX_Precision PREC>
clearing the context will allow you to set up the input and output parameters again.
- Note
- load() must be called again before you can run the VEX code.
template<VEX_Precision PREC>
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.
- Note
- This will also cause all functions to be cleared (see clear()).
template<VEX_Precision PREC>
Removes the given function from the CVEX context.
template<VEX_Precision PREC>
template<VEX_Precision PREC>
template<VEX_Precision PREC>
template<VEX_Precision PREC>
template<VEX_Precision PREC>
template<VEX_Precision PREC>
template<VEX_Precision PREC>
template<VEX_Precision PREC>
template<VEX_Precision PREC>
template<VEX_Precision PREC>
The list of input parameters to the function. It's possible that these values may be shared between the input and output lists.
- Examples:
- CVEX/cvexsample.C.
Definition at line 314 of file CVEX_Context.h.
template<VEX_Precision PREC>
template<VEX_Precision PREC>
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.
template<VEX_Precision PREC>
template<VEX_Precision PREC>
template<VEX_Precision PREC>
Initializes the values array with the defaults of the given parameter. Leaves values empty if it can't find the parameter.
template<VEX_Precision PREC>
template<VEX_Precision PREC>
template<VEX_Precision PREC>
Checks if the VEX function by the given name already exists.
template<VEX_Precision PREC>
Quick test to see if the function has been loaded.
template<VEX_Precision PREC>
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.
template<VEX_Precision PREC>
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.
- Examples:
- CVEX/cvexsample.C, CVEX/simple.C, and SOP/SOP_PrimVOP.C.
template<VEX_Precision PREC>
With load function we already have pre-loaded the CVEX_Function so the argv[0] is ignored.
template<VEX_Precision PREC>
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.
template<VEX_Precision PREC>
Loads the given file. Instead of registering the loaded function in the global function table, returns it as a CVEX_Function
template<VEX_Precision PREC>
template<VEX_Precision PREC>
Loads the functin form the global function table.
template<VEX_Precision PREC>
Query the assignment status of an output. This must be called after the code has been loaded.
template<VEX_Precision PREC>
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.
- Parameters
-
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. |
- Examples:
- CVEX/cvexsample.C, CVEX/simple.C, and SOP/SOP_PrimVOP.C.
The documentation for this class was generated from the following file: