HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_PrimitiveSplit.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 
23 {
24 public:
25  static int version() { return 1; }
26 
28  {
29  myGroup = ""_sh;
30  myAttribname = ""_sh;
31  myTol = 0.001;
32 
33  }
34 
35  explicit SOP_PrimitiveSplitParms(const SOP_PrimitiveSplitParms &) = default;
36 
38 
40  {
41  if (myGroup != src.myGroup) return false;
42  if (myAttribname != src.myAttribname) return false;
43  if (myTol != src.myTol) return false;
44 
45  return true;
46  }
48  {
49  return !operator==(src);
50  }
51 
52 
53 
54  void buildFromOp(const OP_Node *node, fpreal time, DEP_MicroNode *depnode)
55  {
56  if (true)
57  OP_Utils::evalOpParm(myGroup, node, "group", time, 0);
58  else myGroup = ""_sh;
59  if (true)
60  OP_Utils::evalOpParm(myAttribname, node, "attribname", time, 0);
61  else myAttribname = ""_sh;
62  if (true)
63  OP_Utils::evalOpParm(myTol, node, "tol", time, 0);
64  else myTol = 0.001;
65 
66  }
67 
68 
69  virtual void loadFromOpSubclass(const LoadParms &loadparms)
70  {
71  buildFromOp(loadparms.node(), loadparms.context().getTime(), loadparms.depnode());
72  }
73 
74 
75  virtual void copyFrom(const SOP_NodeParms *src)
76  {
77  *this = *((const SOP_PrimitiveSplitParms *)src);
78  }
79 
80  template <typename T>
81  void
82  doGetParmValue(exint idx, T &value) const
83  {
84  switch (idx)
85  {
86  case 0:
87  coerceValue(value, myGroup);
88  break;
89  case 1:
90  coerceValue(value, myAttribname);
91  break;
92  case 2:
93  coerceValue(value, myTol);
94  break;
95 
96  }
97  }
98 
99  void getParmValue(exint idx, exint &value) const
100  { doGetParmValue(idx, value); }
101  void getParmValue(exint idx, fpreal &value) const
102  { doGetParmValue(idx, value); }
104  { doGetParmValue(idx, value); }
106  { doGetParmValue(idx, value); }
108  { doGetParmValue(idx, value); }
110  { doGetParmValue(idx, value); }
112  { doGetParmValue(idx, value); }
114  { doGetParmValue(idx, value); }
116  { doGetParmValue(idx, value); }
118  { doGetParmValue(idx, value); }
120  { doGetParmValue(idx, value); }
121 
122  template <typename T>
123  void
124  doSetParmValue(exint idx, const T &value)
125  {
126  switch (idx)
127  {
128  case 0:
129  coerceValue(myGroup, value);
130  break;
131  case 1:
132  coerceValue(myAttribname, value);
133  break;
134  case 2:
135  coerceValue(myTol, value);
136  break;
137 
138  }
139  }
140 
141  void setParmValue(exint idx, const exint &value)
142  { doSetParmValue(idx, value); }
143  void setParmValue(exint idx, const fpreal &value)
144  { doSetParmValue(idx, value); }
145  void setParmValue(exint idx, const UT_Vector2D &value)
146  { doSetParmValue(idx, value); }
147  void setParmValue(exint idx, const UT_Vector3D &value)
148  { doSetParmValue(idx, value); }
149  void setParmValue(exint idx, const UT_Vector4D &value)
150  { doSetParmValue(idx, value); }
151  void setParmValue(exint idx, const UT_Matrix2D &value)
152  { doSetParmValue(idx, value); }
153  void setParmValue(exint idx, const UT_Matrix3D &value)
154  { doSetParmValue(idx, value); }
155  void setParmValue(exint idx, const UT_Matrix4D &value)
156  { doSetParmValue(idx, value); }
158  { doSetParmValue(idx, value); }
160  { doSetParmValue(idx, value); }
162  { doSetParmValue(idx, value); }
163 
164  virtual exint getNumParms() const
165  {
166  return 3;
167  }
168 
169  virtual const char *getParmName(exint fieldnum) const
170  {
171  switch (fieldnum)
172  {
173  case 0:
174  return "group";
175  case 1:
176  return "attribname";
177  case 2:
178  return "tol";
179 
180  }
181  return 0;
182  }
183 
184  virtual ParmType getParmType(exint fieldnum) const
185  {
186  switch (fieldnum)
187  {
188  case 0:
189  return PARM_STRING;
190  case 1:
191  return PARM_STRING;
192  case 2:
193  return PARM_FLOAT;
194 
195  }
196  return PARM_UNSUPPORTED;
197  }
198 
199  // Boiler plate to load individual types.
200  static void loadData(UT_IStream &is, int64 &v)
201  { is.bread(&v, 1); }
202  static void loadData(UT_IStream &is, bool &v)
203  { int64 iv; is.bread(&iv, 1); v = iv; }
204  static void loadData(UT_IStream &is, fpreal64 &v)
205  { is.bread<fpreal64>(&v, 1); }
206  static void loadData(UT_IStream &is, UT_Vector2D &v)
207  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1); }
208  static void loadData(UT_IStream &is, UT_Vector3D &v)
209  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
210  is.bread<fpreal64>(&v.z(), 1); }
211  static void loadData(UT_IStream &is, UT_Vector4D &v)
212  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
213  is.bread<fpreal64>(&v.z(), 1); is.bread<fpreal64>(&v.w(), 1); }
214  static void loadData(UT_IStream &is, UT_Matrix2D &v)
215  { for (int r = 0; r < 2; r++) for (int c = 0; c < 2; c++) is.bread<fpreal64>(&v(r, c), 1); }
216  static void loadData(UT_IStream &is, UT_Matrix3D &v)
217  { for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) is.bread<fpreal64>(&v(r, c), 1); }
218  static void loadData(UT_IStream &is, UT_Matrix4D &v)
219  { for (int r = 0; r < 4; r++) for (int c = 0; c < 4; c++) is.bread<fpreal64>(&v(r, c), 1); }
220  static void loadData(UT_IStream &is, UT_Vector2I &v)
221  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1); }
222  static void loadData(UT_IStream &is, UT_Vector3I &v)
223  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
224  is.bread<int64>(&v.z(), 1); }
225  static void loadData(UT_IStream &is, UT_Vector4I &v)
226  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
227  is.bread<int64>(&v.z(), 1); is.bread<int64>(&v.w(), 1); }
229  { is.bread(v); }
231  { UT_StringHolder rampdata;
232  loadData(is, rampdata);
233  if (rampdata.isstring())
234  {
235  v.reset(new UT_Ramp());
236  UT_IStream istr((const char *) rampdata, rampdata.length(), UT_ISTREAM_ASCII);
237  v->load(istr);
238  }
239  else v.reset();
240  }
243  loadData(is, data);
244  if (data.isstring())
245  {
246  // Find the data type.
247  char *colon = UT_StringWrap(data).findChar(':');
248  if (colon)
249  {
250  int typelen = colon - data.buffer();
252  type.strncpy(data.buffer(), typelen);
253  UT_IStream istr(((const char *) data) + typelen + 1, data.length() - (typelen + 1), UT_ISTREAM_BINARY);
254 
255  v = PRM_DataFactory::parseBinary(type.buffer(), istr);
256  }
257  }
258  else v.reset();
259  }
260 
261  static void saveData(std::ostream &os, int64 v)
262  { UTwrite(os, &v); }
263  static void saveData(std::ostream &os, bool v)
264  { int64 iv = v; UTwrite(os, &iv); }
265  static void saveData(std::ostream &os, fpreal64 v)
266  { UTwrite<fpreal64>(os, &v); }
267  static void saveData(std::ostream &os, UT_Vector2D v)
268  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y()); }
269  static void saveData(std::ostream &os, UT_Vector3D v)
270  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
271  UTwrite<fpreal64>(os, &v.z()); }
272  static void saveData(std::ostream &os, UT_Vector4D v)
273  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
274  UTwrite<fpreal64>(os, &v.z()); UTwrite<fpreal64>(os, &v.w()); }
275  static void saveData(std::ostream &os, UT_Matrix2D v)
277  static void saveData(std::ostream &os, UT_Matrix3D v)
279  static void saveData(std::ostream &os, UT_Matrix4D v)
281  static void saveData(std::ostream &os, UT_StringHolder s)
282  { UT_StringWrap(s).saveBinary(os); }
283  static void saveData(std::ostream &os, UT_SharedPtr<UT_Ramp> s)
284  { UT_StringHolder result;
285  UT_OStringStream ostr;
286  if (s) s->save(ostr);
287  result = ostr.str();
288  saveData(os, result);
289  }
290  static void saveData(std::ostream &os, PRM_DataItemHandle s)
291  { UT_StringHolder result;
292  UT_OStringStream ostr;
293  if (s)
294  {
295  ostr << s->getDataTypeToken();
296  ostr << ":";
297  s->saveBinary(ostr);
298  }
299  result = ostr.str();
300  saveData(os, result);
301  }
302 
303 
304  void save(std::ostream &os) const
305  {
306  int32 v = version();
307  UTwrite(os, &v);
308  saveData(os, myGroup);
309  saveData(os, myAttribname);
310  saveData(os, myTol);
311 
312  }
313 
314  bool load(UT_IStream &is)
315  {
316  int32 v;
317  is.bread(&v, 1);
318  if (version() != v)
319  {
320  // Fail incompatible versions
321  return false;
322  }
323  loadData(is, myGroup);
324  loadData(is, myAttribname);
325  loadData(is, myTol);
326 
327  return true;
328  }
329 
330  const UT_StringHolder & getGroup() const { return myGroup; }
331  void setGroup(const UT_StringHolder & val) { myGroup = val; }
333  {
334  SOP_Node *thissop = cookparms.getNode();
335  if (!thissop) return getGroup();
336  UT_StringHolder result;
337  OP_Utils::evalOpParm(result, thissop, "group", cookparms.getCookTime(), 0);
338  return result;
339  }
340  const UT_StringHolder & getAttribname() const { return myAttribname; }
341  void setAttribname(const UT_StringHolder & val) { myAttribname = val; }
343  {
344  SOP_Node *thissop = cookparms.getNode();
345  if (!thissop) return getAttribname();
346  UT_StringHolder result;
347  OP_Utils::evalOpParm(result, thissop, "attribname", cookparms.getCookTime(), 0);
348  return result;
349  }
350  fpreal64 getTol() const { return myTol; }
351  void setTol(fpreal64 val) { myTol = val; }
352  fpreal64 opTol(const SOP_NodeVerb::CookParms &cookparms) const
353  {
354  SOP_Node *thissop = cookparms.getNode();
355  if (!thissop) return getTol();
356  fpreal64 result;
357  OP_Utils::evalOpParm(result, thissop, "tol", cookparms.getCookTime(), 0);
358  return result;
359  }
360 
361 private:
362  UT_StringHolder myGroup;
363  UT_StringHolder myAttribname;
364  fpreal64 myTol;
365 
366 };
static void loadData(UT_IStream &is, bool &v)
void getParmValue(exint idx, UT_SharedPtr< UT_Ramp > &value) const
void save(std::ostream &os) const
static void loadData(UT_IStream &is, UT_Vector4I &v)
void setParmValue(exint idx, const UT_Vector2D &value)
SOP_Node * getNode() const
Definition: SOP_NodeVerb.h:494
void getParmValue(exint idx, exint &value) const
T & z(void)
Definition: UT_Vector4.h:379
void setParmValue(exint idx, const UT_Vector4D &value)
virtual const char * getParmName(exint fieldnum) const
void doGetParmValue(exint idx, T &value) const
static void loadData(UT_IStream &is, fpreal64 &v)
void getParmValue(exint idx, UT_Vector2D &value) const
exint bread(int32 *buffer, exint asize=1)
GT_API const UT_StringHolder time
fpreal getTime() const
Definition: OP_Context.h:60
const GLdouble * v
Definition: glcorearb.h:836
static void saveData(std::ostream &os, UT_Matrix3D v)
void setParmValue(exint idx, const PRM_DataItemHandle &value)
void setAttribname(const UT_StringHolder &val)
SYS_FORCE_INLINE const char * buffer() const
T & x(void)
Definition: UT_Vector2.h:285
An output stream object that owns its own string buffer storage.
void buildFromOp(const OP_Node *node, fpreal time, DEP_MicroNode *depnode)
bool operator==(const SOP_PrimitiveSplitParms &src) const
void setParmValue(exint idx, const fpreal &value)
bool operator!=(const SOP_PrimitiveSplitParms &src) const
static void loadData(UT_IStream &is, UT_Vector3D &v)
static void loadData(UT_IStream &is, UT_Matrix3D &v)
const UT_WorkBuffer & str() const
Returns a read-only reference to the underlying UT_WorkBuffer.
SYS_FORCE_INLINE T & x(void)
Definition: UT_Vector3.h:498
void getParmValue(exint idx, PRM_DataItemHandle &value) const
virtual exint getNumParms() const
static PRM_DataItemHandle parseBinary(const char *type, UT_IStream &is)
static void loadData(UT_IStream &is, UT_StringHolder &v)
const UT_StringHolder & getAttribname() const
UT_StringHolder opAttribname(const SOP_NodeVerb::CookParms &cookparms) const
static void saveData(std::ostream &os, UT_Vector3D v)
void getParmValue(exint idx, fpreal &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
static void loadData(UT_IStream &is, UT_Vector2D &v)
void getParmValue(exint idx, UT_Vector3D &value) const
long long int64
Definition: SYS_Types.h:107
static void saveData(std::ostream &os, UT_Vector4D v)
static void loadData(UT_IStream &is, UT_Vector4D &v)
static void saveData(std::ostream &os, UT_SharedPtr< UT_Ramp > s)
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
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:28
virtual ParmType getParmType(exint fieldnum) const
int64 exint
Definition: SYS_Types.h:116
static void saveData(std::ostream &os, UT_Matrix2D v)
const OP_Node * node() const
Definition: SOP_NodeVerb.h:104
double fpreal64
Definition: SYS_Types.h:192
void setParmValue(exint idx, const UT_Matrix4D &value)
void setParmValue(exint idx, const UT_Vector3D &value)
void setGroup(const UT_StringHolder &val)
void getParmValue(exint idx, UT_StringHolder &value) const
static void saveData(std::ostream &os, fpreal64 v)
static void saveData(std::ostream &os, int64 v)
void doSetParmValue(exint idx, const T &value)
GLboolean * data
Definition: glcorearb.h:130
int int32
Definition: SYS_Types.h:35
void setParmValue(exint idx, const UT_Matrix2D &value)
static void loadData(UT_IStream &is, UT_SharedPtr< UT_Ramp > &v)
T & y(void)
Definition: UT_Vector4.h:377
fpreal64 opTol(const SOP_NodeVerb::CookParms &cookparms) const
void saveBinary(std::ostream &os) const
Save string to binary stream.
Definition: UT_String.h:294
static void saveData(std::ostream &os, UT_Matrix4D v)
static void loadData(UT_IStream &is, PRM_DataItemHandle &v)
void setParmValue(exint idx, const UT_StringHolder &value)
GT_API const UT_StringHolder version
DEP_MicroNode * depnode() const
Definition: SOP_NodeVerb.h:111
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_Vector2D v)
void getParmValue(exint idx, UT_Matrix3D &value) const
void setParmValue(exint idx, const UT_SharedPtr< UT_Ramp > &value)
static void loadData(UT_IStream &is, UT_Matrix4D &v)
const UT_StringHolder & getGroup() const
void getParmValue(exint idx, UT_Vector4D &value) const
void getParmValue(exint idx, UT_Matrix4D &value) const
Utility class for containing a color ramp.
Definition: UT_Ramp.h:84
static void saveData(std::ostream &os, PRM_DataItemHandle s)
static void loadData(UT_IStream &is, UT_Matrix2D &v)
GLuint GLfloat * val
Definition: glcorearb.h:1607
void getParmValue(exint idx, UT_Matrix2D &value) const
virtual void loadFromOpSubclass(const LoadParms &loadparms)
#define SOP_API
Definition: SOP_API.h:10
void setParmValue(exint idx, const exint &value)
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
fpreal getCookTime() const
Definition: SOP_NodeVerb.h:501
virtual void copyFrom(const SOP_NodeParms *src)
T & x(void)
Definition: UT_Vector4.h:375
UT_StringHolder opGroup(const SOP_NodeVerb::CookParms &cookparms) const
T & y(void)
Definition: UT_Vector2.h:287
static void loadData(UT_IStream &is, UT_Vector2I &v)
void setParmValue(exint idx, const UT_Matrix3D &value)
static void loadData(UT_IStream &is, int64 &v)
GLboolean r
Definition: glcorearb.h:1221
static void loadData(UT_IStream &is, UT_Vector3I &v)
T & w(void)
Definition: UT_Vector4.h:381
static void saveData(std::ostream &os, UT_StringHolder s)
static void saveData(std::ostream &os, bool v)
const OP_Context & context() const
Definition: SOP_NodeVerb.h:109
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
Definition: PRM_Parm.h:88
SYS_FORCE_INLINE bool isstring() const
SYS_FORCE_INLINE void strncpy(const char *src, exint maxlen)
GLenum src
Definition: glcorearb.h:1792