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