HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_AttribComposite.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: SOP Library (C++)
7  *
8  * COMMENTS: SOP which composites attributes from two or more geometries
9  *
10  */
11 
12 #ifndef __SOP_AttribComp_h__
13 #define __SOP_AttribComp_h__
14 
15 #include "SOP_API.h"
16 class GA_Primitive;
17 class GD_Primitive;
18 
19 #include "SOP_Node.h"
20 #include "SOP_NodeParmsOptions.h"
21 
22 #include <GA/GA_Types.h>
23 
24 #include <UT/UT_ValArray.h>
25 #include <UT/UT_Array.h>
26 
28 {
29 public:
30  SOP_AttribComp(OP_Network *net, const char *name,
31  OP_Operator *entry);
32 
33  void syncNodeVersion(const char *old_version,
34  const char *current_version,
35  bool *node_deleted) override;
36  static OP_Node *myConstructor(OP_Network *net, const char *name,
37  OP_Operator *entry);
38 
39  void setSelectionOverride(bool selection_override);
40  void setBlendValue(int i, float value, fpreal t);
41  void setBlendAlias(int i, const char *alias);
42  void removeBlend(int i);
43 
44  static PRM_Template myTemplateList[];
45 
46  const SOP_NodeVerb *cookVerb() const override;
47 
48 protected:
49  const char *inputLabel(unsigned) const override;
50  bool updateParmsFlags() override;
51 
53  int alone = 0) override;
54  OP_ERROR cookMySop(OP_Context &context) override;
55 
56 private:
57  static void buildAlphaMenu(void *data, PRM_Name *entries, int size,
58  const PRM_SpareData *, const PRM_Parm *);
59 
60  void setNBLENDS(int n)
61  { setInt( "nblends", 0, 0, n); }
62  int SELECTIONIDX()
63  { return evalInt("selectionidx", 0, 0); }
64  int DETAILATTRIBCOMP()
65  { return evalInt( "detailattribs", 0, 0); }
66  void DETAILATTRIBS(UT_String &str)
67  { evalString(str, "detailattriblist", 0, 0);
68  str.harden();
69  str.trimSpace(true);
70  }
71  int PRIMATTRIBCOMP()
72  { return evalInt( "primitiveattribs", 0, 0); }
73  void PRIMATTRIBS(UT_String &str)
74  { evalString(str, "primattriblist", 0, 0);
75  str.harden();
76  str.trimSpace(true);
77  }
78  int PTATTRIBCOMP()
79  { return evalInt( "pointattribs", 0, 0); }
80  void PTATTRIBS(UT_String &str)
81  { evalString(str, "pointattriblist", 0, 0);
82  str.harden();
83  str.trimSpace(true);
84  }
85  int VTXATTRIBCOMP()
86  { return evalInt( "vertexattribs", 0, 0); }
87  void VTXATTRIBS(UT_String &str)
88  { evalString(str, "vertexattriblist", 0, 0);
89  str.harden();
90  str.trimSpace(true);
91  }
92  int MATCHPATTRIB()
93  { return evalInt("matchpattrib", 0, 0); }
94  int NBLENDS()
95  { return evalInt( "nblends", 0, 0); }
96  float BLEND(int i, fpreal t)
97  { return evalFloatInst("blend#", &i, 0, t); }
98 
99  void ALPHAATTRIB(UT_String &str)
100  { evalString(str, "alphaattrib", 0, 0); }
101  int COMPOP()
102  { return evalInt( "compop", 0, 0); }
103 
104  static PRM_ChoiceList ourAlphaAttribMenu;
105 };
106 
107 
109 {
110 public:
112 
113 protected:
114  OP_ERROR cook(OP_Context &context) override;
115 
116 
117  void parseMySop(
118  UT_ValArray<GA_Attribute *> &detailattribs,
119  UT_ValArray<GA_Attribute *> &primattribs,
120  UT_ValArray<GA_Attribute *> &pointattribs,
121  UT_ValArray<GA_Attribute *> &vertexattribs);
122  bool verifyGeometries();
123  void verifyAttribsExist(UT_ValArray<GA_Attribute *> &attribs,
124  GA_AttributeOwner owner);
125  void setupOpFN();
126  void setupWeights(int numWeights, fpreal t);
127  void setAlphaAttrib(GA_AttributeOwner owner,
128  UT_Array<GA_ROHandleR> &alphaattribs,
129  const UT_String &alpha);
130  GA_Attribute * createAttrib(GA_Attribute *destattrib,
131  UT_ValArray<UT_IntArray *> &new_indices);
132  void compAttrib(
133  GA_AttributeOwner owner,
134  GA_Attribute *destattrib,
135  const UT_Array<GA_ROHandleR> &alphaattribs,
136  const UT_ValArray<UT_IntArray *> &new_indices,
137  const UT_Array<GA_Offset> &arrsrcoffsets,
138  GA_Offset destoffset, int compop);
139  void compGrpAttribs(
140  UT_ValArray<GA_Attribute *> &detailattribs,
141  UT_ValArray<GA_Attribute *> &primattribs,
142  UT_ValArray<GA_Attribute *> &pointattribs,
143  UT_ValArray<GA_Attribute *> &vertexattribs);
144 
145 
147  { return evalInt("selectionidx", 0, 0); }
149  { return evalInt( "detailattribs", 0, 0); }
151  { evalString(str, "detailattriblist", 0, 0);
152  str.harden();
153  str.trimSpace(true);
154  }
156  { return evalInt( "primitiveattribs", 0, 0); }
158  { evalString(str, "primattriblist", 0, 0);
159  str.harden();
160  str.trimSpace(true);
161  }
163  { return evalInt( "pointattribs", 0, 0); }
164  void PTATTRIBS(UT_String &str)
165  { evalString(str, "pointattriblist", 0, 0);
166  str.harden();
167  str.trimSpace(true);
168  }
170  { return evalInt( "vertexattribs", 0, 0); }
172  { evalString(str, "vertexattriblist", 0, 0);
173  str.harden();
174  str.trimSpace(true);
175  }
177  { return evalInt("matchpattrib", 0, 0); }
178  int NBLENDS()
179  { return evalInt( "nblends", 0, 0); }
180  float BLEND(int i, fpreal t)
181  { return evalFloatInst("blend#", &i, 0, t); }
182 
184  { evalString(str, "alphaattrib", 0, 0); }
185  int COMPOP()
186  { return evalInt( "compop", 0, 0); }
187 
191  void (*myOpFN)(fpreal, fpreal*, fpreal);
194 };
195 
196 #endif
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
virtual bool updateParmsFlags()
virtual const SOP_NodeVerb * cookVerb() const
Definition: SOP_Node.h:906
void syncNodeVersion(const char *old_version, const char *current_version, bool *node_deleted) override
fpreal evalFloatInst(const char *parm, const int *instance, int vi, fpreal time, int nestlevel=1) const
void
Definition: png.h:1083
int trimSpace(bool leave_single_space_between_words=false)
virtual const char * inputLabel(unsigned idx) const
int64 exint
Definition: SYS_Types.h:125
UT_ErrorSeverity
Definition: UT_Error.h:25
void VTXATTRIBS(UT_String &str)
void ALPHAATTRIB(UT_String &str)
GA_Size GA_Offset
Definition: GA_Types.h:641
GLdouble n
Definition: glcorearb.h:2008
exint evalInt(const char *parm, int vi, fpreal time) const
void evalString(UT_String &val, int pi, int vi, fpreal t) const
void harden()
Take shallow copy and make it deep.
Definition: UT_String.h:215
void DETAILATTRIBS(UT_String &str)
float BLEND(int i, fpreal t)
void evalString(UT_String &value, const char *parm, int vi, fpreal time) const
GLfloat GLfloat GLfloat alpha
Definition: glcorearb.h:112
fpreal evalFloatInst(const UT_StringRef &name, const int *inst, int vi, fpreal t, int nestlevel=1) const
GLuint const GLchar * name
Definition: glcorearb.h:786
virtual OP_ERROR cookInputGroups(OP_Context &context, int alone=0)
void PRIMATTRIBS(UT_String &str)
GLdouble t
Definition: glad.h:2397
virtual OP_ERROR cook(OP_Context &context)=0
void PTATTRIBS(UT_String &str)
GLsizeiptr size
Definition: glcorearb.h:664
GA_AttributeOwner
Definition: GA_Types.h:34
fpreal64 fpreal
Definition: SYS_Types.h:277
void setInt(int parmi, int vectori, fpreal t, exint value)
UT_Array< const GU_Detail * > mySrcGdps
#define SOP_API
Definition: SOP_API.h:10
Definition: core.h:1131
exint evalInt(int pi, int vi, fpreal t) const
virtual OP_ERROR cookMySop(OP_Context &context)=0
Definition: format.h:895
UT_Array< const GA_Attribute * > mySrcAttributes