HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SOP_Normal.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_NormalEnums
22 {
23  enum class Grouptype
24  {
25  GUESS = 0,
26  VERTICES,
27  EDGES,
28  POINTS,
29  PRIMS
30  };
31  enum class Type
32  {
33  TYPEPOINT = 0,
34  TYPEVERTEX,
35  TYPEPRIM,
37  };
38  enum class Method
39  {
40  UNIFORM = 0,
41  ANGLE,
42  AREA
43  };
44 }
45 
46 
48 {
49 public:
50  static int version() { return 1; }
51 
53  {
54  myGroup = ""_sh;
55  myGrouptype = 0;
56  myType = 1;
57  myCuspangle = 60;
58  myMethod = 1;
59 
60  }
61 
62  explicit SOP_NormalParms(const SOP_NormalParms &) = default;
63 
64  virtual ~SOP_NormalParms() {}
65 
66  bool operator==(const SOP_NormalParms &src) const
67  {
68  if (myGroup != src.myGroup) return false;
69  if (myGrouptype != src.myGrouptype) return false;
70  if (myType != src.myType) return false;
71  if (myCuspangle != src.myCuspangle) return false;
72  if (myMethod != src.myMethod) return false;
73 
74  return true;
75  }
79 
80 
81 
82  void buildFromOp(const OP_Node *node, fpreal time, DEP_MicroNode *depnode)
83  {
84  if (true)
85  OP_Utils::evalOpParm(myGroup, node, "group", time, 0);
86  else myGroup = ""_sh;
87  if (true)
88  OP_Utils::evalOpParm(myGrouptype, node, "grouptype", time, 0);
89  else myGrouptype = 0;
90  if (true)
91  OP_Utils::evalOpParm(myType, node, "type", time, 0);
92  else myType = 1;
93  if (true && ( (!(((int64(getType())!=1)))) ) )
94  OP_Utils::evalOpParm(myCuspangle, node, "cuspangle", time, 0);
95  else myCuspangle = 60;
96  if (true)
97  OP_Utils::evalOpParm(myMethod, node, "method", time, 0);
98  else myMethod = 1;
99 
100  }
101 
102 
103  virtual void loadFromOpSubclass(const LoadParms &loadparms)
104  {
105  buildFromOp(loadparms.node(), loadparms.context().getTime(), loadparms.depnode());
106  }
107 
108 
109  virtual void copyFrom(const SOP_NodeParms *src)
110  {
111  *this = *((const SOP_NormalParms *)src);
112  }
113 
114  template <typename T>
115  void
116  doGetParmValue(exint idx, T &value) const
117  {
118  switch (idx)
119  {
120  case 0:
121  coerceValue(value, myGroup);
122  break;
123  case 1:
124  coerceValue(value, myGrouptype);
125  break;
126  case 2:
127  coerceValue(value, myType);
128  break;
129  case 3:
130  coerceValue(value, myCuspangle);
131  break;
132  case 4:
133  coerceValue(value, myMethod);
134  break;
135 
136  }
137  }
138 
139  void getParmValue(exint idx, exint &value) const
140  { doGetParmValue(idx, value); }
141  void getParmValue(exint idx, fpreal &value) const
142  { doGetParmValue(idx, value); }
144  { doGetParmValue(idx, value); }
146  { doGetParmValue(idx, value); }
148  { doGetParmValue(idx, value); }
150  { doGetParmValue(idx, value); }
152  { doGetParmValue(idx, value); }
154  { doGetParmValue(idx, value); }
156  { doGetParmValue(idx, value); }
158  { doGetParmValue(idx, value); }
160  { doGetParmValue(idx, value); }
161 
162  template <typename T>
163  void
164  doSetParmValue(exint idx, const T &value)
165  {
166  switch (idx)
167  {
168  case 0:
169  coerceValue(myGroup, value);
170  break;
171  case 1:
172  coerceValue(myGrouptype, value);
173  break;
174  case 2:
175  coerceValue(myType, value);
176  break;
177  case 3:
178  coerceValue(myCuspangle, value);
179  break;
180  case 4:
181  coerceValue(myMethod, value);
182  break;
183 
184  }
185  }
186 
187  void setParmValue(exint idx, const exint &value)
188  { doSetParmValue(idx, value); }
189  void setParmValue(exint idx, const fpreal &value)
190  { doSetParmValue(idx, value); }
191  void setParmValue(exint idx, const UT_Vector2D &value)
192  { doSetParmValue(idx, value); }
193  void setParmValue(exint idx, const UT_Vector3D &value)
194  { doSetParmValue(idx, value); }
195  void setParmValue(exint idx, const UT_Vector4D &value)
196  { doSetParmValue(idx, value); }
197  void setParmValue(exint idx, const UT_Matrix2D &value)
198  { doSetParmValue(idx, value); }
199  void setParmValue(exint idx, const UT_Matrix3D &value)
200  { doSetParmValue(idx, value); }
201  void setParmValue(exint idx, const UT_Matrix4D &value)
202  { doSetParmValue(idx, value); }
204  { doSetParmValue(idx, value); }
206  { doSetParmValue(idx, value); }
208  { doSetParmValue(idx, value); }
209 
210  virtual exint getNumParms() const
211  {
212  return 5;
213  }
214 
215  virtual const char *getParmName(exint fieldnum) const
216  {
217  switch (fieldnum)
218  {
219  case 0:
220  return "group";
221  case 1:
222  return "grouptype";
223  case 2:
224  return "type";
225  case 3:
226  return "cuspangle";
227  case 4:
228  return "method";
229 
230  }
231  return 0;
232  }
233 
234  virtual ParmType getParmType(exint fieldnum) const
235  {
236  switch (fieldnum)
237  {
238  case 0:
239  return PARM_STRING;
240  case 1:
241  return PARM_INTEGER;
242  case 2:
243  return PARM_INTEGER;
244  case 3:
245  return PARM_FLOAT;
246  case 4:
247  return PARM_INTEGER;
248 
249  }
250  return PARM_UNSUPPORTED;
251  }
252 
253  // Boiler plate to load individual types.
254  static void loadData(UT_IStream &is, int64 &v)
255  { is.bread(&v, 1); }
256  static void loadData(UT_IStream &is, bool &v)
257  { int64 iv; is.bread(&iv, 1); v = iv; }
258  static void loadData(UT_IStream &is, fpreal64 &v)
259  { is.bread<fpreal64>(&v, 1); }
260  static void loadData(UT_IStream &is, UT_Vector2D &v)
261  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1); }
262  static void loadData(UT_IStream &is, UT_Vector3D &v)
263  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
264  is.bread<fpreal64>(&v.z(), 1); }
265  static void loadData(UT_IStream &is, UT_Vector4D &v)
266  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
267  is.bread<fpreal64>(&v.z(), 1); is.bread<fpreal64>(&v.w(), 1); }
268  static void loadData(UT_IStream &is, UT_Matrix2D &v)
269  { for (int r = 0; r < 2; r++) for (int c = 0; c < 2; c++) is.bread<fpreal64>(&v(r, c), 1); }
270  static void loadData(UT_IStream &is, UT_Matrix3D &v)
271  { for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) is.bread<fpreal64>(&v(r, c), 1); }
272  static void loadData(UT_IStream &is, UT_Matrix4D &v)
273  { for (int r = 0; r < 4; r++) for (int c = 0; c < 4; c++) is.bread<fpreal64>(&v(r, c), 1); }
274  static void loadData(UT_IStream &is, UT_Vector2I &v)
275  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1); }
276  static void loadData(UT_IStream &is, UT_Vector3I &v)
277  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
278  is.bread<int64>(&v.z(), 1); }
279  static void loadData(UT_IStream &is, UT_Vector4I &v)
280  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
281  is.bread<int64>(&v.z(), 1); is.bread<int64>(&v.w(), 1); }
283  { is.bread(v); }
285  { UT_StringHolder rampdata;
286  loadData(is, rampdata);
287  if (rampdata.isstring())
288  {
289  v.reset(new UT_Ramp());
290  UT_IStream istr((const char *) rampdata, rampdata.length(), UT_ISTREAM_ASCII);
291  v->load(istr);
292  }
293  else v.reset();
294  }
297  loadData(is, data);
298  if (data.isstring())
299  {
300  // Find the data type.
301  char *colon = UT_StringWrap(data).findChar(':');
302  if (colon)
303  {
304  int typelen = colon - data.buffer();
306  type.strncpy(data.buffer(), typelen);
307  UT_IStream istr(((const char *) data) + typelen + 1, data.length() - (typelen + 1), UT_ISTREAM_BINARY);
308 
309  v = PRM_DataFactory::parseBinary(type.buffer(), istr);
310  }
311  }
312  else v.reset();
313  }
314 
315  static void saveData(std::ostream &os, int64 v)
316  { UTwrite(os, &v); }
317  static void saveData(std::ostream &os, bool v)
318  { int64 iv = v; UTwrite(os, &iv); }
319  static void saveData(std::ostream &os, fpreal64 v)
320  { UTwrite<fpreal64>(os, &v); }
321  static void saveData(std::ostream &os, UT_Vector2D v)
322  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y()); }
323  static void saveData(std::ostream &os, UT_Vector3D v)
324  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
325  UTwrite<fpreal64>(os, &v.z()); }
326  static void saveData(std::ostream &os, UT_Vector4D v)
327  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
328  UTwrite<fpreal64>(os, &v.z()); UTwrite<fpreal64>(os, &v.w()); }
329  static void saveData(std::ostream &os, UT_Matrix2D v)
331  static void saveData(std::ostream &os, UT_Matrix3D v)
333  static void saveData(std::ostream &os, UT_Matrix4D v)
335  static void saveData(std::ostream &os, UT_StringHolder s)
336  { UT_StringWrap(s).saveBinary(os); }
337  static void saveData(std::ostream &os, UT_SharedPtr<UT_Ramp> s)
338  { UT_StringHolder result;
339  UT_OStringStream ostr;
340  if (s) s->save(ostr);
341  result = ostr.str();
342  saveData(os, result);
343  }
344  static void saveData(std::ostream &os, PRM_DataItemHandle s)
345  { UT_StringHolder result;
346  UT_OStringStream ostr;
347  if (s)
348  {
349  ostr << s->getDataTypeToken();
350  ostr << ":";
351  s->saveBinary(ostr);
352  }
353  result = ostr.str();
354  saveData(os, result);
355  }
356 
357 
358  void save(std::ostream &os) const
359  {
360  int32 v = version();
361  UTwrite(os, &v);
362  saveData(os, myGroup);
363  saveData(os, myGrouptype);
364  saveData(os, myType);
365  saveData(os, myCuspangle);
366  saveData(os, myMethod);
367 
368  }
369 
370  bool load(UT_IStream &is)
371  {
372  int32 v;
373  is.bread(&v, 1);
374  if (version() != v)
375  {
376  // Fail incompatible versions
377  return false;
378  }
379  loadData(is, myGroup);
380  loadData(is, myGrouptype);
381  loadData(is, myType);
382  loadData(is, myCuspangle);
383  loadData(is, myMethod);
384 
385  return true;
386  }
387 
388  const UT_StringHolder & getGroup() const { return myGroup; }
389  void setGroup(const UT_StringHolder & val) { myGroup = val; }
391  {
392  SOP_Node *thissop = cookparms.getNode();
393  if (!thissop) return getGroup();
394  UT_StringHolder result;
395  OP_Utils::evalOpParm(result, thissop, "group", cookparms.getCookTime(), 0);
396  return result;
397  }
398  Grouptype getGrouptype() const { return Grouptype(myGrouptype); }
399  void setGrouptype(Grouptype val) { myGrouptype = int64(val); }
401  {
402  SOP_Node *thissop = cookparms.getNode();
403  if (!thissop) return getGrouptype();
404  int64 result;
405  OP_Utils::evalOpParm(result, thissop, "grouptype", cookparms.getCookTime(), 0);
406  return Grouptype(result);
407  }
408  Type getType() const { return Type(myType); }
409  void setType(Type val) { myType = int64(val); }
410  Type opType(const SOP_NodeVerb::CookParms &cookparms) const
411  {
412  SOP_Node *thissop = cookparms.getNode();
413  if (!thissop) return getType();
414  int64 result;
415  OP_Utils::evalOpParm(result, thissop, "type", cookparms.getCookTime(), 0);
416  return Type(result);
417  }
418  fpreal64 getCuspangle() const { return myCuspangle; }
419  void setCuspangle(fpreal64 val) { myCuspangle = val; }
421  {
422  SOP_Node *thissop = cookparms.getNode();
423  if (!thissop) return getCuspangle();
424  fpreal64 result;
425  OP_Utils::evalOpParm(result, thissop, "cuspangle", cookparms.getCookTime(), 0);
426  return result;
427  }
428  Method getMethod() const { return Method(myMethod); }
429  void setMethod(Method val) { myMethod = int64(val); }
430  Method opMethod(const SOP_NodeVerb::CookParms &cookparms) const
431  {
432  SOP_Node *thissop = cookparms.getNode();
433  if (!thissop) return getMethod();
434  int64 result;
435  OP_Utils::evalOpParm(result, thissop, "method", cookparms.getCookTime(), 0);
436  return Method(result);
437  }
438 
439 private:
440  UT_StringHolder myGroup;
441  int64 myGrouptype;
442  int64 myType;
443  fpreal64 myCuspangle;
444  int64 myMethod;
445 
446 };
void getParmValue(exint idx, UT_Matrix4D &value) const
void save(std::ostream &os) const
void doGetParmValue(exint idx, T &value) const
static void saveData(std::ostream &os, UT_StringHolder s)
virtual exint getNumParms() const
static void saveData(std::ostream &os, bool v)
static void loadData(UT_IStream &is, UT_Vector2I &v)
SOP_Node * getNode() const
Definition: SOP_NodeVerb.h:492
virtual void copyFrom(const SOP_NodeParms *src)
void setParmValue(exint idx, const PRM_DataItemHandle &value)
T & z(void)
Definition: UT_Vector4.h:372
void getParmValue(exint idx, UT_Vector2D &value) const
exint bread(int32 *buffer, exint asize=1)
static void loadData(UT_IStream &is, UT_Vector3I &v)
static void loadData(UT_IStream &is, UT_Matrix4D &v)
fpreal getTime() const
Definition: OP_Context.h:34
const GLdouble * v
Definition: glcorearb.h:836
void getParmValue(exint idx, UT_Vector4D &value) const
void getParmValue(exint idx, UT_SharedPtr< UT_Ramp > &value) const
T & x(void)
Definition: UT_Vector2.h:284
static void loadData(UT_IStream &is, bool &v)
An output stream object that owns its own string buffer storage.
static void loadData(UT_IStream &is, PRM_DataItemHandle &v)
void setGrouptype(Grouptype val)
static void loadData(UT_IStream &is, UT_Matrix2D &v)
const UT_WorkBuffer & str() const
Returns a read-only reference to the underlying UT_WorkBuffer.
void buildFromOp(const OP_Node *node, fpreal time, DEP_MicroNode *depnode)
SYS_FORCE_INLINE T & x(void)
Definition: UT_Vector3.h:581
bool operator==(const SOP_NormalParms &src) const
void getParmValue(exint idx, UT_Matrix2D &value) const
static PRM_DataItemHandle parseBinary(const char *type, UT_IStream &is)
static void saveData(std::ostream &os, fpreal64 v)
void setCuspangle(fpreal64 val)
static void loadData(UT_IStream &is, UT_Matrix3D &v)
void getParmValue(exint idx, UT_StringHolder &value) const
void setType(Type val)
void getParmValue(exint idx, UT_Matrix3D &value) const
SYS_FORCE_INLINE T & z(void)
Definition: UT_Vector3.h:585
long long int64
Definition: SYS_Types.h:106
Method opMethod(const SOP_NodeVerb::CookParms &cookparms) const
Method getMethod() const
virtual void loadFromOpSubclass(const LoadParms &loadparms)
exint length() const
void setGroup(const UT_StringHolder &val)
char * findChar(int c) const
Find first occurrance of character. Returns NULL upon failure.
Definition: UT_String.h:550
void getParmValue(exint idx, UT_Vector3D &value) const
static void loadData(UT_IStream &is, UT_Vector3D &v)
SYS_FORCE_INLINE const char * buffer() const
int64 exint
Definition: SYS_Types.h:115
void setParmValue(exint idx, const UT_Vector2D &value)
const OP_Node * node() const
Definition: SOP_NodeVerb.h:104
static void loadData(UT_IStream &is, UT_Vector4D &v)
double fpreal64
Definition: SYS_Types.h:191
static void saveData(std::ostream &os, UT_SharedPtr< UT_Ramp > s)
Type opType(const SOP_NodeVerb::CookParms &cookparms) const
static int version()
virtual const char * getParmName(exint fieldnum) const
void setParmValue(exint idx, const exint &value)
Grouptype opGrouptype(const SOP_NodeVerb::CookParms &cookparms) const
static void loadData(UT_IStream &is, int64 &v)
void setParmValue(exint idx, const UT_Matrix3D &value)
static void saveData(std::ostream &os, UT_Vector2D v)
static void loadData(UT_IStream &is, UT_StringHolder &v)
Grouptype getGrouptype() const
void setParmValue(exint idx, const UT_StringHolder &value)
static void loadData(UT_IStream &is, UT_Vector2D &v)
GLboolean * data
Definition: glcorearb.h:130
int int32
Definition: SYS_Types.h:34
T & y(void)
Definition: UT_Vector4.h:370
void saveBinary(std::ostream &os) const
Save string to binary stream.
Definition: UT_String.h:294
UT_StringHolder opGroup(const SOP_NodeVerb::CookParms &cookparms) const
void setParmValue(exint idx, const UT_SharedPtr< UT_Ramp > &value)
DEP_MicroNode * depnode() const
Definition: SOP_NodeVerb.h:111
static void saveData(std::ostream &os, int64 v)
void getParmValue(exint idx, PRM_DataItemHandle &value) const
void setParmValue(exint idx, const fpreal &value)
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
static void saveData(std::ostream &os, UT_Vector4D v)
void strncpy(const char *src, exint maxlen)
void setMethod(Method val)
static void loadData(UT_IStream &is, fpreal64 &v)
void doSetParmValue(exint idx, const T &value)
Utility class for containing a color ramp.
Definition: UT_Ramp.h:84
static void saveData(std::ostream &os, UT_Matrix2D v)
void setParmValue(exint idx, const UT_Vector3D &value)
void getParmValue(exint idx, exint &value) const
GLuint GLfloat * val
Definition: glcorearb.h:1607
static void loadData(UT_IStream &is, UT_SharedPtr< UT_Ramp > &v)
void setParmValue(exint idx, const UT_Vector4D &value)
#define SOP_API
Definition: SOP_API.h:10
virtual ParmType getParmType(exint fieldnum) const
const char * buffer() const
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
bool load(UT_IStream &is)
void setParmValue(exint idx, const UT_Matrix4D &value)
fpreal getCookTime() const
Definition: SOP_NodeVerb.h:499
T & x(void)
Definition: UT_Vector4.h:368
static void saveData(std::ostream &os, UT_Matrix4D v)
T & y(void)
Definition: UT_Vector2.h:286
static void saveData(std::ostream &os, UT_Matrix3D v)
GLboolean r
Definition: glcorearb.h:1221
static void loadData(UT_IStream &is, UT_Vector4I &v)
Type getType() const
void getParmValue(exint idx, fpreal &value) const
T & w(void)
Definition: UT_Vector4.h:374
static void saveData(std::ostream &os, UT_Vector3D v)
fpreal64 opCuspangle(const SOP_NodeVerb::CookParms &cookparms) const
virtual ~SOP_NormalParms()
void setParmValue(exint idx, const UT_Matrix2D &value)
const OP_Context & context() const
Definition: SOP_NodeVerb.h:109
static void saveData(std::ostream &os, PRM_DataItemHandle s)
fpreal64 getCuspangle() const
SYS_FORCE_INLINE bool isstring() const
const UT_StringHolder & getGroup() const
GLenum src
Definition: glcorearb.h:1792