HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_Cluster.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  struct Controls
29  {
32 
33 
35  {
36  control_attrib = "P"_UTsh;
37  control_weight = 1;
38 
39  }
40 
41  bool operator==(const Controls &src) const
42  {
43  if (control_attrib != src.control_attrib) return false;
44  if (control_weight != src.control_weight) return false;
45 
46  return true;
47  }
48  bool operator!=(const Controls &src) const
49  {
50  return !operator==(src);
51  }
52 
53  };
54 
56  {
58 
59  buf.strcat("[ ");
60  for (int i = 0; i < list.entries(); i++)
61  {
62  if (i)
63  buf.strcat(", ");
64  buf.strcat("( ");
65  buf.append("");
66  { UT_String tmp; tmp = UT_StringWrap(list(i).control_attrib).makeQuotedString('"'); buf.strcat(tmp); }
67  buf.append(", ");
68  buf.appendSprintf("%f", (list(i).control_weight));
69 
70  buf.strcat(" )");
71  }
72  buf.strcat(" ]");
73 
75  return result;
76  }
77 
79  {
80  myNumClusters = 10;
81  myClusterAttrib = "cluster"_UTsh;
82  myOutputCenter = false;
83  myControls.setSize(1);
84  myIterations = 50;
85  myRandomSeed = 0;
86  myThresholdAttrib = ""_UTsh;
87  myThresholdWeight = 10;
88  myInitialThreshold = 1;
89  myFinalThreshold = 0.25;
90  myUseLInf = false;
91  myKMeanPP = true;
92 
93  }
94 
95  explicit SOP_ClusterParms(const SOP_ClusterParms &) = default;
96  SOP_ClusterParms &operator=(const SOP_ClusterParms &) = default;
97  SOP_ClusterParms(SOP_ClusterParms &&) noexcept = default;
98  SOP_ClusterParms &operator=(SOP_ClusterParms &&) noexcept = default;
99 
100  ~SOP_ClusterParms() override {}
101 
102  bool operator==(const SOP_ClusterParms &src) const
103  {
104  if (myNumClusters != src.myNumClusters) return false;
105  if (myClusterAttrib != src.myClusterAttrib) return false;
106  if (myOutputCenter != src.myOutputCenter) return false;
107  if (myControls != src.myControls) return false;
108  if (myIterations != src.myIterations) return false;
109  if (myRandomSeed != src.myRandomSeed) return false;
110  if (myThresholdAttrib != src.myThresholdAttrib) return false;
111  if (myThresholdWeight != src.myThresholdWeight) return false;
112  if (myInitialThreshold != src.myInitialThreshold) return false;
113  if (myFinalThreshold != src.myFinalThreshold) return false;
114  if (myUseLInf != src.myUseLInf) return false;
115  if (myKMeanPP != src.myKMeanPP) return false;
116 
117  return true;
118  }
119  bool operator!=(const SOP_ClusterParms &src) const
120  {
121  return !operator==(src);
122  }
123 
124 
125 
126  void buildFromOp(const OP_GraphProxy *graph, exint nodeidx, fpreal time, DEP_MicroNode *depnode)
127  {
128  myNumClusters = 10;
129  if (true && ( (true&&!((((graph->getInput(nodeidx,1)>=0)==1)))) ) )
130  graph->evalOpParm(myNumClusters, nodeidx, "num_clusters", time, 0);
131  myClusterAttrib = "cluster"_UTsh;
132  if (true)
133  graph->evalOpParm(myClusterAttrib, nodeidx, "cluster_attrib", time, 0);
134  myOutputCenter = false;
135  if (true && ( (true&&!((((graph->getInput(nodeidx,1)>=0)==1)))) ) )
136  graph->evalOpParm(myOutputCenter, nodeidx, "output_center", time, 0);
137  if (true)
138  {
139  int64 length = 0;
140  graph->evalOpParm(length, nodeidx, "num_controls", time, 0);
141  if (length < 0) length = 0;
142  myControls.setSize(length);
143  for (exint i = 0; i < length; i++)
144  {
145  int parmidx[1];
146  int offsets[1];
147  parmidx[0] = i+1;
148  offsets[0] = 1;
149  auto && _curentry = myControls(i);
150  (void) _curentry;
151  _curentry.control_attrib = "P"_UTsh;
152  if (true)
153  graph->evalOpParmInst(_curentry.control_attrib, nodeidx, "control_attrib#", parmidx, offsets, time, 0, 2-1);
154  _curentry.control_weight = 1;
155  if (true)
156  graph->evalOpParmInst(_curentry.control_weight, nodeidx, "control_weight#", parmidx, offsets, time, 0, 2-1);
157 
158  }
159  }
160  else
161  myControls.clear();
162  myIterations = 50;
163  if (true && ( (true&&!((((graph->getInput(nodeidx,1)>=0)==1)))) ) )
164  graph->evalOpParm(myIterations, nodeidx, "iterations", time, 0);
165  myRandomSeed = 0;
166  if (true && ( (true&&!((((graph->getInput(nodeidx,1)>=0)==1)))) ) )
167  graph->evalOpParm(myRandomSeed, nodeidx, "random_seed", time, 0);
168  myThresholdAttrib = ""_UTsh;
169  if (true)
170  graph->evalOpParm(myThresholdAttrib, nodeidx, "threshold_attrib", time, 0);
171  myThresholdWeight = 10;
172  if (true && ( (true&&!(((getThresholdAttrib()=="")))) ) )
173  graph->evalOpParm(myThresholdWeight, nodeidx, "threshold_weight", time, 0);
174  myInitialThreshold = 1;
175  if (true && ( (true&&!(((getThresholdAttrib()=="")))) ) )
176  graph->evalOpParm(myInitialThreshold, nodeidx, "initial_threshold", time, 0);
177  myFinalThreshold = 0.25;
178  if (true && ( (true&&!(((getThresholdAttrib()=="")))) ) )
179  graph->evalOpParm(myFinalThreshold, nodeidx, "final_threshold", time, 0);
180  myUseLInf = false;
181  if (true)
182  graph->evalOpParm(myUseLInf, nodeidx, "use_linf", time, 0);
183  myKMeanPP = true;
184  if (true && ( (true&&!((((graph->getInput(nodeidx,1)>=0)==1)))) ) )
185  graph->evalOpParm(myKMeanPP, nodeidx, "kmeanpp", time, 0);
186 
187  }
188 
189 
190  void loadFromOpSubclass(const LoadParms &loadparms) override
191  {
192  buildFromOp(loadparms.graph(), loadparms.nodeIdx(), loadparms.context().getTime(), loadparms.depnode());
193  }
194 
195 
196  void copyFrom(const OP_NodeParms *src) override
197  {
198  *this = *((const SOP_ClusterParms *)src);
199  }
200 
201  template <typename T>
202  void
203  doGetParmValue(TempIndex idx, TempIndex instance, T &value) const
204  {
205  if (idx.size() < 1)
206  return;
207  UT_ASSERT(idx.size() == instance.size()+1);
208  if (idx.size() != instance.size()+1)
209  return;
210  switch (idx[0])
211  {
212  case 0:
213  coerceValue(value, myNumClusters);
214  break;
215  case 1:
216  coerceValue(value, myClusterAttrib);
217  break;
218  case 2:
219  coerceValue(value, myOutputCenter);
220  break;
221  case 3:
222  if (idx.size() == 1)
223  coerceValue(value, myControls.entries());
224  else if (instance[0] < myControls.entries())
225  {
226  auto && _data = myControls(instance[0]);
227  switch (idx[1])
228  {
229  case 0:
230  coerceValue(value, _data.control_attrib);
231  break;
232  case 1:
233  coerceValue(value, _data.control_weight);
234  break;
235 
236  }
237  }
238  break;
239  case 4:
240  coerceValue(value, myIterations);
241  break;
242  case 5:
243  coerceValue(value, myRandomSeed);
244  break;
245  case 6:
246  coerceValue(value, myThresholdAttrib);
247  break;
248  case 7:
249  coerceValue(value, myThresholdWeight);
250  break;
251  case 8:
252  coerceValue(value, myInitialThreshold);
253  break;
254  case 9:
255  coerceValue(value, myFinalThreshold);
256  break;
257  case 10:
258  coerceValue(value, myUseLInf);
259  break;
260  case 11:
261  coerceValue(value, myKMeanPP);
262  break;
263 
264  }
265  }
266 
267  bool isParmColorRamp(exint idx) const override
268  {
269  switch (idx)
270  {
271 
272  }
273  return false;
274  }
275 
276  void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override
277  { doGetParmValue(idx, instance, value); }
278  void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override
279  { doGetParmValue(idx, instance, value); }
280  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override
281  { doGetParmValue(idx, instance, value); }
282  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override
283  { doGetParmValue(idx, instance, value); }
284  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector4D &value) const override
285  { doGetParmValue(idx, instance, value); }
286  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override
287  { doGetParmValue(idx, instance, value); }
288  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override
289  { doGetParmValue(idx, instance, value); }
290  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix4D &value) const override
291  { doGetParmValue(idx, instance, value); }
292  void getNestParmValue(TempIndex idx, TempIndex instance, UT_StringHolder &value) const override
293  { doGetParmValue(idx, instance, value); }
294  void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr<UT_Ramp> &value) const override
295  { doGetParmValue(idx, instance, value); }
296  void getNestParmValue(TempIndex idx, TempIndex instance, PRM_DataItemHandle &value) const override
297  { doGetParmValue(idx, instance, value); }
298 
299  template <typename T>
300  void
301  doSetParmValue(TempIndex idx, TempIndex instance, const T &value)
302  {
303  if (idx.size() < 1)
304  return;
305  UT_ASSERT(idx.size() == instance.size()+1);
306  if (idx.size() != instance.size()+1)
307  return;
308  switch (idx[0])
309  {
310  case 0:
311  coerceValue(myNumClusters, clampMinValue(1, ( value ) ));
312  break;
313  case 1:
314  coerceValue(myClusterAttrib, ( ( value ) ));
315  break;
316  case 2:
317  coerceValue(myOutputCenter, ( ( value ) ));
318  break;
319  case 3:
320  if (idx.size() == 1)
321  {
322  exint newsize;
323  coerceValue(newsize, value);
324  if (newsize < 0) newsize = 0;
325  myControls.setSize(newsize);
326  }
327  else
328  {
329  if (instance[0] < 0)
330  return;
331  myControls.setSizeIfNeeded(instance[0]+1);
332  auto && _data = myControls(instance[0]);
333  switch (idx[1])
334  {
335  case 0:
336  coerceValue(_data.control_attrib, value);
337  break;
338  case 1:
339  coerceValue(_data.control_weight, value);
340  break;
341 
342  }
343  }
344  break;
345  case 4:
346  coerceValue(myIterations, clampMinValue(1, ( value ) ));
347  break;
348  case 5:
349  coerceValue(myRandomSeed, ( ( value ) ));
350  break;
351  case 6:
352  coerceValue(myThresholdAttrib, ( ( value ) ));
353  break;
354  case 7:
355  coerceValue(myThresholdWeight, clampMinValue(0, ( value ) ));
356  break;
357  case 8:
358  coerceValue(myInitialThreshold, clampMinValue(0, ( value ) ));
359  break;
360  case 9:
361  coerceValue(myFinalThreshold, clampMinValue(0, ( value ) ));
362  break;
363  case 10:
364  coerceValue(myUseLInf, ( ( value ) ));
365  break;
366  case 11:
367  coerceValue(myKMeanPP, ( ( value ) ));
368  break;
369 
370  }
371  }
372 
373  void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override
374  { doSetParmValue(idx, instance, value); }
375  void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override
376  { doSetParmValue(idx, instance, value); }
377  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override
378  { doSetParmValue(idx, instance, value); }
379  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector3D &value) override
380  { doSetParmValue(idx, instance, value); }
381  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override
382  { doSetParmValue(idx, instance, value); }
383  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix2D &value) override
384  { doSetParmValue(idx, instance, value); }
385  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix3D &value) override
386  { doSetParmValue(idx, instance, value); }
387  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override
388  { doSetParmValue(idx, instance, value); }
389  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override
390  { doSetParmValue(idx, instance, value); }
391  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr<UT_Ramp> &value) override
392  { doSetParmValue(idx, instance, value); }
393  void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override
394  { doSetParmValue(idx, instance, value); }
395 
396  exint getNestNumParms(TempIndex idx) const override
397  {
398  if (idx.size() == 0)
399  return 12;
400  switch (idx[0])
401  {
402  case 3:
403  return 2;
404 
405  }
406  // Invalid
407  return 0;
408  }
409 
410  const char *getNestParmName(TempIndex fieldnum) const override
411  {
412  if (fieldnum.size() < 1)
413  return 0;
414  switch (fieldnum[0])
415  {
416  case 0:
417  return "num_clusters";
418  case 1:
419  return "cluster_attrib";
420  case 2:
421  return "output_center";
422  case 3:
423  if (fieldnum.size() == 1)
424  return "num_controls";
425  switch (fieldnum[1])
426  {
427  case 0:
428  return "control_attrib#";
429  case 1:
430  return "control_weight#";
431 
432  }
433  return 0;
434  case 4:
435  return "iterations";
436  case 5:
437  return "random_seed";
438  case 6:
439  return "threshold_attrib";
440  case 7:
441  return "threshold_weight";
442  case 8:
443  return "initial_threshold";
444  case 9:
445  return "final_threshold";
446  case 10:
447  return "use_linf";
448  case 11:
449  return "kmeanpp";
450 
451  }
452  return 0;
453  }
454 
455  ParmType getNestParmType(TempIndex fieldnum) const override
456  {
457  if (fieldnum.size() < 1)
458  return PARM_UNSUPPORTED;
459  switch (fieldnum[0])
460  {
461  case 0:
462  return PARM_INTEGER;
463  case 1:
464  return PARM_STRING;
465  case 2:
466  return PARM_INTEGER;
467  case 3:
468  if (fieldnum.size() == 1)
469  return PARM_MULTIPARM;
470  switch (fieldnum[1])
471  {
472  case 0:
473  return PARM_STRING;
474  case 1:
475  return PARM_FLOAT;
476 
477  }
478  return PARM_UNSUPPORTED;
479  case 4:
480  return PARM_INTEGER;
481  case 5:
482  return PARM_INTEGER;
483  case 6:
484  return PARM_STRING;
485  case 7:
486  return PARM_FLOAT;
487  case 8:
488  return PARM_FLOAT;
489  case 9:
490  return PARM_FLOAT;
491  case 10:
492  return PARM_INTEGER;
493  case 11:
494  return PARM_INTEGER;
495 
496  }
497  return PARM_UNSUPPORTED;
498  }
499 
500  // Boiler plate to load individual types.
501  static void loadData(UT_IStream &is, int64 &v)
502  { is.bread(&v, 1); }
503  static void loadData(UT_IStream &is, bool &v)
504  { int64 iv; is.bread(&iv, 1); v = iv; }
505  static void loadData(UT_IStream &is, fpreal64 &v)
506  { is.bread<fpreal64>(&v, 1); }
507  static void loadData(UT_IStream &is, UT_Vector2D &v)
508  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1); }
509  static void loadData(UT_IStream &is, UT_Vector3D &v)
510  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
511  is.bread<fpreal64>(&v.z(), 1); }
512  static void loadData(UT_IStream &is, UT_Vector4D &v)
513  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
514  is.bread<fpreal64>(&v.z(), 1); is.bread<fpreal64>(&v.w(), 1); }
515  static void loadData(UT_IStream &is, UT_Matrix2D &v)
516  { for (int r = 0; r < 2; r++) for (int c = 0; c < 2; c++) is.bread<fpreal64>(&v(r, c), 1); }
517  static void loadData(UT_IStream &is, UT_Matrix3D &v)
518  { for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) is.bread<fpreal64>(&v(r, c), 1); }
519  static void loadData(UT_IStream &is, UT_Matrix4D &v)
520  { for (int r = 0; r < 4; r++) for (int c = 0; c < 4; c++) is.bread<fpreal64>(&v(r, c), 1); }
521  static void loadData(UT_IStream &is, UT_Vector2I &v)
522  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1); }
523  static void loadData(UT_IStream &is, UT_Vector3I &v)
524  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
525  is.bread<int64>(&v.z(), 1); }
526  static void loadData(UT_IStream &is, UT_Vector4I &v)
527  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
528  is.bread<int64>(&v.z(), 1); is.bread<int64>(&v.w(), 1); }
530  { is.bread(v); }
532  { UT_StringHolder rampdata;
533  loadData(is, rampdata);
534  if (rampdata.isstring())
535  {
536  v.reset(new UT_Ramp());
537  UT_IStream istr((const char *) rampdata, rampdata.length(), UT_ISTREAM_ASCII);
538  v->load(istr);
539  }
540  else v.reset();
541  }
544  loadData(is, data);
545  if (data.isstring())
546  {
547  // Find the data type.
548  const char *colon = UT_StringWrap(data).findChar(':');
549  if (colon)
550  {
551  int typelen = colon - data.buffer();
553  type.strncpy(data.buffer(), typelen);
554  UT_IStream istr(((const char *) data) + typelen + 1, data.length() - (typelen + 1), UT_ISTREAM_BINARY);
555 
556  v = PRM_DataFactory::parseBinary(type.buffer(), istr);
557  }
558  }
559  else v.reset();
560  }
561 
562  static void saveData(std::ostream &os, int64 v)
563  { UTwrite(os, &v); }
564  static void saveData(std::ostream &os, bool v)
565  { int64 iv = v; UTwrite(os, &iv); }
566  static void saveData(std::ostream &os, fpreal64 v)
567  { UTwrite<fpreal64>(os, &v); }
568  static void saveData(std::ostream &os, UT_Vector2D v)
569  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y()); }
570  static void saveData(std::ostream &os, UT_Vector3D v)
571  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
572  UTwrite<fpreal64>(os, &v.z()); }
573  static void saveData(std::ostream &os, UT_Vector4D v)
574  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
575  UTwrite<fpreal64>(os, &v.z()); UTwrite<fpreal64>(os, &v.w()); }
576  static void saveData(std::ostream &os, UT_Matrix2D v)
578  static void saveData(std::ostream &os, UT_Matrix3D v)
580  static void saveData(std::ostream &os, UT_Matrix4D v)
582  static void saveData(std::ostream &os, UT_StringHolder s)
583  { UT_StringWrap(s).saveBinary(os); }
584  static void saveData(std::ostream &os, UT_SharedPtr<UT_Ramp> s)
586  UT_OStringStream ostr;
587  if (s) s->save(ostr);
588  result = ostr.str();
589  saveData(os, result);
590  }
591  static void saveData(std::ostream &os, PRM_DataItemHandle s)
593  UT_OStringStream ostr;
594  if (s)
595  {
596  ostr << s->getDataTypeToken();
597  ostr << ":";
598  s->saveBinary(ostr);
599  }
600  result = ostr.str();
601  saveData(os, result);
602  }
603 
604 
605  void save(std::ostream &os) const
606  {
607  int32 v = version();
608  UTwrite(os, &v);
609  saveData(os, myNumClusters);
610  saveData(os, myClusterAttrib);
611  saveData(os, myOutputCenter);
612  {
613  int64 length = myControls.entries();
614  UTwrite(os, &length);
615  for (exint i = 0; i < length; i++)
616  {
617  auto && _curentry = myControls(i);
618  (void) _curentry;
619  saveData(os, _curentry.control_attrib);
620  saveData(os, _curentry.control_weight);
621 
622  }
623  }
624  saveData(os, myIterations);
625  saveData(os, myRandomSeed);
626  saveData(os, myThresholdAttrib);
627  saveData(os, myThresholdWeight);
628  saveData(os, myInitialThreshold);
629  saveData(os, myFinalThreshold);
630  saveData(os, myUseLInf);
631  saveData(os, myKMeanPP);
632 
633  }
634 
635  bool load(UT_IStream &is)
636  {
637  int32 v;
638  is.bread(&v, 1);
639  if (version() != v)
640  {
641  // Fail incompatible versions
642  return false;
643  }
644  loadData(is, myNumClusters);
645  loadData(is, myClusterAttrib);
646  loadData(is, myOutputCenter);
647  {
648  int64 length;
649  is.read(&length, 1);
650  myControls.setSize(length);
651  for (exint i = 0; i < length; i++)
652  {
653  auto && _curentry = myControls(i);
654  (void) _curentry;
655  loadData(is, _curentry.control_attrib);
656  loadData(is, _curentry.control_weight);
657 
658  }
659  }
660  loadData(is, myIterations);
661  loadData(is, myRandomSeed);
662  loadData(is, myThresholdAttrib);
663  loadData(is, myThresholdWeight);
664  loadData(is, myInitialThreshold);
665  loadData(is, myFinalThreshold);
666  loadData(is, myUseLInf);
667  loadData(is, myKMeanPP);
668 
669  return true;
670  }
671 
672  int64 getNumClusters() const { return myNumClusters; }
673  void setNumClusters(int64 val) { myNumClusters = val; }
675  {
676  SOP_Node *thissop = cookparms.getNode();
677  if (!thissop) return getNumClusters();
678  int64 result;
679  OP_Utils::evalOpParm(result, thissop, "num_clusters", cookparms.getCookTime(), 0);
680  return result;
681  }
682  const UT_StringHolder & getClusterAttrib() const { return myClusterAttrib; }
683  void setClusterAttrib(const UT_StringHolder & val) { myClusterAttrib = val; }
685  {
686  SOP_Node *thissop = cookparms.getNode();
687  if (!thissop) return getClusterAttrib();
689  OP_Utils::evalOpParm(result, thissop, "cluster_attrib", cookparms.getCookTime(), 0);
690  return result;
691  }
692  bool getOutputCenter() const { return myOutputCenter; }
693  void setOutputCenter(bool val) { myOutputCenter = val; }
694  bool opOutputCenter(const SOP_NodeVerb::CookParms &cookparms) const
695  {
696  SOP_Node *thissop = cookparms.getNode();
697  if (!thissop) return getOutputCenter();
698  bool result;
699  OP_Utils::evalOpParm(result, thissop, "output_center", cookparms.getCookTime(), 0);
700  return result;
701  }
702  const UT_Array<Controls> &getControls() const { return myControls; }
703 void setControls(const UT_Array<Controls> &val) { myControls = val; }
704  exint opControls(const SOP_NodeVerb::CookParms &cookparms) const
705  {
706  SOP_Node *thissop = cookparms.getNode();
707  if (!thissop) return getControls().entries();
708  exint result;
709  OP_Utils::evalOpParm(result, thissop, "num_controls", cookparms.getCookTime(), 0);
710  return result;
711  }
713  { return opinstControls_control_attrib(cookparms, &_idx); }
715  {
716  SOP_Node *thissop = cookparms.getNode();
717  if (!thissop) return (myControls(_idx[0]).control_attrib);
718  int _parmidx[2-1];
719  _parmidx[1-1] = _idx[1-1] + 1;
720 
722  OP_Utils::evalOpParmInst(result, thissop, "control_attrib#", _parmidx, cookparms.getCookTime(), 0, 2-1);
723  return (result);
724  }
726  { return opinstControls_control_weight(cookparms, &_idx); }
727  fpreal64 opinstControls_control_weight(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
728  {
729  SOP_Node *thissop = cookparms.getNode();
730  if (!thissop) return (myControls(_idx[0]).control_weight);
731  int _parmidx[2-1];
732  _parmidx[1-1] = _idx[1-1] + 1;
733 
735  OP_Utils::evalOpParmInst(result, thissop, "control_weight#", _parmidx, cookparms.getCookTime(), 0, 2-1);
736  return (result);
737  }
738 
739  int64 getIterations() const { return myIterations; }
740  void setIterations(int64 val) { myIterations = val; }
742  {
743  SOP_Node *thissop = cookparms.getNode();
744  if (!thissop) return getIterations();
745  int64 result;
746  OP_Utils::evalOpParm(result, thissop, "iterations", cookparms.getCookTime(), 0);
747  return result;
748  }
749  int64 getRandomSeed() const { return myRandomSeed; }
750  void setRandomSeed(int64 val) { myRandomSeed = val; }
752  {
753  SOP_Node *thissop = cookparms.getNode();
754  if (!thissop) return getRandomSeed();
755  int64 result;
756  OP_Utils::evalOpParm(result, thissop, "random_seed", cookparms.getCookTime(), 0);
757  return result;
758  }
759  const UT_StringHolder & getThresholdAttrib() const { return myThresholdAttrib; }
760  void setThresholdAttrib(const UT_StringHolder & val) { myThresholdAttrib = val; }
762  {
763  SOP_Node *thissop = cookparms.getNode();
764  if (!thissop) return getThresholdAttrib();
766  OP_Utils::evalOpParm(result, thissop, "threshold_attrib", cookparms.getCookTime(), 0);
767  return result;
768  }
769  fpreal64 getThresholdWeight() const { return myThresholdWeight; }
770  void setThresholdWeight(fpreal64 val) { myThresholdWeight = val; }
772  {
773  SOP_Node *thissop = cookparms.getNode();
774  if (!thissop) return getThresholdWeight();
776  OP_Utils::evalOpParm(result, thissop, "threshold_weight", cookparms.getCookTime(), 0);
777  return result;
778  }
779  fpreal64 getInitialThreshold() const { return myInitialThreshold; }
780  void setInitialThreshold(fpreal64 val) { myInitialThreshold = val; }
782  {
783  SOP_Node *thissop = cookparms.getNode();
784  if (!thissop) return getInitialThreshold();
786  OP_Utils::evalOpParm(result, thissop, "initial_threshold", cookparms.getCookTime(), 0);
787  return result;
788  }
789  fpreal64 getFinalThreshold() const { return myFinalThreshold; }
790  void setFinalThreshold(fpreal64 val) { myFinalThreshold = val; }
792  {
793  SOP_Node *thissop = cookparms.getNode();
794  if (!thissop) return getFinalThreshold();
796  OP_Utils::evalOpParm(result, thissop, "final_threshold", cookparms.getCookTime(), 0);
797  return result;
798  }
799  bool getUseLInf() const { return myUseLInf; }
800  void setUseLInf(bool val) { myUseLInf = val; }
801  bool opUseLInf(const SOP_NodeVerb::CookParms &cookparms) const
802  {
803  SOP_Node *thissop = cookparms.getNode();
804  if (!thissop) return getUseLInf();
805  bool result;
806  OP_Utils::evalOpParm(result, thissop, "use_linf", cookparms.getCookTime(), 0);
807  return result;
808  }
809  bool getKMeanPP() const { return myKMeanPP; }
810  void setKMeanPP(bool val) { myKMeanPP = val; }
811  bool opKMeanPP(const SOP_NodeVerb::CookParms &cookparms) const
812  {
813  SOP_Node *thissop = cookparms.getNode();
814  if (!thissop) return getKMeanPP();
815  bool result;
816  OP_Utils::evalOpParm(result, thissop, "kmeanpp", cookparms.getCookTime(), 0);
817  return result;
818  }
819 
820 private:
821  int64 myNumClusters;
822  UT_StringHolder myClusterAttrib;
823  bool myOutputCenter;
824  UT_Array<Controls> myControls;
825  int64 myIterations;
826  int64 myRandomSeed;
827  UT_StringHolder myThresholdAttrib;
828  fpreal64 myThresholdWeight;
829  fpreal64 myInitialThreshold;
830  fpreal64 myFinalThreshold;
831  bool myUseLInf;
832  bool myKMeanPP;
833 
834 };
void setIterations(int64 val)
void setClusterAttrib(const UT_StringHolder &val)
fpreal64 opinstControls_control_weight(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2540
static void loadData(UT_IStream &is, UT_Vector4I &v)
fpreal64 opFinalThreshold(const SOP_NodeVerb::CookParms &cookparms) const
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override
int int32
Definition: SYS_Types.h:39
UT_StringHolder createString(const UT_Array< Controls > &list) const
SOP_Node * getNode() const
Definition: SOP_NodeVerb.h:347
bool opKMeanPP(const SOP_NodeVerb::CookParms &cookparms) const
static void loadData(UT_IStream &is, UT_Vector4D &v)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override
UT_StringHolder opThresholdAttrib(const SOP_NodeVerb::CookParms &cookparms) const
void
Definition: png.h:1083
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
int64 getRandomSeed() const
static void loadData(UT_IStream &is, UT_Vector2D &v)
static void saveData(std::ostream &os, PRM_DataItemHandle s)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr< UT_Ramp > &value) override
void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override
static void saveData(std::ostream &os, int64 v)
UT_String makeQuotedString(char delimiter='\'', bool escape_nonprinting=false) const
void setKMeanPP(bool val)
static void loadData(UT_IStream &is, UT_Vector3I &v)
const OP_Context & context() const
Definition: OP_NodeParms.h:97
void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override
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
static void loadData(UT_IStream &is, fpreal64 &v)
GLdouble s
Definition: glad.h:3009
ParmType getNestParmType(TempIndex fieldnum) const override
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:795
static int version()
An output stream object that owns its own string buffer storage.
fpreal64 opControls_control_weight(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
static void saveData(std::ostream &os, UT_Vector3D v)
void setControls(const UT_Array< Controls > &val)
void copyFrom(const OP_NodeParms *src) override
**But if you need a result
Definition: thread.h:613
T clampMinValue(fpreal minvalue, const T &src) const
Definition: OP_NodeParms.h:308
void save(std::ostream &os) const
int64 opIterations(const SOP_NodeVerb::CookParms &cookparms) const
bool getUseLInf() const
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.
bool load(UT_IStream &is)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix2D &value) override
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector4D &value) const override
virtual NodeIdx getInput(NodeIdx idx, int input, bool markused=false) const =0
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector4.h:491
fpreal64 getInitialThreshold() const
static void loadData(UT_IStream &is, UT_Vector3D &v)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override
GLuint GLsizei const GLuint const GLintptr * offsets
Definition: glcorearb.h:2621
const UT_Array< Controls > & getControls() const
double fpreal64
Definition: SYS_Types.h:201
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector2.h:423
static void saveData(std::ostream &os, UT_Vector4D v)
void loadFromOpSubclass(const LoadParms &loadparms) override
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
bool isParmColorRamp(exint idx) const override
void setThresholdWeight(fpreal64 val)
void setRandomSeed(int64 val)
bool operator==(const Controls &src) const
exint length() const
fpreal64 getFinalThreshold() const
void getNestParmValue(TempIndex idx, TempIndex instance, UT_StringHolder &value) const override
int64 getIterations() const
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
void getNestParmValue(TempIndex idx, TempIndex instance, PRM_DataItemHandle &value) const override
static void loadData(UT_IStream &is, UT_Vector2I &v)
static void saveData(std::ostream &os, UT_Matrix3D v)
static void loadData(UT_IStream &is, UT_SharedPtr< UT_Ramp > &v)
static void saveData(std::ostream &os, fpreal64 v)
exint read(bool *array, exint sz=1)
Definition: UT_IStream.h:276
const OP_GraphProxy * graph() const
Definition: OP_NodeParms.h:94
void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override
void setOutputCenter(bool val)
virtual void evalOpParmInst(int64 &v, NodeIdx node, const char *parmname, const int *inst, const int *offsets, fpreal time, DEP_MicroNode *depnode, int nestlevel=1) const =0
void setUseLInf(bool val)
long long int64
Definition: SYS_Types.h:116
static void loadData(UT_IStream &is, bool &v)
static void loadData(UT_IStream &is, UT_Matrix3D &v)
bool operator!=(const Controls &src) const
static void saveData(std::ostream &os, UT_StringHolder s)
virtual void evalOpParm(int64 &v, NodeIdx node, const char *parmname, fpreal time, DEP_MicroNode *depnode) const =0
void doGetParmValue(TempIndex idx, TempIndex instance, T &value) const
static void saveData(std::ostream &os, UT_Matrix2D v)
void buildFromOp(const OP_GraphProxy *graph, exint nodeidx, fpreal time, DEP_MicroNode *depnode)
SYS_FORCE_INLINE void strcat(const char *src)
void saveBinary(std::ostream &os) const
Save string to binary stream.
Definition: UT_String.h:296
GT_API const UT_StringHolder version
exint entries() const
Alias of size(). size() is preferred.
Definition: UT_Array.h:648
exint opControls(const SOP_NodeVerb::CookParms &cookparms) const
UT_StringHolder opControls_control_attrib(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override
int int appendSprintf(const char *fmt,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
static void loadData(UT_IStream &is, UT_StringHolder &v)
void coerceValue(T &result, const S &src) const
Definition: OP_NodeParms.h:301
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix3D &value) override
int64 getNumClusters() const
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector3D &value) override
const UT_StringHolder & getThresholdAttrib() const
const char * getNestParmName(TempIndex fieldnum) const override
bool opUseLInf(const SOP_NodeVerb::CookParms &cookparms) const
bool operator!=(const SOP_ClusterParms &src) const
static void loadData(UT_IStream &is, PRM_DataItemHandle &v)
bool getKMeanPP() const
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override
fpreal64 fpreal
Definition: SYS_Types.h:277
DEP_MicroNode * depnode() const
Definition: OP_NodeParms.h:99
Utility class for containing a color ramp.
Definition: UT_Ramp.h:92
exint getNestNumParms(TempIndex idx) const override
constexpr SYS_FORCE_INLINE T & w() noexcept
Definition: UT_Vector4.h:497
SYS_FORCE_INLINE void append(char character)
UT_StringHolder opinstControls_control_attrib(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
GLuint GLfloat * val
Definition: glcorearb.h:1608
#define SOP_API
Definition: SOP_API.h:10
void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override
void setInitialThreshold(fpreal64 val)
fpreal getCookTime() const
Definition: SOP_NodeVerb.h:361
void setThresholdAttrib(const UT_StringHolder &val)
static void saveData(std::ostream &os, UT_Vector2D v)
fpreal64 opThresholdWeight(const SOP_NodeVerb::CookParms &cookparms) const
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override
const UT_StringHolder & getClusterAttrib() const
void setFinalThreshold(fpreal64 val)
bool opOutputCenter(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
int64 opRandomSeed(const SOP_NodeVerb::CookParms &cookparms) const
Definition: core.h:1131
static void saveData(std::ostream &os, UT_SharedPtr< UT_Ramp > s)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override
void setNumClusters(int64 val)
void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override
GLboolean r
Definition: glcorearb.h:1222
void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr< UT_Ramp > &value) const override
static void loadData(UT_IStream &is, UT_Matrix2D &v)
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector3.h:665
bool operator==(const SOP_ClusterParms &src) const
static void saveData(std::ostream &os, bool v)
static void saveData(std::ostream &os, UT_Matrix4D v)
static void loadData(UT_IStream &is, int64 &v)
type
Definition: core.h:1059
UT_StringHolder opClusterAttrib(const SOP_NodeVerb::CookParms &cookparms) const
fpreal64 opInitialThreshold(const SOP_NodeVerb::CookParms &cookparms) const
int64 opNumClusters(const SOP_NodeVerb::CookParms &cookparms) const
void doSetParmValue(TempIndex idx, TempIndex instance, const T &value)
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
Definition: PRM_Parm.h:97
static void loadData(UT_IStream &is, UT_Matrix4D &v)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix4D &value) const override
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override
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)
bool getOutputCenter() const
GLenum src
Definition: glcorearb.h:1793
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector3.h:663
fpreal64 getThresholdWeight() const