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