34 #include "SOP_MaxPromote.proto.h"
46 using namespace UT::Literal;
47 using namespace HDK_Sample;
58 const UT_StringHolder SOP_MaxPromote::theSOPTypeName(
"hdk_maxpromote"_sh);
67 SOP_MaxPromote::theSOPTypeName,
69 SOP_MaxPromote::myConstructor,
70 SOP_MaxPromote::buildTemplates(),
82 static const char *theDsFile = R
"THEDSFILE(
87 label "Point Attribute"
93 label "Keep Source Attribute"
101 SOP_MaxPromote::buildTemplates()
141 virtual void cook(
const CookParms &cookparms)
const;
155 SOP_MaxPromote::cookVerb()
const
160 template <
typename T>
191 bool first_set =
false;
194 cur_val = source_handle.
get(pt_off);
195 if (!first_set || cur_val > max_val)
210 auto &&sopparms = cookparms.
parms<SOP_MaxPromoteParms>();
217 GA_Attribute * source_attrib = detail->findPointAttribute(attrib_name);
227 bool keep_existing = sopparms.getKeepsource();
241 if (!source_numerical_attrib || source_numerical_attrib->
getTupleSize() != 1)
246 cookparms.
sopAddError(
SOP_MESSAGE,
"Invalid attribute type. Only numerical attributes with one component are supported.");
256 GA_Attribute * out_attrib = detail->getAttributes().cloneAttribute(
271 switch (source_numerical_attrib->
getStorage())
276 sopPromote<int32>(cookparms, *detail, *source_attrib, *out_attrib);
282 sopPromote<int64>(cookparms, *detail, *source_attrib, *out_attrib);
288 sopPromote<fpreal32>(cookparms, *detail, *source_attrib, *out_attrib);
294 sopPromote<fpreal64>(cookparms, *detail, *source_attrib, *out_attrib);
299 cookparms.
sopAddError(
SOP_MESSAGE,
"Invalid attribute storage type. Only 32 and 64 bit integer or floating point attributes are supported.");
307 detail->destroyAttribute(source_attrib->
getOwner(), source_attrib->
getName());
Definition of a geometry attribute.
static PRM_ChoiceList pointAttribReplaceMenu
void setChoiceListPtr(const UT_StringRef &name, PRM_ChoiceList *list)
UT_ErrorSeverity sopAddWarning(int code, const char *msg=0, const UT_SourceLocation *loc=0) const
bool addOperator(OP_Operator *op, std::ostream *err=nullptr)
UT_ErrorSeverity sopAddError(int code, const char *msg=0, const UT_SourceLocation *loc=0) const
SYS_FORCE_INLINE const UT_StringHolder & getName() const
GA_Range getPointRange(const GA_PointGroup *group=0) const
Get a range of all points in the detail.
Constructs a PRM_Template list from an embedded .ds file or an istream.
PRM_Template * templates() const
static SYS_FORCE_INLINE GA_ATINumeric * cast(GA_Attribute *attrib)
SYS_FORCE_INLINE T get(GA_Offset off, int comp=0) const
SYS_FORCE_INLINE bool isInvalid() const
GLenum GLenum GLsizei void * table
GA_API const UT_StringHolder parms
SYS_FORCE_INLINE void set(GA_Offset off, const T &val) const
SYS_FORCE_INLINE GA_AttributeOwner getOwner() const
GU_DetailHandle & gdh() const
The initial state of gdh depends on the cookMode()
GA_Storage getStorage() const