HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SOP_Rewire.proto.h
Go to the documentation of this file.
1 /* Automagically Generated by generate_proto.py
2  * Do not Edit
3  */
4 #pragma once
5 
6 #include <SOP/SOP_NodeVerb.h>
7 #include <OP/OP_Utils.h>
8 #include <PRM/PRM_Parm.h>
9 #include <UT/UT_IStream.h>
10 #include <UT/UT_NTStreamUtil.h>
11 #include <UT/UT_Ramp.h>
12 #include <UT/UT_SharedPtr.h>
13 #include <UT/UT_StringHolder.h>
14 #include <UT/UT_StringStream.h>
15 #include <UT/UT_VectorTypes.h>
16 #include <SYS/SYS_Types.h>
17 
18 using namespace UT::Literal;
19 
20 class DEP_MicroNode;
21 namespace SOP_RewireEnums
22 {
23  enum class Grouptype
24  {
25  GUESS = 0,
26  VERTICES,
27  EDGES,
28  POINTS,
29  PRIMS
30  };
31 }
32 
33 
35 {
36 public:
37  static int version() { return 1; }
38 
40  {
41  myGroup = ""_sh;
42  myGrouptype = 0;
43  myAttrib = "rewire_to"_sh;
44  myRecurse = false;
45  myKeepunusedpoints = false;
46  myCreateorigattrib = false;
47  myOrigattrib = "rewired_from"_sh;
48 
49  }
50 
51  explicit SOP_RewireParms(const SOP_RewireParms &) = default;
52 
53  virtual ~SOP_RewireParms() {}
54 
55  bool operator==(const SOP_RewireParms &src) const
56  {
57  if (myGroup != src.myGroup) return false;
58  if (myGrouptype != src.myGrouptype) return false;
59  if (myAttrib != src.myAttrib) return false;
60  if (myRecurse != src.myRecurse) return false;
61  if (myKeepunusedpoints != src.myKeepunusedpoints) return false;
62  if (myCreateorigattrib != src.myCreateorigattrib) return false;
63  if (myOrigattrib != src.myOrigattrib) return false;
64 
65  return true;
66  }
68 
69 
70 
71  void buildFromOp(const OP_Node *node, fpreal time, DEP_MicroNode *depnode)
72  {
73  if (true)
74  OP_Utils::evalOpParm(myGroup, node, "group", time, 0);
75  else myGroup = ""_sh;
76  if (true)
77  OP_Utils::evalOpParm(myGrouptype, node, "grouptype", time, 0);
78  else myGrouptype = 0;
79  if (true)
80  OP_Utils::evalOpParm(myAttrib, node, "attrib", time, 0);
81  else myAttrib = "rewire_to"_sh;
82  if (true)
83  OP_Utils::evalOpParm(myRecurse, node, "recurse", time, 0);
84  else myRecurse = false;
85  if (true)
86  OP_Utils::evalOpParm(myKeepunusedpoints, node, "keepunusedpoints", time, 0);
87  else myKeepunusedpoints = false;
88  if (true)
89  OP_Utils::evalOpParm(myCreateorigattrib, node, "createorigattrib", time, 0);
90  else myCreateorigattrib = false;
91  if (true && ( (!(((getCreateorigattrib()==0)))) ) )
92  OP_Utils::evalOpParm(myOrigattrib, node, "origattrib", time, 0);
93  else myOrigattrib = "rewired_from"_sh;
94 
95  }
96 
97 
98  virtual void loadFromOpSubclass(const LoadParms &loadparms)
99  {
100  buildFromOp(loadparms.node(), loadparms.context().getTime(), loadparms.depnode());
101  }
102 
103 
104  virtual void copyFrom(const SOP_NodeParms *src)
105  {
106  *this = *((const SOP_RewireParms *)src);
107  }
108 
109  template <typename T>
110  void
111  doGetParmValue(exint idx, T &value) const
112  {
113  switch (idx)
114  {
115  case 0:
116  coerceValue(value, myGroup);
117  break;
118  case 1:
119  coerceValue(value, myGrouptype);
120  break;
121  case 2:
122  coerceValue(value, myAttrib);
123  break;
124  case 3:
125  coerceValue(value, myRecurse);
126  break;
127  case 4:
128  coerceValue(value, myKeepunusedpoints);
129  break;
130  case 5:
131  coerceValue(value, myCreateorigattrib);
132  break;
133  case 6:
134  coerceValue(value, myOrigattrib);
135  break;
136 
137  }
138  }
139 
140  void getParmValue(exint idx, exint &value) const
141  { doGetParmValue(idx, value); }
142  void getParmValue(exint idx, fpreal &value) const
143  { doGetParmValue(idx, value); }
145  { doGetParmValue(idx, value); }
147  { doGetParmValue(idx, value); }
149  { doGetParmValue(idx, value); }
151  { doGetParmValue(idx, value); }
153  { doGetParmValue(idx, value); }
155  { doGetParmValue(idx, value); }
157  { doGetParmValue(idx, value); }
159  { doGetParmValue(idx, value); }
161  { doGetParmValue(idx, value); }
162 
163  template <typename T>
164  void
165  doSetParmValue(exint idx, const T &value)
166  {
167  switch (idx)
168  {
169  case 0:
170  coerceValue(myGroup, value);
171  break;
172  case 1:
173  coerceValue(myGrouptype, value);
174  break;
175  case 2:
176  coerceValue(myAttrib, value);
177  break;
178  case 3:
179  coerceValue(myRecurse, value);
180  break;
181  case 4:
182  coerceValue(myKeepunusedpoints, value);
183  break;
184  case 5:
185  coerceValue(myCreateorigattrib, value);
186  break;
187  case 6:
188  coerceValue(myOrigattrib, value);
189  break;
190 
191  }
192  }
193 
194  void setParmValue(exint idx, const exint &value)
195  { doSetParmValue(idx, value); }
196  void setParmValue(exint idx, const fpreal &value)
197  { doSetParmValue(idx, value); }
198  void setParmValue(exint idx, const UT_Vector2D &value)
199  { doSetParmValue(idx, value); }
200  void setParmValue(exint idx, const UT_Vector3D &value)
201  { doSetParmValue(idx, value); }
202  void setParmValue(exint idx, const UT_Vector4D &value)
203  { doSetParmValue(idx, value); }
204  void setParmValue(exint idx, const UT_Matrix2D &value)
205  { doSetParmValue(idx, value); }
206  void setParmValue(exint idx, const UT_Matrix3D &value)
207  { doSetParmValue(idx, value); }
208  void setParmValue(exint idx, const UT_Matrix4D &value)
209  { doSetParmValue(idx, value); }
211  { doSetParmValue(idx, value); }
213  { doSetParmValue(idx, value); }
215  { doSetParmValue(idx, value); }
216 
217  virtual exint getNumParms() const
218  {
219  return 7;
220  }
221 
222  virtual const char *getParmName(exint fieldnum) const
223  {
224  switch (fieldnum)
225  {
226  case 0:
227  return "group";
228  case 1:
229  return "grouptype";
230  case 2:
231  return "attrib";
232  case 3:
233  return "recurse";
234  case 4:
235  return "keepunusedpoints";
236  case 5:
237  return "createorigattrib";
238  case 6:
239  return "origattrib";
240 
241  }
242  return 0;
243  }
244 
245  virtual ParmType getParmType(exint fieldnum) const
246  {
247  switch (fieldnum)
248  {
249  case 0:
250  return PARM_STRING;
251  case 1:
252  return PARM_INTEGER;
253  case 2:
254  return PARM_STRING;
255  case 3:
256  return PARM_INTEGER;
257  case 4:
258  return PARM_INTEGER;
259  case 5:
260  return PARM_INTEGER;
261  case 6:
262  return PARM_STRING;
263 
264  }
265  return PARM_UNSUPPORTED;
266  }
267 
268  // Boiler plate to load individual types.
269  static void loadData(UT_IStream &is, int64 &v)
270  { is.bread(&v, 1); }
271  static void loadData(UT_IStream &is, bool &v)
272  { int64 iv; is.bread(&iv, 1); v = iv; }
273  static void loadData(UT_IStream &is, fpreal64 &v)
274  { is.bread<fpreal64>(&v, 1); }
275  static void loadData(UT_IStream &is, UT_Vector2D &v)
276  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1); }
277  static void loadData(UT_IStream &is, UT_Vector3D &v)
278  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
279  is.bread<fpreal64>(&v.z(), 1); }
280  static void loadData(UT_IStream &is, UT_Vector4D &v)
281  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
282  is.bread<fpreal64>(&v.z(), 1); is.bread<fpreal64>(&v.w(), 1); }
283  static void loadData(UT_IStream &is, UT_Matrix2D &v)
284  { for (int r = 0; r < 2; r++) for (int c = 0; c < 2; c++) is.bread<fpreal64>(&v(r, c), 1); }
285  static void loadData(UT_IStream &is, UT_Matrix3D &v)
286  { for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) is.bread<fpreal64>(&v(r, c), 1); }
287  static void loadData(UT_IStream &is, UT_Matrix4D &v)
288  { for (int r = 0; r < 4; r++) for (int c = 0; c < 4; c++) is.bread<fpreal64>(&v(r, c), 1); }
289  static void loadData(UT_IStream &is, UT_Vector2I &v)
290  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1); }
291  static void loadData(UT_IStream &is, UT_Vector3I &v)
292  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
293  is.bread<int64>(&v.z(), 1); }
294  static void loadData(UT_IStream &is, UT_Vector4I &v)
295  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
296  is.bread<int64>(&v.z(), 1); is.bread<int64>(&v.w(), 1); }
298  { is.bread(v); }
300  { UT_StringHolder rampdata;
301  loadData(is, rampdata);
302  if (rampdata.isstring())
303  {
304  v.reset(new UT_Ramp());
305  UT_IStream istr((const char *) rampdata, rampdata.length(), UT_ISTREAM_ASCII);
306  v->load(istr);
307  }
308  else v.reset();
309  }
312  loadData(is, data);
313  if (data.isstring())
314  {
315  // Find the data type.
316  char *colon = UT_StringWrap(data).findChar(':');
317  if (colon)
318  {
319  int typelen = colon - data.buffer();
321  type.strncpy(data.buffer(), typelen);
322  UT_IStream istr(((const char *) data) + typelen + 1, data.length() - (typelen + 1), UT_ISTREAM_BINARY);
323 
324  v = PRM_DataFactory::parseBinary(type.buffer(), istr);
325  }
326  }
327  else v.reset();
328  }
329 
330  static void saveData(std::ostream &os, int64 v)
331  { UTwrite(os, &v); }
332  static void saveData(std::ostream &os, bool v)
333  { int64 iv = v; UTwrite(os, &iv); }
334  static void saveData(std::ostream &os, fpreal64 v)
335  { UTwrite<fpreal64>(os, &v); }
336  static void saveData(std::ostream &os, UT_Vector2D v)
337  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y()); }
338  static void saveData(std::ostream &os, UT_Vector3D v)
339  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
340  UTwrite<fpreal64>(os, &v.z()); }
341  static void saveData(std::ostream &os, UT_Vector4D v)
342  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
343  UTwrite<fpreal64>(os, &v.z()); UTwrite<fpreal64>(os, &v.w()); }
344  static void saveData(std::ostream &os, UT_Matrix2D v)
346  static void saveData(std::ostream &os, UT_Matrix3D v)
348  static void saveData(std::ostream &os, UT_Matrix4D v)
350  static void saveData(std::ostream &os, UT_StringHolder s)
351  { UT_StringWrap(s).saveBinary(os); }
352  static void saveData(std::ostream &os, UT_SharedPtr<UT_Ramp> s)
353  { UT_StringHolder result;
354  UT_OStringStream ostr;
355  if (s) s->save(ostr);
356  result = ostr.str();
357  saveData(os, result);
358  }
359  static void saveData(std::ostream &os, PRM_DataItemHandle s)
360  { UT_StringHolder result;
361  UT_OStringStream ostr;
362  if (s)
363  {
364  ostr << s->getDataTypeToken();
365  ostr << ":";
366  s->saveBinary(ostr);
367  }
368  result = ostr.str();
369  saveData(os, result);
370  }
371 
372 
373  void save(std::ostream &os) const
374  {
375  int32 v = version();
376  UTwrite(os, &v);
377  saveData(os, myGroup);
378  saveData(os, myGrouptype);
379  saveData(os, myAttrib);
380  saveData(os, myRecurse);
381  saveData(os, myKeepunusedpoints);
382  saveData(os, myCreateorigattrib);
383  saveData(os, myOrigattrib);
384 
385  }
386 
387  bool load(UT_IStream &is)
388  {
389  int32 v;
390  is.bread(&v, 1);
391  if (version() != v)
392  {
393  // Fail incompatible versions
394  return false;
395  }
396  loadData(is, myGroup);
397  loadData(is, myGrouptype);
398  loadData(is, myAttrib);
399  loadData(is, myRecurse);
400  loadData(is, myKeepunusedpoints);
401  loadData(is, myCreateorigattrib);
402  loadData(is, myOrigattrib);
403 
404  return true;
405  }
406 
407  const UT_StringHolder & getGroup() const { return myGroup; }
408  void setGroup(const UT_StringHolder & val) { myGroup = val; }
410  {
411  SOP_Node *thissop = cookparms.getNode();
412  if (!thissop) return getGroup();
413  UT_StringHolder result;
414  OP_Utils::evalOpParm(result, thissop, "group", cookparms.getCookTime(), 0);
415  return result;
416  }
417  Grouptype getGrouptype() const { return Grouptype(myGrouptype); }
418  void setGrouptype(Grouptype val) { myGrouptype = int64(val); }
420  {
421  SOP_Node *thissop = cookparms.getNode();
422  if (!thissop) return getGrouptype();
423  int64 result;
424  OP_Utils::evalOpParm(result, thissop, "grouptype", cookparms.getCookTime(), 0);
425  return Grouptype(result);
426  }
427  const UT_StringHolder & getAttrib() const { return myAttrib; }
428  void setAttrib(const UT_StringHolder & val) { myAttrib = val; }
430  {
431  SOP_Node *thissop = cookparms.getNode();
432  if (!thissop) return getAttrib();
433  UT_StringHolder result;
434  OP_Utils::evalOpParm(result, thissop, "attrib", cookparms.getCookTime(), 0);
435  return result;
436  }
437  bool getRecurse() const { return myRecurse; }
438  void setRecurse(bool val) { myRecurse = val; }
439  bool opRecurse(const SOP_NodeVerb::CookParms &cookparms) const
440  {
441  SOP_Node *thissop = cookparms.getNode();
442  if (!thissop) return getRecurse();
443  bool result;
444  OP_Utils::evalOpParm(result, thissop, "recurse", cookparms.getCookTime(), 0);
445  return result;
446  }
447  bool getKeepunusedpoints() const { return myKeepunusedpoints; }
448  void setKeepunusedpoints(bool val) { myKeepunusedpoints = val; }
449  bool opKeepunusedpoints(const SOP_NodeVerb::CookParms &cookparms) const
450  {
451  SOP_Node *thissop = cookparms.getNode();
452  if (!thissop) return getKeepunusedpoints();
453  bool result;
454  OP_Utils::evalOpParm(result, thissop, "keepunusedpoints", cookparms.getCookTime(), 0);
455  return result;
456  }
457  bool getCreateorigattrib() const { return myCreateorigattrib; }
458  void setCreateorigattrib(bool val) { myCreateorigattrib = val; }
459  bool opCreateorigattrib(const SOP_NodeVerb::CookParms &cookparms) const
460  {
461  SOP_Node *thissop = cookparms.getNode();
462  if (!thissop) return getCreateorigattrib();
463  bool result;
464  OP_Utils::evalOpParm(result, thissop, "createorigattrib", cookparms.getCookTime(), 0);
465  return result;
466  }
467  const UT_StringHolder & getOrigattrib() const { return myOrigattrib; }
468  void setOrigattrib(const UT_StringHolder & val) { myOrigattrib = val; }
470  {
471  SOP_Node *thissop = cookparms.getNode();
472  if (!thissop) return getOrigattrib();
473  UT_StringHolder result;
474  OP_Utils::evalOpParm(result, thissop, "origattrib", cookparms.getCookTime(), 0);
475  return result;
476  }
477 
478 private:
479  UT_StringHolder myGroup;
480  int64 myGrouptype;
481  UT_StringHolder myAttrib;
482  bool myRecurse;
483  bool myKeepunusedpoints;
484  bool myCreateorigattrib;
485  UT_StringHolder myOrigattrib;
486 
487 };
static void loadData(UT_IStream &is, UT_Matrix3D &v)
UT_StringHolder opOrigattrib(const SOP_NodeVerb::CookParms &cookparms) const
bool opKeepunusedpoints(const SOP_NodeVerb::CookParms &cookparms) const
void getParmValue(exint idx, UT_Matrix4D &value) const
void setParmValue(exint idx, const fpreal &value)
void setParmValue(exint idx, const UT_Matrix2D &value)
SOP_Node * getNode() const
Definition: SOP_NodeVerb.h:492
void setAttrib(const UT_StringHolder &val)
T & z(void)
Definition: UT_Vector4.h:372
void setKeepunusedpoints(bool val)
bool operator==(const SOP_RewireParms &src) const
exint bread(int32 *buffer, exint asize=1)
static void loadData(UT_IStream &is, fpreal64 &v)
virtual exint getNumParms() const
fpreal getTime() const
Definition: OP_Context.h:34
bool load(UT_IStream &is)
const GLdouble * v
Definition: glcorearb.h:836
void setGrouptype(Grouptype val)
static void loadData(UT_IStream &is, UT_StringHolder &v)
bool opRecurse(const SOP_NodeVerb::CookParms &cookparms) const
T & x(void)
Definition: UT_Vector2.h:284
void setParmValue(exint idx, const UT_Vector4D &value)
An output stream object that owns its own string buffer storage.
static void loadData(UT_IStream &is, UT_SharedPtr< UT_Ramp > &v)
const UT_WorkBuffer & str() const
Returns a read-only reference to the underlying UT_WorkBuffer.
bool getCreateorigattrib() const
SYS_FORCE_INLINE T & x(void)
Definition: UT_Vector3.h:581
void doGetParmValue(exint idx, T &value) const
static void saveData(std::ostream &os, UT_Vector4D v)
static PRM_DataItemHandle parseBinary(const char *type, UT_IStream &is)
bool opCreateorigattrib(const SOP_NodeVerb::CookParms &cookparms) const
void setParmValue(exint idx, const UT_Vector2D &value)
static void saveData(std::ostream &os, UT_SharedPtr< UT_Ramp > s)
virtual const char * getParmName(exint fieldnum) const
static void saveData(std::ostream &os, UT_StringHolder s)
UT_StringHolder opGroup(const SOP_NodeVerb::CookParms &cookparms) const
SYS_FORCE_INLINE T & z(void)
Definition: UT_Vector3.h:585
static void loadData(UT_IStream &is, UT_Vector4I &v)
long long int64
Definition: SYS_Types.h:106
static void saveData(std::ostream &os, PRM_DataItemHandle s)
const UT_StringHolder & getAttrib() const
void getParmValue(exint idx, fpreal &value) const
exint length() const
char * findChar(int c) const
Find first occurrance of character. Returns NULL upon failure.
Definition: UT_String.h:550
SYS_FORCE_INLINE const char * buffer() const
int64 exint
Definition: SYS_Types.h:115
static void loadData(UT_IStream &is, UT_Vector4D &v)
static void saveData(std::ostream &os, UT_Matrix2D v)
void setParmValue(exint idx, const PRM_DataItemHandle &value)
static void loadData(UT_IStream &is, UT_Vector2D &v)
const OP_Node * node() const
Definition: SOP_NodeVerb.h:104
double fpreal64
Definition: SYS_Types.h:191
UT_StringHolder opAttrib(const SOP_NodeVerb::CookParms &cookparms) const
static void loadData(UT_IStream &is, UT_Vector2I &v)
static void loadData(UT_IStream &is, UT_Vector3D &v)
void getParmValue(exint idx, UT_Vector2D &value) const
static void loadData(UT_IStream &is, int64 &v)
void setGroup(const UT_StringHolder &val)
Grouptype opGrouptype(const SOP_NodeVerb::CookParms &cookparms) const
static int version()
bool getKeepunusedpoints() const
virtual void copyFrom(const SOP_NodeParms *src)
void setParmValue(exint idx, const UT_Matrix3D &value)
void setParmValue(exint idx, const UT_Vector3D &value)
GLboolean * data
Definition: glcorearb.h:130
int int32
Definition: SYS_Types.h:34
T & y(void)
Definition: UT_Vector4.h:370
void getParmValue(exint idx, UT_StringHolder &value) const
void getParmValue(exint idx, UT_Matrix2D &value) const
const UT_StringHolder & getGroup() const
void getParmValue(exint idx, exint &value) const
void saveBinary(std::ostream &os) const
Save string to binary stream.
Definition: UT_String.h:294
virtual ~SOP_RewireParms()
DEP_MicroNode * depnode() const
Definition: SOP_NodeVerb.h:111
void setCreateorigattrib(bool val)
void buildFromOp(const OP_Node *node, fpreal time, DEP_MicroNode *depnode)
static void saveData(std::ostream &os, int64 v)
SYS_FORCE_INLINE T & y(void)
Definition: UT_Vector3.h:583
GLsizei const GLfloat * value
Definition: glcorearb.h:823
double fpreal
Definition: SYS_Types.h:269
void strncpy(const char *src, exint maxlen)
static void saveData(std::ostream &os, UT_Matrix3D v)
void setParmValue(exint idx, const exint &value)
static void loadData(UT_IStream &is, UT_Matrix4D &v)
static void saveData(std::ostream &os, UT_Vector2D v)
static void loadData(UT_IStream &is, UT_Matrix2D &v)
Grouptype getGrouptype() const
Utility class for containing a color ramp.
Definition: UT_Ramp.h:84
void setOrigattrib(const UT_StringHolder &val)
void setParmValue(exint idx, const UT_StringHolder &value)
GLuint GLfloat * val
Definition: glcorearb.h:1607
#define SOP_API
Definition: SOP_API.h:10
void setRecurse(bool val)
static void saveData(std::ostream &os, UT_Vector3D v)
const char * buffer() const
const UT_StringHolder & getOrigattrib() const
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
fpreal getCookTime() const
Definition: SOP_NodeVerb.h:499
T & x(void)
Definition: UT_Vector4.h:368
static void loadData(UT_IStream &is, PRM_DataItemHandle &v)
bool getRecurse() const
T & y(void)
Definition: UT_Vector2.h:286
void save(std::ostream &os) const
GLboolean r
Definition: glcorearb.h:1221
static void saveData(std::ostream &os, fpreal64 v)
void getParmValue(exint idx, UT_Vector4D &value) const
T & w(void)
Definition: UT_Vector4.h:374
static void saveData(std::ostream &os, UT_Matrix4D v)
static void loadData(UT_IStream &is, bool &v)
virtual void loadFromOpSubclass(const LoadParms &loadparms)
void setParmValue(exint idx, const UT_SharedPtr< UT_Ramp > &value)
void getParmValue(exint idx, PRM_DataItemHandle &value) const
const OP_Context & context() const
Definition: SOP_NodeVerb.h:109
static void loadData(UT_IStream &is, UT_Vector3I &v)
void getParmValue(exint idx, UT_Matrix3D &value) const
void getParmValue(exint idx, UT_SharedPtr< UT_Ramp > &value) const
void getParmValue(exint idx, UT_Vector3D &value) const
SYS_FORCE_INLINE bool isstring() const
static void saveData(std::ostream &os, bool v)
void doSetParmValue(exint idx, const T &value)
GLenum src
Definition: glcorearb.h:1792
virtual ParmType getParmType(exint fieldnum) const
void setParmValue(exint idx, const UT_Matrix4D &value)