All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: DOP_Engine.h ( SOP Library, C++)
7  *
9  */
11 #ifndef __DOP_Engine_h__
12 #define __DOP_Engine_h__
14 #include "DOP_API.h"
15 #include "DOP_Output.h"
16 #include <SIM/SIM_Engine.h>
17 #include <DEP/DEP_MicroNode.h>
18 #include <UT/UT_SymbolTable.h>
19 #include <UT/UT_ErrorManager.h>
22 class OP_Network;
23 class SIM_ObjectArray;
24 class DOP_Node;
25 class DOP_Output;
26 class DOP_OutputDependency;
32 /// This subclass of SIM_Engine is the one used to contain simulations
33 /// controlled by DOP_Node networks. It serves as the glue between the
34 /// pure simulation library and the DOP_Node interface given to simulations
35 /// in Houdini.
37 {
38 public:
39  /// Constructor is given a pointer to the network that owns the simulation.
40  DOP_Engine(OP_Node *owner);
41  /// Destructor destroys all data for the simulation.
42  ~DOP_Engine() override;
44  /// Groups objects passed to a DOP_Node by the input they arrived in.
45  /// Each entry in the returned UT_ValArray represents an input to
46  /// the DOP_Node. If a particular input is not connected, the
47  /// corresponding entry in the array will by null. Generally this
48  /// function will be called from DOP_Node::processObjects() by nodes
49  /// which need to have objects coming through one input interact in
50  /// some way with objects coming through another input.
51  void getObjectsAtInputs(DOP_Node *node,
53  objectsatinputs) const;
55  /// Gets the objects in the stream associated with the supplied node.
56  /// For nodes with multiple outputs, the result is the combination of all
57  /// objects on any output. This function does not do any cooking of the
58  /// networks, or call partitionObjects on any nodes. It only pulls
59  /// existing data from our set of outputs to process. This function
60  /// is for use by expression functions that want to know what objects
61  /// most recently passed through a particular node.
62  void getObjectsForNode(DOP_Node *node,
63  SIM_ConstObjectArray &objects) const;
65  /// Adds the specified root data (cast to an object) as a sort of
66  /// "extra object" processed by a DOP node. These extra objects don't
67  /// affect cooking at all, but show up in the list of objects processed
68  /// by that node (in the MMB info and dopnodeobjs expression).
69  void addObjectForNode(DOP_Node *node,
70  SIM_RootData &rootdata);
72  /// Gets a pointer to the node that is currently being processed by
73  /// the DOP_Engine. The return value will be null if the engine is not
74  /// currently in the preSimulationStep and inside a call to
75  /// DOP_Node::processObjects(). This function is used by subnet DOPs
76  /// to evaluate standard DOP local variables in the context of the node
77  /// that is being processed (since subnets have no context of their own).
78  DOP_Node *getDopNodeBeingProcessed() const;
80  /// Explicitly dirty dependents of this simulation
81  void propagateSimDirty(bool send_event);
83  /// Pass through to our parent's notification
86  /// Returns whether resimulations is globally disabled.
87  static bool getWantResimulation()
88  { return theWantResimulation; }
90  /// Globally disables resimulations caused by external node changes. This
91  /// is meant for internal use.
92  static void setWantResimulation(bool want_resimulation)
93  { theWantResimulation = want_resimulation; }
95  /// Re-applies any errors cached locally to the given node.
96  /// Only applies errors with severity greater or equal to minimum.
97  /// If only_nodes_errors is false, will catch all errors and apply
98  /// them to sink.
99  void applyErrorsToNode(OP_Node *sink,
100  OP_Node *sourcenode,
101  bool only_nodes_errors=true,
102  UT_ErrorSeverity minseverity = UT_ERROR_MESSAGE) const;
104  { return myErrorSeverity; }
106  /// Registers an error against a specified node so it will be
107  /// resurrected every time that node recooks. Usually handled
108  /// transparently by addErrorSubclass, but required when the
109  /// error is added outside the simulation path.
110  void registerNodeError(OP_Node *node, const UT_StringHolder &errmsg, UT_ErrorSeverity sev) const;
112 protected:
113  /// Overrides the base class method to make sure that all our internal
114  /// data related to the last timestep cook has been cleared away.
115  void resetSimulation() override;
116  /// Overrides the actions that occur before doing a simulation step.
117  /// This is where the network of DOP_Nodes is parsed. Each DOP_Node
118  /// has a chance to alter the simulation objects in the
119  /// DOP_Node::processObjects() function. Nodes can also specify
120  /// which objects are sent to each output of the node.
121  void preSimulationStep() override;
122  /// Overrides the actions that occur after a simulation step.
123  void postSimulationStep() override;
124  /// When the most recent simulation state is being deleted or
125  /// removed from memory, we have to clear all our references to
126  /// it. This basically means our lists of output objects to process.
127  void clearReferencesToMostRecentState() override;
128  /// Sets up custom data on a new object.
129  /// This implementation calls the base class implementation, then it
130  /// stores information about the DOP_Node that created the object.
131  void objectCreated(SIM_Object *object) override;
132  /// Overrides the default behavior when removing a simulation object.
133  /// This implementation eliminates all references to this object stored
134  /// in our internal data then calls the base class implementation.
135  void objectRemoved(SIM_Object *object) override;
136  /// Override this method to flag ourselves as requiring a resimulation
137  /// when any of our external referenced nodes changes in a significant
138  /// way.
140  OP_Node *changednode,
141  OP_EventType eventtype,
142  void *data,
143  bool isguide) override;
144  /// Uses the object and data arguments to put the error message on an
145  /// appropriate DOP_Node. First priority is given to the node that
146  /// created the data, then the node that created the object, then the
147  /// node with the display flag.
148  void addErrorSubclass(const SIM_RootData *rootdata,
149  const SIM_Data *data,
150  int errorcode,
151  const char *errorparm,
152  UT_ErrorSeverity severity) const override;
153  /// We keep track of all the accumulated errors so we can re-post
154  /// them every time the DOP nodes cook (as they cook independently
155  /// of simulating.) This will clear out all the cached errors.
156  void resetErrorsSubclass() override;
157  /// Returns the simulation time that corresponds to the given global time.
159  const SIM_Time &t) const override;
160  /// Returns the global time that corresponds to the given simulation time.
162  const SIM_Time &t) const override;
164  /// Alerts our owner that we are simulating due to an internally
165  /// generated need. Returns the previous state
166  bool setIsSimulating(bool issimulating) const override;
168 private:
169  void buildObjectListForOutput(DOP_OutputDependency &output) const;
170  void partitionObjectsForOutput(DOP_OutputDependency &output) const;
171  void createOutputsToProcess(DOP_Node *node, int outputidx,
172  const SIM_Time &optime);
173  void clearOutputsToProcess();
174  void assignObjectsToCreatorOutputs();
175  void removeAllUnusedObjects(const SIM_ObjectArray &usedobjs);
177  UT_ErrorSeverity myOwnerSeverity;
178  DOP_OutputArray myOutputsToProcess;
179  DOP_OutputMap myOutputsSymbolTable;
180  int myProcessingOutput;
182  struct ErrorInfo
183  {
184  UT_StringHolder msg;
185  UT_ErrorSeverity sev;
186  };
188  mutable UT_Lock myErrorManagerLock;
189  mutable UT_ArrayMap<int, UT_Array<ErrorInfo>> myNodeErrors;
190  mutable UT_ErrorSeverity myErrorSeverity;
192  static bool theWantResimulation;
193 };
195 #endif
virtual void preSimulationStep()
virtual void resetSimulation()
Definition: UT_Error.h:25
UT_ErrorSeverity getErrorSeverity() const
Definition: DOP_Engine.h:103
virtual void notifySimulationChangeSinksOfChange()
Definition: SIM_Engine.h:356
GLdouble GLdouble t
Definition: glew.h:1403
GLsizei GLenum GLboolean sink
Definition: glew.h:4996
static void setWantResimulation(bool want_resimulation)
Definition: DOP_Engine.h:92
#define DOP_API
Definition: DOP_API.h:10
virtual void clearReferencesToMostRecentState()
Holds pointers to a number of SIM_Object objects.
UT_ValArray< DOP_OutputDependency * > DOP_OutputArray
Definition: DOP_Engine.h:26
virtual void postSimulationStep()
This function is run after all objects are processed by their solvers.
virtual void resetErrorsSubclass()
UT_Map< DOP_Output, DOP_OutputDependency * > DOP_OutputMap
Definition: DOP_Engine.h:29
GLenum GLenum severity
Definition: glcorearb.h:2538
Holds pointers to a number of const SIM_Object objects.
virtual void addErrorSubclass(const SIM_RootData *rootdata, const SIM_Data *data, int errorcode, const char *errorparm, UT_ErrorSeverity severity) const
The default implementation of this function does nothing.
GLboolean * data
Definition: glcorearb.h:130
virtual void objectCreated(SIM_Object *object)
virtual void objectRemoved(SIM_Object *object)
Definition: OP_Value.h:22
DOP_OutputMap::const_iterator DOP_OutputMapConstIter
Definition: DOP_Engine.h:30
virtual const SIM_Time getEngineTimeSubclass(const SIM_Time &t) const
Returns the simulation time that corresponds to the given global time.
This is the base class for all DOP nodes.
Definition: DOP_Node.h:77
virtual void handleExternalNodeChangeSubclass(OP_Node *changednode, OP_EventType eventtype, void *data, bool isguide)
static bool getWantResimulation()
Returns whether resimulations is globally disabled.
Definition: DOP_Engine.h:87
virtual const SIM_Time getGlobalTimeSubclass(const SIM_Time &t) const
Returns the global time that corresponds to the given simulation time.
virtual bool setIsSimulating(bool issimulating) const