1 // Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File: GEOMAlgo_PassKeyShape.cxx
25 // Author: Peter KURNEV
28 #include <GEOMAlgo_PassKeyShape.hxx>
30 #include <Basics_OCCTVersion.hxx>
32 #include <TopTools_ListOfShape.hxx>
33 #include <TopTools_ListIteratorOfListOfShape.hxx>
37 Standard_Integer NormalizedId(const Standard_Integer aId,
38 const Standard_Integer aDiv);
39 //=======================================================================
42 //=======================================================================
43 GEOMAlgo_PassKeyShape::GEOMAlgo_PassKeyShape()
47 //=======================================================================
50 //=======================================================================
51 GEOMAlgo_PassKeyShape::GEOMAlgo_PassKeyShape(const GEOMAlgo_PassKeyShape& aOther)
54 myNbIds=aOther.myNbIds;
58 //=======================================================================
61 //=======================================================================
62 GEOMAlgo_PassKeyShape::~GEOMAlgo_PassKeyShape()
65 //=======================================================================
68 //=======================================================================
69 GEOMAlgo_PassKeyShape& GEOMAlgo_PassKeyShape::Assign(const GEOMAlgo_PassKeyShape& aOther)
72 myNbIds=aOther.myNbIds;
77 //=======================================================================
80 //=======================================================================
81 void GEOMAlgo_PassKeyShape::Clear()
87 //=======================================================================
90 //=======================================================================
91 void GEOMAlgo_PassKeyShape::SetShapes(const TopoDS_Shape& aS1)
99 #if OCC_VERSION_LARGE < 0x07080000
100 aHC=aS1.HashCode(myUpper);
102 aHC = std::hash<TopoDS_Shape>{}(aS1);
104 mySum=NormalizedId(aHC, myNbIds);
106 //=======================================================================
107 //function :SetShapes
109 //=======================================================================
110 void GEOMAlgo_PassKeyShape::SetShapes(const TopoDS_Shape& aS1,
111 const TopoDS_Shape& aS2)
113 TopTools_ListOfShape aLS;
119 //=======================================================================
120 //function :SetShapes
122 //=======================================================================
123 void GEOMAlgo_PassKeyShape::SetShapes(const TopoDS_Shape& aS1,
124 const TopoDS_Shape& aS2,
125 const TopoDS_Shape& aS3)
127 TopTools_ListOfShape aLS;
134 //=======================================================================
135 //function :SetShapes
137 //=======================================================================
138 void GEOMAlgo_PassKeyShape::SetShapes(const TopoDS_Shape& aS1,
139 const TopoDS_Shape& aS2,
140 const TopoDS_Shape& aS3,
141 const TopoDS_Shape& aS4)
143 TopTools_ListOfShape aLS;
151 //=======================================================================
152 //function :SetShapes
154 //=======================================================================
155 void GEOMAlgo_PassKeyShape::SetShapes(const TopTools_ListOfShape& aLS)
157 Standard_Integer i, aId, aIdN;
158 TopTools_ListIteratorOfListOfShape aIt;
162 for (; aIt.More(); aIt.Next()) {
163 const TopoDS_Shape& aS=aIt.Value();
166 myNbIds=myMap.Extent();
167 for(i=1; i<=myNbIds; ++i) {
168 const TopoDS_Shape& aS=myMap(i);
169 #if OCC_VERSION_LARGE < 0x07080000
170 aId=aS.HashCode(myUpper);
172 aId = std::hash<TopoDS_Shape>{}(aS);
174 aIdN=NormalizedId(aId, myNbIds);
178 //=======================================================================
181 //=======================================================================
182 Standard_Integer GEOMAlgo_PassKeyShape::NbIds()const
186 //=======================================================================
189 //=======================================================================
190 Standard_Boolean GEOMAlgo_PassKeyShape::IsEqual(const GEOMAlgo_PassKeyShape& aOther) const
192 Standard_Boolean bRet;
197 if (myNbIds!=aOther.myNbIds) {
200 for (i=1; i<=myNbIds; ++i) {
201 const TopoDS_Shape& aS=myMap(i);
202 if (!aOther.myMap.Contains(aS)) {
208 #if OCC_VERSION_LARGE < 0x07080000
209 //=======================================================================
210 //function : HashCode
212 //=======================================================================
213 Standard_Integer GEOMAlgo_PassKeyShape::HashCode(const Standard_Integer aUpper) const
215 return ::HashCode(mySum, aUpper);
218 //=======================================================================
221 //=======================================================================
222 void GEOMAlgo_PassKeyShape::Dump(const Standard_Integer)const
225 //=======================================================================
226 // function: NormalizedId
228 //=======================================================================
229 Standard_Integer NormalizedId(const Standard_Integer aId,
230 const Standard_Integer aDiv)
232 Standard_Integer aMax, aTresh, aIdRet;
235 aMax=::IntegerLast();