HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_UVSew.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.
7  *
8  * COMMENTS: This class contains the methods to perform the UV Sew
9  * operation.
10  *
11  */
12 
13 
14 
15 #ifndef __GU_UVSew_h__
16 #define __GU_UVSew_h__
17 
18 #include "GU_API.h"
19 
20 #include <UT/UT_ValArray.h>
21 #include <UT/UT_IntArray.h>
22 #include <UT/UT_Map.h>
23 #include <UT/UT_VectorTypes.h>
24 #include <GA/GA_Handle.h>
25 #include <GEO/GEO_PrimClassifier.h>
26 
27 class UT_BitArray;
28 class GA_EdgeGroup;
29 class GA_Primitive;
30 class GA_VertexGroup;
31 class GEO_Delta;
32 class GEO_Primitive;
33 class GEO_PrimPoly;
35 class GU_Detail;
36 class gu_SuperVertex;
37 class gu_VertexTransform;
38 class gu_ClassEdges;
39 template<typename T, bool B> class GA_EdgeT;
41 
43 {
44 public:
45 
46  GU_UVSew(GU_Detail &gdp, GEO_Delta *geodelta, const GA_RWHandleV3 &uvattrib);
47  ~GU_UVSew();
48 
49  // The sew() method is the workhorse of this class. Given an edge group,
50  // this method will perform the work necessary to sew vertex UV's sharing
51  // the same points.
52  void sew(const GA_EdgeGroup *edge_grp);
53 
54 protected:
55  // Helper method that sews an edge, this time the from and to polygon have
56  // already been resolved. They should both share the given edge.
57  void sew(const GEO_PrimPoly &from_poly,
58  const GEO_PrimPoly &to_poly,
59  GA_Edge &edge);
60 
61  // Fills the supervertex array of the given primitive. After this call
62  // the primitive should have a super vertex assigned to each of its
63  // vertices.
64  void fillSuperVertexArray(const GEO_Primitive &prim);
65 
66  // This method is used to process all the vertices connected
67  // (uv-connectivity) to the super vertex svtx_idx.
68  void processConnectedVertices(int svtx_idx,
69  const UT_Vector2 &translate,
70  float rotation,
71  const UT_Vector2 &scales,
72  const UT_Vector2 &pivot,
73  const UT_Vector3 &p0,
74  const UT_Vector3 &p1);
75 
76  // Returns the index of the supervertex containing vtx on prim.
77  int getSuperVertexIndex(const GA_Primitive &prim,
78  int vtx);
79 
80  // Helper method that adds prim/vtx to the super vertex indexed by svtx_idx.
81  void insertVertexToSuperVertex(int svtx_idx,
82  const GEO_Primitive &prim,
83  int vtx);
84 
85 
86  // Convenience methods for retrieving UV coordinates from vertices and
87  // supervertices.
88  void getVertexUV(const GEO_Primitive &prim,
89  int vtx, UT_Vector3 &uv);
90  bool getSuperVertexUV(int svtx_idx, UT_Vector3 &uv);
91 
92 
93  // Adds the vertices in a super vertex to the given group.
94  void addSuperVertexToGroup(int svtx_idx,
95  GA_VertexGroup &group);
96 
97 
98  // Apply all the accumulated transforms to each super vertex.
99  void applyAndRemoveSuperTransforms();
100 
101 
102  // Convenience methods for appending transforms to supervertices.
103  void transformSuperVertex(int svtx_idx,
104  const UT_Vector2 &translate,
105  float rotation,
106  const UT_Vector2 &scales,
107  const UT_Vector2 &pivots,
108  bool locked,
109  float weight);
110  void translateSuperVertex(int svtx_idx,
111  const UT_Vector2 &translate,
112  bool locked,
113  float weight);
114 
115  // Returns the list of super vertices that are connected to the given
116  // super vertex.
117  void getConnectedSuperVertices(int svtx_idx,
118  UT_IntArray &connected);
119 
120  // From the given edge group, this method sorts and partitions the edges
121  // into classes (e.g. patches) and gets them ready to be processed in a
122  // specific order.
123  void buildMainClasses(const GA_EdgeGroup *edge_grp);
124 
125  // This is a helper method for builMainClasses, it goes through the list
126  // of edges in the given edge group and determines populates the
127  // myMainClassEdges array with the corresponding main edges.
128  void resolveToEdges(const GA_EdgeGroup *edge_grp);
129 
130  // Clears the super transforms array.
131  void clearSuperTransforms();
132 
133  // Returns the main polygon that we should be moving the other polygons to.
134  GEO_PrimPoly *getMainPoly(const GA_Edge &edge,
135  const GEO_Primitive *edge_prim,
136  const UT_IntArray &polys);
137 
138  // Rebuilds our connectivity information -- use sparingly.
139  void resetConnectivityStructures();
140 
141 private:
142  GU_Detail &myGdp;
143  GEO_Delta *myDelta;
144  GA_RWHandleV3 myVertexUVAttrib;
145  GEO_PrimClassifier myUVClassifier;
146  GEO_PrimConnectorUV *myUVConnector;
147  UT_ValArray<gu_SuperVertex *> mySuperVertices;
148  UT_ValArray<gu_VertexTransform *> mySuperTransforms;
149  UT_Map<uint64, int> myVertexToSuperVertexTable;
150  UT_ValArray<gu_ClassEdges *> myMainClassEdges;
151 };
152 
153 #endif
GA_API const UT_StringHolder uv
#define GU_API
Definition: GU_API.h:12
GA_API const UT_StringHolder pivot
MatType rotation(const Quat< typename MatType::value_type > &q, typename MatType::value_type eps=static_cast< typename MatType::value_type >(1.0e-8))
Return the rotation matrix specified by the given quaternion.
Definition: Mat.h:204