HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_Cookie.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_Cookie.h ( GU Library, C++)
7  *
8  * COMMENTS: The infamous Cookie operator. This allows you to
9  * crease or cut two gdps groups with each other.
10  */
11 
12 #ifndef __GU_Cookie__
13 #define __GU_Cookie__
14 
15 #include "GU_API.h"
16 #include <GA/GA_Edge.h>
17 #include <GA/GA_EdgeMap.h>
18 #include <GA/GA_Types.h>
19 #include <UT/UT_Array.h>
20 #include <UT/UT_Vector3.h>
21 #include <UT/UT_VectorTypes.h>
22 
23 class GU_Detail;
24 class GU_RayIntersect;
25 class GA_PrimitiveGroup;
26 class GA_PointGroup;
28 class GEO_PrimPoly;
30 class UT_SampleQuad2D;
31 class UT_SampleTri2D;
32 
33 class guEdgeHashEntry;
34 class guTrimInfo;
35 class guTrimProjection;
37 {
38 public:
39  int dir; // 1 if in direction of normal, else -1.
41  float loc; // Where we are on the plane/plane isect line.
42 };
43 
45 {
46 public:
47  GU_Cookie();
48  virtual ~GU_Cookie();
49 
50  GU_Detail *getDetail() const { return myGdp; }
51 
52  void setGroups(const GA_PrimitiveGroup *agrp,
53  const GA_PrimitiveGroup *bgrp,
54  GA_PointGroup *aptgrp,
55  GA_PointGroup *bptgrp)
56  {
57  myGrpA = agrp;
58  myGrpB = bgrp;
59  myPtGrpA = aptgrp;
60  myPtGrpB = bptgrp;
61  }
62  float getTolerance() { return myTol; }
63  void setTolerance(float tol) { myTol = tol; }
64  void setAutoJoin(int aj) { myAutoJoin = aj; }
65 
66  /// Invoke the cookie operation.
67  ///
68  /// The group of polygons to cookie must be setup with the setGroups
69  /// function.
70  ///
71  /// The [a|b][in|out|overlap]grps are the primitive groups to classify
72  /// each clipped polygon piece into.
73  ///
74  /// If a set of connected polygons doesn't intersect, and the insidetest
75  /// is enabled, the insidedness of the polygons will be determined by
76  /// sending a ray with the winding rule.
77  ///
78  /// If generatecrease is set, instead of clipping the polygons, the line
79  /// segments generated by poly-poly intersection will be generated.
80  void cookie(GU_Detail &gdp,
81  int generatecrease,
82  GA_PrimitiveGroup &aingrp,
83  GA_PrimitiveGroup &aoutgrp,
84  GA_PrimitiveGroup &aoverlapgrp,
85  int aclosed,
86  GA_PrimitiveGroup &bingrp,
87  GA_PrimitiveGroup &boutgrp,
88  GA_PrimitiveGroup &boverlapgrp,
89  int bclosed,
90  int insidetest);
91 
92 
93  // The following are internal functions.
94 
95  /// The call back from intersection tests:
96  /// The two indices are the primitive numbers to intersect.
97  void performIsect(int primIdA, int primIdB);
98 
99  /// This adds all the isects of the second polygon into the trim
100  /// list of the first:
101  void buildTrimSegments(GEO_PrimPoly *dst,
102  GEO_PrimPoly *src);
103  void buildTrimSegmentsCoplanar(GEO_PrimPoly *dst,
104  GEO_PrimPoly *src,
105  bool reverse);
106 
107 
108  void addPointToGroup(GA_Offset ptoff, GEO_PrimPoly *poly);
109 
110  /// The edge is poly(edge-1) to poly(edge).
111  GA_Offset createEdgeVertex(GA_WorkVertexBuffer &vbuf,
112  guTrimInfo *base, int edge, float t, int dir);
113 
114  GEO_PrimPoly *createPoly(guTrimInfo *base,
115  const UT_Array<GA_Offset> &vtxes,
116  bool closed,
117  bool preserve_groups = true);
118 
119  /// Punches a hole in the polygon base with the polygon hole. The
120  /// appropriate bridges are formed.
121  void punchHole(GEO_PrimPoly *base, GEO_PrimPoly *hole);
122 
123 
124  UT_IntArray *buildConnectivityGraph();
125 
126  void classifyPolygons(const GA_PrimitiveGroup &originalgrp,
127  GA_PrimitiveGroup &ingrp,
128  GA_PrimitiveGroup &outgrp,
129  GA_PrimitiveGroup &overlapgrp,
130  UT_IntArray *edges,
131  const GA_PrimitiveGroup &othergrp,
132  GU_RayIntersect *&inter,
133  bool insidetest,
134  bool inter_closed);
135 
136  /// @private
137  GA_Offset createInteriorVertex(GA_WorkVertexBuffer &vbuf,
138  guTrimInfo *base,
139  const UT_Vector3 &pt);
140 protected:
144 
146 
147  // We add all newly created points to each of these. Points generated
148  // from A primitives go to ptgrpa, those from B primitives to point
149  // group B.
150  GA_PointGroup *myPtGrpA, *myPtGrpB;
151  const GA_PrimitiveGroup *myGrpA, *myGrpB;
152 
153  // Intersections within a polygon..
154  // This is used by buildTrimSegments, but shared so don't need
155  // to reallocate.
158  float myTol;
159 
160 private:
161 };
162 
163 #endif
UT_Vector3 pos
Definition: GU_Cookie.h:40
GA_Size GA_Offset
Definition: GA_Types.h:617
#define GU_API
Definition: GU_API.h:12
GLenum GLenum dst
Definition: glcorearb.h:1792
float loc
Definition: GU_Cookie.h:41
GLenum src
Definition: glcorearb.h:1792