File indexing completed on 2026-07-29 09:14:33
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOPTools_PairSelector_HeaderFile
0016 #define BOPTools_PairSelector_HeaderFile
0017
0018 #include <BVH_Traverse.hxx>
0019 #include <BVH_BoxSet.hxx>
0020
0021 #include <Standard_Integer.hxx>
0022 #include <algorithm>
0023
0024
0025 template <int Dimension>
0026 class BOPTools_PairSelector
0027 : public BVH_PairTraverse<Standard_Real,
0028 Dimension,
0029 BVH_BoxSet<Standard_Real, Dimension, Standard_Integer>>
0030 {
0031 public:
0032
0033 struct PairIDs
0034 {
0035 PairIDs(const Standard_Integer theId1 = -1, const Standard_Integer theId2 = -1)
0036 : ID1(theId1),
0037 ID2(theId2)
0038 {
0039 }
0040
0041 Standard_Boolean operator<(const PairIDs& theOther) const
0042 {
0043 return ID1 < theOther.ID1 || (ID1 == theOther.ID1 && ID2 < theOther.ID2);
0044 }
0045
0046 Standard_Integer ID1;
0047 Standard_Integer ID2;
0048 };
0049
0050 typedef typename BVH::VectorType<Standard_Real, Dimension>::Type BVH_VecNd;
0051
0052 public:
0053
0054 BOPTools_PairSelector()
0055 : mySameBVHs(Standard_False)
0056 {
0057 }
0058
0059 public:
0060
0061 void Clear() { myPairs.clear(); }
0062
0063
0064 void Sort() { std::sort(myPairs.begin(), myPairs.end()); }
0065
0066
0067
0068
0069
0070
0071
0072
0073 void SetSame(const Standard_Boolean theIsSame) { mySameBVHs = theIsSame; }
0074
0075
0076 const std::vector<PairIDs>& Pairs() const { return myPairs; }
0077
0078 public:
0079
0080 virtual Standard_Boolean RejectNode(const BVH_VecNd& theCMin1,
0081 const BVH_VecNd& theCMax1,
0082 const BVH_VecNd& theCMin2,
0083 const BVH_VecNd& theCMax2,
0084 Standard_Real&) const Standard_OVERRIDE
0085 {
0086 return BVH_Box<Standard_Real, 3>(theCMin1, theCMax1).IsOut(theCMin2, theCMax2);
0087 }
0088
0089
0090 Standard_Boolean RejectElement(const Standard_Integer theID1, const Standard_Integer theID2)
0091 {
0092 return (mySameBVHs && theID1 >= theID2)
0093 || this->myBVHSet1->Box(theID1).IsOut(this->myBVHSet2->Box(theID2));
0094 }
0095
0096
0097 virtual Standard_Boolean Accept(const Standard_Integer theID1,
0098 const Standard_Integer theID2) Standard_OVERRIDE
0099 {
0100 if (!RejectElement(theID1, theID2))
0101 {
0102 myPairs.push_back(
0103 PairIDs(this->myBVHSet1->Element(theID1), this->myBVHSet2->Element(theID2)));
0104 return Standard_True;
0105 }
0106 return Standard_False;
0107 }
0108
0109 protected:
0110 std::vector<PairIDs> myPairs;
0111 Standard_Boolean mySameBVHs;
0112 };
0113
0114 #endif