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