1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: NMTDS_PassKeyShape.cxx
22 // Author: Peter KURNEV
25 #include <NMTDS_PassKeyShape.ixx>
27 #include <TopTools_ListOfShape.hxx>
28 #include <TopTools_ListIteratorOfListOfShape.hxx>
32 Standard_Integer NormalizedId(const Standard_Integer aId,
33 const Standard_Integer aDiv);
34 //=======================================================================
37 //=======================================================================
38 NMTDS_PassKeyShape::NMTDS_PassKeyShape()
42 //=======================================================================
45 //=======================================================================
46 NMTDS_PassKeyShape::NMTDS_PassKeyShape(const NMTDS_PassKeyShape& aOther)
49 myNbIds=aOther.myNbIds;
53 //=======================================================================
56 //=======================================================================
57 NMTDS_PassKeyShape::~NMTDS_PassKeyShape()
60 //=======================================================================
63 //=======================================================================
64 NMTDS_PassKeyShape& NMTDS_PassKeyShape::Assign(const NMTDS_PassKeyShape& aOther)
67 myNbIds=aOther.myNbIds;
72 //=======================================================================
75 //=======================================================================
76 void NMTDS_PassKeyShape::Clear()
82 //=======================================================================
85 //=======================================================================
86 void NMTDS_PassKeyShape::SetShapes(const TopoDS_Shape& aS1)
94 aHC=aS1.HashCode(myUpper);
95 mySum=NormalizedId(aHC, myNbIds);
97 //=======================================================================
100 //=======================================================================
101 void NMTDS_PassKeyShape::SetShapes(const TopoDS_Shape& aS1,
102 const TopoDS_Shape& aS2)
104 TopTools_ListOfShape aLS;
110 //=======================================================================
111 //function :SetShapes
113 //=======================================================================
114 void NMTDS_PassKeyShape::SetShapes(const TopoDS_Shape& aS1,
115 const TopoDS_Shape& aS2,
116 const TopoDS_Shape& aS3)
118 TopTools_ListOfShape aLS;
125 //=======================================================================
126 //function :SetShapes
128 //=======================================================================
129 void NMTDS_PassKeyShape::SetShapes(const TopoDS_Shape& aS1,
130 const TopoDS_Shape& aS2,
131 const TopoDS_Shape& aS3,
132 const TopoDS_Shape& aS4)
134 TopTools_ListOfShape aLS;
142 //=======================================================================
143 //function :SetShapes
145 //=======================================================================
146 void NMTDS_PassKeyShape::SetShapes(const TopTools_ListOfShape& aLS)
148 Standard_Integer i, aId, aIdN;
149 TopTools_ListIteratorOfListOfShape aIt;
153 for (; aIt.More(); aIt.Next()) {
154 const TopoDS_Shape& aS=aIt.Value();
157 myNbIds=myMap.Extent();
158 for(i=1; i<=myNbIds; ++i) {
159 const TopoDS_Shape& aS=myMap(i);
160 aId=aS.HashCode(myUpper);
161 aIdN=NormalizedId(aId, myNbIds);
165 //=======================================================================
168 //=======================================================================
169 Standard_Integer NMTDS_PassKeyShape::NbIds()const
173 //=======================================================================
176 //=======================================================================
177 Standard_Boolean NMTDS_PassKeyShape::IsEqual(const NMTDS_PassKeyShape& aOther) const
179 Standard_Boolean bRet;
184 if (myNbIds!=aOther.myNbIds) {
187 for (i=1; i<=myNbIds; ++i) {
188 const TopoDS_Shape& aS=myMap(i);
189 if (!aOther.myMap.Contains(aS)) {
195 //=======================================================================
196 //function : HashCode
198 //=======================================================================
199 Standard_Integer NMTDS_PassKeyShape::HashCode(const Standard_Integer aUpper) const
201 return ::HashCode(mySum, aUpper);
203 //=======================================================================
206 //=======================================================================
207 void NMTDS_PassKeyShape::Dump(const Standard_Integer)const
210 //=======================================================================
211 // function: NormalizedId
213 //=======================================================================
214 Standard_Integer NormalizedId(const Standard_Integer aId,
215 const Standard_Integer aDiv)
217 Standard_Integer aMax, aTresh, aIdRet;
220 aMax=::IntegerLast();