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