HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_HoleInfo.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_HoleInfo (C++)
7  *
8  * COMMENTS: This is the info structure used for hole information. Each
9  * primitive has a an attribute added which points to one of these
10  * structures.
11  * The flag is set to 1 if there's a hole.
12  * The array is filled with all the primitives which are enclosed
13  * within the face.
14  */
15 
16 #ifndef __GU_HoleInfo__
17 #define __GU_HoleInfo__
18 
19 #include "GU_API.h"
20 #include <GA/GA_BlobData.h>
21 #include <GA/GA_Types.h>
22 #include <UT/UT_ValArray.h>
23 #include <UT/UT_BoundingBox.h>
24 
25 class GU_Detail;
26 class GA_Attribute;
27 class GA_PrimitiveGroup;
28 class GEO_Primitive;
29 class GEO_Face;
30 class UT_MemoryCounter;
31 
33 {
34 public:
35  GU_HoleInfo(const GEO_Primitive *prim);
36  virtual ~GU_HoleInfo();
37 
38  /// @{
39  /// Methods defined on GA_BlobData
40  virtual uint hash() const;
41  virtual bool isEqual(const GA_BlobData &blob) const;
42  /// @}
43 
44  // isHole() will return whether the primitive is contained in another face.
45  unsigned isHole() const { return myHoleFlag & 1; }
46 
47  // isReversed() will return whether the normal is opposite of the
48  // surrounding primitives normal (as it should be).
49  unsigned isReversed() const { return myHoleFlag & 2; }
50 
51  // Return the number of holes in the primitive and a pointer to the hole.
52  int entries() const { return myHoles.entries(); }
53  GEO_Face *getHole(int i) { return myHoles(i); }
54 
55  /// Store @b this hole info in the given attribute for the given object
56  void setHole(GA_Offset o, GA_Attribute *a);
57  /// @{ Get the hole info out of the object
58  static GU_HoleInfo *getHole(GA_Offset o, GA_Attribute *a);
59  static const GU_HoleInfo *getHole(GA_Offset o, const GA_Attribute *a);
60  /// @}
61 
62  // For promotion of primitives
64  {
65  myFace = face;
66  return myFace != 0;
67  }
68  GEO_Face *getPromotedFace() { return myFace; }
69 
70  // A bounding box for the primitive.
71  const UT_BoundingBox &getBox() const { return myBox; }
72 
73 // Methods which really should be private...
74  UT_ValArray<GEO_Face *> &getHoles() { return myHoles; }
75  void setHole(int on)
76  {
77  if (on) myHoleFlag |= 1;
78  else myHoleFlag &= ~1;
79  }
80  void setReversed() { myHoleFlag |= 2; }
81 
82  /// Report approximate memory usage
83  virtual int64 getMemoryUsage(bool inclusive) const;
84 
85  /// Count memory usage using a UT_MemoryCounter in order to count
86  /// shared memory correctly.
87  /// If inclusive is true, the size of this object is counted,
88  /// else only memory owned by this object is counted.
89  /// If this is pointed to by the calling object, inclusive should be true.
90  /// If this is contained in the calling object, inclusive should be false.
91  /// (Its memory was already counted in the size of the calling object.)
92  virtual void countMemory(UT_MemoryCounter &counter, bool inclusive) const;
93 
94 private:
95  void fixPromotions(GA_Attribute *attrib);
96 
97  unsigned myHoleFlag;
99  UT_BoundingBox myBox;
100  GEO_Face *myFace; // Promoted
101 
102  friend class GU_HoleDetail;
103 };
104 
106 {
107 public:
108  GU_HoleDetail();
109  ~GU_HoleDetail();
110 
111  // Returns the primitive attribute for the hole info pointers.
112  // It returns -1 if there are no face primitives in the gdp.
113  // The info structures are all initialized to contain the correct hole
114  // information.
115  GA_Attribute *buildInfo(GU_Detail *gdp, float distance, float angle,
116  const GA_PrimitiveGroup *primGroup);
117 
118  // Build information about orientation of the holes (i.e. whether the
119  // normal is the wrong way for the holes).
120  void buildReversalInfo();
121  // Promote polygons to bezier when needed. The old primitives are
122  // destroyed, but the attribute information is maintained.
123  void promoteFaces();
124 
125  // Detaches us from the GU_Detail, possibly deleting our normal.
126  void destroyInfo();
127 
128 protected:
132 };
133 
134 #endif
Definition of a geometry attribute.
Definition: GA_Attribute.h:190
virtual int64 getMemoryUsage(bool inclusive) const =0
Report approximate memory usage.
int entries() const
Definition: GU_HoleInfo.h:52
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
const UT_BoundingBox & getBox() const
Definition: GU_HoleInfo.h:71
bool myAddedNormals
Definition: GU_HoleInfo.h:131
png_uint_32 i
Definition: png.h:2877
GA_Size GA_Offset
Definition: GA_Types.h:617
long long int64
Definition: SYS_Types.h:107
void setReversed()
Definition: GU_HoleInfo.h:80
T distance(const UT_Vector4T< T > &v1, const UT_Vector4T< T > &v2)
Definition: UT_Vector4.h:698
virtual uint hash() const =0
Create a hash.
T angle(const Vec2< T > &v1, const Vec2< T > &v2)
Definition: Vec2.h:472
#define GU_API
Definition: GU_API.h:12
GEO_Face * getPromotedFace()
Definition: GU_HoleInfo.h:68
unsigned int uint
Definition: SYS_Types.h:40
GEO_Face * getHole(int i)
Definition: GU_HoleInfo.h:53
void setHole(int on)
Definition: GU_HoleInfo.h:75
unsigned isHole() const
Definition: GU_HoleInfo.h:45
unsigned isReversed() const
Definition: GU_HoleInfo.h:49
GU_Detail * myGdp
Definition: GU_HoleInfo.h:129
GA_Attribute * myCmpInfoAttrib
Definition: GU_HoleInfo.h:130
int setPromotedFace(GEO_Face *face)
Definition: GU_HoleInfo.h:63
UT_ValArray< GEO_Face * > & getHoles()
Definition: GU_HoleInfo.h:74
virtual void countMemory(UT_MemoryCounter &counter, bool inclusive) const =0
virtual bool isEqual(const GA_BlobData &blob) const =0
Return true if this blob is equal to the other blob.