File indexing completed on 2025-01-18 10:03:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _BVH_TreeBase_Header
0017 #define _BVH_TreeBase_Header
0018
0019 #include <BVH_Box.hxx>
0020
0021 template<class T, int N> class BVH_Builder;
0022
0023
0024
0025 class BVH_TreeBaseTransient : public Standard_Transient
0026 {
0027 DEFINE_STANDARD_RTTIEXT(BVH_TreeBaseTransient, Standard_Transient)
0028 protected:
0029 BVH_TreeBaseTransient() {}
0030
0031
0032 virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const { (void)theOStream; (void)theDepth; }
0033
0034
0035 virtual void DumpNode (const int theNodeIndex, Standard_OStream& theOStream, Standard_Integer theDepth) const
0036 { (void)theNodeIndex; (void)theOStream; (void)theDepth; }
0037 };
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 template<class T, int N>
0048 class BVH_TreeBase : public BVH_TreeBaseTransient
0049 {
0050 friend class BVH_Builder<T, N>;
0051
0052 public:
0053
0054 typedef typename BVH_Box<T, N>::BVH_VecNt BVH_VecNt;
0055
0056 public:
0057
0058
0059 BVH_TreeBase() : myDepth (0) { }
0060
0061
0062 virtual ~BVH_TreeBase() {}
0063
0064
0065 int Depth() const
0066 {
0067 return myDepth;
0068 }
0069
0070
0071 int Length() const
0072 {
0073 return BVH::Array<int, 4>::Size (myNodeInfoBuffer);
0074 }
0075
0076 public:
0077
0078
0079 BVH_VecNt& MinPoint (const int theNodeIndex)
0080 {
0081 return BVH::Array<T, N>::ChangeValue (myMinPointBuffer, theNodeIndex);
0082 }
0083
0084
0085 BVH_VecNt& MaxPoint (const int theNodeIndex)
0086 {
0087 return BVH::Array<T, N>::ChangeValue (myMaxPointBuffer, theNodeIndex);
0088 }
0089
0090
0091 const BVH_VecNt& MinPoint (const int theNodeIndex) const
0092 {
0093 return BVH::Array<T, N>::Value (myMinPointBuffer, theNodeIndex);
0094 }
0095
0096
0097 const BVH_VecNt& MaxPoint (const int theNodeIndex) const
0098 {
0099 return BVH::Array<T, N>::Value (myMaxPointBuffer, theNodeIndex);
0100 }
0101
0102
0103 int& BegPrimitive (const int theNodeIndex)
0104 {
0105 return BVH::Array<int, 4>::ChangeValue (myNodeInfoBuffer, theNodeIndex).y();
0106 }
0107
0108
0109 int& EndPrimitive (const int theNodeIndex)
0110 {
0111 return BVH::Array<int, 4>::ChangeValue (myNodeInfoBuffer, theNodeIndex).z();
0112 }
0113
0114
0115 int BegPrimitive (const int theNodeIndex) const
0116 {
0117 return BVH::Array<int, 4>::Value (myNodeInfoBuffer, theNodeIndex).y();
0118 }
0119
0120
0121 int EndPrimitive (const int theNodeIndex) const
0122 {
0123 return BVH::Array<int, 4>::Value (myNodeInfoBuffer, theNodeIndex).z();
0124 }
0125
0126
0127 int NbPrimitives (const int theNodeIndex) const
0128 {
0129 return EndPrimitive (theNodeIndex) - BegPrimitive (theNodeIndex) + 1;
0130 }
0131
0132
0133 int& Level (const int theNodeIndex)
0134 {
0135 return BVH::Array<int, 4>::ChangeValue (myNodeInfoBuffer, theNodeIndex).w();
0136 }
0137
0138
0139 int Level (const int theNodeIndex) const
0140 {
0141 return BVH::Array<int, 4>::Value (myNodeInfoBuffer, theNodeIndex).w();
0142 }
0143
0144
0145 bool IsOuter (const int theNodeIndex) const
0146 {
0147 return BVH::Array<int, 4>::Value (myNodeInfoBuffer, theNodeIndex).x() != 0;
0148 }
0149
0150 public:
0151
0152
0153 BVH_Array4i& NodeInfoBuffer()
0154 {
0155 return myNodeInfoBuffer;
0156 }
0157
0158
0159 const BVH_Array4i& NodeInfoBuffer() const
0160 {
0161 return myNodeInfoBuffer;
0162 }
0163
0164
0165 typename BVH::ArrayType<T, N>::Type& MinPointBuffer()
0166 {
0167 return myMinPointBuffer;
0168 }
0169
0170
0171 typename BVH::ArrayType<T, N>::Type& MaxPointBuffer()
0172 {
0173 return myMaxPointBuffer;
0174 }
0175
0176
0177 const typename BVH::ArrayType<T, N>::Type& MinPointBuffer() const
0178 {
0179 return myMinPointBuffer;
0180 }
0181
0182
0183 const typename BVH::ArrayType<T, N>::Type& MaxPointBuffer() const
0184 {
0185 return myMaxPointBuffer;
0186 }
0187
0188
0189 virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE
0190 {
0191 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
0192 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myDepth)
0193 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Length())
0194
0195 for (Standard_Integer aNodeIdx = 0; aNodeIdx < Length(); ++aNodeIdx)
0196 {
0197 DumpNode (aNodeIdx, theOStream, theDepth);
0198 }
0199 }
0200
0201
0202 virtual void DumpNode (const int theNodeIndex, Standard_OStream& theOStream, Standard_Integer theDepth) const Standard_OVERRIDE
0203 {
0204 OCCT_DUMP_CLASS_BEGIN (theOStream, BVH_TreeNode)
0205
0206 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, theNodeIndex)
0207
0208 Bnd_Box aBndBox = BVH::ToBndBox (MinPoint (theNodeIndex), MaxPoint (theNodeIndex));
0209 Bnd_Box* aPointer = &aBndBox;
0210 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aPointer)
0211
0212 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, BegPrimitive (theNodeIndex))
0213 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, EndPrimitive (theNodeIndex))
0214 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Level (theNodeIndex))
0215 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, IsOuter (theNodeIndex))
0216 }
0217
0218 public:
0219
0220
0221 BVH_Array4i myNodeInfoBuffer;
0222
0223
0224 typename BVH::ArrayType<T, N>::Type myMinPointBuffer;
0225
0226
0227 typename BVH::ArrayType<T, N>::Type myMaxPointBuffer;
0228
0229
0230 int myDepth;
0231
0232 };
0233
0234
0235 struct BVH_QuadTree { };
0236
0237
0238 struct BVH_BinaryTree { };
0239
0240
0241 template<class T, int N, class Arity = BVH_BinaryTree>
0242 class BVH_Tree
0243 {
0244
0245 };
0246
0247 #endif