1 // Copyright (C) 2014-2020 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "BuildPlugin_Shape.h"
22 #include <ModelAPI_AttributeSelectionList.h>
23 #include <ModelAPI_ResultBody.h>
25 #include <GeomAlgoAPI_MakeShape.h>
27 #include <GeomAPI_PlanarEdges.h>
30 //=================================================================================================
31 void BuildPlugin_Shape::storeResult(const GeomMakeShapePtr& theAlgorithm,
32 const ListOfShape& theOriginalShapes,
33 const ListOfShape& theOriginalSolids,
34 const GeomShapePtr& theResultShape,
35 const int theResultIndex)
37 ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex);
38 aResultBody->storeModified(theOriginalSolids, theResultShape, theAlgorithm);
40 for (ListOfShape::const_iterator anIt = theOriginalShapes.cbegin();
41 anIt != theOriginalShapes.cend();
44 GeomShapePtr aShape = *anIt;
45 aResultBody->loadModifiedShapes(theAlgorithm, aShape, GeomAPI_Shape::VERTEX);
46 aResultBody->loadModifiedShapes(theAlgorithm, aShape, GeomAPI_Shape::EDGE);
47 aResultBody->loadModifiedShapes(theAlgorithm, aShape, GeomAPI_Shape::FACE);
49 setResult(aResultBody, theResultIndex);
52 //=================================================================================================
53 void BuildPlugin_Shape::getOriginalShapesAndContexts(const std::string& theSelectionListID,
54 ListOfShape& theShapes,
55 ListOfShape& theContexts)
57 std::set<GeomShapePtr, GeomAPI_Shape::Comparator> aContexts;
59 AttributeSelectionListPtr aSelectionList = selectionList(theSelectionListID);
60 for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
61 AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
62 GeomShapePtr aShape = aSelection->value();
63 GeomShapePtr aContext = aSelection->context()->shape();
66 theShapes.push_back(aShape);
68 // do not collect sketch faces, because they are stored as compounds
69 // and then are treated as modified by the algorithm
70 if (!std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aContext).get())
71 aContexts.insert(aContext);
74 std::set<GeomShapePtr, GeomAPI_Shape::Comparator>::const_iterator anIt = aContexts.begin();
75 for (; anIt != aContexts.end(); ++anIt)
76 theContexts.push_back(*anIt);