1 // Copyright (C) 2014-2022 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 "FeaturesPlugin_Loft.h"
21 #include "FeaturesPlugin_Tools.h"
23 #include <ModelAPI_AttributeSelection.h>
25 #include <GeomAlgoAPI_Copy.h>
26 #include <GeomAlgoAPI_Filling.h>
27 #include <GeomAlgoAPI_ShapeTools.h>
28 #include <GeomAlgoAPI_Tools.h>
29 #include <GeomAPI_Pnt.h>
30 #include <GeomAPI_ShapeExplorer.h>
34 //==================================================================================================
35 FeaturesPlugin_Loft::FeaturesPlugin_Loft()
39 //==================================================================================================
40 void FeaturesPlugin_Loft::initAttributes()
42 data()->addAttribute(FIRST_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
43 data()->addAttribute(SECOND_OBJECT_ID(), ModelAPI_AttributeSelection::typeId());
46 //==================================================================================================
47 void FeaturesPlugin_Loft::execute()
49 AttributeSelectionPtr aFirstSelection = selection(FIRST_OBJECT_ID());
50 AttributeSelectionPtr aSecondelection = selection(SECOND_OBJECT_ID());
52 if (aFirstSelection->isInitialized() && aSecondelection->isInitialized()) {
54 GeomShapePtr aFirstShape, aSecondShape;
56 if (aFirstSelection && aSecondelection) {
57 aFirstShape = aFirstSelection->value();
58 if (!aFirstShape && aFirstSelection->context())
59 aFirstShape = aFirstSelection->context()->shape();
61 aSecondShape = aSecondelection->value();
62 if (!aSecondShape && aSecondelection->context())
63 aSecondShape = aSecondelection->context()->shape();
67 std::shared_ptr<GeomAlgoAPI_Loft> aLoftAlgo(new GeomAlgoAPI_Loft(aFirstShape, aSecondShape));
69 if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aLoftAlgo, getKind(), anError)) {
73 ListOfShape theBoundaryShapes;
74 theBoundaryShapes.push_back(aFirstShape);
75 theBoundaryShapes.push_back(aSecondShape);
77 // Create result body.
78 ResultBodyPtr aResultBody = document()->createBody(data());
80 aResultBody->store(aLoftAlgo->shape());
82 for(GeomAPI_ShapeExplorer anExp(aLoftAlgo->shape(), GeomAPI_Shape::FACE);
83 anExp.more(); anExp.next()) {
84 GeomShapePtr anEdge = anExp.current();
85 aResultBody->generated(anEdge, "Loft_Face");
87 setResult(aResultBody, 0);