HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GU_Group.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:
9  *
10  */
11 
12 #ifndef __GU_Group_h__
13 #define __GU_Group_h__
14 
15 #include "GU_API.h"
16 
17 #include <UT/UT_BoundingBox.h>
18 #include <UT/UT_VectorTypes.h>
19 #include <GA/GA_Types.h>
20 
21 class UT_String;
22 class GU_Detail;
23 class GU_RayIntersect;
24 class GA_PointGroup;
25 class GA_Group;
26 
27 //////////////////////////////////////////////////////////////////////////////
28 //
29 // The parameters used to create a specified group.
30 //
31 //////////////////////////////////////////////////////////////////////////////
32 
34 {
35 public:
37  {
38  useBounding = 0;
39  useNumbering = 0;
40  useNormal = 0;
41  useBackface = 0;
42  useEdgeDist = 0;
43  useDegenerate = 0;
44  origptgroup = 0;
45  edgedepth = 0;
46  useNonPlanar = 0;
47  isoOffset = 0.0;
48  invertVolume = false;
49  includeNotWhollyContained = false;
50  boundGdp = 0;
51  pattern = pattern_group = 0;
52  }
54 
55  const char *pattern;
56  const char *pattern_group;
57  int ordered;
58  int start;
59  int end;
60  int incStart;
61  int incEnd;
62  float radx, rady, radz;
63  float tx, ty, tz;
64  float rx, ry, rz;
65  float nx, ny, nz; // Normal
66  UT_Vector3 eye; // Eye position for backface
67  float spreadAngle;
72  int useNormal;
77  int edgedepth;
79  const UT_String *group1;
80  const UT_String *group2;
82  float nonPlanarTol;
85  bool useZAF; // zero area faces
86  bool doOpenZAF; // treat open faces as closed
87  float tolZAF;
88  float isoOffset;
92 };
93 
94 //////////////////////////////////////////////////////////////////////////////
95 //
96 // The enumeration of the possible group boolean operations.
97 //
98 //////////////////////////////////////////////////////////////////////////////
99 
101 {
107 };
108 
109 //////////////////////////////////////////////////////////////////////////////
110 //
111 // This class is a group constructor class. As most of the functionality
112 // are common to both point and primitive groups it exists as a templated
113 // class. It modifies a single GA_Group which is created upon construction
114 // of the subclasses GU_PointGroup and GU_PrimGroup. Use generateGroup to
115 // create a group with the given parameters.
116 //
117 // To construct your own operations if they are common to both points and
118 // primitives place them here in the protected section.
119 //
120 //////////////////////////////////////////////////////////////////////////////
121 
123 {
124 public:
125  GU_Group(GU_Detail *gdp);
126  virtual ~GU_Group();
127 
128  virtual GA_Group *newGroup(const char *) = 0;
129  virtual GA_Group *find(const char *) const = 0;
130  virtual void destroy(void) = 0;
131 
132 
133  GA_Group *group() const { return myGroup; }
134 
135  // Select items based on a boolean operation done between one or two
136  // different groups (e.g. intersect, union, subtraction, negation).
137  // Returns false if any error was encountered and true otherwise.
138  virtual bool boolean(GU_GroupBoolOp boolop,
139  const UT_String &group1, bool negate1,
140  const UT_String &group2, bool negate2) const;
141 
142  virtual bool boolean(GU_GroupBoolOp boolop,
143  GA_Group *group1, bool negate1,
144  GA_Group *group2, bool negate2) const;
145 
146 protected:
147  // this method actually creates the group given the current parms
148  virtual void generateGroup(const GU_GroupParms &parms) = 0;
149 
150  //
151  // methods that allow you to select objects to be in the group
152  //
153 
154  // Selects specific items given a start, and end number as well as
155  // a step and an increment so you can select every 2 of 3
156  virtual void range(int, int, int, int, int, int) const=0;
157  void getRangeValues(int, int &, int &,
158  int &, int &) const;
159 
160 
161  // Selects specific items by a pattern i.e. 1-10:2,3 (1 to 10 every 2 of 3)
162  virtual void pattern(const char *pattern, int nelements,
163  int order) const=0;
164  // Like pattern, but uses the GOP Group Parser to act the same
165  // as the rest of our groups.
166  virtual void patternGroup(const char *pattern, bool order) const=0;
167 
168  // Select specific items within the given bounding box
169  virtual int boundingBox(float, float, float,
170  float, float, float,
171  float, float, float,
172  bool);
173 
174 
175  // Select specific items within the given bounding sphere
176  virtual void boundingSphere(float, float, float,
177  float, float, float,
178  bool) const = 0;
179 
180  // Select just those items with the given normal and an angle about
181  // that normal.
182  virtual void normal(UT_Vector3 &nml, float angle) const = 0;
183 
184  /// Select just those items that are degenerate, or are zero area faces.
185  /// Set degenerate flag to select degenerates. Set the zaf flag to
186  /// select zero area faces. Set the doOpen flag to treat open faces
187  /// as closed. Set tol for a tolerance used in detecting degeneracies.
188  virtual void degenerate(bool degenerate, bool zaf,
189  bool doOpen, float tol) const = 0;
190 
191 
192  static int isBackface(UT_Vector3 pos,
193  UT_Vector3 nml,
194  UT_Vector3 eye);
195 
196 
197  // Used by the subclasses for the bounding routines to determine if a
198  // specified point lies within a given sphere
199  bool pointInsideSphere(const GU_Detail *gdp,
200  GA_Offset ptoff,
201  float a, float b, float c,
202  float tx, float ty, float tz)
203  const;
204 
205  // methods to access the private infomation
206  GU_Detail *gdp() const { return myGdp; }
207  UT_BoundingBox *getBBox() const { return myBBox; }
208 
209  // methods to set the private data
210  void setGroup(GA_Group *grp) { myGroup = grp; }
211  void deleteBBox();
212 
213 
214 private:
215 
216  GA_Group *myGroup; // The group being constructed
217  UT_BoundingBox *myBBox; // Bounding box
218  GU_Detail *myGdp; // Detail containing the group
219 };
220 
221 #endif
~GU_GroupParms()
Definition: GU_Group.h:53
int useEdgeDist
Definition: GU_Group.h:75
int booleanType
Definition: GU_Group.h:74
GLenum GLint * range
Definition: glcorearb.h:1924
float tz
Definition: GU_Group.h:63
const char * pattern_group
Definition: GU_Group.h:56
float nz
Definition: GU_Group.h:65
const GU_Detail * boundGdp
Definition: GU_Group.h:91
float spreadAngle
Definition: GU_Group.h:67
GU_GroupBoolOp
Definition: GU_Group.h:100
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
int useBackface
Definition: GU_Group.h:73
int boundingType
Definition: GU_Group.h:68
float nonPlanarTol
Definition: GU_Group.h:82
const char * pattern
Definition: GU_Group.h:55
bool doOpenZAF
Definition: GU_Group.h:86
UT_BoundingBox * getBBox() const
Definition: GU_Group.h:207
int useDegenerate
Definition: GU_Group.h:83
UT_Vector3 eye
Definition: GU_Group.h:66
bool invertVolume
Definition: GU_Group.h:89
GA_Size GA_Offset
Definition: GA_Types.h:617
void setGroup(GA_Group *grp)
Definition: GU_Group.h:210
const GA_PointGroup * origptgroup
Definition: GU_Group.h:76
int edgedepth
Definition: GU_Group.h:77
float isoOffset
Definition: GU_Group.h:88
bool useZAF
Definition: GU_Group.h:85
T angle(const Vec2< T > &v1, const Vec2< T > &v2)
Definition: Vec2.h:480
int useBounding
Definition: GU_Group.h:70
#define GU_API
Definition: GU_API.h:11
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
float tolZAF
Definition: GU_Group.h:87
bool useDegenPrims
Definition: GU_Group.h:84
GU_RayIntersect * rayTree
Definition: GU_Group.h:78
int numberingType
Definition: GU_Group.h:69
float radz
Definition: GU_Group.h:62
GA_Group * group() const
Definition: GU_Group.h:133
int useNormal
Definition: GU_Group.h:72
bool includeNotWhollyContained
Definition: GU_Group.h:90
const UT_String * group1
Definition: GU_Group.h:79
float rz
Definition: GU_Group.h:64
GU_Detail * gdp() const
Definition: GU_Group.h:206
int incStart
Definition: GU_Group.h:60
int useNumbering
Definition: GU_Group.h:71
const UT_String * group2
Definition: GU_Group.h:80
int useNonPlanar
Definition: GU_Group.h:81