HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_PolyExtrude.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: Poly Extrude code.
9  *
10  */
11 #ifndef __GU_PolyExtrude_h__
12 #define __GU_PolyExtrude_h__
13 
14 #include "GU_API.h"
15 #include <UT/UT_Matrix4.h>
16 #include <UT/UT_Array.h>
17 #include <UT/UT_Vector3.h>
18 #include <GA/GA_Types.h>
19 
20 class GA_Group;
21 class GA_PointGroup;
22 class GA_PrimitiveGroup;
24 class GEO_Face;
25 class GEO_PrimPoly;
26 class GU_Detail;
27 class gu_PolyExtrudeConsolidator;
28 template<typename T, bool B> class GA_EdgeT;
30 
32 {
33  GU_EXTRUDE_CONSOLIDATE_FRONT = 0x01, // consolidate front face.
34  GU_EXTRUDE_CONSOLIDATE_BACK = 0x02, // consolidate back face.
35  GU_EXTRUDE_CONSOLIDATE_SIDE = 0x04, // consolidate sides.
36  GU_EXTRUDE_CONSOLIDATE_ALL = 0x08, // consolidate all faces
37  // together.
38  GU_EXTRUDE_CONSOLIDATE_ALLPERPOINT = 0x10, // consolidate all originating
39  // points together.
43 };
44 
46 {
51 };
52 
54 {
58 };
59 
60 class gu_PointTargetList;
61 class gu_LocalSpaceAlgorithm;
62 
63 typedef void (*GU_PolyExtrudeXformCallback)(int primnum, UT_Matrix4 &xform,
64  void *user_data);
65 typedef float (*GU_PolyExtrudeInsetCallback)(int primnum, int vtxnum, int ptnum,
66  void *user_data);
67 typedef int (*GU_PolyExtrudeDivCallback)(int primnum, void *user_data);
68 
70 {
71 public:
73 
74  const GA_Group *myGroup;
75 
76 
80 
82 
86 
88 
91 
92  unsigned int myConsolidatePoints; // Bit flag for fuse options
93 
94 
96 
98 
99  // This flag is used to orient faces extruded from edges based on the
100  // neighbouring faces.
102 
103  // Floating point tolerance for consolidating and coincident face removal.
104  float myTolerance;
105 
106  void setLocalXform(const UT_Matrix4 &mat,
108  const UT_Matrix4 &getLocalXform(int primnum) const;
109 
110  void setGlobalXform(const UT_Matrix4 &mat,
112  const UT_Matrix4 &getGlobalXform(int primnum) const;
113 
114  void setInset(float inset, GU_PolyExtrudeInsetCallback cb);
115  float getInset(int primnum, int vtxnum, int ptnum) const;
116 
117  void setDivisions(int div, GU_PolyExtrudeDivCallback cb);
118  int getDivisions(int primnum) const;
119 
120  // Returns true if either the bit passed is set in our myConsolidatePoints
121  // bit field or if one of the 'All' options is set.
122  bool isFusing(unsigned int bit) const;
123 
124  // Returns true if we are using the 'All Per-Point' method of fusing
125  // and myKeepFacesTogether is true.
126  bool isConsolidatePerPoint() const;
127 
128  // Returns true if we are using the 'All' or 'All Per-Point' method of
129  // fusing.
130  bool isConsolidateAll() const;
131 
132  // Callback support for local variables
138 
139 private:
140 
141  // These parameters can be changed by local variables and so must be
142  // accessed through methods of this class.
143  UT_Matrix4 myLocalXform;
144  UT_Matrix4 myGlobalXform;
145  mutable UT_Matrix4 myTempLXform; // For callback storage
146  mutable UT_Matrix4 myTempGXform; // For callback storage
147  int myDivisions;
148  float myInset;
149 
150 };
151 
152 
154 {
155 public:
156 
158  ~GU_PolyExtrude();
159 
160  // Performs the extrusion
161  void extrude(const GU_PolyExtrudeParms &parms);
162 
163  // Removes coincident polygons
164  void removeSharedSides(GA_PrimitiveGroup *primgrp, float tolerance);
165 
166 
167  // Computes an edge normal
168  bool computeEdgeNormal(UT_Vector3 &nml, const GA_Edge &edge,
169  bool cleanup);
170 
171  // Computes the local coordinate space of the polygon and returns
172  // the change of basis matrix in mat. If it fails, then false is
173  // returned, otherwise it returns true. (Failure condition might
174  // be that the polygon is degenerate.)
175  static bool computeLocalSpace(const GEO_Face &face,
176  UT_Matrix4 &mat);
177  bool computeLocalSpace(const GA_Edge &edge, UT_Matrix4 &mat);
178 
179 private:
180  void extrudePolys(const GU_PolyExtrudeParms &parms,
181  GA_ElementWranglerCache &wranglers);
182  void extrudeEdges(const GU_PolyExtrudeParms &parms,
183  GA_ElementWranglerCache &wranglers);
184  bool extrudeFace(const GEO_Face &face, gu_LocalSpaceAlgorithm &lsa,
185  const GU_PolyExtrudeParms &parms,
186  GA_PrimitiveGroup *sideprims,
187  const gu_PointTargetList &pt_target_list,
188  GA_ElementWranglerCache &wranglers);
189  void extrudeEdge(const GA_Edge &edge, gu_LocalSpaceAlgorithm &lsa,
190  const GU_PolyExtrudeParms &parms,
191  const gu_PointTargetList &pt_target_list,
192  GA_ElementWranglerCache &wranglers);
193 
194  void buildRails(const GU_PolyExtrudeParms &parms,
195  UT_Array<GA_Offset> &ptlist0,
196  UT_Array<GA_Offset> &ptlist1,
197  GA_Offset pt0, GA_Offset pt1,
198  GA_Offset frontpt0, GA_Offset frontpt1,
199  const UT_Vector3 &extrudedir0,
200  const UT_Vector3 &extrudedir1,
201  float t, bool regenlist0, int divs,
202  GA_ElementWranglerCache &wranglers);
203 
204  // Returns a new point based on the myConsolidatePoints option.
205  // If likept is null, then we won't copy attributes
206  GA_Offset newPoint(const GU_PolyExtrudeParms &parms,
207  const UT_Vector3 &atpos,
208  GA_Offset likept,
209  GA_ElementWranglerCache &wranglers);
210 
211  GEO_PrimPoly *buildFrontFace(const GEO_Face &face,
212  gu_LocalSpaceAlgorithm &lsa,
213  const GU_PolyExtrudeParms &parms,
214  const gu_PointTargetList &pt_target_list,
215  GA_ElementWranglerCache &wranglers);
216  void buildSideFaces(const GEO_Face &face,
217  const GEO_Face &newface,
218  const GU_PolyExtrudeParms &parms,
219  const gu_PointTargetList &pt_target_list,
220  UT_Array<GA_Offset> &new_sides,
221  GA_ElementWranglerCache &wranglers);
222 
223  GA_Offset getEdgePoint(int ptnum, int div, float t,
224  const UT_Vector3 &extrudedir,
225  const GU_PolyExtrudeParms &parms,
226  const gu_PointTargetList &pt_target_list,
227  GA_ElementWranglerCache &wranglers);
228 
229 
230  GU_Detail *myGdp;
231  bool myInternalNormals;
232 
233  gu_PolyExtrudeConsolidator *myNewPointsConsolidator;
234 };
235 
236 #endif
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
GA_API const UT_StringHolder div
GU_PolyExtrudeXformCallback myLocalXformCallback
void
Definition: png.h:1083
int(* GU_PolyExtrudeDivCallback)(int primnum, void *user_data)
GA_PrimitiveGroup * myBackGroup
void(* GU_PolyExtrudeXformCallback)(int primnum, UT_Matrix4 &xform, void *user_data)
GU_PolyExtrudeKeepSharedPoints
GA_Size GA_Offset
Definition: GA_Types.h:646
GU_PolyExtrudeKeepSharedPoints myKeepSharedPointsTogether
GU_PolyExtrudeConsolidate
IMATH_NAMESPACE::V2f float
GA_PrimitiveGroup * mySideGroup
#define GU_API
Definition: GU_API.h:14
GU_PolyExtrudeDivCallback myDivCallback
GLdouble t
Definition: glad.h:2397
IMATH_HOSTDEVICE constexpr int divs(int x, int y) IMATH_NOEXCEPT
Definition: ImathFun.h:140
GU_PolyExtrudeSymmetryAxis mySymmetryAxis
const GA_Group * myGroup
GU_PolyExtrudeXformCallback myGlobalXformCallback
GA_PrimitiveGroup * myFrontGroup
GU_PolyExtrudeInsetCallback myInsetCallback
unsigned int myConsolidatePoints
GU_PolyExtrudeSymmetryAxis
GA_Group * myOutputGroup
float(* GU_PolyExtrudeInsetCallback)(int primnum, int vtxnum, int ptnum, void *user_data)