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 public: 00037 // Returns the primitive attribute offset for the hole info pointers. 00038 // It returns -1 if there are no face primitives in the gdp. 00039 // The info structures are all initialized to contain the correct hole 00040 // information. 00041 static int buildInfo(GU_Detail *gdp, 00042 float distance = 0.001, 00043 float angle = 0.2, 00044 const GB_PrimitiveGroup *grp = 0); 00045 00046 // Build information about orientation of the holes (i.e. whether the 00047 // normal is the wrong way for the holes). 00048 static void buildReversalInfo(GU_Detail *gdp); 00049 00050 // Promote polygons to bezier when needed. The old primitives are 00051 // destroyed, but the attribute information is maintained. 00052 static void promoteFaces(GU_Detail *gdp); 00053 00054 static void destroyInfo(GU_Detail *gdp); 00055 00056 GU_HoleInfo(const GEO_Primitive *prim); 00057 ~GU_HoleInfo(); 00058 00059 // isHole() will return whether the primitive is contained in another face. 00060 unsigned isHole() const { return myHoleFlag & 1; } 00061 00062 // isReversed() will return whether the normal is opposite of the 00063 // surrounding primitives normal (as it should be). 00064 unsigned isReversed() const { return myHoleFlag & 2; } 00065 00066 // Return the number of holes in the primitive and a pointer to the hole. 00067 int entries() const { return myHoles.entries(); } 00068 GEO_Face *getHole(int i) { return myHoles(i); } 00069 00070 // For promotion of primitives 00071 int setPromotedFace(GEO_Face *face) 00072 { 00073 myFace = face; 00074 return myFace != 0; 00075 } 00076 GEO_Face *getPromotedFace() { return myFace; } 00077 00078 // A bounding box for the primitive. 00079 const UT_BoundingBox &getBox() const { return myBox; } 00080 00081 // Methods which really should be private... 00082 UT_PtrArray<GEO_Face *> &getHoles() { return myHoles; } 00083 void setHole(int on) 00084 { 00085 if (on) myHoleFlag |= 1; 00086 else myHoleFlag &= ~1; 00087 } 00088 void setReversed() { myHoleFlag |= 2; } 00089 00090 private: 00091 void fixPromotions(int attrib_off); 00092 unsigned myHoleFlag; 00093 UT_PtrArray<GEO_Face *> myHoles; 00094 UT_BoundingBox myBox; 00095 GEO_Face *myFace; // Promoted 00096 }; 00097 00098 #endif
1.5.9