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 <OP/OP_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 
118  if (baseGetSignature() != src.baseGetSignature()) return false;
119 
120  return true;
121  }
122  bool operator!=(const SOP_ClusterParms &src) const
123  {
124  return !operator==(src);
125  }
126 
127 
128 
129  void buildFromOp(const OP_GraphProxy *graph, exint nodeidx, fpreal time, DEP_MicroNode *depnode)
130  {
131  myNumClusters = 10;
132  if (true && ( (true&&!((((graph->getInput(nodeidx,1)>=0)==1)))) ) )
133  graph->evalOpParm(myNumClusters, nodeidx, "num_clusters", time, graph->isDirect()?nullptr:depnode);
134  myClusterAttrib = "cluster"_UTsh;
135  if (true)
136  graph->evalOpParm(myClusterAttrib, nodeidx, "cluster_attrib", time, graph->isDirect()?nullptr:depnode);
137  myOutputCenter = false;
138  if (true && ( (true&&!((((graph->getInput(nodeidx,1)>=0)==1)))) ) )
139  graph->evalOpParm(myOutputCenter, nodeidx, "output_center", time, graph->isDirect()?nullptr:depnode);
140  if (true)
141  {
142  int64 length = 0;
143  graph->evalOpParm(length, nodeidx, "num_controls", time, graph->isDirect()?nullptr:depnode);
144  if (length < 0) length = 0;
145  myControls.setSize(length);
146  for (exint i = 0; i < length; i++)
147  {
148  int parmidx[1];
149  int offsets[1];
150  parmidx[0] = i+1;
151  offsets[0] = 1;
152  auto && _curentry = myControls(i);
153  (void) _curentry;
154  _curentry.control_attrib = "P"_UTsh;
155  if (true)
156  graph->evalOpParmInst(_curentry.control_attrib, nodeidx, "control_attrib#", parmidx, offsets, time, graph->isDirect()?nullptr:depnode, 2-1);
157  _curentry.control_weight = 1;
158  if (true)
159  graph->evalOpParmInst(_curentry.control_weight, nodeidx, "control_weight#", parmidx, offsets, time, graph->isDirect()?nullptr:depnode, 2-1);
160 
161  }
162  }
163  else
164  myControls.clear();
165  myIterations = 50;
166  if (true && ( (true&&!((((graph->getInput(nodeidx,1)>=0)==1)))) ) )
167  graph->evalOpParm(myIterations, nodeidx, "iterations", time, graph->isDirect()?nullptr:depnode);
168  myRandomSeed = 0;
169  if (true && ( (true&&!((((graph->getInput(nodeidx,1)>=0)==1)))) ) )
170  graph->evalOpParm(myRandomSeed, nodeidx, "random_seed", time, graph->isDirect()?nullptr:depnode);
171  myThresholdAttrib = ""_UTsh;
172  if (true)
173  graph->evalOpParm(myThresholdAttrib, nodeidx, "threshold_attrib", time, graph->isDirect()?nullptr:depnode);
174  myThresholdWeight = 10;
175  if (true && ( (true&&!(((getThresholdAttrib()=="")))) ) )
176  graph->evalOpParm(myThresholdWeight, nodeidx, "threshold_weight", time, graph->isDirect()?nullptr:depnode);
177  myInitialThreshold = 1;
178  if (true && ( (true&&!(((getThresholdAttrib()=="")))) ) )
179  graph->evalOpParm(myInitialThreshold, nodeidx, "initial_threshold", time, graph->isDirect()?nullptr:depnode);
180  myFinalThreshold = 0.25;
181  if (true && ( (true&&!(((getThresholdAttrib()=="")))) ) )
182  graph->evalOpParm(myFinalThreshold, nodeidx, "final_threshold", time, graph->isDirect()?nullptr:depnode);
183  myUseLInf = false;
184  if (true)
185  graph->evalOpParm(myUseLInf, nodeidx, "use_linf", time, graph->isDirect()?nullptr:depnode);
186  myKMeanPP = true;
187  if (true && ( (true&&!((((graph->getInput(nodeidx,1)>=0)==1)))) ) )
188  graph->evalOpParm(myKMeanPP, nodeidx, "kmeanpp", time, graph->isDirect()?nullptr:depnode);
189 
190  }
191 
192 
193  void loadFromOpSubclass(const LoadParms &loadparms) override
194  {
195  buildFromOp(loadparms.graph(), loadparms.nodeIdx(), loadparms.context().getTime(), loadparms.depnode());
196  }
197 
198 
199  void copyFrom(const OP_NodeParms *src) override
200  {
201  *this = *((const SOP_ClusterParms *)src);
202  }
203 
204  template <typename T>
205  void
206  doGetParmValue(TempIndex idx, TempIndex instance, T &value) const
207  {
208  if (idx.size() < 1)
209  return;
210  UT_ASSERT(idx.size() == instance.size()+1);
211  if (idx.size() != instance.size()+1)
212  return;
213  switch (idx[0])
214  {
215  case 0:
216  coerceValue(value, myNumClusters);
217  break;
218  case 1:
219  coerceValue(value, myClusterAttrib);
220  break;
221  case 2:
222  coerceValue(value, myOutputCenter);
223  break;
224  case 3:
225  if (idx.size() == 1)
226  coerceValue(value, myControls.entries());
227  else if (instance[0] < myControls.entries())
228  {
229  auto && _data = myControls(instance[0]);
230  switch (idx[1])
231  {
232  case 0:
233  coerceValue(value, _data.control_attrib);
234  break;
235  case 1:
236  coerceValue(value, _data.control_weight);
237  break;
238 
239  }
240  }
241  break;
242  case 4:
243  coerceValue(value, myIterations);
244  break;
245  case 5:
246  coerceValue(value, myRandomSeed);
247  break;
248  case 6:
249  coerceValue(value, myThresholdAttrib);
250  break;
251  case 7:
252  coerceValue(value, myThresholdWeight);
253  break;
254  case 8:
255  coerceValue(value, myInitialThreshold);
256  break;
257  case 9:
258  coerceValue(value, myFinalThreshold);
259  break;
260  case 10:
261  coerceValue(value, myUseLInf);
262  break;
263  case 11:
264  coerceValue(value, myKMeanPP);
265  break;
266 
267  }
268  }
269 
270  bool isParmColorRamp(exint idx) const override
271  {
272  switch (idx)
273  {
274 
275  }
276  return false;
277  }
278 
279  void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override
280  { doGetParmValue(idx, instance, value); }
281  void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override
282  { doGetParmValue(idx, instance, value); }
283  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override
284  { doGetParmValue(idx, instance, value); }
285  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override
286  { doGetParmValue(idx, instance, value); }
287  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector4D &value) const override
288  { doGetParmValue(idx, instance, value); }
289  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override
290  { doGetParmValue(idx, instance, value); }
291  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override
292  { doGetParmValue(idx, instance, value); }
293  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix4D &value) const override
294  { doGetParmValue(idx, instance, value); }
295  void getNestParmValue(TempIndex idx, TempIndex instance, UT_StringHolder &value) const override
296  { doGetParmValue(idx, instance, value); }
297  void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr<UT_Ramp> &value) const override
298  { doGetParmValue(idx, instance, value); }
299  void getNestParmValue(TempIndex idx, TempIndex instance, PRM_DataItemHandle &value) const override
300  { doGetParmValue(idx, instance, value); }
301 
302  template <typename T>
303  void
304  doSetParmValue(TempIndex idx, TempIndex instance, const T &value)
305  {
306  if (idx.size() < 1)
307  return;
308  UT_ASSERT(idx.size() == instance.size()+1);
309  if (idx.size() != instance.size()+1)
310  return;
311  switch (idx[0])
312  {
313  case 0:
314  coerceValue(myNumClusters, clampMinValue(1, ( value ) ));
315  break;
316  case 1:
317  coerceValue(myClusterAttrib, ( ( value ) ));
318  break;
319  case 2:
320  coerceValue(myOutputCenter, ( ( value ) ));
321  break;
322  case 3:
323  if (idx.size() == 1)
324  {
325  exint newsize;
326  coerceValue(newsize, value);
327  if (newsize < 0) newsize = 0;
328  myControls.setSize(newsize);
329  }
330  else
331  {
332  if (instance[0] < 0)
333  return;
334  myControls.setSizeIfNeeded(instance[0]+1);
335  auto && _data = myControls(instance[0]);
336  switch (idx[1])
337  {
338  case 0:
339  coerceValue(_data.control_attrib, value);
340  break;
341  case 1:
342  coerceValue(_data.control_weight, value);
343  break;
344 
345  }
346  }
347  break;
348  case 4:
349  coerceValue(myIterations, clampMinValue(1, ( value ) ));
350  break;
351  case 5:
352  coerceValue(myRandomSeed, ( ( value ) ));
353  break;
354  case 6:
355  coerceValue(myThresholdAttrib, ( ( value ) ));
356  break;
357  case 7:
358  coerceValue(myThresholdWeight, clampMinValue(0, ( value ) ));
359  break;
360  case 8:
361  coerceValue(myInitialThreshold, clampMinValue(0, ( value ) ));
362  break;
363  case 9:
364  coerceValue(myFinalThreshold, clampMinValue(0, ( value ) ));
365  break;
366  case 10:
367  coerceValue(myUseLInf, ( ( value ) ));
368  break;
369  case 11:
370  coerceValue(myKMeanPP, ( ( value ) ));
371  break;
372 
373  }
374  }
375 
376  void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override
377  { doSetParmValue(idx, instance, value); }
378  void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override
379  { doSetParmValue(idx, instance, value); }
380  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override
381  { doSetParmValue(idx, instance, value); }
382  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector3D &value) override
383  { doSetParmValue(idx, instance, value); }
384  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override
385  { doSetParmValue(idx, instance, value); }
386  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix2D &value) override
387  { doSetParmValue(idx, instance, value); }
388  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix3D &value) override
389  { doSetParmValue(idx, instance, value); }
390  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override
391  { doSetParmValue(idx, instance, value); }
392  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override
393  { doSetParmValue(idx, instance, value); }
394  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr<UT_Ramp> &value) override
395  { doSetParmValue(idx, instance, value); }
396  void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override
397  { doSetParmValue(idx, instance, value); }
398 
399  exint getNestNumParms(TempIndex idx) const override
400  {
401  if (idx.size() == 0)
402  return 12;
403  switch (idx[0])
404  {
405  case 3:
406  return 2;
407 
408  }
409  // Invalid
410  return 0;
411  }
412 
413  const char *getNestParmName(TempIndex fieldnum) const override
414  {
415  if (fieldnum.size() < 1)
416  return 0;
417  switch (fieldnum[0])
418  {
419  case 0:
420  return "num_clusters";
421  case 1:
422  return "cluster_attrib";
423  case 2:
424  return "output_center";
425  case 3:
426  if (fieldnum.size() == 1)
427  return "num_controls";
428  switch (fieldnum[1])
429  {
430  case 0:
431  return "control_attrib#";
432  case 1:
433  return "control_weight#";
434 
435  }
436  return 0;
437  case 4:
438  return "iterations";
439  case 5:
440  return "random_seed";
441  case 6:
442  return "threshold_attrib";
443  case 7:
444  return "threshold_weight";
445  case 8:
446  return "initial_threshold";
447  case 9:
448  return "final_threshold";
449  case 10:
450  return "use_linf";
451  case 11:
452  return "kmeanpp";
453 
454  }
455  return 0;
456  }
457 
458  ParmType getNestParmType(TempIndex fieldnum) const override
459  {
460  if (fieldnum.size() < 1)
461  return PARM_UNSUPPORTED;
462  switch (fieldnum[0])
463  {
464  case 0:
465  return PARM_INTEGER;
466  case 1:
467  return PARM_STRING;
468  case 2:
469  return PARM_INTEGER;
470  case 3:
471  if (fieldnum.size() == 1)
472  return PARM_MULTIPARM;
473  switch (fieldnum[1])
474  {
475  case 0:
476  return PARM_STRING;
477  case 1:
478  return PARM_FLOAT;
479 
480  }
481  return PARM_UNSUPPORTED;
482  case 4:
483  return PARM_INTEGER;
484  case 5:
485  return PARM_INTEGER;
486  case 6:
487  return PARM_STRING;
488  case 7:
489  return PARM_FLOAT;
490  case 8:
491  return PARM_FLOAT;
492  case 9:
493  return PARM_FLOAT;
494  case 10:
495  return PARM_INTEGER;
496  case 11:
497  return PARM_INTEGER;
498 
499  }
500  return PARM_UNSUPPORTED;
501  }
502 
503  // Boiler plate to load individual types.
504  static void loadData(UT_IStream &is, int64 &v)
505  { is.bread(&v, 1); }
506  static void loadData(UT_IStream &is, bool &v)
507  { int64 iv; is.bread(&iv, 1); v = iv; }
508  static void loadData(UT_IStream &is, fpreal64 &v)
509  { is.bread<fpreal64>(&v, 1); }
510  static void loadData(UT_IStream &is, UT_Vector2D &v)
511  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1); }
512  static void loadData(UT_IStream &is, UT_Vector3D &v)
513  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
514  is.bread<fpreal64>(&v.z(), 1); }
515  static void loadData(UT_IStream &is, UT_Vector4D &v)
516  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
517  is.bread<fpreal64>(&v.z(), 1); is.bread<fpreal64>(&v.w(), 1); }
518  static void loadData(UT_IStream &is, UT_Matrix2D &v)
519  { for (int r = 0; r < 2; r++) for (int c = 0; c < 2; c++) is.bread<fpreal64>(&v(r, c), 1); }
520  static void loadData(UT_IStream &is, UT_Matrix3D &v)
521  { for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) is.bread<fpreal64>(&v(r, c), 1); }
522  static void loadData(UT_IStream &is, UT_Matrix4D &v)
523  { for (int r = 0; r < 4; r++) for (int c = 0; c < 4; c++) is.bread<fpreal64>(&v(r, c), 1); }
524  static void loadData(UT_IStream &is, UT_Vector2I &v)
525  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1); }
526  static void loadData(UT_IStream &is, UT_Vector3I &v)
527  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
528  is.bread<int64>(&v.z(), 1); }
529  static void loadData(UT_IStream &is, UT_Vector4I &v)
530  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
531  is.bread<int64>(&v.z(), 1); is.bread<int64>(&v.w(), 1); }
533  { is.bread(v); }
535  { UT_StringHolder rampdata;
536  loadData(is, rampdata);
537  if (rampdata.isstring())
538  {
539  v.reset(new UT_Ramp());
540  UT_IStream istr((const char *) rampdata, rampdata.length(), UT_ISTREAM_ASCII);
541  v->load(istr);
542  }
543  else v.reset();
544  }
547  loadData(is, data);
548  if (data.isstring())
549  {
550  // Find the data type.
551  const char *colon = UT_StringWrap(data).findChar(':');
552  if (colon)
553  {
554  int typelen = colon - data.buffer();
556  type.strncpy(data.buffer(), typelen);
557  UT_IStream istr(((const char *) data) + typelen + 1, data.length() - (typelen + 1), UT_ISTREAM_BINARY);
558 
559  v = PRM_DataFactory::parseBinary(type.buffer(), istr);
560  }
561  }
562  else v.reset();
563  }
564 
565  static void saveData(std::ostream &os, int64 v)
566  { UTwrite(os, &v); }
567  static void saveData(std::ostream &os, bool v)
568  { int64 iv = v; UTwrite(os, &iv); }
569  static void saveData(std::ostream &os, fpreal64 v)
570  { UTwrite<fpreal64>(os, &v); }
571  static void saveData(std::ostream &os, UT_Vector2D v)
572  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y()); }
573  static void saveData(std::ostream &os, UT_Vector3D v)
574  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
575  UTwrite<fpreal64>(os, &v.z()); }
576  static void saveData(std::ostream &os, UT_Vector4D v)
577  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
578  UTwrite<fpreal64>(os, &v.z()); UTwrite<fpreal64>(os, &v.w()); }
579  static void saveData(std::ostream &os, UT_Matrix2D v)
581  static void saveData(std::ostream &os, UT_Matrix3D v)
583  static void saveData(std::ostream &os, UT_Matrix4D v)
585  static void saveData(std::ostream &os, UT_StringHolder s)
586  { UT_StringWrap(s).saveBinary(os); }
587  static void saveData(std::ostream &os, UT_SharedPtr<UT_Ramp> s)
589  UT_OStringStream ostr;
590  if (s) s->save(ostr);
591  result = ostr.str();
592  saveData(os, result);
593  }
594  static void saveData(std::ostream &os, PRM_DataItemHandle s)
596  UT_OStringStream ostr;
597  if (s)
598  {
599  ostr << s->getDataTypeToken();
600  ostr << ":";
601  s->saveBinary(ostr);
602  }
603  result = ostr.str();
604  saveData(os, result);
605  }
606 
607 
608  void save(std::ostream &os) const
609  {
610  int32 v = version();
611  UTwrite(os, &v);
612  saveData(os, myNumClusters);
613  saveData(os, myClusterAttrib);
614  saveData(os, myOutputCenter);
615  {
616  int64 length = myControls.entries();
617  UTwrite(os, &length);
618  for (exint i = 0; i < length; i++)
619  {
620  auto && _curentry = myControls(i);
621  (void) _curentry;
622  saveData(os, _curentry.control_attrib);
623  saveData(os, _curentry.control_weight);
624 
625  }
626  }
627  saveData(os, myIterations);
628  saveData(os, myRandomSeed);
629  saveData(os, myThresholdAttrib);
630  saveData(os, myThresholdWeight);
631  saveData(os, myInitialThreshold);
632  saveData(os, myFinalThreshold);
633  saveData(os, myUseLInf);
634  saveData(os, myKMeanPP);
635 
636  }
637 
638  bool load(UT_IStream &is)
639  {
640  int32 v;
641  is.bread(&v, 1);
642  if (version() != v)
643  {
644  // Fail incompatible versions
645  return false;
646  }
647  loadData(is, myNumClusters);
648  loadData(is, myClusterAttrib);
649  loadData(is, myOutputCenter);
650  {
651  int64 length;
652  is.read(&length, 1);
653  myControls.setSize(length);
654  for (exint i = 0; i < length; i++)
655  {
656  auto && _curentry = myControls(i);
657  (void) _curentry;
658  loadData(is, _curentry.control_attrib);
659  loadData(is, _curentry.control_weight);
660 
661  }
662  }
663  loadData(is, myIterations);
664  loadData(is, myRandomSeed);
665  loadData(is, myThresholdAttrib);
666  loadData(is, myThresholdWeight);
667  loadData(is, myInitialThreshold);
668  loadData(is, myFinalThreshold);
669  loadData(is, myUseLInf);
670  loadData(is, myKMeanPP);
671 
672  return true;
673  }
674 
675  int64 getNumClusters() const { return myNumClusters; }
676  void setNumClusters(int64 val) { myNumClusters = val; }
678  {
679  SOP_Node *thissop = cookparms.getNode();
680  if (!thissop) return getNumClusters();
681  int64 result;
682  OP_Utils::evalOpParm(result, thissop, "num_clusters", cookparms.getCookTime(), 0);
683  return result;
684  }
685  const UT_StringHolder & getClusterAttrib() const { return myClusterAttrib; }
686  void setClusterAttrib(const UT_StringHolder & val) { myClusterAttrib = val; }
688  {
689  SOP_Node *thissop = cookparms.getNode();
690  if (!thissop) return getClusterAttrib();
692  OP_Utils::evalOpParm(result, thissop, "cluster_attrib", cookparms.getCookTime(), 0);
693  return result;
694  }
695  bool getOutputCenter() const { return myOutputCenter; }
696  void setOutputCenter(bool val) { myOutputCenter = val; }
697  bool opOutputCenter(const SOP_NodeVerb::CookParms &cookparms) const
698  {
699  SOP_Node *thissop = cookparms.getNode();
700  if (!thissop) return getOutputCenter();
701  bool result;
702  OP_Utils::evalOpParm(result, thissop, "output_center", cookparms.getCookTime(), 0);
703  return result;
704  }
705  const UT_Array<Controls> &getControls() const { return myControls; }
706 void setControls(const UT_Array<Controls> &val) { myControls = val; }
707  exint opControls(const SOP_NodeVerb::CookParms &cookparms) const
708  {
709  SOP_Node *thissop = cookparms.getNode();
710  if (!thissop) return getControls().entries();
711  exint result;
712  OP_Utils::evalOpParm(result, thissop, "num_controls", cookparms.getCookTime(), 0);
713  return result;
714  }
716  { return opinstControls_control_attrib(cookparms, &_idx); }
718  {
719  SOP_Node *thissop = cookparms.getNode();
720  if (!thissop) return (myControls(_idx[0]).control_attrib);
721  int _parmidx[2-1];
722  _parmidx[1-1] = _idx[1-1] + 1;
723 
725  OP_Utils::evalOpParmInst(result, thissop, "control_attrib#", _parmidx, cookparms.getCookTime(), 0, 2-1);
726  return (result);
727  }
729  { return opinstControls_control_weight(cookparms, &_idx); }
730  fpreal64 opinstControls_control_weight(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
731  {
732  SOP_Node *thissop = cookparms.getNode();
733  if (!thissop) return (myControls(_idx[0]).control_weight);
734  int _parmidx[2-1];
735  _parmidx[1-1] = _idx[1-1] + 1;
736 
738  OP_Utils::evalOpParmInst(result, thissop, "control_weight#", _parmidx, cookparms.getCookTime(), 0, 2-1);
739  return (result);
740  }
741 
742  int64 getIterations() const { return myIterations; }
743  void setIterations(int64 val) { myIterations = val; }
745  {
746  SOP_Node *thissop = cookparms.getNode();
747  if (!thissop) return getIterations();
748  int64 result;
749  OP_Utils::evalOpParm(result, thissop, "iterations", cookparms.getCookTime(), 0);
750  return result;
751  }
752  int64 getRandomSeed() const { return myRandomSeed; }
753  void setRandomSeed(int64 val) { myRandomSeed = val; }
755  {
756  SOP_Node *thissop = cookparms.getNode();
757  if (!thissop) return getRandomSeed();
758  int64 result;
759  OP_Utils::evalOpParm(result, thissop, "random_seed", cookparms.getCookTime(), 0);
760  return result;
761  }
762  const UT_StringHolder & getThresholdAttrib() const { return myThresholdAttrib; }
763  void setThresholdAttrib(const UT_StringHolder & val) { myThresholdAttrib = val; }
765  {
766  SOP_Node *thissop = cookparms.getNode();
767  if (!thissop) return getThresholdAttrib();
769  OP_Utils::evalOpParm(result, thissop, "threshold_attrib", cookparms.getCookTime(), 0);
770  return result;
771  }
772  fpreal64 getThresholdWeight() const { return myThresholdWeight; }
773  void setThresholdWeight(fpreal64 val) { myThresholdWeight = val; }
775  {
776  SOP_Node *thissop = cookparms.getNode();
777  if (!thissop) return getThresholdWeight();
779  OP_Utils::evalOpParm(result, thissop, "threshold_weight", cookparms.getCookTime(), 0);
780  return result;
781  }
782  fpreal64 getInitialThreshold() const { return myInitialThreshold; }
783  void setInitialThreshold(fpreal64 val) { myInitialThreshold = val; }
785  {
786  SOP_Node *thissop = cookparms.getNode();
787  if (!thissop) return getInitialThreshold();
789  OP_Utils::evalOpParm(result, thissop, "initial_threshold", cookparms.getCookTime(), 0);
790  return result;
791  }
792  fpreal64 getFinalThreshold() const { return myFinalThreshold; }
793  void setFinalThreshold(fpreal64 val) { myFinalThreshold = val; }
795  {
796  SOP_Node *thissop = cookparms.getNode();
797  if (!thissop) return getFinalThreshold();
799  OP_Utils::evalOpParm(result, thissop, "final_threshold", cookparms.getCookTime(), 0);
800  return result;
801  }
802  bool getUseLInf() const { return myUseLInf; }
803  void setUseLInf(bool val) { myUseLInf = val; }
804  bool opUseLInf(const SOP_NodeVerb::CookParms &cookparms) const
805  {
806  SOP_Node *thissop = cookparms.getNode();
807  if (!thissop) return getUseLInf();
808  bool result;
809  OP_Utils::evalOpParm(result, thissop, "use_linf", cookparms.getCookTime(), 0);
810  return result;
811  }
812  bool getKMeanPP() const { return myKMeanPP; }
813  void setKMeanPP(bool val) { myKMeanPP = val; }
814  bool opKMeanPP(const SOP_NodeVerb::CookParms &cookparms) const
815  {
816  SOP_Node *thissop = cookparms.getNode();
817  if (!thissop) return getKMeanPP();
818  bool result;
819  OP_Utils::evalOpParm(result, thissop, "kmeanpp", cookparms.getCookTime(), 0);
820  return result;
821  }
822 
823 private:
824  int64 myNumClusters;
825  UT_StringHolder myClusterAttrib;
826  bool myOutputCenter;
827  UT_Array<Controls> myControls;
828  int64 myIterations;
829  int64 myRandomSeed;
830  UT_StringHolder myThresholdAttrib;
831  fpreal64 myThresholdWeight;
832  fpreal64 myInitialThreshold;
833  fpreal64 myFinalThreshold;
834  bool myUseLInf;
835  bool myKMeanPP;
836 
837 };
void setIterations(int64 val)
virtual NodeIdx getInput(NodeIdx idx, OP_InputIdx input, bool markused=false) const =0
type
Definition: core.h:556
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:63
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
GLsizei const GLfloat * value
Definition: glcorearb.h:824
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:622
T clampMinValue(fpreal minvalue, const T &src) const
Definition: OP_NodeParms.h:317
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
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
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
Definition: APEX_Include.h:55
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:303
GT_API const UT_StringHolder version
exint entries() const
Alias of size(). size() is preferred.
Definition: UT_Array.h:655
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:310
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:278
DEP_MicroNode * depnode() const
Definition: OP_NodeParms.h:99
Utility class for containing a color ramp.
Definition: UT_Ramp.h:96
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
virtual UT_StringHolder baseGetSignature() const
Definition: OP_NodeParms.h:294
#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:372
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:1401
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
int64 opRandomSeed(const SOP_NodeVerb::CookParms &cookparms) const
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)
UT_StringHolder opClusterAttrib(const SOP_NodeVerb::CookParms &cookparms) const
fpreal64 opInitialThreshold(const SOP_NodeVerb::CookParms &cookparms) const
virtual bool isDirect() const =0
Direct proxies mirror actual nodes:
int64 opNumClusters(const SOP_NodeVerb::CookParms &cookparms) const
void doSetParmValue(TempIndex idx, TempIndex instance, const T &value)
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