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