X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_CompoundBuilder.cpp;h=aee5148791a1a39d12faec0da70cc98638f15212;hb=88ee9b2b81cf93a6324336b57e30cc8a3a487499;hp=6df743c509174546d72c566a057cdf6fde150391;hpb=6e421e939851e0de46554ae45a3ca0e1f67cd91d;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.cpp index 6df743c50..aee514879 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_CompoundBuilder.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// Copyright (C) 2014-2022 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -22,6 +22,7 @@ #include #include #include +#include std::shared_ptr GeomAlgoAPI_CompoundBuilder::compound( std::list > theShapes) @@ -41,6 +42,20 @@ std::shared_ptr GeomAlgoAPI_CompoundBuilder::compound( return aRes; } +// Returns true if transformations are equal with the given precision +static bool isEqual(const gp_Trsf& theT1, const gp_Trsf& theT2, const double thePrecision) +{ + for(int aRow = 1; aRow < 4; aRow++) { + for(int aCol = 1; aCol < 5; aCol++) { + double aDiff = theT1.Value(aRow, aCol) - theT2.Value(aRow, aCol); + if (aDiff < 0) aDiff = -aDiff; + if (aDiff > thePrecision) + return false; + } + } + return true; +} + int GeomAlgoAPI_CompoundBuilder::id( std::shared_ptr theContext, std::shared_ptr theSub) { @@ -51,6 +66,18 @@ int GeomAlgoAPI_CompoundBuilder::id( TopTools_IndexedMapOfShape aSubShapesMap; TopExp::MapShapes(aMainShape, aSubShapesMap); anID = aSubShapesMap.FindIndex(aSubShape); + if (anID == 0) { // try to search shape with the same location if TopLoc_Location is different + TopExp_Explorer anExp(aMainShape, aSubShape.ShapeType()); + for(; anExp.More(); anExp.Next()) { + if (anExp.Current().TShape() == aSubShape.TShape()) { + const TopLoc_Location aLoc1 = anExp.Current().Location(); + if (isEqual(aLoc1.Transformation(), aSubShape.Location().Transformation(), 1.e-7)) { + anID = aSubShapesMap.FindIndex(anExp.Current()); + break; + } + } + } + } } return anID;