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 * Ondrej Kos 00008 * Side Effects Software Inc. 00009 * 477 Richmond St. West 00010 * Toronto, Ontario, M5V 2M5 00011 * Canada 00012 * 416-504-9876 00013 * 00014 * NAME: GU_PrimGroupClosure.h 00015 * 00016 * COMMENTS: A class to encapsulate the bit mask and point closure 00017 * of a primitive group. 00018 * 00019 */ 00020 00021 #ifndef __GU_PrimGroupClosure_h__ 00022 #define __GU_PrimGroupClosure_h__ 00023 00024 #include "GU_API.h" 00025 #include <UT/UT_BitArray.h> 00026 #include <UT/UT_Assert.h> 00027 #include <GB/GB_PrimGroupClosure.h> 00028 #include <GEO/GEO_Primitive.h> 00029 #include <GEO/GEO_Point.h> 00030 00031 class GU_Detail; 00032 00033 class GU_API GU_PrimGroupClosure : public GB_PrimGroupClosure 00034 { 00035 public: 00036 GU_PrimGroupClosure(); 00037 GU_PrimGroupClosure(const GU_Detail *gdp, 00038 const char *group_name); 00039 virtual ~GU_PrimGroupClosure(); 00040 00041 #define GU_CONTAINS_PRIM(prim) \ 00042 UT_ASSERT_P(prim); \ 00043 UT_ASSERT_P(myValid); \ 00044 UT_ASSERT_P(myPrimGroup); \ 00045 return myPrimGroup->contains(prim) 00046 00047 #define GU_CONTAINS_POINT(ppt) \ 00048 UT_ASSERT_P(myValid); \ 00049 return myPointArray(ppt->getNum()) 00050 00051 virtual bool containsBasePrim(const GB_Element *prim) const 00052 { GU_CONTAINS_PRIM(prim); } 00053 00054 virtual bool containsBasePoint(const GB_Element *ppt) const 00055 { GU_CONTAINS_POINT(ppt); } 00056 00057 // We could call the containsBase*() methods from the contains*() methods. 00058 // However, by not calling the virtuals there's a better chance that these 00059 // methods can be inlined. So, we use macros instead. 00060 bool containsPrim(const GEO_Primitive *prim) const 00061 { GU_CONTAINS_PRIM(prim); } 00062 00063 bool containsPoint(const GEO_Point *ppt) const 00064 { GU_CONTAINS_POINT(ppt); } 00065 bool containsPoint(int ptnum) const 00066 { 00067 UT_ASSERT(myValid); 00068 return myPointArray(ptnum); 00069 } 00070 00071 bool isValid() const { return myValid; } 00072 00073 // Refresh our bit array. Call isValid() to determine whether 00074 // the bit array was successfully built. 00075 void refresh(const GU_Detail *gdp, 00076 const char *group_name, 00077 bool shared_points_go_in_closure = true); 00078 00079 const GB_PrimitiveGroup *primGroup() const { return myPrimGroup; } 00080 GB_PrimitiveGroup *primGroup() { return myPrimGroup; } 00081 00082 private: 00083 GB_PrimitiveGroup *myPrimGroup; 00084 00085 UT_BitArray myPointArray; // a bit for each point, indicating 00086 // whether to draw it or not 00087 00088 const GU_Detail *myDetail; // detail pointer 00089 int myDetailUniqueId; // unique id of detail 00090 int myDetailCacheCount; // last seen cache count 00091 00092 bool myValid; // is the point array valid 00093 }; 00094 00095 #endif
1.5.9