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);
256 void saveSimulationFile(
OP_Node *node,
257 const char *filename,
262 bool saveSimulationState(std::ostream &os,
264 bool saveSimulationStateToFile(
const char *fname,
266 bool threadedio)
const;
281 void setSimulationTime(
const SIM_Time &
t,
282 bool resimlasttimestep,
284 bool allowsimulation);
291 { myFirstSimulationStep =
true; }
294 const SIM_Time &getSimulationTime()
const;
300 const SIM_Time &getEarliestCacheTime()
const;
301 const SIM_Time &getLatestCacheTime()
const;
305 bool inmemory)
const;
307 bool isFrameCached(
exint frame)
const;
313 const SIM_Time &getTimeStep()
const;
315 void setTimeStep(
const SIM_Time &time);
317 int getMaxFeedbackIterations()
const;
319 void setMaxFeedbackIterations(
int max);
322 int getFeedbackIteration()
const;
324 bool getProvideDataHints()
const;
326 void setProvideDataHints(
bool providehints);
329 {
return myCurrentCreatorId; }
332 {
return myCurrentCreatorIndex; }
335 void setCreatorInfo(
int id,
int index);
342 int getSimulationFrame(
const SIM_Time &time)
const;
345 const SIM_Time getSimulationTime(
int frame)
const;
354 const char *errorparm,
361 int64 getTotalMemorySize()
const;
364 void removeAllOPInterests()
const;
367 void addOPInterest(
OP_Node *node)
const;
368 void addGuideOPInterest(
OP_Node *node)
const;
372 {
return myOPInterestNodes.contains(node); }
387 void getDataTypeSuperclasses(
409 static bool canCastToDataType(
415 void findAllObjectsFromString(
const char *objspec,
418 bool interpolateobj)
const;
421 const SIM_Object *findObjectFromString(
const char *objspec,
422 int whichmatch,
int *nummatch,
424 bool interpolateobj)
const;
427 void findAllObjectsCreatedBy(
OP_Node *creator,
431 void findAllRelationshipsFromString(
435 bool interpolaterel)
const;
440 int whichmatch,
int *nummatch,
442 bool interpolaterel)
const;
447 void clearSelection()
const;
451 fpreal scaleToMKS(
const char *fromunits)
const;
454 fpreal scaleFromMKS(
const char *tounits)
const;
460 {
return mySimMicroNode; }
462 {
return mySimMicroNode; }
467 {
return mySimInputMicroNode; }
469 {
return mySimInputMicroNode; }
471 {
return myResimParmsMicroNode; }
473 {
return myResimParmsMicroNode; }
475 {
return myRefilterParmsMicroNode; }
477 {
return myRefilterParmsMicroNode; }
482 void getExtraInterests(
OP_NodeList &extras,
bool normal,
bool guides)
const;
487 void setIsPlayer(
bool isPlayer);
493 void updatePlayerFrames();
502 virtual void resetSimulation();
506 virtual void preSimulationStep();
508 virtual void postSimulationStep();
512 virtual void clearReferencesToMostRecentState();
515 virtual void objectCreated(
SIM_Object *
object);
519 virtual void objectRemoved(
SIM_Object *
object);
522 virtual void handleExternalNodeChangeSubclass(
528 virtual void addErrorSubclass(
const SIM_RootData *rootdata,
531 const char *errorparm,
533 virtual void resetErrorsSubclass();
540 SIM_Object *getNonConstSimulationObject(
int index);
544 virtual bool setIsSimulating(
bool issimulating)
const;
548 int getOwnerUniqueId()
const;
551 void clearSimulation();
555 void clearSimulationForDestruction();
557 void doSimulationStep(
bool forreset);
560 void doSimulationStepForMetaObject(
561 SIM_MetaObject &metaobject,
563 bool isLastMetaObject);
566 void mergeSimulation(
567 SIM_SimulationState &fromstate,
570 bool acceptnewobjects,
572 const char *nameprefix);
583 SIM_SimulationState &getSimulationObjects();
585 const SIM_SimulationState &getSimulationObjects()
const;
587 SIM_Object *getNonConstSimulationObjectFromId(
595 void purgeUnusedData()
const;
600 void registerNewData(
SIM_Data *newdata)
const;
604 bool doinit=
true)
const;
608 const UT_Guid &uniqueid)
const;
612 void unregisterDeletedData(
SIM_Data *deleteddata)
const;
622 void setNeedsToRecalculateMemorySize(
631 void handleExternalNodeChange(
OP_Node *changednode,
638 static void handleExternalNodeChange(
OP_Node *changednode,
642 static void handleExternalGuideNodeChange(
OP_Node *changednode,
648 void clearAllSolveInfo();
659 SIM_BaseCache *myBaseCache;
662 int myMaxFeedbackIterations;
663 int myFeedbackIteration;
664 int myCurrentCreatorId;
665 int myCurrentCreatorIndex;
672 mutable int64 myTotalMemorySize;
673 bool myProvideDataHints;
674 bool myFirstSimulationStep;
675 bool myLastCookInterrupted;
678 mutable bool myClearingSolveInfos;
683 friend class SIM_SimulationState;
684 friend class SIM_SaveCommand;
685 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