8 #ifndef __SIM_Engine_h__
9 #define __SIM_Engine_h__
25 #define SIM_PATH_SEPCHAR '/'
26 #define SIM_OBJECT_SEPCHAR ':'
27 #define SIM_OBJECTNUM_SEPCHAR '.'
28 #define SIM_OBJECTDATA_SEPCHAR '/'
39 class SIM_SimulationState;
41 class SIM_MetaObjectArray;
44 class SIM_SaveCommand;
52 {
return "SIM_SimulationMicroNode"; }
80 const UT_String &getOwnerFullPath()
const;
81 void getOwnerFullPathString(
UT_String &str)
const;
86 SIM_Object *addSimulationObject(
bool solvefirstframe);
92 void removeSimulationObject(
int index);
97 void removeSimulationObject(
SIM_Object *
object);
99 int getNumSimulationObjects()
const;
101 int64 getNumSimulationData()
const;
106 const SIM_Object *getSimulationObject(
int index)
const;
111 const SIM_Object *getSimulationObjectFromId(
int objectid)
const;
124 int getNumRelationships()
const;
131 void filterConstRelationships(
135 void removeRelationship(
int index);
137 void removeRelationship(
const char *name);
143 void removeAllRelationships(
int createdby,
170 bool allowinterpolation)
const;
184 bool allowinterpolation);
202 int getObjectsAtPastTimes(
205 const int num_objects,
211 int getRelationshipsAtPastTimes(
232 void removeSubStepObject(
SIM_Object *objectattime,
233 bool allwithmatchingid);
244 bool mergeSimulationFile(
const char *
filename,
248 bool forcecreatortodefault,
249 bool acceptnewobjects,
251 const char *nameprefix,
252 bool solvecurrentframe =
false);
257 void saveSimulationFile(
OP_Node *node,
258 const char *filename,
263 bool saveSimulationState(std::ostream &os,
265 bool saveSimulationStateToFile(
const char *fname,
267 bool threadedio)
const;
282 void setSimulationTime(
const SIM_Time &
t,
283 bool resimlasttimestep,
285 bool allowsimulation);
292 { myFirstSimulationStep =
true; }
295 const SIM_Time &getSimulationTime()
const;
301 const SIM_Time &getEarliestCacheTime()
const;
302 const SIM_Time &getLatestCacheTime()
const;
306 bool inmemory)
const;
308 bool isFrameCached(
exint frame)
const;
314 const SIM_Time &getTimeStep()
const;
316 void setTimeStep(
const SIM_Time &time);
318 int getMaxFeedbackIterations()
const;
320 void setMaxFeedbackIterations(
int max);
323 int getFeedbackIteration()
const;
325 bool getProvideDataHints()
const;
327 void setProvideDataHints(
bool providehints);
330 {
return myCurrentCreatorId; }
333 {
return myCurrentCreatorIndex; }
336 void setCreatorInfo(
int id,
int index);
343 int getSimulationFrame(
const SIM_Time &time)
const;
346 const SIM_Time getSimulationTime(
int frame)
const;
355 const char *errorparm,
362 int64 getTotalMemorySize()
const;
365 void removeAllOPInterests()
const;
368 void addOPInterest(
OP_Node *node)
const;
369 void addGuideOPInterest(
OP_Node *node)
const;
373 {
return myOPInterestNodes.contains(node); }
388 void getDataTypeSuperclasses(
410 static bool canCastToDataType(
416 void findAllObjectsFromString(
const char *objspec,
419 bool interpolateobj)
const;
422 const SIM_Object *findObjectFromString(
const char *objspec,
423 int whichmatch,
int *nummatch,
425 bool interpolateobj)
const;
428 void findAllObjectsCreatedBy(
OP_Node *creator,
432 void findAllRelationshipsFromString(
436 bool interpolaterel)
const;
441 int whichmatch,
int *nummatch,
443 bool interpolaterel)
const;
448 void clearSelection()
const;
452 fpreal scaleToMKS(
const char *fromunits)
const;
455 fpreal scaleFromMKS(
const char *tounits)
const;
461 {
return mySimMicroNode; }
463 {
return mySimMicroNode; }
468 {
return mySimInputMicroNode; }
470 {
return mySimInputMicroNode; }
472 {
return myResimParmsMicroNode; }
474 {
return myResimParmsMicroNode; }
476 {
return myRefilterParmsMicroNode; }
478 {
return myRefilterParmsMicroNode; }
483 void getExtraInterests(
OP_NodeList &extras,
bool normal,
bool guides)
const;
488 void setIsPlayer(
bool isPlayer);
494 void updatePlayerFrames();
503 virtual void resetSimulation();
507 virtual void preSimulationStep();
509 virtual void postSimulationStep();
513 virtual void clearReferencesToMostRecentState();
516 virtual void objectCreated(
SIM_Object *
object);
520 virtual void objectRemoved(
SIM_Object *
object);
523 virtual void handleExternalNodeChangeSubclass(
529 virtual void addErrorSubclass(
const SIM_RootData *rootdata,
532 const char *errorparm,
534 virtual void resetErrorsSubclass();
541 SIM_Object *getNonConstSimulationObject(
int index);
545 virtual bool setIsSimulating(
bool issimulating)
const;
549 int getOwnerUniqueId()
const;
552 void clearSimulation();
556 void clearSimulationForDestruction();
558 void doSimulationStep(
bool forreset);
561 void doSimulationStepForMetaObject(
562 SIM_MetaObject &metaobject,
564 bool isLastMetaObject);
567 void mergeSimulation(
568 SIM_SimulationState &fromstate,
571 bool acceptnewobjects,
573 const char *nameprefix,
574 bool solvecurrentframe);
585 SIM_SimulationState &getSimulationObjects();
587 const SIM_SimulationState &getSimulationObjects()
const;
589 SIM_Object *getNonConstSimulationObjectFromId(
597 void purgeUnusedData()
const;
602 void registerNewData(
SIM_Data *newdata)
const;
606 bool doinit=
true)
const;
610 const UT_Guid &uniqueid)
const;
614 void unregisterDeletedData(
SIM_Data *deleteddata)
const;
624 void setNeedsToRecalculateMemorySize(
633 void handleExternalNodeChange(
OP_Node *changednode,
640 static void handleExternalNodeChange(
OP_Node *changednode,
644 static void handleExternalGuideNodeChange(
OP_Node *changednode,
650 void clearAllSolveInfo();
661 SIM_BaseCache *myBaseCache;
664 int myMaxFeedbackIterations;
665 int myFeedbackIteration;
666 int myCurrentCreatorId;
667 int myCurrentCreatorIndex;
674 mutable int64 myTotalMemorySize;
675 bool myProvideDataHints;
676 bool myFirstSimulationStep;
677 bool myLastCookInterrupted;
680 mutable bool myClearingSolveInfos;
685 friend class SIM_SimulationState;
686 friend class SIM_SaveCommand;
687 friend class SIM_BaseCache;
DEP_MicroNode & refilterParmsMicroNode()
DEP_MicroNode myResimParmsMicroNode
PXL_API const char * getDescription(const ColorSpace *space)
Return the description of the color space.
GT_API const UT_StringHolder filename
virtual void becameDirty(DEP_MicroNode &src, const DEP_PropagateData &propdata)
GT_API const UT_StringHolder time
DEP_MicroNode & resimParmsMicroNode()
const char * className() const override
virtual void notifySimulationChangeSinksOfChange()
A reference counter base class for use with UT_IntrusivePtr.
int getCurrentCreatorId() const
Gets the id for the node that is currently being processed.
Holds pointers to a number of SIM_Relationships.
UT_IntrusiveRefCounter & operator=(const UT_IntrusiveRefCounter &) noexcept
Assignment operator: Does not modify counter.
void resetToFirstSimulationStep()
GLint GLint GLsizei GLint GLenum GLenum type
SIM_SimulationMicroNode mySimInputMicroNode
DEP_MicroNode & simInputMicroNode()
Holds pointers to a number of SIM_Object objects.
int64 getModVersion() const
OP_DopParentMicroNode mySimMicroNode
GLuint const GLchar * name
DEP_MicroNode myRefilterParmsMicroNode
Holds pointers to a number of const SIM_Object objects.
bool hasOPInterest(OP_Node *node) const
Returns whether there is an explicit interest on the node.
const DEP_MicroNode & refilterParmsMicroNode() const
const DEP_MicroNode & resimParmsMicroNode() const
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
Propagation info for a dep micro node.
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.
const DEP_MicroNode & simInputMicroNode() const
DEP_MicroNode & simMicroNode()
const DEP_MicroNode & simMicroNode() const
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter