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_Triangulation_HeaderFile
0017 #define BVH_Triangulation_HeaderFile
0018
0019 #include <BVH_PrimitiveSet.hxx>
0020
0021
0022
0023
0024 template<class T, int N>
0025 class BVH_Triangulation : public BVH_PrimitiveSet<T, N>
0026 {
0027 public:
0028
0029 typedef typename BVH::VectorType<T, N>::Type BVH_VecNt;
0030
0031 public:
0032
0033
0034 BVH_Triangulation() {}
0035
0036
0037 BVH_Triangulation (const opencascade::handle<BVH_Builder<T, N> >& theBuilder)
0038 : BVH_PrimitiveSet<T, N> (theBuilder)
0039 {
0040
0041 }
0042
0043
0044 virtual ~BVH_Triangulation() {}
0045
0046 public:
0047
0048
0049 typename BVH::ArrayType<T, N>::Type Vertices;
0050
0051
0052 BVH_Array4i Elements;
0053
0054 public:
0055
0056
0057 virtual Standard_Integer Size() const Standard_OVERRIDE
0058 {
0059 return BVH::Array<Standard_Integer, 4>::Size (Elements);
0060 }
0061
0062
0063 using BVH_PrimitiveSet<T, N>::Box;
0064
0065
0066 virtual BVH_Box<T, N> Box (const Standard_Integer theIndex) const Standard_OVERRIDE
0067 {
0068 const BVH_Vec4i& anIndex = BVH::Array<Standard_Integer, 4>::Value (Elements, theIndex);
0069
0070 const BVH_VecNt& aPoint0 = BVH::Array<T, N>::Value (Vertices, anIndex.x());
0071 const BVH_VecNt& aPoint1 = BVH::Array<T, N>::Value (Vertices, anIndex.y());
0072 const BVH_VecNt& aPoint2 = BVH::Array<T, N>::Value (Vertices, anIndex.z());
0073
0074 BVH_VecNt aMinPoint (aPoint0), aMaxPoint (aPoint0);
0075
0076 BVH::BoxMinMax<T, N>::CwiseMin (aMinPoint, aPoint1);
0077 BVH::BoxMinMax<T, N>::CwiseMin (aMinPoint, aPoint2);
0078 BVH::BoxMinMax<T, N>::CwiseMax (aMaxPoint, aPoint1);
0079 BVH::BoxMinMax<T, N>::CwiseMax (aMaxPoint, aPoint2);
0080 return BVH_Box<T, N> (aMinPoint, aMaxPoint);
0081 }
0082
0083
0084 virtual T Center (const Standard_Integer theIndex,
0085 const Standard_Integer theAxis) const Standard_OVERRIDE
0086 {
0087 const BVH_Vec4i& anIndex = BVH::Array<Standard_Integer, 4>::Value (Elements, theIndex);
0088
0089 const BVH_VecNt& aPoint0 = BVH::Array<T, N>::Value (Vertices, anIndex.x());
0090 const BVH_VecNt& aPoint1 = BVH::Array<T, N>::Value (Vertices, anIndex.y());
0091 const BVH_VecNt& aPoint2 = BVH::Array<T, N>::Value (Vertices, anIndex.z());
0092 return (BVH::VecComp<T, N>::Get (aPoint0, theAxis) +
0093 BVH::VecComp<T, N>::Get (aPoint1, theAxis) +
0094 BVH::VecComp<T, N>::Get (aPoint2, theAxis)) * static_cast<T> (1.0 / 3.0);
0095 }
0096
0097
0098 virtual void Swap (const Standard_Integer theIndex1,
0099 const Standard_Integer theIndex2) Standard_OVERRIDE
0100 {
0101 BVH_Vec4i& anIndices1 = BVH::Array<Standard_Integer, 4>::ChangeValue (Elements, theIndex1);
0102 BVH_Vec4i& anIndices2 = BVH::Array<Standard_Integer, 4>::ChangeValue (Elements, theIndex2);
0103 std::swap (anIndices1, anIndices2);
0104 }
0105
0106 };
0107
0108 #endif