HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GU_Pelt.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: GU library (C++)
7  *
8  * COMMENTS: Pelt GU
9  */
10 
11 #ifndef __GU_Pelt_h__
12 #define __GU_Pelt_h__
13 
14 #include "GU_API.h"
15 #include "GU_Detail.h"
16 #include <GEO/GEO_HedgeInterface.h>
17 #include <GA/GA_Edge.h>
18 #include <GA/GA_EdgeGroup.h>
19 #include <UT/UT_UniquePtr.h>
20 
21 enum
22 {
26 };
27 
29 {
31 };
32 
34 {
35 public:
36  // class for the pelt frame point
38  {
39  public:
40  fpreal coord[2];
41  fpreal connectedcoord[2];
42  };
43 
44  // class representing a boundary component of the geometry
46  {
49 
50  int entries;
52  int comp;
53 
55  {
56  length = 0;
57  entries = 0;
58  comp = 0;
59  }
60  };
61 
62  // boundary components are sorted by length using this comparator
63  static int Compare(const BoundaryComponent *A,
64  const BoundaryComponent *B)
65  {
66  int r = 0;
67  if (A->length < B->length) r = 1;
68  if (A->length > B->length) r = -1;
69  return r;
70  }
71 
72  // the structure gathering all parameters from the sop
73  struct Parameters
74  {
75  Parameters(int it, fpreal sc, bool ur, int uf, int vf,
76  fpreal orient, int meth, bool ot, int h, fpreal mnu,
77  fpreal mxu, fpreal mnv, fpreal mxv) :
78  iterations(it), springconstant(sc), userange(ur),
79  ufrom(uf), vfrom(vf), orientation(orient), method(meth),
80  outputtoggle(ot), hintpoly(h), minu(mnu), maxu(mxu),
81  minv(mnv), maxv(mxv)
82  {
83  }
84 
87  bool userange;
88  int ufrom;
89  int vfrom;
91  int method;
93  int hintpoly;
98  };
99 
100  GU_Pelt(GU_Detail *gdp, const GA_EdgeGroup *gp, const GEO_Face *face,
101  UT_String outputgroup, const Parameters &parms)
102  {
103  myGdp = gdp;
104  myFramePointCount = 0;
105  myFace = face;
106  myIterations = parms.iterations;
107  mySpringConstant = parms.springconstant;
108  myUseRange = parms.userange;
109  myUfrom = parms.ufrom;
110  myVfrom = parms.vfrom;
111  myOrientation = parms.orientation;
112  myMethod = (GU_PeltingMethod)parms.method;
113  myOutputToggle = parms.outputtoggle;
114  myOutputGroup = outputgroup;
115  myHintPoly = parms.hintpoly;
116  myMinu = parms.minu;
117  myMaxu = parms.maxu;
118  myMinv = parms.minv;
119  myMaxv = parms.maxv;
120 
121  splitIntoComponents(gp);
122  }
123 
125  {}
126 
127  static void getHintComponent(GU_Detail *gdp, const GA_EdgeGroup *cuts,
128  int hint_prim,
129  GA_PrimitiveGroup *connected_prims);
130 
131  void updateUVs(bool (*callback_func)(void *), void *callback_data,
132  const char *tension_attribute,
133  const char *density_attribute,
134  const GA_RWHandleV3 &uvattrib);
135 
137  {
138  return myFramePointCount;
139  }
140 
142  {
143  return myFramePoints;
144  }
145 
146 private:
147  UT_Array<FramePoint> myFramePoints;
148  int myFramePointCount;
149  GU_Detail *myGdp;
150  // hedge interface attached to the temporary gdp;
152  const GEO_Face *myFace;
153  UT_UniquePtr<GA_EdgeGroup> myCutsGroup;
154  int myCurrentComp;
155  UT_Array<GEO_Hedge> myHintEdges;
156  // hedge interface attached to the temporary gdp;
157  int myFrameBound;
158  // the boundary geometry
159  UT_Array<BoundaryComponent> myBoundary;
160  // Parameters from the SOP
161  int myIterations;
162  fpreal mySpringConstant;
163  bool myUseRange;
164  int myUfrom;
165  int myVfrom;
166  fpreal myOrientation;
167  GU_PeltingMethod myMethod;
168  bool myOutputToggle;
169  UT_String myOutputGroup;
170  int myHintPoly;
171  fpreal myMinu;
172  fpreal myMaxu;
173  fpreal myMinv;
174  fpreal myMaxv;
175 
176  // attach a primitive attribute indicating component index
177  void splitIntoComponents(const GA_EdgeGroup *gp);
178  // returns the primitive group of a given component
179  void getConnectedPrimitives(GU_Detail *gdp,
180  GA_PrimitiveGroup *primitives, int c);
181  // construct a frame using myBoundary array. Chooses the longest
182  // boundary that lies in the hint component
183  void getFrame(GU_Detail *gdp, GA_PointGroup *boundary_points, int c,
184  const char *density_attribute);
185  // fill myBoundary array
186  void getBoundaryComps(GU_Detail *gdp);
187  // create and fill myFramePoints array
188  void createFrame(GU_Detail *gdp,const GA_PointGroup *boundary_points,
189  const char *density_attribute);
190  void remapCoord(UT_Array<FramePoint> &frame, int num_points);
191  // returns the weight of an edge according to the chosen method
192  fpreal getWeight(GEO_Hedge e);
193 
194 };
195 
196 #endif
~GU_Pelt()
Definition: GU_Pelt.h:124
UT_Array< GA_Offset > points
Definition: GU_Pelt.h:48
Parameters(int it, fpreal sc, bool ur, int uf, int vf, fpreal orient, int meth, bool ot, int h, fpreal mnu, fpreal mxu, fpreal mnv, fpreal mxv)
Definition: GU_Pelt.h:75
int getFramePointCount()
Definition: GU_Pelt.h:136
fpreal springconstant
Definition: GU_Pelt.h:86
GEO_Hedge encapsulates a half-edge (hedge) which is the restriction of.
Definition: GEO_Hedge.h:47
int method
Definition: png.h:1924
UT_Array< FramePoint > & getFramePoints()
Definition: GU_Pelt.h:141
#define GU_API
Definition: GU_API.h:11
GA_API const UT_StringHolder orient
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
double fpreal
Definition: SYS_Types.h:263
png_infop png_sPLT_tpp entries
Definition: png.h:2481
GU_Pelt(GU_Detail *gdp, const GA_EdgeGroup *gp, const GEO_Face *face, UT_String outputgroup, const Parameters &parms)
Definition: GU_Pelt.h:100
fpreal orientation
Definition: GU_Pelt.h:90
GLboolean r
Definition: glcorearb.h:1221
GU_PeltingMethod
Definition: GU_Pelt.h:28
UT_Array< GEO_Hedge > hedges
Definition: GU_Pelt.h:47
static int Compare(const BoundaryComponent *A, const BoundaryComponent *B)
Definition: GU_Pelt.h:63
GLuint GLsizei GLsizei * length
Definition: glcorearb.h:794