HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_Node.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 Library (C++)
7  *
8  * COMMENTS: The base class for all SOP operators
9  * Every SOP is responsible for filling in the following methods:
10  * cookMe(float t);
11  *
12  */
13 
14 #ifndef __SOP_Node_h__
15 #define __SOP_Node_h__
16 
17 #include "SOP_API.h"
18 
19 #include "SOP_Error.h"
20 #include "SOP_Guide.h"
21 #include "SOP_NodeFlags.h"
23 
24 #include <GOP/GOP_Manager.h>
25 #include <GU/GU_Detail.h>
26 #include <GU/GU_DetailHandle.h>
27 #include <GU/GU_DetailGroupPair.h>
28 #include <GU/GU_SelectType.h>
29 #include <GU/GU_SelectionSet.h>
30 #include <GEO/GEO_Detail.h>
31 #include <GA/GA_AttributeRef.h>
32 #include <GA/GA_Types.h>
33 #include <CH/CH_LocalVariable.h>
35 #include <OP/OP_Network.h>
36 #include <PRM/PRM_Shared.h>
37 #include <UT/UT_Function.h>
38 #include <UT/UT_Lock.h>
39 #include <UT/UT_SymbolTable.h>
40 #include <UT/UT_IntArray.h>
41 #include <UT/UT_Array.h>
42 #include <UT/UT_String.h>
43 #include <SYS/SYS_Deprecated.h>
44 
45 class UT_InfoTree;
46 class UT_Undo;
47 class GU_Selection;
48 class OP_OperatorTable;
49 class SOP_Node;
50 class SOP_SoftLockData;
51 class DD_Source;
52 
53 class sop_AttributeEvaluator;
54 class SOP_NodeVerb;
55 class SOP_NodeParms;
56 class SOP_NodeCache;
57 
59 {
61 };
62 
63 extern "C" {
65 };
66 
67 class sopVarInfo;
68 
70 {
71 public:
73  int mySize;
75 };
76 
77 // A call back operator for local variables:
79  (sopVarInfo *varinfo);
80 
82 {
83 public:
84  CH_LocalVariable myVar; // Actual variable name.
85  int myTable; // Which table to use
86  UT_String myAttribName; // Name of the attribute
87  GA_ROAttributeRef myOffset; // Offset in attrib
88  sopVarInfo *mySecondaryVariable; // For LIFE that needs two.
89  int myTupleIndex; // Component in tuple
90  fpreal myDefault; // Default value if not present
91  GA_StorageClass myStorageClass; // Float, Int, or String
92  GA_AttributeOwner myDictionary; // Vertex, Point, Primitive, or Detail
93  int myVaridx; // Call back parameter.
94  SOP_LocalVarFunc myCallback; // Call back function
95 };
96 
97 // Handy function to build a meta kernel menu. Used in several sops.
98 SOP_API extern void SOPfillMetaKernelMenu(
99  void *, PRM_Name *names, int size,
100  const PRM_SpareData *, const PRM_Parm *);
101 
102 
103 SOP_API int SOPlookupGroupInput(const PRM_SpareData *spare);
104 
105 // Start of local variable indices
106 #define SOP_LOCALVAR_START 1000000
107 // Names of graph provider classes that can be returned by SOP nodes.
108 #define SOP_APEXUNIGRAPHPROVIDER_TYPE "apex"
109 
110 //___________________________________________________________________________
111 
112 typedef void sopVisualizeCallback(void * /*data*/, SOP_Node *, OP_Context &, GU_Detail *);
113 
115 {
116 public:
117  const char *getChildType() const override;
118  const char *getOpType() const override;
119 
120  OP_OpTypeId getChildTypeID() const override;
121  OP_OpTypeId getOpTypeID() const override;
122 
123  const SOP_NodeFlags &getFlags() const { return mySopFlags; }
124 
125  // Whether a SOP is cooking render is whether its object creator is.
126  int isCookingRender() const override
127  { return getCreator()->isCookingRender(); }
128 
129  // This allows us to tap into flag changes and perform unloads
130  // if necessary.
131  void opChanged(OP_EventType reason,
132  void *data=nullptr) override;
133 
134  // SOP networks need some logic to switch between using
135  // output nodes, display nodes, or render nodes. This function can
136  // also be used to just return the Output SOPs by passing false to
137  // "fallback_to_display_render".
138  // Note that this function may require syncDelayedOTL to be called
139  // beforehand if the OTL has not yet been loaded.
140  SOP_Node *getOutputSop(int outputidx,
141  bool fallback_to_display_render = true);
142 
143  /// Returns a source object that creates and loads uni-graph from this
144  /// op node. Returns null if this op node does not provide any uni-graph.
145  OP_UniGraphProvider *getUniGraphProvider() override;
146  /// Return the name of the C++ class returned by the above method.
147  UT_StringHolder getUniGraphProviderType(bool allow_cook) override;
148 
149  //
150  // Local variable functions:
151  //
152 
153  // Used to accumulate local variables:
155  const char *name) override;
157  const char *name) override;
158 
159  // Each one gets a precedence from 0-3. Resolution within
160  // a precedence is undefined.
161  // 0 is highest precedence.
162  // This is used for generic variables like Cd
163  void setVariableOrder(int detail, int prim,
164  int pt, int vtx);
165  // Gets the index of specified level. Index is same as the parameter
166  // order in setVariableOrder
167  int getVariableOrder(int level) const;
168  // Given a variable idx, gives the precedence.
169  int getVariablePrecedence(int var) const;
170 
171  // Wipe the table of local variables
172  // This is automatically called by the setup function so
173  // shouldn't be called outside it.
174 
175  bool usesFootprint() const override
176  { return true; }
177 
178  void setVisualizeCallback(sopVisualizeCallback *callback, void *data);
179 
180  /// Moves visualizer into our output list
182  int outputidx) override;
183 
184 private:
185  void clearLocalVars();
186  void updateLocalVarOffsets();
187 
188  // invalidate any cached data
189  void clearCache() override;
190 
191  // This resets the attribute caches for @ style local variables.
192  // It is implied by setupLocalVars, resetLocalVarRefs,
193  // and clearLocalVars.
194  void clearAttributeEvalCaches();
195 public:
196 
197  // the flag indicating the capture override state (on/off)
198  // This override is mirroring the kinematic override at the OBJ level.
199  // It is used to determine whether capture related SOPs use the
200  // capture parameter or regular animation parameters for cooking
201  static void setCaptureOverrideFlag( bool flag )
202  {
203  theGlobalCaptOverride = flag;
204  }
205  static bool getCaptureOverrideFlag()
206  {
207  return theGlobalCaptOverride;
208  }
209 
210 
211  // Build the local variable table
212  // This should be done AFTER you have set the local variable
213  // order & AFTER you have initialized your myGdp[*].
214  bool setupLocalVars();
215 
216  // This resets all the myCur*s to zero so we can be sure they
217  // are all cleared out. It does NOT clear the bounding box
218  // build states.
219  void resetLocalVarRefs();
220 
221  void setCurGdh(int index,
222  const GU_DetailHandle &gdh);
223  void clearCurGdh(int index);
224  const GU_DetailHandle &getCurGdh(int index);
225 
226  void setCurPoint(int index,
227  GA_Offset ptoff);
228  void clearCurPoint(int index);
229  void setCurVertex(int index,
230  GA_Offset ptoff);
231  void clearCurVertex(int index);
232  void setCurPrim(int index,
233  GA_Offset primoff);
234  void clearCurPrim(int index);
235  void setCurVertexNum(int index,
236  exint vtxnum);
237  void clearCurVertexNum(int index);
238 
239  // Called by evalVariableValue() to resolve local variables.
240  // Note that this will not resolve global variables like $F!
241  bool getVariableValueFP(fpreal &val, int index);
242 
243  // This gets the variable value as an fpreal value.
244  // Note that you should call the base class if you don't handle the given
245  // index.
246  bool evalVariableValue(fpreal &val, int index,
247  int thread) override;
248 
249  // This gets the variable value as a string. Not the string
250  // corresponding to the specified index.
251  // Note that you should call the base class if you don't handle the given
252  // index.
254  int thread) override;
255 
256  /// A simple wrapper class to help in the semantic transition of specific
257  /// addGenericVariable() and addSpecificVariable() overloads that now use
258  /// higher level tuple index arguments instead of lower level byte offset
259  /// arguments.
261  {
262  public:
263  explicit AttribTupleIndexArg(int index) : myIndex(index) {}
264  operator int() const { return myIndex; }
265  private:
266  int myIndex;
267 
268  };
269 
270  // Tries to add the variable to each of our gdps, using the appropriate
271  // "" or "2" suffix.
272  void addGenericVariable(const char *varname,
274  const AttribTupleIndexArg &tuple_idx,
276  GA_Defaults const& defaults = GA_Defaults(0.0f));
277  void addGenericVariable(const char *varname,
278  const char *attribname,
279  const AttribTupleIndexArg &tuple_idx,
281  GA_Defaults const& defaults = GA_Defaults(0.0f));
282  void addGenericVariable(const char *varname,
283  int varidx,
284  SOP_LocalVarFunc callback,
285  GA_Defaults const& defaults = GA_Defaults(0.0f));
286  // Add variables to our look up table, provided they exist in the GDP
287  // The addGeneric adds all the prefixed versions, then finds the first
288  // one which is valid and sets itself to that.
289  void addGenericVariable(const GU_Detail *gdp,
290  int gdpidx,
291  const char *varname,
292  const char *attribname,
293  const AttribTupleIndexArg &tuple_idx,
295  GA_Defaults const& defaults = GA_Defaults(0.0f));
296  void addGenericVariable(int gpdidx,
297  const char *varname,
298  int varidx,
299  SOP_LocalVarFunc callback,
300  GA_Defaults const& defaults = GA_Defaults(0.0f));
301  void addSpecificVariable(const GU_Detail *gdp,
302  int gdpidx,
303  const char *varname,
304  const char *attribname,
305  const AttribTupleIndexArg &tuple_idx,
307  GA_AttributeOwner dictionary,
308  GA_Defaults const& defaults = GA_Defaults(0.0f));
309  void addSpecificVariable(int gpidx,
310  const char *varname,
311  int varidx,
312  GA_AttributeOwner dictionary,
313  SOP_LocalVarFunc callback,
314  GA_Defaults const& defaults = GA_Defaults(0.0f));
315 
316  static int addCustomVariableCallback(const char *attr,
317  const char *varname, void *data);
318  void addCustomVariable(const char *attr,
319  const char *varname);
320 
321  void cacheVarPtBox(int gpdidx);
322  void cacheVarPrimBox(int gpdidx);
323 
324  //
325  // These are the call back functions to evaluate various variable
326  // types.
327  //
328  fpreal varCallbackT(sopVarInfo *varinfo);
329 
330  fpreal varCallbackPT(sopVarInfo *varinfo);
331  fpreal varCallbackPR(sopVarInfo *varinfo);
332  fpreal varCallbackVTX(sopVarInfo *varinfo);
333 
334  fpreal varCallbackNPT(sopVarInfo *varinfo);
335  fpreal varCallbackNPR(sopVarInfo *varinfo);
336  fpreal varCallbackNVTX(sopVarInfo *varinfo);
337 
338  fpreal varCallbackCE(sopVarInfo *varinfo);
339  fpreal varCallbackMIN(sopVarInfo *varinfo);
340  fpreal varCallbackMAX(sopVarInfo *varinfo);
341  fpreal varCallbackSIZE(sopVarInfo *varinfo);
342  fpreal varCallbackLIFE(sopVarInfo *varinfo);
343  fpreal varCallbackAGE(sopVarInfo *varinfo);
344  fpreal varCallbackBB(sopVarInfo *varinfo);
345  fpreal varCallbackWEIGHT(sopVarInfo *varinfo);
346 
347  // These methods return the variables being iterated over. The index
348  // must be 0 or 1.
349  const GU_DetailHandle &curGdh(int index) const
350  { UT_ASSERT(index == 0 || index == 1); return myCurGdh[index]; }
351 
352  // Note that the current vertex num will be 0 even if there is no
353  // current vertex. Use curVertex() to check if there is a current
354  // vertex.
355  int curVertexNum(int index) const
356  { UT_ASSERT(index == 0 || index == 1); return myCurVtxNum[index]; }
357 
358  const GU_Detail *curGdp(int index) const
359  { UT_ASSERT(index == 0 || index == 1); return myCurGdp[index]; }
360 
361  GA_Offset curVertex(int local_var_gdp_index) const
362  { UT_ASSERT(local_var_gdp_index == 0 || local_var_gdp_index == 1);
363  if (!myCurGdp[local_var_gdp_index]) return GA_INVALID_OFFSET;
364  return myCurVtxOff[local_var_gdp_index]; }
365 
367  { UT_ASSERT(index == 0 || index == 1); if (!myCurGdp[index]) return GA_INVALID_OFFSET; return myCurPtOff[index]; }
368 
369  const GEO_Primitive *curPrim(int index) const
370  { UT_ASSERT(index == 0 || index == 1); if (!myCurGdp[index]) return nullptr; return myCurGdp[index]->getGEOPrimitive(myCurPrimOff[index]); }
371 
373  { UT_ASSERT(index == 0 || index == 1); if (!myCurGdp[index]) return GA_INVALID_OFFSET; return myCurPrimOff[index]; }
374 
375  // The point bounding box is used from $BBX, $BBY, and $BBZ.
377  {
378  UT_ASSERT(index == 0 || index == 1);
379  cacheVarPtBox(index);
380  return myCurPtBox[index];
381  }
382 
383  // The primitive bounding box is used from $MINX, $MINY, and $MINZ.
385  {
386  UT_ASSERT(index == 0 || index == 1);
387  cacheVarPrimBox(index);
388  return myCurPrimBox[index];
389  }
390 
391 
392  // Function to set the pivot parm to the centroid of the input group
393  void setPivotParmToGroupCentroid(OP_Context &context);
394 
395 private:
396  // Helper function for building the drop down group menus.
397  void getGroupMenuHeader(int sourcenum, const char * title,
398  UT_String & header);
399 
400  static int buildSopGroups(const GU_Detail *src,
401  const char *prim_header,
402  const char *pt_header,
403  const char *edge_header,
404  const char *vertex_header,
405  PRM_Name *menu_entries, int themenusize,
406  unsigned type, int start,
407  bool includeselection, const PRM_Parm *parm,
408  bool include_name_attrib = true);
409 
410  static int buildSopEdgeGroups(const GU_Detail *src,
411  const char * edge_header,
412  const char *prim_header, const char *pt_header,
413  const char *vertex_header,
414  PRM_Name *menu_entries, int themenusize,
415  bool addprim, int start,
416  const PRM_Parm *parm);
417 
418  static int buildSopBreakpointGroups(const GU_Detail *src,
419  const char * brkpt_header,
420  const char * prim_header, const char *pt_header,
421  const char * edge_header,
422  const char *vertex_header,
423  PRM_Name *choicenames, int menusize,
424  bool addprim, int start,
425  const PRM_Parm *parm);
426 
427 public:
428  // The following method has to be public for some static functions in
429  // the code
430  static void buildGroupsFromSop( SOP_Node * src_sop,
431  const PRM_Parm *parm,
432  const PRM_SpareData *spare,
433  unsigned type, int start,
434  PRM_Name *menu_entries, int thelistsize,
435  bool include_name_attrib = true);
436 
437  static int buildEdgeGroupsFromSop( SOP_Node * src_sop,
438  const PRM_Parm *parm,
439  const PRM_SpareData *spare,
440  bool addprim, int start,
441  PRM_Name *menu_entries, int thelistsize );
442 
443  static int buildBreakpointGroupsFromSop( SOP_Node * src_sop,
444  const PRM_Parm *parm,
445  const PRM_SpareData *spare,
446  bool addprim, int start,
447  PRM_Name *menu_entries, int thelistsize );
448 
449  void buildNamedPrims(int thesourcenum,
450  PRM_Name *thechoicenames,
451  int themenusize,
452  const PRM_Parm *parm,
453  bool globvectors,
454  bool numberedvolumes);
455 
456  void buildInputGroups(int thesourcenum,
457  PRM_Name *thechoicenames,
458  int themenusize,
459  unsigned type, int start,
460  bool includeselection,
461  const PRM_Parm *parm);
462 
463  int buildInputEdgeGroups(int sourcenum,
464  PRM_Name *choicenames, int menusize,
465  bool addprim, int start,
466  const PRM_Parm *parm);
467 
468  int buildInputBreakpointGroups(int sourcenum,
469  PRM_Name *choicenames, int menusize,
470  bool addprim, int start,
471  const PRM_Parm *parm);
472 
473  OP_LockTypes setModelLock(OP_LockTypes lock_type,
474  void *modeler = nullptr,
475  bool allow_softlock_promotion = false,
476  UT_Undo *undo = nullptr) override;
477 
478  // Nobody should have to override this, but it's public for other people
479  OP_DataType getCookedDataType() const override;
480 
481  void *getCookedData(const OP_Context &ctx) override;
482 
483  bool getBoundingBox(UT_BoundingBox &box,
484  OP_Context &ctx) override;
485 
486  // Get cooked geometry. If "forced" is true and cooking fails, we create
487  // an empty gdp and clear the cooking flags.
488  // Note that the resulting handle may be reused in future cooks!
489  // To prevent the handle from being reused, call addPreserveRequest()
490  // on the handle.
491  const GU_Detail *getCookedGeo(OP_Context &, int forced = 0);
492  GU_DetailHandle getCookedGeoHandle(OP_Context &, int forced = 0);
493 
494  // Cook an Output at index outputidx.
495  // Add data interests to interests pointer if it isn't null.
496  // If **output isn't null, return the node that was cooked inside the
497  // subnet or nullptr if the node is bypassed.
498  GU_DetailHandle cookOutput(OP_Context &context, int outputidx, SOP_Node *interests);
499 
500  const SOP_Guide *getCookedGuide1() const;
501  const SOP_Guide *getCookedGuide2() const;
502 
503  // Cooks the view output sop if this is a subnet, otherwise itself.
504  // If it is redirected, the optional target_sop will be non-null
505  // and point to the actual SOP cooked (and to which dependencies
506  // should be added, as well as flag dependencies to this node)
507  GU_DetailHandle getCookedViewGeoHandle(OP_Context &, int forced = 0, SOP_Node **target_sop = nullptr);
508 
509  // This is similar to the getCookedGeo except it merely returns the
510  // cached GEO, if any. If none, it returns NULL without trying to cook.
511  const GU_Detail *getLastGeo() const;
512 
513  // Returns the equivalent of getLastGeo of the given input. This lets
514  // you get an input geometry without locking the input and without
515  // risking cooking it. It can, and will, return NULL without trying
516  // to cook in many cases.
517  const GU_Detail *getInputLastGeo(int input, fpreal time) const;
518 
519  OP_ERROR cookGuide1(OP_Context &context);
520  OP_ERROR cookGuide2(OP_Context &context);
521 
522 
523  enum class GuideType
524  {
525  VIEWPORT, // To be drawn by viewport
526  STATE // To pass geometry to states
527  };
528 
529  virtual int getNumGuides() { return 0; }
530  virtual GuideType getGuideType(int guide_idx)
531  { return GuideType::VIEWPORT; }
532  virtual bool isGuideTimeDep(int guide_idx) const { return false; }
533 
534  GU_DetailHandle cookGuide(int guide_idx, OP_Context &context);
535 
536  // The guide list can consist of either GOP_Guide derived objects or simple
537  // GU_Detail objects (but not a combination). This method is used to query
538  // which of the two, if any, the node generates.
540  { return OP_GUIDELIST_GUDETAIL; }
541 
542  OP_ERROR lockInput(OP_InputIdx idx,
543  OP_Context &context) override;
544  void unlockInput(OP_InputIdx idx) override;
545  OP_ERROR lockInputs(OP_Context &context) override;
546  void unlockInputs() override;
547 
548  static void buildOperatorTable(OP_OperatorTable &table);
549  static void initializeExpressions();
550 
551  // Change the string into a valid group name. A return value of true
552  // indicates that the string needed changing, in which case severity
553  // specifies the level of error this method generated (UT_ERROR_NONE,
554  // UT_ERROR_WARNING, or UT_ERROR_ABORT).
555  // Note that this does not force the name to be non-zero in length.
556  bool forceValidGroupName(UT_String &name,
558  static bool forceValidGroupName(UT_String &name,
561  // Change the string into a valid group prefix. A return value of true
562  // indicates that the string needed changing, in which case severity
563  // specifies the level of error this method generated (UT_ERROR_NONE,
564  // UT_ERROR_WARNING, or UT_ERROR_ABORT).
565  // Note that this does not force the prefix to be non-zero in length.
566  bool forceValidGroupPrefix(UT_String &prefix,
568 
569  void expandGroupMask(const char *pattern,
570  UT_String &out_names,
572  const GU_Detail *pgdp);
573  void expandGroupMask(const char *pattern,
574  UT_String &out_names,
576  { expandGroupMask(pattern, out_names, type, gdp); }
577 
578  /// Typedef to help make use of GroupCreator less verbose.
580 
581  const GA_PrimitiveGroup *parsePrimitiveGroups(const char *pattern,
582  const GroupCreator &creator,
583  bool allow_numeric = true,
584  bool ordered = false,
585  bool strict = false,
586  GA_Index offset = GA_Index(0));
587  SYS_DEPRECATED_HDK_REPLACE(15.0,GroupCreator version of function and dont cast away const on input geo)
588  const GA_PrimitiveGroup *parsePrimitiveGroups(const char *pattern,
589  GU_Detail *pgdp,
590  int allow_numeric=1,
591  int ordered = 1,
592  bool strict = false,
593  int offset = 0);
594  const GA_PrimitiveGroup *parsePrimitiveGroups(const char *pattern)
595  { return parsePrimitiveGroups(pattern, GroupCreator(gdp, false), true, true); }
596 
597  GA_PrimitiveGroup *parsePrimitiveGroupsCopy(const char *pattern,
598  const GroupCreator &creator,
599  bool allow_numeric = true,
600  bool ordered = false,
601  bool strict = false);
602  SYS_DEPRECATED_HDK_REPLACE(15.0,GroupCreator version of function and dont cast away const on input geo)
603  GA_PrimitiveGroup *parsePrimitiveGroupsCopy(const char *pattern,
604  GU_Detail *pgdp,
605  int allow_numeric=1,
606  int ordered = 1,
607  bool strict = false);
609  { return parsePrimitiveGroupsCopy(pattern, GroupCreator(gdp, false), true, true); }
610 
611  const GA_PointGroup *parsePointGroups(const char *pattern,
612  const GroupCreator &creator,
613  bool allow_numeric = true,
614  bool ordered = false,
615  bool strict = false,
616  GA_Index offset = GA_Index(0));
617  SYS_DEPRECATED_HDK_REPLACE(15.0,GroupCreator version of function and dont cast away const on input geo)
618  const GA_PointGroup *parsePointGroups(const char *pattern,
619  GU_Detail *pgdp,
620  int allow_numeric=1,
621  int ordered = 1,
622  bool strict = false,
623  int offset = 0);
624  const GA_PointGroup *parsePointGroups(const char *pattern)
625  { return parsePointGroups(pattern, GroupCreator(gdp, false), true, true); }
626 
627  GA_PointGroup *parsePointGroupsCopy(const char *pattern,
628  const GroupCreator &creator,
629  bool allow_numeric = true,
630  bool ordered = false,
631  bool strict = false);
632  SYS_DEPRECATED_HDK_REPLACE(15.0,GroupCreator version of function and dont cast away const on input geo)
633  GA_PointGroup *parsePointGroupsCopy(const char *pattern,
634  GU_Detail *pgdp,
635  int allow_numeric=1,
636  int ordered = 1,
637  bool strict = false);
638  GA_PointGroup *parsePointGroupsCopy(const char *pattern)
639  { return parsePointGroupsCopy(pattern, GroupCreator(gdp, false), true, true); }
640 
641  const GA_EdgeGroup *parseEdgeGroups(const char *pattern,
642  const GU_Detail *pgdp,
643  bool strict = true,
644  GA_Index prim_offset = GA_Index(0),
645  GA_Index point_offset = GA_Index(0));
646  const GA_EdgeGroup *parseEdgeGroups(const char *pattern)
647  { return parseEdgeGroups(pattern, (const GU_Detail *)gdp); }
648 
649  GA_EdgeGroup *parseEdgeGroupsCopy(const char *pattern,
650  const GU_Detail *pgdp);
651  GA_EdgeGroup *parseEdgeGroupsCopy(const char *pattern)
652  { return parseEdgeGroupsCopy(pattern, (const GU_Detail *)gdp); }
653 
654  const GA_BreakpointGroup *parseBreakpointGroups(const char *pattern,
655  const GU_Detail *pgdp,
656  bool strict = true,
657  GA_Index offset = GA_Index(0));
658  const GA_BreakpointGroup *parseBreakpointGroups(const char *pattern)
659  { return parseBreakpointGroups(pattern, (const GU_Detail *)gdp); }
660 
661  GA_BreakpointGroup *parseBreakpointGroupsCopy(const char *pattern,
662  const GU_Detail *pgdp);
664  {return parseBreakpointGroupsCopy(pattern,(const GU_Detail *)gdp);}
665 
666  const GA_VertexGroup *parseVertexGroups(const char *pattern,
667  const GU_Detail *pgdp,
668  bool strict = true,
669  GA_Index offset = GA_Index(0));
670  const GA_VertexGroup *parseVertexGroups(const char *pattern)
671  { return parseVertexGroups(pattern, (const GU_Detail *)gdp); }
672 
673  GA_VertexGroup *parseVertexGroupsCopy(const char *pattern,
674  const GU_Detail *pgdp);
675  GA_VertexGroup *parseVertexGroupsCopy(const char *pattern)
676  { return parseVertexGroupsCopy(pattern, (const GU_Detail *)gdp); }
677 
678  const GA_Group *parseAllGroups(const char *pattern,
679  const GroupCreator &creator,
680  bool allow_numeric = true,
681  bool ordered = false,
683  GA_GroupType bestguess=GA_GROUP_PRIMITIVE);
684  SYS_DEPRECATED_HDK_REPLACE(15.0,GroupCreator version of function and dont cast away const on input geo)
685  const GA_Group *parseAllGroups(const char *pattern,
686  GU_Detail *pgdp,
687  int allow_numeric=1,
688  int ordered=1,
690  const GA_Group *parseAllGroups(const char *pattern)
691  { return parseAllGroups(pattern, GroupCreator(gdp, false), true, true); }
692 
693  GA_Group *parseAllGroupsCopy(const char *pattern,
694  const GroupCreator &creator,
695  bool allow_numeric = true,
696  bool ordered = false,
698  GA_GroupType bestguess=GA_GROUP_PRIMITIVE);
699  SYS_DEPRECATED_HDK_REPLACE(15.0,GroupCreator version of function and dont cast away const on input geo)
700  GA_Group *parseAllGroupsCopy(const char *pattern,
701  GU_Detail *pgdp,
702  int allow_numeric=1,
703  int ordered=1,
705  GA_Group *parseAllGroupsCopy(const char *pattern)
706  { return parseAllGroupsCopy(pattern, GroupCreator(gdp, false), true, true); }
707 
708  // Explicitly destroy an adhoc group. Usually this is done on your behalf
709  // internally, after the SOP cooks, but this method allows you to delete
710  // an adhoc group within the cooking methods. Return is 0 if not found.
711  // An adhoc group is created when the SOP groups are parsed, or when you
712  // call createAdhocPrimGroup() or createAdhocPointGroup().
713 
714  int destroyAdhocGroup (const GA_Group *group)
715  { return myGroupParse.destroyAdhocGroup(group); }
717  { myGroupParse.destroyAdhocGroups(); }
719  { myGroupParse.destroyAdhocGroups(g); }
720 
721  // Set the selection based on the given geometry:
722 
723  /// Update the selection object on the detail to match the one for this
724  /// SOP node.
725  SYS_DEPRECATED(16.0)
726  void updateUserSelectionOnDetail();
727 
728  /// Set a specific override selection for this node only. Automatically
729  /// updates the selection object on the detail.
730  SYS_DEPRECATED(16.0)
731  void setNodeSelectionSet(GU_SelectionSetHandle selection_set);
732 
733  SYS_DEPRECATED(16.0)
734  GU_SelectionSetHandle nodeSelectionSet() const;
735 
736  /// Clears the override selection. Automatically updates the selection
737  /// object on the detail.
738  SYS_DEPRECATED(16.0)
739  void clearNodeSelectionSet();
740 
741  /// Copies the cooked selection generated by the SOP to the detail-external
742  /// user selection. If \c context is NULL, then the last successful cook,
743  /// if any, is used.
744  SYS_DEPRECATED(16.0)
745  void copyCookedSelectionToUserSelection(OP_Context *context = nullptr);
746 
747 public:
748 
751  void select(GU_SelectionType stype);
753 
754  void select(GA_GroupType gtype = GA_GROUP_PRIMITIVE);
755 
756  void select(const GU_SelectionHandle &selection,
757  bool add_to_sel = false);
758 
759  // Select the group. opt use its type as sel type
760  void select(const GA_Group &group, bool use_gtype = true,
761  bool add_to_sel = false);
762 
763  void select(const GEO_Primitive &prim, bool sel_prim = true,
764  bool add_to_sel = false);
765  void selectPrimitive(GA_Offset primoff,
766  bool prim_sel = true,
767  bool add_to_sel = false);
768  void selectPoint(GA_Offset ptoff, bool point_sel = true,
769  bool add_to_sel = false);
770  void selectFrom(const GEO_Primitive &prim, bool sel_prim = true,
771  bool add_to_sel = false);
772  void selectPointsFrom(GA_Offset ptoff, bool point_sel = true,
773  bool add_to_sel = false);
774  void select(const GA_Range &range, bool use_rtype = true,
775  bool add_to_sel = false);
776 
777  // Selects input based on the group supplied and the group type. If
778  // group is not null, then it's type is used, otherwise the group type
779  // is used.
780  void selectInputGroup(const GA_Group *group,
781  GA_GroupType grouptype);
782  // FIXME: Delete this function once it's swept out, because
783  // the int corresponds with PRM_GroupType instead of
784  // GA_GroupType.
785  void selectInputGroup(const GA_Group *group,
786  int grouptype);
787 
788  // If no selection is present, then create a new empty primitive cook
789  // selection group. Otherwise, clear the selection.
790  void clearSelection();
791 
793  SYS_DEPRECATED_REPLACE(14.0, "SOP_Node::clearSelection(GA_GroupType gtype)")
794  void clearSelection(GU_SelectionType stype);
796 
797  /// If the cook selection group is not of the given type, create an empty
798  /// cook selection group of that type. Otherwise, clear the existing cook
799  /// selection group.
800  void clearSelection(GA_GroupType gtype);
801 
802  // Blow away the selection and reinitialize it to 0. Much more radical
803  // than clearSelection(), which leaves behind a clean, empty selection.
804  // This method returns 1 if it had anything to destroy, else 0.
805  bool destroySelection();
806 
807  // Return 1 if selection is enabled, 0 if false.
808  bool selectionEnabled() const
809  {
810  return getHighlight();
811  }
812 
813  bool hasCookedSelection() const
814  {
815  return myHasCookedSelection;
816  }
817 
818  // Copy all the temp selections from the given SOP into this one. All
819  // existing selections on this SOP will be destroyed first. If there are
820  // no temp selections, then the cook selection is copied into a temp
821  // selection.
822  bool copyTempSelections(OP_Context &context, SOP_Node *src);
823 
824  /// Functions to convert between different group type representations.
825  /// When no group type can be guessed, GA_GROUP_INVALID,
826  /// PRM_GROUPTYPE_GUESS, PRM_UVGROUPTYPE_GUESS, or GA_ATTRIB_INVALID
827  /// Will be returned.
828  /// @{
829  static GA_GroupType getGAGroupType(PRM_GroupType prmgrouptype, GA_GroupType guess = GA_GROUP_INVALID);
830  static GA_GroupType getGAGroupType(PRM_UVGroupType prmuvgrouptype, GA_GroupType guess = GA_GROUP_INVALID);
832  static GA_GroupType getGAGroupType(GU_SelectionType guseltype);
834  static GA_GroupType getGAGroupType(GA_AttributeOwner owner);
835  static GA_GroupType getGAGroupType(const char *possiblename, GA_GroupType guess = GA_GROUP_INVALID);
836  static PRM_GroupType getPRMGroupType(GA_GroupType gagrouptype);
837  static PRM_UVGroupType getPRMUVGroupType(GA_GroupType gagrouptype);
839  static GU_SelectionType getGUSelType(GA_GroupType gagrouptype, GU_SelectionType guess = GU_SPrimitive);
841  static GA_AttributeOwner getGroupAttribOwner(GA_GroupType gagrouptype, GA_AttributeOwner guess = GA_ATTRIB_INVALID);
842  static const char *getGroupTypeName(GA_GroupType gagrouptype, const char *guess = "guess");
843  /// @}
844 
845 
846  virtual void resetSimulation () {}
847 
848  void addInstanceReference(SOP_Node *node);
849  void clearInstanceReference(SOP_Node *node);
850 
851  /// This makes *this an instance of node. It must be called within
852  /// a cookMySop. myGdpHandle is assumed to have an active write lock.
853  /// this->gdp is updated to point to the new gdp. It is assumed
854  /// that clearInstance() has already been called.
855  /// The node that you pass in must be cooked prior to instancing!
856  /// This has occured for free if it was lockInputed. Otherwise,
857  /// one must use getCookedGeoHandle to cook the SOP.
858  void makeInstanceOf(SOP_Node *node, OP_Context &context, int inputidx);
859 
860  /// This makes us shallow copy the given gu_detailhandle.
861  /// We are marked as a preserve request so with our next
862  /// cook we will not re-use this gdp. This should be
863  /// called while cooking - ie, gdp is locked.
864  /// While you can alter gdp afterwards, it is a bad idea as
865  /// you will also alter the source.
866  void makeInstanceOf(const GU_ConstDetailHandle &gdh);
867 
868  /// A hint to this node that it is about to be cooked at an
869  /// unexpected time so shouldn't reuse the existing GDP.
870  /// Should not be used without understanding the consequences.
871  virtual void makePreserveRequest();
872 
873  virtual void setVisualization(bool) {}
874  virtual void setForceCapture(bool) {}
875 
876  void getNodeSpecificInfoText(OP_Context &context,
877  OP_NodeInfoParms &iparms) override;
878 
879  /// Fill in tree with this SOP's details
880  void fillInfoTreeNodeSpecific(UT_InfoTree &tree,
881  const OP_NodeInfoTreeParms &parms) override;
882  /// Helper class that puts our geometry info into a branch.
883  void fillInfoTreeForGeometry(UT_InfoTree &branch,
884  const OP_NodeInfoTreeParms &parms);
885 
886  bool getCameraInfo(const UT_StringRef &camid,
887  const OP_Context &context,
888  DEP_MicroNode *depnode,
889  UT_StringHolder &foundcamid,
890  UT_CameraParms &camparms) override;
891 
892  bool getWorldTransformFromData(const UT_StringRef &id,
893  const OP_Context &context,
894  bool get_inverse_xform,
895  DEP_MicroNode *depnode,
896  UT_DMatrix4 &xform) override;
897 
898  /// Return an interface to apply appearance operations. The default
899  /// behaviour is to return a NULL pointer.
900  virtual SOP_ObjectAppearancePtr getObjectAppearance();
901 
902  /// Spare data used to determine which input the group menu is associated
903  /// with.
904  /// Because these rely on static initialization, do NOT use,
905  /// use the sparedata functions instead.
910  /// Uses the second input if present, else the first input.
911  /// FIXME: Support for this has only been added to allAttribsMenu.
913 
914  /// Spare data to determine whcih input the group menu is associated
915  /// with.
916  static PRM_SpareData *sparedataFirstInput();
917  static PRM_SpareData *sparedataSecondInput();
918  static PRM_SpareData *sparedataThirdInput();
919  static PRM_SpareData *sparedataFourthInput();
920  static PRM_SpareData *sparedataSecondElseFirstInput();
921 
922  ///Absolute Width
923  fpreal getW() const override;
924  ///Absolute Height
925  fpreal getH() const override;
926 
927 
928  /// Provide a verb interface to this SOP. Verb interfaces are designed
929  /// to ensure thread safety and prevent any persistent storage between
930  /// cooks.
931  virtual const SOP_NodeVerb *cookVerb() const { return nullptr; }
932 
933 protected:
934  SOP_Node(OP_Network *parent, const char *name, OP_Operator *entry);
935  ~SOP_Node() override;
936 
937  // We listen to these as our Cache relies on unique ids, so must
938  // know when they are no longer valid.
939  void setUniqueId(int id) override;
940  void clearUniqueId() override;
941 
942  // Remove the adhoc group(s) from the list of adhocs to be deleted when
943  // cooking ends. This way, deletion of the group becomes your
944  // responsibility. You should rarely and cautiously use these methods.
945  // Most of the time you need destroyAdhocGroup[s] instead.
946  // You *MUST* use the parse.*Copy methods to get the adhoc group.
947  // Otherwise, you may delete a group which you don't have ownership of.
948  int removeAdhocGroup (const GA_Group *group)
949  { return myGroupParse.removeAdhocGroup(group); }
951  { myGroupParse.removeAdhocGroups(); }
952 
953  // Protected virtuals:
954  //
955  // "cookMe" is where the actual work is done.
956  // The error is returned (OP_ERR_NONE on success).
957  //
958  OP_ERROR cookMe(OP_Context &context) override;
959  OP_ERROR bypassMe(OP_Context &context,
960  int &copied_input) override;
961 
962  virtual OP_ERROR cookMySop(OP_Context &context) = 0;
963 
964  /// This is meant to be called within cookMySop() if all you
965  /// want to do is invoke the verb returned by cookVerb().
966  OP_ERROR cookMyselfAsVerb(OP_Context &context);
967 
968  // The interests node is the node to get an extra input on whatever
969  // actual real data node is at the source of this chain.
970  virtual GU_DetailHandle cookMySopOutput(OP_Context &context, int outputidx, SOP_Node *interests);
971 
972  virtual OP_ERROR cookMyGuide1(OP_Context &context);
973  virtual OP_ERROR cookMyGuide2(OP_Context &context);
974 
975  virtual
976  GU_DetailHandle cookMyGuide(int guide_idx, OP_Context &context)
977  { return GU_DetailHandle(); }
978 
979 
980 
981  OP_ERROR pubCookInputGroups(OP_Context &context,
982  int alone = 0) override;
983 
984  void notifyGroupParmListeners(
985  int parm_index, int group_type_index,
986  const GU_Detail *pgdp, const GA_Group *group);
987 
988  /// The cookInput.+Groups functions are helper functions that look at
989  /// your Group Name and Group Type parameters (the offsets for which
990  /// are passed in parm_index, for Group Name, and group_type_index,
991  /// for group_type), evaluate them, and then call parse.+Group on that
992  /// group name. For every method other than cookInputAllGroups,
993  /// group_type_index is used only to determine whether the parm is dirty.
994  /// The pointer group is set as a return value.
995  /// If alone is true, we are cooking for a selector, and can't assume that
996  /// our gdp is valid (because it might not have been constructed by now).
997  /// If allow_reference is true, the group returned may not be modified.
998  /// If fetchgdp is true and alone is true, these new groups will be
999  /// created on the input_index-th input (because the gdp isn't constructed
1000  /// yet).
1001  /// If fetchgdp is true and alone is false, false, groups will be
1002  /// constructed on the current gdp.
1003  /// If fetchgdp is false, you must supply a gdp to create groups on in
1004  /// the paramerer pgdp.
1005  OP_ERROR cookInputPrimitiveGroups(OP_Context &context,
1006  const GA_PrimitiveGroup *&group,
1007  bool alone = false, bool do_selection = true,
1008  int parm_index = 0,
1009  int group_type_index = -1,
1010  bool allow_reference = true,
1011  bool ordered = false,
1012  bool detached = true,
1013  int input_index = 0);
1014  OP_ERROR cookInputPrimitiveGroups(OP_Context &context,
1015  const GA_PrimitiveGroup *&group,
1016  bool alone, bool do_selection,
1017  int parm_index,
1018  int group_type_index,
1019  bool allow_reference,
1020  bool ordered,
1021  const GroupCreator &creator);
1022  SYS_DEPRECATED_HDK_REPLACE(15.0,GroupCreator or other version of function and dont cast away const on input geo and be careful since defaults have changed)
1023  virtual OP_ERROR cookInputPrimitiveGroups(OP_Context &context,
1024  const GA_PrimitiveGroup *&group,
1025  GU_DetailGroupPair &detail_group_pair,
1026  int alone = 0, bool do_selection = true,
1027  int input_index = 0, int parm_index = 0,
1028  int group_type_index = -1,
1029  bool allow_reference = true,
1030  bool fetchgdp = true,
1031  GU_Detail *pgdp = nullptr);
1032 
1033  /// See cookInputPrimitiveGroups.
1034  OP_ERROR cookInputPointGroups(OP_Context &context,
1035  const GA_PointGroup *&group,
1036  bool alone = false, bool do_selection = true,
1037  int parm_index = 0,
1038  int group_type_index = -1,
1039  bool allow_reference = true,
1040  bool ordered = false,
1041  bool detached = true,
1042  int input_index = 0);
1043  OP_ERROR cookInputPointGroups(OP_Context &context,
1044  const GA_PointGroup *&group,
1045  bool alone, bool do_selection,
1046  int parm_index,
1047  int group_type_index,
1048  bool allow_reference,
1049  bool ordered,
1050  const GroupCreator &creator);
1051  SYS_DEPRECATED_HDK_REPLACE(15.0,GroupCreator or other version of function and dont cast away const on input geo and be careful since defaults have changed)
1052  virtual OP_ERROR cookInputPointGroups(OP_Context &context,
1053  const GA_PointGroup *&group,
1054  GU_DetailGroupPair &detail_group_pair,
1055  int alone = 0, bool do_selection = true,
1056  int input_index = 0, int parm_index = 0,
1057  int group_type_index = -1,
1058  bool allow_reference = true,
1059  bool fetchgdp = true,
1060  GU_Detail *pgdp = nullptr);
1061 
1062  /// See cookInputPrimitiveGroups.
1063  OP_ERROR cookInputEdgeGroups(OP_Context &context,
1064  const GA_EdgeGroup *&group,
1065  bool alone = false, bool do_selection = true,
1066  int parm_index = 0,
1067  int group_type_index = -1,
1068  bool allow_reference = true,
1069  int input_index = 0);
1070  OP_ERROR cookInputEdgeGroups(OP_Context &context,
1071  const GA_EdgeGroup *&group,
1072  bool alone, bool do_selection,
1073  int parm_index,
1074  int group_type_index,
1075  bool allow_reference,
1076  const GU_Detail *pgdp);
1077  SYS_DEPRECATED_HDK_REPLACE(15.0,GroupCreator or other version of function and dont cast away const on input geo and be careful since defaults have changed)
1078  virtual OP_ERROR cookInputEdgeGroups(OP_Context &context,
1079  const GA_EdgeGroup *&group,
1080  GU_DetailGroupPair &detail_group_pair,
1081  int alone = 0, bool do_selection = true,
1082  int input_index = 0, int parm_index = 0,
1083  int group_type_index = -1,
1084  // JML: I do not know why Edge Groups
1085  // used Copy instead of the reference version.
1086  // They are left like this so as to not cause
1087  // problems unforeseen.
1088  bool allow_reference = false,
1089  bool fetchgdp = true,
1090  GU_Detail *pgdp = nullptr);
1091 
1092  /// See cookInputPrimitiveGroups. Also, is_default_prim only affects
1093  /// cases when we're not able to guess the type of groups; in those
1094  /// cases, we try again with primitive groups if is_default_prim is
1095  /// true, and point groups otherwise.
1096  OP_ERROR cookInputAllGroups(OP_Context &context,
1097  const GA_Group *&group,
1098  bool alone = false, bool do_selection = true,
1099  int parm_index = 0,
1100  int group_type_index = -1,
1101  GA_GroupType grouptype = GA_GROUP_INVALID,
1102  bool allow_reference = true,
1103  bool is_default_prim = true,
1104  bool ordered = false,
1105  bool detached = true,
1106  int input_index = 0);
1107  OP_ERROR cookInputAllGroups(OP_Context &context,
1108  const GA_Group *&group,
1109  bool alone, bool do_selection,
1110  int parm_index,
1111  int group_type_index,
1112  GA_GroupType grouptype,
1113  bool allow_reference,
1114  bool is_default_prim,
1115  bool ordered,
1116  const GroupCreator &creator);
1117  SYS_DEPRECATED_HDK_REPLACE(15.0,GroupCreator or other version of function and dont cast away const on input geo and be careful since defaults have changed)
1118  virtual OP_ERROR cookInputAllGroups(OP_Context &context,
1119  const GA_Group *&group,
1120  GU_DetailGroupPair &detail_group_pair,
1121  int alone = 0, bool do_selection = true,
1122  int input_index = 0, int parm_index = 0,
1123  int group_type_index = -1,
1124  bool allow_reference = false,
1125  bool is_default_prim = true,
1126  bool fetchgdp = true,
1127  GU_Detail *pgdp = nullptr);
1128 
1129  /// Parse the input group specified by groupname, of type grouptype,
1130  /// in detail gdp. If allow_reference is true, this group cannot be
1131  /// later modified. If is_default_prim is true, if the group's type cannot
1132  /// be guessed, we'll try with a primitive group; otherwise, we'll try
1133  /// with a point group.
1134  const GA_Group *parseInputGroup(const UT_String &groupname,
1135  GA_GroupType grouptype, const GroupCreator &creator,
1136  bool allow_reference, bool is_default_prim,
1137  bool ordered=false);
1138  const GA_Group *parseInputGroup(const UT_String &groupname,
1139  int grouptype, GU_Detail *gdp,
1140  bool allow_reference, bool is_default_prim);
1141 
1142  /// Retrieve a list of the local variables visible to this node.
1143  /// This list is unsorted and may contain duplicates.
1144  void buildLocalVarNames(UT_StringArray &out_vars) override;
1145 
1146 private:
1147  /// Helper function for cookInput.+Groups. You shouldn't need to use it.
1148  OP_ERROR cookInputGroupsPrologue(OP_Context &context,
1149  bool alone, int input_index, bool detached,
1150  GroupCreator &creator);
1151  SYS_DEPRECATED_HDK_REPLACE(15.0,GroupCreator version of function)
1152  OP_ERROR cookInputGroupsPrologue(OP_Context &context, bool fetchgdp,
1153  bool alone, int input_index,
1154  GU_Detail *&pgdp);
1155 
1156  /// Helper function for cookInput.+Groups. You shouldn't need to use it.
1157  SYS_DEPRECATED_HDK_REPLACE(15.0,GroupCreator version of function)
1158  void cookInputGroupsEpilogue(int parm_index, int group_type_index,
1159  const GU_Detail *pgdp, const GA_Group *group,
1160  int input_index, bool fetchgdp, bool alone);
1161 
1162 protected:
1163  void inputConnectChanged(int which_input) override;
1164 
1165 //_________________________________________________________________________
1166 //
1167 // Some very useful methods used in cooking SOPs, convenience if you will
1168 //_________________________________________________________________________
1169 //
1170 
1171  // Note that the context parameter is unused!
1173  { return inputGeo(index); }
1174  const GU_Detail *inputGeo(int index) const;
1175  GU_DetailHandle inputGeoHandle(int index) const;
1176 
1177 //_________________________________________________________________________
1178 //
1179 // Convenience Error methods...
1180 //_________________________________________________________________________
1181 //
1182 public:
1183  void addError(int code, const char *msg = nullptr)
1184  { getLockedErrorManager()->addError(SOP_OPTYPE_NAME,
1185  code, msg); }
1186  void addMessage(SOP_ErrorCodes code, const char *msg = nullptr)
1187  { getLockedErrorManager()->addMessage(SOP_OPTYPE_NAME,
1188  code, msg); }
1189  void addWarning(SOP_ErrorCodes code, const char *msg = nullptr)
1190  { getLockedErrorManager()->addWarning(SOP_OPTYPE_NAME,
1191  code, msg); }
1192  void addFatal(SOP_ErrorCodes code, const char *msg = nullptr)
1193  { getLockedErrorManager()->addFatal(SOP_OPTYPE_NAME,
1194  code, msg); }
1195  void addSystemError(const char *msg = nullptr)
1196  { getLockedErrorManager()->systemError(msg);}
1198  const char *msg = nullptr)
1199  { getLockedErrorManager()->commonError(what, msg);}
1201  const char *msg = nullptr)
1202  { getLockedErrorManager()->commonWarning(what, msg);}
1203 
1204 protected:
1205  //
1206  // Methods for dealing with groups in SOPs
1207 
1208  /// We want these public as we it is perfectly fine to use them in
1209  /// static parm templates. This occurs, for example, when instancing
1210  /// multiparms.
1211 public:
1212  static PRM_ChoiceList allGroupMenu; // All the groups
1213  static PRM_ChoiceList groupMenu; // Prim and point groups
1217  static PRM_ChoiceList edgePointGroupMenu; // Edge and point groups
1220  static PRM_ChoiceList primNamedGroupMenu; // Named prim grps only
1221  static PRM_ChoiceList pointNamedGroupMenu; // Named pt groups only
1222  static PRM_ChoiceList edgeNamedGroupMenu; // Named edge groups only
1223  static PRM_ChoiceList vertexNamedGroupMenu;// Named vertex groups only
1224 
1225  static PRM_ChoiceList allGroupReplaceMenu; // All the groups
1226  static PRM_ChoiceList groupReplaceMenu; // Prim and point groups
1230  static PRM_ChoiceList edgePointGroupReplaceMenu; // Edge and point groups
1233  static PRM_ChoiceList primNamedGroupReplaceMenu; // Named prim grps only
1234  static PRM_ChoiceList pointNamedGroupReplaceMenu; // Named pt groups only
1235  static PRM_ChoiceList edgeNamedGroupReplaceMenu; // Named edge groups only
1236  static PRM_ChoiceList vertexNamedGroupReplaceMenu;// Named vertex groups only
1237 
1243 
1249 
1255 
1258 
1261 
1262  /// Returns spare data that adds a "group select" button which runs a
1263  /// python script to invoke soputils.selectGroupParm. The group_type
1264  /// should be used if only one group type is supported by the group parm.
1265  /// The group_type_parm value should be used (with group_type set to
1266  /// GA_GROUP_INVALID) if there is a separate menu parameter to specify
1267  /// the group type. The input_index indicates which input of the SOP
1268  /// the group refers to. The merge_spare_data can contain any other
1269  /// PRM_SpareData that you want on the parameter (the most common being
1270  /// "&SOP_Node::theSecondInput" to control the input used by the
1271  /// SOP_Node::primGroupMenu, SOP_Node::pointGroupMenu, or other SOP_Node
1272  /// standard parameter group menus.
1273  /// If the SOP requires or supports multi-stage selection, then it's
1274  /// possible to show previous selections during this picking sessions to
1275  /// assist the user. To do this, a comma-separated list of group types /
1276  /// group parm names can be given with assoc_groups
1277  /// (e.g. "point my_point_group_parm, edge my_edge_group_parm").
1278  /// If use_name_attr is given, the numbered group will be converted to
1279  /// "@name=group" format.
1280  /// If select_script is given, it will replace the
1281  /// `soputils.selectGroupParm(kwargs)` line.
1283  {
1284  /// AUTO: Use any bound selectors to determine whether the selection
1285  /// should be ordered or not.
1286  AUTO,
1287  /// FORCE_UNORDERED: Force an unordered selection.
1288  FORCE_UNORDERED,
1289  /// FORCE_ORDERED: Force an ordered selection.
1290  FORCE_ORDERED
1291  };
1292  static PRM_SpareData *getGroupSelectButton(
1293  GA_GroupType group_type,
1294  const char *group_type_parm = nullptr,
1295  int input_index = 0,
1296  PRM_SpareData *merge_spare_data = nullptr,
1297  const char *assoc_groups = nullptr,
1298  GroupSelectAsOrdered ordered =
1299  GroupSelectAsOrdered::AUTO,
1300  const char *use_name_attr=nullptr,
1301  const char *select_script=nullptr);
1302 
1303  static PRM_SpareData *getGroupSelectButton(
1304  GA_GroupMaskType group_mask,
1305  const char *group_type_parm = nullptr,
1306  int input_index = 0,
1307  PRM_SpareData *merge_spare_data = nullptr,
1308  const char *assoc_groups = nullptr,
1309  GroupSelectAsOrdered ordered =
1310  GroupSelectAsOrdered::AUTO,
1311  const char *use_name_attr=nullptr,
1312  const char *select_script=nullptr);
1313 
1314 protected:
1315  /// Open a tree chooser populated by the values from the @c path_attrib
1316  /// string values so the user can select primitives. The @c stringparm
1317  /// parameter is evaluated to choose the selected primitives, and the
1318  /// result is written back to the @c stringparm when the user makes their
1319  /// selection. If the @c path_attrib doesn't exist, then optionally,
1320  /// packed primitive intrinsic names can be used to populate the tree.
1321  void pickPrimitivesUsingPathAttribute(
1322  const GU_Detail &gdp,
1323  const GA_Range &srcrange,
1324  const char *stringparm,
1325  fpreal t,
1326  const char *path_attrib="path",
1327  bool use_packed_names=true);
1328  /// Pick assuming that the range is a full range of primitives. This
1329  /// method gets the primitive range from the specified @c input_number.
1330  void pickPrimitivesUsingPathAttribute(
1331  const char *stringparm,
1332  fpreal t,
1333  int input_number=0,
1334  const char *path_attrib="path",
1335  bool use_packed_names=true);
1336  /// Create a GA_Range containing the primitives specified by the values in
1337  /// the @c pickedstring. The primitives are selected from the @c
1338  /// srcrange in the given @c gdp.
1339  static GA_Range getPickedRangeUsingPathAttribute(
1340  const GU_Detail &gdp,
1341  const GA_Range &srcrange,
1342  const char *pickedstring,
1343  const char *path_attrib="path",
1344  bool use_packed_names=true);
1345 
1346  /// WARNING: The groups returned are const and should not be modified
1347  SYS_DEPRECATED_HDK_REPLACE(15.0,GroupCreator or other version of function and dont cast away const on input geo)
1348  int parseGroups(const char *pattern,
1349  GU_Detail *gdp,
1350  const GA_PrimitiveGroup *&prim,
1351  const GA_PointGroup *&points,
1352  bool strict = false);
1353 
1354  SYS_DEPRECATED_HDK_REPLACE(15.0,GroupCreator or other version of function and dont cast away const on input geo)
1355  int parseGroupsCopy(const char *pattern,
1356  GU_Detail *gdp,
1357  GA_PrimitiveGroup *&prim,
1359  GA_EdgeGroup *&edges,
1360  int unify,
1361  bool strict = false,
1362  GA_GroupType numeric_type
1363  = GA_GROUP_PRIMITIVE);
1364 
1365 public:
1366  /// Method to help fill in the menu entries representing attributes
1367  /// It will iterate though the attributes of the 'dictionary' supplied
1368  /// from the input 'input_index'. The 'approve' filter callback is applied
1369  /// (if present) and if it returns ture for an attribute, this attribute
1370  /// is appended to the 'menu_entries'. If not present, all attributes
1371  /// are appended. The number of entries appended does not exceed
1372  /// 'max_menu_size' (including the terminating sentinel). 'menu_entries' are
1373  /// sorted alphabetically and the function returns the number of entries
1374  /// appended (excluding the terminating sentinel).
1375  /// If decode_tokens is true, the tokens will contain the decoded name of
1376  /// any encoded attribute names (see UT_VarEncode::encodeAttrib). This can
1377  /// be used for parameters that support matching against decoded names
1378  /// rather than the actual attribute names.
1379  int fillAttribNameMenu(PRM_Name *menu_entries,
1380  int max_menu_size,
1381  GA_AttributeOwner dictionary,
1382  int input_index,
1383  bool (*approve)(const GA_Attribute*,void*)=nullptr,
1384  void *approve_data = nullptr,
1385  bool decode_tokens = false);
1386 
1387  /// utility method for pruning the duplicate entries in a sorted menu
1388  static void removeMenuDuplicates(PRM_Name *menu_entries, int size);
1389 
1390  /// Obtains pointers to the vertex, point, and primitive vector attributes.
1391  /// Only vector attributes are considered.
1392  /// NB: it needs access to the gdp, so use it only in the cook methods
1393  void getVectorAttribs( const char * attrib_names,
1394  UT_Array<GA_Attribute *> &vertex_attribs,
1395  UT_Array<GA_Attribute *> &point_attribs,
1396  UT_Array<GA_Attribute *> &prim_attribs);
1397  static void getVectorAttribs( GU_Detail *gdp,
1398  const char * attrib_names,
1399  UT_Array<GA_Attribute *> &vertex_attribs,
1400  UT_Array<GA_Attribute *> &point_attribs,
1401  UT_Array<GA_Attribute *> &prim_attribs);
1402 
1403  /// parses the vector attrib parameter and fills attribs array
1404  static void getVectorAttribs(const GA_AttributeDict &dict,
1405  const char * attrib_string,
1406  UT_Array<GA_Attribute *> &attribs,
1407  UT_String &bad_attribs);
1408 
1409 protected:
1410 
1411  /// Drag-n-drop receiver functions
1412 
1413  int acceptDragDrop(DD_Source &src,
1414  const char *l) override;
1415  int testDragDrop(DD_Source &src) override;
1416  void getDragDropChoice(DD_Source &src,
1417  DD_ChoiceList &choices) override;
1418 
1419  typedef void (SOP_Node::*GroupOperation)(const GA_Group *, void *);
1420 
1421  /// Perform an operation on each group matching the specified mask.
1422  int forEachGroupMatchingMask(
1423  const char *pattern,
1424  GroupOperation operation,
1425  void *data,
1426  GA_GroupType grp_type,
1427  const GEO_Detail *pgdp=nullptr,
1428  bool maintainorder=false);
1429 public:
1430  static int invokeForEachGroupMatchingMask(
1431  const GU_Detail *gdp,
1432  const char *pattern,
1433  GA_GroupType grp_type,
1434  const UT_Function<void(const GA_Group *)> &operation,
1435  bool maintainorder);
1436 protected:
1437 
1438  /// Take an optional group and subdivide it into smaller groups as
1439  /// input to operation
1440 
1441 public:
1442  static void invokeForSubdivisionOfPrimitiveGroup(
1443  const UT_Function<void(const GA_Group *)> &operation,
1444  const GA_PrimitiveGroup *group,
1445  int optype,
1446  int opstep, const char *oplabel,
1447  const GU_Detail *gdp);
1448 
1449 protected:
1450  void subdividePrimitiveGroup(
1451  GroupOperation operation,
1452  const GA_PrimitiveGroup *group,
1453  void *data, int optype,
1454  int opstep, const char *oplabel,
1455  const GU_Detail *gdp=nullptr);
1456  void subdivideMixPrimitiveGroup(
1457  GroupOperation operation,
1458  const GA_PrimitiveGroup *group,
1459  void *data, int optype,
1460  int opstep, const char *oplabel,
1461  GU_Detail *gdp=nullptr);
1462  void subdividePointGroup(
1463  GroupOperation operation,
1464  const GA_PointGroup *group,
1465  void *data, int optype,
1466  int opstep, const char *oplabel,
1467  GU_Detail *gdp=nullptr);
1468 
1469 
1470  /// Create an adhoc (internal) group and add it to the list of adhoc groups.
1471  /// The group will be deleted for you after cooking.
1473  const char *p="adhoc")
1474  { return myGroupParse.createPrimitiveGroup(geo, p); }
1476  const char *p="adhoc")
1477  { return myGroupParse.createPointGroup(geo, p); }
1479  const char *p="adhoc")
1480  { return myGroupParse.createEdgeGroup(geo, p); }
1482  const char *p="adhoc")
1483  { return myGroupParse.createVertexGroup(geo, p); }
1485  {
1486  return myGroupParse.appendAdhocGroup(
1488  }
1490  {
1491  return myGroupParse.appendAdhocGroup(geo.createDetachedPointGroup());
1492  }
1494  {
1495  return myGroupParse.appendAdhocGroup(geo.createDetachedEdgeGroup());
1496  }
1498  {
1499  return myGroupParse.appendAdhocGroup(geo.createDetachedVertexGroup());
1500  }
1502  {
1503  return myGroupParse.createBreakpointGroup(geo);
1504  }
1505 
1506  /// This is only called when the instance flag is set.
1507  /// The gdp will be modified shortly after this function is called. After
1508  /// the return, the gdp member data should contain an empty (or full)
1509  /// GU_Detail. Setting the duplicate flag will duplicate the current gdp
1510  /// in the new one.
1511  /// This used to require one to derive from it to clear references
1512  /// to myInstanceOp. This is now handled at this level.
1513  void clearInstance(int duplicate = 0);
1514  /// True if another SOP has an instance of our geometry.
1515  bool hasInstances();
1516  /// Counts the number SOPs that are descended instances of our geometry.
1517  int countInstances();
1518  /// Clears SOPs with descended instances of our geometry.
1519  void clearAllInstances();
1520 
1521  /// In between cooks, the gdp pointer might be reset by the cooking engine
1522  /// (eg. if its gdp was instanced by some other SOP). If this function
1523  /// returns true, then it will be reset to an empty gdp. If this function
1524  /// returns false, then the contents of the old gdp will be duplicated into
1525  /// the new gdp. SOPs performing simulation which rely on the cooked
1526  /// contents of its gdp from the last frame should override this to return
1527  /// false.
1528  virtual bool shouldResetGeoToEmpty() const { return true; }
1529 
1530  /// The duplicate*Source methods take a context parameter but do not
1531  /// use it for anything.
1532  /// The specified input must already be locked. The context used to
1533  /// lock the input is the context used for duplication.
1534  OP_ERROR duplicateSource(unsigned index, OP_Context &context,
1535  GU_Detail *gdp, bool clean=true);
1537  {
1538  return duplicateSource(index, context, gdp, true);
1539  }
1540 
1541  /// Only duplicates the source if the source has changed. Otherwise,
1542  /// it copies the points from the source to our gdp. It's meant to be
1543  /// used by most deformer SOPs, which simply transform the points and
1544  /// or the primitives. If wattrib is true, we check if any transforming
1545  /// primitive or vertex attributes are present and if any point attribs
1546  /// exist, and copy those too.
1547  ///
1548  /// NOTE: Do not use this if you are creating or destroying point
1549  /// attributes.
1550  ///
1551  /// NOTE: While this takes a gdp to operate on, if it is not the SOP's
1552  /// own gdp, it will just do a duplicateSource.
1553  OP_ERROR duplicatePointSource(unsigned index, OP_Context &ctx,
1554  GU_Detail *gdp, bool clean = true,
1555  bool wattrib = true,
1556  bool *fully = nullptr);
1558  {
1559  return duplicatePointSource(index, ctx, gdp, 1,
1560  true, nullptr);
1561  }
1562 
1563  /// This copies all the point positions from the given input gdp into
1564  /// the current one.
1565  /// @pre input_i has already been locked via lockInput
1566  bool copyPointPosFromSource(
1567  unsigned input_i, OP_Context &ctx);
1568 
1569  /// @brief Only duplicates the source if the source has changed since the
1570  /// last call to this method.
1571  OP_ERROR duplicateChangedSource(unsigned idx, OP_Context &ctx,
1572  int *changed = nullptr, bool force=false);
1573 
1574  /// Only duplicates primitives in primgroup from src_gdp to dest_gdp
1575  OP_ERROR duplicateSourceGroup(const GU_Detail *src_gdp,
1576  const GA_PrimitiveGroup *primgroup,
1577  GU_Detail *dest_gdp=nullptr);
1578 
1579  /// Forces duplicateChangedSource() to do the duplication on its next call.
1580  /// Can specify an input index (-1 to reset all)
1581  void resetChangedSourceFlags();
1582  void resetChangedSourceFlags(int which_input);
1583 
1584  /// @brief Checks if a duplication will occur on the next call to
1585  /// duplicateChangedSource().
1586  ///
1587  /// Similar to useInputSource() except it doesn't affect the flags. It's
1588  /// used to simply query whether the given input has changed. Returns false
1589  /// if there's errors on the input. Upon return, @c changed is updated.
1590  OP_ERROR checkChangedSourceFlags(unsigned idx, OP_Context &ctx,
1591  int *changed);
1592 
1593  /// @brief Mark the given input as used for cooking by this node.
1594  ///
1595  /// This updates source flags to mark the input as now clean, returning
1596  /// whether the input has changed since the last time this function was
1597  /// called. If force is true, then we treat the input as always dirty.
1598  /// Returns false if the input has errors.
1599  /// @note duplicateChangedSource() calls this function.
1600  bool useInputSource(unsigned idx, bool &changed, bool force)
1601  {
1602  return myInputChangeHelper.useInput(
1603  *this, idx, changed, force);
1604  }
1605 
1606  void deleteCookedData() override;
1607  int deleteNodeData(void *) override;
1608 
1609  /// Methods for dealing with group centroid
1610  void convertPivotAboutGroupCentroid(
1611  PRM_Parm &grppivot_parm,
1612  int pivot_parm_idx,
1613  const UT_Vector3 *centroid = nullptr);
1614  void convertPivotAboutGroupCentroid(
1615  PRM_Parm &grppivot_parm,
1616  const char *pivot_parm_name,
1617  const UT_Vector3 *centroid = nullptr);
1618 
1619 
1620  /// subclasses override this to return the group centroid if they support
1621  /// it.
1622  virtual bool getGroupCentroid(OP_Context & /*context*/,
1623  UT_Vector3 & /*centroid*/)
1624  { return false; }
1625 
1626  //
1627  // I/O methods
1628  //
1629  OP_ERROR save(std::ostream &os,
1630  const OP_SaveFlags &flags,
1631  const char *path_prefix,
1632  const UT_StringHolder &name_override = UT_StringHolder()
1633  ) override;
1634  bool load(UT_IStream &is,
1635  const char *extension,
1636  const char *path=nullptr) override;
1637 
1638  void refreshGdp();
1639 
1640 
1641  //
1642  // Data for the SOP class
1643  //
1644 
1645  /// The gdp handle provides a indirect reference to the current
1646  /// gdp of this SOP.
1648 
1649  /// During cooks, myGdpHandle is writelocked and stored in the
1650  /// gdp variable. This is to provide backwards compatibility.
1651  /// The gdp variable should not be trusted or accessed elsewhere.
1653  SOP_Guide *myGuide1; // primary guide geometry
1654  SOP_Guide *myGuide2; // secondary guide geometry
1656 
1657 private:
1658  //
1659  // These virtuals are methods that nobody should override...
1660  //
1661  // I/O methods
1662  //
1663  OP_ERROR saveIntrinsic(std::ostream &os,
1664  const OP_SaveFlags &flags) override;
1665 
1666  bool loadPacket(UT_IStream &is,
1667  short class_id, short sig,
1668  const char *path=nullptr) override;
1669  bool loadPacket(UT_IStream &is, const char *token,
1670  const char *path=nullptr) override;
1671 
1672  void clearAndDestroy() override;
1673 
1674  int saveCookedData(const char *,
1675  OP_Context &) override;
1676  int saveCookedData(std::ostream &os,
1677  OP_Context &,
1678  int binary = 0) override;
1679  bool loadCookedData(UT_IStream &is,
1680  const char *path=nullptr) override;
1681 
1682  /// loadHardCookedData is just like loadCookedData, except it doesn't
1683  /// check if this SOP is softlocked. Use it only if you know you are
1684  /// loading hardlocked data (as in SOP_UndoModel)
1685  bool loadHardCookedData(UT_IStream &is, const char *path=nullptr);
1686 
1687  const char *getFileExtension(int binary) const override;
1688 
1689  bool softLockable(const GU_Detail &unmodelled_gdp,
1690  const GU_Detail &modelled_gdp) const;
1691  /// take a snapshot of the current gdp and stores the soft lock data.
1692  /// copies the previous slock data to the given reference (so caller
1693  /// can use it for undo)
1694  /// returns true on success, false otherwise
1695  bool storeSoftLockData(OP_Context &context,
1696  SOP_SoftLockData *old_slockdata=nullptr);
1697 
1698  sopVisualizeCallback *myVisualizeCallback;
1699  void *myVisualizeCallbackData;
1700 
1701 public:
1702 
1703  // compact the weight data of an index pair attribute
1704  static void compactIndexPair(GA_Attribute *attrib);
1705 
1706 public:
1707  /// Do not use this function! Using it will likely cause crashes.
1708  virtual void unloadDataHack();
1709 
1710  /// Unload data for this node, called by unload flag heuristics, etc.
1711  /// @note Does not clear verb data by default. To ensure that is
1712  /// also cleared, call clearVerbCache().
1713  bool unloadData() override;
1714 
1715  /// Clears the node verb cache and parms
1716  void clearVerbCache();
1717 
1718  /// Returns the amount of memory owned by this node, *NOT* including
1719  /// any cooked geometry.
1720  int64 getMemoryUsage(bool inclusive) const override;
1721 
1722  /// Returns the amount of memory used by this SOP, that will
1723  /// be unloaded by an unload call. Baseclass defaults to
1724  /// returning the GDP's data.
1725  virtual int64 getLoadedMemoryUsage() const;
1726 
1727  /// Returns whether this node currently has cooked data or not.
1728  bool isLoaded() const override;
1729 
1730  /// Returns if the sop cache manager will allow unloading.
1731  bool shouldUnload() const;
1732 
1733  /// Convenience method to prepare newly allocated GU_Detail objects to
1734  /// act as the output.
1735  /// Note that this returns the passed in gdp pointer.
1736  static GU_Detail *prepNewDetail(GU_Detail *gdp);
1737 
1738  /// This method is automatically called at the conclusion of cooking to
1739  /// notify the gdp that it's data has changed. By default, this will call:
1740  /// @code
1741  /// if (bumpalldataid)
1742  /// gdp->bumpAllDataIds();
1743  /// gdp->defragment();
1744  /// gdp->edgeGroups().makeAllEdgesValid();
1745  /// gdp->incrementMetaCacheCount();
1746  /// @endcode
1747  static void markDetailDirty(GU_Detail *dirtygdp,
1748  bool bumpalldataid);
1749 
1750  /// All SOP nodes can be a selection owner.
1751  /// This replaces the previous inheritance from SOP_SelectionOwner.
1752  bool isSelectionOwnerType() const override final
1753  { return true; }
1754 
1755 
1756 private:
1757  OP_InputChangeHelper myInputChangeHelper;
1758 
1759  /// We store all locked inputs in this list. We can then allow
1760  /// the same source node to be cooked with different contexts
1761  /// and let copy on write semantics avoid problems.
1762  /// Any non-null handle here has PreserveRequest set and should
1763  /// have it removed before removing.
1764  UT_ValArray<GU_DetailHandle *> myInputGeoHandles;
1765 
1766  GOP_Manager myGroupParse;
1767 
1768  friend class SOP_UndoModel; // needs access to gdp
1769  friend class SOP_CacheManager; // needs access to handle.
1770  friend class SOP_CacheData; // needs access to handle.
1771  friend class sop_AttributeEvaluator; // needs access to local var info
1772 
1773  //
1774  // Private data
1775  //
1776  SOP_SoftLockData *mySoftLockData;
1777 
1778  bool myHasCookedSelection;
1779 
1780  /// the capture override flag is used to indicate wheter the SOPs should
1781  /// use their capture parameters or cook capture geometry. (e.g.,
1782  /// SOP_CaptureRegion). This flag is mirrored from OBJ_Bone, which
1783  /// allows to view bones and capture region in their capture configuration
1784  static bool theGlobalCaptOverride;
1785 
1786  // myInstancingOpsLock no longer serves a purpose since we have long
1787  // stopped trying to multi-thread cooking.
1788  //UT_Lock myInstancingOpsLock;
1789  UT_Set<int> myInstancingOps;
1790  int myInstanceOp; // Which op we are instancing.
1791 
1792 public:
1793  // This method needs to be public so HOM can flag an expression as needing
1794  // corresponding to local variables.
1796  { myUsesSOPLocalVar = true; }
1797 
1798  UT_AttributeEvaluator *createAttributeEvaluator(
1799  const char *name) override;
1800  void getAttributeEvaluatorNames(
1801  UT_StringArray &names) override;
1802 
1803  // CHOP Transform Tracks
1804  bool hasTransformTracks() const override;
1805  bool evaluateTransformTracks( OP_Context &context,
1807  bool evaluateTransformTracksTargets( OP_Context &context,
1808  OP_NodeList &nodes, OP_Node *caller) override;
1809 
1810 protected:
1811  /// Local variable items:
1815 
1816  /// Tracks if any expression has triggered a local variable,
1817  /// like $PT, etc. If this is false, it is safe to only
1818  /// evaluate the parm once for all subtypes.
1819  /// The higher level code is expected to clear this flag, evaluate their
1820  /// relevant parms, and then test this flag.
1822 private:
1823  // myFlagUnused used to be myLocalVarActive, which has been moved down to
1824  // OP_Node. It's still here to avoid breaking HDK binary compatibility.
1825  bool myFlagUnused;
1826  const GU_Detail *myCurGdp[2];
1827  GU_DetailHandle myCurGdh[2];
1828 
1829  /// This is the selection set we use when the footprint flag is on.
1830  GU_SelectionSetHandle myFootprintSelectionSet;
1831 
1832  /// This is a complete override for all selection sets. Used temporarily
1833  /// by selectors.
1834  GU_SelectionSetHandle mySelectionSetOverride;
1835 
1836 protected:
1837  GA_Offset myCurVtxOff[2];
1838  int myCurVtxNum[2];
1839  GA_Offset myCurPtOff[2];
1840  GA_Offset myCurPrimOff[2];
1841  int myCurBuiltPtBox[2];
1842  UT_BoundingBox myCurPtBox[2];
1843  int myCurBuiltPrimBox[2];
1844  UT_BoundingBox myCurPrimBox[2];
1845 
1846  int myCurGdpVal; // Which gdp is being traversed
1847 
1848  /// Cached values so we can tell if we have to rebuild.
1851  /// This is all the old attribute information, one for each of the
1852  /// dictionary types... If this (including the order) matches the
1853  /// new attribute data, no offsets will have changed.
1854  UT_Array<sop_attribRef> myAttribCache[2][4];
1855  UT_String myVarMapCache[2];
1856  int myAttribCacheOffsetGdpId[2];
1857  int myAttribCacheOffsetMetaCacheCount[2];
1858  unsigned int myAttribCacheTotalDictSize[2];
1859  /// Stores the @ cache lookups generated JIT.
1861 
1862  /// Stores the parms & cache for old-style node cooking of verb
1863  /// based nodes.
1866  friend class SOP_NodeVerb;
1867  friend class SOP_NodeParms;
1868  friend class sop_NodeInputs;
1869 };
1870 
1871 /// Function to get a list of template arrays containing parm names that must
1872 /// be reserved when compiling VEX SOPs.
1873 SOP_API extern void
1875 
1876 #endif
static PRM_ChoiceList primGroupMenu
Definition: SOP_Node.h:1214
GA_VertexGroup * parseVertexGroupsCopy(const char *pattern)
Definition: SOP_Node.h:675
virtual UT_StringHolder getUniGraphProviderType(bool allow_cook)
static PRM_ChoiceList onnxDTypeMenu
Definition: SOP_Node.h:1260
virtual void setVisualization(bool)
Definition: SOP_Node.h:873
GT_API const UT_StringHolder selection
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
int curVertexNum(int index) const
Definition: SOP_Node.h:355
Definition of a geometry attribute.
Definition: GA_Attribute.h:203
static PRM_ChoiceList pointAttribReplaceMenu
Definition: SOP_Node.h:1253
GA_VertexGroup * createAdhocVertexGroup(GU_Detail &geo, const char *p="adhoc")
Definition: SOP_Node.h:1481
static PRM_ChoiceList allGroupMenu
Definition: SOP_Node.h:1212
GLbitfield flags
Definition: glcorearb.h:1596
static PRM_ChoiceList vertexTextureCoordMenu
Definition: SOP_Node.h:1257
static PRM_SpareData theFourthInput
Definition: SOP_Node.h:909
GA_PrimitiveGroupUPtr createDetachedPrimitiveGroup() const
Definition: GA_Detail.h:1385
GLenum GLint * range
Definition: glcorearb.h:1925
static PRM_ChoiceList onnxProviderMenu
Definition: SOP_Node.h:1259
virtual const SOP_NodeVerb * cookVerb() const
Definition: SOP_Node.h:931
GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glad.h:2676
#define SOP_Guide
Definition: SOP_Guide.h:17
#define SYS_DEPRECATED(__V__)
GA_StorageClass myStorageClass
Definition: SOP_Node.h:91
GA_ROAttributeRef myOffset
Definition: SOP_Node.h:87
const GA_Group * parseAllGroups(const char *pattern)
Definition: SOP_Node.h:690
static PRM_ChoiceList edgeGroupReplaceMenu
Definition: SOP_Node.h:1229
virtual OP_UniGraphProvider * getUniGraphProvider()
GA_Offset curVertex(int local_var_gdp_index) const
Definition: SOP_Node.h:361
GA_PointGroup * createAdhocPointGroup(const GEO_Detail &geo)
Definition: SOP_Node.h:1489
static PRM_ChoiceList namedPrimsMenu
Definition: SOP_Node.h:1239
static PRM_ChoiceList namedVolumesGlobMenu
Definition: SOP_Node.h:1242
Class which stores the default values for a GA_Attribute.
Definition: GA_Defaults.h:32
#define SYS_VISIBILITY_EXPORT
void
Definition: png.h:1083
GA_StorageClass
Definition: GA_Types.h:75
getFileOption("OpenEXR:storage") storage
Definition: HDK_Image.dox:276
UT_StringMap< sop_AttributeEvaluator * > myAttributeEvaluatorCache
Stores the @ cache lookups generated JIT.
Definition: SOP_Node.h:1860
GT_API const UT_StringHolder time
#define SYS_DEPRECATED_PUSH_DISABLE()
const GA_PrimitiveGroup * parsePrimitiveGroups(const char *pattern)
Definition: SOP_Node.h:594
static PRM_ChoiceList allAttribMenu
Definition: SOP_Node.h:1244
GA_AttributeOwner myDictionary
Definition: SOP_Node.h:92
#define SYS_DEPRECATED_POP_DISABLE()
static PRM_ChoiceList groupNameMenu
Definition: SOP_Node.h:1238
GLuint start
Definition: glcorearb.h:475
GLsizei const GLfloat * value
Definition: glcorearb.h:824
GroupSelectAsOrdered
Definition: SOP_Node.h:1282
virtual GuideType getGuideType(int guide_idx)
Definition: SOP_Node.h:530
#define SYS_DEPRECATED_HDK_REPLACE(__V__, __R__)
const GLuint GLenum const void * binary
Definition: glcorearb.h:1924
void destroyAdhocGroups(const GU_Detail *g)
Definition: SOP_Node.h:718
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
static PRM_ChoiceList breakpointGroupMenu
Definition: SOP_Node.h:1219
int removeAdhocGroup(const GA_Group *group)
Definition: SOP_Node.h:948
int OP_InputIdx
Definition: OP_DataTypes.h:184
static PRM_ChoiceList pointAttribMenu
Definition: SOP_Node.h:1247
static PRM_ChoiceList primGroupReplaceMenu
Definition: SOP_Node.h:1227
bool useInputSource(unsigned idx, bool &changed, bool force)
Mark the given input as used for cooking by this node.
Definition: SOP_Node.h:1600
GLboolean GLboolean g
Definition: glcorearb.h:1222
int64 exint
Definition: SYS_Types.h:125
GLint level
Definition: glcorearb.h:108
SOP_UIChangeType
Definition: SOP_Node.h:58
static PRM_ChoiceList edgePointGroupReplaceMenu
Definition: SOP_Node.h:1230
PRM_UVGroupType
Definition: PRM_Shared.h:34
UT_ErrorSeverity
Definition: UT_Error.h:25
static PRM_ChoiceList primNamedGroupMenu
Definition: SOP_Node.h:1220
Parameters for OP_Node::getInfoText()/OP_Node::getNodeSpecificInfoText()
void addMessage(SOP_ErrorCodes code, const char *msg=nullptr)
Definition: SOP_Node.h:1186
CH_LocalVariable myVar
Definition: SOP_Node.h:84
fpreal(SOP_Node::* SOP_LocalVarFunc)(sopVarInfo *varinfo)
Definition: SOP_Node.h:79
static PRM_SpareData theSecondElseFirstInput
Definition: SOP_Node.h:912
UT_SharedPtr< GU_SelectionSet > GU_SelectionSetHandle
GU_DetailHandle myGdpHandle
Definition: SOP_Node.h:1647
SOP_ErrorCodes
Definition: SOP_Error.h:16
void addCommonWarning(UT_CommonErrorCode what, const char *msg=nullptr)
Definition: SOP_Node.h:1200
void addError(int code, const char *msg=nullptr)
Definition: SOP_Node.h:1183
static PRM_ChoiceList primNamedGroupReplaceMenu
Definition: SOP_Node.h:1233
const GEO_Primitive * curPrim(int index) const
Definition: SOP_Node.h:369
SOP_Guide * myGuide1
Definition: SOP_Node.h:1653
const GA_PointGroup * parsePointGroups(const char *pattern)
Definition: SOP_Node.h:624
static PRM_ChoiceList pointGroupMenu
Definition: SOP_Node.h:1215
OP_Network * getCreator() const
static PRM_ChoiceList allGroupReplaceMenu
Definition: SOP_Node.h:1225
fpreal myDefault
Definition: SOP_Node.h:90
bool hasCookedSelection() const
Definition: SOP_Node.h:813
int myLocalVarOrder
Definition: SOP_Node.h:1814
#define GA_INVALID_OFFSET
Definition: GA_Types.h:694
static PRM_ChoiceList pointNamedGroupMenu
Definition: SOP_Node.h:1221
int myCurGdpVal
Definition: SOP_Node.h:1846
virtual const CH_LocalVariable * resolveExtraVariableForSyntaxHighlight(const char *name)
A range of elements in an index-map.
Definition: GA_Range.h:42
< returns > If no error
Definition: snippets.dox:2
GA_EdgeGroup * parseEdgeGroupsCopy(const char *pattern)
Definition: SOP_Node.h:651
A string map of attributes to ease backward compatibility In the GB/GEO/GU library code would often p...
GA_Offset curPoint(int index) const
Definition: SOP_Node.h:366
void opChanged(OP_EventType reason, void *data=nullptr) override
#define SYS_DEPRECATED_REPLACE(__V__, __R__)
GA_Size GA_Offset
Definition: GA_Types.h:653
GA_PointGroupUPtr createDetachedPointGroup() const
Definition: GA_Detail.h:1381
SYS_VISIBILITY_EXPORT void newSopOperator(OP_OperatorTable *table)
Definition: SOP_Euclid.C:44
PRM_GroupType
Definition: PRM_Shared.h:23
const GU_DetailHandle & curGdh(int index) const
Definition: SOP_Node.h:349
void expandGroupMask(const char *pattern, UT_String &out_names, GA_GroupType type)
Definition: SOP_Node.h:573
static PRM_SpareData theFirstInput
Definition: SOP_Node.h:906
GLfloat f
Definition: glcorearb.h:1926
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
GLintptr offset
Definition: glcorearb.h:665
static PRM_ChoiceList edgePointGroupMenu
Definition: SOP_Node.h:1217
SYS_FORCE_INLINE const X * cast(const InstancablePtr *o)
static PRM_ChoiceList vertexNamedGroupMenu
Definition: SOP_Node.h:1223
int myLocalVarOrderCache
Cached values so we can tell if we have to rebuild.
Definition: SOP_Node.h:1849
UT_String myName
Definition: SOP_Node.h:72
static PRM_ChoiceList namedVolumesMenu
Definition: SOP_Node.h:1241
void addFatal(SOP_ErrorCodes code, const char *msg=nullptr)
Definition: SOP_Node.h:1192
void destroyAdhocGroups()
Definition: SOP_Node.h:716
vint4 select(const vbool4 &mask, const vint4 &a, const vint4 &b)
Definition: simd.h:4983
const GU_Detail * inputGeo(int index, OP_Context &)
Definition: SOP_Node.h:1172
This class provides a way to manage a reference to an attribute permitting Read-Only access...
GOP_Manager::GroupCreator GroupCreator
Typedef to help make use of GroupCreator less verbose.
Definition: SOP_Node.h:579
static PRM_ChoiceList namedPrimsGlobMenu
Definition: SOP_Node.h:1240
GA_VertexGroup * createAdhocVertexGroup(const GEO_Detail &geo)
Definition: SOP_Node.h:1497
bool myUsesSOPLocalVar
Definition: SOP_Node.h:1821
SOP_NodeCache * myNodeVerbCache
Definition: SOP_Node.h:1864
void addCommonError(UT_CommonErrorCode what, const char *msg=nullptr)
Definition: SOP_Node.h:1197
SOP_Guide * myGuide2
Definition: SOP_Node.h:1654
static bool getCaptureOverrideFlag()
Definition: SOP_Node.h:205
GA_EdgeGroupUPtr createDetachedEdgeGroup() const
Definition: GA_Detail.h:1393
SOP_API int SOPlookupGroupInput(const PRM_SpareData *spare)
UT_ValArray< sopVarInfo * > myLocalVarArray
Definition: SOP_Node.h:1813
GA_EdgeGroup * createAdhocEdgeGroup(GU_Detail &geo, const char *p="adhoc")
Definition: SOP_Node.h:1478
UT_String myAttribName
Definition: SOP_Node.h:86
static PRM_ChoiceList groupReplaceMenu
Definition: SOP_Node.h:1226
void removeAdhocGroups()
Definition: SOP_Node.h:950
virtual GOP_GuideListType getGuideListType() const
Definition: SOP_Node.h:539
virtual bool addOrMoveVisualizerToOutput(int outputidx)
Definition: OP_Node.h:3352
static PRM_ChoiceList primAttribReplaceMenu
Definition: SOP_Node.h:1252
static PRM_ChoiceList breakpointGroupReplaceMenu
Definition: SOP_Node.h:1232
GLint GLuint mask
Definition: glcorearb.h:124
UT_BoundingBox curPointBBox(int index)
Definition: SOP_Node.h:376
int myTupleIndex
Definition: SOP_Node.h:89
sopVarInfo * mySecondaryVariable
Definition: SOP_Node.h:88
long long int64
Definition: SYS_Types.h:116
SOP_NodeFlags mySopFlags
Definition: SOP_Node.h:1655
GA_PointGroup * parsePointGroupsCopy(const char *pattern)
Definition: SOP_Node.h:638
OP_OpTypeId
Definition: OP_OpTypeId.h:18
int isCookingRender() const override
Definition: SOP_Node.h:126
GLenum GLenum severity
Definition: glcorearb.h:2539
GLuint const GLchar * name
Definition: glcorearb.h:786
GA_Storage myStorage
Definition: SOP_Node.h:74
SOP_API void SOPfillMetaKernelMenu(void *, PRM_Name *names, int size, const PRM_SpareData *, const PRM_Parm *)
int destroyAdhocGroup(const GA_Group *group)
Definition: SOP_Node.h:714
static PRM_ChoiceList primEdgePointGroupMenu
Definition: SOP_Node.h:1218
GLushort pattern
Definition: glad.h:2583
virtual const CH_LocalVariable * resolveVariable(const char *name)
GA_BreakpointGroup * parseBreakpointGroupsCopy(const char *pattern)
Definition: SOP_Node.h:663
std::function< T > UT_Function
Definition: UT_Function.h:37
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:647
virtual bool getGroupCentroid(OP_Context &, UT_Vector3 &)
Definition: SOP_Node.h:1622
static PRM_ChoiceList detailAttribReplaceMenu
Definition: SOP_Node.h:1251
GA_PrimitiveGroup * createAdhocPrimGroup(GU_Detail &geo, const char *p="adhoc")
Definition: SOP_Node.h:1472
UT_SharedPtr< GU_Selection > GU_SelectionHandle
virtual void setForceCapture(bool)
Definition: SOP_Node.h:874
const GA_VertexGroup * parseVertexGroups(const char *pattern)
Definition: SOP_Node.h:670
GLenum GLenum GLsizei void * table
Definition: glad.h:5129
virtual OP_OpTypeId getOpTypeID() const
Definition: OP_Node.h:557
static PRM_ChoiceList groupMenu
Definition: SOP_Node.h:1213
static PRM_ChoiceList primEdgePointGroupReplaceMenu
Definition: SOP_Node.h:1231
#define SOP_OPTYPE_NAME
Definition: OP_Node.h:315
GLdouble t
Definition: glad.h:2397
GU_SelectionType
Definition: GU_SelectType.h:29
GU_Detail * gdp
Definition: SOP_Node.h:1652
SOP_API void SOPgetVexReservedTemplateLists(UT_ValArray< PRM_Template * > &tplatelists)
GT_API const UT_StringHolder version
static PRM_ChoiceList edgeGroupMenu
Definition: SOP_Node.h:1216
void setUsesSOPLocalVar()
Definition: SOP_Node.h:1795
const GU_Detail * curGdp(int index) const
Definition: SOP_Node.h:358
GA_VertexGroupUPtr createDetachedVertexGroup() const
Definition: GA_Detail.h:1389
UT_CommonErrorCode
Definition: UT_Error.h:42
static PRM_ChoiceList vertexAttribReplaceMenu
Definition: SOP_Node.h:1254
static PRM_ChoiceList vertexAttribMenu
Definition: SOP_Node.h:1248
const SOP_NodeFlags & getFlags() const
Definition: SOP_Node.h:123
virtual const char * getChildType() const
static PRM_ChoiceList pointNamedGroupReplaceMenu
Definition: SOP_Node.h:1234
GLsizeiptr size
Definition: glcorearb.h:664
**Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
virtual bool shouldResetGeoToEmpty() const
Definition: SOP_Node.h:1528
GA_AttributeOwner
Definition: GA_Types.h:35
GA_API const UT_StringHolder parms
Parameters for OP_Node::fillInfoTree()/OP_Node::fillInfoTreeNodeSpecific()
static PRM_ChoiceList primAttribMenu
Definition: SOP_Node.h:1246
static PRM_ChoiceList edgeNamedGroupReplaceMenu
Definition: SOP_Node.h:1235
void sopVisualizeCallback(void *, SOP_Node *, OP_Context &, GU_Detail *)
Definition: SOP_Node.h:112
static void setCaptureOverrideFlag(bool flag)
Definition: SOP_Node.h:201
bool isSelectionOwnerType() const overridefinal
Definition: SOP_Node.h:1752
SIM_API const UT_StringHolder force
bool usesFootprint() const override
Definition: SOP_Node.h:175
static PRM_ChoiceList edgeNamedGroupMenu
Definition: SOP_Node.h:1222
virtual GU_DetailHandle cookMyGuide(int guide_idx, OP_Context &context)
Definition: SOP_Node.h:976
fpreal64 fpreal
Definition: SYS_Types.h:283
SOP_LocalVarFunc myCallback
Definition: SOP_Node.h:94
GA_Group * parseAllGroupsCopy(const char *pattern)
Definition: SOP_Node.h:705
GA_GroupType
An ordinal enum for the different types of groups in GA.
Definition: GA_Types.h:167
const GA_BreakpointGroup * parseBreakpointGroups(const char *pattern)
Definition: SOP_Node.h:658
GLuint index
Definition: glcorearb.h:786
GA_PrimitiveGroup * parsePrimitiveGroupsCopy(const char *pattern)
Definition: SOP_Node.h:608
SOP_NodeParms * myNodeVerbParms
Definition: SOP_Node.h:1865
virtual const char * getOpType() const
void addSystemError(const char *msg=nullptr)
Definition: SOP_Node.h:1195
GLuint GLfloat * val
Definition: glcorearb.h:1608
UT_SymbolMap< sopVarInfo * > myLocalVarTable
Local variable items:
Definition: SOP_Node.h:1812
OP_EventType
Definition: OP_Value.h:22
A global error manager scope.
static PRM_ChoiceList detailAttribMenu
Definition: SOP_Node.h:1245
#define SOP_API
Definition: SOP_API.h:10
GA_PrimitiveGroup * createAdhocPrimGroup(const GEO_Detail &geo)
Definition: SOP_Node.h:1484
OP_DataType
Definition: OP_DataTypes.h:189
virtual OP_OpTypeId getChildTypeID() const =0
GU_API void xform(CE_Context &context, bool recompile, int npts, const cl::Buffer &outPos, const cl::Buffer &inPos, const cl::Buffer &surfacexform, const cl::Buffer *grp=nullptr)
static PRM_SpareData theThirdInput
Definition: SOP_Node.h:908
**If you just want to fire and args
Definition: thread.h:618
GA_PointGroup * createAdhocPointGroup(GU_Detail &geo, const char *p="adhoc")
Definition: SOP_Node.h:1475
virtual bool evalVariableValue(UT_String &val, int index, int thread)
int myVaridx
Definition: SOP_Node.h:93
OP_ERROR duplicatePointSource(unsigned index, OP_Context &ctx)
Definition: SOP_Node.h:1557
virtual bool isGuideTimeDep(int guide_idx) const
Definition: SOP_Node.h:532
GOP_GuideListType
Definition: GOP_Guide.h:24
static PRM_ChoiceList pointGroupReplaceMenu
Definition: SOP_Node.h:1228
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:165
GA_GroupMaskType
Definition: GA_Types.h:182
virtual int isCookingRender() const
Definition: OP_Node.h:2686
static PRM_ChoiceList vertexNamedGroupReplaceMenu
Definition: SOP_Node.h:1236
static PRM_SpareData theSecondInput
Definition: SOP_Node.h:907
virtual int getNumGuides()
Definition: SOP_Node.h:529
UT_BoundingBox curPrimBBox(int index)
Definition: SOP_Node.h:384
const GA_EdgeGroup * parseEdgeGroups(const char *pattern)
Definition: SOP_Node.h:646
static PRM_ChoiceList allAttribReplaceMenu
Definition: SOP_Node.h:1250
GEO_Standard_Attributes
Definition: GEO_Detail.h:166
void addWarning(SOP_ErrorCodes code, const char *msg=nullptr)
Definition: SOP_Node.h:1189
int myCurrentLayerCache
Definition: SOP_Node.h:1850
GA_BreakpointGroup * createAdhocBreakpointGroup(const GEO_Detail &geo)
Definition: SOP_Node.h:1501
GA_Storage
Definition: GA_Types.h:52
OP_ERROR duplicateSource(unsigned index, OP_Context &context)
Definition: SOP_Node.h:1536
static PRM_ChoiceList allTextureCoordMenu
Definition: SOP_Node.h:1256
OIIO_UTIL_API std::string extension(string_view filepath, bool include_dot=true) noexcept
Definition: format.h:1821
GA_EdgeGroup * createAdhocEdgeGroup(const GEO_Detail &geo)
Definition: SOP_Node.h:1493
virtual void clearCache()
GA_Offset curPrimOff(int index) const
Definition: SOP_Node.h:372
GLenum src
Definition: glcorearb.h:1793
int myTable
Definition: SOP_Node.h:85