HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DOP_Parent.h
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_Parent.h ( SOP Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __DOP_Parent_h__
12 #define __DOP_Parent_h__
13 
14 #include "DOP_API.h"
15 #include "DOP_FullPathData.h"
16 #include "DOP_Node.h"
17 
18 #include <SIM/SIM_Utils.h>
19 #include <UT/UT_ValArray.h>
20 #include <OP/OP_DopParent.h>
21 
22 class DEP_MicroNode;
23 class DOP_Parent;
24 
25 typedef enum {
30 
32 
34 {
35 public:
36  DOP_Parent();
37  virtual ~DOP_Parent();
38 
39  const DOP_Engine &getEngine() const;
40  DOP_Engine &getNonConstEngine();
41 
42  int dopparentUniqueId() const { return myDopParentUniqueId; }
43 
44  void setNeedsToResimulateLastTimestep();
45  void setNeedsToFilterData();
46  virtual void setNeedsToCompletelyReset();
47 
48  /// Sets the current simulation time, solving all intermediate steps.
49  /// Note that the time t passed in to this function is a global
50  /// Houdini time, and may not match the simulation time.
51  void setDOPTime(const SIM_Time &t);
52  /// Returns the simulation time that corresponds to a given global
53  /// Houdini time.
54  const SIM_Time getDOPTime(const SIM_Time &t) const;
55  /// Returns the global Houdini time that corresponds to a given
56  /// simulation time.
57  const SIM_Time getGlobalTime(const SIM_Time &t) const;
58  void resimulate();
59  /// Resets the simulation and cooks to a specific DOP time, this
60  /// avoids double cooking if you are resetting to frame 0.
61  void resimulateToTime(const SIM_Time &t);
62 
63  /// Returns true if the DOP network has changed such that the
64  /// simulation needs to be reset.
65  bool getNeedsResimulation() const;
66 
67  /// Attributes for controlling the simulation behavior.
68  const SIM_Time &getOffsetTime() const;
69  void setOffsetTime(const SIM_Time &t);
70  fpreal getTimeScale() const;
71  void setTimeScale(fpreal scale);
72  bool getAutoResimulation() const;
73  void setAutoResimulation(bool autoreset);
74  bool getInterpolateData(const SIM_Time &t) const;
75  void setInterpolateData(bool interpolate);
76  bool getIsSimulating() const;
77  virtual bool getIsTimeless() const { return false; }
78 
79  /// Used by SIM_Engine to flag this privately if it is during
80  /// an internally generated simulation pass
81  void setIsSimulating(bool val) { mySimulating = val; }
82 
83  /// Used externally to flag that we do not want to resimulate
84  /// due to our setDOPTime() invocations.
85  bool getDisableSimulation() const { return myDisableSimulation; }
86  void setDisableSimulation(bool disable) { myDisableSimulation = disable; }
87 
88  /// Get all objects that match a particular string. This calls the
89  /// SIM_Engine::findAllObjectsFromString() function, but converts the
90  /// time value from global time to simulation time, and passes our
91  /// getInterpolateData() value as the interpolate parameter.
92  void findAllObjectsFromString(const char *objspec,
93  SIM_ConstObjectArray &objects,
94  const SIM_Time &t) const;
95  /// Get the object that matches a particular string. This calls the
96  /// SIM_Engine::findObjectFromString() function, but converts the
97  /// time value from global time to simulation time, and passes our
98  /// getInterpolateData() value as the interpolate parameter.
99  const SIM_Object *findObjectFromString(const char *objspec,
100  int whichmatch, int *nummatch,
101  const SIM_Time &t) const;
102  /// Get all relationships that match a particular string. This calls the
103  /// SIM_Engine::findAllRelationshipsFromString() function, but converts the
104  /// time value from global time to simulation time, and passes our
105  /// getInterpolateData() value as the interpolate parameter.
106  void findAllRelationshipsFromString(
107  const char *relspec,
108  SIM_ConstDataArray &relationships,
109  const SIM_Time &t) const;
110  /// Get the relationship that matches a particular string. This calls the
111  /// SIM_Engine::findRelationshipFromString() function, but converts the
112  /// time value from global time to simulation time, and passes our
113  /// getInterpolateData() value as the interpolate parameter.
114  const SIM_Relationship *findRelationshipFromString(
115  const char *relspec,
116  int whichmatch, int *nummatch,
117  const SIM_Time &t) const;
118 
119  /// Returns data used by DOP_Nodes during their cook process. This is
120  /// information that is global to the DOP Network as it cooks.
121  DOP_Node::DOP_CookData &getDopNodeCookData();
122 
123  /// Sends out a parm changed message so that anyone interested in the
124  /// simulation will know to refresh their data. This call also protects
125  /// the DOP Network from causing infinite recursion when the DOP Network
126  /// is interested in a SOP node which is interested in the DOP Network
127  /// (a common and legal situation when using a SOP Solver, for example).
128  void sendResimulateNotification(
129  bool callnotify,
130  bool changingguideparm);
131 
133  { return getNonConstEngineSubclass().simMicroNode(); }
135  { return getNonConstEngineSubclass().simInputMicroNode(); }
137  { return getNonConstEngineSubclass().resimParmsMicroNode(); }
139  { return getEngineSubclass().resimParmsMicroNode(); }
141  { return getNonConstEngineSubclass().refilterParmsMicroNode(); }
143  { return getEngineSubclass().refilterParmsMicroNode(); }
144 
145  /// This static function returns an array of all DOP_Parents.
146  static const DOP_ParentList &getAllDopParents();
147  /// This function moves a particular DOP_Parent to the front of the list
148  /// of all DOP_Parents. This lets us treat this list as a "most recently
149  /// used" stack.
150  static void setMostRecentDopParent(DOP_Parent *dopparent);
151 
152  /// The current dopnet may not be the top of the recently used.
153  /// Dopnets that are inside locked assets, for example, are rather
154  /// useless as destinations.
155  /// Except we do want access to those for tracking cache settings,
156  /// reset flags, etc.
157  static OP_Node *getMostRecentDopOwner();
158  static OP_Node *getMostRecentWriteableDopOwner();
159 
160  virtual bool opGetNeedsResimulation() const
161  { return getNeedsResimulation(); }
162  virtual bool opGetDisableSimulation() const;
163  /// Query cache size.
164  virtual void opGetDiskCache(UT_IntArray &frames) const;
165  virtual void opGetMemoryCache(UT_IntArray &frames) const;
166 
167  /// Update re-simulation parameters, ensuring getOffsetTime and the
168  /// ilk are valid. This is required before getDOPTime will work
169  /// as expected (but note setDOPTime() implicitly invokes this)
170  void updateResimParms(const SIM_Time &t);
171 
172 protected:
173  const SIM_Time &getLastSetTime() const;
174  void resimulateLastTimestep();
175  /// Sets a flag that says we need to re-filter our simulation data the
176  /// next time a request for the data is made.
177  void setNeedsToFilterData(const SIM_Time &t);
178  /// Check if we need to filter our simulation data, and do so if required.
179  void filterDataIfRequired() const;
180  /// This function calls filterDataSubclass() to cache pointers to the
181  /// simulation data that is of interest to us.
182  void filterData(const SIM_Time &t);
183 
184  virtual const DOP_Engine &getEngineSubclass() const = 0;
185  virtual void resimulateLastTimestepSubclass();
186  virtual void setDOPTimeSubclass(const SIM_Time &t);
187  virtual DOP_Engine &getNonConstEngineSubclass() = 0;
188  virtual void filterDataSubclass(const SIM_Time &t) = 0;
189 
190  virtual void handleRefilterParms(const SIM_Time &t) {}
191  virtual void handleResimParms(const SIM_Time &t) {}
192 
193  void notifySimulationChangeSinksOfChange();
194  void notifySimulationChangeSinksOfDelete();
195 
196 private:
197  UT_ValArray<DOP_SimulationChangeSink *> mySimulationChangeSinks;
198  DOP_Node::DOP_CookData myDopNodeCookData;
199  SIM_Time myLastSetTime;
200  SIM_Time myOffsetTime;
201  SIM_Time myNeedsToFilterDataTime;
202  fpreal myTimeScale;
203  bool myNeedsToFilterData;
204  bool mySimulating;
205  bool myNeedsToResimulateFrame;
206  bool myNeedsToResimulateCompletely;
207  bool myAutoResimulation;
208  bool myInterpolateData;
209  bool mySendingResimulateNotification;
210  bool myDisableSimulation;
211  int myDopParentUniqueId;
212 
213  static DOP_ParentList theDopParents;
214 
216  friend class DOP_Engine;
217 };
218 
220 {
221 public:
223  { }
225  { removeAllSimulationChangeSinks(); }
226 
227  virtual void simulationChanged(DOP_Parent *dopparent) = 0;
228  virtual void simulationDeleted(DOP_Parent *dopparent)
229  { removeSimulationChangeSink(dopparent); }
230 
231 protected:
233  {
234  if( !dopparent ) return;
235  dopparent->mySimulationChangeSinks.append(this, 1);
236  myDopParents.append(dopparent, 1);
237  }
239  {
240  if( !dopparent ) return;
241  dopparent->mySimulationChangeSinks.findAndRemove(this);
242  myDopParents.findAndRemove(dopparent);
243  }
245  {
246  for( int i = myDopParents.entries(); i --> 0; )
247  removeSimulationChangeSink(myDopParents(i));
248  }
249 
250 private:
251  UT_ValArray<DOP_Parent *> myDopParents;
252 };
253 
254 #endif
virtual void opGetDiskCache(UT_IntArray &frames) const =0
bool getDisableSimulation() const
Definition: DOP_Parent.h:85
int dopparentUniqueId() const
Definition: DOP_Parent.h:42
void addSimulationChangeSink(DOP_Parent *dopparent)
Definition: DOP_Parent.h:232
virtual void simulationDeleted(DOP_Parent *dopparent)
Definition: DOP_Parent.h:228
virtual void setNeedsToCompletelyReset()=0
virtual bool opGetDisableSimulation() const =0
void removeAllSimulationChangeSinks()
Definition: DOP_Parent.h:244
void removeSimulationChangeSink(DOP_Parent *dopparent)
Definition: DOP_Parent.h:238
DEP_MicroNode & resimParmsMicroNode()
Definition: DOP_Parent.h:136
virtual void handleRefilterParms(const SIM_Time &t)
Definition: DOP_Parent.h:190
void setIsSimulating(bool val)
Definition: DOP_Parent.h:81
png_uint_32 i
Definition: png.h:2877
UT_ValArray< DOP_Parent * > DOP_ParentList
Definition: DOP_Parent.h:31
virtual bool opGetNeedsResimulation() const
Definition: DOP_Parent.h:160
void setDisableSimulation(bool disable)
Definition: DOP_Parent.h:86
GA_API const UT_StringHolder scale
virtual void opGetMemoryCache(UT_IntArray &frames) const =0
#define DOP_API
Definition: DOP_API.h:10
const DEP_MicroNode & refilterParmsMicroNode() const
Definition: DOP_Parent.h:142
virtual ~DOP_SimulationChangeSink()
Definition: DOP_Parent.h:224
virtual void handleResimParms(const SIM_Time &t)
Definition: DOP_Parent.h:191
DEP_MicroNode & simMicroNode()
Definition: DOP_Parent.h:132
Holds pointers to a number of const SIM_Object objects.
double fpreal
Definition: SYS_Types.h:263
virtual bool getIsTimeless() const
Definition: DOP_Parent.h:77
GLuint GLfloat * val
Definition: glcorearb.h:1607
exint append(void)
Definition: UT_Array.h:95
DEP_MicroNode & refilterParmsMicroNode()
Definition: DOP_Parent.h:140
DEP_MicroNode & simInputMicroNode()
Definition: DOP_Parent.h:134
DOP_ParentEventType
Definition: DOP_Parent.h:25
const DEP_MicroNode & resimParmsMicroNode() const
Definition: DOP_Parent.h:138
exint findAndRemove(const T &t)
Definition: UT_ArrayImpl.h:500