HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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  virtual ~SOP_AttribComp();
33 
34  virtual void syncNodeVersion(const char *old_version,
35  const char *current_version,
36  bool *node_deleted) override;
37  static OP_Node *myConstructor(OP_Network *net, const char *name,
38  OP_Operator *entry);
39 
40  void setSelectionOverride(bool selection_override);
41  void setBlendValue(int i, float value, fpreal t);
42  void setBlendAlias(int i, const char *alias);
43  void removeBlend(int i);
44 
45  static PRM_Template myTemplateList[];
46 
47  const SOP_NodeVerb *cookVerb() const override;
48 
49 protected:
50  virtual const char *inputLabel(unsigned) const override;
51  virtual bool updateParmsFlags() override;
52 
53  virtual OP_ERROR cookInputGroups(OP_Context &context,
54  int alone = 0) override;
55  virtual OP_ERROR cookMySop(OP_Context &context) override;
56 
57 private:
58  static void buildAlphaMenu(void *data, PRM_Name *entries, int size,
59  const PRM_SpareData *, const PRM_Parm *);
60 
61  void setNBLENDS(int n)
62  { setInt( "nblends", 0, 0, n); }
63  int SELECTIONIDX(void)
64  { return evalInt("selectionidx", 0, 0); }
65  int DETAILATTRIBCOMP()
66  { return evalInt( "detailattribs", 0, 0); }
67  void DETAILATTRIBS(UT_String &str)
68  { evalString(str, "detailattriblist", 0, 0);
69  str.harden();
70  str.trimSpace(true);
71  }
72  int PRIMATTRIBCOMP()
73  { return evalInt( "primitiveattribs", 0, 0); }
74  void PRIMATTRIBS(UT_String &str)
75  { evalString(str, "primattriblist", 0, 0);
76  str.harden();
77  str.trimSpace(true);
78  }
79  int PTATTRIBCOMP()
80  { return evalInt( "pointattribs", 0, 0); }
81  void PTATTRIBS(UT_String &str)
82  { evalString(str, "pointattriblist", 0, 0);
83  str.harden();
84  str.trimSpace(true);
85  }
86  int VTXATTRIBCOMP()
87  { return evalInt( "vertexattribs", 0, 0); }
88  void VTXATTRIBS(UT_String &str)
89  { evalString(str, "vertexattriblist", 0, 0);
90  str.harden();
91  str.trimSpace(true);
92  }
93  int MATCHPATTRIB()
94  { return evalInt("matchpattrib", 0, 0); }
95  int NBLENDS()
96  { return evalInt( "nblends", 0, 0); }
97  float BLEND(int i, fpreal t)
98  { return evalFloatInst("blend#", &i, 0, t); }
99 
100  void ALPHAATTRIB(UT_String &str)
101  { evalString(str, "alphaattrib", 0, 0); }
102  int COMPOP()
103  { return evalInt( "compop", 0, 0); }
104 
105  static PRM_ChoiceList ourAlphaAttribMenu;
106 };
107 
108 
110 {
111 public:
113  virtual ~SOP_AttribCompositeCache();
114 
115 protected:
116  virtual OP_ERROR cook(OP_Context &context) override;
117 
118 
119  void parseMySop(
120  UT_ValArray<GA_Attribute *> &detailattribs,
121  UT_ValArray<GA_Attribute *> &primattribs,
122  UT_ValArray<GA_Attribute *> &pointattribs,
123  UT_ValArray<GA_Attribute *> &vertexattribs);
124  bool verifyGeometries(void);
125  void verifyAttribsExist(UT_ValArray<GA_Attribute *> &attribs,
126  GA_AttributeOwner owner);
127  void setupOpFN(void);
128  void setupWeights(int numWeights, fpreal t);
129  void setAlphaAttrib(GA_AttributeOwner owner,
130  UT_Array<GA_ROHandleR> &alphaattribs,
131  const UT_String &alpha);
132  GA_Attribute * createAttrib(GA_Attribute *destattrib,
133  UT_ValArray<UT_IntArray *> &new_indices);
134  void compAttrib(
135  GA_AttributeOwner owner,
136  GA_Attribute *destattrib,
137  const UT_Array<GA_ROHandleR> &alphaattribs,
138  const UT_ValArray<UT_IntArray *> &new_indices,
139  const UT_Array<GA_Offset> &arrsrcoffsets,
140  GA_Offset destoffset, int compop);
141  void compGrpAttribs(
142  UT_ValArray<GA_Attribute *> &detailattribs,
143  UT_ValArray<GA_Attribute *> &primattribs,
144  UT_ValArray<GA_Attribute *> &pointattribs,
145  UT_ValArray<GA_Attribute *> &vertexattribs);
146 
147 
148  int SELECTIONIDX(void)
149  { return evalInt("selectionidx", 0, 0); }
151  { return evalInt( "detailattribs", 0, 0); }
153  { evalString(str, "detailattriblist", 0, 0);
154  str.harden();
155  str.trimSpace(true);
156  }
158  { return evalInt( "primitiveattribs", 0, 0); }
160  { evalString(str, "primattriblist", 0, 0);
161  str.harden();
162  str.trimSpace(true);
163  }
165  { return evalInt( "pointattribs", 0, 0); }
166  void PTATTRIBS(UT_String &str)
167  { evalString(str, "pointattriblist", 0, 0);
168  str.harden();
169  str.trimSpace(true);
170  }
172  { return evalInt( "vertexattribs", 0, 0); }
174  { evalString(str, "vertexattriblist", 0, 0);
175  str.harden();
176  str.trimSpace(true);
177  }
179  { return evalInt("matchpattrib", 0, 0); }
180  int NBLENDS()
181  { return evalInt( "nblends", 0, 0); }
182  float BLEND(int i, fpreal t)
183  { return evalFloatInst("blend#", &i, 0, t); }
184 
186  { evalString(str, "alphaattrib", 0, 0); }
187  int COMPOP()
188  { return evalInt( "compop", 0, 0); }
189 
193  void (*myOpFN)(fpreal, fpreal*, fpreal);
196 };
197 
198 #endif
Definition of a geometry attribute.
Definition: GA_Attribute.h:189
virtual bool updateParmsFlags()
virtual const SOP_NodeVerb * cookVerb() const
Definition: SOP_Node.h:889
fpreal evalFloatInst(const char *parm, const int *instance, int vi, fpreal time, int nestlevel=1) const
fpreal evalFloatInst(const char *name, const int *inst, int vi, fpreal t, int nestlevel=1) const
virtual void syncNodeVersion(const char *old_version, const char *current_version, bool *node_deleted)
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
virtual const char * inputLabel(unsigned idx) const
UT_ErrorSeverity
Definition: UT_Error.h:25
void VTXATTRIBS(UT_String &str)
void ALPHAATTRIB(UT_String &str)
png_uint_32 i
Definition: png.h:2877
GLsizeiptr size
Definition: glcorearb.h:663
GA_Size GA_Offset
Definition: GA_Types.h:617
GLdouble n
Definition: glcorearb.h:2007
exint evalInt(const char *parm, int vi, fpreal time) const
int64 exint
Definition: SYS_Types.h:115
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:213
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:111
GLboolean * data
Definition: glcorearb.h:130
GLuint const GLchar * name
Definition: glcorearb.h:785
virtual OP_ERROR cookInputGroups(OP_Context &context, int alone=0)
void PRIMATTRIBS(UT_String &str)
virtual OP_ERROR cook(OP_Context &context)=0
void PTATTRIBS(UT_String &str)
GLsizei const GLfloat * value
Definition: glcorearb.h:823
GA_AttributeOwner
Definition: GA_Types.h:33
double fpreal
Definition: SYS_Types.h:269
png_infop png_sPLT_tpp entries
Definition: png.h:2481
int trimSpace(bool leaveSingleSpaceBetweenWords=false)
void setInt(int parmi, int vectori, fpreal t, exint value)
UT_Array< const GU_Detail * > mySrcGdps
#define SOP_API
Definition: SOP_API.h:10
exint evalInt(int pi, int vi, fpreal t) const
virtual OP_ERROR cookMySop(OP_Context &context)=0
UT_Array< const GA_Attribute * > mySrcAttributes