HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
COP_ApexProgram Class Reference

#include <COP_ApexProgram.h>

Public Types

enum  SlapcompBuildStatus { SlapcompBuildStatus::FAIL = 0, SlapcompBuildStatus::REBUILD_NOT_NEEDED, SlapcompBuildStatus::SUCCESS }
 
enum  BeginBindingsMode { BeginBindingsMode::ALL_INPUTS_BOUND, BeginBindingsMode::NETWORK_STATE }
 

Public Member Functions

 COP_ApexProgram (bool harden_parms=true)
 
 ~COP_ApexProgram ()
 
bool setOutputBlock (COP_Block *output, const UT_Array< COP_Signature > *sigs, const UT_Array< COP_CableStructure > *input_cables)
 
bool setOutputBlock (COP_Block *output, BeginBindingsMode mode)
 
bool buildFromBlock (COP_Block *output, const UT_Array< COP_Signature > *sigs, const UT_Array< COP_CableStructure > *cables, const OP_Context &context, UT_ErrorManager &error)
 
bool buildFromBlock (COP_Block *output, BeginBindingsMode mode, const OP_Context &context, UT_ErrorManager &error)
 
bool buildFromSingleNode (COP_Node *output, const UT_Array< COP_Request > &requests, const COP_Signature &signature, const OP_Context &context, UT_ErrorManager &error)
 
COP_CableStructure getBlockOutputCableStructure (OP_OutputIdx port) const
 
void saveToGeometry (GU_Detail *gdp) const
 Saves the graph as geometry. More...
 
bool loadFromGeometry (const GU_Detail *gdp)
 Loads a graph from geometry. More...
 
bool saveToFile (const char *filename) const
 Saves the graph to a (geometry) file. More...
 
bool loadFromFile (const char *filename)
 Loads the graph from a geometry file. More...
 
bool setInputLayer (const UT_StringRef &name, const IMX_LayerConstPtr &layer)
 Binds an input to the program. More...
 
bool setInputGeometry (const UT_StringRef &name, const GU_ConstDetailHandle &geo)
 
bool setInputVDB (const UT_StringRef &name, const IMX_VDBConstPtr &vdb)
 
bool setInput (const UT_StringRef &name, const COP_PortData &input, bool as_cable=false)
 
bool clearInput (const UT_StringRef &name, bool as_cable=false)
 If as_cable is true, all inputs that match name.* are cleared. More...
 
void runProgram (const OP_Context &context, UT_ErrorManager &error)
 Runs the program after the inputs have been bound. More...
 
IMX_LayerPtr getOutputLayer (const UT_StringRef &name) const
 Extracts results after the program has executed. More...
 
GU_ConstDetailHandle getOutputGeometry (const UT_StringRef &name) const
 
IMX_VDBPtr getOutputVDB (const UT_StringRef &name) const
 
COP_PortData getOutput (const UT_StringRef &name) const
 
COP_PortData getOutputCable (const UT_StringRef &name, const COP_CableStructure &cable) const
 
void clearInputs ()
 Clears all the graph inputs, letting go of the held references. More...
 
void clearOutputs ()
 clears all the graph outputs, letting go of the held references. More...
 
const UT_StringMap< std::pair
< COP_Type, bool > > & 
getProgramInputs () const
 
const UT_StringMap< std::pair
< COP_Type, UT_StringHolder > > & 
getProgramOutputs () const
 
COP_Type getOutputType (const UT_StringRef &output) const
 Returns type of the given output. More...
 
bool isUnusedInput (const UT_StringRef &name) const
 Returns true if the input of the given name exists but is not used. More...
 
bool isUsedInput (const UT_StringRef &name, bool as_cable=false) const
 
DEP_TimedMicroNodegetGraphDep ()
 Returns the micronode that captures all dependencies for the program. More...
 
DEP_TimedMicroNodegetResultsDep ()
 
void enableCallback (bool enable)
 
void setCallback (void(*callback)(void *), void *data)
 
SlapcompBuildStatus rebuildIfNeeded (const OP_Context &context, UT_ErrorManager &error)
 
bool expectsLayerCameras () const
 
int getGraphProxyOverrideId () const
 Signature evaluation context override ID seen by this program. More...
 
COP_Block * getOutputBlock () const
 
int getOutputNodeId () const
 
COP_Node * getOutputNode () const
 
bool isOutputBlockSlapComp () const
 Returns if this program is for a block that is registered for slap comp. More...
 

Protected Types

enum  BuildTarget { BuildTarget::BLOCK, BuildTarget::SINGLE_NODE, BuildTarget::INVALID }
 What the program is built for. More...
 

