X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMAlgo%2FGEOMAlgo_PassKeyShape.cxx;h=57686fd634858e52498158f0316ffb687aa9c970;hb=refs%2Fheads%2FV9_9_BR;hp=cd90291c2585e788363fd05701a2ef7d029aa380;hpb=9499b99fe2dcb53e1ea364f97986f8f432b04600;p=modules%2Fgeom.git diff --git a/src/GEOMAlgo/GEOMAlgo_PassKeyShape.cxx b/src/GEOMAlgo/GEOMAlgo_PassKeyShape.cxx old mode 100755 new mode 100644 index cd90291c2..57686fd63 --- a/src/GEOMAlgo/GEOMAlgo_PassKeyShape.cxx +++ b/src/GEOMAlgo/GEOMAlgo_PassKeyShape.cxx @@ -1,131 +1,229 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File: GEOMAlgo_PassKeyShape.cxx -// Created: -// Author: Peter KURNEV -// - -#include - -#include -#include +// File: GEOMAlgo_PassKeyShape.cxx +// Created: +// Author: Peter KURNEV +// +// +#include +#include #include -#include + +static + Standard_Integer NormalizedId(const Standard_Integer aId, + const Standard_Integer aDiv); //======================================================================= //function : -//purpose : +//purpose : //======================================================================= GEOMAlgo_PassKeyShape::GEOMAlgo_PassKeyShape() -: - GEOMAlgo_PassKey() { myUpper=432123; - GEOMAlgo_PassKey::Clear(); } //======================================================================= -//function :SetIds -//purpose : +//function : +//purpose : //======================================================================= - void GEOMAlgo_PassKeyShape::SetIds(const TopoDS_Shape& aS1) - + GEOMAlgo_PassKeyShape::GEOMAlgo_PassKeyShape(const GEOMAlgo_PassKeyShape& aOther) { - Standard_Integer anId1; - // - anId1=aS1.HashCode(myUpper); - GEOMAlgo_PassKey::SetIds(anId1); + myUpper=432123; + myNbIds=aOther.myNbIds; + mySum=aOther.mySum; + myMap=aOther.myMap; } //======================================================================= -//function :SetIds -//purpose : +//function :~ +//purpose : //======================================================================= - void GEOMAlgo_PassKeyShape::SetIds(const TopoDS_Shape& aS1, - const TopoDS_Shape& aS2) + GEOMAlgo_PassKeyShape::~GEOMAlgo_PassKeyShape() { - Standard_Integer anId1, anId2; - // - anId1=aS1.HashCode(myUpper); - anId2=aS2.HashCode(myUpper); - // - GEOMAlgo_PassKey::SetIds(anId1, anId2); } //======================================================================= -//function :SetIds -//purpose : +//function :Assign +//purpose : //======================================================================= - void GEOMAlgo_PassKeyShape::SetIds(const TopoDS_Shape& aS1, - const TopoDS_Shape& aS2, - const TopoDS_Shape& aS3) + GEOMAlgo_PassKeyShape& GEOMAlgo_PassKeyShape::Assign(const GEOMAlgo_PassKeyShape& aOther) { - Standard_Integer anId1, anId2, anId3; + myUpper=432123; + myNbIds=aOther.myNbIds; + mySum=aOther.mySum; + myMap=aOther.myMap; + return *this; +} +//======================================================================= +//function :Clear +//purpose : +//======================================================================= + void GEOMAlgo_PassKeyShape::Clear() +{ + myNbIds=0; + mySum=0; + myMap.Clear(); +} +//======================================================================= +//function :SetShapes +//purpose : +//======================================================================= + void GEOMAlgo_PassKeyShape::SetShapes(const TopoDS_Shape& aS1) + +{ + Standard_Integer aHC; // - anId1=aS1.HashCode(myUpper); - anId2=aS2.HashCode(myUpper); - anId3=aS3.HashCode(myUpper); + Clear(); + myNbIds=1; + myMap.Add(aS1); + aHC=aS1.HashCode(myUpper); + mySum=NormalizedId(aHC, myNbIds); +} +//======================================================================= +//function :SetShapes +//purpose : +//======================================================================= + void GEOMAlgo_PassKeyShape::SetShapes(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2) +{ + TopTools_ListOfShape aLS; // - GEOMAlgo_PassKey::SetIds(anId1, anId2, anId3); + aLS.Append(aS1); + aLS.Append(aS2); + SetShapes(aLS); } //======================================================================= -//function :SetIds -//purpose : +//function :SetShapes +//purpose : //======================================================================= - void GEOMAlgo_PassKeyShape::SetIds(const TopoDS_Shape& aS1, - const TopoDS_Shape& aS2, - const TopoDS_Shape& aS3, - const TopoDS_Shape& aS4) + void GEOMAlgo_PassKeyShape::SetShapes(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2, + const TopoDS_Shape& aS3) { - Standard_Integer anId1, anId2, anId3, anId4; + TopTools_ListOfShape aLS; // - anId1=aS1.HashCode(myUpper); - anId2=aS2.HashCode(myUpper); - anId3=aS3.HashCode(myUpper); - anId4=aS4.HashCode(myUpper); + aLS.Append(aS1); + aLS.Append(aS2); + aLS.Append(aS3); + SetShapes(aLS); +} +//======================================================================= +//function :SetShapes +//purpose : +//======================================================================= + void GEOMAlgo_PassKeyShape::SetShapes(const TopoDS_Shape& aS1, + const TopoDS_Shape& aS2, + const TopoDS_Shape& aS3, + const TopoDS_Shape& aS4) +{ + TopTools_ListOfShape aLS; // - GEOMAlgo_PassKey::SetIds(anId1, anId2, anId3, anId4); + aLS.Append(aS1); + aLS.Append(aS2); + aLS.Append(aS3); + aLS.Append(aS4); + SetShapes(aLS); } //======================================================================= -//function :SetIds -//purpose : +//function :SetShapes +//purpose : //======================================================================= - void GEOMAlgo_PassKeyShape::SetIds(const TopTools_ListOfShape& aLS) + void GEOMAlgo_PassKeyShape::SetShapes(const TopTools_ListOfShape& aLS) { - Standard_Integer anId; + Standard_Integer i, aId, aIdN; TopTools_ListIteratorOfListOfShape aIt; - TColStd_ListOfInteger aLI; - // - //aNb=aLS.Extent(); - //if (aNb<1 || aNb > myNbMax) { - // return; - //} // - //myNbIds=aNb; - //mySum=0; - //i=myNbMax-myNbIds; - + Clear(); aIt.Initialize(aLS); for (; aIt.More(); aIt.Next()) { const TopoDS_Shape& aS=aIt.Value(); - anId=aS.HashCode(myUpper); - aLI.Append(anId); + myMap.Add(aS); + } + myNbIds=myMap.Extent(); + for(i=1; i<=myNbIds; ++i) { + const TopoDS_Shape& aS=myMap(i); + aId=aS.HashCode(myUpper); + aIdN=NormalizedId(aId, myNbIds); + mySum+=aIdN; + } +} +//======================================================================= +//function :NbIds +//purpose : +//======================================================================= + Standard_Integer GEOMAlgo_PassKeyShape::NbIds()const +{ + return myNbIds; +} +//======================================================================= +//function :IsEqual +//purpose : +//======================================================================= + Standard_Boolean GEOMAlgo_PassKeyShape::IsEqual(const GEOMAlgo_PassKeyShape& aOther) const +{ + Standard_Boolean bRet; + Standard_Integer i; + // + bRet=Standard_False; + // + if (myNbIds!=aOther.myNbIds) { + return bRet; + } + for (i=1; i<=myNbIds; ++i) { + const TopoDS_Shape& aS=myMap(i); + if (!aOther.myMap.Contains(aS)) { + return bRet; + } + } + return !bRet; +} +//======================================================================= +//function : HashCode +//purpose : +//======================================================================= + Standard_Integer GEOMAlgo_PassKeyShape::HashCode(const Standard_Integer aUpper) const +{ + return ::HashCode(mySum, aUpper); +} +//======================================================================= +//function : Dump +//purpose : +//======================================================================= + void GEOMAlgo_PassKeyShape::Dump(const Standard_Integer)const +{ +} +//======================================================================= +// function: NormalizedId +// purpose : +//======================================================================= +Standard_Integer NormalizedId(const Standard_Integer aId, + const Standard_Integer aDiv) +{ + Standard_Integer aMax, aTresh, aIdRet; + // + aIdRet=aId; + aMax=::IntegerLast(); + aTresh=aMax/aDiv; + if (aId>aTresh) { + aIdRet=aId%aTresh; } - GEOMAlgo_PassKey::SetIds(aLI); + return aIdRet; }