00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Mark Elendt 00008 * Side Effects Software Inc. 00009 * 20 Maud St. 00010 * Toronto, Ontario, M5V 2M5 00011 * Canada 00012 * 416-366-4607 00013 * 00014 * NAME: GU_HoleInfo (C++) 00015 * 00016 * COMMENTS: This is the info structure used for hole information. Each 00017 * primitive has a an attribute added which points to one of these 00018 * structures. 00019 * The flag is set to 1 if there's a hole. 00020 * The array is filled with all the primitives which are enclosed 00021 * within the face. 00022 */ 00023 00024 #ifndef __GU_HoleInfo__ 00025 #define __GU_HoleInfo__ 00026 00027 #include "GU_API.h" 00028 #include <UT/UT_PtrArray.h> 00029 #include <UT/UT_BoundingBox.h> 00030 00031 class GU_Detail; 00032 class GEO_Primitive; 00033 class GEO_Face; 00034 00035 class GU_API GU_HoleInfo 00036 { 00037 public: 00038 GU_HoleInfo(const GEO_Primitive *prim); 00039 ~GU_HoleInfo(); 00040 00041 // isHole() will return whether the primitive is contained in another face. 00042 unsigned isHole() const { return myHoleFlag & 1; } 00043 00044 // isReversed() will return whether the normal is opposite of the 00045 // surrounding primitives normal (as it should be). 00046 unsigned isReversed() const { return myHoleFlag & 2; } 00047 00048 // Return the number of holes in the primitive and a pointer to the hole. 00049 int entries() const { return myHoles.entries(); } 00050 GEO_Face *getHole(int i) { return myHoles(i); } 00051 00052 /// Store @b this hole info in the given attribute for the given object 00053 void setHole(GB_AttributeElem &o, 00054 const GB_AttributeRef &h); 00055 /// @{ Get the hole info out of the object 00056 static GU_HoleInfo *getHole(GB_AttributeElem &o, 00057 const GB_AttributeRef &h); 00058 static const GU_HoleInfo *getHole(const GB_AttributeElem &o, 00059 const GB_AttributeRef &h); 00060 /// @} 00061 00062 // For promotion of primitives 00063 int setPromotedFace(GEO_Face *face) 00064 { 00065 myFace = face; 00066 return myFace != 0; 00067 } 00068 GEO_Face *getPromotedFace() { return myFace; } 00069 00070 // A bounding box for the primitive. 00071 const UT_BoundingBox &getBox() const { return myBox; } 00072 00073 // Methods which really should be private... 00074 UT_PtrArray<GEO_Face *> &getHoles() { return myHoles; } 00075 void setHole(int on) 00076 { 00077 if (on) myHoleFlag |= 1; 00078 else myHoleFlag &= ~1; 00079 } 00080 void setReversed() { myHoleFlag |= 2; } 00081 00082 private: 00083 void fixPromotions(const GB_AttributeRef &attrib_off); 00084 00085 unsigned myHoleFlag; 00086 UT_PtrArray<GEO_Face *> myHoles; 00087 UT_BoundingBox myBox; 00088 GEO_Face *myFace; // Promoted 00089 00090 friend class GU_HoleDetail; 00091 }; 00092 00093 class GU_API GU_HoleDetail 00094 { 00095 public: 00096 GU_HoleDetail(); 00097 ~GU_HoleDetail(); 00098 00099 // Returns the primitive attribute offset for the hole info pointers. 00100 // It returns -1 if there are no face primitives in the gdp. 00101 // The info structures are all initialized to contain the correct hole 00102 // information. 00103 GB_AttributeRef buildInfo(GU_Detail *gdp, float distance, float angle, 00104 const GB_PrimitiveGroup *primGroup); 00105 00106 // Build information about orientation of the holes (i.e. whether the 00107 // normal is the wrong way for the holes). 00108 void buildReversalInfo(); 00109 // Promote polygons to bezier when needed. The old primitives are 00110 // destroyed, but the attribute information is maintained. 00111 void promoteFaces(); 00112 00113 // Detaches us from the GU_Detail, possibly deleting our normal. 00114 void destroyInfo(); 00115 00116 protected: 00117 GU_Detail *myGdp; 00118 GB_AttributeRef myInfoOffset; 00119 bool myAddedNormals; 00120 GB_AttributeRef myCmpInfoOffset; 00121 }; 00122 00123 #endif
1.5.9