1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: NMTDS_PassKeyShape.cxx
22 // Author: Peter KURNEV
26 #include <NMTDS_PassKeyShape.ixx>
28 #include <TopTools_ListOfShape.hxx>
29 #include <TopTools_ListIteratorOfListOfShape.hxx>
33 Standard_Integer NormalizedId(const Standard_Integer aId,
34 const Standard_Integer aDiv);
35 //=======================================================================
38 //=======================================================================
39 NMTDS_PassKeyShape::NMTDS_PassKeyShape()
43 //=======================================================================
46 //=======================================================================
47 NMTDS_PassKeyShape::NMTDS_PassKeyShape(const NMTDS_PassKeyShape& aOther)
50 myNbIds=aOther.myNbIds;
54 //=======================================================================
57 //=======================================================================
58 NMTDS_PassKeyShape::~NMTDS_PassKeyShape()
61 //=======================================================================
64 //=======================================================================
65 NMTDS_PassKeyShape& NMTDS_PassKeyShape::Assign(const NMTDS_PassKeyShape& aOther)
68 myNbIds=aOther.myNbIds;
73 //=======================================================================
76 //=======================================================================
77 void NMTDS_PassKeyShape::Clear()
83 //=======================================================================
86 //=======================================================================
87 void NMTDS_PassKeyShape::SetShapes(const TopoDS_Shape& aS1)
95 aHC=aS1.HashCode(myUpper);
96 mySum=NormalizedId(aHC, myNbIds);
98 //=======================================================================
101 //=======================================================================
102 void NMTDS_PassKeyShape::SetShapes(const TopoDS_Shape& aS1,
103 const TopoDS_Shape& aS2)
105 TopTools_ListOfShape aLS;
111 //=======================================================================
112 //function :SetShapes
114 //=======================================================================
115 void NMTDS_PassKeyShape::SetShapes(const TopoDS_Shape& aS1,
116 const TopoDS_Shape& aS2,
117 const TopoDS_Shape& aS3)
119 TopTools_ListOfShape aLS;
126 //=======================================================================
127 //function :SetShapes
129 //=======================================================================
130 void NMTDS_PassKeyShape::SetShapes(const TopoDS_Shape& aS1,
131 const TopoDS_Shape& aS2,
132 const TopoDS_Shape& aS3,
133 const TopoDS_Shape& aS4)
135 TopTools_ListOfShape aLS;
143 //=======================================================================
144 //function :SetShapes
146 //=======================================================================
147 void NMTDS_PassKeyShape::SetShapes(const TopTools_ListOfShape& aLS)
149 Standard_Integer i, aId, aIdN;
150 TopTools_ListIteratorOfListOfShape aIt;
154 for (; aIt.More(); aIt.Next()) {
155 const TopoDS_Shape& aS=aIt.Value();
158 myNbIds=myMap.Extent();
159 for(i=1; i<=myNbIds; ++i) {
160 const TopoDS_Shape& aS=myMap(i);
161 aId=aS.HashCode(myUpper);
162 aIdN=NormalizedId(aId, myNbIds);
166 //=======================================================================
169 //=======================================================================
170 Standard_Integer NMTDS_PassKeyShape::NbIds()const
174 //=======================================================================
177 //=======================================================================
178 Standard_Boolean NMTDS_PassKeyShape::IsEqual(const NMTDS_PassKeyShape& aOther) const
180 Standard_Boolean bRet;
185 if (myNbIds!=aOther.myNbIds) {
188 for (i=1; i<=myNbIds; ++i) {
189 const TopoDS_Shape& aS=myMap(i);
190 if (!aOther.myMap.Contains(aS)) {
196 //=======================================================================
197 //function : HashCode
199 //=======================================================================
200 Standard_Integer NMTDS_PassKeyShape::HashCode(const Standard_Integer aUpper) const
202 return ::HashCode(mySum, aUpper);
204 //=======================================================================
207 //=======================================================================
208 void NMTDS_PassKeyShape::Dump(const Standard_Integer)const
211 //=======================================================================
212 // function: NormalizedId
214 //=======================================================================
215 Standard_Integer NormalizedId(const Standard_Integer aId,
216 const Standard_Integer aDiv)
218 Standard_Integer aMax, aTresh, aIdRet;
221 aMax=::IntegerLast();