From 506a83727ca8f8297fc1dcdf4ea40d7865c35450 Mon Sep 17 00:00:00 2001 From: dbv Date: Fri, 30 Oct 2015 13:26:39 +0300 Subject: [PATCH] Fix for solids color changing after sketch modification --- src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp index 39b06f927..3a4f577ac 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp @@ -24,6 +24,7 @@ #include #include #include +#include //================================================================================================= @@ -148,10 +149,13 @@ void GeomAlgoAPI_ShapeTools::combineShapes(const std::shared_ptr TopoDS_CompSolid aCSolid; TopoDS_Builder aBuilder; theType == GeomAPI_Shape::COMPSOLID ? aBuilder.MakeCompSolid(aCSolid) : aBuilder.MakeShell(aShell); - const NCollection_Map& aShapesMap = anIter.Value(); - for(NCollection_Map::Iterator aShIter(aShapesMap); aShIter.More(); aShIter.Next()) { - const TopoDS_Shape& aShape = aShIter.Value(); - theType == GeomAPI_Shape::COMPSOLID ? aBuilder.Add(aCSolid, aShape) : aBuilder.Add(aShell, aShape); + NCollection_Map& aShapesMap = anIter.ChangeValue(); + for(TopExp_Explorer anExp(aShapesComp, aTA); anExp.More(); anExp.Next()) { + const TopoDS_Shape& aShape = anExp.Current(); + if(aShapesMap.Contains(aShape)) { + theType == GeomAPI_Shape::COMPSOLID ? aBuilder.Add(aCSolid, aShape) : aBuilder.Add(aShell, aShape); + aShapesMap.Remove(aShape); + } } std::shared_ptr aGeomShape(new GeomAPI_Shape); TopoDS_Shape* aSh = theType == GeomAPI_Shape::COMPSOLID ? new TopoDS_Shape(aCSolid) : new TopoDS_Shape(aShell); @@ -160,11 +164,13 @@ void GeomAlgoAPI_ShapeTools::combineShapes(const std::shared_ptr } // Adding free shapes. - for(NCollection_Map::Iterator aShIter(aFreeShapes); aShIter.More(); aShIter.Next()) { - const TopoDS_Shape& aShape = aShIter.Value(); - std::shared_ptr aGeomShape(new GeomAPI_Shape); - aGeomShape->setImpl(new TopoDS_Shape(aShape)); - theFreeShapes.push_back(aGeomShape); + for(TopExp_Explorer anExp(aShapesComp, aTA); anExp.More(); anExp.Next()) { + const TopoDS_Shape& aShape = anExp.Current(); + if(aFreeShapes.Contains(aShape)) { + std::shared_ptr aGeomShape(new GeomAPI_Shape); + aGeomShape->setImpl(new TopoDS_Shape(aShape)); + theFreeShapes.push_back(aGeomShape); + } } } -- 2.39.2