Protected Member Functions

void addBlockDeps (DEP_MicroNode &dep, COP_Block *begin, COP_Block *end)
 
void setOutputNodeInternal (COP_Node *output, BuildTarget target, const UT_Array< COP_Signature > *sigs, const UT_Array< COP_CableStructure > *cables, const UT_Array< COP_Request > *requests)
 
COP_GraphProxyDirect * getGraphProxy ()
 

Protected Attributes

UT_UniquePtr< apex::APEX_Graph > myGraph
 
UT_StringMap< std::pair
< COP_Type, bool > > 
myProgramInputs
 Map of all inputs used by the program. More...
 
UT_StringMap< std::pair
< COP_Type, bool > > 
myUnusedInputs
 
UT_StringMap< std::pair
< COP_Type, UT_StringHolder > > 
myProgramOutputs
 
UT_StringMap< COP_PortData > myPassthroughOutputs
 
int myOutputNodeId = -1
 
BuildTarget myBuildTarget = BuildTarget::INVALID
 
UT_Array< COP_Request > myOutputRequests
 
COP_MicroNodeWithCallback myGraphDep
 
COP_MicroNodeWithCallback myResultsDep
 
COP_MicroNodeWithCallback myErroredMonitor
 
UT_UniquePtr
< COP_ApexNodeDependencies > 
myParameterDep
 
UT_UniquePtr
< COP_GraphProxyDirect > 
myGraphProxy
 
bool myHardenParameters
 
bool myExpectInputCameras = true
 

Detailed Description

This class creates an executable program out of a COP block. All parameters are evaluated and hardened in the graph.

Definition at line 80 of file COP_ApexProgram.h.

Member Enumeration Documentation

This tag can be used with setOutputBlock() and buildFromBlock() methods to indicate what the block begin's input states are (i.e. which ports are actually connected).

Enumerator
ALL_INPUTS_BOUND 

Will assume all inputs are connected non-null data.

NETWORK_STATE 

Will use the network's connections.

Definition at line 93 of file COP_ApexProgram.h.

enum COP_ApexProgram::BuildTarget
strongprotected

What the program is built for.

Enumerator
BLOCK 
SINGLE_NODE 
INVALID 

Definition at line 271 of file COP_ApexProgram.h.

Enumerator
FAIL 
REBUILD_NOT_NEEDED 
SUCCESS 

Definition at line 83 of file COP_ApexProgram.h.

Constructor & Destructor Documentation

COP_ApexProgram::COP_ApexProgram ( bool  harden_parms = true)

If harden_parms is true, the parameters will be evaluated and baked into the built graphs.

COP_ApexProgram::~COP_ApexProgram ( )

Member Function Documentation

void COP_ApexProgram::addBlockDeps ( DEP_MicroNode dep,
COP_Block *  begin,
COP_Block *  end 
)
protected

Helper function to register dependencies on the signature and port names of the block nodes.

bool COP_ApexProgram::buildFromBlock ( COP_Block *  output,
const UT_Array< COP_Signature > *  sigs,
const UT_Array< COP_CableStructure > *  cables,
const OP_Context context,
UT_ErrorManager error 
)

Builds an executable out of the block end node, containing everything up to its begin node.

bool COP_ApexProgram::buildFromBlock ( COP_Block *  output,
BeginBindingsMode  mode,
const OP_Context context,
UT_ErrorManager error 
)

This version of the method assumes that all inputs to the block are properly bound non-null data when the program gets built.

bool COP_ApexProgram::buildFromSingleNode ( COP_Node *  output,
const UT_Array< COP_Request > &  requests,
const COP_Signature signature,
const OP_Context context,
UT_ErrorManager error 
)

Builds a program that cooks the specified outputs of a single node. The node can be a subnetwork or an atomic node.

bool COP_ApexProgram::clearInput ( const UT_StringRef name,
bool  as_cable = false 
)

If as_cable is true, all inputs that match name.* are cleared.

void COP_ApexProgram::clearInputs ( )

Clears all the graph inputs, letting go of the held references.

void COP_ApexProgram::clearOutputs ( )

clears all the graph outputs, letting go of the held references.

void COP_ApexProgram::enableCallback ( bool  enable)
inline

When enabled, the registered callback is invoked whenever the program's results become out of date. Note that the callback may be invoked more than once when the results are dirtied!!!

Definition at line 223 of file COP_ApexProgram.h.

bool COP_ApexProgram::expectsLayerCameras ( ) const
inline

