1 // version 2.1 of the License, or (at your option) any later version.
3 // This library is distributed in the hope that it will be useful,
4 // but WITHOUT ANY WARRANTY; without even the implied warranty of
5 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6 // Lesser General Public License for more details.
8 // You should have received a copy of the GNU Lesser General Public
9 // License along with this library; if not, write to the Free Software
10 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
12 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
15 #include <PrimitivesPlugin_Tube.h>
17 #include <ModelAPI_AttributeDouble.h>
18 #include <ModelAPI_ResultBody.h>
20 //=================================================================================================
21 PrimitivesPlugin_Tube::PrimitivesPlugin_Tube() // Nothing to do during instantiation
25 //=================================================================================================
26 void PrimitivesPlugin_Tube::initAttributes()
28 data()->addAttribute(PrimitivesPlugin_Tube::RMIN_ID(), ModelAPI_AttributeDouble::typeId());
29 data()->addAttribute(PrimitivesPlugin_Tube::RMAX_ID(), ModelAPI_AttributeDouble::typeId());
30 data()->addAttribute(PrimitivesPlugin_Tube::HEIGHT_ID(), ModelAPI_AttributeDouble::typeId());
33 //=================================================================================================
34 void PrimitivesPlugin_Tube::execute()
36 double aRMin = real(PrimitivesPlugin_Tube::RMIN_ID())->value();
37 double aRMax = real(PrimitivesPlugin_Tube::RMAX_ID())->value();
38 double aZ = real(PrimitivesPlugin_Tube::HEIGHT_ID())->value();
40 std::shared_ptr<GeomAlgoAPI_Tube> aTubeAlgo(new GeomAlgoAPI_Tube(aRMin,aRMax,aZ));
42 // These checks should be made to the GUI for the feature but
43 // the corresponding validator does not exist yet.
44 if (!aTubeAlgo->check()) {
45 setError(aTubeAlgo->getError());
53 ResultBodyPtr aResultTube = document()->createBody(data(), aResultIndex);
54 loadNamingDS(aTubeAlgo, aResultTube);
55 setResult(aResultTube, aResultIndex);
58 //=================================================================================================
59 void PrimitivesPlugin_Tube::loadNamingDS(std::shared_ptr<GeomAlgoAPI_Tube> theTubeAlgo,
60 std::shared_ptr<ModelAPI_ResultBody> theResultTube)
63 theResultTube->store(theTubeAlgo->shape());
66 theTubeAlgo->prepareNamingFaces();
69 std::map< std::string, std::shared_ptr<GeomAPI_Shape> > listOfFaces =
70 theTubeAlgo->getCreatedFaces();
71 for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator it = listOfFaces.begin();
72 it != listOfFaces.end();
75 theResultTube->generated((*it).second, (*it).first);