HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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  }
76  bool operator!=(const SOP_NormalParms &src) const
77  {
78  return !operator==(src);
79  }
83 
84 
85 
86  void buildFromOp(const OP_Node *node, fpreal time, DEP_MicroNode *depnode)
87  {
88  if (true)
89  OP_Utils::evalOpParm(myGroup, node, "group", time, 0);
90  else myGroup = ""_sh;
91  if (true)
92  OP_Utils::evalOpParm(myGrouptype, node, "grouptype", time, 0);
93  else myGrouptype = 0;
94  if (true)
95  OP_Utils::evalOpParm(myType, node, "type", time, 0);
96  else myType = 1;
97  if (true && ( (!(((int64(getType())!=1)))) ) )
98  OP_Utils::evalOpParm(myCuspangle, node, "cuspangle", time, 0);
99  else myCuspangle = 60;
100  if (true)
101  OP_Utils::evalOpParm(myMethod, node, "method", time, 0);
102  else myMethod = 1;
103 
104  }
105 
106 
107  virtual void loadFromOpSubclass(const LoadParms &loadparms)
108  {
109  buildFromOp(loadparms.node(), loadparms.context().getTime(), loadparms.depnode());
110  }
111 
112 
113  virtual void copyFrom(const SOP_NodeParms *src)
114  {
115  *this = *((const SOP_NormalParms *)src);
116  }
117 
118  template <typename T>
119  void
120  doGetParmValue(exint idx, T &value) const
121  {
122  switch (idx)
123  {
124  case 0:
125  coerceValue(value, myGroup);
126  break;
127  case 1:
128  coerceValue(value, myGrouptype);
129  break;
130  case 2:
131  coerceValue(value, myType);
132  break;
133  case 3:
134  coerceValue(value, myCuspangle);
135  break;
136  case 4:
137  coerceValue(value, myMethod);
138  break;
139 
140  }
141  }
142 
143  void getParmValue(exint idx, exint &value) const
144  { doGetParmValue(idx, value); }
145  void getParmValue(exint idx, fpreal &value) const
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); }
162  { doGetParmValue(idx, value); }
164  { doGetParmValue(idx, value); }
165 
166  template <typename T>
167  void
168  doSetParmValue(exint idx, const T &value)
169  {
170  switch (idx)
171  {
172  case 0:
173  coerceValue(myGroup, value);
174  break;
175  case 1:
176  coerceValue(myGrouptype, value);
177  break;
178  case 2:
179  coerceValue(myType, value);
180  break;
181  case 3:
182  coerceValue(myCuspangle, value);
183  break;
184  case 4:
185  coerceValue(myMethod, value);
186  break;
187 
188  }
189  }
190 
191  void setParmValue(exint idx, const exint &value)
192  { doSetParmValue(idx, value); }
193  void setParmValue(exint idx, const fpreal &value)
194  { doSetParmValue(idx, value); }
195  void setParmValue(exint idx, const UT_Vector2D &value)
196  { doSetParmValue(idx, value); }
197  void setParmValue(exint idx, const UT_Vector3D &value)
198  { doSetParmValue(idx, value); }
199  void setParmValue(exint idx, const UT_Vector4D &value)
200  { doSetParmValue(idx, value); }
201  void setParmValue(exint idx, const UT_Matrix2D &value)
202  { doSetParmValue(idx, value); }
203  void setParmValue(exint idx, const UT_Matrix3D &value)
204  { doSetParmValue(idx, value); }
205  void setParmValue(exint idx, const UT_Matrix4D &value)
206  { doSetParmValue(idx, value); }
208  { doSetParmValue(idx, value); }
210  { doSetParmValue(idx, value); }
212  { doSetParmValue(idx, value); }
213 
214  virtual exint getNumParms() const
215  {
216  return 5;
217  }
218 
219  virtual const char *getParmName(exint fieldnum) const
220  {
221  switch (fieldnum)
222  {
223  case 0:
224  return "group";
225  case 1:
226  return "grouptype";
227  case 2:
228  return "type";
229  case 3:
230  return "cuspangle";
231  case 4:
232  return "method";
233 
234  }
235  return 0;
236  }
237 
238  virtual ParmType getParmType(exint fieldnum) const
239  {
240  switch (fieldnum)
241  {
242  case 0:
243  return PARM_STRING;
244  case 1:
245  return PARM_INTEGER;
246  case 2:
247  return PARM_INTEGER;
248  case 3:
249  return PARM_FLOAT;
250  case 4:
251  return PARM_INTEGER;
252 
253  }
254  return PARM_UNSUPPORTED;
255  }
256 
257  // Boiler plate to load individual types.
258  static void loadData(UT_IStream &is, int64 &v)
259  { is.bread(&v, 1); }
260  static void loadData(UT_IStream &is, bool &v)
261  { int64 iv; is.bread(&iv, 1); v = iv; }
262  static void loadData(UT_IStream &is, fpreal64 &v)
263  { is.bread<fpreal64>(&v, 1); }
264  static void loadData(UT_IStream &is, UT_Vector2D &v)
265  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1); }
266  static void loadData(UT_IStream &is, UT_Vector3D &v)
267  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
268  is.bread<fpreal64>(&v.z(), 1); }
269  static void loadData(UT_IStream &is, UT_Vector4D &v)
270  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
271  is.bread<fpreal64>(&v.z(), 1); is.bread<fpreal64>(&v.w(), 1); }
272  static void loadData(UT_IStream &is, UT_Matrix2D &v)
273  { for (int r = 0; r < 2; r++) for (int c = 0; c < 2; c++) is.bread<fpreal64>(&v(r, c), 1); }
274  static void loadData(UT_IStream &is, UT_Matrix3D &v)
275  { for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) is.bread<fpreal64>(&v(r, c), 1); }
276  static void loadData(UT_IStream &is, UT_Matrix4D &v)
277  { for (int r = 0; r < 4; r++) for (int c = 0; c < 4; c++) is.bread<fpreal64>(&v(r, c), 1); }
278  static void loadData(UT_IStream &is, UT_Vector2I &v)
279  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1); }
280  static void loadData(UT_IStream &is, UT_Vector3I &v)
281  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
282  is.bread<int64>(&v.z(), 1); }
283  static void loadData(UT_IStream &is, UT_Vector4I &v)
284  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
285  is.bread<int64>(&v.z(), 1); is.bread<int64>(&v.w(), 1); }
287  { is.bread(v); }
289  { UT_StringHolder rampdata;
290  loadData(is, rampdata);
291  if (rampdata.isstring())
292  {
293  v.reset(new UT_Ramp());
294  UT_IStream istr((const char *) rampdata, rampdata.length(), UT_ISTREAM_ASCII);
295  v->load(istr);
296  }
297  else v.reset();
298  }
301  loadData(is, data);
302  if (data.isstring())
303  {
304  // Find the data type.
305  char *colon = UT_StringWrap(data).findChar(':');
306  if (colon)
307  {
308  int typelen = colon - data.buffer();
310  type.strncpy(data.buffer(), typelen);
311  UT_IStream istr(((const char *) data) + typelen + 1, data.length() - (typelen + 1), UT_ISTREAM_BINARY);
312 
313  v = PRM_DataFactory::parseBinary(type.buffer(), istr);
314  }
315  }
316  else v.reset();
317  }
318 
319  static void saveData(std::ostream &os, int64 v)
320  { UTwrite(os, &v); }
321  static void saveData(std::ostream &os, bool v)
322  { int64 iv = v; UTwrite(os, &iv); }
323  static void saveData(std::ostream &os, fpreal64 v)
324  { UTwrite<fpreal64>(os, &v); }
325  static void saveData(std::ostream &os, UT_Vector2D v)
326  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y()); }
327  static void saveData(std::ostream &os, UT_Vector3D v)
328  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
329  UTwrite<fpreal64>(os, &v.z()); }
330  static void saveData(std::ostream &os, UT_Vector4D v)
331  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
332  UTwrite<fpreal64>(os, &v.z()); UTwrite<fpreal64>(os, &v.w()); }
333  static void saveData(std::ostream &os, UT_Matrix2D v)
335  static void saveData(std::ostream &os, UT_Matrix3D v)
337  static void saveData(std::ostream &os, UT_Matrix4D v)
339  static void saveData(std::ostream &os, UT_StringHolder s)
340  { UT_StringWrap(s).saveBinary(os); }
341  static void saveData(std::ostream &os, UT_SharedPtr<UT_Ramp> s)
342  { UT_StringHolder result;
343  UT_OStringStream ostr;
344  if (s) s->save(ostr);
345  result = ostr.str();
346  saveData(os, result);
347  }
348  static void saveData(std::ostream &os, PRM_DataItemHandle s)
349  { UT_StringHolder result;
350  UT_OStringStream ostr;
351  if (s)
352  {
353  ostr << s->getDataTypeToken();
354  ostr << ":";
355  s->saveBinary(ostr);
356  }
357  result = ostr.str();
358  saveData(os, result);
359  }
360 
361 
362  void save(std::ostream &os) const
363  {
364  int32 v = version();
365  UTwrite(os, &v);
366  saveData(os, myGroup);
367  saveData(os, myGrouptype);
368  saveData(os, myType);
369  saveData(os, myCuspangle);
370  saveData(os, myMethod);
371 
372  }
373 
374  bool load(UT_IStream &is)
375  {
376  int32 v;
377  is.bread(&v, 1);
378  if (version() != v)
379  {
380  // Fail incompatible versions
381  return false;
382  }
383  loadData(is, myGroup);
384  loadData(is, myGrouptype);
385  loadData(is, myType);
386  loadData(is, myCuspangle);
387  loadData(is, myMethod);
388 
389  return true;
390  }
391 
392  const UT_StringHolder & getGroup() const { return myGroup; }
393  void setGroup(const UT_StringHolder & val) { myGroup = val; }
395  {
396  SOP_Node *thissop = cookparms.getNode();
397  if (!thissop) return getGroup();
398  UT_StringHolder result;
399  OP_Utils::evalOpParm(result, thissop, "group", cookparms.getCookTime(), 0);
400  return result;
401  }
402  Grouptype getGrouptype() const { return Grouptype(myGrouptype); }
403  void setGrouptype(Grouptype val) { myGrouptype = int64(val); }
405  {
406  SOP_Node *thissop = cookparms.getNode();
407  if (!thissop) return getGrouptype();
408  int64 result;
409  OP_Utils::evalOpParm(result, thissop, "grouptype", cookparms.getCookTime(), 0);
410  return Grouptype(result);
411  }
412  Type getType() const { return Type(myType); }
413  void setType(Type val) { myType = int64(val); }
414  Type opType(const SOP_NodeVerb::CookParms &cookparms) const
415  {
416  SOP_Node *thissop = cookparms.getNode();
417  if (!thissop) return getType();
418  int64 result;
419  OP_Utils::evalOpParm(result, thissop, "type", cookparms.getCookTime(), 0);
420  return Type(result);
421  }
422  fpreal64 getCuspangle() const { return myCuspangle; }
423  void setCuspangle(fpreal64 val) { myCuspangle = val; }
425  {
426  SOP_Node *thissop = cookparms.getNode();
427  if (!thissop) return getCuspangle();
428  fpreal64 result;
429  OP_Utils::evalOpParm(result, thissop, "cuspangle", cookparms.getCookTime(), 0);
430  return result;
431  }
432  Method getMethod() const { return Method(myMethod); }
433  void setMethod(Method val) { myMethod = int64(val); }
434  Method opMethod(const SOP_NodeVerb::CookParms &cookparms) const
435  {
436  SOP_Node *thissop = cookparms.getNode();
437  if (!thissop) return getMethod();
438  int64 result;
439  OP_Utils::evalOpParm(result, thissop, "method", cookparms.getCookTime(), 0);
440  return Method(result);
441  }
442 
443 private:
444  UT_StringHolder myGroup;
445  int64 myGrouptype;
446  int64 myType;
447  fpreal64 myCuspangle;
448  int64 myMethod;
449 
450 };
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:494
virtual void copyFrom(const SOP_NodeParms *src)
void setParmValue(exint idx, const PRM_DataItemHandle &value)
T & z(void)
Definition: UT_Vector4.h:379
void getParmValue(exint idx, UT_Vector2D &value) const
exint bread(int32 *buffer, exint asize=1)
static void loadData(UT_IStream &is, UT_Vector3I &v)
GT_API const UT_StringHolder time
static void loadData(UT_IStream &is, UT_Matrix4D &v)
fpreal getTime() const
Definition: OP_Context.h:60
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
SYS_FORCE_INLINE const char * buffer() const
T & x(void)
Definition: UT_Vector2.h:285
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:498
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:502
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
long long int64
Definition: SYS_Types.h:107
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
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:28
int64 exint
Definition: SYS_Types.h:116
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:192
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:35
T & y(void)
Definition: UT_Vector4.h:377
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)
GT_API const UT_StringHolder version
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:500
GLsizei const GLfloat * value
Definition: glcorearb.h:823
double fpreal
Definition: SYS_Types.h:270
static void saveData(std::ostream &os, UT_Vector4D v)
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
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:501
T & x(void)
Definition: UT_Vector4.h:375
static void saveData(std::ostream &os, UT_Matrix4D v)
T & y(void)
Definition: UT_Vector2.h:287
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:381
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)
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
Definition: PRM_Parm.h:88
fpreal64 getCuspangle() const
SYS_FORCE_INLINE bool isstring() const
bool operator!=(const SOP_NormalParms &src) const
SYS_FORCE_INLINE void strncpy(const char *src, exint maxlen)
const UT_StringHolder & getGroup() const
GLenum src
Definition: glcorearb.h:1792