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