X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Tools.cpp;h=efdee580134ed3afa36a9cb0b81da35e8df9655b;hb=18c79f681adeded537213e9ff7bc1aef6b87464d;hp=22431b98b62ab11c899b6abfff20a81dfc290b86;hpb=66352ff97e5213cdf3ea8f90ed31a6d3d1803983;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp b/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp index 22431b98b..efdee5801 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Tools.cpp @@ -1,8 +1,22 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: FeaturesPlugin_Tools.cpp -// Created: 17 November 2016 -// Author: Dmitry Bobylev +// Copyright (C) 2014-2017 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 +// 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 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// #include "FeaturesPlugin_Tools.h" @@ -10,41 +24,114 @@ #include -void FeaturesPlugin_Tools::storeModifiedShapes(GeomAlgoAPI_MakeShape& theAlgo, - std::shared_ptr theResultBody, - std::shared_ptr theBaseShape, - int& theTag, - const std::string theName, - GeomAPI_DataMapOfShapeShape& theSubShapes) +//================================================================================================== +void FeaturesPlugin_Tools::loadModifiedShapes(ResultBodyPtr theResultBody, + const GeomShapePtr theBaseShape, + const ListOfShape& theTools, + const GeomMakeShapePtr& theMakeShape, + const GeomShapePtr theResultShape) +{ + if (theBaseShape->isEqual(theResultShape)) { + theResultBody->store(theResultShape, false); + return; + } + + theResultBody->storeModified(theBaseShape, theResultShape); + + ListOfShape aShapes = theTools; + aShapes.push_front(theBaseShape); + + for (ListOfShape::const_iterator anIter = aShapes.begin(); anIter != aShapes.end(); ++anIter) + { + theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::VERTEX); + theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::EDGE); + theResultBody->loadModifiedShapes(theMakeShape, *anIter, GeomAPI_Shape::FACE); + } +} + +//================================================================================================== +void FeaturesPlugin_Tools::loadModifiedShapes(ResultBodyPtr theResultBody, + const GeomShapePtr theBaseShape, + const GeomMakeShapePtr& theMakeShape, + const std::string theName) { switch(theBaseShape->shapeType()) { case GeomAPI_Shape::COMPOUND: { for(GeomAPI_ShapeIterator anIt(theBaseShape); anIt.more(); anIt.next()) { - storeModifiedShapes(theAlgo, theResultBody, theBaseShape, theTag, theName, theSubShapes); - theTag++; + loadModifiedShapes(theResultBody, + anIt.current(), + theMakeShape, + theName); } break; } case GeomAPI_Shape::COMPSOLID: case GeomAPI_Shape::SOLID: case GeomAPI_Shape::SHELL: { - theResultBody->loadAndOrientModifiedShapes(&theAlgo, - theBaseShape, GeomAPI_Shape::FACE, - theTag, theName + "_Face", theSubShapes); - if (theBaseShape->shapeType() == GeomAPI_Shape::COMPSOLID - || theBaseShape->shapeType() == GeomAPI_Shape::SOLID) { - break; - } + theResultBody->loadModifiedShapes(theMakeShape, + theBaseShape, + GeomAPI_Shape::FACE, + theName); } case GeomAPI_Shape::FACE: - case GeomAPI_Shape::WIRE: - theResultBody->loadAndOrientModifiedShapes(&theAlgo, - theBaseShape, GeomAPI_Shape::EDGE, - ++theTag, theName + "_Edge", theSubShapes); - case GeomAPI_Shape::EDGE: - theResultBody->loadAndOrientModifiedShapes(&theAlgo, - theBaseShape, GeomAPI_Shape::VERTEX, - ++theTag, theName + "_Vertex", theSubShapes); + case GeomAPI_Shape::WIRE: { + theResultBody->loadModifiedShapes(theMakeShape, + theBaseShape, + GeomAPI_Shape::EDGE, + theName); + } + case GeomAPI_Shape::EDGE: { + theResultBody->loadModifiedShapes(theMakeShape, + theBaseShape, + GeomAPI_Shape::VERTEX, + theName); + } + } +} + +//================================================================================================== +void FeaturesPlugin_Tools::loadDeletedShapes(ResultBodyPtr theResultBody, + const GeomShapePtr theBaseShape, + const ListOfShape& theTools, + const GeomMakeShapePtr& theMakeShape, + const GeomShapePtr theResultShapesCompound) +{ + ListOfShape aShapes = theTools; + aShapes.push_front(theBaseShape); + + for (ListOfShape::const_iterator anIter = aShapes.begin(); anIter != aShapes.end(); anIter++) + { + theResultBody->loadDeletedShapes(theMakeShape, + *anIter, + GeomAPI_Shape::VERTEX, + theResultShapesCompound); + theResultBody->loadDeletedShapes(theMakeShape, + *anIter, + GeomAPI_Shape::EDGE, + theResultShapesCompound); + theResultBody->loadDeletedShapes(theMakeShape, + *anIter, + GeomAPI_Shape::FACE, + theResultShapesCompound); + } +} + +//================================================================================================== +void FeaturesPlugin_Tools::loadDeletedShapes( + std::vector& theResultBaseAlgoList, + const ListOfShape& theTools, + const GeomShapePtr theResultShapesCompound) +{ + for (std::vector::iterator anIt = theResultBaseAlgoList.begin(); + anIt != theResultBaseAlgoList.end(); + ++anIt) + { + ResultBaseAlgo& aRCA = *anIt; + loadDeletedShapes(aRCA.resultBody, + aRCA.baseShape, + theTools, + aRCA.makeShape, + theResultShapesCompound); } }