23 namespace SOP_MLExampleSerializePackedEnums
34 using namespace UT::Literal;
51 using namespace UT::Literal;
76 inputpointattribute =
"value"_UTsh;
77 inputvolumename =
"density"_UTsh;
83 if (inputtype != src.
inputtype)
return false;
101 for (
int i = 0; i < list.
entries(); i++)
130 targetpointattribute =
"value"_UTsh;
131 targetvolumename =
"density"_UTsh;
137 if (targettype != src.
targettype)
return false;
155 for (
int i = 0; i < list.
entries(); i++)
177 myInputDimensionAttribute =
"inputdimension"_UTsh;
178 myTargetDimensionAttribute =
"targetdimension"_UTsh;
179 mySerialAttribute =
"value"_UTsh;
181 myTargets.setSize(1);
194 if (myInputDimensionAttribute != src.myInputDimensionAttribute)
return false;
195 if (myTargetDimensionAttribute != src.myTargetDimensionAttribute)
return false;
196 if (mySerialAttribute != src.mySerialAttribute)
return false;
197 if (myInputs != src.myInputs)
return false;
198 if (myTargets != src.myTargets)
return false;
213 myInputDimensionAttribute =
"inputdimension"_UTsh;
215 graph->
evalOpParm(myInputDimensionAttribute, nodeidx,
"inputdimensionattribute", time, 0);
216 myTargetDimensionAttribute =
"targetdimension"_UTsh;
218 graph->
evalOpParm(myTargetDimensionAttribute, nodeidx,
"targetdimensionattribute", time, 0);
219 mySerialAttribute =
"value"_UTsh;
221 graph->
evalOpParm(mySerialAttribute, nodeidx,
"serialattribute", time, 0);
225 graph->
evalOpParm(length, nodeidx,
"inputs", time, 0);
226 if (length < 0) length = 0;
227 myInputs.setSize(length);
234 auto && _curentry = myInputs(i);
236 _curentry.inputtype = 0;
238 graph->
evalOpParmInst(_curentry.inputtype, nodeidx,
"inputtype#", parmidx, offsets, time, 0, 2-1);
239 _curentry.inputpointattribute =
"value"_UTsh;
240 if (
true && ( (
true&&!(((_curentry.inputtype!=0)))) ) )
241 graph->
evalOpParmInst(_curentry.inputpointattribute, nodeidx,
"inputpointattribute#", parmidx, offsets, time, 0, 2-1);
242 _curentry.inputvolumename =
"density"_UTsh;
243 if (
true && ( (
true&&!(((_curentry.inputtype!=1)))) ) )
244 graph->
evalOpParmInst(_curentry.inputvolumename, nodeidx,
"inputvolumename#", parmidx, offsets, time, 0, 2-1);
253 graph->
evalOpParm(length, nodeidx,
"targets", time, 0);
254 if (length < 0) length = 0;
255 myTargets.setSize(length);
262 auto && _curentry = myTargets(i);
264 _curentry.targettype = 0;
266 graph->
evalOpParmInst(_curentry.targettype, nodeidx,
"targettype#", parmidx, offsets, time, 0, 2-1);
267 _curentry.targetpointattribute =
"value"_UTsh;
268 if (
true && ( (
true&&!(((_curentry.targettype!=0)))) ) )
269 graph->
evalOpParmInst(_curentry.targetpointattribute, nodeidx,
"targetpointattribute#", parmidx, offsets, time, 0, 2-1);
270 _curentry.targetvolumename =
"density"_UTsh;
271 if (
true && ( (
true&&!(((_curentry.targettype!=1)))) ) )
272 graph->
evalOpParmInst(_curentry.targetvolumename, nodeidx,
"targetvolumename#", parmidx, offsets, time, 0, 2-1);
293 template <
typename T>
300 if (idx.
size() != instance.
size()+1)
305 coerceValue(value, myInputDimensionAttribute);
308 coerceValue(value, myTargetDimensionAttribute);
311 coerceValue(value, mySerialAttribute);
315 coerceValue(value, myInputs.entries());
316 else if (instance[0] < myInputs.entries())
318 auto && _data = myInputs(instance[0]);
322 coerceValue(value, _data.inputtype);
325 coerceValue(value, _data.inputpointattribute);
328 coerceValue(value, _data.inputvolumename);
336 coerceValue(value, myTargets.entries());
337 else if (instance[0] < myTargets.entries())
339 auto && _data = myTargets(instance[0]);
343 coerceValue(value, _data.targettype);
346 coerceValue(value, _data.targetpointattribute);
349 coerceValue(value, _data.targetvolumename);
369 { doGetParmValue(idx, instance, value); }
371 { doGetParmValue(idx, instance, value); }
373 { doGetParmValue(idx, instance, value); }
375 { doGetParmValue(idx, instance, value); }
377 { doGetParmValue(idx, instance, value); }
379 { doGetParmValue(idx, instance, value); }
381 { doGetParmValue(idx, instance, value); }
383 { doGetParmValue(idx, instance, value); }
385 { doGetParmValue(idx, instance, value); }
387 { doGetParmValue(idx, instance, value); }
389 { doGetParmValue(idx, instance, value); }
391 template <
typename T>
398 if (idx.
size() != instance.
size()+1)
403 coerceValue(myInputDimensionAttribute, ( ( value ) ));
406 coerceValue(myTargetDimensionAttribute, ( ( value ) ));
409 coerceValue(mySerialAttribute, ( ( value ) ));
415 coerceValue(newsize, value);
416 if (newsize < 0) newsize = 0;
417 myInputs.setSize(newsize);
423 myInputs.setSizeIfNeeded(instance[0]+1);
424 auto && _data = myInputs(instance[0]);
428 coerceValue(_data.inputtype, value);
431 coerceValue(_data.inputpointattribute, value);
434 coerceValue(_data.inputvolumename, value);
444 coerceValue(newsize, value);
445 if (newsize < 0) newsize = 0;
446 myTargets.setSize(newsize);
452 myTargets.setSizeIfNeeded(instance[0]+1);
453 auto && _data = myTargets(instance[0]);
457 coerceValue(_data.targettype, value);
460 coerceValue(_data.targetpointattribute, value);
463 coerceValue(_data.targetvolumename, value);
474 { doSetParmValue(idx, instance, value); }
476 { doSetParmValue(idx, instance, value); }
478 { doSetParmValue(idx, instance, value); }
480 { doSetParmValue(idx, instance, value); }
482 { doSetParmValue(idx, instance, value); }
484 { doSetParmValue(idx, instance, value); }
486 { doSetParmValue(idx, instance, value); }
488 { doSetParmValue(idx, instance, value); }
490 { doSetParmValue(idx, instance, value); }
492 { doSetParmValue(idx, instance, value); }
494 { doSetParmValue(idx, instance, value); }
514 if (fieldnum.
size() < 1)
519 return "inputdimensionattribute";
521 return "targetdimensionattribute";
523 return "serialattribute";
525 if (fieldnum.
size() == 1)
532 return "inputpointattribute#";
534 return "inputvolumename#";
539 if (fieldnum.
size() == 1)
544 return "targettype#";
546 return "targetpointattribute#";
548 return "targetvolumename#";
559 if (fieldnum.
size() < 1)
560 return PARM_UNSUPPORTED;
570 if (fieldnum.
size() == 1)
571 return PARM_MULTIPARM;
582 return PARM_UNSUPPORTED;
584 if (fieldnum.
size() == 1)
585 return PARM_MULTIPARM;
596 return PARM_UNSUPPORTED;
599 return PARM_UNSUPPORTED;
635 loadData(is, rampdata);
653 int typelen = colon - data.
buffer();
667 {
int64 iv =
v; UTwrite(os, &iv); }
669 { UTwrite<fpreal64>(os, &
v); }
671 { UTwrite<fpreal64>(os, &v.
x()); UTwrite<fpreal64>(os, &v.
y()); }
673 { UTwrite<fpreal64>(os, &v.
x()); UTwrite<fpreal64>(os, &v.
y());
674 UTwrite<fpreal64>(os, &v.
z()); }
676 { UTwrite<fpreal64>(os, &v.
x()); UTwrite<fpreal64>(os, &v.
y());
677 UTwrite<fpreal64>(os, &v.
z()); UTwrite<fpreal64>(os, &v.
w()); }
689 if (s) s->save(ostr);
691 saveData(os, result);
698 ostr << s->getDataTypeToken();
703 saveData(os, result);
707 void save(std::ostream &os)
const
711 saveData(os, myInputDimensionAttribute);
712 saveData(os, myTargetDimensionAttribute);
713 saveData(os, mySerialAttribute);
716 UTwrite(os, &length);
719 auto && _curentry = myInputs(i);
721 saveData(os, _curentry.inputtype);
722 saveData(os, _curentry.inputpointattribute);
723 saveData(os, _curentry.inputvolumename);
729 UTwrite(os, &length);
732 auto && _curentry = myTargets(i);
734 saveData(os, _curentry.targettype);
735 saveData(os, _curentry.targetpointattribute);
736 saveData(os, _curentry.targetvolumename);
752 loadData(is, myInputDimensionAttribute);
753 loadData(is, myTargetDimensionAttribute);
754 loadData(is, mySerialAttribute);
758 myInputs.setSize(length);
761 auto && _curentry = myInputs(i);
763 loadData(is, _curentry.inputtype);
764 loadData(is, _curentry.inputpointattribute);
765 loadData(is, _curentry.inputvolumename);
772 myTargets.setSize(length);
775 auto && _curentry = myTargets(i);
777 loadData(is, _curentry.targettype);
778 loadData(is, _curentry.targetpointattribute);
779 loadData(is, _curentry.targetvolumename);
792 if (!thissop)
return getInputDimensionAttribute();
794 OP_Utils::evalOpParm(result, thissop,
"inputdimensionattribute", cookparms.
getCookTime(), 0);
802 if (!thissop)
return getTargetDimensionAttribute();
804 OP_Utils::evalOpParm(result, thissop,
"targetdimensionattribute", cookparms.
getCookTime(), 0);
812 if (!thissop)
return getSerialAttribute();
814 OP_Utils::evalOpParm(result, thissop,
"serialattribute", cookparms.
getCookTime(), 0);
822 if (!thissop)
return getInputs().entries();
824 OP_Utils::evalOpParm(result, thissop,
"inputs", cookparms.
getCookTime(), 0);
828 {
return opinstInputs_inputtype(cookparms, &_idx); }
832 if (!thissop)
return (myInputs(_idx[0]).inputtype);
834 _parmidx[1-1] = _idx[1-1] + 1;
837 OP_Utils::evalOpParmInst(result, thissop,
"inputtype#", _parmidx, cookparms.
getCookTime(), 0, 2-1);
841 {
return opinstInputs_inputpointattribute(cookparms, &_idx); }
845 if (!thissop)
return (myInputs(_idx[0]).inputpointattribute);
847 _parmidx[1-1] = _idx[1-1] + 1;
850 OP_Utils::evalOpParmInst(result, thissop,
"inputpointattribute#", _parmidx, cookparms.
getCookTime(), 0, 2-1);
854 {
return opinstInputs_inputvolumename(cookparms, &_idx); }
858 if (!thissop)
return (myInputs(_idx[0]).inputvolumename);
860 _parmidx[1-1] = _idx[1-1] + 1;
863 OP_Utils::evalOpParmInst(result, thissop,
"inputvolumename#", _parmidx, cookparms.
getCookTime(), 0, 2-1);
872 if (!thissop)
return getTargets().entries();
874 OP_Utils::evalOpParm(result, thissop,
"targets", cookparms.
getCookTime(), 0);
878 {
return opinstTargets_targettype(cookparms, &_idx); }
882 if (!thissop)
return (myTargets(_idx[0]).targettype);
884 _parmidx[1-1] = _idx[1-1] + 1;
887 OP_Utils::evalOpParmInst(result, thissop,
"targettype#", _parmidx, cookparms.
getCookTime(), 0, 2-1);
891 {
return opinstTargets_targetpointattribute(cookparms, &_idx); }
895 if (!thissop)
return (myTargets(_idx[0]).targetpointattribute);
897 _parmidx[1-1] = _idx[1-1] + 1;
900 OP_Utils::evalOpParmInst(result, thissop,
"targetpointattribute#", _parmidx, cookparms.
getCookTime(), 0, 2-1);
904 {
return opinstTargets_targetvolumename(cookparms, &_idx); }
908 if (!thissop)
return (myTargets(_idx[0]).targetvolumename);
910 _parmidx[1-1] = _idx[1-1] + 1;
913 OP_Utils::evalOpParmInst(result, thissop,
"targetvolumename#", _parmidx, cookparms.
getCookTime(), 0, 2-1);
static void loadData(UT_IStream &is, UT_Vector4I &v)
static void saveData(std::ostream &os, UT_Matrix4D v)
static void saveData(std::ostream &os, UT_SharedPtr< UT_Ramp > s)
GLenum GLuint GLenum GLsizei const GLchar * buf
void loadFromOpSubclass(const LoadParms &loadparms) override
SOP_Node * getNode() const
UT_StringHolder opinstTargets_targetpointattribute(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
static void saveData(std::ostream &os, UT_StringHolder s)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override
static void loadData(UT_IStream &is, int64 &v)
static void loadData(UT_IStream &is, fpreal64 &v)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix2D &value) override
UT_StringHolder opSerialAttribute(const SOP_NodeVerb::CookParms &cookparms) const
exint bread(int32 *buffer, exint asize=1)
GT_API const UT_StringHolder time
constexpr SYS_FORCE_INLINE T & y() noexcept
void setTargetDimensionAttribute(const UT_StringHolder &val)
UT_StringHolder opInputDimensionAttribute(const SOP_NodeVerb::CookParms &cookparms) const
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector4D &value) const override
void setSerialAttribute(const UT_StringHolder &val)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_StringHolder &value) const override
UT_String makeQuotedString(char delimiter='\'', bool escape_nonprinting=false) const
const OP_Context & context() const
constexpr SYS_FORCE_INLINE T & z() noexcept
SYS_FORCE_INLINE const char * buffer() const
GLuint GLsizei GLsizei * length
static void saveData(std::ostream &os, PRM_DataItemHandle s)
An output stream object that owns its own string buffer storage.
void copyFrom(const OP_NodeParms *src) override
**But if you need a result
static void loadData(UT_IStream &is, PRM_DataItemHandle &v)
bool operator==(const Targets &src) const
static void saveData(std::ostream &os, bool v)
bool isParmColorRamp(exint idx) const override
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, UT_Matrix4D &value) const override
constexpr SYS_FORCE_INLINE T & x() noexcept
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override
void doGetParmValue(TempIndex idx, TempIndex instance, T &value) const
static void saveData(std::ostream &os, UT_Matrix2D v)
GLuint GLsizei const GLuint const GLintptr * offsets
UT_StringHolder opInputs_inputvolumename(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
constexpr SYS_FORCE_INLINE T & x() noexcept
const UT_StringHolder & getTargetDimensionAttribute() const
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
static void loadData(UT_IStream &is, bool &v)
UT_StringHolder opinstInputs_inputvolumename(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override
bool operator!=(const SOP_MLExampleSerializePackedParms &src) const
void setInputs(const UT_Array< Inputs > &val)
ParmType getNestParmType(TempIndex fieldnum) const override
UT_StringHolder targetvolumename
SYS_FORCE_INLINE UT_StringHolder getToken(InputType enum_value)
UT_StringHolder opTargets_targetvolumename(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
SYS_FORCE_INLINE const char * buffer() const
std::shared_ptr< T > UT_SharedPtr
Wrapper around std::shared_ptr.
int64 opinstTargets_targettype(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
constexpr SYS_FORCE_INLINE T & z() noexcept
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override
UT_StringHolder opinstInputs_inputpointattribute(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
void getNestParmValue(TempIndex idx, TempIndex instance, PRM_DataItemHandle &value) const override
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override
exint read(bool *array, exint sz=1)
const OP_GraphProxy * graph() const
bool load(UT_IStream &is)
exint opTargets(const SOP_NodeVerb::CookParms &cookparms) const
UT_StringHolder opInputs_inputpointattribute(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
UT_StringHolder opTargets_targetpointattribute(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
const UT_StringHolder & getInputDimensionAttribute() const
static void saveData(std::ostream &os, int64 v)
static void saveData(std::ostream &os, UT_Vector3D 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
UT_StringHolder createString(const UT_Array< Inputs > &list) const
SOP_MLExampleSerializePackedParms()
bool operator!=(const Targets &src) const
const char * getNestParmName(TempIndex fieldnum) const override
static void saveData(std::ostream &os, fpreal64 v)
const UT_Array< Inputs > & getInputs() const
static void saveData(std::ostream &os, UT_Matrix3D v)
virtual void evalOpParm(int64 &v, NodeIdx node, const char *parmname, fpreal time, DEP_MicroNode *depnode) const =0
void setInputDimensionAttribute(const UT_StringHolder &val)
UT_StringHolder createString(const UT_Array< Targets > &list) const
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector3D &value) override
SYS_FORCE_INLINE void strcat(const char *src)
void saveBinary(std::ostream &os) const
Save string to binary stream.
GT_API const UT_StringHolder version
exint entries() const
Alias of size(). size() is preferred.
bool operator==(const SOP_MLExampleSerializePackedParms &src) const
static void loadData(UT_IStream &is, UT_Matrix3D &v)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix3D &value) 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 loadData(UT_IStream &is, UT_Vector2D &v)
static void loadData(UT_IStream &is, UT_SharedPtr< UT_Ramp > &v)
static void loadData(UT_IStream &is, UT_Vector3I &v)
void setTargets(const UT_Array< Targets > &val)
DEP_MicroNode * depnode() const
static void loadData(UT_IStream &is, UT_Matrix4D &v)
LeafData & operator=(const LeafData &)=delete
Utility class for containing a color ramp.
void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override
constexpr SYS_FORCE_INLINE T & w() noexcept
SYS_FORCE_INLINE void append(char character)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr< UT_Ramp > &value) const override
const UT_Array< Targets > & getTargets() const
static void saveData(std::ostream &os, UT_Vector2D v)
fpreal getCookTime() const
static void saveData(std::ostream &os, UT_Vector4D v)
void save(std::ostream &os) const
int64 opTargets_targettype(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
int64 opInputs_inputtype(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override
static void loadData(UT_IStream &is, UT_Vector2I &v)
static void loadData(UT_IStream &is, UT_StringHolder &v)
const char * findChar(int c) const
exint opInputs(const SOP_NodeVerb::CookParms &cookparms) const
UT_StringHolder opTargetDimensionAttribute(const SOP_NodeVerb::CookParms &cookparms) const
void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override
UT_StringHolder targetpointattribute
constexpr SYS_FORCE_INLINE T & y() noexcept
static void loadData(UT_IStream &is, UT_Vector3D &v)
static void loadData(UT_IStream &is, UT_Matrix2D &v)
UT_StringHolder opinstTargets_targetvolumename(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override
static void loadData(UT_IStream &is, UT_Vector4D &v)
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override
constexpr SYS_FORCE_INLINE T & y() noexcept
SYS_FORCE_INLINE bool isstring() const
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr< UT_Ramp > &value) override
exint getNestNumParms(TempIndex idx) const override
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override
const UT_StringHolder & getSerialAttribute() const
void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override
void buildFromOp(const OP_GraphProxy *graph, exint nodeidx, fpreal time, DEP_MicroNode *depnode)
SYS_FORCE_INLINE void strncpy(const char *src, exint maxlen)
void doSetParmValue(TempIndex idx, TempIndex instance, const T &value)
constexpr SYS_FORCE_INLINE T & x() noexcept