00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Side Effects Software Inc 00008 * 477 Richmond Street West 00009 * Toronto, Ontario 00010 * Canada M5V 3E7 00011 * 416-504-9876 00012 * 00013 * NAME: DOP_Engine.h ( SOP Library, C++) 00014 * 00015 * COMMENTS: 00016 */ 00017 00018 #ifndef __DOP_Engine_h__ 00019 #define __DOP_Engine_h__ 00020 00021 #include "DOP_API.h" 00022 #include <UT/UT_SymbolTable.h> 00023 #include <UT/UT_ErrorManager.h> 00024 #include <SIM/SIM_Engine.h> 00025 00026 class OP_Network; 00027 class SIM_ObjectArray; 00028 class DOP_Node; 00029 class DOP_Output; 00030 class DOP_OutputDependency; 00031 00032 /// This defines the name of the paramater that will appear on OBJ_DopNets 00033 /// to allow DOPs to send parm change messages to force a resimulation. 00034 #define DOP_FORCERESIMPARM "forceresim" 00035 00036 /// This subclass of SIM_Engine is the one used to contain simulations 00037 /// controlled by DOP_Node networks. It serves as the glue between the 00038 /// pure simulation library and the DOP_Node interface given to simulations 00039 /// in Houdini. 00040 class DOP_API DOP_Engine : public SIM_Engine 00041 { 00042 public: 00043 /// Constructor is given a pointer to the network that owns the simulation. 00044 DOP_Engine(OP_Node *owner); 00045 /// Destructor destroys all data for the simulation. 00046 virtual ~DOP_Engine(); 00047 00048 /// Groups objects passed to a DOP_Node by the input they arrived in. 00049 /// Each entry in the returned UT_PtrArray represents an input to 00050 /// the DOP_Node. If a particular input is not connected, the 00051 /// corresponding entry in the array will by null. Generally this 00052 /// function will be called from DOP_Node::processObjects() by nodes 00053 /// which need to have objects coming through one input interact in 00054 /// some way with objects coming through another input. 00055 void getObjectsAtInputs(DOP_Node *node, 00056 UT_PtrArray<const SIM_ObjectArray *> & 00057 objectsatinputs) const; 00058 00059 /// Gets the objects in the stream associated with the supplied node. 00060 /// For nodes with multiple outputs, the result is the combination of all 00061 /// objects on any output. This function does not do any cooking of the 00062 /// networks, or call partitionObjects on any nodes. It only pulls 00063 /// existing data from our set of outputs to process. This function 00064 /// is for use by expression functions that want to know what objects 00065 /// most recently passed through a particular node. 00066 void getObjectsForNode(DOP_Node *node, 00067 SIM_ConstObjectArray &objects) const; 00068 00069 /// Adds the specified root data (cast to an object) as a sort of 00070 /// "extra object" processed by a DOP node. These extra objects don't 00071 /// affect cooking at all, but show up in the list of objects processed 00072 /// by that node (in the MMB info and dopnodeobjs expression). 00073 void addObjectForNode(DOP_Node *node, 00074 SIM_RootData &rootdata); 00075 00076 /// Gets a pointer to the node that is currently being processed by 00077 /// the DOP_Engine. The return value will be null if the engine is not 00078 /// currently in the preSimulationStep and inside a call to 00079 /// DOP_Node::processObjects(). This function is used by subnet DOPs 00080 /// to evaluate standard DOP local variables in the context of the node 00081 /// that is being processed (since subnets have no context of their own). 00082 DOP_Node *getDopNodeBeingProcessed() const; 00083 00084 protected: 00085 /// Overrides the base class method to make sure that all our internal 00086 /// data related to the last timestep cook has been cleared away. 00087 virtual void resetSimulation(); 00088 /// Overrides the actions that occur before doing a simulation step. 00089 /// This is where the network of DOP_Nodes is parsed. Each DOP_Node 00090 /// has a chance to alter the simulation objects in the 00091 /// DOP_Node::processObjects() function. Nodes can also specify 00092 /// which objects are sent to each output of the node. 00093 virtual void preSimulationStep(); 00094 /// Overrides the actions that occur after a simulation step. 00095 virtual void postSimulationStep(); 00096 /// When the most recent simulation state is being deleted or 00097 /// removed from memory, we have to clear all our references to 00098 /// it. This basically means our lists of output objects to process. 00099 virtual void clearReferencesToMostRecentState(); 00100 /// Sets up custom data on a new object. 00101 /// This implementation calls the base class implementation, then it 00102 /// stores information about the DOP_Node that created the object. 00103 virtual void objectCreated(SIM_Object *object); 00104 /// Overrides the default behavior when removing a simulation object. 00105 /// This implementation eliminates all references to this object stored 00106 /// in our internal data then calls the base class implementation. 00107 virtual void objectRemoved(SIM_Object *object); 00108 /// Override this method to flag ourselves as requiring a resimulation 00109 /// when any of our external referenced nodes changes in a significant 00110 /// way. 00111 virtual void handleExternalNodeChangeSubclass( 00112 OP_Node *changednode, 00113 OP_EventType eventtype, 00114 void *data); 00115 /// Uses the object and data arguments to put the error message on an 00116 /// appropriate DOP_Node. First priority is given to the node that 00117 /// created the data, then the node that created the object, then the 00118 /// node with the display flag. 00119 virtual void addErrorSubclass(const SIM_RootData *rootdata, 00120 const SIM_Data *data, 00121 int errorcode, 00122 const char *errorparm, 00123 UT_ErrorSeverity severity) const; 00124 /// Returns the simulation time that corresponds to the given global time. 00125 virtual const SIM_Time getEngineTimeSubclass(const SIM_Time &t) const; 00126 /// Returns the global time that corresponds to the given simulation time. 00127 virtual const SIM_Time getGlobalTimeSubclass(const SIM_Time &t) const; 00128 00129 private: 00130 void buildOutputSymbol(DOP_Output &output, UT_String &symbol) const; 00131 void buildObjectListForOutput(DOP_OutputDependency &output) const; 00132 void partitionObjectsForOutput(DOP_OutputDependency &output) const; 00133 void createOutputsToProcess(DOP_Node *node, int outputidx, 00134 const SIM_Time &optime); 00135 void clearOutputsToProcess(); 00136 void assignObjectsToCreatorOutputs(); 00137 void removeAllUnusedObjects(const SIM_ObjectArray &usedobjs); 00138 00139 UT_ErrorSeverity myOwnerSeverity; 00140 UT_PtrArray<DOP_OutputDependency *> myOutputsToProcess; 00141 UT_SymbolTable myOutputsSymbolTable; 00142 int myProcessingOutput; 00143 }; 00144 00145 #endif
1.5.9