1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, 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.
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
22 // File: NMTDS_PassKeyShape.cxx
24 // Author: Peter KURNEV
27 #include <NMTDS_PassKeyShape.ixx>
29 #include <TopTools_ListOfShape.hxx>
30 #include <TopTools_ListIteratorOfListOfShape.hxx>
34 Standard_Integer NormalizedId(const Standard_Integer aId,
35 const Standard_Integer aDiv);
36 //=======================================================================
39 //=======================================================================
40 NMTDS_PassKeyShape::NMTDS_PassKeyShape()
44 //=======================================================================
47 //=======================================================================
48 NMTDS_PassKeyShape::NMTDS_PassKeyShape(const NMTDS_PassKeyShape& aOther)
51 myNbIds=aOther.myNbIds;
55 //=======================================================================
58 //=======================================================================
59 NMTDS_PassKeyShape::~NMTDS_PassKeyShape()
62 //=======================================================================
65 //=======================================================================
66 NMTDS_PassKeyShape& NMTDS_PassKeyShape::Assign(const NMTDS_PassKeyShape& aOther)
69 myNbIds=aOther.myNbIds;
74 //=======================================================================
77 //=======================================================================
78 void NMTDS_PassKeyShape::Clear()
84 //=======================================================================
87 //=======================================================================
88 void NMTDS_PassKeyShape::SetShapes(const TopoDS_Shape& aS1)
96 aHC=aS1.HashCode(myUpper);
97 mySum=NormalizedId(aHC, myNbIds);
99 //=======================================================================
100 //function :SetShapes
102 //=======================================================================
103 void NMTDS_PassKeyShape::SetShapes(const TopoDS_Shape& aS1,
104 const TopoDS_Shape& aS2)
106 TopTools_ListOfShape aLS;
112 //=======================================================================
113 //function :SetShapes
115 //=======================================================================
116 void NMTDS_PassKeyShape::SetShapes(const TopoDS_Shape& aS1,
117 const TopoDS_Shape& aS2,
118 const TopoDS_Shape& aS3)
120 TopTools_ListOfShape aLS;
127 //=======================================================================
128 //function :SetShapes
130 //=======================================================================
131 void NMTDS_PassKeyShape::SetShapes(const TopoDS_Shape& aS1,
132 const TopoDS_Shape& aS2,
133 const TopoDS_Shape& aS3,
134 const TopoDS_Shape& aS4)
136 TopTools_ListOfShape aLS;
144 //=======================================================================
145 //function :SetShapes
147 //=======================================================================
148 void NMTDS_PassKeyShape::SetShapes(const TopTools_ListOfShape& aLS)
150 Standard_Integer i, aId, aIdN;
151 TopTools_ListIteratorOfListOfShape aIt;
155 for (; aIt.More(); aIt.Next()) {
156 const TopoDS_Shape& aS=aIt.Value();
159 myNbIds=myMap.Extent();
160 for(i=1; i<=myNbIds; ++i) {
161 const TopoDS_Shape& aS=myMap(i);
162 aId=aS.HashCode(myUpper);
163 aIdN=NormalizedId(aId, myNbIds);
167 //=======================================================================
170 //=======================================================================
171 Standard_Integer NMTDS_PassKeyShape::NbIds()const
175 //=======================================================================
178 //=======================================================================
179 Standard_Boolean NMTDS_PassKeyShape::IsEqual(const NMTDS_PassKeyShape& aOther) const
181 Standard_Boolean bRet;
186 if (myNbIds!=aOther.myNbIds) {
189 for (i=1; i<=myNbIds; ++i) {
190 const TopoDS_Shape& aS=myMap(i);
191 if (!aOther.myMap.Contains(aS)) {
197 //=======================================================================
198 //function : HashCode
200 //=======================================================================
201 Standard_Integer NMTDS_PassKeyShape::HashCode(const Standard_Integer aUpper) const
203 return ::HashCode(mySum, aUpper);
205 //=======================================================================
208 //=======================================================================
209 void NMTDS_PassKeyShape::Dump(const Standard_Integer)const
212 //=======================================================================
213 // function: NormalizedId
215 //=======================================================================
216 Standard_Integer NormalizedId(const Standard_Integer aId,
217 const Standard_Integer aDiv)
219 Standard_Integer aMax, aTresh, aIdRet;
222 aMax=::IntegerLast();