00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __BV_Tree_h__
00019 #define __BV_Tree_h__
00020
00021 #include "BV_API.h"
00022 #include <UT/UT_DMatrix4.h>
00023
00024 class UT_IStream;
00025 class BV_Callback;
00026 class BV_LeafIterator;
00027
00028
00029
00030
00031 class BV_API BV_Tree
00032 {
00033 public:
00034 enum Status
00035 {
00036 BV_PASS,
00037
00038 BV_FAIL_ROTATIONS_UNSUPPORTED,
00039
00040 BV_FAIL_BAD_TYPE,
00041
00042 BV_FAIL
00043 };
00044 BV_Tree();
00045 virtual ~BV_Tree();
00046 BV_Tree *clone() const
00047 { return cloneSubclass(); }
00048
00049 virtual const char *getType() const = 0;
00050 virtual const BV_Tree
00051 *castTo(const char *type) const;
00052 virtual BV_Tree *castTo(const char *type);
00053
00054 int64 getMemoryUsage() const
00055 { return getMemoryUsageSubclass(); }
00056 int getNumLeaves() const
00057 { return getNumLeavesSubclass(); }
00058
00059
00060
00061
00062 void save(ostream &os, bool onlyStructure) const
00063 { saveSubclass(os, onlyStructure); }
00064 bool load(UT_IStream &is, bool onlyStructure)
00065 { return loadSubclass(is, onlyStructure); }
00066
00067
00068
00069
00070 void build(BV_LeafIterator &leafIt)
00071 { buildSubclass(leafIt); }
00072
00073
00074 void updateExtents(BV_LeafIterator &leafIt)
00075 { updateExtentsSubclass(leafIt); }
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 Status intersect(BV_Callback &callback,
00092 const BV_Tree &treeb,
00093 const UT_DMatrix4 &xforma,
00094 const UT_DMatrix4 &xformb,
00095 fpreal tol = 0.001F) const
00096 {
00097 return intersectSubclass(callback, treeb,
00098 xforma, xforma,
00099 xformb, xformb,
00100 tol);
00101 }
00102
00103 Status intersect(BV_Callback &callback,
00104 const BV_Tree &treeb,
00105 fpreal tol = 0.001F) const
00106 {
00107 return intersectSubclass(callback, treeb,
00108 UT_DMatrix4(1.f),
00109 UT_DMatrix4(1.f),
00110 UT_DMatrix4(1.f),
00111 UT_DMatrix4(1.f),
00112 tol);
00113 }
00114
00115 Status intersect(BV_Callback &callback,
00116 const BV_Tree &treeb,
00117 const UT_DMatrix4 &startxforma,
00118 const UT_DMatrix4 &startxformb,
00119 const UT_DMatrix4 &endxforma,
00120 const UT_DMatrix4 &endxformb,
00121 fpreal tol = 0.001F) const
00122 {
00123 return intersectSubclass(callback, treeb,
00124 startxforma,
00125 startxformb,
00126 endxforma,
00127 endxformb,
00128 tol);
00129 }
00130
00131 Status intersect(BV_Callback &callback,
00132 const BV_Tree &treeb,
00133 const UT_DMatrix4 &xforma,
00134 const UT_DMatrix4 &startxforma,
00135 const UT_DMatrix4 &startxformb,
00136 const UT_DMatrix4 &xformb,
00137 const UT_DMatrix4 &endxforma,
00138 const UT_DMatrix4 &endxformb,
00139 fpreal tol = 0.001F) const
00140 {
00141
00142 return intersectSubclass(callback, treeb,
00143 startxforma * xforma,
00144 startxformb * xformb,
00145 endxforma * xforma,
00146 endxformb * xformb,
00147 tol);
00148 }
00149
00150
00151
00152 protected:
00153 BV_Tree(const BV_Tree &tree);
00154
00155 virtual BV_Tree *cloneSubclass() const = 0;
00156 virtual void buildSubclass(BV_LeafIterator &leafIt) = 0;
00157 virtual int64 getMemoryUsageSubclass() const = 0;
00158 virtual int getNumLeavesSubclass() const = 0;
00159 virtual void saveSubclass(ostream &os, bool onlyStructure)const = 0;
00160 virtual bool loadSubclass(UT_IStream &is, bool onlyStructure) = 0;
00161 virtual void updateExtentsSubclass(BV_LeafIterator &leafIt) = 0;
00162 virtual Status intersectSubclass(BV_Callback &callback,
00163 const BV_Tree &treeb,
00164 const UT_DMatrix4 &startxforma,
00165 const UT_DMatrix4 &startxformb,
00166 const UT_DMatrix4 &endxforma,
00167 const UT_DMatrix4 &endxformb,
00168 fpreal tol) const = 0;
00169
00170 private:
00171
00172 BV_Tree &operator=(const BV_Tree &);
00173 };
00174
00175 #endif