30 #include "SOP_SplitPointsHDK.proto.h"
42 using namespace UT::Literal;
44 namespace HDK_Sample {
61 virtual void cook(
const CookParms &cookparms)
const;
77 const UT_StringHolder SOP_SplitPointsHDKVerb::theSOPTypeName(
"hdk_splitpoints"_sh);
93 static void buildAttribMenu(
103 using namespace SOP_SplitPointsHDKEnums;
104 switch (parmgrouptype)
116 SOP_SplitPointsHDK::buildAttribMenu(
130 SOP_SplitPointsHDK::buildAttribMenu);
133 SOP_SplitPointsHDK::buildTemplates()
135 static PRM_TemplateBuilder templ(
"SOP_SplitPointsHDK.C"_sh, SOP_SplitPointsHDKVerb::theDsFile);
213 namespace HDK_Sample {
228 parmtag { "script_action" "import soputils\nkwargs['geometrytype'] = kwargs['node'].parmTuple('grouptype')\nkwargs['inputindex'] = 0\nsoputils.selectGroupParm(kwargs)" }
229 parmtag { "script_action_help" "Select geometry from an available viewport.\nShift-click to turn on Select Groups." }
230 parmtag { "script_action_icon" "BUTTONS_reselect" }
239 "guess" "Guess from Group"
240 "vertices" "Vertices"
248 label "Limit by Attribute"
260 disablewhen "{ useattrib == 0 }"
268 disablewhen "{ useattrib == 0 }"
272 label "Promote to Point Attribute"
275 disablewhen "{ useattrib == 0 }"
284 auto &&sopparms = cookparms.
parms<SOP_SplitPointsHDKParms>();
293 GA_GroupType grouptype = sopSplitPointsGroupType(sopparms.getGroupType());
309 if (sopparms.getUseAttrib() && sopparms.getAttribName().isstring())
311 fpreal tolerance = sopparms.getTol();
312 const bool promote = sopparms.getPromote();
314 const char *
pattern = sopparms.getAttribName().c_str();
318 auto &&functor = [
pattern,promote,gdp,group,tolerance,&attribsToPromote](
GA_Attribute *attrib)
320 UT_String attribname_string(attrib->getName().c_str());
321 if (!attribname_string.multiMatch(pattern))
330 attribsToPromote.
append(attrib->getName());
336 for (
auto it = gdp->vertexAttribs().obegin(
GA_SCOPE_PUBLIC); !it.atEnd(); ++it)
338 for (
exint i = 0; i < attribsToPromote.
size(); ++i)
344 attribsToPromote.
clear();
346 for (
auto it = gdp->primitiveAttribs().obegin(
GA_SCOPE_PUBLIC); !it.atEnd(); ++it)
348 for (
exint i = 0; i < attribsToPromote.
size(); ++i)
354 attribsToPromote.
clear();
356 for (
auto it = gdp->vertexAttribs().obegin(
GA_SCOPE_GROUP); !it.atEnd(); ++it)
358 for (
exint i = 0; i < attribsToPromote.
size(); ++i)
360 GA_ElementGroup *cur_group = gdp->findVertexGroup(attribsToPromote[i]);
364 attribsToPromote.
clear();
366 for (
auto it = gdp->primitiveAttribs().obegin(
GA_SCOPE_GROUP); !it.atEnd(); ++it)
368 for (
exint i = 0; i < attribsToPromote.
size(); ++i)
370 GA_ElementGroup *cur_group = gdp->findPrimitiveGroup(attribsToPromote[i]);
374 attribsToPromote.
clear();
381 attrib = gdp->primitiveAttribs().find(
GA_SCOPE_PUBLIC, sopparms.getAttribName());
386 attrib = gdp->vertexGroups().find(sopparms.getAttribName());
389 attrib = gdp->primitiveGroups().find(sopparms.getAttribName());
408 else if (!sopparms.getUseAttrib())
Definition of a geometry attribute.
SOP_Node * getNode() const
void setChoiceListPtr(const UT_StringRef &name, PRM_ChoiceList *list)
UT_ErrorSeverity sopAddWarning(int code, const char *msg=0, const UT_SourceLocation *loc=0) const
static PRM_Template * buildTemplates()
virtual ~SOP_SplitPointsHDKVerb()
virtual OP_ERROR cookInputGroups(OP_Context &context, int alone)
const GA_Group * parseGroupDetached(const char *pat, GA_GroupType grouptype, const GEO_Detail *pgdp, bool forceexistence, bool defaultprim, bool &success)
GA_Size GEOsplitPointsByAttrib(GEO_Detail *detail, const GA_ElementGroup *group, const GA_Attribute *attrib, fpreal tolerance)
static const char *const theDsFile
This is the parameter interface string, below.
static const SOP_NodeVerb::Register< SOP_SplitPointsHDKVerb > theVerb
SYS_FORCE_INLINE TO_T UTverify_cast(FROM_T from)
bool addOperator(OP_Operator *op, std::ostream *err=nullptr)
Standard user attribute level.
virtual CookMode cookMode(const SOP_NodeParms *parms) const
static PRM_ChoiceList pointGroupMenu
#define UT_ASSERT_MSG(ZZ,...)
Constructs a PRM_Template list from an embedded .ds file or an istream.
PRM_Template * templates() const
bool isElementGroup() const
OP_ERROR cookMyselfAsVerb(OP_Context &context)
GLuint const GLchar * name
int fillAttribNameMenu(PRM_Name *menu_entries, int max_menu_size, GA_AttributeOwner dictionary, int input_index, bool(*approve)(const GA_Attribute *, void *)=NULL, void *approve_data=NULL, bool decode_tokens=false)
void newSopOperator(OP_OperatorTable *table)
GLenum GLenum GLsizei void * table
void setManagesDataIDs(bool onOff)
static bool multiMatchCheck(const char *pattern)
void notifyGroupParmListeners(SOP_Node *oldsop, int groupparm_idx, int grouptype_idx, const GU_Detail *gdp, const GA_Group *group) const
static const UT_StringHolder theSOPTypeName
virtual const SOP_NodeVerb * cookVerb() const
OP_ERROR cookInputAllGroups(OP_Context &context, const GA_Group *&group, bool alone=false, bool do_selection=true, int parm_index=0, int group_type_index=-1, GA_GroupType grouptype=GA_GROUP_INVALID, bool allow_reference=true, bool is_default_prim=true, bool ordered=false, bool detached=true, int input_index=0)
static OP_Node * myConstructor(OP_Network *net, const char *name, OP_Operator *entry)
GA_GroupType
An ordinal enum for the different types of groups in GA.
virtual ~SOP_SplitPointsHDK()
This is the SOP class definition.
GA_Size GEOsplitPoints(GEO_Detail *detail, const GA_ElementGroup *group)
exint evalInt(int pi, int vi, fpreal t) const
virtual SOP_NodeParms * allocParms() const
void clear()
Resets list to an empty list.
virtual OP_ERROR cookMySop(OP_Context &context)
virtual void cook(const CookParms &cookparms) const
Compute the output geometry.
GU_DetailHandle & gdh() const
The initial state of gdh depends on the cookMode()
SYS_FORCE_INLINE bool isstring() const
virtual UT_StringHolder name() const