HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SOP_VolumeReduce.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_VolumeReduceEnums
22 {
23  enum class Reduction
24  {
25  MAX = 0,
26  MIN,
27  MAXABS,
28  MINABS,
29  AVERAGE,
30  MEDIAN,
31  SUM,
32  SUMABS,
33  SUMSQUARE,
34  RMS
35  };
36  enum class Scaleby
37  {
38  NONE = 0,
39  LENGTH,
40  AREA,
41  VOLUME
42  };
43  enum class Result
44  {
45  VOLUME = 0,
46  VERTEX,
47  POINT,
48  PRIM,
49  DETAIL
50  };
51 }
52 
53 
55 {
56 public:
57  static int version() { return 1; }
58 
60  {
61  myGroup = ""_sh;
62  myReduction = 0;
63  myPercentile = 50;
64  myScaleby = 0;
65  myResult = 0;
66  myResultattrib = "density"_sh;
67  myResultlvar = ""_sh;
68 
69  }
70 
71  explicit SOP_VolumeReduceParms(const SOP_VolumeReduceParms &) = default;
72 
74 
76  {
77  if (myGroup != src.myGroup) return false;
78  if (myReduction != src.myReduction) return false;
79  if (myPercentile != src.myPercentile) return false;
80  if (myScaleby != src.myScaleby) return false;
81  if (myResult != src.myResult) return false;
82  if (myResultattrib != src.myResultattrib) return false;
83  if (myResultlvar != src.myResultlvar) return false;
84 
85  return true;
86  }
90 
91 
92 
93  void buildFromOp(const OP_Node *node, fpreal time, DEP_MicroNode *depnode)
94  {
95  if (true)
96  OP_Utils::evalOpParm(myGroup, node, "group", time, 0);
97  else myGroup = ""_sh;
98  if (true)
99  OP_Utils::evalOpParm(myReduction, node, "reduction", time, 0);
100  else myReduction = 0;
101  if (true && ( (!(((int64(getReduction())!=5)))) ) )
102  OP_Utils::evalOpParm(myPercentile, node, "percentile", time, 0);
103  else myPercentile = 50;
104  if (true)
105  OP_Utils::evalOpParm(myScaleby, node, "scaleby", time, 0);
106  else myScaleby = 0;
107  if (true)
108  OP_Utils::evalOpParm(myResult, node, "result", time, 0);
109  else myResult = 0;
110  if (true && ( (!(((int64(getResult())==0)))) ) )
111  OP_Utils::evalOpParm(myResultattrib, node, "resultattrib", time, 0);
112  else myResultattrib = "density"_sh;
113  if (true && ( (!(((int64(getResult())==0)))) ) )
114  OP_Utils::evalOpParm(myResultlvar, node, "resultlvar", time, 0);
115  else myResultlvar = ""_sh;
116 
117  }
118 
119 
120  virtual void loadFromOpSubclass(const LoadParms &loadparms)
121  {
122  buildFromOp(loadparms.node(), loadparms.context().getTime(), loadparms.depnode());
123  }
124 
125 
126  virtual void copyFrom(const SOP_NodeParms *src)
127  {
128  *this = *((const SOP_VolumeReduceParms *)src);
129  }
130 
131  template <typename T>
132  void
133  doGetParmValue(exint idx, T &value) const
134  {
135  switch (idx)
136  {
137  case 0:
138  coerceValue(value, myGroup);
139  break;
140  case 1:
141  coerceValue(value, myReduction);
142  break;
143  case 2:
144  coerceValue(value, myPercentile);
145  break;
146  case 3:
147  coerceValue(value, myScaleby);
148  break;
149  case 4:
150  coerceValue(value, myResult);
151  break;
152  case 5:
153  coerceValue(value, myResultattrib);
154  break;
155  case 6:
156  coerceValue(value, myResultlvar);
157  break;
158 
159  }
160  }
161 
162  void getParmValue(exint idx, exint &value) const
163  { doGetParmValue(idx, value); }
164  void getParmValue(exint idx, fpreal &value) const
165  { doGetParmValue(idx, value); }
167  { doGetParmValue(idx, value); }
169  { doGetParmValue(idx, value); }
171  { doGetParmValue(idx, value); }
173  { doGetParmValue(idx, value); }
175  { doGetParmValue(idx, value); }
177  { doGetParmValue(idx, value); }
179  { doGetParmValue(idx, value); }
181  { doGetParmValue(idx, value); }
183  { doGetParmValue(idx, value); }
184 
185  template <typename T>
186  void
187  doSetParmValue(exint idx, const T &value)
188  {
189  switch (idx)
190  {
191  case 0:
192  coerceValue(myGroup, value);
193  break;
194  case 1:
195  coerceValue(myReduction, value);
196  break;
197  case 2:
198  coerceValue(myPercentile, value);
199  break;
200  case 3:
201  coerceValue(myScaleby, value);
202  break;
203  case 4:
204  coerceValue(myResult, value);
205  break;
206  case 5:
207  coerceValue(myResultattrib, value);
208  break;
209  case 6:
210  coerceValue(myResultlvar, value);
211  break;
212 
213  }
214  }
215 
216  void setParmValue(exint idx, const exint &value)
217  { doSetParmValue(idx, value); }
218  void setParmValue(exint idx, const fpreal &value)
219  { doSetParmValue(idx, value); }
220  void setParmValue(exint idx, const UT_Vector2D &value)
221  { doSetParmValue(idx, value); }
222  void setParmValue(exint idx, const UT_Vector3D &value)
223  { doSetParmValue(idx, value); }
224  void setParmValue(exint idx, const UT_Vector4D &value)
225  { doSetParmValue(idx, value); }
226  void setParmValue(exint idx, const UT_Matrix2D &value)
227  { doSetParmValue(idx, value); }
228  void setParmValue(exint idx, const UT_Matrix3D &value)
229  { doSetParmValue(idx, value); }
230  void setParmValue(exint idx, const UT_Matrix4D &value)
231  { doSetParmValue(idx, value); }
233  { doSetParmValue(idx, value); }
235  { doSetParmValue(idx, value); }
237  { doSetParmValue(idx, value); }
238 
239  virtual exint getNumParms() const
240  {
241  return 7;
242  }
243 
244  virtual const char *getParmName(exint fieldnum) const
245  {
246  switch (fieldnum)
247  {
248  case 0:
249  return "group";
250  case 1:
251  return "reduction";
252  case 2:
253  return "percentile";
254  case 3:
255  return "scaleby";
256  case 4:
257  return "result";
258  case 5:
259  return "resultattrib";
260  case 6:
261  return "resultlvar";
262 
263  }
264  return 0;
265  }
266 
267  virtual ParmType getParmType(exint fieldnum) const
268  {
269  switch (fieldnum)
270  {
271  case 0:
272  return PARM_STRING;
273  case 1:
274  return PARM_INTEGER;
275  case 2:
276  return PARM_FLOAT;
277  case 3:
278  return PARM_INTEGER;
279  case 4:
280  return PARM_INTEGER;
281  case 5:
282  return PARM_STRING;
283  case 6:
284  return PARM_STRING;
285 
286  }
287  return PARM_UNSUPPORTED;
288  }
289 
290  // Boiler plate to load individual types.
291  static void loadData(UT_IStream &is, int64 &v)
292  { is.bread(&v, 1); }
293  static void loadData(UT_IStream &is, bool &v)
294  { int64 iv; is.bread(&iv, 1); v = iv; }
295  static void loadData(UT_IStream &is, fpreal64 &v)
296  { is.bread<fpreal64>(&v, 1); }
297  static void loadData(UT_IStream &is, UT_Vector2D &v)
298  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1); }
299  static void loadData(UT_IStream &is, UT_Vector3D &v)
300  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
301  is.bread<fpreal64>(&v.z(), 1); }
302  static void loadData(UT_IStream &is, UT_Vector4D &v)
303  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
304  is.bread<fpreal64>(&v.z(), 1); is.bread<fpreal64>(&v.w(), 1); }
305  static void loadData(UT_IStream &is, UT_Matrix2D &v)
306  { for (int r = 0; r < 2; r++) for (int c = 0; c < 2; c++) is.bread<fpreal64>(&v(r, c), 1); }
307  static void loadData(UT_IStream &is, UT_Matrix3D &v)
308  { for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) is.bread<fpreal64>(&v(r, c), 1); }
309  static void loadData(UT_IStream &is, UT_Matrix4D &v)
310  { for (int r = 0; r < 4; r++) for (int c = 0; c < 4; c++) is.bread<fpreal64>(&v(r, c), 1); }
311  static void loadData(UT_IStream &is, UT_Vector2I &v)
312  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1); }
313  static void loadData(UT_IStream &is, UT_Vector3I &v)
314  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
315  is.bread<int64>(&v.z(), 1); }
316  static void loadData(UT_IStream &is, UT_Vector4I &v)
317  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
318  is.bread<int64>(&v.z(), 1); is.bread<int64>(&v.w(), 1); }
320  { is.bread(v); }
322  { UT_StringHolder rampdata;
323  loadData(is, rampdata);
324  if (rampdata.isstring())
325  {
326  v.reset(new UT_Ramp());
327  UT_IStream istr((const char *) rampdata, rampdata.length(), UT_ISTREAM_ASCII);
328  v->load(istr);
329  }
330  else v.reset();
331  }
334  loadData(is, data);
335  if (data.isstring())
336  {
337  // Find the data type.
338  char *colon = UT_StringWrap(data).findChar(':');
339  if (colon)
340  {
341  int typelen = colon - data.buffer();
343  type.strncpy(data.buffer(), typelen);
344  UT_IStream istr(((const char *) data) + typelen + 1, data.length() - (typelen + 1), UT_ISTREAM_BINARY);
345 
346  v = PRM_DataFactory::parseBinary(type.buffer(), istr);
347  }
348  }
349  else v.reset();
350  }
351 
352  static void saveData(std::ostream &os, int64 v)
353  { UTwrite(os, &v); }
354  static void saveData(std::ostream &os, bool v)
355  { int64 iv = v; UTwrite(os, &iv); }
356  static void saveData(std::ostream &os, fpreal64 v)
357  { UTwrite<fpreal64>(os, &v); }
358  static void saveData(std::ostream &os, UT_Vector2D v)
359  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y()); }
360  static void saveData(std::ostream &os, UT_Vector3D v)
361  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
362  UTwrite<fpreal64>(os, &v.z()); }
363  static void saveData(std::ostream &os, UT_Vector4D v)
364  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
365  UTwrite<fpreal64>(os, &v.z()); UTwrite<fpreal64>(os, &v.w()); }
366  static void saveData(std::ostream &os, UT_Matrix2D v)
368  static void saveData(std::ostream &os, UT_Matrix3D v)
370  static void saveData(std::ostream &os, UT_Matrix4D v)
372  static void saveData(std::ostream &os, UT_StringHolder s)
373  { UT_StringWrap(s).saveBinary(os); }
374  static void saveData(std::ostream &os, UT_SharedPtr<UT_Ramp> s)
375  { UT_StringHolder result;
376  UT_OStringStream ostr;
377  if (s) s->save(ostr);
378  result = ostr.str();
379  saveData(os, result);
380  }
381  static void saveData(std::ostream &os, PRM_DataItemHandle s)
382  { UT_StringHolder result;
383  UT_OStringStream ostr;
384  if (s)
385  {
386  ostr << s->getDataTypeToken();
387  ostr << ":";
388  s->saveBinary(ostr);
389  }
390  result = ostr.str();
391  saveData(os, result);
392  }
393 
394 
395  void save(std::ostream &os) const
396  {
397  int32 v = version();
398  UTwrite(os, &v);
399  saveData(os, myGroup);
400  saveData(os, myReduction);
401  saveData(os, myPercentile);
402  saveData(os, myScaleby);
403  saveData(os, myResult);
404  saveData(os, myResultattrib);
405  saveData(os, myResultlvar);
406 
407  }
408 
409  bool load(UT_IStream &is)
410  {
411  int32 v;
412  is.bread(&v, 1);
413  if (version() != v)
414  {
415  // Fail incompatible versions
416  return false;
417  }
418  loadData(is, myGroup);
419  loadData(is, myReduction);
420  loadData(is, myPercentile);
421  loadData(is, myScaleby);
422  loadData(is, myResult);
423  loadData(is, myResultattrib);
424  loadData(is, myResultlvar);
425 
426  return true;
427  }
428 
429  const UT_StringHolder & getGroup() const { return myGroup; }
430  void setGroup(const UT_StringHolder & val) { myGroup = val; }
432  {
433  SOP_Node *thissop = cookparms.getNode();
434  if (!thissop) return getGroup();
435  UT_StringHolder result;
436  OP_Utils::evalOpParm(result, thissop, "group", cookparms.getCookTime(), 0);
437  return result;
438  }
439  Reduction getReduction() const { return Reduction(myReduction); }
440  void setReduction(Reduction val) { myReduction = int64(val); }
442  {
443  SOP_Node *thissop = cookparms.getNode();
444  if (!thissop) return getReduction();
445  int64 result;
446  OP_Utils::evalOpParm(result, thissop, "reduction", cookparms.getCookTime(), 0);
447  return Reduction(result);
448  }
449  fpreal64 getPercentile() const { return myPercentile; }
450  void setPercentile(fpreal64 val) { myPercentile = val; }
452  {
453  SOP_Node *thissop = cookparms.getNode();
454  if (!thissop) return getPercentile();
455  fpreal64 result;
456  OP_Utils::evalOpParm(result, thissop, "percentile", cookparms.getCookTime(), 0);
457  return result;
458  }
459  Scaleby getScaleby() const { return Scaleby(myScaleby); }
460  void setScaleby(Scaleby val) { myScaleby = int64(val); }
461  Scaleby opScaleby(const SOP_NodeVerb::CookParms &cookparms) const
462  {
463  SOP_Node *thissop = cookparms.getNode();
464  if (!thissop) return getScaleby();
465  int64 result;
466  OP_Utils::evalOpParm(result, thissop, "scaleby", cookparms.getCookTime(), 0);
467  return Scaleby(result);
468  }
469  Result getResult() const { return Result(myResult); }
470  void setResult(Result val) { myResult = int64(val); }
471  Result opResult(const SOP_NodeVerb::CookParms &cookparms) const
472  {
473  SOP_Node *thissop = cookparms.getNode();
474  if (!thissop) return getResult();
475  int64 result;
476  OP_Utils::evalOpParm(result, thissop, "result", cookparms.getCookTime(), 0);
477  return Result(result);
478  }
479  const UT_StringHolder & getResultattrib() const { return myResultattrib; }
480  void setResultattrib(const UT_StringHolder & val) { myResultattrib = val; }
482  {
483  SOP_Node *thissop = cookparms.getNode();
484  if (!thissop) return getResultattrib();
485  UT_StringHolder result;
486  OP_Utils::evalOpParm(result, thissop, "resultattrib", cookparms.getCookTime(), 0);
487  return result;
488  }
489  const UT_StringHolder & getResultlvar() const { return myResultlvar; }
490  void setResultlvar(const UT_StringHolder & val) { myResultlvar = val; }
492  {
493  SOP_Node *thissop = cookparms.getNode();
494  if (!thissop) return getResultlvar();
495  UT_StringHolder result;
496  OP_Utils::evalOpParm(result, thissop, "resultlvar", cookparms.getCookTime(), 0);
497  return result;
498  }
499 
500 private:
501  UT_StringHolder myGroup;
502  int64 myReduction;
503  fpreal64 myPercentile;
504  int64 myScaleby;
505  int64 myResult;
506  UT_StringHolder myResultattrib;
507  UT_StringHolder myResultlvar;
508 
509 };
void setParmValue(exint idx, const UT_Matrix3D &value)
virtual exint getNumParms() const
void getParmValue(exint idx, UT_StringHolder &value) const
virtual ParmType getParmType(exint fieldnum) const
static void loadData(UT_IStream &is, UT_StringHolder &v)
bool operator==(const SOP_VolumeReduceParms &src) const
static void saveData(std::ostream &os, UT_Vector2D v)
void getParmValue(exint idx, UT_Vector4D &value) const
void getParmValue(exint idx, UT_Matrix3D &value) const
SOP_Node * getNode() const
Definition: SOP_NodeVerb.h:492
T & z(void)
Definition: UT_Vector4.h:372
void setParmValue(exint idx, const UT_Vector4D &value)
static void loadData(UT_IStream &is, UT_Vector3I &v)
const UT_StringHolder & getGroup() const
void getParmValue(exint idx, fpreal &value) const
exint bread(int32 *buffer, exint asize=1)
fpreal getTime() const
Definition: OP_Context.h:34
const GLdouble * v
Definition: glcorearb.h:836
void getParmValue(exint idx, UT_Matrix2D &value) const
static void loadData(UT_IStream &is, UT_SharedPtr< UT_Ramp > &v)
void setReduction(Reduction val)
const UT_StringHolder & getResultattrib() const
UT_StringHolder opResultattrib(const SOP_NodeVerb::CookParms &cookparms) const
void setParmValue(exint idx, const PRM_DataItemHandle &value)
static void loadData(UT_IStream &is, UT_Vector2I &v)
static void saveData(std::ostream &os, bool v)
T & x(void)
Definition: UT_Vector2.h:284
void doGetParmValue(exint idx, T &value) const
const UT_StringHolder & getResultlvar() const
An output stream object that owns its own string buffer storage.
void getParmValue(exint idx, UT_Matrix4D &value) const
const UT_WorkBuffer & str() const
Returns a read-only reference to the underlying UT_WorkBuffer.
static void saveData(std::ostream &os, UT_StringHolder s)
SYS_FORCE_INLINE T & x(void)
Definition: UT_Vector3.h:581
virtual void loadFromOpSubclass(const LoadParms &loadparms)
static PRM_DataItemHandle parseBinary(const char *type, UT_IStream &is)
void setParmValue(exint idx, const UT_Vector2D &value)
bool load(UT_IStream &is)
SYS_FORCE_INLINE T & z(void)
Definition: UT_Vector3.h:585
void setParmValue(exint idx, const UT_StringHolder &value)
long long int64
Definition: SYS_Types.h:100
static void saveData(std::ostream &os, UT_Matrix3D v)
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
UT_StringHolder opResultlvar(const SOP_NodeVerb::CookParms &cookparms) const
static void loadData(UT_IStream &is, UT_Vector4I &v)
int64 exint
Definition: SYS_Types.h:109
fpreal64 opPercentile(const SOP_NodeVerb::CookParms &cookparms) const
const OP_Node * node() const
Definition: SOP_NodeVerb.h:104
double fpreal64
Definition: SYS_Types.h:185
void setParmValue(exint idx, const UT_Vector3D &value)
static void loadData(UT_IStream &is, UT_Vector4D &v)
static void saveData(std::ostream &os, int64 v)
void save(std::ostream &os) const
virtual const char * getParmName(exint fieldnum) const
static void loadData(UT_IStream &is, UT_Matrix4D &v)
UT_StringHolder opGroup(const SOP_NodeVerb::CookParms &cookparms) const
void setParmValue(exint idx, const exint &value)
void buildFromOp(const OP_Node *node, fpreal time, DEP_MicroNode *depnode)
void getParmValue(exint idx, UT_SharedPtr< UT_Ramp > &value) const
Reduction getReduction() const
Reduction opReduction(const SOP_NodeVerb::CookParms &cookparms) const
GLboolean * data
Definition: glcorearb.h:130
int int32
Definition: SYS_Types.h:28
T & y(void)
Definition: UT_Vector4.h:370
void saveBinary(std::ostream &os) const
Save string to binary stream.
Definition: UT_String.h:294
void getParmValue(exint idx, UT_Vector3D &value) const
static void saveData(std::ostream &os, UT_Vector4D v)
DEP_MicroNode * depnode() const
Definition: SOP_NodeVerb.h:111
Scaleby opScaleby(const SOP_NodeVerb::CookParms &cookparms) const
void setPercentile(fpreal64 val)
static void saveData(std::ostream &os, UT_Vector3D v)
static void loadData(UT_IStream &is, UT_Matrix2D &v)
void setParmValue(exint idx, const UT_SharedPtr< UT_Ramp > &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:263
void strncpy(const char *src, exint maxlen)
void getParmValue(exint idx, PRM_DataItemHandle &value) const
virtual void copyFrom(const SOP_NodeParms *src)
void setParmValue(exint idx, const UT_Matrix4D &value)
static void loadData(UT_IStream &is, int64 &v)
static void saveData(std::ostream &os, PRM_DataItemHandle s)
Utility class for containing a color ramp.
Definition: UT_Ramp.h:84
static void saveData(std::ostream &os, UT_SharedPtr< UT_Ramp > s)
GLuint GLfloat * val
Definition: glcorearb.h:1607
void getParmValue(exint idx, exint &value) const
#define SOP_API
Definition: SOP_API.h:10
const char * buffer() const
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
fpreal getCookTime() const
Definition: SOP_NodeVerb.h:499
static void loadData(UT_IStream &is, UT_Matrix3D &v)
T & x(void)
Definition: UT_Vector4.h:368
static void saveData(std::ostream &os, UT_Matrix4D v)
void setResultlvar(const UT_StringHolder &val)
T & y(void)
Definition: UT_Vector2.h:286
fpreal64 getPercentile() const
void doSetParmValue(exint idx, const T &value)
void setGroup(const UT_StringHolder &val)
static void saveData(std::ostream &os, fpreal64 v)
static void loadData(UT_IStream &is, PRM_DataItemHandle &v)
static void loadData(UT_IStream &is, UT_Vector3D &v)
GLboolean r
Definition: glcorearb.h:1221
static void loadData(UT_IStream &is, UT_Vector2D &v)
T & w(void)
Definition: UT_Vector4.h:374
static void saveData(std::ostream &os, UT_Matrix2D v)
void getParmValue(exint idx, UT_Vector2D &value) const
void setResultattrib(const UT_StringHolder &val)
const OP_Context & context() const
Definition: SOP_NodeVerb.h:109
void setParmValue(exint idx, const fpreal &value)
static void loadData(UT_IStream &is, fpreal64 &v)
SYS_FORCE_INLINE bool isstring() const
void setParmValue(exint idx, const UT_Matrix2D &value)
static void loadData(UT_IStream &is, bool &v)
GLenum src
Definition: glcorearb.h:1792
Result opResult(const SOP_NodeVerb::CookParms &cookparms) const