HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SIM_Engine.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  */
7 
8 #ifndef __SIM_Engine_h__
9 #define __SIM_Engine_h__
10 
11 #include "SIM_API.h"
12 #include "SIM_Cache.h"
13 #include "SIM_Data.h"
14 #include "SIM_Error.h"
15 #include "SIM_ObjectSolveInfo.h"
16 #include <OP/OP_Value.h>
17 #include <OP/OP_DopParent.h>
18 #include <DEP/DEP_MicroNode.h>
19 #include <UT/UT_IntrusivePtr.h>
20 #include <UT/UT_Map.h>
21 #include <UT/UT_Set.h>
22 #include <UT/UT_SymbolTable.h>
23 
24 #define SIM_PATH_SEPCHAR '/'
25 #define SIM_OBJECT_SEPCHAR ':'
26 #define SIM_OBJECTNUM_SEPCHAR '.'
27 #define SIM_OBJECTDATA_SEPCHAR '/'
28 
29 class UT_InfoTree;
30 class UT_StringArray;
31 class UT_StringRef;
32 class OP_Node;
33 class SIM_BaseCache;
34 class SIM_DopDescription;
36 class SIM_DataFactory;
37 class SIM_Data;
38 class SIM_SimulationState;
39 class SIM_MetaObject;
40 class SIM_MetaObjectArray;
42 class SIM_ObjectArray;
43 class SIM_SaveCommand;
44 
46 {
47 public:
49 
50  const char *className() const override
51  { return "SIM_SimulationMicroNode"; }
52  void becameDirty(
54  const DEP_PropagateData &data) override;
55 
56 protected:
58 };
59 
60 /// This is the main engine behind all simulations. Any number of these
61 /// can be created to create independent simulations. Generally a simulation
62 /// will be owned by a particular OP_Node. For example, the DopNet object
63 /// contains a SIM_Engine.
64 class SIM_API SIM_Engine : public UT_IntrusiveRefCounter<SIM_Engine>
65 {
66 public:
67  /// Constructor to create a new simulation.
68  SIM_Engine(OP_Node *owner);
69  /// Destructor to destroy all data associated with a simulation.
70  virtual ~SIM_Engine();
71 
72  /// Returns the OP_Node that owns this engine. This may be null if
73  /// the engine isn't associated with a particular node.
74  OP_Node *getOwner() const;
75  /// Gets the full path to the DOP Network node that owns this simulation.
76  const UT_String &getOwnerFullPath() const;
77  void getOwnerFullPathString(UT_String &str) const;
78 
79  /// Allocates a new SIM_Object and adds it to the simulation.
80  /// The name parameter is assigned to the object. This name does not
81  /// have to be unique.
82  SIM_Object *addSimulationObject(bool solvefirstframe);
83  /// Removes a SIM_Object from the simulation.
84  /// The index value is the current location of the object in the
85  /// simulations's list of objects. This value will not be the same
86  /// as the SIM_Object::getObjectId() value, and may change when objects
87  /// are added to or removed from the simulation.
88  void removeSimulationObject(int index);
89  /// Removes a SIM_Object from the simulation.
90  /// This version of this function takes a SIM_Object pointer instead
91  /// of an index. The pointer is converted to an index and the indexed
92  /// version of removeSimulationObject() is called.
93  void removeSimulationObject(SIM_Object *object);
94  /// Returns the number of objects currently in the simulation.
95  int getNumSimulationObjects() const;
96  /// Returns the number of objects currently in the simulation.
97  int64 getNumSimulationData() const;
98  /// Returns a pointer to the SIM_Object at the specified index.
99  /// The index value is the current location of the object in the
100  /// simulations's list of objects. This value will not be the same
101  /// as the SIM_Object::getObjectId() value.
102  const SIM_Object *getSimulationObject(int index) const;
103  /// Returns a pointer to the SIM_Object with the specified unique id.
104  /// This function searches the current list of objects for the
105  /// specified objectid. If the objectid is not found, this function
106  /// returns null.
107  const SIM_Object *getSimulationObjectFromId(int objectid) const;
108  /// Returns the "nth" simulation object that matches a supplied filter.
109  /// If less than the supplied n objects match the filter, 0 is returned.
110  const SIM_Object *getNthSimulationObject(
111  const SIM_DataFilter &filter,
112  int n) const;
113 
114  /// Creates a new relationship. The creationflags parameter accepts the
115  /// same SIM_DATA_* flags accepted by the creationflags parameter of
116  /// SIM_Data::createNamedSubData().
117  SIM_Relationship *addRelationship(const char *name,
118  int creationflags);
119  /// Returns the number of relationships in the current simulation state.
120  int getNumRelationships() const;
121  /// This function allows looping through the simulations relationships.
122  const SIM_Relationship *getRelationship(int index) const;
123  /// Returns the relationship with the specified name.
124  const SIM_Relationship *getRelationship(const char *name) const;
125  /// Gets all the relationships of a particular type. The type of a
126  /// relationship is defined by the one subdata on the SIM_Relationship.
127  void filterConstRelationships(
128  const SIM_DataFilter &filter,
129  SIM_ConstDataArray &rels) const;
130  /// Removes the relationship at the specified position.
131  void removeRelationship(int index);
132  /// Removes the relationship with the specified name.
133  void removeRelationship(const char *name);
134  /// Removes the specified relationship.
135  void removeRelationship(SIM_Relationship *rel);
136  /// Removes all relationships created by a particular DOP node. If -1
137  /// is specified, then all relationships are removed. Relationships in
138  /// the "except" array are not removed.
139  void removeAllRelationships(int createdby,
140  const SIM_RelationshipArray *except);
141 
142  /// Returns either a SIM_Relationship or SIM_Object depending on the
143  /// information stored in the id parameter.
144  const SIM_RootData *getRootDataFromId(
145  const SIM_RootDataId &id) const;
146 
147  // Only HOM should call this method:
148  SIM_RootData *getNonConstRootDataFromId(
149  const SIM_RootDataId &id);
150 
151  /// Returns a pointer to the state of an object at some time in the past.
152  /// This function searches for these past object states in three ways.
153  /// First, if the specified time is equal to a past time step, the state
154  /// for that time step is returned. Second, if the specified time is not
155  /// equal to a past time step, then past time steps are searched for
156  /// object states stored explicitly with createSubStepObject(). Finally,
157  /// if both these methods fail to find a matching object state, then the
158  /// closest object states before and after the specified time are found
159  /// using the first two approaches. Then a new object state is created by
160  /// interpolating between these two states using SIM_Data::interpolate().
161  /// This third approach is skipped if allowinterpolation is set to false.
162  /// If no previous or no future object state can be found, then this
163  /// function returns null.
164  const SIM_Object *getObjectAtTime(const SIM_Object &object,
165  const SIM_Time &time,
166  bool allowinterpolation) const;
167 
168  /// Returns a non-const pointer to an object for a particular time.
169  /// This function is very similar to getObjectAtTime() except for two
170  /// things. First, it requires a non-const starting object, and it is
171  /// a non-const function. Second, if the specified time exactly matches
172  /// a time in the past, the returned object will be a copy of that past
173  /// object, not the object itself. Otherwise modifying that object could
174  /// modify the past. However, if the current time is sepcified, the actual
175  /// object (i.e. a pointer to the passed in SIM_Object) is returned.
176  /// This function is for use by solvers that want to modify their
177  /// affector objects and which do substepping.
178  SIM_Object *getAffectorAtTime(SIM_Object &object,
179  const SIM_Time &time,
180  bool allowinterpolation);
181 
182  /// This is a more direct, more efficient method for reading
183  /// cached versions of objects from previous frames, without interpolation.
184  ///
185  /// Before the call, 'past_objects' must be a valid array of
186  /// SIM_Object* arrays and 'past_times' must be a valid array of SIM_Time.
187  /// 'past_objects' must have size 'max_past'
188  /// each element of 'past_objects' must be an array of SIM_Object* of
189  //// size 'num_objects'
190  /// 'past_times' must be an array of size 'max_past'
191  ///
192  /// Output:
193  /// The number of cached frames is returned.
194  /// The cached version of object[oi] at time past_times[i]
195  /// is stored in the array past_objects[i] at location oi,
196  /// for all 0 <= i < "the returned number of cached frames"
197 
198  int getObjectsAtPastTimes(
199  const SIM_Object**const past_objects[],
200  SIM_Time past_times[],
201  const int num_objects,
202  const SIM_Object*const objects[],
203  const int max_past
204  );
205 
206  /// Creates an object in the current state with a particular time stamp.
207  /// This function is useful for solvers that need to do their own time
208  /// stepping with step sizes smaller than the globally specified time
209  /// step size. These explicitly stored subsamples are accessible later
210  /// with the getObjectAtTime() function.
211  SIM_Object *createSubStepObject(const SIM_Object &object,
212  const SIM_Time &time);
213  /// Removes an object previously created by createSubStepObject().
214  /// If the allwithmatchingid parameter is set to true, not only will
215  /// the specified object be destroyed, but all other objects with the
216  /// same object id created using createSubStepObject() will be destroyed.
217  /// This provides a quick way to destroy all temporary working copies
218  /// of a particular object.
219  void removeSubStepObject(SIM_Object *objectattime,
220  bool allwithmatchingid);
221 
222  /// Loads a simulation state from a file and merges it into the current
223  /// simulation state. The data that gets loaded is not allowed to do any
224  /// sharing of data with the current state, since the data id's can't
225  /// be expected to match. Objects from the file will replace objects from
226  /// the current state if their object ids match. Objects loaded from the
227  /// file will be flagged so that they will not be solved in the current
228  /// timestep. In subsequent timesteps these objects will be solved.
229  /// The filter parameter specifies which objects stored in the file
230  /// are merged in.
231  bool mergeSimulationFile(const char *filename,
232  const SIM_DataFilter &filter,
233  const SIM_ObjectArray &replaceobjects,
234  const OP_Node *defaultcreator,
235  bool forcecreatortodefault,
236  bool acceptnewobjects,
237  bool matchbyname,
238  const char *nameprefix);
239  /// Schedules some objects to be saved to a files at the end of the
240  /// current timestep. The filter parameter makes it possible to save
241  /// only some of the objects to the file. The actual save happens
242  /// in the postSimulationStep().
243  void saveSimulationFile(OP_Node *node,
244  const char *filename,
245  const SIM_DataFilter &filter,
246  const SIM_ObjectArray &objects,
248  /// Saves the entire current state of the simulation immediately.
249  bool saveSimulationState(std::ostream &os,
251  bool saveSimulationStateToFile(const char *fname,
253  bool threadedio) const;
254 
255  /// Sets the current time for the simulation. If the new simulation
256  /// time is less than the current time, the SIM_Cache is simply set to
257  /// use its best match for the chosen time. If the new simulation time
258  /// is greater than the current time, the simulation is stepped forward
259  /// in time to the new time. The resimlasttimestep parameter causes the
260  /// most recent cache entry to be deleted before trying to set the
261  /// current time. This is useful if some parameter of the simulation
262  /// changes on the current timestep. It causes the timestep to be
263  /// recooked with the new parameter. This resimulation may also happen
264  /// if the simulation was interrupted the last time this function was
265  /// called. The forceresetsim parameter tells the SIM_Engine to reset
266  /// the simulation before trying to move to the specified time, whether
267  /// the reset is required or not.
268  void setSimulationTime(const SIM_Time &t,
269  bool resimlasttimestep,
270  bool forceresetsim,
271  bool allowsimulation);
272 
273  /// Marks this engine as invalid without actually clearing or
274  /// resetting anything. A proper reset implies also a frame
275  /// advance to the first frame that can be expensive.
276  /// Note the cache will not be cleared until it is cooked, however!
278  { myFirstSimulationStep = true; }
279 
280  /// Returns the current simulation time.
281  const SIM_Time &getSimulationTime() const;
282  /// Returns the simulation time that corresponds to the given global time.
283  const SIM_Time getEngineTime(const SIM_Time &t) const;
284  /// Returns the global time that corresponds to the given simulation time.
285  const SIM_Time getGlobalTime(const SIM_Time &t) const;
286  /// Returns the time of the earliest simulation state in the cache.
287  const SIM_Time &getEarliestCacheTime() const;
288  const SIM_Time &getLatestCacheTime() const;
289  /// Returns the cached frames.
290  /// Inclusive.
291  void getCachedFrames(UT_IntArray &frames, bool inmemory) const;
292  /// Returns a reference to the cache options for this simulation.
293  const SIM_CacheOptions &getCacheOptions() const;
294  /// Sets the cache options for this simulation.
295  void setCacheOptions(const SIM_CacheOptions &o);
296  /// Returns the time step size.
297  const SIM_Time &getTimeStep() const;
298  /// Sets the global time step size.
299  void setTimeStep(const SIM_Time &time);
300  /// Gets the maximum number of allowed feedback iterations.
301  int getMaxFeedbackIterations() const;
302  /// Sets the maximum number of allowed feedback iterations.
303  void setMaxFeedbackIterations(int max);
304  /// Gets the current feedback iteration we are on. If we are not
305  /// currently solving, this function will return -1;
306  int getFeedbackIteration() const;
307  /// Returns true if the engine is providing data hierarchy hints.
308  bool getProvideDataHints() const;
309  /// Specifies whether the engine should provide data hierarchy hints.
310  void setProvideDataHints(bool providehints);
311  /// Gets the id for the node that is currently being processed.
313  { return myCurrentCreatorId; }
314  /// Gets the index of the node output that is currently being processed.
316  { return myCurrentCreatorIndex; }
317  /// Set the creator information. These values are automatically reset
318  /// to (-1, -1) before performing a simulation step.
319  void setCreatorInfo(int id, int index);
320  /// Returns the SIM_Data pointer with the specified unique id.
321  const SIM_Data *getConstDataWithId(const UT_Guid &id) const;
322  /// Returns the simulation frame number that corresponds to the given
323  /// time. The simulation frame number is the number of timesteps that
324  /// need to be run to get to the specified time, plus one (so that
325  /// time zero is frame 1).
326  int getSimulationFrame(const SIM_Time &time) const;
327  /// Returns the simulation time that corresponds to the given simulation
328  /// frame.
329  const SIM_Time getSimulationTime(int frame) const;
330 
331  /// Adds an error to the engine. The object and data parameters allow
332  /// the DOP_Engine to put the error message on an appropriate DOP Node.
333  /// Errors are found in the SIM error file. This function simply calls
334  /// addErrorSubclass().
335  void addError(const SIM_RootData *rootdata,
336  const SIM_Data *data,
337  int errorcode,
338  const char *errorparm,
339  UT_ErrorSeverity severity) const;
340  /// Resets the errors stored in the simulation.
341  void resetErrors();
342 
343  /// Returns the total amount of memory used by all data currently in
344  /// this simulation, at the current time or in the cache.
345  int64 getTotalMemorySize() const;
346 
347  /// Removes all node interests from the engine.
348  void removeAllOPInterests() const;
349  /// Adds an interest in the supplied node. When the node changes, the
350  /// engine's handleExternalNodeChange function will be called.
351  void addOPInterest(OP_Node *node) const;
352  void addGuideOPInterest(OP_Node *node) const;
353 
354  /// Passes up to our owner to alert anything that needs an OP_Event
355  /// in response to use becoming dirty.
357 
358  /// Returns all available data type names.
359  /// If a null type pointer is passed in, this function returns a list
360  /// of every data type that the SIM_Engine can create. If a data type
361  /// name is passed in, the list returned will only contain those data
362  /// types that can be cast to the specified data type using the
363  /// SIM_Data::getPointerToType() function.
364  void getDataTypes(UT_StringArray &datatypes,
365  const UT_StringRef &datatype) const;
366  /// Returns all available data types and the source of their definition.
367  /// The definition source will be an empty string if the data type is
368  /// defined internally to Houdini. Otherwise it will be the name of the
369  /// DSO or DLL file that contains the data type.
370  void getDataTypeSources(UT_StringArray &datatypes,
371  UT_StringArray &srcs) const;
372  /// Returns the descriptive name for a data type.
373  /// Given the unique identifying name for a data type this function
374  /// finds the appropriate data factory and returns the descriptive
375  /// string assigned to the type.
376  const char *getDescription(
377  const UT_StringRef &datatype) const;
378  /// Returns the SIM_DopDescription from the SIM_DataFactory of a
379  /// particular data type.
380  const SIM_DopDescription *getDopDescription(
381  const UT_StringRef &datatype) const;
382 
383  /// Returns whether we can cast to a superclass data type without creating
384  /// the SIM_Data.
385  static bool canCastToDataType(
386  const UT_StringRef &from_type,
387  const UT_StringRef &to_type);
388 
389  /// Filters all our simulation objects based on a string pattern.
390  /// Note that the time value is a simulation time, not global time.
391  void findAllObjectsFromString(const char *objspec,
392  SIM_ConstObjectArray &objects,
393  const SIM_Time &t,
394  bool interpolateobj) const;
395  /// Returns a single object matching a specified string pattern.
396  /// Note that the time value is a simulation time, not global time.
397  const SIM_Object *findObjectFromString(const char *objspec,
398  int whichmatch, int *nummatch,
399  const SIM_Time &t,
400  bool interpolateobj) const;
401  /// Returns a list of objects created by the specified node, or any
402  /// nodes inside the specified node (if it is a subnet).
403  void findAllObjectsCreatedBy(OP_Node *creator,
404  SIM_ConstObjectArray &objects) const;
405  /// Filters all our relationships based on a string pattern.
406  /// Note that the time value is a simulation time, not global time.
407  void findAllRelationshipsFromString(
408  const char *relspec,
409  SIM_ConstDataArray &relationships,
410  const SIM_Time &t,
411  bool interpolaterel) const;
412  /// Returns a single relationship matching a specified string pattern.
413  /// Note that the time value is a simulation time, not global time.
414  const SIM_Relationship *findRelationshipFromString(
415  const char *relspec,
416  int whichmatch, int *nummatch,
417  const SIM_Time &t,
418  bool interpolaterel) const;
419 
420  /// Gets a list of all selected data in the simulation.
421  void getSelection(SIM_ConstDataArray &data) const;
422  /// Clears the selection flag on all data in this simulation.
423  void clearSelection() const;
424 
425  /// Returns the scale factor to convert a value in the provided units
426  /// into the equivalent MKS value.
427  fpreal scaleToMKS(const char *fromunits) const;
428  /// Returns the scale factor to convert a value in MKS units into the
429  /// equivalent value in the provided units.
430  fpreal scaleFromMKS(const char *tounits) const;
431 
432  /// The micronode representing the simulation result. It is marked as
433  /// dirtied and propagated whenever the simulation is cleared. Callers can
434  /// use this to express dependencies on/from the simulation.
436  { return mySimMicroNode; }
437  const DEP_MicroNode & simMicroNode() const
438  { return mySimMicroNode; }
439  /// This micronode holds the simulation input. It is wired directly
440  /// to the simMicroNode, however, does not care about refilter
441  /// events.
443  { return mySimInputMicroNode; }
445  { return mySimInputMicroNode; }
447  { return myResimParmsMicroNode; }
449  { return myResimParmsMicroNode; }
451  { return myRefilterParmsMicroNode; }
453  { return myRefilterParmsMicroNode; }
454 
455  /// Fetch all the nodes in which this simulation has an interest. This
456  /// method can get the normal node interests, guide geometry interests,
457  /// or both.
458  void getExtraInterests(OP_NodeList &extras, bool normal, bool guides) const;
459 
460  /// Sets this simulation as a player. It will replace it's cache
461  /// with simulation data from the files given and not simulate,
462  /// just read the files.
463  void setIsPlayer(bool isPlayer);
464  bool isPlayer() const { return myIsPlayer; }
465 
466  /// Rebuilds the player cache.
467  void resetPlayer();
468  /// Tries to expand the cached frame range
469  void updatePlayerFrames();
470 
471 protected:
472  /// Resets the simulation to a clean state. This function calls
473  /// clearSimulation(), then builds a single empty simulation state.
474  virtual void resetSimulation();
475  /// This function is run before passing each object to its solver.
476  /// The implementation at this level clears out all temporary data
477  /// from the simulation objects.
478  virtual void preSimulationStep();
479  /// This function is run after all objects are processed by their solvers.
480  virtual void postSimulationStep();
481  /// This function is called by our cache whenever the most recent
482  /// simulated timestep is being removed from memory (either deleted
483  /// or moved onto disk).
484  virtual void clearReferencesToMostRecentState();
485  /// Initializes a newly created object. This function is called by
486  /// addSimulationObject(). The default implementation does nothing.
487  virtual void objectCreated(SIM_Object *object);
488  /// Allows special handling of objects that are being removed. This
489  /// function is called by removeSimulationObject(). The default
490  /// implementation does nothing.
491  virtual void objectRemoved(SIM_Object *object);
492  /// Override this method to handle changes to external nodes in which
493  /// we have an interest. The default implementation does nothing.
494  virtual void handleExternalNodeChangeSubclass(
495  OP_Node *changednode,
496  OP_EventType eventtype,
497  void *data,
498  bool isguide);
499  /// The default implementation of this function does nothing.
500  virtual void addErrorSubclass(const SIM_RootData *rootdata,
501  const SIM_Data *data,
502  int errorcode,
503  const char *errorparm,
504  UT_ErrorSeverity severity) const;
505  virtual void resetErrorsSubclass();
506  /// Returns the simulation time that corresponds to the given global time.
507  virtual const SIM_Time getEngineTimeSubclass(const SIM_Time &t) const;
508  /// Returns the global time that corresponds to the given simulation time.
509  virtual const SIM_Time getGlobalTimeSubclass(const SIM_Time &t) const;
510  /// This function is the only way for a SIM_Engine subclass to get a
511  /// non-const SIM_Object pointer.
512  SIM_Object *getNonConstSimulationObject(int index);
513 
514  /// Alerts our owner that we are simulating due to an internally
515  /// generated need. Returns the previous state
516  virtual bool setIsSimulating(bool issimulating) const;
517 
518 private:
519  /// Gets the unique id of the OP_Node that owns this engine.
520  int getOwnerUniqueId() const;
521  /// Completely clears all existing data related to a simulation.
522  /// This will still reset to ensure the simulation has one good frame.
523  void clearSimulation();
524  /// Completely clears all existing data for the simulation and
525  /// does not attempt to reset. It will have no good frames and
526  /// this should only be used in the destructor path.
527  void clearSimulationForDestruction();
528  /// Takes one time step forward in the simulation.
529  void doSimulationStep(bool forreset);
530  /// Solves a meta object for one time step. All affectors will already
531  /// be solved.
532  void doSimulationStepForMetaObject(
533  SIM_MetaObject &metaobject,
534  const SIM_Time &timestep,
535  bool isLastMetaObject);
536  /// Merges another simulation state in with our current state. This
537  /// state can come from a file or another live simulation.
538  void mergeSimulation(
539  SIM_SimulationState &fromstate,
540  const SIM_DataFilter *filter,
541  const SIM_ObjectArray *replaceobjects,
542  bool acceptnewobjects,
543  bool matchbyname,
544  const char *nameprefix);
545 
546  /// Solves a relationship for one timestep. All objects will
547  /// already be solved.
548  void solveRelationship(SIM_Relationship *relation,
549  const SIM_Time &timestep);
550 
551  /// Gets the current simulation state. Notably, it returns non-const.
552  /// It is quite questionable to use this non-const function in
553  /// solvers! One should acquire non-const SIM_Objects through
554  /// your affector lists or other ways.
555  SIM_SimulationState &getSimulationObjects();
556  /// Gets a const reference to the current simulation state.
557  const SIM_SimulationState &getSimulationObjects() const;
558 
559  SIM_Object *getNonConstSimulationObjectFromId(
560  int objectid);
561  SIM_Relationship *getNonConstRelationship(const char *name);
562  SIM_Relationship *getNonConstRelationshipFromIndex(int index);
563 
564  /// Returns the SIM_Data pointer with the specified unique id.
565  SIM_Data *getDataWithId(const UT_Guid &id) const;
566  /// Destroy any data that has a zero reference count.
567  void purgeUnusedData() const;
568 
569  /// Register a new piece of data with the engine. This is
570  /// called from the SIM_DataFactory newData function to add
571  /// the data to myAllData and myAllChangedSizeData.
572  void registerNewData(SIM_Data *newdata) const;
573  /// Create data using our factories.
574  /// Only SIM_Data should use this functions.
575  SIM_Data *newData(const UT_StringRef &datatype,
576  bool doinit=true) const;
577  /// Create data using our factories, and set the uniqueid of the new data.
578  /// Only SIM_SimulationState should use this functions.
579  SIM_Data *newData(const UT_StringRef &datatype,
580  const UT_Guid &uniqueid) const;
581  /// Unregister a piece of data that is being deleted. This is
582  /// called from the SIM_DataFactory deleteData function to remove
583  /// the data from myAllData and myAllChangedSizeData.
584  void unregisterDeletedData(SIM_Data *deleteddata) const;
585  /// Delete data using our factories.
586  /// Only SIM_Data should use this functions.
587  void deleteData(SIM_Data *data) const;
588  /// This function is called when the unique id of a SIM_Data changes.
589  /// It lets us keep the myAllData hash table up to date.
590  void changeDataUniqueId(SIM_Data *data,
591  const UT_Guid &newid) const;
592  /// This function is called when a piece of data has decided it needs
593  /// to recalculate its memory size.
594  void setNeedsToRecalculateMemorySize(
595  const SIM_Data *data) const;
596 
597  /// Access our data factories.
598  SIM_DataFactory *getDataFactory(const UT_StringRef &name) const;
599  void addDataFactory(SIM_DataFactory *factory);
600 
601  /// This function is called when an external node in which we have an
602  /// interest changes. It calls handleExternalNodeChangeSubclass.
603  void handleExternalNodeChange(OP_Node *changednode,
604  OP_EventType eventtype,
605  void *data,
606  bool isguide);
607  /// This static version of handleExternalNodeChange converts the callee
608  /// pointer to a SIM_Engine pointer and calls handleExternalNodeChange
609  /// on that engine.
610  static void handleExternalNodeChange(OP_Node *changednode,
611  void *callee,
612  OP_EventType eventtype,
613  void *data);
614  static void handleExternalGuideNodeChange(OP_Node *changednode,
615  void *callee,
616  OP_EventType eventtype,
617  void *data);
618 
619  /// Clears all the active solve info attached to this engine.
620  void clearAllSolveInfo();
621 
622  /// Adds a SIM_DataFactoryCreator to the global list.
623  static void addDataFactoryCreator(SIM_DataFactoryCreator *creator);
624  /// Removes a SIM_DataFactoryCreator from the global list.
625  static void removeDataFactoryCreator(SIM_DataFactoryCreator *creator);
626  /// Returns the global list of data factory creators.
627  static UT_ValArray<SIM_DataFactoryCreator *> &getCreators();
628 
630  SIM_Cache myCache;
631  SIM_BaseCache *myBaseCache;
632  SIM_Time myTimeStep;
633  OP_Node *myOwner;
634  int myMaxFeedbackIterations;
635  int myFeedbackIteration;
636  int myCurrentCreatorId;
637  int myCurrentCreatorIndex;
638  mutable UT_String myOwnerFullPath;
639  mutable UT_ValArray<SIM_SaveCommand *> mySaveCommands;
640  mutable UT_Map<UT_Guid, SIM_Data *> myAllData;
641  mutable UT_Set<const SIM_Data *> myAllChangedSizeData;
642  mutable UT_Set<OP_Node *> myOPInterestNodes;
643  mutable UT_Set<OP_Node *> myGuideOPInterestNodes;
644  mutable int64 myTotalMemorySize;
645  bool myProvideDataHints;
646  bool myFirstSimulationStep;
647  bool myLastCookInterrupted;
648  mutable SIM_ObjectSolveInfoArray mySolveInfo;
649  mutable bool myClearingSolveInfos;
650 
651  friend class SIM_Data;
652  friend class SIM_DataFactory;
654  friend class SIM_SimulationState;
655  friend class SIM_SaveCommand;
656  friend class SIM_BaseCache;
657  friend class SIM_Cache;
658 
659  friend class SIM_ObjectSolveInfo;
660 
661 protected:
667 
668 };
669 
670 #endif
vint4 max(const vint4 &a, const vint4 &b)
Definition: simd.h:4703
DEP_MicroNode & refilterParmsMicroNode()
Definition: SIM_Engine.h:450
DEP_MicroNode myResimParmsMicroNode
Definition: SIM_Engine.h:664
GT_API const UT_StringHolder filename
GLenum src
Definition: glew.h:2410
virtual void becameDirty(DEP_MicroNode &src, const DEP_PropagateData &propdata)
GLuint const GLchar * name
Definition: glew.h:1814
GT_API const UT_StringHolder time
GLuint index
Definition: glew.h:1814
DEP_MicroNode & resimParmsMicroNode()
Definition: SIM_Engine.h:446
const char * className() const override
Definition: SIM_Engine.h:50
GLenum severity
Definition: glew.h:2579
bool myIsPlayer
Definition: SIM_Engine.h:666
UT_ErrorSeverity
Definition: UT_Error.h:25
virtual void notifySimulationChangeSinksOfChange()
Definition: SIM_Engine.h:356
A reference counter base class for use with UT_IntrusivePtr.
int getCurrentCreatorId() const
Gets the id for the node that is currently being processed.
Definition: SIM_Engine.h:312
Holds pointers to a number of SIM_Relationships.
void resetToFirstSimulationStep()
Definition: SIM_Engine.h:277
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glew.h:2981
SIM_SimulationMicroNode mySimInputMicroNode
Definition: SIM_Engine.h:662
DEP_MicroNode & simInputMicroNode()
Definition: SIM_Engine.h:442
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
Holds pointers to a number of SIM_Object objects.
GLsizei n
Definition: glew.h:4040
long long int64
Definition: SYS_Types.h:116
OP_DopParentMicroNode mySimMicroNode
Definition: SIM_Engine.h:663
DEP_MicroNode myRefilterParmsMicroNode
Definition: SIM_Engine.h:665
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1253
Holds pointers to a number of const SIM_Object objects.
SIM_Engine & myEngine
Definition: SIM_Engine.h:57
const DEP_MicroNode & refilterParmsMicroNode() const
Definition: SIM_Engine.h:452
const DEP_MicroNode & resimParmsMicroNode() const
Definition: SIM_Engine.h:448
fpreal64 fpreal
Definition: SYS_Types.h:277
UT_CompressionType
bool isPlayer() const
Definition: SIM_Engine.h:464
#define SIM_API
Definition: SIM_API.h:10
OP_EventType
Definition: OP_Value.h:22
Propagation info for a dep micro node.
Definition: DEP_MicroNode.h:36
This class stores all the caching options used by the SIM_Cache.
int getCurrentCreatorIndex() const
Gets the index of the node output that is currently being processed.
Definition: SIM_Engine.h:315
const DEP_MicroNode & simInputMicroNode() const
Definition: SIM_Engine.h:444
DEP_MicroNode & simMicroNode()
Definition: SIM_Engine.h:435
GLdouble GLdouble t
Definition: glew.h:1398
const DEP_MicroNode & simMicroNode() const
Definition: SIM_Engine.h:437