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