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  // 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 
118  OP_Context &context,
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  bool unloadData() override;
128 
129  // Special methods used to get the feedback geometry from Next
130  // SOPs.
131  virtual bool hasFeedbackGeo() const;
132  virtual GU_DetailHandle getFeedbackGeo() const;
133 
134  virtual bool hasPieceGeo() const;
135  virtual GU_DetailHandle getPieceGeo();
136 
137  // Force the for sop to cook its iteration input, if possible.
138  // (will respect the debug setting)
139  // Afterwards hasPieceGeo() is likely valid. You will get recursion
140  // issues if you have a Next in the second input, but you are
141  // doing something wrong there regardless.
142  virtual bool cookPieceGeo(OP_Context &context, SOP_Node *caller);
143 
144  virtual GU_DetailHandle cookMetadata(OP_Context &context, SOP_Node *caller);
145 
146  // Registers all each sops that want to be told if the feedback
147  // geo changes.
148  virtual void registerEachSOP(SOP_Node *sop);
149  virtual void unregisterEachSOP(SOP_Node *sop);
150 
151  exint getCurrentCookPass() const { if (myForState) return myForState->getCurrentCookPass(); return -1; }
152  exint getExpectedIterations() const { if (myForState) return myForState->getExpectedIterations(); return 0; }
153 
154  // Resets our current cook pass to the default values before
155  // the SOP cooked the first time.
156  static int resetCookPassStatic(void *op, int idx, fpreal t,
157  const PRM_Template *);
158  void resetCookPass(fpreal t);
159 
160  /// Finds the template sop, either what is wired to second
161  /// input or to the linked Begin.
162  SOP_Node *getTemplateSOP(fpreal t) const;
163  /// Finds the feedback sop, what is wired to the primary input
164  SOP_Node *getFeedbackSOP(fpreal t) const;
165 
166  static sop_PieceExtractor *buildPieceExtractor(const OP_GraphProxy *graph,
167  exint forsopidx,
168  SOP_Node *error_sink,
169  fpreal t,
170  GU_DetailHandle iterationgeo,
171  exint &niterations);
172 
173  // Should all inputs be treated as enclosed?
174  bool encloseInputs() const override { return false; }
175 
176 protected:
177  OP_ERROR cookMySop(OP_Context &context) override;
178 
179  const char *inputLabel(unsigned idx) const override;
180  void getDescriptiveName(UT_String &name) const override;
181 
182  virtual void dirtyAllEachSOPs();
183 
184 
185  /// Rebuilds our myPieceExtractor from our relevant parameters &
186  /// from the current myIterationGeo. Returns number of items.
187  exint rebuildPieceExtractor(OP_Context &context);
188 
189 public:
191  { return evalInt("itermethod", 0, t); }
192  int FORMETHOD(fpreal t) const
193  { return evalInt("method", 0, t); }
195  { return evalInt("iterations", 0, t); }
196  void ATTRIB(UT_String &str, fpreal t) const
197  { evalString(str, "attrib", 0, t); }
198  bool USEMAXITER(fpreal t) const
199  { return evalInt("usemaxiter", 0, t); }
200  bool USEATTRIB(fpreal t) const
201  { return evalInt("useattrib", 0, t); }
202  int MAXITER(fpreal t) const
203  { return evalInt("maxiter", 0, t); }
204  void PRIMARYNEXT(UT_String &str, fpreal t) const
205  { evalString(str, "blockpath", 0, t); }
206  void TEMPLATEPATH(UT_String &str, fpreal t) const
207  { evalString(str, "templatepath", 0, t); }
208  bool DOSINGLEPASS(fpreal t) const
209  { return evalInt("dosinglepass", 0, t); }
210  int SINGLEPASS(fpreal t) const
211  { return evalInt("singlepass", 0, t); }
212  bool STOPCONDITION(fpreal t) const
213  { return evalInt("stopcondition", 0, t); }
214  bool MULTITHREAD(fpreal t) const
215  { return evalInt("multithread", 0, t); }
216 
217  void PRIMARYPATH(UT_String &str, fpreal t) const override
218  { str = ""; }
219 
220 protected:
223 
224 private:
225 };
226 
227 #endif
228 
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
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)
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
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
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