1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "BuildPlugin_Shape.h"
23 #include <ModelAPI_AttributeSelectionList.h>
24 #include <ModelAPI_ResultBody.h>
26 #include <GeomAlgoAPI_MakeShape.h>
28 #include <GeomAPI_PlanarEdges.h>
31 //=================================================================================================
32 void BuildPlugin_Shape::storeResult(const GeomMakeShapePtr& theAlgorithm,
33 const ListOfShape& theOriginalShapes,
34 const ListOfShape& theOriginalSolids,
35 const GeomShapePtr& theResultShape,
36 const int theResultIndex)
38 ResultBodyPtr aResultBody = document()->createBody(data(), theResultIndex);
39 aResultBody->storeModified(theOriginalSolids, theResultShape, theAlgorithm);
41 for (ListOfShape::const_iterator anIt = theOriginalShapes.cbegin();
42 anIt != theOriginalShapes.cend();
45 GeomShapePtr aShape = *anIt;
46 aResultBody->loadModifiedShapes(theAlgorithm, aShape, GeomAPI_Shape::VERTEX);
47 aResultBody->loadModifiedShapes(theAlgorithm, aShape, GeomAPI_Shape::EDGE);
48 aResultBody->loadModifiedShapes(theAlgorithm, aShape, GeomAPI_Shape::FACE);
50 setResult(aResultBody, theResultIndex);
53 //=================================================================================================
54 void BuildPlugin_Shape::getOriginalShapesAndContexts(const std::string& theSelectionListID,
55 ListOfShape& theShapes,
56 ListOfShape& theContexts)
58 std::set<GeomShapePtr, GeomAPI_Shape::Comparator> aContexts;
60 AttributeSelectionListPtr aSelectionList = selectionList(theSelectionListID);
61 for (int anIndex = 0; anIndex < aSelectionList->size(); ++anIndex) {
62 AttributeSelectionPtr aSelection = aSelectionList->value(anIndex);
63 GeomShapePtr aShape = aSelection->value();
64 GeomShapePtr aContext = aSelection->context()->shape();
67 theShapes.push_back(aShape);
69 // do not collect sketch faces, because they are stored as compounds
70 // and then are treated as modified by the algorithm
71 if (!std::dynamic_pointer_cast<GeomAPI_PlanarEdges>(aContext).get())
72 aContexts.insert(aContext);
75 std::set<GeomShapePtr, GeomAPI_Shape::Comparator>::const_iterator anIt = aContexts.begin();
76 for (; anIt != aContexts.end(); ++anIt)
77 theContexts.push_back(*anIt);