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