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