36 control_attrib =
"P"_UTsh;
60 for (
int i = 0; i < list.
entries(); i++)
81 myClusterAttrib =
"cluster"_UTsh;
82 myOutputCenter =
false;
83 myControls.setSize(1);
86 myThresholdAttrib =
""_UTsh;
87 myThresholdWeight = 10;
88 myInitialThreshold = 1;
89 myFinalThreshold = 0.25;
104 if (myNumClusters != src.myNumClusters)
return false;
105 if (myClusterAttrib != src.myClusterAttrib)
return false;
106 if (myOutputCenter != src.myOutputCenter)
return false;
107 if (myControls != src.myControls)
return false;
108 if (myIterations != src.myIterations)
return false;
109 if (myRandomSeed != src.myRandomSeed)
return false;
110 if (myThresholdAttrib != src.myThresholdAttrib)
return false;
111 if (myThresholdWeight != src.myThresholdWeight)
return false;
112 if (myInitialThreshold != src.myInitialThreshold)
return false;
113 if (myFinalThreshold != src.myFinalThreshold)
return false;
114 if (myUseLInf != src.myUseLInf)
return false;
115 if (myKMeanPP != src.myKMeanPP)
return false;
129 if (
true && ( (
true&&!((((graph->
getInput(nodeidx,1)>=0)==1)))) ) )
130 graph->
evalOpParm(myNumClusters, nodeidx,
"num_clusters", time, 0);
131 myClusterAttrib =
"cluster"_UTsh;
133 graph->
evalOpParm(myClusterAttrib, nodeidx,
"cluster_attrib", time, 0);
134 myOutputCenter =
false;
135 if (
true && ( (
true&&!((((graph->
getInput(nodeidx,1)>=0)==1)))) ) )
136 graph->
evalOpParm(myOutputCenter, nodeidx,
"output_center", time, 0);
140 graph->
evalOpParm(length, nodeidx,
"num_controls", time, 0);
141 if (length < 0) length = 0;
142 myControls.setSize(length);
149 auto && _curentry = myControls(i);
151 _curentry.control_attrib =
"P"_UTsh;
153 graph->
evalOpParmInst(_curentry.control_attrib, nodeidx,
"control_attrib#", parmidx, offsets, time, 0, 2-1);
154 _curentry.control_weight = 1;
156 graph->
evalOpParmInst(_curentry.control_weight, nodeidx,
"control_weight#", parmidx, offsets, time, 0, 2-1);
163 if (
true && ( (
true&&!((((graph->
getInput(nodeidx,1)>=0)==1)))) ) )
164 graph->
evalOpParm(myIterations, nodeidx,
"iterations", time, 0);
166 if (
true && ( (
true&&!((((graph->
getInput(nodeidx,1)>=0)==1)))) ) )
167 graph->
evalOpParm(myRandomSeed, nodeidx,
"random_seed", time, 0);
168 myThresholdAttrib =
""_UTsh;
170 graph->
evalOpParm(myThresholdAttrib, nodeidx,
"threshold_attrib", time, 0);
171 myThresholdWeight = 10;
172 if (
true && ( (
true&&!(((getThresholdAttrib()==
"")))) ) )
173 graph->
evalOpParm(myThresholdWeight, nodeidx,
"threshold_weight", time, 0);
174 myInitialThreshold = 1;
175 if (
true && ( (
true&&!(((getThresholdAttrib()==
"")))) ) )
176 graph->
evalOpParm(myInitialThreshold, nodeidx,
"initial_threshold", time, 0);
177 myFinalThreshold = 0.25;
178 if (
true && ( (
true&&!(((getThresholdAttrib()==
"")))) ) )
179 graph->
evalOpParm(myFinalThreshold, nodeidx,
"final_threshold", time, 0);
182 graph->
evalOpParm(myUseLInf, nodeidx,
"use_linf", time, 0);
184 if (
true && ( (
true&&!((((graph->
getInput(nodeidx,1)>=0)==1)))) ) )
185 graph->
evalOpParm(myKMeanPP, nodeidx,
"kmeanpp", time, 0);
201 template <
typename T>
208 if (idx.
size() != instance.
size()+1)
224 else if (instance[0] < myControls.entries())
226 auto && _data = myControls(instance[0]);
277 { doGetParmValue(idx, instance, value); }
279 { doGetParmValue(idx, instance, value); }
281 { doGetParmValue(idx, instance, value); }
283 { doGetParmValue(idx, instance, value); }
285 { doGetParmValue(idx, instance, value); }
287 { doGetParmValue(idx, instance, value); }
289 { doGetParmValue(idx, instance, value); }
291 { doGetParmValue(idx, instance, value); }
293 { doGetParmValue(idx, instance, value); }
295 { doGetParmValue(idx, instance, value); }
297 { doGetParmValue(idx, instance, value); }
299 template <
typename T>
306 if (idx.
size() != instance.
size()+1)
324 if (newsize < 0) newsize = 0;
325 myControls.setSize(newsize);
331 myControls.setSizeIfNeeded(instance[0]+1);
332 auto && _data = myControls(instance[0]);
374 { doSetParmValue(idx, instance, value); }
376 { doSetParmValue(idx, instance, value); }
378 { doSetParmValue(idx, instance, value); }
380 { doSetParmValue(idx, instance, value); }
382 { doSetParmValue(idx, instance, value); }
384 { doSetParmValue(idx, instance, value); }
386 { doSetParmValue(idx, instance, value); }
388 { doSetParmValue(idx, instance, value); }
390 { doSetParmValue(idx, instance, value); }
392 { doSetParmValue(idx, instance, value); }
394 { doSetParmValue(idx, instance, value); }
412 if (fieldnum.
size() < 1)
417 return "num_clusters";
419 return "cluster_attrib";
421 return "output_center";
423 if (fieldnum.
size() == 1)
424 return "num_controls";
428 return "control_attrib#";
430 return "control_weight#";
437 return "random_seed";
439 return "threshold_attrib";
441 return "threshold_weight";
443 return "initial_threshold";
445 return "final_threshold";
457 if (fieldnum.
size() < 1)
458 return PARM_UNSUPPORTED;
468 if (fieldnum.
size() == 1)
469 return PARM_MULTIPARM;
533 loadData(is, rampdata);
551 int typelen = colon - data.
buffer();
565 {
int64 iv =
v; UTwrite(os, &iv); }
567 { UTwrite<fpreal64>(os, &
v); }
569 { UTwrite<fpreal64>(os, &v.
x()); UTwrite<fpreal64>(os, &v.
y()); }
571 { UTwrite<fpreal64>(os, &v.
x()); UTwrite<fpreal64>(os, &v.
y());
572 UTwrite<fpreal64>(os, &v.
z()); }
574 { UTwrite<fpreal64>(os, &v.
x()); UTwrite<fpreal64>(os, &v.
y());
575 UTwrite<fpreal64>(os, &v.
z()); UTwrite<fpreal64>(os, &v.
w()); }
587 if (s) s->save(ostr);
589 saveData(os, result);
596 ostr << s->getDataTypeToken();
601 saveData(os, result);
605 void save(std::ostream &os)
const
609 saveData(os, myNumClusters);
610 saveData(os, myClusterAttrib);
611 saveData(os, myOutputCenter);
614 UTwrite(os, &length);
617 auto && _curentry = myControls(i);
619 saveData(os, _curentry.control_attrib);
620 saveData(os, _curentry.control_weight);
624 saveData(os, myIterations);
625 saveData(os, myRandomSeed);
626 saveData(os, myThresholdAttrib);
627 saveData(os, myThresholdWeight);
628 saveData(os, myInitialThreshold);
629 saveData(os, myFinalThreshold);
630 saveData(os, myUseLInf);
631 saveData(os, myKMeanPP);
644 loadData(is, myNumClusters);
645 loadData(is, myClusterAttrib);
646 loadData(is, myOutputCenter);
650 myControls.setSize(length);
653 auto && _curentry = myControls(i);
655 loadData(is, _curentry.control_attrib);
656 loadData(is, _curentry.control_weight);
660 loadData(is, myIterations);
661 loadData(is, myRandomSeed);
662 loadData(is, myThresholdAttrib);
663 loadData(is, myThresholdWeight);
664 loadData(is, myInitialThreshold);
665 loadData(is, myFinalThreshold);
666 loadData(is, myUseLInf);
667 loadData(is, myKMeanPP);
677 if (!thissop)
return getNumClusters();
679 OP_Utils::evalOpParm(result, thissop,
"num_clusters", cookparms.
getCookTime(), 0);
687 if (!thissop)
return getClusterAttrib();
689 OP_Utils::evalOpParm(result, thissop,
"cluster_attrib", cookparms.
getCookTime(), 0);
697 if (!thissop)
return getOutputCenter();
699 OP_Utils::evalOpParm(result, thissop,
"output_center", cookparms.
getCookTime(), 0);
707 if (!thissop)
return getControls().entries();
709 OP_Utils::evalOpParm(result, thissop,
"num_controls", cookparms.
getCookTime(), 0);
713 {
return opinstControls_control_attrib(cookparms, &_idx); }
717 if (!thissop)
return (myControls(_idx[0]).control_attrib);
719 _parmidx[1-1] = _idx[1-1] + 1;
722 OP_Utils::evalOpParmInst(result, thissop,
"control_attrib#", _parmidx, cookparms.
getCookTime(), 0, 2-1);
726 {
return opinstControls_control_weight(cookparms, &_idx); }
730 if (!thissop)
return (myControls(_idx[0]).control_weight);
732 _parmidx[1-1] = _idx[1-1] + 1;
735 OP_Utils::evalOpParmInst(result, thissop,
"control_weight#", _parmidx, cookparms.
getCookTime(), 0, 2-1);
744 if (!thissop)
return getIterations();
746 OP_Utils::evalOpParm(result, thissop,
"iterations", cookparms.
getCookTime(), 0);
754 if (!thissop)
return getRandomSeed();
756 OP_Utils::evalOpParm(result, thissop,
"random_seed", cookparms.
getCookTime(), 0);
764 if (!thissop)
return getThresholdAttrib();
766 OP_Utils::evalOpParm(result, thissop,
"threshold_attrib", cookparms.
getCookTime(), 0);
774 if (!thissop)
return getThresholdWeight();
776 OP_Utils::evalOpParm(result, thissop,
"threshold_weight", cookparms.
getCookTime(), 0);
784 if (!thissop)
return getInitialThreshold();
786 OP_Utils::evalOpParm(result, thissop,
"initial_threshold", cookparms.
getCookTime(), 0);
794 if (!thissop)
return getFinalThreshold();
796 OP_Utils::evalOpParm(result, thissop,
"final_threshold", cookparms.
getCookTime(), 0);
804 if (!thissop)
return getUseLInf();
806 OP_Utils::evalOpParm(result, thissop,
"use_linf", cookparms.
getCookTime(), 0);
814 if (!thissop)
return getKMeanPP();
816 OP_Utils::evalOpParm(result, thissop,
"kmeanpp", cookparms.
getCookTime(), 0);
void setIterations(int64 val)
void setClusterAttrib(const UT_StringHolder &val)
fpreal64 opinstControls_control_weight(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
GLenum GLuint GLenum GLsizei const GLchar * buf
static void loadData(UT_IStream &is, UT_Vector4I &v)
fpreal64 opFinalThreshold(const SOP_NodeVerb::CookParms &cookparms) const
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector2D &value) override
UT_StringHolder createString(const UT_Array< Controls > &list) const
SOP_Node * getNode() const
bool opKMeanPP(const SOP_NodeVerb::CookParms &cookparms) const
static void loadData(UT_IStream &is, UT_Vector4D &v)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix2D &value) const override
UT_StringHolder opThresholdAttrib(const SOP_NodeVerb::CookParms &cookparms) const
exint bread(int32 *buffer, exint asize=1)
GT_API const UT_StringHolder time
constexpr SYS_FORCE_INLINE T & y() noexcept
int64 getRandomSeed() const
static void loadData(UT_IStream &is, UT_Vector2D &v)
static void saveData(std::ostream &os, PRM_DataItemHandle s)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_SharedPtr< UT_Ramp > &value) override
void setNestParmValue(TempIndex idx, TempIndex instance, const fpreal &value) override
static void saveData(std::ostream &os, int64 v)
UT_String makeQuotedString(char delimiter='\'', bool escape_nonprinting=false) const
void setKMeanPP(bool val)
static void loadData(UT_IStream &is, UT_Vector3I &v)
const OP_Context & context() const
void getNestParmValue(TempIndex idx, TempIndex instance, fpreal &value) const override
constexpr SYS_FORCE_INLINE T & z() noexcept
SYS_FORCE_INLINE const char * buffer() const
static void loadData(UT_IStream &is, fpreal64 &v)
ParmType getNestParmType(TempIndex fieldnum) const override
GLuint GLsizei GLsizei * length
An output stream object that owns its own string buffer storage.
fpreal64 opControls_control_weight(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
static void saveData(std::ostream &os, UT_Vector3D v)
void setControls(const UT_Array< Controls > &val)
void copyFrom(const OP_NodeParms *src) override
**But if you need a result
T clampMinValue(fpreal minvalue, const T &src) const
void save(std::ostream &os) const
int64 opIterations(const SOP_NodeVerb::CookParms &cookparms) 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
virtual NodeIdx getInput(NodeIdx idx, int input, bool markused=false) const =0
constexpr SYS_FORCE_INLINE T & x() noexcept
fpreal64 getInitialThreshold() const
static void loadData(UT_IStream &is, UT_Vector3D &v)
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Vector4D &value) override
GLuint GLsizei const GLuint const GLintptr * offsets
const UT_Array< Controls > & getControls() const
constexpr SYS_FORCE_INLINE T & x() noexcept
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)
bool isParmColorRamp(exint idx) const override
void setThresholdWeight(fpreal64 val)
void setRandomSeed(int64 val)
bool operator==(const Controls &src) 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.
constexpr SYS_FORCE_INLINE T & z() noexcept
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)
const OP_GraphProxy * graph() const
void setNestParmValue(TempIndex idx, TempIndex instance, const PRM_DataItemHandle &value) override
void setOutputCenter(bool val)
virtual void evalOpParmInst(int64 &v, NodeIdx node, const char *parmname, const int *inst, const int *offsets, fpreal time, DEP_MicroNode *depnode, int nestlevel=1) const =0
void setUseLInf(bool val)
static void loadData(UT_IStream &is, bool &v)
static void loadData(UT_IStream &is, UT_Matrix3D &v)
bool operator!=(const Controls &src) const
static void saveData(std::ostream &os, UT_StringHolder s)
virtual void evalOpParm(int64 &v, NodeIdx node, const char *parmname, fpreal time, DEP_MicroNode *depnode) const =0
void doGetParmValue(TempIndex idx, TempIndex instance, T &value) const
static void saveData(std::ostream &os, UT_Matrix2D v)
void buildFromOp(const OP_GraphProxy *graph, exint nodeidx, fpreal time, DEP_MicroNode *depnode)
SYS_FORCE_INLINE void strcat(const char *src)
void saveBinary(std::ostream &os) const
Save string to binary stream.
GT_API const UT_StringHolder version
exint entries() const
Alias of size(). size() is preferred.
exint opControls(const SOP_NodeVerb::CookParms &cookparms) const
UT_StringHolder opControls_control_attrib(const SOP_NodeVerb::CookParms &cookparms, int _idx) const
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_StringHolder &value) override
int int appendSprintf(const char *fmt,...) SYS_PRINTF_CHECK_ATTRIBUTE(2
static void loadData(UT_IStream &is, UT_StringHolder &v)
void coerceValue(T &result, const S &src) const
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)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix3D &value) const override
DEP_MicroNode * depnode() const
Utility class for containing a color ramp.
exint getNestNumParms(TempIndex idx) const override
constexpr SYS_FORCE_INLINE T & w() noexcept
SYS_FORCE_INLINE void append(char character)
UT_StringHolder opinstControls_control_attrib(const SOP_NodeVerb::CookParms &cookparms, const int *_idx) const
void getNestParmValue(TempIndex idx, TempIndex instance, exint &value) const override
void setInitialThreshold(fpreal64 val)
fpreal getCookTime() const
void setThresholdAttrib(const UT_StringHolder &val)
static void saveData(std::ostream &os, UT_Vector2D v)
fpreal64 opThresholdWeight(const SOP_NodeVerb::CookParms &cookparms) const
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector2D &value) const override
const UT_StringHolder & getClusterAttrib() const
void setFinalThreshold(fpreal64 val)
bool opOutputCenter(const SOP_NodeVerb::CookParms &cookparms) const
const char * findChar(int c) const
int64 opRandomSeed(const SOP_NodeVerb::CookParms &cookparms) const
static void saveData(std::ostream &os, UT_SharedPtr< UT_Ramp > s)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Vector3D &value) const override
void setNumClusters(int64 val)
void setNestParmValue(TempIndex idx, TempIndex instance, const exint &value) override
UT_StringHolder control_attrib
void getNestParmValue(TempIndex idx, TempIndex instance, UT_SharedPtr< UT_Ramp > &value) const override
static void loadData(UT_IStream &is, UT_Matrix2D &v)
constexpr SYS_FORCE_INLINE T & y() noexcept
bool operator==(const SOP_ClusterParms &src) const
static void saveData(std::ostream &os, bool v)
static void saveData(std::ostream &os, UT_Matrix4D v)
static void loadData(UT_IStream &is, int64 &v)
UT_StringHolder opClusterAttrib(const SOP_NodeVerb::CookParms &cookparms) const
fpreal64 opInitialThreshold(const SOP_NodeVerb::CookParms &cookparms) const
int64 opNumClusters(const SOP_NodeVerb::CookParms &cookparms) const
void doSetParmValue(TempIndex idx, TempIndex instance, const T &value)
UT_SharedPtr< const PRM_DataItem > PRM_DataItemHandle
static void loadData(UT_IStream &is, UT_Matrix4D &v)
void getNestParmValue(TempIndex idx, TempIndex instance, UT_Matrix4D &value) const override
void setNestParmValue(TempIndex idx, TempIndex instance, const UT_Matrix4D &value) override
constexpr SYS_FORCE_INLINE T & y() noexcept
SYS_FORCE_INLINE bool isstring() const
OP_NodeParms & operator=(const OP_NodeParms &)=default
SYS_FORCE_INLINE void strncpy(const char *src, exint maxlen)
bool getOutputCenter() const
constexpr SYS_FORCE_INLINE T & x() noexcept
fpreal64 getThresholdWeight() const