HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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  exint getExpectedIterations() const { return myExpectedIterations; }
44  exint getStartPass() const { return myStartPass; }
45 
46 
47  void setPass(exint pass, GU_DetailHandle feedback);
48 
49  bool hasPieceGeo() const
50  { return !myIterationGeo.isNull() && myPieceExtractor; }
51 
52  /// Allows one to reduce the reference count when all inputs
53  /// have extracted the feedback for inplace operations.
55  {
56  if (!myFeedbackGeo.isNull())
57  myFeedbackGeo.removePreserveRequest();
58  myFeedbackGeo.clear();
59  }
60 
61  /// Erases the piece extractor as it holds hard references
62  /// to geometry
63  void clearPieceExtractor();
64 
65  protected:
66  /// myFeedbackGeo is the last fed-back version of the geometry
67  /// going through the system.
69 
70  /// myIterationGeo is the second input, it is kept here so
71  /// we can extract the pieces just-in-time and unlock the
72  /// second input.
74 
75  /// The most recently extracted piece of the myIterationGeo. We
76  /// cache it in case there are multiple next sops grabbing it, or
77  /// for when we are done and the user is manually cooking the chain.
79 
80  /// Likewise, the cached metadata.
82 
83  /// Functor object to extract a subset of the iteration geo.
84  sop_PieceExtractor *myPieceExtractor;
85 
86  /// Used to dynamically recompute piece geo and provide
87  /// info.
91 
93  fpreal myStartValue, myIncrement;
94 
98  };
99 
100  SOP_BlockEndFor(OP_Network *net, const char *name, OP_Operator *entry);
101  virtual ~SOP_BlockEndFor();
102 
103  virtual bool updateParmsFlags();
104 
105  static OP_Node *myConstructor(OP_Network *net,
106  const char *name,
107  OP_Operator *entry);
108  static PRM_Template myTemplateList[];
109 
110  virtual void getNodeSpecificInfoText(OP_Context &context,
111  OP_NodeInfoParms &iparms);
112 
113  // Fill in tree with this node's details
114  virtual void fillInfoTreeNodeSpecific(UT_InfoTree &tree,
115  const OP_NodeInfoTreeParms &parms);
116 
117  // Special methods used to get the feedback geometry from Next
118  // SOPs.
119  virtual bool hasFeedbackGeo() const;
120  virtual GU_DetailHandle getFeedbackGeo() const;
121 
122  virtual bool hasPieceGeo() const;
123  virtual GU_DetailHandle getPieceGeo();
124 
125  // Force the for sop to cook its iteration input, if possible.
126  // (will respect the debug setting)
127  // Afterwards hasPieceGeo() is likely valid. You will get recursion
128  // issues if you have a Next in the second input, but you are
129  // doing something wrong there regardless.
130  virtual bool cookPieceGeo(OP_Context &context, SOP_Node *caller);
131 
132  virtual GU_DetailHandle cookMetadata(OP_Context &context, SOP_Node *caller);
133 
134  // Registers all each sops that want to be told if the feedback
135  // geo changes.
136  virtual void registerEachSOP(SOP_Node *sop);
137  virtual void unregisterEachSOP(SOP_Node *sop);
138 
139  exint getCurrentCookPass() const { if (myForState) return myForState->getCurrentCookPass(); return -1; }
140  exint getExpectedIterations() const { if (myForState) return myForState->getExpectedIterations(); return 0; }
141 
142  // Resets our current cook pass to the default values before
143  // the SOP cooked the first time.
144  static int resetCookPassStatic(void *op, int idx, fpreal t,
145  const PRM_Template *);
146  void resetCookPass(fpreal t);
147 
148  /// Finds the template sop, either what is wired to second
149  /// input or to the linked Begin.
150  SOP_Node *getTemplateSOP(fpreal t) const;
151  /// Finds the feedback sop, what is wired to the primary input
152  SOP_Node *getFeedbackSOP(fpreal t) const;
153 
154  static sop_PieceExtractor *buildPieceExtractor(SOP_BlockEndFor *node,
155  SOP_Node *error_sink,
156  fpreal t,
157  GU_DetailHandle iterationgeo,
158  exint &niterations);
159 
160  // Should all inputs be treated as enclosed?
161  virtual bool encloseInputs() const { return false; }
162 
163 protected:
164  virtual OP_ERROR cookMySop(OP_Context &context);
165 
166  virtual const char *inputLabel(unsigned idx) const;
167  virtual void getDescriptiveName(UT_String &name) const;
168 
169  virtual void dirtyAllEachSOPs();
170 
171 
172  /// Rebuilds our myPieceExtractor from our relevant parameters &
173  /// from the current myIterationGeo. Returns number of items.
174  exint rebuildPieceExtractor(OP_Context &context);
175 
176 public:
177  int ITERATIONMETHOD(fpreal t) const
178  { return evalInt("itermethod", 0, t); }
179  int FORMETHOD(fpreal t) const
180  { return evalInt("method", 0, t); }
182  { return evalInt("iterations", 0, t); }
183  void ATTRIB(UT_String &str, fpreal t) const
184  { evalString(str, "attrib", 0, t); }
185  bool USEMAXITER(fpreal t) const
186  { return evalInt("usemaxiter", 0, t); }
187  bool USEATTRIB(fpreal t) const
188  { return evalInt("useattrib", 0, t); }
189  int MAXITER(fpreal t) const
190  { return evalInt("maxiter", 0, t); }
191  void PRIMARYNEXT(UT_String &str, fpreal t) const
192  { evalString(str, "blockpath", 0, t); }
193  void TEMPLATEPATH(UT_String &str, fpreal t) const
194  { evalString(str, "templatepath", 0, t); }
195  bool DOSINGLEPASS(fpreal t) const
196  { return evalInt("dosinglepass", 0, t); }
197  int SINGLEPASS(fpreal t) const
198  { return evalInt("singlepass", 0, t); }
199  bool STOPCONDITION(fpreal t) const
200  { return evalInt("stopcondition", 0, t); }
201  bool MULTITHREAD(fpreal t) const
202  { return evalInt("multithread", 0, t); }
203 
204 protected:
207 
208 private:
209 };
210 
211 #endif
212 
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()
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:109
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:263
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