From: jfa Date: Mon, 15 Jan 2024 13:17:43 +0000 (+0000) Subject: Porting to OCCT 7.8.0 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3bee946d01c97a6f1799ca929f0a5753fee21636;p=modules%2Fshaper.git Porting to OCCT 7.8.0 --- diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp index e114d961c..3fb717b75 100644 --- a/src/GeomAPI/GeomAPI_Shape.cpp +++ b/src/GeomAPI/GeomAPI_Shape.cpp @@ -19,6 +19,8 @@ #include "GeomAPI_Shape.h" +#include + #include #include #include @@ -60,8 +62,6 @@ #include #include // for std::transform -#include - #define MY_SHAPE implPtr() GeomAPI_Shape::GeomAPI_Shape() @@ -810,8 +810,13 @@ bool GeomAPI_Shape::Comparator::operator()(const std::shared_ptr& const TopoDS_Shape& aShape2 = theShape2->impl(); bool isLess = aShape1.TShape() < aShape2.TShape(); if (aShape1.TShape() == aShape2.TShape()) { +#if OCC_VERSION_LARGE < 0x07080000 Standard_Integer aHash1 = aShape1.Location().HashCode(IntegerLast()); Standard_Integer aHash2 = aShape2.Location().HashCode(IntegerLast()); +#else + Standard_Integer aHash1 = aShape1.Location().HashCode(); + Standard_Integer aHash2 = aShape2.Location().HashCode(); +#endif isLess = aHash1 < aHash2; } return isLess; @@ -825,8 +830,13 @@ bool GeomAPI_Shape::ComparatorWithOri::operator()( const TopoDS_Shape& aShape2 = theShape2->impl(); bool isLess = aShape1.TShape() < aShape2.TShape(); if (aShape1.TShape() == aShape2.TShape()) { +#if OCC_VERSION_LARGE < 0x07080000 Standard_Integer aHash1 = aShape1.Location().HashCode(IntegerLast()); Standard_Integer aHash2 = aShape2.Location().HashCode(IntegerLast()); +#else + Standard_Integer aHash1 = aShape1.Location().HashCode(); + Standard_Integer aHash2 = aShape2.Location().HashCode(); +#endif isLess = (aHash1 < aHash2) || (aHash1 == aHash2 && aShape1.Orientation() < aShape2.Orientation()); } @@ -836,7 +846,11 @@ bool GeomAPI_Shape::ComparatorWithOri::operator()( int GeomAPI_Shape::Hash::operator()(const std::shared_ptr& theShape) const { const TopoDS_Shape& aShape = theShape->impl(); +#if OCC_VERSION_LARGE < 0x07080000 return aShape.HashCode(IntegerLast()); +#else + return std::hash{}(aShape); +#endif } bool GeomAPI_Shape::Equal::operator()(const std::shared_ptr& theShape1, @@ -845,8 +859,13 @@ bool GeomAPI_Shape::Equal::operator()(const std::shared_ptr& theS const TopoDS_Shape& aShape1 = theShape1->impl(); const TopoDS_Shape& aShape2 = theShape2->impl(); +#if OCC_VERSION_LARGE < 0x07080000 Standard_Integer aHash1 = aShape1.Location().HashCode(IntegerLast()); Standard_Integer aHash2 = aShape2.Location().HashCode(IntegerLast()); +#else + Standard_Integer aHash1 = aShape1.Location().HashCode(); + Standard_Integer aHash2 = aShape2.Location().HashCode(); +#endif return aShape1.TShape() == aShape2.TShape() && aHash1 == aHash2; } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.cpp index c3686dffd..651b1b401 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.cpp @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include #include @@ -153,12 +155,22 @@ bool STEPExport(const std::string& theFileName, Interface_Static::SetCVal("xstep.cascade.unit", "M"); Interface_Static::SetIVal("write.step.nonmanifold", 0); // 1 don't allow to export assemly tree Interface_Static::SetCVal("write.step.unit", "M"); -#else +#elif OCC_VERSION_LARGE < 0x07080000 STEPCAFControl_Writer aWriterTmp; Interface_Static::SetCVal("xstep.cascade.unit", "M"); Interface_Static::SetIVal("write.step.nonmanifold", 0); // 1 don't allow to export assemly tree Interface_Static::SetCVal("write.step.unit", "M"); STEPCAFControl_Writer aWriter; +#else + STEPCAFControl_Writer aWriter; + Interface_Static::SetCVal("xstep.cascade.unit", "M"); + Interface_Static::SetIVal("write.step.nonmanifold", 0); // 1 don't allow to export assemly tree + Interface_Static::SetCVal("write.step.unit", "M"); + Handle(StepData_StepModel) aModel = aWriter.ChangeWriter().Model(); + aModel->InternalParameters.InitFromStatic(); + Standard_Integer aWriteUnitInt = Interface_Static::IVal("write.step.unit"); + Standard_Real aWriteUnitReal = UnitsMethods::GetLengthFactorValue(aWriteUnitInt); + aModel->SetWriteLengthUnit(aWriteUnitReal); #endif auto aStatus = aWriter.Transfer(aDoc, STEPControl_AsIs); diff --git a/src/GeomAlgoImpl/GEOMAlgo_IndexedDataMapOfIntegerShape.hxx b/src/GeomAlgoImpl/GEOMAlgo_IndexedDataMapOfIntegerShape.hxx index c848ff86c..68ad864de 100644 --- a/src/GeomAlgoImpl/GEOMAlgo_IndexedDataMapOfIntegerShape.hxx +++ b/src/GeomAlgoImpl/GEOMAlgo_IndexedDataMapOfIntegerShape.hxx @@ -29,6 +29,11 @@ #include #include + +#include + +#if OCC_VERSION_LARGE < 0x07080000 + #include #define _NCollection_MapHasher @@ -39,6 +44,13 @@ typedef NCollection_IndexedDataMap + +typedef NCollection_IndexedDataMap GEOMAlgo_IndexedDataMapOfIntegerShape; + +#endif // OCC_VERSION_LARGE < 0x07080000 #endif diff --git a/src/GeomAlgoImpl/GEOMAlgo_PassKeyShape.cxx b/src/GeomAlgoImpl/GEOMAlgo_PassKeyShape.cxx index fa0c73ee7..e4ceeb154 100644 --- a/src/GeomAlgoImpl/GEOMAlgo_PassKeyShape.cxx +++ b/src/GeomAlgoImpl/GEOMAlgo_PassKeyShape.cxx @@ -27,6 +27,8 @@ // #include +#include + #include #include @@ -94,7 +96,11 @@ static Clear(); myNbIds=1; myMap.Add(aS1); +#if OCC_VERSION_LARGE < 0x07080000 aHC=aS1.HashCode(myUpper); +#else + aHC = std::hash{}(aS1); +#endif mySum=NormalizedId(aHC, myNbIds); } //======================================================================= @@ -160,7 +166,11 @@ static myNbIds=myMap.Extent(); for(i=1; i<=myNbIds; ++i) { const TopoDS_Shape& aS=myMap(i); +#if OCC_VERSION_LARGE < 0x07080000 aId=aS.HashCode(myUpper); +#else + aId = std::hash{}(aS); +#endif aIdN=NormalizedId(aId, myNbIds); mySum+=aIdN; } @@ -195,6 +205,7 @@ static } return !bRet; } +#if OCC_VERSION_LARGE < 0x07080000 //======================================================================= //function : HashCode //purpose : @@ -203,6 +214,7 @@ static { return ::HashCode(mySum, aUpper); } +#endif //======================================================================= //function : Dump //purpose : diff --git a/src/GeomAlgoImpl/GEOMAlgo_PassKeyShape.hxx b/src/GeomAlgoImpl/GEOMAlgo_PassKeyShape.hxx index 420d9fdac..0f6e79057 100644 --- a/src/GeomAlgoImpl/GEOMAlgo_PassKeyShape.hxx +++ b/src/GeomAlgoImpl/GEOMAlgo_PassKeyShape.hxx @@ -1,5 +1,9 @@ +<<<<<<< HEAD // Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE +======= +// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE +>>>>>>> d24a43759... Porting to OCCT 7.8.0 // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -31,6 +35,8 @@ #include +#include + #include #include #include @@ -92,8 +98,19 @@ class GEOMAlgo_PassKeyShape { GEOMALGOIMPL_EXPORT Standard_Boolean IsEqual(const GEOMAlgo_PassKeyShape& aOther) const; +#if OCC_VERSION_LARGE < 0x07080000 GEOMALGOIMPL_EXPORT Standard_Integer HashCode(const Standard_Integer Upper) const; +#endif + + GEOMALGOIMPL_EXPORT + bool operator==(const GEOMAlgo_PassKeyShape& theOther) const + { + return IsEqual(theOther); + } + + GEOMALGOIMPL_EXPORT + size_t GetSum() const { return (size_t)mySum; } GEOMALGOIMPL_EXPORT void Dump(const Standard_Integer aHex = 0) const; diff --git a/src/GeomAlgoImpl/GEOMAlgo_PassKeyShapeMapHasher.cxx b/src/GeomAlgoImpl/GEOMAlgo_PassKeyShapeMapHasher.cxx index 7e1dccbc1..e926870f9 100644 --- a/src/GeomAlgoImpl/GEOMAlgo_PassKeyShapeMapHasher.cxx +++ b/src/GeomAlgoImpl/GEOMAlgo_PassKeyShapeMapHasher.cxx @@ -27,6 +27,8 @@ // #include +#if OCC_VERSION_LARGE < 0x07080000 + //======================================================================= //function : HashCode //purpose : @@ -45,3 +47,18 @@ { return aPK1.IsEqual(aPK2); } + +#else + +size_t GEOMAlgo_PassKeyShapeMapHasher::operator()(const GEOMAlgo_PassKeyShape& aPKey) const +{ + return aPKey.GetSum(); +} + +bool GEOMAlgo_PassKeyShapeMapHasher::operator()(const GEOMAlgo_PassKeyShape& aPKey1, + const GEOMAlgo_PassKeyShape& aPKey2) const +{ + return aPKey1.IsEqual(aPKey2); +} + +#endif // OCC_VERSION_LARGE < 0x07080000 diff --git a/src/GeomAlgoImpl/GEOMAlgo_PassKeyShapeMapHasher.hxx b/src/GeomAlgoImpl/GEOMAlgo_PassKeyShapeMapHasher.hxx index d6aafc70d..57e456448 100644 --- a/src/GeomAlgoImpl/GEOMAlgo_PassKeyShapeMapHasher.hxx +++ b/src/GeomAlgoImpl/GEOMAlgo_PassKeyShapeMapHasher.hxx @@ -36,6 +36,8 @@ #include #include +#include + //======================================================================= //class : GEOMAlgo_PassKeyShapeMapHasher //purpose : @@ -43,6 +45,7 @@ class GEOMAlgo_PassKeyShapeMapHasher { public: +#if OCC_VERSION_LARGE < 0x07080000 GEOMALGOIMPL_EXPORT static Standard_Integer HashCode(const GEOMAlgo_PassKeyShape& aPKey, const Standard_Integer Upper) ; @@ -50,5 +53,13 @@ class GEOMAlgo_PassKeyShapeMapHasher GEOMALGOIMPL_EXPORT static Standard_Boolean IsEqual(const GEOMAlgo_PassKeyShape& aPKey1, const GEOMAlgo_PassKeyShape& aPKey2) ; +#else + GEOMALGOIMPL_EXPORT + size_t operator()(const GEOMAlgo_PassKeyShape& aPKey) const; + + GEOMALGOIMPL_EXPORT + bool operator()(const GEOMAlgo_PassKeyShape& aPKey1, + const GEOMAlgo_PassKeyShape& aPKey2) const; +#endif // OCC_VERSION_LARGE < 0x07080000 }; #endif diff --git a/src/Model/Model_BodyBuilder.cpp b/src/Model/Model_BodyBuilder.cpp index d397d0a9b..df7d937da 100644 --- a/src/Model/Model_BodyBuilder.cpp +++ b/src/Model/Model_BodyBuilder.cpp @@ -19,6 +19,8 @@ #include +#include + #include #include @@ -932,7 +934,11 @@ int findAmbiguities(const TopoDS_Shape& theShapeIn, continue; Standard_Integer anID = 0; for(TopTools_ListIteratorOfListOfShape aFaceIt(ancestors); aFaceIt.More(); aFaceIt.Next()) { +#if OCC_VERSION_LARGE < 0x07080000 anID ^= HashCode(aFaceIt.ChangeValue(), 1990657); // Pierpont prime +#else + anID ^= ((std::hash{}(aFaceIt.ChangeValue()) & IntegerLast()) % 1990657 + 1); // Pierpont prime +#endif } if (aFacesIDs.IsBound(anID)) { // there found same edge, check they really have same faces const NCollection_List& aSameFaces1 = diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 1927466b4..5f313a855 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -690,7 +690,8 @@ void Model_Document::compactNested() /// references and Boolean and Integer Arrays for the current moment. static bool isEqualContent(Handle(TDF_Attribute) theAttr1, Handle(TDF_Attribute) theAttr2) { - if (Standard_GUID::IsEqual(theAttr1->ID(), TDF_Reference::GetID())) { // reference + Standard_GUID aGUID1 = theAttr1->ID(); + if (aGUID1 == TDF_Reference::GetID()) { // reference Handle(TDF_Reference) aRef1 = Handle(TDF_Reference)::DownCast(theAttr1); Handle(TDF_Reference) aRef2 = Handle(TDF_Reference)::DownCast(theAttr2); if (aRef1.IsNull() && aRef2.IsNull()) @@ -698,7 +699,7 @@ static bool isEqualContent(Handle(TDF_Attribute) theAttr1, Handle(TDF_Attribute) if (aRef1.IsNull() || aRef2.IsNull()) return false; return aRef1->Get().IsEqual(aRef2->Get()) == Standard_True; - } else if (Standard_GUID::IsEqual(theAttr1->ID(), TDataStd_BooleanArray::GetID())) { + } else if (aGUID1 == TDataStd_BooleanArray::GetID()) { Handle(TDataStd_BooleanArray) anArr1 = Handle(TDataStd_BooleanArray)::DownCast(theAttr1); Handle(TDataStd_BooleanArray) anArr2 = Handle(TDataStd_BooleanArray)::DownCast(theAttr2); if (anArr1.IsNull() && anArr2.IsNull()) @@ -716,7 +717,7 @@ static bool isEqualContent(Handle(TDF_Attribute) theAttr1, Handle(TDF_Attribute) } return true; } - } else if (Standard_GUID::IsEqual(theAttr1->ID(), TDataStd_IntegerArray::GetID())) { + } else if (aGUID1 == TDataStd_IntegerArray::GetID()) { Handle(TDataStd_IntegerArray) anArr1 = Handle(TDataStd_IntegerArray)::DownCast(theAttr1); Handle(TDataStd_IntegerArray) anArr2 = Handle(TDataStd_IntegerArray)::DownCast(theAttr2); if (anArr1.IsNull() && anArr2.IsNull()) @@ -734,7 +735,7 @@ static bool isEqualContent(Handle(TDF_Attribute) theAttr1, Handle(TDF_Attribute) } return true; } - } else if (Standard_GUID::IsEqual(theAttr1->ID(), TDataStd_ReferenceArray::GetID())) { + } else if (aGUID1 == TDataStd_ReferenceArray::GetID()) { Handle(TDataStd_ReferenceArray) anArr1 = Handle(TDataStd_ReferenceArray)::DownCast(theAttr1); Handle(TDataStd_ReferenceArray) anArr2 = Handle(TDataStd_ReferenceArray)::DownCast(theAttr2); if (anArr1.IsNull() && anArr2.IsNull()) @@ -752,7 +753,7 @@ static bool isEqualContent(Handle(TDF_Attribute) theAttr1, Handle(TDF_Attribute) } return true; } - } else if (Standard_GUID::IsEqual(theAttr1->ID(), TDataStd_ReferenceList::GetID())) { + } else if (aGUID1 == TDataStd_ReferenceList::GetID()) { Handle(TDataStd_ReferenceList) aList1 = Handle(TDataStd_ReferenceList)::DownCast(theAttr1); Handle(TDataStd_ReferenceList) aList2= Handle(TDataStd_ReferenceList)::DownCast(theAttr2); if (aList1.IsNull() && aList2.IsNull()) @@ -768,7 +769,7 @@ static bool isEqualContent(Handle(TDF_Attribute) theAttr1, Handle(TDF_Attribute) return false; } return !aLIter1.More() && !aLIter2.More(); // both lists are with the same size - } else if (Standard_GUID::IsEqual(theAttr1->ID(), TDF_TagSource::GetID())) { + } else if (aGUID1 == TDF_TagSource::GetID()) { return true; // it just for created and removed feature: nothing is changed } return false; @@ -797,7 +798,7 @@ static bool isEmptyTransaction(const Handle(TDocStd_Document)& theDoc) { continue; // attribute is not changed actually } } else - if (Standard_GUID::IsEqual(anADelta->Attribute()->ID(), TDataStd_AsciiString::GetID())) { + if (anADelta->Attribute()->ID() == TDataStd_AsciiString::GetID()) { continue; // error message is disappeared } } diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 7aa4407bf..544b5bef8 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -18,6 +18,9 @@ // #include + +#include + #include #include #include @@ -47,14 +50,18 @@ #include #include #include -#include #include #include +#if OCC_VERSION_LARGE < 0x07080000 + +#include // for TDF_Label map usage static Standard_Integer HashCode(const TDF_Label& theLab, const Standard_Integer theUpper); static Standard_Boolean IsEqual(const TDF_Label& theLab1, const TDF_Label& theLab2); +#endif + int kUNDEFINED_FEATURE_INDEX = -1; static const std::string& groupNameFoldering(const std::string& theGroupID, @@ -1491,7 +1498,7 @@ std::shared_ptr Model_Objects::findFolder( int aRefIndex = aRefs->Lower(); for(; aRefIndex <= aRefs->Upper(); ++aRefIndex) { // iterate all existing features TDF_Label aCurLabel = aRefs->Value(aRefIndex); - if (IsEqual(aCurLabel, aFirstFeatureLabel)) + if (aCurLabel.IsEqual(aFirstFeatureLabel)) break; // no need to continue searching // searching the folder below, just continue to search last feature from the list @@ -1502,7 +1509,7 @@ std::shared_ptr Model_Objects::findFolder( // because the folder may end by the feature which is // neither a sub-feature nor a feature in history. if (!aLastFeatureInFolder.IsNull()) { - if (IsEqual(aCurLabel, aLastFeatureInFolder)) + if (aCurLabel.IsEqual(aLastFeatureInFolder)) aLastFeatureInFolder.Nullify(); // the last feature in the folder is achieved continue; } @@ -2112,6 +2119,7 @@ std::shared_ptr Model_Objects::internalFeature(const int theIn return FeaturePtr(); // invalid } +#if OCC_VERSION_LARGE < 0x07080000 Standard_Integer HashCode(const TDF_Label& theLab, const Standard_Integer theUpper) { return TDF_LabelMapHasher::HashCode(theLab, theUpper); @@ -2120,3 +2128,4 @@ Standard_Boolean IsEqual(const TDF_Label& theLab1, const TDF_Label& theLab2) { return TDF_LabelMapHasher::IsEqual(theLab1, theLab2); } +#endif