X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FFeaturesPlugin%2FFeaturesPlugin_Intersection.cpp;h=e557498945a3add650f18bbbd6c4fa805341670b;hb=ca925f26180f15699a77e76461679f11abd499ba;hp=3e04656b11108d6f67e0a9a81b6e95584331025a;hpb=423c10234142d14d0d5de89383f2f96a4ec5930f;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/FeaturesPlugin_Intersection.cpp b/src/FeaturesPlugin/FeaturesPlugin_Intersection.cpp index 3e04656b1..e55749894 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Intersection.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Intersection.cpp @@ -1,8 +1,22 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> - -// File: FeaturesPlugin_Intersection.cpp -// Created: 15 Feb 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_Intersection.h" @@ -13,6 +27,7 @@ #include #include +#include #include @@ -107,35 +122,81 @@ void FeaturesPlugin_Intersection::loadNamingDS(std::shared_ptr aResultShape = theMakeShape.shape(); - std::shared_ptr aMapOfShapes = theMakeShape.mapOfSubShapes(); - const int aDeletedTag = 1; - /// sub solids will be placed at labels 3, 4, etc. if result is compound of solids - const int aSubsolidsTag = 2; - const int aModifyTag = 100000; - int aModifyToolsTag = 200000; - std::ostringstream aStream; - - theResultBody->storeModified(theBaseShape, aResultShape, aSubsolidsTag); - - std::string aModName = "Modified"; - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::VERTEX, - aModifyTag, aModName, *aMapOfShapes.get(), true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::EDGE, - aModifyTag, aModName, *aMapOfShapes.get(), true); - theResultBody->loadDeletedShapes(&theMakeShape, theBaseShape, GeomAPI_Shape::FACE, aDeletedTag); - - int anIndex = 1; - for(ListOfShape::const_iterator anIter = theTools.begin(); anIter != theTools.end(); anIter++) { - aStream.str(std::string()); - aStream.clear(); - aStream << aModName << "_" << anIndex++; - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::VERTEX, - aModifyToolsTag, aStream.str(), *aMapOfShapes.get(), true); - theResultBody->loadAndOrientModifiedShapes(&theMakeShape, *anIter, GeomAPI_Shape::EDGE, - aModifyToolsTag, aStream.str(), *aMapOfShapes.get(), true); - theResultBody->loadDeletedShapes(&theMakeShape, *anIter, GeomAPI_Shape::FACE, aDeletedTag); - aModifyToolsTag += 10000; + theResultBody->storeModified(theBaseShape, aResultShape); + + const int aDeletedVertexTag = 1; + const int aDeletedEdgeTag = 2; + const int aDeletedFaceTag = 3; + + theResultBody->loadDeletedShapes(&theMakeShape, + theBaseShape, + GeomAPI_Shape::VERTEX, + aDeletedVertexTag); + theResultBody->loadDeletedShapes(&theMakeShape, + theBaseShape, + GeomAPI_Shape::EDGE, + aDeletedEdgeTag); + theResultBody->loadDeletedShapes(&theMakeShape, + theBaseShape, + GeomAPI_Shape::FACE, + aDeletedFaceTag); + + ListOfShape aShapes = theTools; + aShapes.push_back(theBaseShape); + GeomAPI_DataMapOfShapeShape aShapesMap; // Map to store {result_shape, original_shape} + const int aShapeTypesNb = 2; + const GeomAPI_Shape::ShapeType aShapeTypes[aShapeTypesNb] = + {GeomAPI_Shape::VERTEX, GeomAPI_Shape::EDGE}; + for(ListOfShape::const_iterator anIt = aShapes.cbegin(); anIt != aShapes.cend(); ++anIt) { + const GeomShapePtr aShape = *anIt; + for(int anIndex = 0; anIndex < aShapeTypesNb; ++anIndex) { + for(GeomAPI_ShapeExplorer anOrigShapeExp(aShape, aShapeTypes[anIndex]); + anOrigShapeExp.more(); + anOrigShapeExp.next()) { + ListOfShape aHistory; + const GeomShapePtr aSubShape = anOrigShapeExp.current(); + theMakeShape.modified(aSubShape, aHistory); + for(ListOfShape::const_iterator aHistoryIt = aHistory.cbegin(); + aHistoryIt != aHistory.cend(); + ++aHistoryIt) { + aShapesMap.bind(*aHistoryIt, aSubShape); + } + } + } + } + + int aModifiedVertexIndex(1), + aGeneratedVertexIndex(1), + aModifiedEdgeIndex(1), + aGeneratedEdgeIndex(1); + int aTag = 4; + GeomAPI_DataMapOfShapeShape aStoredShapes; + for(int anIndex = 0; anIndex < aShapeTypesNb; ++anIndex) { + for(GeomAPI_ShapeExplorer aShapeExp(aResultShape, aShapeTypes[anIndex]); + aShapeExp.more(); + aShapeExp.next()) { + const GeomShapePtr aSubShape = aShapeExp.current(); + if(aStoredShapes.isBound(aSubShape)) { + continue; + } + if(aShapesMap.isBound(aSubShape)) { + theResultBody->modified(aShapesMap.find(aSubShape), + aSubShape, + std::string("Modified_") + + (anIndex == 0 ? "Vertex_" : "Edge_") + + std::to_string((long long)(anIndex == 0 ? aModifiedVertexIndex++ + : aModifiedEdgeIndex++)), + aTag++); + } else { + theResultBody->generated(aSubShape, + std::string("Generated_") + + (anIndex == 0 ? "Vertex_" : "Edge_") + + std::to_string((long long)(anIndex == 0 ? aGeneratedVertexIndex++ + : aGeneratedEdgeIndex++)), + aTag++); + } + aStoredShapes.bind(aSubShape, aSubShape); + } } }