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 <PrimitivesPlugin_Tube.h>
22 #include <ModelAPI_AttributeDouble.h>
23 #include <ModelAPI_ResultBody.h>
25 //=================================================================================================
26 PrimitivesPlugin_Tube::PrimitivesPlugin_Tube() // Nothing to do during instantiation
30 //=================================================================================================
31 void PrimitivesPlugin_Tube::initAttributes()
33 data()->addAttribute(PrimitivesPlugin_Tube::RMIN_ID(), ModelAPI_AttributeDouble::typeId());
34 data()->addAttribute(PrimitivesPlugin_Tube::RMAX_ID(), ModelAPI_AttributeDouble::typeId());
35 data()->addAttribute(PrimitivesPlugin_Tube::HEIGHT_ID(), ModelAPI_AttributeDouble::typeId());
38 //=================================================================================================
39 void PrimitivesPlugin_Tube::execute()
41 double aRMin = real(PrimitivesPlugin_Tube::RMIN_ID())->value();
42 double aRMax = real(PrimitivesPlugin_Tube::RMAX_ID())->value();
43 double aZ = real(PrimitivesPlugin_Tube::HEIGHT_ID())->value();
45 std::shared_ptr<GeomAlgoAPI_Tube> aTubeAlgo(new GeomAlgoAPI_Tube(aRMin,aRMax,aZ));
47 // These checks should be made to the GUI for the feature but
48 // the corresponding validator does not exist yet.
49 if (!aTubeAlgo->check()) {
50 setError(aTubeAlgo->getError());
58 ResultBodyPtr aResultTube = document()->createBody(data(), aResultIndex);
59 loadNamingDS(aTubeAlgo, aResultTube);
60 setResult(aResultTube, aResultIndex);
63 //=================================================================================================
64 void PrimitivesPlugin_Tube::loadNamingDS(std::shared_ptr<GeomAlgoAPI_Tube> theTubeAlgo,
65 std::shared_ptr<ModelAPI_ResultBody> theResultTube)
68 theResultTube->store(theTubeAlgo->shape());
71 theTubeAlgo->prepareNamingFaces();
74 std::map< std::string, std::shared_ptr<GeomAPI_Shape> > listOfFaces =
75 theTubeAlgo->getCreatedFaces();
76 for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator it = listOfFaces.begin();
77 it != listOfFaces.end();
80 theResultTube->generated((*it).second, (*it).first);