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 * Jeff Lait 00008 * Side Effects Software Inc. 00009 * 123 Front Street West, Suite 1401 00010 * Toronto, Ontario 00011 * Canada M5J 2M2 00012 * 416-504-9876 00013 */ 00014 00015 #ifndef __SIM_Slice_h__ 00016 #define __SIM_Slice_h__ 00017 00018 #include "SIM_API.h" 00019 #include <UT/UT_Vector3.h> 00020 #include <UT/UT_RefArray.h> 00021 #include "SIM_DataUtils.h" 00022 00023 class UT_DMatrix4; 00024 class UT_Matrix; 00025 class UT_FloatArray; 00026 class UT_Vector3Array; 00027 class GU_ConstDetailHandle; 00028 class SIM_Geometry; 00029 class SIM_Position; 00030 class SIM_Motion; 00031 00032 class SIM_Slice; 00033 00034 class SIM_SliceSearchEntry 00035 { 00036 public: 00037 SIM_SliceSearchEntry() 00038 { 00039 mySlice = 0; 00040 myInside = false; 00041 } 00042 SIM_SliceSearchEntry(const SIM_Slice *slice, bool isinside) 00043 { 00044 mySlice = slice; 00045 myInside = isinside; 00046 } 00047 const SIM_Slice *mySlice; 00048 bool myInside; 00049 }; 00050 00051 typedef UT_RefArray<SIM_SliceSearchEntry> SIM_SliceSearchList; 00052 typedef UT_RefArray<SIM_SliceSearchList> SIM_SliceSearchTable; 00053 00054 /// This is the definition of the SIM_Slice interface. The only function that 00055 /// needs to be overridden (besides any standard SIM_Data overrides) is the 00056 /// getSliceBoundaryDistSubclass() functions. 00057 class SIM_API SIM_Slice : public SIM_Data 00058 { 00059 public: 00060 /// Returns whether we are inside this slice or not. 00061 /// true is inside. This corresponds to a negative slice 00062 /// boundary distance but is overrideable for efficiency. 00063 bool isInsideSlice(const UT_Vector3 &pos) const; 00064 00065 /// Returns the distance to the slice's boundary. If the point 00066 /// is inside the slice this is a negative distance, else positive. 00067 fpreal getSliceBoundaryDist(const UT_Vector3 &pos) const; 00068 00069 /// This is used to determine which side of my parent I am on. 00070 virtual UT_Vector3 getCenter() const; 00071 00072 /// Count number of slices from myself and my children. 00073 int countSlices() const; 00074 static int countSlices(const SIM_ConstDataArray &slices); 00075 00076 /// The nth entry of this list stores how to search for the nth 00077 /// slice. 00078 void buildSliceSearch(SIM_SliceSearchTable &table) const; 00079 static void buildSliceSearch(SIM_SliceSearchTable &table, 00080 SIM_ConstDataArray &slices); 00081 00082 static fpreal computeSliceDist(const SIM_SliceSearchList &list, 00083 const UT_Vector3 &pos); 00084 /// This is different than a computeSliceDist < 0 because 00085 /// we need to ensure that we are consistent with <= against 00086 /// a zero result... 00087 static bool isInsideSlice(const SIM_SliceSearchList &list, 00088 const UT_Vector3 &pos); 00089 00090 protected: 00091 explicit SIM_Slice(const SIM_DataFactory *factory); 00092 virtual ~SIM_Slice(); 00093 00094 /// Returns whether we are inside this slice or not. 00095 /// true is inside. This corresponds to a negative slice 00096 /// boundary distance but is overrideable for efficiency. 00097 /// Default implementation just compares the distance with 0. 00098 virtual bool isInsideSliceSubclass(const UT_Vector3 &pos) const; 00099 00100 /// Returns the distance to the slice's boundary. If the point 00101 /// is inside the slice this is a negative distance, else positive. 00102 /// This is what must be overridden to make the slice do something 00103 /// interesting 00104 virtual fpreal getSliceBoundaryDistSubclass(const UT_Vector3 &pos) const = 0; 00105 00106 /// This is used to determine which side of my parent I am on. 00107 virtual UT_Vector3 getCenterSubclass() const = 0; 00108 00109 private: 00110 DECLARE_STANDARD_GETCASTTOTYPE(); 00111 DECLARE_CLASSNAME(SIM_Slice, SIM_Data); 00112 }; 00113 00114 #endif 00115
1.5.9