Returns true if the user should bind input layers that have correct camera metadata. If this is false, then the input layers are expected to use the default transformation.

Definition at line 249 of file COP_ApexProgram.h.

COP_CableStructure COP_ApexProgram::getBlockOutputCableStructure ( OP_OutputIdx  port) const

Returns the cable structure of an output of the block this is built from.

DEP_TimedMicroNode& COP_ApexProgram::getGraphDep ( )
inline

Returns the micronode that captures all dependencies for the program.

Definition at line 208 of file COP_ApexProgram.h.

COP_GraphProxyDirect* COP_ApexProgram::getGraphProxy ( )
protected

Returns this program's graph proxy, allocating it if it's not yet created.

int COP_ApexProgram::getGraphProxyOverrideId ( ) const

Signature evaluation context override ID seen by this program.

COP_PortData COP_ApexProgram::getOutput ( const UT_StringRef name) const
COP_Block* COP_ApexProgram::getOutputBlock ( ) const

Returns the Block End node this program is built for; if the program was built for a single node, this returns nullptr.

COP_PortData COP_ApexProgram::getOutputCable ( const UT_StringRef name,
const COP_CableStructure cable 
) const

Extracts the port data for a single cable output of the given name. The incoming cable structure is assumed to be correct.

GU_ConstDetailHandle COP_ApexProgram::getOutputGeometry ( const UT_StringRef name) const
IMX_LayerPtr COP_ApexProgram::getOutputLayer ( const UT_StringRef name) const

Extracts results after the program has executed.

COP_Node* COP_ApexProgram::getOutputNode ( ) const

Returns the node this program was built from, if it was built from a block or a single node, and if that node still exists.

int COP_ApexProgram::getOutputNodeId ( ) const

Returns the id of the node this program was built from, if it was built from a block or a single node.

COP_Type COP_ApexProgram::getOutputType ( const UT_StringRef output) const

Returns type of the given output.

IMX_VDBPtr COP_ApexProgram::getOutputVDB ( const UT_StringRef name) const
const UT_StringMap<std::pair<COP_Type, bool> >& COP_ApexProgram::getProgramInputs ( ) const
inline

Returns a map of all COP inputs to the program. Key of an input is its name, while the value is its expected type in the program.

Definition at line 186 of file COP_ApexProgram.h.

const UT_StringMap<std::pair<COP_Type, UT_StringHolder> >& COP_ApexProgram::getProgramOutputs ( ) const
inline

Returns a map of all COP outputs of the program. Key of an output is its name, while the value is its type in the program.

Definition at line 193 of file COP_ApexProgram.h.

DEP_TimedMicroNode& COP_ApexProgram::getResultsDep ( )
inline

Returns the micronode that captures all dynamic runtime dependencies from the previous program execution.

Definition at line 214 of file COP_ApexProgram.h.

bool COP_ApexProgram::isOutputBlockSlapComp ( ) const

Returns if this program is for a block that is registered for slap comp.

bool COP_ApexProgram::isUnusedInput ( const UT_StringRef name) const

Returns true if the input of the given name exists but is not used.

bool COP_ApexProgram::isUsedInput ( const UT_StringRef name,
bool  as_cable = false 
) const

Returns true if the input of the given name exists and is used by the program. If as_cable is true, this program is scanned for inputs that match name.*.

bool COP_ApexProgram::loadFromFile ( const char *  filename)

Loads the graph from a geometry file.

bool COP_ApexProgram::loadFromGeometry ( const GU_Detail gdp)

Loads a graph from geometry.

SlapcompBuildStatus COP_ApexProgram::rebuildIfNeeded ( const OP_Context context,
UT_ErrorManager error 
)

Rebuilds the APEX graph if necessary and returns one of the above status codes.

void COP_ApexProgram::runProgram ( const OP_Context context,
UT_ErrorManager error 
)

Runs the program after the inputs have been bound.

bool COP_ApexProgram::saveToFile ( const char *  filename) const

Saves the graph to a (geometry) file.

void COP_ApexProgram::saveToGeometry ( GU_Detail gdp) const

Saves the graph as geometry.

void COP_ApexProgram::setCallback ( void(*)(void *)  callback,
void data 
)
inline

Registers the callback that is to run when the program's results become out of date. Use enableCallback() to control whether or not the callback is forced to run. The data pointer is passed to the callback function when it executes. Note that the callback may be invoked more than once when the results are dirtied!!!

Definition at line 234 of file COP_ApexProgram.h.

bool COP_ApexProgram::setInput ( const UT_StringRef name,
const COP_PortData &  input,
bool  as_cable = false 
)

