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 <SOP/SOP_GraphProxy.h>
8 
9 #include <OP/OP_Utils.h>
10 #include <PRM/PRM_Parm.h>
11 #include <UT/UT_IStream.h>
12 #include <UT/UT_NTStreamUtil.h>
13 #include <UT/UT_Ramp.h>
14 #include <UT/UT_SharedPtr.h>
15 #include <UT/UT_StringHolder.h>
16 #include <UT/UT_StringStream.h>
17 #include <UT/UT_VectorTypes.h>
18 #include <SYS/SYS_Types.h>
19 
20 using namespace UT::Literal;
21 
22 class DEP_MicroNode;
23 
25 {
26 public:
27  static int version() { return 1; }
28 
30  {
31  myGroup = ""_sh;
32  myAttribname = ""_sh;
33  myTol = 0.001;
34 
35  }
36 
37  explicit SOP_PrimitiveSplitParms(const SOP_PrimitiveSplitParms &) = default;
38 
40 
42  {
43  if (myGroup != src.myGroup) return false;
44  if (myAttribname != src.myAttribname) return false;
45  if (myTol != src.myTol) return false;
46 
47  return true;
48  }
50  {
51  return !operator==(src);
52  }
53 
54 
55 
56  void buildFromOp(const SOP_GraphProxy *graph, exint nodeidx, fpreal time, DEP_MicroNode *depnode)
57  {
58  myGroup = ""_sh;
59  if (true)
60  graph->evalOpParm(myGroup, nodeidx, "group", time, 0);
61  myAttribname = ""_sh;
62  if (true)
63  graph->evalOpParm(myAttribname, nodeidx, "attribname", time, 0);
64  myTol = 0.001;
65  if (true)
66  graph->evalOpParm(myTol, nodeidx, "tol", time, 0);
67 
68  }
69 
70 
71  void loadFromOpSubclass(const LoadParms &loadparms) override
72  {
73  buildFromOp(loadparms.graph(), loadparms.nodeIdx(), loadparms.context().getTime(), loadparms.depnode());
74  }
75 
76 
77  void copyFrom(const SOP_NodeParms *src) override
78  {
79  *this = *((const SOP_PrimitiveSplitParms *)src);
80  }
81 
82  template <typename T>
83  void
84  doGetParmValue(TempIndex idx, TempIndex instance, T &value) const
85  {
86  if (idx.size() < 1)
87  return;
88  UT_ASSERT(idx.size() == instance.size()+1);
89  if (idx.size() != instance.size()+1)
90  return;
91  switch (idx[0])
92  {
93  case 0:
94  coerceValue(value, myGroup);
95  break;
96  case 1:
97  coerceValue(value, myAttribname);
98  break;
99  case 2:
100  coerceValue(value, myTol);
101  break;
102 
103  }
104  }
105 
106  void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override
107  { doGetParmValue(idx, instance, value); }
108  void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override
109  { doGetParmValue(idx, instance, value); }
110  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override
111  { doGetParmValue(idx, instance, value); }
112  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override
113  { doGetParmValue(idx, instance, value); }
114  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector4D &value) const override
115  { doGetParmValue(idx, instance, value); }
116  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override
117  { doGetParmValue(idx, instance, value); }
118  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override
119  { doGetParmValue(idx, instance, value); }
120  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix4D &value) const override
121  { doGetParmValue(idx, instance, value); }
122  void getNestParmValue(TempIndex idx, TempIndex instance, UT_StringHolder &value) const override
123  { doGetParmValue(idx, instance, value); }
124  void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr<UT_Ramp> &value) const override
125  { doGetParmValue(idx, instance, value); }
126  void getNestParmValue(TempIndex idx, TempIndex instance, PRM_DataItemHandle &value) const override
127  { doGetParmValue(idx, instance, value); }
128 
129  template <typename T>
130  void
131  doSetParmValue(TempIndex idx, TempIndex instance, const T &value)
132  {
133  if (idx.size() < 1)
134  return;
135  UT_ASSERT(idx.size() == instance.size()+1);
136  if (idx.size() != instance.size()+1)
137  return;
138  switch (idx[0])
139  {
140  case 0:
141  coerceValue(myGroup, value);
142  break;
143  case 1:
144  coerceValue(myAttribname, value);
145  break;
146  case 2:
147  coerceValue(myTol, value);
148  break;
149 
150  }
151  }
152 
153  void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override
154  { doSetParmValue(idx, instance, value); }
155  void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override
156  { doSetParmValue(idx, instance, value); }
157  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override
158  { doSetParmValue(idx, instance, value); }
159  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector3D &value) override
160  { doSetParmValue(idx, instance, value); }
161  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override
162  { doSetParmValue(idx, instance, value); }
163  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix2D &value) override
164  { doSetParmValue(idx, instance, value); }
165  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix3D &value) override
166  { doSetParmValue(idx, instance, value); }
167  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override
168  { doSetParmValue(idx, instance, value); }
169  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override
170  { doSetParmValue(idx, instance, value); }
171  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr<UT_Ramp> &value) override
172  { doSetParmValue(idx, instance, value); }
173  void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override
174  { doSetParmValue(idx, instance, value); }
175 
176  exint getNestNumParms(TempIndex idx) const override
177  {
178  if (idx.size() == 0)
179  return 3;
180  switch (idx[0])
181  {
182 
183  }
184  // Invalid
185  return 0;
186  }
187 
188  const char *getNestParmName(TempIndex fieldnum) const override
189  {
190  if (fieldnum.size() < 1)
191  return 0;
192  switch (fieldnum[0])
193  {
194  case 0:
195  return "group";
196  case 1:
197  return "attribname";
198  case 2:
199  return "tol";
200 
201  }
202  return 0;
203  }
204 
205  ParmType getNestParmType(TempIndex fieldnum) const override
206  {
207  if (fieldnum.size() < 1)
208  return PARM_UNSUPPORTED;
209  switch (fieldnum[0])
210  {
211  case 0:
212  return PARM_STRING;
213  case 1:
214  return PARM_STRING;
215  case 2:
216  return PARM_FLOAT;
217 
218  }
219  return PARM_UNSUPPORTED;
220  }
221 
222  // Boiler plate to load individual types.
223  static void loadData(UT_IStream &is, int64 &v)
224  { is.bread(&v, 1); }
225  static void loadData(UT_IStream &is, bool &v)
226  { int64 iv; is.bread(&iv, 1); v = iv; }
227  static void loadData(UT_IStream &is, fpreal64 &v)
228  { is.bread<fpreal64>(&v, 1); }
229  static void loadData(UT_IStream &is, UT_Vector2D &v)
230  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1); }
231  static void loadData(UT_IStream &is, UT_Vector3D &v)
232  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
233  is.bread<fpreal64>(&v.z(), 1); }
234  static void loadData(UT_IStream &is, UT_Vector4D &v)
235  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
236  is.bread<fpreal64>(&v.z(), 1); is.bread<fpreal64>(&v.w(), 1); }
237  static void loadData(UT_IStream &is, UT_Matrix2D &v)
238  { for (int r = 0; r < 2; r++) for (int c = 0; c < 2; c++) is.bread<fpreal64>(&v(r, c), 1); }
239  static void loadData(UT_IStream &is, UT_Matrix3D &v)
240  { for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) is.bread<fpreal64>(&v(r, c), 1); }
241  static void loadData(UT_IStream &is, UT_Matrix4D &v)
242  { for (int r = 0; r < 4; r++) for (int c = 0; c < 4; c++) is.bread<fpreal64>(&v(r, c), 1); }
243  static void loadData(UT_IStream &is, UT_Vector2I &v)
244  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1); }
245  static void loadData(UT_IStream &is, UT_Vector3I &v)
246  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
247  is.bread<int64>(&v.z(), 1); }
248  static void loadData(UT_IStream &is, UT_Vector4I &v)
249  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
250  is.bread<int64>(&v.z(), 1); is.bread<int64>(&v.w(), 1); }
252  { is.bread(v); }
254  { UT_StringHolder rampdata;
255  loadData(is, rampdata);
256  if (rampdata.isstring())
257  {
258  v.reset(new UT_Ramp());
259  UT_IStream istr((const char *) rampdata, rampdata.length(), UT_ISTREAM_ASCII);
260  v->load(istr);
261  }
262  else v.reset();
263  }
266  loadData(is, data);
267  if (data.isstring())
268  {
269  // Find the data type.
270  const char *colon = UT_StringWrap(data).findChar(':');
271  if (colon)
272  {
273  int typelen = colon - data.buffer();
275  type.strncpy(data.buffer(), typelen);
276  UT_IStream istr(((const char *) data) + typelen + 1, data.length() - (typelen + 1), UT_ISTREAM_BINARY);
277 
278  v = PRM_DataFactory::parseBinary(type.buffer(), istr);
279  }
280  }
281  else v.reset();
282  }
283 
284  static void saveData(std::ostream &os, int64 v)
285  { UTwrite(os, &v); }
286  static void saveData(std::ostream &os, bool v)
287  { int64 iv = v; UTwrite(os, &iv); }
288  static void saveData(std::ostream &os, fpreal64 v)
289  { UTwrite<fpreal64>(os, &v); }
290  static void saveData(std::ostream &os, UT_Vector2D v)
291  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y()); }
292  static void saveData(std::ostream &os, UT_Vector3D v)
293  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
294  UTwrite<fpreal64>(os, &v.z()); }
295  static void saveData(std::ostream &os, UT_Vector4D v)
296  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
297  UTwrite<fpreal64>(os, &v.z()); UTwrite<fpreal64>(os, &v.w()); }
298  static void saveData(std::ostream &os, UT_Matrix2D v)
300  static void saveData(std::ostream &os, UT_Matrix3D v)
302  static void saveData(std::ostream &os, UT_Matrix4D v)
304  static void saveData(std::ostream &os, UT_StringHolder s)
305  { UT_StringWrap(s).saveBinary(os); }
306  static void saveData(std::ostream &os, UT_SharedPtr<UT_Ramp> s)
308  UT_OStringStream ostr;
309  if (s) s->save(ostr);
310  result = ostr.str();
311  saveData(os, result);
312  }
313  static void saveData(std::ostream &os, PRM_DataItemHandle s)
315  UT_OStringStream ostr;
316  if (s)
317  {
318  ostr << s->getDataTypeToken();
319  ostr << ":";
320  s->saveBinary(ostr);
321  }
322  result = ostr.str();
323  saveData(os, result);
324  }
325 
326 
327  void save(std::ostream &os) const
328  {
329  int32 v = version();
330  UTwrite(os, &v);
331  saveData(os, myGroup);
332  saveData(os, myAttribname);
333  saveData(os, myTol);
334 
335  }
336 
337  bool load(UT_IStream &is)
338  {
339  int32 v;
340  is.bread(&v, 1);
341  if (version() != v)
342  {
343  // Fail incompatible versions
344  return false;
345  }
346  loadData(is, myGroup);
347  loadData(is, myAttribname);
348  loadData(is, myTol);
349 
350  return true;
351  }
352 
353  const UT_StringHolder & getGroup() const { return myGroup; }
354  void setGroup(const UT_StringHolder & val) { myGroup = val; }
356  {
357  SOP_Node *thissop = cookparms.getNode();
358  if (!thissop) return getGroup();
360  OP_Utils::evalOpParm(result, thissop, "group", cookparms.getCookTime(), 0);
361  return result;
362  }
363  const UT_StringHolder & getAttribname() const { return myAttribname; }
364  void setAttribname(const UT_StringHolder & val) { myAttribname = val; }
366  {
367  SOP_Node *thissop = cookparms.getNode();
368  if (!thissop) return getAttribname();
370  OP_Utils::evalOpParm(result, thissop, "attribname", cookparms.getCookTime(), 0);
371  return result;
372  }
373  fpreal64 getTol() const { return myTol; }
374  void setTol(fpreal64 val) { myTol = val; }
375  fpreal64 opTol(const SOP_NodeVerb::CookParms &cookparms) const
376  {
377  SOP_Node *thissop = cookparms.getNode();
378  if (!thissop) return getTol();
380  OP_Utils::evalOpParm(result, thissop, "tol", cookparms.getCookTime(), 0);
381  return result;
382  }
383 
384 private:
385  UT_StringHolder myGroup;
386  UT_StringHolder myAttribname;
387  fpreal64 myTol;
388 
389 };
GLdouble s
Definition: glew.h:1390
static void loadData(UT_IStream &is, bool &v)
exint nodeIdx() const
Definition: SOP_NodeVerb.h:114
void save(std::ostream &os) const
static void loadData(UT_IStream &is, UT_Vector4I &v)
GLenum src
Definition: glew.h:2410
int int32
Definition: SYS_Types.h:39
SOP_Node * getNode() const
Definition: SOP_NodeVerb.h:640
void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override
void getNestParmValue(TempIndex idx, TempIndex instance, PRM_DataItemHandle &value) const override
void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix3D &value) override
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix4D &value) const override
static void loadData(UT_IStream &is, fpreal64 &v)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override
exint bread(int32 *buffer, exint asize=1)
GT_API const UT_StringHolder time
fpreal getTime() const
Definition: OP_Context.h:60
GLuint const GLfloat * val
Definition: glew.h:2794
const char * getNestParmName(TempIndex fieldnum) const override
void buildFromOp(const SOP_GraphProxy *graph, exint nodeidx, fpreal time, DEP_MicroNode *depnode)
static void saveData(std::ostream &os, UT_Matrix3D v)
void setAttribname(const UT_StringHolder &val)
int64 exint
Definition: SYS_Types.h:125
SYS_FORCE_INLINE const char * buffer() const
const SOP_GraphProxy * graph() const
Definition: SOP_NodeVerb.h:113
An output stream object that owns its own string buffer storage.
bool operator==(const SOP_PrimitiveSplitParms &src) const
bool operator!=(const SOP_PrimitiveSplitParms &src) const
void doSetParmValue(TempIndex idx, TempIndex instance, const T &value)
static void loadData(UT_IStream &is, UT_Vector3D &v)
static void loadData(UT_IStream &is, UT_Matrix3D &v)
const GLdouble * v
Definition: glew.h:1391
exint getNestNumParms(TempIndex idx) const override
static PRM_DataItemHandle parseBinary(const char *type, UT_IStream &is)
const UT_WorkBuffer & str()
Returns a read-only reference to the underlying UT_WorkBuffer.
static void loadData(UT_IStream &is, UT_StringHolder &v)
void doGetParmValue(TempIndex idx, TempIndex instance, T &value) const
const UT_StringHolder & getAttribname() const
UT_StringHolder opAttribname(const SOP_NodeVerb::CookParms &cookparms) const
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override
static void saveData(std::ostream &os, UT_Vector3D v)
double fpreal64
Definition: SYS_Types.h:201
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
static void loadData(UT_IStream &is, UT_Vector2D &v)
static void saveData(std::ostream &os, UT_Vector4D v)
static void loadData(UT_IStream &is, UT_Vector4D &v)
SYS_FORCE_INLINE T & y()
Definition: UT_Vector3.h:513
ParmType getNestParmType(TempIndex fieldnum) const override
static void saveData(std::ostream &os, UT_SharedPtr< UT_Ramp > s)
exint length() const
void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr< UT_Ramp > &value) const override
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override
SYS_FORCE_INLINE const char * buffer() const
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:28
static void saveData(std::ostream &os, UT_Matrix2D v)
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override
SYS_FORCE_INLINE T & z()
Definition: UT_Vector3.h:515
void setGroup(const UT_StringHolder &val)
void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override
const GLfloat * c
Definition: glew.h:16296
long long int64
Definition: SYS_Types.h:116
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override
static void saveData(std::ostream &os, fpreal64 v)
static void saveData(std::ostream &os, int64 v)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix2D &value) override
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector4D &value) const override
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override
static void loadData(UT_IStream &is, UT_SharedPtr< UT_Ramp > &v)
fpreal64 opTol(const SOP_NodeVerb::CookParms &cookparms) const
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector3D &value) override
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)
GT_API const UT_StringHolder version
DEP_MicroNode * depnode() const
Definition: SOP_NodeVerb.h:121
void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override
void copyFrom(const SOP_NodeParms *src) override
static void saveData(std::ostream &os, UT_Vector2D v)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_StringHolder &value) const override
fpreal64 fpreal
Definition: SYS_Types.h:277
static void loadData(UT_IStream &is, UT_Matrix4D &v)
const UT_StringHolder & getGroup() const
Utility class for containing a color ramp.
Definition: UT_Ramp.h:84
static void saveData(std::ostream &os, PRM_DataItemHandle s)
GLdouble GLdouble GLdouble r
Definition: glew.h:1406
static void loadData(UT_IStream &is, UT_Matrix2D &v)
#define SOP_API
Definition: SOP_API.h:10
virtual void evalOpParm(int64 &v, NodeIdx node, const char *parmname, fpreal time, DEP_MicroNode *depnode) const =0
SYS_FORCE_INLINE T & x()
Definition: UT_Vector3.h:511
fpreal getCookTime() const
Definition: SOP_NodeVerb.h:654
UT_StringHolder opGroup(const SOP_NodeVerb::CookParms &cookparms) const
GLuint64EXT * result
Definition: glew.h:14007
const char * findChar(int c) const
Definition: UT_String.h:1367
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:135
static void loadData(UT_IStream &is, UT_Vector2I &v)
static void loadData(UT_IStream &is, int64 &v)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override
static void loadData(UT_IStream &is, UT_Vector3I &v)
void loadFromOpSubclass(const LoadParms &loadparms) override
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr< UT_Ramp > &value) override
static void saveData(std::ostream &os, UT_StringHolder s)
static void saveData(std::ostream &os, bool v)
GLsizei const GLfloat * value
Definition: glew.h:1849
const OP_Context & context() const
Definition: SOP_NodeVerb.h:119
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
Definition: PRM_Parm.h:89
SYS_FORCE_INLINE bool isstring() const
SYS_FORCE_INLINE void strncpy(const char *src, exint maxlen)
type
Definition: core.h:528