From 273b7e012655bd6a4cbcdfb0cee9cc30c939f7de Mon Sep 17 00:00:00 2001 From: cg246364 Date: Wed, 4 Nov 2020 15:24:19 +0100 Subject: [PATCH] Adding the Tube primitive --- src/GeomAlgoAPI/CMakeLists.txt | 2 + src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h | 2 + src/GeomAlgoAPI/GeomAlgoAPI_Tube.cpp | 225 ++++++++++++++++++ src/GeomAlgoAPI/GeomAlgoAPI_Tube.h | 73 ++++++ src/PrimitivesPlugin/CMakeLists.txt | 3 + .../PrimitivesPlugin_Plugin.cpp | 3 + .../PrimitivesPlugin_Tube.cpp | 129 ++++++++++ src/PrimitivesPlugin/PrimitivesPlugin_Tube.h | 130 ++++++++++ src/PrimitivesPlugin/plugin-Primitives.xml | 6 + src/PrimitivesPlugin/tube_widget.xml | 81 +++++++ 10 files changed, 654 insertions(+) create mode 100644 src/GeomAlgoAPI/GeomAlgoAPI_Tube.cpp create mode 100644 src/GeomAlgoAPI/GeomAlgoAPI_Tube.h create mode 100644 src/PrimitivesPlugin/PrimitivesPlugin_Tube.cpp create mode 100644 src/PrimitivesPlugin/PrimitivesPlugin_Tube.h create mode 100644 src/PrimitivesPlugin/tube_widget.xml diff --git a/src/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index 3349b7968..550f9b569 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -82,6 +82,7 @@ SET(PROJECT_HEADERS GeomAlgoAPI_SolidClassifier.h GeomAlgoAPI_MapShapesAndAncestors.h GeomAlgoAPI_Chamfer.h + GeomAlgoAPI_Tube.h GeomAlgoAPI_ROOTExport.h ) @@ -145,6 +146,7 @@ SET(PROJECT_SOURCES GeomAlgoAPI_MapShapesAndAncestors.cpp GeomAlgoAPI_Projection.cpp GeomAlgoAPI_Chamfer.cpp + GeomAlgoAPI_Tube.cpp GeomAlgoAPI_ROOTExport.cpp ) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h index a840233ec..0f3ab0646 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h @@ -28,6 +28,8 @@ #include #include +#define ANGULAR_PRECISION Precision::Angular() * 180. / M_PI + /// \class GeomAlgoAPI_MakeShape /// \ingroup DataAlgo /// \brief Interface to the root class of all topological shapes constructions diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Tube.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Tube.cpp new file mode 100644 index 000000000..770c479df --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Tube.cpp @@ -0,0 +1,225 @@ +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include + +//================================================================================================= +GeomAlgoAPI_Tube::GeomAlgoAPI_Tube() +{ +} + + +//================================================================================================= +GeomAlgoAPI_Tube::GeomAlgoAPI_Tube(const double theRMin, const double theRMax, const double theZ) +{ + isSimple = true; + + myRMin = theRMin; + myRMax = theRMax; + myZ = theZ; +} + +//================================================================================================= +GeomAlgoAPI_Tube::GeomAlgoAPI_Tube(const double theRMin, const double theRMax, const double theZ, + const double theStartPhi, const double theDeltaPhi) +{ + isSimple = false; + + myRMin = theRMin; + myRMax = theRMax; + myZ = theZ; + myStartPhi = theStartPhi; + myDeltaPhi = theDeltaPhi; +} + +//================================================================================================= +bool GeomAlgoAPI_Tube::check() +{ + if ((myRMax - myRMin) < Precision::Confusion()){ + myError = "Tube builder :: rmin is greater than or equal to rmax."; + return false; + } else if (myRMin < 0.){ + myError = "Tube builder :: rmin is negative."; + return false; + } else if (myRMax < Precision::Confusion()){ + myError = "Tube builder :: rmax is negative or null."; + return false; + } else if (myZ < Precision::Confusion()){ + myError = "Tube builder :: z is negative or null."; + return false; + } + + if (!isSimple) { + if (myDeltaPhi < ANGULAR_PRECISION){ + myError = "Tube builder :: deltaphi is negative or null."; + return false; + } else if (myDeltaPhi > 360.){ + myError = "Tube builder :: deltaphi is greater than 360 degrees."; + return false; + } + } + + return true; +} + +//================================================================================================= +void GeomAlgoAPI_Tube::build() +{ + myCreatedFaces.clear(); + + std::shared_ptr aResultShape; + if (isSimple) + aResultShape = buildSimpleTube(); + else + aResultShape = buildSegmentTube(); + + // Test on the shapes + if (!(aResultShape).get() || aResultShape->isNull()) { + myError = ""; + return; + } + + setShape(aResultShape); + setDone(true); +} + +//================================================================================================= +std::shared_ptr GeomAlgoAPI_Tube::buildSimpleTube() +{ + // Construct the inner and outer circles + gp_Pnt anOrigin(0., 0., 0.); + gp_Dir aNormal(0., 0., 1.); + gp_Circ anInnerCircle(gp_Ax2(anOrigin, aNormal), myRMin); + gp_Circ anOuterCircle(gp_Ax2(anOrigin, aNormal), myRMax); + + // Construct the outer wire + BRepBuilderAPI_MakeEdge anOuterCircleBuilder(anOuterCircle); + anOuterCircleBuilder.Build(); + BRepBuilderAPI_MakeWire anOuterWireBuilder; + anOuterWireBuilder.Add(anOuterCircleBuilder.Edge()); + anOuterWireBuilder.Build(); + TopoDS_Wire anOuterWire(anOuterWireBuilder.Wire()); + + // Construct the face with the outer wire + BRepBuilderAPI_MakeFace aFaceBuilder(anOuterWireBuilder.Wire()); + aFaceBuilder.Build(); + TopoDS_Face aFace(aFaceBuilder.Face()); + + // Construct the inner wire + BRepBuilderAPI_MakeEdge anInnerCircleBuilder(anInnerCircle); + anInnerCircleBuilder.Build(); + BRepBuilderAPI_MakeWire anInnerWireBuilder; + anInnerWireBuilder.Add(anInnerCircleBuilder.Edge()); + anInnerWireBuilder.Build(); + TopoDS_Wire anInnerWire(anInnerWireBuilder.Wire()); + + // Construct the hole face + BRepAlgo_FaceRestrictor aFRestrictor; + aFRestrictor.Init(aFace, Standard_False, Standard_True); + aFRestrictor.Add(anInnerWire); + aFRestrictor.Add(anOuterWire); + aFRestrictor.Perform(); + aFace = TopoDS_Face(aFRestrictor.Current()); + + // Construct the tube + gp_Vec aVec(aNormal); + BRepPrimAPI_MakePrism* aPrismBuilder = new BRepPrimAPI_MakePrism(aFace, aVec * myZ); + + setImpl(aPrismBuilder); + setBuilderType(OCCT_BRepBuilderAPI_MakeShape); + + std::shared_ptr aResultShape = + std::shared_ptr(new GeomAPI_Shape()); + aResultShape->setImpl(new TopoDS_Shape(aPrismBuilder->Shape())); + + return aResultShape; +} + +//================================================================================================= +std::shared_ptr GeomAlgoAPI_Tube::buildSegmentTube() +{ + const double aStartPhiRad = myStartPhi * M_PI / 180.; + BRepBuilderAPI_MakeWire aWireBuilder; + + // Build the 4 points defining the section's vertices (it's a simple rectangular section) + gp_Pnt aTopOuter(myRMax*cos(aStartPhiRad), myRMax*sin(aStartPhiRad),myZ/2.); + gp_Pnt aBaseOuter(myRMax*cos(aStartPhiRad), myRMax*sin(aStartPhiRad),-myZ/2.); + gp_Pnt aTopInner(myRMin*cos(aStartPhiRad), myRMin*sin(aStartPhiRad),myZ/2.); + gp_Pnt aBaseInner(myRMin*cos(aStartPhiRad), myRMin*sin(aStartPhiRad),-myZ/2.); + + // Build the edges of the section's outline, add them to a wire + BRepBuilderAPI_MakeEdge anEdgeBuilderTop(aTopOuter, aTopInner); + anEdgeBuilderTop.Build(); + aWireBuilder.Add(anEdgeBuilderTop.Edge()); + BRepBuilderAPI_MakeEdge anEdgeBuilderInner(aTopInner, aBaseInner); + anEdgeBuilderInner.Build(); + aWireBuilder.Add(anEdgeBuilderInner.Edge()); + BRepBuilderAPI_MakeEdge anEdgeBuilderBase(aBaseInner, aBaseOuter); + anEdgeBuilderBase.Build(); + aWireBuilder.Add(anEdgeBuilderBase.Edge()); + BRepBuilderAPI_MakeEdge anEdgeBuilderOuter(aBaseOuter, aTopOuter); + anEdgeBuilderOuter.Build(); + aWireBuilder.Add(anEdgeBuilderOuter.Edge()); + + // Build the section (face) from the wire + aWireBuilder.Build(); + BRepBuilderAPI_MakeFace aFaceBuilder(aWireBuilder.Wire()); + aFaceBuilder.Build(); + + if (!aFaceBuilder.IsDone()){ + myError = "Tube Segment builder :: section is not valid"; + return; + } + + // Create the mathematical tools needed to perform the revolution + gp_Dir aZDir(0., 0., 1.); + gp_Pnt anOrigin(0., 0., 0.); + gp_Ax1 aZAxis(anOrigin, aZDir); + + // Perform the revolution using the section + BRepPrimAPI_MakeRevol* aRevolBuilder = new BRepPrimAPI_MakeRevol(aFaceBuilder.Face(), aZAxis, myDeltaPhi * M_PI / 180., Standard_True); + if(!aRevolBuilder) { + return; + myError = "Tube Segment builder :: section revolution did not succeed"; + } + if(!aRevolBuilder->IsDone()) { + myError = "Tube Segment builder :: section revolution did not succeed"; + return; + } + + // Store the result and publish it + std::shared_ptr aResultShape = std::shared_ptr(new GeomAPI_Shape()) ; + aResultShape->setImpl(new TopoDS_Shape(aRevolBuilder->Shape())); + + return aResultShape; +} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Tube.h b/src/GeomAlgoAPI/GeomAlgoAPI_Tube.h new file mode 100644 index 000000000..d93ff2444 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Tube.h @@ -0,0 +1,73 @@ +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef GeomAlgoAPI_Tube_H_ +#define GeomAlgoAPI_Tube_H_ + +#include + +/**\class GeomAlgoAPI_TubeSegment + * \ingroup DataAlgo + * \brief Allows to create Tube Segment GDML Primitives + */ +class GeomAlgoAPI_Tube : public GeomAlgoAPI_MakeShape +{ + public: + GEOMALGOAPI_EXPORT GeomAlgoAPI_Tube(); + + /// Creates a tube segment using standard GDML parameters + /// \param theRMin inside radius of segment + /// \param theRMax outside radius of segment + /// \param theZ z length of tube segment + GEOMALGOAPI_EXPORT GeomAlgoAPI_Tube(const double theRMin, + const double theRMax, + const double theZ); + + /// Creates a tube segment using standard GDML parameters + /// \param theRMin inside radius of segment + /// \param theRMax outside radius of segment + /// \param theZ z length of tube segment + /// \param theStartPhi starting phi position angle of segment + /// \param theDeltaPhi delta angle of segment + GEOMALGOAPI_EXPORT GeomAlgoAPI_Tube(const double theRMin, + const double theRMax, + const double theZ, + const double theStartPhi, + const double theDeltaPhi); + + /// Checks if the set of parameters used to define the tube are OK. + GEOMALGOAPI_EXPORT bool check(); + + /// Builds the tube based on the parameters given in the constructor. + GEOMALGOAPI_EXPORT void build(); + + private: + bool isSimple; /// attribute to indicate whether we are building a simple tube + double myRMin; /// attribute inside radius of segment + double myRMax; /// attribute outside radius of segment + double myZ; /// attribute z length of tube segment + double myStartPhi; /// attribute starting phi position angle of segment + double myDeltaPhi; /// attribute delta angle of segment + + std::shared_ptr buildSimpleTube(); + std::shared_ptr buildSegmentTube(); +}; + +#endif + diff --git a/src/PrimitivesPlugin/CMakeLists.txt b/src/PrimitivesPlugin/CMakeLists.txt index 244061636..f95a42781 100644 --- a/src/PrimitivesPlugin/CMakeLists.txt +++ b/src/PrimitivesPlugin/CMakeLists.txt @@ -25,6 +25,7 @@ SET(PROJECT_HEADERS PrimitivesPlugin_Cylinder.h PrimitivesPlugin_Sphere.h PrimitivesPlugin_Torus.h + PrimitivesPlugin_Tube.h ) SET(PROJECT_SOURCES @@ -34,6 +35,7 @@ SET(PROJECT_SOURCES PrimitivesPlugin_Cylinder.cpp PrimitivesPlugin_Sphere.cpp PrimitivesPlugin_Torus.cpp + PrimitivesPlugin_Tube.cpp ) SET(XML_RESOURCES @@ -43,6 +45,7 @@ SET(XML_RESOURCES cylinder_widget.xml sphere_widget.xml torus_widget.xml + tube_widget.xml ) SET(TEXT_RESOURCES diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Plugin.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Plugin.cpp index df8427825..e0a0e7507 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Plugin.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Plugin.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -52,6 +53,8 @@ FeaturePtr PrimitivesPlugin_Plugin::createFeature(std::string theFeatureID) return FeaturePtr(new PrimitivesPlugin_Sphere); } else if (theFeatureID == PrimitivesPlugin_Torus::ID()) { return FeaturePtr(new PrimitivesPlugin_Torus); + } else if (theFeatureID == PrimitivesPlugin_Tube::ID()) { + return FeaturePtr(new PrimitivesPlugin_Tube); } // feature of such kind is not found return FeaturePtr(); diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Tube.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Tube.cpp new file mode 100644 index 000000000..b8c4a6e0b --- /dev/null +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Tube.cpp @@ -0,0 +1,129 @@ +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include + +#include +#include +#include + +//================================================================================================= +PrimitivesPlugin_Tube::PrimitivesPlugin_Tube() // Nothing to do during instantiation +{ +} + +//================================================================================================= +void PrimitivesPlugin_Tube::initAttributes() +{ + data()->addAttribute(PrimitivesPlugin_Tube::CREATION_METHOD(), ModelAPI_AttributeString::typeId()); + + data()->addAttribute(PrimitivesPlugin_Tube::RMIN_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(PrimitivesPlugin_Tube::RMAX_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(PrimitivesPlugin_Tube::Z_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(PrimitivesPlugin_Tube::START_PHI_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(PrimitivesPlugin_Tube::DELTA_PHI_ID(), ModelAPI_AttributeDouble::typeId()); +} + +//================================================================================================= +void PrimitivesPlugin_Tube::execute() +{ + AttributeStringPtr aMethodTypeAttr = string(PrimitivesPlugin_Tube::CREATION_METHOD()); + std::string aMethodType = aMethodTypeAttr->value(); + + if (aMethodType == METHODE_SIMPLE_TUBE_ID()) + createSimpleTube(); + + if (aMethodType == METHODE_SEGMENT_TUBE_ID()) + createSegmentTube(); +} + +//================================================================================================= +void PrimitivesPlugin_Tube::createSimpleTube() +{ + double aRMin = real(PrimitivesPlugin_Tube::RMIN_ID())->value(); + double aRMax = real(PrimitivesPlugin_Tube::RMAX_ID())->value(); + double aZ = real(PrimitivesPlugin_Tube::Z_ID())->value(); + + std::shared_ptr aTubeAlgo(new GeomAlgoAPI_Tube(aRMin,aRMax,aZ)); + + // These checks should be made to the GUI for the feature but + // the corresponding validator does not exist yet. + if (!aTubeAlgo->check()) { + setError(aTubeAlgo->getError()); + return; + } + + // Build the tube + aTubeAlgo->build(); + + int aResultIndex = 0; + ResultBodyPtr aResultTube = document()->createBody(data(), aResultIndex); + loadNamingDS(aTubeAlgo, aResultTube); + setResult(aResultTube, aResultIndex); +} + +//================================================================================================= +void PrimitivesPlugin_Tube::createSegmentTube() +{ + double aRMin = real(PrimitivesPlugin_Tube::RMIN_ID())->value(); + double aRMax = real(PrimitivesPlugin_Tube::RMAX_ID())->value(); + double aZ = real(PrimitivesPlugin_Tube::Z_ID())->value(); + double aStartPhi =real(PrimitivesPlugin_Tube::START_PHI_ID())->value(); + double aDelatPhi =real(PrimitivesPlugin_Tube::DELTA_PHI_ID())->value(); + + std::shared_ptr aTubeAlgo(new GeomAlgoAPI_Tube(aRMin,aRMax,aZ, + aStartPhi, aDelatPhi)); + + // These checks should be made to the GUI for the feature but + // the corresponding validator does not exist yet. + if (!aTubeAlgo->check()) { + setError(aTubeAlgo->getError()); + return; + } + + // Build the tube + aTubeAlgo->build(); + + int aResultIndex = 0; + ResultBodyPtr aResultTube = document()->createBody(data(), aResultIndex); + loadNamingDS(aTubeAlgo, aResultTube); + setResult(aResultTube, aResultIndex); +} + +//================================================================================================= +void PrimitivesPlugin_Tube::loadNamingDS(std::shared_ptr theTubeAlgo, + std::shared_ptr theResultTube) +{ + // Load the result + theResultTube->store(theTubeAlgo->shape()); + + // Prepare the naming + theTubeAlgo->prepareNamingFaces(); + + // Insert to faces + int num = 1; + std::map< std::string, std::shared_ptr > listOfFaces = + theTubeAlgo->getCreatedFaces(); + for (std::map< std::string, std::shared_ptr >::iterator it = listOfFaces.begin(); + it != listOfFaces.end(); + ++it) + { + theResultTube->generated((*it).second, (*it).first); + } +} diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Tube.h b/src/PrimitivesPlugin/PrimitivesPlugin_Tube.h new file mode 100644 index 000000000..8d968f6af --- /dev/null +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Tube.h @@ -0,0 +1,130 @@ +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef PrimitivesPlugin_Tube_H_ +#define PrimitivesPlugin_Tube_H_ + +#include +#include +#include + +/// \class PrimitivesPlugin_Tube +/// \ingroup Plugins +/// \brief Feature for creation of a tube primitive using various methods. +/// +/// ToDo +/// Supported following methods: +/// * two points that define a diagonal, +/// * three lengths that define the rectangular dimensions, +/// * one point and three lengths that define the rectangular dimensions. +class PrimitivesPlugin_Tube : public ModelAPI_Feature +{ + public: + /// Tube kind + inline static const std::string& ID() + { + static const std::string MY_TUBE_ID("Tube"); + return MY_TUBE_ID; + } + + /// Attribute name for creation method + inline static const std::string& CREATION_METHOD() + { + static const std::string MY_CREATION_METHOD_ID("CreationMethod"); + return MY_CREATION_METHOD_ID; + } + + /// Attribute name for creation method + inline static const std::string& METHODE_SIMPLE_TUBE_ID() + { + static const std::string MY_CREATION_METHOD_ID("SimpleTube"); + return MY_CREATION_METHOD_ID; + } + + /// Attribute name for creation method + inline static const std::string& METHODE_SEGMENT_TUBE_ID() + { + static const std::string MY_CREATION_METHOD_ID("SegmentTube"); + return MY_CREATION_METHOD_ID; + } + + /// Attribute name of the inner radius of tube + inline static const std::string& RMIN_ID() + { + static const std::string MY_RMIN("rmin"); + return MY_RMIN; + } + + /// Attribute name of the outer radius of tube + inline static const std::string& RMAX_ID() + { + static const std::string MY_RMAX("rmax"); + return MY_RMAX; + } + + /// Attribute name of the z length of tube + inline static const std::string& Z_ID() + { + static const std::string MY_Z("z"); + return MY_Z; + } + + /// attribute name of the starting phi position angle of segment + inline static const std::string& START_PHI_ID() + { + static const std::string MY_START_PHI("startphi"); + return MY_START_PHI; + } + + /// attribute name of the delta angle of segment + inline static const std::string& DELTA_PHI_ID() + { + static const std::string MY_DELTA_PHI("deltaphi"); + return MY_DELTA_PHI; + } + + /// Returns the kind of a feature + PRIMITIVESPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = PrimitivesPlugin_Tube::ID(); + return MY_KIND; + } + + /// Creates a new part document if needed + PRIMITIVESPLUGIN_EXPORT virtual void execute(); + + /// Request for initialization of data model of the feature: adding all attributes + PRIMITIVESPLUGIN_EXPORT virtual void initAttributes(); + + /// Use plugin manager for features creation + PrimitivesPlugin_Tube(); + + private: + /// Load Naming data structure of the feature to the document + void loadNamingDS(std::shared_ptr theTubeAlgo, + std::shared_ptr theResultBox); + + ///Perform the creation of the simple tube + void createSimpleTube(); + + ///Perform the creation of the segment tube + void createSegmentTube(); +}; + +#endif diff --git a/src/PrimitivesPlugin/plugin-Primitives.xml b/src/PrimitivesPlugin/plugin-Primitives.xml index f250b587e..e345693c9 100644 --- a/src/PrimitivesPlugin/plugin-Primitives.xml +++ b/src/PrimitivesPlugin/plugin-Primitives.xml @@ -30,5 +30,11 @@ + + + + + diff --git a/src/PrimitivesPlugin/tube_widget.xml b/src/PrimitivesPlugin/tube_widget.xml new file mode 100644 index 000000000..2b5c9904f --- /dev/null +++ b/src/PrimitivesPlugin/tube_widget.xml @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.39.2