1 // Copyright (C) 2017-2019 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_Fillet.h"
22 #include <ModelAPI_AttributeDouble.h>
23 #include <ModelAPI_AttributeSelectionList.h>
24 #include <ModelAPI_AttributeString.h>
25 #include <ModelAPI_Session.h>
26 #include <ModelAPI_Validator.h>
28 #include <GeomAlgoAPI_Fillet.h>
29 #include <GeomAlgoAPI_MakeShape.h>
30 #include <GeomAlgoAPI_Tools.h>
32 #include <GeomAPI_ShapeExplorer.h>
34 // Extract edges from the list
35 static ListOfShape extractEdges(const ListOfShape& theShapes)
38 for (ListOfShape::const_iterator anIt = theShapes.begin(); anIt != theShapes.end(); ++anIt)
39 for (GeomAPI_ShapeExplorer anExp(*anIt, GeomAPI_Shape::EDGE); anExp.more(); anExp.next())
40 anEdges.push_back(anExp.current());
45 FeaturesPlugin_Fillet::FeaturesPlugin_Fillet()
49 void FeaturesPlugin_Fillet::initAttributes()
51 data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId());
52 AttributePtr aSelectionList =
53 data()->addAttribute(OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
54 data()->addAttribute(START_RADIUS_ID(), ModelAPI_AttributeDouble::typeId());
55 data()->addAttribute(END_RADIUS_ID(), ModelAPI_AttributeDouble::typeId());
57 ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), END_RADIUS_ID());
59 initVersion(aSelectionList);
62 AttributePtr FeaturesPlugin_Fillet::objectsAttribute()
64 return attribute(OBJECT_LIST_ID());
67 const std::string& FeaturesPlugin_Fillet::modifiedShapePrefix() const
69 static const std::string& THE_PREFIX("Fillet");
73 GeomMakeShapePtr FeaturesPlugin_Fillet::performOperation(const GeomShapePtr& theSolid,
74 const ListOfShape& theEdges)
76 AttributeStringPtr aCreationMethod = string(CREATION_METHOD());
78 return GeomMakeShapePtr();
80 bool isFixedRadius = aCreationMethod->value() == CREATION_METHOD_SINGLE_RADIUS();
81 double aRadius1 = 0.0, aRadius2 = 0.0;
83 aRadius1 = real(RADIUS_ID())->value();
85 aRadius1 = real(START_RADIUS_ID())->value();
86 aRadius2 = real(END_RADIUS_ID())->value();
89 // Perform fillet operation
90 std::shared_ptr<GeomAlgoAPI_Fillet> aFilletBuilder;
93 ListOfShape aFilletEdges = extractEdges(theEdges);
95 aFilletBuilder.reset(new GeomAlgoAPI_Fillet(theSolid, aFilletEdges, aRadius1));
97 aFilletBuilder.reset(new GeomAlgoAPI_Fillet(theSolid, aFilletEdges, aRadius1, aRadius2));
99 if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFilletBuilder, getKind(), anError)) {
101 return GeomMakeShapePtr();
103 return aFilletBuilder;