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;
311 const SIM_Time &getTimeStep()
const;
313 void setTimeStep(
const SIM_Time &time);
315 int getMaxFeedbackIterations()
const;
317 void setMaxFeedbackIterations(
int max);
320 int getFeedbackIteration()
const;
322 bool getProvideDataHints()
const;
324 void setProvideDataHints(
bool providehints);
327 {
return myCurrentCreatorId; }
330 {
return myCurrentCreatorIndex; }
333 void setCreatorInfo(
int id,
int index);
340 int getSimulationFrame(
const SIM_Time &time)
const;
343 const SIM_Time getSimulationTime(
int frame)
const;
352 const char *errorparm,
359 int64 getTotalMemorySize()
const;
362 void removeAllOPInterests()
const;
365 void addOPInterest(
OP_Node *node)
const;
366 void addGuideOPInterest(
OP_Node *node)
const;
370 {
return myOPInterestNodes.contains(node); }
385 void getDataTypeSuperclasses(
407 static bool canCastToDataType(
413 void findAllObjectsFromString(
const char *objspec,
416 bool interpolateobj)
const;
419 const SIM_Object *findObjectFromString(
const char *objspec,
420 int whichmatch,
int *nummatch,
422 bool interpolateobj)
const;
425 void findAllObjectsCreatedBy(
OP_Node *creator,
429 void findAllRelationshipsFromString(
433 bool interpolaterel)
const;
438 int whichmatch,
int *nummatch,
440 bool interpolaterel)
const;
445 void clearSelection()
const;
449 fpreal scaleToMKS(
const char *fromunits)
const;
452 fpreal scaleFromMKS(
const char *tounits)
const;
458 {
return mySimMicroNode; }
460 {
return mySimMicroNode; }
465 {
return mySimInputMicroNode; }
467 {
return mySimInputMicroNode; }
469 {
return myResimParmsMicroNode; }
471 {
return myResimParmsMicroNode; }
473 {
return myRefilterParmsMicroNode; }
475 {
return myRefilterParmsMicroNode; }
480 void getExtraInterests(
OP_NodeList &extras,
bool normal,
bool guides)
const;
485 void setIsPlayer(
bool isPlayer);
491 void updatePlayerFrames();
500 virtual void resetSimulation();
504 virtual void preSimulationStep();
506 virtual void postSimulationStep();
510 virtual void clearReferencesToMostRecentState();
513 virtual void objectCreated(
SIM_Object *
object);
517 virtual void objectRemoved(
SIM_Object *
object);
520 virtual void handleExternalNodeChangeSubclass(
526 virtual void addErrorSubclass(
const SIM_RootData *rootdata,
529 const char *errorparm,
531 virtual void resetErrorsSubclass();
538 SIM_Object *getNonConstSimulationObject(
int index);
542 virtual bool setIsSimulating(
bool issimulating)
const;
546 int getOwnerUniqueId()
const;
549 void clearSimulation();
553 void clearSimulationForDestruction();
555 void doSimulationStep(
bool forreset);
558 void doSimulationStepForMetaObject(
559 SIM_MetaObject &metaobject,
561 bool isLastMetaObject);
564 void mergeSimulation(
565 SIM_SimulationState &fromstate,
568 bool acceptnewobjects,
570 const char *nameprefix);
581 SIM_SimulationState &getSimulationObjects();
583 const SIM_SimulationState &getSimulationObjects()
const;
585 SIM_Object *getNonConstSimulationObjectFromId(
593 void purgeUnusedData()
const;
598 void registerNewData(
SIM_Data *newdata)
const;
602 bool doinit=
true)
const;
606 const UT_Guid &uniqueid)
const;
610 void unregisterDeletedData(
SIM_Data *deleteddata)
const;
620 void setNeedsToRecalculateMemorySize(
629 void handleExternalNodeChange(
OP_Node *changednode,
636 static void handleExternalNodeChange(
OP_Node *changednode,
640 static void handleExternalGuideNodeChange(
OP_Node *changednode,
646 void clearAllSolveInfo();
657 SIM_BaseCache *myBaseCache;
660 int myMaxFeedbackIterations;
661 int myFeedbackIteration;
662 int myCurrentCreatorId;
663 int myCurrentCreatorIndex;
670 mutable int64 myTotalMemorySize;
671 bool myProvideDataHints;
672 bool myFirstSimulationStep;
673 bool myLastCookInterrupted;
676 mutable bool myClearingSolveInfos;
681 friend class SIM_SimulationState;
682 friend class SIM_SaveCommand;
683 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()
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