If as_cable is true, all fields from the port are bound as inputs (based on the field names).

bool COP_ApexProgram::setInputGeometry ( const UT_StringRef name,
const GU_ConstDetailHandle geo 
)
bool COP_ApexProgram::setInputLayer ( const UT_StringRef name,
const IMX_LayerConstPtr layer 
)

Binds an input to the program.

bool COP_ApexProgram::setInputVDB ( const UT_StringRef name,
const IMX_VDBConstPtr vdb 
)
bool COP_ApexProgram::setOutputBlock ( COP_Block *  output,
const UT_Array< COP_Signature > *  sigs,
const UT_Array< COP_CableStructure > *  input_cables 
)

Set the block end node for this program, without trying to rebuild. Returns false if output is a block begin node, in which case the output node (and the program as a whole) is unchanged. If sigs and input_cables are provided, they will be used as the authoritative state of inputs to the block (on the begin side); if one is given, the other must be as well. If these arguments are nullptr, then the built program will reflect state of the network.

bool COP_ApexProgram::setOutputBlock ( COP_Block *  output,
BeginBindingsMode  mode 
)

This version of the method assumes that all inputs to the block are properly bound non-null data when the program gets built.

void COP_ApexProgram::setOutputNodeInternal ( COP_Node *  output,
BuildTarget  target,
const UT_Array< COP_Signature > *  sigs,
const UT_Array< COP_CableStructure > *  cables,
const UT_Array< COP_Request > *  requests 
)
protected

Sets the target output node for the program, possibly marking the graph dirty if it's different from a built program's.

Member Data Documentation

BuildTarget COP_ApexProgram::myBuildTarget = BuildTarget::INVALID
protected

Definition at line 307 of file COP_ApexProgram.h.

COP_MicroNodeWithCallback COP_ApexProgram::myErroredMonitor
protected

This micronode is used only when the build fails. It gets notified when a relevant node is rewired or changed.

Definition at line 314 of file COP_ApexProgram.h.

bool COP_ApexProgram::myExpectInputCameras = true
protected

This flag indicates to the user whether they should place the input layers at the correct 3D locations or use default transforms.

Definition at line 332 of file COP_ApexProgram.h.

UT_UniquePtr<apex::APEX_Graph> COP_ApexProgram::myGraph
protected

Definition at line 293 of file COP_ApexProgram.h.

COP_MicroNodeWithCallback COP_ApexProgram::myGraphDep
protected

Definition at line 310 of file COP_ApexProgram.h.

UT_UniquePtr<COP_GraphProxyDirect> COP_ApexProgram::myGraphProxy
protected

This program's graph proxy that might have registered overrides (if building from a node).

Definition at line 324 of file COP_ApexProgram.h.

bool COP_ApexProgram::myHardenParameters
protected

This flag controls how the graph is built from a node. If true, all parameters are evaluated and baked into the graph; otherwise, they're made into graph inputs.

Definition at line 329 of file COP_ApexProgram.h.

int COP_ApexProgram::myOutputNodeId = -1
protected

Definition at line 306 of file COP_ApexProgram.h.

UT_Array<COP_Request> COP_ApexProgram::myOutputRequests
protected

Definition at line 308 of file COP_ApexProgram.h.

UT_UniquePtr<COP_ApexNodeDependencies> COP_ApexProgram::myParameterDep
protected

Contains all the dependency-tracking data for node parameters (if built from a node).

Definition at line 319 of file COP_ApexProgram.h.

UT_StringMap<COP_PortData> COP_ApexProgram::myPassthroughOutputs
protected

Mapping of bound passthrough outputs (by their name) to the bound input that they correspond to.

Definition at line 305 of file COP_ApexProgram.h.

UT_StringMap<std::pair<COP_Type, bool> > COP_ApexProgram::myProgramInputs
protected

Map of all inputs used by the program.

Definition at line 296 of file COP_ApexProgram.h.

UT_StringMap<std::pair<COP_Type, UT_StringHolder> > COP_ApexProgram::myProgramOutputs
protected

Definition at line 302 of file COP_ApexProgram.h.

COP_MicroNodeWithCallback COP_ApexProgram::myResultsDep
protected

Definition at line 311 of file COP_ApexProgram.h.

UT_StringMap<std::pair<COP_Type, bool> > COP_ApexProgram::myUnusedInputs
protected

Map of all inputs that are not used by the program. These are saved as they are part of the program's signature.

Definition at line 300 of file COP_ApexProgram.h.


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