HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_BlockEndFor.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  * NAME: SOP_BlockEndFor.h ( SOP Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __SOP_BlockEndFor_h__
12 #define __SOP_BlockEndFor_h__
13 
14 #include "SOP_API.h"
15 #include "SOP_BlockEnd.h"
16 
17 class UT_InfoTree;
18 
19 class sop_PieceExtractor;
20 
22 {
23 public:
24 
26  {
27  public:
28  ForStateIterator(SOP_BlockEndFor *forsop, SOP_Node *error_sink, fpreal t, GU_DetailHandle iterationgeo);
30  {
31  myPieceExtractor = 0;
32  *this = iter;
33  }
35 
36  ForStateIterator &operator=(const ForStateIterator &iter);
37 
38  GU_DetailHandle getPieceGeo();
39  GU_DetailHandle getFeedbackGeo();
40  GU_DetailHandle getMetadataGeo();
41  GU_DetailHandle getIterationGeo() { return myIterationGeo; }
42  exint getCurrentCookPass() const { return myCurrentCookPass; }
43  // Expected iterations is the number we expect to actually perform
44  exint getExpectedIterations() const { return myExpectedIterations; }
45  // Full Pass iterations is the number prior to singlepass, this
46  // can ensure switching to single pass gives same behaviour for
47  // stuff that uses numiteration
48  exint getFullPassIterations() const { return myFullPassIterations; }
49  exint getStartPass() const { return myStartPass; }
50 
51 
52  void setPass(exint pass, GU_DetailHandle feedback);
53 
54  bool hasPieceGeo() const
55  { return !myIterationGeo.isNull() && myPieceExtractor; }
56 
57  /// Allows one to reduce the reference count when all inputs
58  /// have extracted the feedback for inplace operations.
60  {
61  if (!myFeedbackGeo.isNull())
62  myFeedbackGeo.removePreserveRequest();
63  myFeedbackGeo.clear();
64  }
65 
66  /// Erases the piece extractor as it holds hard references
67  /// to geometry
68  void clearPieceExtractor();
69 
70  protected:
71  /// myFeedbackGeo is the last fed-back version of the geometry
72  /// going through the system.
74 
75  /// myIterationGeo is the second input, it is kept here so
76  /// we can extract the pieces just-in-time and unlock the
77  /// second input.
79 
80  /// The most recently extracted piece of the myIterationGeo. We
81  /// cache it in case there are multiple next sops grabbing it, or
82  /// for when we are done and the user is manually cooking the chain.
84 
85  /// Likewise, the cached metadata.
87 
88  /// Functor object to extract a subset of the iteration geo.
89  sop_PieceExtractor *myPieceExtractor;
90 
91  /// Used to dynamically recompute piece geo and provide
92  /// info.
97 
99  fpreal myStartValue, myIncrement;
100 
104  };
105 
106  SOP_BlockEndFor(OP_Network *net, const char *name, OP_Operator *entry);
107  virtual ~SOP_BlockEndFor();
108 
109  virtual bool updateParmsFlags();
110 
111  static OP_Node *myConstructor(OP_Network *net,
112  const char *name,
113  OP_Operator *entry);
114  static PRM_Template myTemplateList[];
115 
116  virtual void getNodeSpecificInfoText(OP_Context &context,
117  OP_NodeInfoParms &iparms);
118 
119  // Fill in tree with this node's details
120  virtual void fillInfoTreeNodeSpecific(UT_InfoTree &tree,
121  const OP_NodeInfoTreeParms &parms);
122 
123  // Special methods used to get the feedback geometry from Next
124  // SOPs.
125  virtual bool hasFeedbackGeo() const;
126  virtual GU_DetailHandle getFeedbackGeo() const;
127 
128  virtual bool hasPieceGeo() const;
129  virtual GU_DetailHandle getPieceGeo();
130 
131  // Force the for sop to cook its iteration input, if possible.
132  // (will respect the debug setting)
133  // Afterwards hasPieceGeo() is likely valid. You will get recursion
134  // issues if you have a Next in the second input, but you are
135  // doing something wrong there regardless.
136  virtual bool cookPieceGeo(OP_Context &context, SOP_Node *caller);
137 
138  virtual GU_DetailHandle cookMetadata(OP_Context &context, SOP_Node *caller);
139 
140  // Registers all each sops that want to be told if the feedback
141  // geo changes.
142  virtual void registerEachSOP(SOP_Node *sop);
143  virtual void unregisterEachSOP(SOP_Node *sop);
144 
145  exint getCurrentCookPass() const { if (myForState) return myForState->getCurrentCookPass(); return -1; }
146  exint getExpectedIterations() const { if (myForState) return myForState->getExpectedIterations(); return 0; }
147 
148  // Resets our current cook pass to the default values before
149  // the SOP cooked the first time.
150  static int resetCookPassStatic(void *op, int idx, fpreal t,
151  const PRM_Template *);
152  void resetCookPass(fpreal t);
153 
154  /// Finds the template sop, either what is wired to second
155  /// input or to the linked Begin.
156  SOP_Node *getTemplateSOP(fpreal t) const;
157  /// Finds the feedback sop, what is wired to the primary input
158  SOP_Node *getFeedbackSOP(fpreal t) const;
159 
160  static sop_PieceExtractor *buildPieceExtractor(SOP_BlockEndFor *node,
161  SOP_Node *error_sink,
162  fpreal t,
163  GU_DetailHandle iterationgeo,
164  exint &niterations);
165 
166  // Should all inputs be treated as enclosed?
167  virtual bool encloseInputs() const { return false; }
168 
169 protected:
170  virtual OP_ERROR cookMySop(OP_Context &context);
171 
172  virtual const char *inputLabel(unsigned idx) const;
173  virtual void getDescriptiveName(UT_String &name) const;
174 
175  virtual void dirtyAllEachSOPs();
176 
177 
178  /// Rebuilds our myPieceExtractor from our relevant parameters &
179  /// from the current myIterationGeo. Returns number of items.
180  exint rebuildPieceExtractor(OP_Context &context);
181 
182 public:
183  int ITERATIONMETHOD(fpreal t) const
184  { return evalInt("itermethod", 0, t); }
185  int FORMETHOD(fpreal t) const
186  { return evalInt("method", 0, t); }
188  { return evalInt("iterations", 0, t); }
189  void ATTRIB(UT_String &str, fpreal t) const
190  { evalString(str, "attrib", 0, t); }
191  bool USEMAXITER(fpreal t) const
192  { return evalInt("usemaxiter", 0, t); }
193  bool USEATTRIB(fpreal t) const
194  { return evalInt("useattrib", 0, t); }
195  int MAXITER(fpreal t) const
196  { return evalInt("maxiter", 0, t); }
197  void PRIMARYNEXT(UT_String &str, fpreal t) const
198  { evalString(str, "blockpath", 0, t); }
199  void TEMPLATEPATH(UT_String &str, fpreal t) const
200  { evalString(str, "templatepath", 0, t); }
201  bool DOSINGLEPASS(fpreal t) const
202  { return evalInt("dosinglepass", 0, t); }
203  int SINGLEPASS(fpreal t) const
204  { return evalInt("singlepass", 0, t); }
205  bool STOPCONDITION(fpreal t) const
206  { return evalInt("stopcondition", 0, t); }
207  bool MULTITHREAD(fpreal t) const
208  { return evalInt("multithread", 0, t); }
209 
210  virtual void PRIMARYPATH(UT_String &str, fpreal t) const
211  { str = ""; }
212 
213 protected:
216 
217 private:
218 };
219 
220 #endif
221 
bool USEMAXITER(fpreal t) const
virtual bool updateParmsFlags()
int FORMETHOD(fpreal t) const
sop_PieceExtractor * myPieceExtractor
Functor object to extract a subset of the iteration geo.
virtual const char * inputLabel(unsigned idx) const
UT_ErrorSeverity
Definition: UT_Error.h:25
Parameters for OP_Node::getInfoText()/OP_Node::getNodeSpecificInfoText()
virtual void PRIMARYPATH(UT_String &str, fpreal t) const
ForStateIterator * myForState
void TEMPLATEPATH(UT_String &str, fpreal t) const
bool MULTITHREAD(fpreal t) const
void ATTRIB(UT_String &str, fpreal t) const
virtual bool encloseInputs() const
void PRIMARYNEXT(UT_String &str, fpreal t) const
int64 exint
Definition: SYS_Types.h:116
void evalString(UT_String &val, int pi, int vi, fpreal t) const
int SINGLEPASS(fpreal t) const
exint getExpectedIterations() const
virtual void getDescriptiveName(UT_String &str) const
bool USEATTRIB(fpreal t) const
ForStateIterator(const ForStateIterator &iter)
GLuint const GLchar * name
Definition: glcorearb.h:785
bool STOPCONDITION(fpreal t) const
exint getCurrentCookPass() const
bool DOSINGLEPASS(fpreal t) const
GA_AttributeOwner
Definition: GA_Types.h:33
double fpreal
Definition: SYS_Types.h:270
Parameters for OP_Node::fillInfoTree()/OP_Node::fillInfoTreeNodeSpecific()
int MAXITER(fpreal t) const
virtual void getNodeSpecificInfoText(OP_Context &context, OP_NodeInfoParms &iparms) override
int ITERATIONMETHOD(fpreal t) const
#define SOP_API
Definition: SOP_API.h:10
GU_DetailHandle myMetadataGeo
Likewise, the cached metadata.
exint evalInt(int pi, int vi, fpreal t) const
virtual void fillInfoTreeNodeSpecific(UT_InfoTree &tree, const OP_NodeInfoTreeParms &parms) override
Fill in tree with this SOP's details.
virtual OP_ERROR cookMySop(OP_Context &context)=0
exint ITERATIONS(fpreal t) const
UT_Set< int > myNextSOPList