HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
POPNET_Node.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 __POPNET_Node_h__
9 #define __POPNET_Node_h__
10 
11 #include "POPNET_API.h"
12 #include <OP/OP_Network.h>
13 #include <POP/POP_Node.h>
14 #undef FLOAT_PARM
15 #undef INT_PARM
16 #undef STR_PARM
17 
18 #include <POP/POP_Cache.h>
19 #include <PRM/PRM_Include.h>
20 #include <PRM/PRM_Name.h>
21 #include <UT/UT_String.h>
22 
23 #define PN_SWITCHER "switcher"
24 #define PN_STARTTIME "timestart"
25 #define PN_PREROLL "timepreroll"
26 #define PN_INITIALSTATE "initialstate"
27 #define PN_RANDOMSEED "seed"
28 #define PN_OVERSAMPLE "oversample"
29 #define PN_MAXPARTICLES "maxparticles"
30 #define PN_REMOVEUNUSED "rmunused"
31 #define PN_CACHEFRAMES "caching"
32 #define PN_PATH1 "path1"
33 #define PN_PATH2 "path2"
34 #define PN_PATH3 "path3"
35 #define PN_PATH4 "path4"
36 #define PN_XFORMPATH "xformpath"
37 
38 class UT_IStream;
39 class GU_Detail;
40 
42 {
43 public:
44  virtual const char* getChildType (void) const;
45  virtual const char* getOpType (void) const;
46 
47  virtual OP_OpTypeId getChildTypeID() const;
48  virtual OP_OpTypeId getOpTypeID() const;
49 
50  static OP_Node* myConstructor (OP_Network* net, const char* name,
51  OP_Operator* entry);
52 
54  static PRM_Template myTemplateList[];
55  static PRM_Template myObsoleteList[];
56  static void buildOperatorTable (OP_OperatorTable &table);
57  static OP_Operator *getManagementOperator();
58  static const char *theChildTableName;
59 
60  virtual void resolveObsoleteParms(
61  PRM_ParmList *obsolete_parms);
62 
63  // This method is static as SOP_Pop and CHOP_Particle want to reuse
64  // the same backwards compatibility resolution mechanics.
65  static void applyBackwardsPathCompatibility(
66  PRM_ParmList *parms,
67  PRM_ParmList *obsolete);
68 
69  // This method cooks if necessary, and returns a possibly cached
70  // POP_ContextData for the given time. The caller is expected to pass
71  // in the POP_ContextData it got from the previous call to this
72  // method (0 if this is the first call). After calling this method,
73  // the caller should no longer use that old context data.
74  // Using this "exchange" mechanism, POPNET_Node can keep track of which
75  // POP_ContextData are still being referenced by POP viewers/spreadsheets,
76  // and ensure that they are not deleted prematurely.
77  POP_ContextData *getCookedContextData(fpreal t,
78  POP_ContextData *oldContextData);
79 
80  // This method is used to release context data's in which the
81  // viewer/spreadsheet has lost interest. After calling this method
82  // the caller should no longer use that context data.
83  static void releaseContextData(POP_ContextData *contextData);
84 
85  void needToRecookGuides();
86  void updateGuideGeometry();
87  void handleGeoSelectionChanged();
88 
89  OP_Network *getXformObj();
90 
91  void computeNeedReset();
92  int needReset() { return myNeedReset; }
93  int cacheObsolete() { return myCacheObsolete; }
94  void reset();
95 
96  virtual void opChanged(OP_EventType reason, void *data=0);
97 
98  static int ourDoInfoFlag;
99 
100  virtual void getNodeSpecificInfoText(OP_Context &context,
101  OP_NodeInfoParms &iparms);
102 
103  static void buildInstanceGuide(POP_ContextData *data);
104 
105  // POPNETs have no outputs
106  virtual unsigned maxOutputs() const { return 0; }
107 
108  ///Absolute width
109  virtual fpreal getW() const;
110  ///Absolute height
111  virtual fpreal getH() const;
112 
113 protected:
114  POPNET_Node (OP_Network* parent, const char* name,
115  OP_Operator* op);
116  virtual ~POPNET_Node (void);
117 
118  virtual OP_ERROR cookMe (OP_Context &context);
119  virtual OP_ERROR bypassMe(OP_Context &context, int &copied_input);
120 
121  virtual OP_DataType getCookedDataType (void) const;
122  virtual void* getCookedData (OP_Context &);
123  virtual void deleteCookedData (void);
124  virtual int saveCookedData (const char *, OP_Context &);
125  virtual int saveCookedData (std::ostream &os, OP_Context &,
126  int binary = 0);
127 
128  virtual const char* getFileExtension (int binary) const;
129 
130 private:
131  void buildPopTable();
132  void initializeContextData(float frameInc,
133  POP_Node *cookPop,
134  POP_Node *displayPop);
135  void changeCacheSize(int newsize);
136 
137  fpreal TIMESTART(void)
138  { return evalFloat(PN_STARTTIME, 0, 0); }
139  fpreal TIMEPREROLL(void)
140  { return evalFloat(PN_PREROLL, 0, 0); }
141  void INITIALSTATE(UT_String &s)
142  { evalString(s, PN_INITIALSTATE, 0, 0); }
143  int RANDOMSEED(void)
144  { return evalInt(PN_RANDOMSEED, 0, 0); }
145  int OVERSAMPLE(void)
146  { return evalInt(PN_OVERSAMPLE, 0, 0); }
147  int MAXPARTICLES(void)
148  { return evalInt(PN_MAXPARTICLES, 0, 0); }
149  int RMUNUSED(void)
150  { return evalInt(PN_REMOVEUNUSED, 0, 0); }
151 
152  // We don't use a fixed index here in preparation for multiparms.
153  int CACHEFRAMES()
154  { return evalInt("caching", 0, 0); }
155 
156  int myNeedReset;
157  int myDoReset;
158  int myNeedCookGuide;
159  int myNeedUpdateGuideGeometry;
160  int myCacheObsolete; // Need to clear cache
161  float myPrevFPS;
162  GU_Detail *myGdp;
163  POP_ContextData *myLocalContextData;
164  POP_ContextData *myCachedContextData;
165  unsigned long myNetChecksum;
166  POP_Node *myLastCookPop;
167  POP_Cache myPopCache;
168 
169  // A member to keep track of the time of the last cook. We cannot query
170  // it from the single precision myLocalContextData->myTime as doing so
171  // introduces significant cumulative error.
172  //
173  // Ideally, POP_ContextData::myTime should be stored with double precision.
174  // Such a change is not appropriate as this time, however, as that member
175  // is considered part of the input, not the state. Given that, and the
176  // fact that all uses of POP_ContextData::myTime in the POP library would
177  // implicitly cast the usage to a single precision float, storing it with
178  // double precision would be, at best, misleading.
179  double myLastCookTime;
180 
181  static POP_ContextData* theEmptyContextData;
182 };
183 
184 #endif
virtual int saveCookedData(std::ostream &os, OP_Context &, int binary=0)=0
#define PN_OVERSAMPLE
Definition: POPNET_Node.h:28
#define PN_REMOVEUNUSED
Definition: POPNET_Node.h:30
virtual fpreal getH() const
Node position/scale is used by the UI.
#define PN_INITIALSTATE
Definition: POPNET_Node.h:26
virtual OP_OpTypeId getOpTypeID() const =0
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
#define POPNET_API
Definition: POPNET_API.h:10
static OP_TemplatePair myTemplatePair
Definition: POPNET_Node.h:53
fpreal evalFloat(int pi, int vi, fpreal t) const
UT_ErrorSeverity
Definition: UT_Error.h:25
Parameters for OP_Node::getInfoText()/OP_Node::getNodeSpecificInfoText()
virtual void getNodeSpecificInfoText(OP_Context &context, OP_NodeInfoParms &parms)
virtual OP_ERROR cookMe(OP_Context &context)=0
virtual void opChanged(OP_EventType reason, void *data=0)
virtual const char * getOpType() const =0
#define PN_MAXPARTICLES
Definition: POPNET_Node.h:29
void evalString(UT_String &val, int pi, int vi, fpreal t) const
virtual void * getCookedData(OP_Context &)
static const char * theChildTableName
Definition: POPNET_Node.h:58
virtual fpreal getW() const
Node position/scale is used by the UI.
static int ourDoInfoFlag
Definition: POPNET_Node.h:98
GLboolean * data
Definition: glcorearb.h:130
GLuint const GLchar * name
Definition: glcorearb.h:785
virtual OP_DataType getCookedDataType() const =0
int cacheObsolete()
Definition: POPNET_Node.h:93
OP_OpTypeId
Definition: OP_Node.h:263
virtual const char * getChildType() const
double fpreal
Definition: SYS_Types.h:269
#define PN_PREROLL
Definition: POPNET_Node.h:25
virtual const char * getFileExtension(int binary) const =0
virtual void resolveObsoleteParms(PRM_ParmList *)
OP_EventType
Definition: OP_Value.h:22
OP_DataType
Definition: OP_DataTypes.h:27
virtual OP_OpTypeId getChildTypeID() const =0
#define PN_STARTTIME
Definition: POPNET_Node.h:24
exint evalInt(int pi, int vi, fpreal t) const
int needReset()
Definition: POPNET_Node.h:92
virtual OP_ERROR bypassMe(OP_Context &context, int &copied_input)=0
#define PN_RANDOMSEED
Definition: POPNET_Node.h:27
virtual unsigned maxOutputs() const
Definition: POPNET_Node.h:106
virtual void deleteCookedData()=0