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  ~GU_HoleInfo() override;
37 
38  /// @{
39  /// Methods defined on GA_BlobData
40  uint hash() const override;
41  bool isEqual(const GA_BlobData &blob) const override;
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  int64 getMemoryUsage(bool inclusive) const override;
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  void countMemory(UT_MemoryCounter &counter,
93  bool inclusive) const override;
94 
95 private:
96  void fixPromotions(GA_Attribute *attrib);
97 
98  unsigned myHoleFlag;
100  UT_BoundingBox myBox;
101  GEO_Face *myFace; // Promoted
102 
103  friend class GU_HoleDetail;
104 };
105 
107 {
108 public:
109  GU_HoleDetail();
110  ~GU_HoleDetail();
111 
112  // Returns the primitive attribute for the hole info pointers.
113  // It returns -1 if there are no face primitives in the gdp.
114  // The info structures are all initialized to contain the correct hole
115  // information.
116  GA_Attribute *buildInfo(GU_Detail *gdp, float distance, float angle,
117  const GA_PrimitiveGroup *primGroup);
118 
119  // Build information about orientation of the holes (i.e. whether the
120  // normal is the wrong way for the holes).
121  void buildReversalInfo();
122  // Promote polygons to bezier when needed. The old primitives are
123  // destroyed, but the attribute information is maintained.
124  void promoteFaces();
125 
126  // Detaches us from the GU_Detail, possibly deleting our normal.
127  void destroyInfo();
128 
129 protected:
133 };
134 
135 #endif
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
SIM_API const UT_StringHolder angle
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:1222
const UT_BoundingBox & getBox() const
Definition: GU_HoleInfo.h:71
bool myAddedNormals
Definition: GU_HoleInfo.h:132
GA_Size GA_Offset
Definition: GA_Types.h:646
void setReversed()
Definition: GU_HoleInfo.h:80
virtual uint hash() const =0
Create a hash.
long long int64
Definition: SYS_Types.h:116
#define GU_API
Definition: GU_API.h:14
GEO_Face * getPromotedFace()
Definition: GU_HoleInfo.h:68
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:130
GA_Attribute * myCmpInfoAttrib
Definition: GU_HoleInfo.h:131
int setPromotedFace(GEO_Face *face)
Definition: GU_HoleInfo.h:63
SIM_API const UT_StringHolder distance
unsigned int uint
Definition: SYS_Types.h:45
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.