HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_MLRegressionLinearCore.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 namespace SOP_MLRegressionLinearCoreEnums
24 {
25  enum class Batch
26  {
27  SINGLE = 0,
29  };
30 
32  getToken(Batch enum_value)
33  {
34  using namespace UT::Literal;
35  switch (enum_value) {
36  case Batch::SINGLE: return "single"_sh;
37  case Batch::MULTIPLEPACKED: return "multiplepacked"_sh;
38  default: UT_ASSERT(false); return ""_sh;
39  }
40  }
41 
42  enum class InputType
43  {
44  POINT = 0,
45  VOLUME
46  };
47 
49  getToken(InputType enum_value)
50  {
51  using namespace UT::Literal;
52  switch (enum_value) {
53  case InputType::POINT: return "point"_sh;
54  case InputType::VOLUME: return "volume"_sh;
55  default: UT_ASSERT(false); return ""_sh;
56  }
57  }
58 
59  enum class OutputType
60  {
61  POINT = 0,
62  VOLUME
63  };
64 
66  getToken(OutputType enum_value)
67  {
68  using namespace UT::Literal;
69  switch (enum_value) {
70  case OutputType::POINT: return "point"_sh;
71  case OutputType::VOLUME: return "volume"_sh;
72  default: UT_ASSERT(false); return ""_sh;
73  }
74  }
75 
76 }
77 
78 
80 {
81 public:
82  static int version() { return 1; }
83  struct Inputs
84  {
88 
89 
91  {
92  inputtype = 0;
93  inputpointattribute = "value"_UTsh;
94  inputvolumename = "density"_UTsh;
95 
96  }
97 
98  bool operator==(const Inputs &src) const
99  {
100  if (inputtype != src.inputtype) return false;
101  if (inputpointattribute != src.inputpointattribute) return false;
102  if (inputvolumename != src.inputvolumename) return false;
103 
104  return true;
105  }
106  bool operator!=(const Inputs &src) const
107  {
108  return !operator==(src);
109  }
110 
111  };
112 
114  {
116 
117  buf.strcat("[ ");
118  for (int i = 0; i < list.entries(); i++)
119  {
120  if (i)
121  buf.strcat(", ");
122  buf.strcat("( ");
123  buf.append("");
124  buf.appendSprintf("%d", (int) list(i).inputtype);
125  buf.append(", ");
126  { UT_String tmp; tmp = UT_StringWrap(list(i).inputpointattribute).makeQuotedString('"'); buf.strcat(tmp); }
127  buf.append(", ");
128  { UT_String tmp; tmp = UT_StringWrap(list(i).inputvolumename).makeQuotedString('"'); buf.strcat(tmp); }
129 
130  buf.strcat(" )");
131  }
132  buf.strcat(" ]");
133 
135  return result;
136  }
137  struct Outputs
138  {
144 
145 
147  {
148  outputtype = 0;
149  outputpointattribute = "value"_UTsh;
150  outputvolumename = "density"_UTsh;
151  outputvolumeresolution = UT_Vector3I(10,10,10);
152  outputtuplesize = 1;
153 
154  }
155 
156  bool operator==(const Outputs &src) const
157  {
158  if (outputtype != src.outputtype) return false;
159  if (outputpointattribute != src.outputpointattribute) return false;
160  if (outputvolumename != src.outputvolumename) return false;
161  if (outputvolumeresolution != src.outputvolumeresolution) return false;
162  if (outputtuplesize != src.outputtuplesize) return false;
163 
164  return true;
165  }
166  bool operator!=(const Outputs &src) const
167  {
168  return !operator==(src);
169  }
170 
171  };
172 
174  {
176 
177  buf.strcat("[ ");
178  for (int i = 0; i < list.entries(); i++)
179  {
180  if (i)
181  buf.strcat(", ");
182  buf.strcat("( ");
183  buf.append("");
184  buf.appendSprintf("%d", (int) list(i).outputtype);
185  buf.append(", ");
186  { UT_String tmp; tmp = UT_StringWrap(list(i).outputpointattribute).makeQuotedString('"'); buf.strcat(tmp); }
187  buf.append(", ");
188  { UT_String tmp; tmp = UT_StringWrap(list(i).outputvolumename).makeQuotedString('"'); buf.strcat(tmp); }
189  buf.append(", ");
190  buf.appendSprintf("(%" SYS_PRId64 ", %" SYS_PRId64 ", %" SYS_PRId64 ")", list(i).outputvolumeresolution.x(), list(i).outputvolumeresolution.y(), list(i).outputvolumeresolution.z());
191  buf.append(", ");
192  buf.appendSprintf("%d", (int) list(i).outputtuplesize);
193 
194  buf.strcat(" )");
195  }
196  buf.strcat(" ]");
197 
199  return result;
200  }
201 
203  {
204  myBatch = 0;
205  myWeightDecay = 0.000001;
206  myErrorThreshold = 0.00000001;
207  myInputs.setSize(1);
208  myOutputs.setSize(1);
209 
210  }
211 
215  SOP_MLRegressionLinearCoreParms &operator=(SOP_MLRegressionLinearCoreParms &&) noexcept = default;
216 
218 
220  {
221  if (myBatch != src.myBatch) return false;
222  if (myWeightDecay != src.myWeightDecay) return false;
223  if (myErrorThreshold != src.myErrorThreshold) return false;
224  if (myInputs != src.myInputs) return false;
225  if (myOutputs != src.myOutputs) return false;
226 
227 
228  if (baseGetSignature() != src.baseGetSignature()) return false;
229 
230  return true;
231  }
233  {
234  return !operator==(src);
235  }
239 
240 
241 
242  void buildFromOp(const OP_GraphProxy *graph, exint nodeidx, fpreal time, DEP_MicroNode *depnode)
243  {
244  myBatch = 0;
245  if (true)
246  graph->evalOpParm(myBatch, nodeidx, "batch", time, graph->isDirect()?nullptr:depnode);
247  myWeightDecay = 0.000001;
248  if (true)
249  graph->evalOpParm(myWeightDecay, nodeidx, "weightdecay", time, graph->isDirect()?nullptr:depnode);
250  myErrorThreshold = 0.00000001;
251  if (true)
252  graph->evalOpParm(myErrorThreshold, nodeidx, "errorthreshold", time, graph->isDirect()?nullptr:depnode);
253  if (true)
254  {
255  int64 length = 0;
256  graph->evalOpParm(length, nodeidx, "inputs", time, graph->isDirect()?nullptr:depnode);
257  if (length < 0) length = 0;
258  myInputs.setSize(length);
259  for (exint i = 0; i < length; i++)
260  {
261  int parmidx[1];
262  int offsets[1];
263  parmidx[0] = i+1;
264  offsets[0] = 1;
265  auto && _curentry = myInputs(i);
266  (void) _curentry;
267  _curentry.inputtype = 0;
268  if (true)
269  graph->evalOpParmInst(_curentry.inputtype, nodeidx, "inputtype#", parmidx, offsets, time, graph->isDirect()?nullptr:depnode, 2-1);
270  _curentry.inputpointattribute = "value"_UTsh;
271  if (true && ( (true&&!(((_curentry.inputtype!=0)))) ) )
272  graph->evalOpParmInst(_curentry.inputpointattribute, nodeidx, "inputpointattribute#", parmidx, offsets, time, graph->isDirect()?nullptr:depnode, 2-1);
273  _curentry.inputvolumename = "density"_UTsh;
274  if (true && ( (true&&!(((_curentry.inputtype!=1)))) ) )
275  graph->evalOpParmInst(_curentry.inputvolumename, nodeidx, "inputvolumename#", parmidx, offsets, time, graph->isDirect()?nullptr:depnode, 2-1);
276 
277  }
278  }
279  else
280  myInputs.clear();
281  if (true)
282  {
283  int64 length = 0;
284  graph->evalOpParm(length, nodeidx, "outputs", time, graph->isDirect()?nullptr:depnode);
285  if (length < 0) length = 0;
286  myOutputs.setSize(length);
287  for (exint i = 0; i < length; i++)
288  {
289  int parmidx[1];
290  int offsets[1];
291  parmidx[0] = i+1;
292  offsets[0] = 1;
293  auto && _curentry = myOutputs(i);
294  (void) _curentry;
295  _curentry.outputtype = 0;
296  if (true)
297  graph->evalOpParmInst(_curentry.outputtype, nodeidx, "outputtype#", parmidx, offsets, time, graph->isDirect()?nullptr:depnode, 2-1);
298  _curentry.outputpointattribute = "value"_UTsh;
299  if (true && ( (true&&!(((_curentry.outputtype!=0)))) ) )
300  graph->evalOpParmInst(_curentry.outputpointattribute, nodeidx, "outputpointattribute#", parmidx, offsets, time, graph->isDirect()?nullptr:depnode, 2-1);
301  _curentry.outputvolumename = "density"_UTsh;
302  if (true && ( (true&&!(((_curentry.outputtype!=1)))) ) )
303  graph->evalOpParmInst(_curentry.outputvolumename, nodeidx, "outputvolumename#", parmidx, offsets, time, graph->isDirect()?nullptr:depnode, 2-1);
304  _curentry.outputvolumeresolution = UT_Vector3I(10,10,10);
305  if (true && ( (true&&!(((_curentry.outputtype!=1)))) ) )
306  graph->evalOpParmInst(_curentry.outputvolumeresolution, nodeidx, "outputvolumeresolution#", parmidx, offsets, time, graph->isDirect()?nullptr:depnode, 2-1);
307  _curentry.outputtuplesize = 1;
308  if (true)
309  graph->evalOpParmInst(_curentry.outputtuplesize, nodeidx, "outputtuplesize#", parmidx, offsets, time, graph->isDirect()?nullptr:depnode, 2-1);
310 
311  }
312  }
313  else
314  myOutputs.clear();
315 
316  }
317 
318 
319  void loadFromOpSubclass(const LoadParms &loadparms) override
320  {
321  buildFromOp(loadparms.graph(), loadparms.nodeIdx(), loadparms.context().getTime(), loadparms.depnode());
322  }
323 
324 
325  void copyFrom(const OP_NodeParms *src) override
326  {
327  *this = *((const SOP_MLRegressionLinearCoreParms *)src);
328  }
329 
330  template <typename T>
331  void
332  doGetParmValue(TempIndex idx, TempIndex instance, T &value) const
333  {
334  if (idx.size() < 1)
335  return;
336  UT_ASSERT(idx.size() == instance.size()+1);
337  if (idx.size() != instance.size()+1)
338  return;
339  switch (idx[0])
340  {
341  case 0:
342  coerceValue(value, myBatch);
343  break;
344  case 1:
345  coerceValue(value, myWeightDecay);
346  break;
347  case 2:
348  coerceValue(value, myErrorThreshold);
349  break;
350  case 3:
351  if (idx.size() == 1)
352  coerceValue(value, myInputs.entries());
353  else if (instance[0] < myInputs.entries())
354  {
355  auto && _data = myInputs(instance[0]);
356  switch (idx[1])
357  {
358  case 0:
359  coerceValue(value, _data.inputtype);
360  break;
361  case 1:
362  coerceValue(value, _data.inputpointattribute);
363  break;
364  case 2:
365  coerceValue(value, _data.inputvolumename);
366  break;
367 
368  }
369  }
370  break;
371  case 4:
372  if (idx.size() == 1)
373  coerceValue(value, myOutputs.entries());
374  else if (instance[0] < myOutputs.entries())
375  {
376  auto && _data = myOutputs(instance[0]);
377  switch (idx[1])
378  {
379  case 0:
380  coerceValue(value, _data.outputtype);
381  break;
382  case 1:
383  coerceValue(value, _data.outputpointattribute);
384  break;
385  case 2:
386  coerceValue(value, _data.outputvolumename);
387  break;
388  case 3:
389  coerceValue(value, _data.outputvolumeresolution);
390  break;
391  case 4:
392  coerceValue(value, _data.outputtuplesize);
393  break;
394 
395  }
396  }
397  break;
398 
399  }
400  }
401 
402  bool isParmColorRamp(exint idx) const override
403  {
404  switch (idx)
405  {
406 
407  }
408  return false;
409  }
410 
411  void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override
412  { doGetParmValue(idx, instance, value); }
413  void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override
414  { doGetParmValue(idx, instance, value); }
415  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override
416  { doGetParmValue(idx, instance, value); }
417  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override
418  { doGetParmValue(idx, instance, value); }
419  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector4D &value) const override
420  { doGetParmValue(idx, instance, value); }
421  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override
422  { doGetParmValue(idx, instance, value); }
423  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override
424  { doGetParmValue(idx, instance, value); }
425  void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix4D &value) const override
426  { doGetParmValue(idx, instance, value); }
427  void getNestParmValue(TempIndex idx, TempIndex instance, UT_StringHolder &value) const override
428  { doGetParmValue(idx, instance, value); }
429  void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr<UT_Ramp> &value) const override
430  { doGetParmValue(idx, instance, value); }
431  void getNestParmValue(TempIndex idx, TempIndex instance, PRM_DataItemHandle &value) const override
432  { doGetParmValue(idx, instance, value); }
433 
434  template <typename T>
435  void
436  doSetParmValue(TempIndex idx, TempIndex instance, const T &value)
437  {
438  if (idx.size() < 1)
439  return;
440  UT_ASSERT(idx.size() == instance.size()+1);
441  if (idx.size() != instance.size()+1)
442  return;
443  switch (idx[0])
444  {
445  case 0:
446  coerceValue(myBatch, clampMinValue(0, clampMaxValue(1, value ) ));
447  break;
448  case 1:
449  coerceValue(myWeightDecay, ( ( value ) ));
450  break;
451  case 2:
452  coerceValue(myErrorThreshold, ( ( value ) ));
453  break;
454  case 3:
455  if (idx.size() == 1)
456  {
457  exint newsize;
458  coerceValue(newsize, value);
459  if (newsize < 0) newsize = 0;
460  myInputs.setSize(newsize);
461  }
462  else
463  {
464  if (instance[0] < 0)
465  return;
466  myInputs.setSizeIfNeeded(instance[0]+1);
467  auto && _data = myInputs(instance[0]);
468  switch (idx[1])
469  {
470  case 0:
471  coerceValue(_data.inputtype, value);
472  break;
473  case 1:
474  coerceValue(_data.inputpointattribute, value);
475  break;
476  case 2:
477  coerceValue(_data.inputvolumename, value);
478  break;
479 
480  }
481  }
482  break;
483  case 4:
484  if (idx.size() == 1)
485  {
486  exint newsize;
487  coerceValue(newsize, value);
488  if (newsize < 0) newsize = 0;
489  myOutputs.setSize(newsize);
490  }
491  else
492  {
493  if (instance[0] < 0)
494  return;
495  myOutputs.setSizeIfNeeded(instance[0]+1);
496  auto && _data = myOutputs(instance[0]);
497  switch (idx[1])
498  {
499  case 0:
500  coerceValue(_data.outputtype, value);
501  break;
502  case 1:
503  coerceValue(_data.outputpointattribute, value);
504  break;
505  case 2:
506  coerceValue(_data.outputvolumename, value);
507  break;
508  case 3:
509  coerceValue(_data.outputvolumeresolution, value);
510  break;
511  case 4:
512  coerceValue(_data.outputtuplesize, value);
513  break;
514 
515  }
516  }
517  break;
518 
519  }
520  }
521 
522  void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override
523  { doSetParmValue(idx, instance, value); }
524  void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override
525  { doSetParmValue(idx, instance, value); }
526  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override
527  { doSetParmValue(idx, instance, value); }
528  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector3D &value) override
529  { doSetParmValue(idx, instance, value); }
530  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override
531  { doSetParmValue(idx, instance, value); }
532  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix2D &value) override
533  { doSetParmValue(idx, instance, value); }
534  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix3D &value) override
535  { doSetParmValue(idx, instance, value); }
536  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override
537  { doSetParmValue(idx, instance, value); }
538  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override
539  { doSetParmValue(idx, instance, value); }
540  void setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr<UT_Ramp> &value) override
541  { doSetParmValue(idx, instance, value); }
542  void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override
543  { doSetParmValue(idx, instance, value); }
544 
545  exint getNestNumParms(TempIndex idx) const override
546  {
547  if (idx.size() == 0)
548  return 5;
549  switch (idx[0])
550  {
551  case 3:
552  return 3;
553  case 4:
554  return 5;
555 
556  }
557  // Invalid
558  return 0;
559  }
560 
561  const char *getNestParmName(TempIndex fieldnum) const override
562  {
563  if (fieldnum.size() < 1)
564  return 0;
565  switch (fieldnum[0])
566  {
567  case 0:
568  return "batch";
569  case 1:
570  return "weightdecay";
571  case 2:
572  return "errorthreshold";
573  case 3:
574  if (fieldnum.size() == 1)
575  return "inputs";
576  switch (fieldnum[1])
577  {
578  case 0:
579  return "inputtype#";
580  case 1:
581  return "inputpointattribute#";
582  case 2:
583  return "inputvolumename#";
584 
585  }
586  return 0;
587  case 4:
588  if (fieldnum.size() == 1)
589  return "outputs";
590  switch (fieldnum[1])
591  {
592  case 0:
593  return "outputtype#";
594  case 1:
595  return "outputpointattribute#";
596  case 2:
597  return "outputvolumename#";
598  case 3:
599  return "outputvolumeresolution#";
600  case 4:
601  return "outputtuplesize#";
602 
603  }
604  return 0;
605 
606  }
607  return 0;
608  }
609 
610  ParmType getNestParmType(TempIndex fieldnum) const override
611  {
612  if (fieldnum.size() < 1)
613  return PARM_UNSUPPORTED;
614  switch (fieldnum[0])
615  {
616  case 0:
617  return PARM_INTEGER;
618  case 1:
619  return PARM_FLOAT;
620  case 2:
621  return PARM_FLOAT;
622  case 3:
623  if (fieldnum.size() == 1)
624  return PARM_MULTIPARM;
625  switch (fieldnum[1])
626  {
627  case 0:
628  return PARM_INTEGER;
629  case 1:
630  return PARM_STRING;
631  case 2:
632  return PARM_STRING;
633 
634  }
635  return PARM_UNSUPPORTED;
636  case 4:
637  if (fieldnum.size() == 1)
638  return PARM_MULTIPARM;
639  switch (fieldnum[1])
640  {
641  case 0:
642  return PARM_INTEGER;
643  case 1:
644  return PARM_STRING;
645  case 2:
646  return PARM_STRING;
647  case 3:
648  return PARM_VECTOR3;
649  case 4:
650  return PARM_INTEGER;
651 
652  }
653  return PARM_UNSUPPORTED;
654 
655  }
656  return PARM_UNSUPPORTED;
657  }
658 
659  // Boiler plate to load individual types.
660  static void loadData(UT_IStream &is, int64 &v)
661  { is.bread(&v, 1); }
662  static void loadData(UT_IStream &is, bool &v)
663  { int64 iv; is.bread(&iv, 1); v = iv; }
664  static void loadData(UT_IStream &is, fpreal64 &v)
665  { is.bread<fpreal64>(&v, 1); }
666  static void loadData(UT_IStream &is, UT_Vector2D &v)
667  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1); }
668  static void loadData(UT_IStream &is, UT_Vector3D &v)
669  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
670  is.bread<fpreal64>(&v.z(), 1); }
671  static void loadData(UT_IStream &is, UT_Vector4D &v)
672  { is.bread<fpreal64>(&v.x(), 1); is.bread<fpreal64>(&v.y(), 1);
673  is.bread<fpreal64>(&v.z(), 1); is.bread<fpreal64>(&v.w(), 1); }
674  static void loadData(UT_IStream &is, UT_Matrix2D &v)
675  { for (int r = 0; r < 2; r++) for (int c = 0; c < 2; c++) is.bread<fpreal64>(&v(r, c), 1); }
676  static void loadData(UT_IStream &is, UT_Matrix3D &v)
677  { for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) is.bread<fpreal64>(&v(r, c), 1); }
678  static void loadData(UT_IStream &is, UT_Matrix4D &v)
679  { for (int r = 0; r < 4; r++) for (int c = 0; c < 4; c++) is.bread<fpreal64>(&v(r, c), 1); }
680  static void loadData(UT_IStream &is, UT_Vector2I &v)
681  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1); }
682  static void loadData(UT_IStream &is, UT_Vector3I &v)
683  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
684  is.bread<int64>(&v.z(), 1); }
685  static void loadData(UT_IStream &is, UT_Vector4I &v)
686  { is.bread<int64>(&v.x(), 1); is.bread<int64>(&v.y(), 1);
687  is.bread<int64>(&v.z(), 1); is.bread<int64>(&v.w(), 1); }
689  { is.bread(v); }
691  { UT_StringHolder rampdata;
692  loadData(is, rampdata);
693  if (rampdata.isstring())
694  {
695  v.reset(new UT_Ramp());
696  UT_IStream istr((const char *) rampdata, rampdata.length(), UT_ISTREAM_ASCII);
697  v->load(istr);
698  }
699  else v.reset();
700  }
703  loadData(is, data);
704  if (data.isstring())
705  {
706  // Find the data type.
707  const char *colon = UT_StringWrap(data).findChar(':');
708  if (colon)
709  {
710  int typelen = colon - data.buffer();
712  type.strncpy(data.buffer(), typelen);
713  UT_IStream istr(((const char *) data) + typelen + 1, data.length() - (typelen + 1), UT_ISTREAM_BINARY);
714 
715  v = PRM_DataFactory::parseBinary(type.buffer(), istr);
716  }
717  }
718  else v.reset();
719  }
720 
721  static void saveData(std::ostream &os, int64 v)
722  { UTwrite(os, &v); }
723  static void saveData(std::ostream &os, bool v)
724  { int64 iv = v; UTwrite(os, &iv); }
725  static void saveData(std::ostream &os, fpreal64 v)
726  { UTwrite<fpreal64>(os, &v); }
727  static void saveData(std::ostream &os, UT_Vector2D v)
728  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y()); }
729  static void saveData(std::ostream &os, UT_Vector3D v)
730  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
731  UTwrite<fpreal64>(os, &v.z()); }
732  static void saveData(std::ostream &os, UT_Vector4D v)
733  { UTwrite<fpreal64>(os, &v.x()); UTwrite<fpreal64>(os, &v.y());
734  UTwrite<fpreal64>(os, &v.z()); UTwrite<fpreal64>(os, &v.w()); }
735  static void saveData(std::ostream &os, UT_Matrix2D v)
737  static void saveData(std::ostream &os, UT_Matrix3D v)
739  static void saveData(std::ostream &os, UT_Matrix4D v)
741  static void saveData(std::ostream &os, UT_StringHolder s)
742  { UT_StringWrap(s).saveBinary(os); }
743  static void saveData(std::ostream &os, UT_SharedPtr<UT_Ramp> s)
745  UT_OStringStream ostr;
746  if (s) s->save(ostr);
747  result = ostr.str();
748  saveData(os, result);
749  }
750  static void saveData(std::ostream &os, PRM_DataItemHandle s)
752  UT_OStringStream ostr;
753  if (s)
754  {
755  ostr << s->getDataTypeToken();
756  ostr << ":";
757  s->saveBinary(ostr);
758  }
759  result = ostr.str();
760  saveData(os, result);
761  }
762 
763 
764  void save(std::ostream &os) const
765  {
766  int32 v = version();
767  UTwrite(os, &v);
768  saveData(os, myBatch);
769  saveData(os, myWeightDecay);
770  saveData(os, myErrorThreshold);
771  {
772  int64 length = myInputs.entries();
773  UTwrite(os, &length);
774  for (exint i = 0; i < length; i++)
775  {
776  auto && _curentry = myInputs(i);
777  (void) _curentry;
778  saveData(os, _curentry.inputtype);
779  saveData(os, _curentry.inputpointattribute);
780  saveData(os, _curentry.inputvolumename);
781 
782  }
783  }
784  {
785  int64 length = myOutputs.entries();
786  UTwrite(os, &length);
787  for (exint i = 0; i < length; i++)
788  {
789  auto && _curentry = myOutputs(i);
790  (void) _curentry;
791  saveData(os, _curentry.outputtype);
792  saveData(os, _curentry.outputpointattribute);
793  saveData(os, _curentry.outputvolumename);
794  saveData(os, _curentry.outputvolumeresolution);
795  saveData(os, _curentry.outputtuplesize);
796 
797  }
798  }
799 
800  }
801 
802  bool load(UT_IStream &is)
803  {
804  int32 v;
805  is.bread(&v, 1);
806  if (version() != v)
807  {
808  // Fail incompatible versions
809  return false;
810  }
811  loadData(is, myBatch);
812  loadData(is, myWeightDecay);
813  loadData(is, myErrorThreshold);
814  {
815  int64 length;
816  is.read(&length, 1);
817  myInputs.setSize(length);
818  for (exint i = 0; i < length; i++)
819  {
820  auto && _curentry = myInputs(i);
821  (void) _curentry;
822  loadData(is, _curentry.inputtype);
823  loadData(is, _curentry.inputpointattribute);
824  loadData(is, _curentry.inputvolumename);
825 
826  }
827  }
828  {
829  int64 length;
830  is.read(&length, 1);
831  myOutputs.setSize(length);
832  for (exint i = 0; i < length; i++)
833  {
834  auto && _curentry = myOutputs(i);
835  (void) _curentry;
836  loadData(is, _curentry.outputtype);
837  loadData(is, _curentry.outputpointattribute);
838  loadData(is, _curentry.outputvolumename);
839  loadData(is, _curentry.outputvolumeresolution);
840  loadData(is, _curentry.outputtuplesize);
841 
842  }
843  }
844 
845  return true;
846  }
847 
848  Batch getBatch() const { return Batch(myBatch); }
849  void setBatch(Batch val) { myBatch = int64(val); }
850  Batch opBatch(const SOP_NodeVerb::CookParms &cookparms) const
851  {
852  SOP_Node *thissop = cookparms.getNode();
853  if (!thissop) return getBatch();
854  int64 result;
855  OP_Utils::evalOpParm(result, thissop, "batch", cookparms.getCookTime(), 0);
856  return Batch(result);
857  }
858  fpreal64 getWeightDecay() const { return myWeightDecay; }
859  void setWeightDecay(fpreal64 val) { myWeightDecay = val; }
861  {
862  SOP_Node *thissop = cookparms.getNode();
863  if (!thissop) return getWeightDecay();
865  OP_Utils::evalOpParm(result, thissop, "weightdecay", cookparms.getCookTime(), 0);
866  return result;
867  }
868  fpreal64 getErrorThreshold() const { return myErrorThreshold; }
869  void setErrorThreshold(fpreal64 val) { myErrorThreshold = val; }
871  {
872  SOP_Node *thissop = cookparms.getNode();
873  if (!thissop) return getErrorThreshold();
875  OP_Utils::evalOpParm(result, thissop, "errorthreshold", cookparms.getCookTime(), 0);
876  return result;
877  }
878  const UT_Array<Inputs> &getInputs() const { return myInputs; }
879 void setInputs(const UT_Array<Inputs> &val) { myInputs = val; }
880  exint opInputs(const SOP_NodeVerb::CookParms &cookparms) const
881  {
882  SOP_Node *thissop = cookparms.getNode();
883  if (!thissop) return getInputs().entries();
884  exint result;
885  OP_Utils::evalOpParm(result, thissop, "inputs", cookparms.getCookTime(), 0);
886  return result;
887  }
888  int64 opInputs_inputtype(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
889  { return opinstInputs_inputtype(cookparms, &_idx); }
890  int64 opinstInputs_inputtype(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
891  {
892  SOP_Node *thissop = cookparms.getNode();
893  if (!thissop) return (myInputs(_idx[0]).inputtype);
894  int _parmidx[2-1];
895  _parmidx[1-1] = _idx[1-1] + 1;
896 
897  int64 result;
898  OP_Utils::evalOpParmInst(result, thissop, "inputtype#", _parmidx, cookparms.getCookTime(), 0, 2-1);
899  return (result);
900  }
902  { return opinstInputs_inputpointattribute(cookparms, &_idx); }
904  {
905  SOP_Node *thissop = cookparms.getNode();
906  if (!thissop) return (myInputs(_idx[0]).inputpointattribute);
907  int _parmidx[2-1];
908  _parmidx[1-1] = _idx[1-1] + 1;
909 
911  OP_Utils::evalOpParmInst(result, thissop, "inputpointattribute#", _parmidx, cookparms.getCookTime(), 0, 2-1);
912  return (result);
913  }
915  { return opinstInputs_inputvolumename(cookparms, &_idx); }
917  {
918  SOP_Node *thissop = cookparms.getNode();
919  if (!thissop) return (myInputs(_idx[0]).inputvolumename);
920  int _parmidx[2-1];
921  _parmidx[1-1] = _idx[1-1] + 1;
922 
924  OP_Utils::evalOpParmInst(result, thissop, "inputvolumename#", _parmidx, cookparms.getCookTime(), 0, 2-1);
925  return (result);
926  }
927 
928  const UT_Array<Outputs> &getOutputs() const { return myOutputs; }
929 void setOutputs(const UT_Array<Outputs> &val) { myOutputs = val; }
930  exint opOutputs(const SOP_NodeVerb::CookParms &cookparms) const
931  {
932  SOP_Node *thissop = cookparms.getNode();
933  if (!thissop) return getOutputs().entries();
934  exint result;
935  OP_Utils::evalOpParm(result, thissop, "outputs", cookparms.getCookTime(), 0);
936  return result;
937  }
938  int64 opOutputs_outputtype(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
939  { return opinstOutputs_outputtype(cookparms, &_idx); }
940  int64 opinstOutputs_outputtype(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
941  {
942  SOP_Node *thissop = cookparms.getNode();
943  if (!thissop) return (myOutputs(_idx[0]).outputtype);
944  int _parmidx[2-1];
945  _parmidx[1-1] = _idx[1-1] + 1;
946 
947  int64 result;
948  OP_Utils::evalOpParmInst(result, thissop, "outputtype#", _parmidx, cookparms.getCookTime(), 0, 2-1);
949  return (result);
950  }
952  { return opinstOutputs_outputpointattribute(cookparms, &_idx); }
954  {
955  SOP_Node *thissop = cookparms.getNode();
956  if (!thissop) return (myOutputs(_idx[0]).outputpointattribute);
957  int _parmidx[2-1];
958  _parmidx[1-1] = _idx[1-1] + 1;
959 
961  OP_Utils::evalOpParmInst(result, thissop, "outputpointattribute#", _parmidx, cookparms.getCookTime(), 0, 2-1);
962  return (result);
963  }
965  { return opinstOutputs_outputvolumename(cookparms, &_idx); }
967  {
968  SOP_Node *thissop = cookparms.getNode();
969  if (!thissop) return (myOutputs(_idx[0]).outputvolumename);
970  int _parmidx[2-1];
971  _parmidx[1-1] = _idx[1-1] + 1;
972 
974  OP_Utils::evalOpParmInst(result, thissop, "outputvolumename#", _parmidx, cookparms.getCookTime(), 0, 2-1);
975  return (result);
976  }
978  { return opinstOutputs_outputvolumeresolution(cookparms, &_idx); }
980  {
981  SOP_Node *thissop = cookparms.getNode();
982  if (!thissop) return (myOutputs(_idx[0]).outputvolumeresolution);
983  int _parmidx[2-1];
984  _parmidx[1-1] = _idx[1-1] + 1;
985 
987  OP_Utils::evalOpParmInst(result, thissop, "outputvolumeresolution#", _parmidx, cookparms.getCookTime(), 0, 2-1);
988  return (result);
989  }
990  int64 opOutputs_outputtuplesize(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
991  { return opinstOutputs_outputtuplesize(cookparms, &_idx); }
992  int64 opinstOutputs_outputtuplesize(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
993  {
994  SOP_Node *thissop = cookparms.getNode();
995  if (!thissop) return (myOutputs(_idx[0]).outputtuplesize);
996  int _parmidx[2-1];
997  _parmidx[1-1] = _idx[1-1] + 1;
998 
999  int64 result;
1000  OP_Utils::evalOpParmInst(result, thissop, "outputtuplesize#", _parmidx, cookparms.getCookTime(), 0, 2-1);
1001  return (result);
1002  }
1003 
1004 
1005 private:
1006  int64 myBatch;
1007  fpreal64 myWeightDecay;
1008  fpreal64 myErrorThreshold;
1009  UT_Array<Inputs> myInputs;
1010  UT_Array<Outputs> myOutputs;
1011 
1012 };
static void loadData(UT_IStream &is, fpreal64 &v)
type
Definition: core.h:556
exint opInputs(const SOP_NodeVerb::CookParms &cookparms) const
void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2540
static void saveData(std::ostream &os, UT_SharedPtr< UT_Ramp > s)
static void saveData(std::ostream &os, UT_StringHolder s)
int int32
Definition: SYS_Types.h:39
SOP_Node * getNode() const
Definition: SOP_NodeVerb.h:347
static void loadData(UT_IStream &is, UT_Matrix2D &v)
static void loadData(UT_IStream &is, UT_Vector3D &v)
const UT_Array< Inputs > & getInputs() const
UT_Vector3I opOutputs_outputvolumeresolution(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override
void
Definition: png.h:1083
UT_Vector3I opinstOutputs_outputvolumeresolution(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
static void saveData(std::ostream &os, UT_Vector4D v)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr< UT_Ramp > &value) const override
exint bread(int32 *buffer, exint asize=1)
GLboolean * data
Definition: glcorearb.h:131
GT_API const UT_StringHolder time
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector4.h:493
const GLdouble * v
Definition: glcorearb.h:837
fpreal getTime() const
Definition: OP_Context.h:63
static void loadData(UT_IStream &is, PRM_DataItemHandle &v)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override
GLsizei const GLfloat * value
Definition: glcorearb.h:824
bool operator==(const SOP_MLRegressionLinearCoreParms &src) const
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix3D &value) override
static void saveData(std::ostream &os, UT_Matrix4D v)
void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override
static void loadData(UT_IStream &is, UT_Vector4I &v)
static void loadData(UT_IStream &is, bool &v)
UT_String makeQuotedString(char delimiter='\'', bool escape_nonprinting=false) const
UT_StringHolder opOutputs_outputvolumename(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
int64 opOutputs_outputtuplesize(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
const OP_Context & context() const
Definition: OP_NodeParms.h:97
constexpr SYS_FORCE_INLINE T & z() noexcept
Definition: UT_Vector3.h:667
int64 exint
Definition: SYS_Types.h:125
UT_StringHolder opinstOutputs_outputvolumename(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
SYS_FORCE_INLINE const char * buffer() const
GLdouble s
Definition: glad.h:3009
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:795
An output stream object that owns its own string buffer storage.
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override
void getNestParmValue(TempIndex idx, TempIndex instance, UT_StringHolder &value) const override
**But if you need a result
Definition: thread.h:622
UT_Vector3T< int64 > UT_Vector3I
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.
void getNestParmValue(TempIndex idx, TempIndex instance, PRM_DataItemHandle &value) const override
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector4.h:491
void loadFromOpSubclass(const LoadParms &loadparms) override
GLuint GLsizei const GLuint const GLintptr * offsets
Definition: glcorearb.h:2621
static void loadData(UT_IStream &is, UT_Vector4D &v)
double fpreal64
Definition: SYS_Types.h:201
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
Definition: APEX_Include.h:55
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr< UT_Ramp > &value) override
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector2.h:423
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
int64 opinstOutputs_outputtuplesize(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override
exint opOutputs(const SOP_NodeVerb::CookParms &cookparms) const
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix2D &value) override
void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override
exint length() const
SYS_FORCE_INLINE const char * buffer() const
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
Definition: UT_SharedPtr.h:36
UT_StringHolder opOutputs_outputpointattribute(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
constexpr SYS_FORCE_INLINE T & z() noexcept
Definition: UT_Vector4.h:495
void buildFromOp(const OP_GraphProxy *graph, exint nodeidx, fpreal time, DEP_MicroNode *depnode)
UT_StringHolder opinstInputs_inputpointattribute(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
UT_StringHolder opinstInputs_inputvolumename(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
static void loadData(UT_IStream &is, UT_Vector2I &v)
exint read(bool *array, exint sz=1)
Definition: UT_IStream.h:276
const OP_GraphProxy * graph() const
Definition: OP_NodeParms.h:94
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
static void saveData(std::ostream &os, int64 v)
void copyFrom(const OP_NodeParms *src) override
UT_StringHolder createString(const UT_Array< Outputs > &list) const
UT_StringHolder opInputs_inputpointattribute(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
fpreal64 opErrorThreshold(const SOP_NodeVerb::CookParms &cookparms) const
static void loadData(UT_IStream &is, UT_Matrix4D &v)
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
long long int64
Definition: SYS_Types.h:116
ParmType getNestParmType(TempIndex fieldnum) const override
void doGetParmValue(TempIndex idx, TempIndex instance, T &value) const
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector4D &value) const override
SYS_FORCE_INLINE UT_StringHolder getToken(Batch enum_value)
virtual void evalOpParm(int64 &v, NodeIdx node, const char *parmname, fpreal time, DEP_MicroNode *depnode) const =0
void setOutputs(const UT_Array< Outputs > &val)
SYS_FORCE_INLINE void strcat(const char *src)
void saveBinary(std::ostream &os) const
Save string to binary stream.
Definition: UT_String.h:303
exint getNestNumParms(TempIndex idx) const override
GT_API const UT_StringHolder version
static void loadData(UT_IStream &is, UT_StringHolder &v)
#define SYS_PRId64
Definition: SYS_Types.h:76
exint entries() const
Alias of size(). size() is preferred.
Definition: UT_Array.h:655
void setInputs(const UT_Array< Inputs > &val)
static void saveData(std::ostream &os, UT_Vector3D v)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector3D &value) override
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override
int int appendSprintf(const char *fmt,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
int64 opinstInputs_inputtype(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
static void saveData(std::ostream &os, UT_Matrix3D v)
static void loadData(UT_IStream &is, UT_Matrix3D &v)
UT_StringHolder createString(const UT_Array< Inputs > &list) const
UT_StringHolder opInputs_inputvolumename(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
fpreal64 fpreal
Definition: SYS_Types.h:278
DEP_MicroNode * depnode() const
Definition: OP_NodeParms.h:99
LeafData & operator=(const LeafData &)=delete
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override
Utility class for containing a color ramp.
Definition: UT_Ramp.h:96
static void saveData(std::ostream &os, UT_Vector2D v)
fpreal64 opWeightDecay(const SOP_NodeVerb::CookParms &cookparms) const
constexpr SYS_FORCE_INLINE T & w() noexcept
Definition: UT_Vector4.h:497
SYS_FORCE_INLINE void append(char character)
GLuint GLfloat * val
Definition: glcorearb.h:1608
static void loadData(UT_IStream &is, UT_Vector3I &v)
virtual UT_StringHolder baseGetSignature() const
Definition: OP_NodeParms.h:294
int64 opOutputs_outputtype(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix4D &value) const override
#define SOP_API
Definition: SOP_API.h:10
fpreal getCookTime() const
Definition: SOP_NodeVerb.h:372
static void loadData(UT_IStream &is, UT_Vector2D &v)
const UT_Array< Outputs > & getOutputs() const
static void loadData(UT_IStream &is, UT_SharedPtr< UT_Ramp > &v)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override
const char * findChar(int c) const
Definition: UT_String.h:1406
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:156
bool operator!=(const SOP_MLRegressionLinearCoreParms &src) const
static void saveData(std::ostream &os, fpreal64 v)
static void saveData(std::ostream &os, UT_Matrix2D v)
bool isParmColorRamp(exint idx) const override
GLboolean r
Definition: glcorearb.h:1222
static void loadData(UT_IStream &is, int64 &v)
static void saveData(std::ostream &os, PRM_DataItemHandle s)
UT_StringHolder opinstOutputs_outputpointattribute(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector3.h:665
int64 opInputs_inputtype(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
int64 opinstOutputs_outputtype(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
virtual bool isDirect() const =0
Direct proxies mirror actual nodes:
void doSetParmValue(TempIndex idx, TempIndex instance, const T &value)
constexpr SYS_FORCE_INLINE T & y() noexcept
Definition: UT_Vector2.h:425
SYS_FORCE_INLINE bool isstring() const
static void saveData(std::ostream &os, bool v)
const char * getNestParmName(TempIndex fieldnum) const override
SYS_FORCE_INLINE void strncpy(const char *src, exint maxlen)
Batch opBatch(const SOP_NodeVerb::CookParms &cookparms) const
GLenum src
Definition: glcorearb.h:1793
constexpr SYS_FORCE_INLINE T & x() noexcept
Definition: UT_Vector3.h:663
void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override