GeomAlgoAPI_Chamfer.h
GeomAlgoAPI_Defeaturing.h
GeomAlgoAPI_BoundingBox.h
+ GeomAlgoAPI_Tube.h
)
SET(PROJECT_SOURCES
GeomAlgoAPI_Chamfer.cpp
GeomAlgoAPI_Defeaturing.cpp
GeomAlgoAPI_BoundingBox.cpp
+ GeomAlgoAPI_Tube.cpp
)
SET(PROJECT_LIBRARIES
void GeomAlgoAPI_Sphere::build()
{
myCreatedFaces.clear();
-
+
if (isSectionSphere) {
buildSectionSphere();
} else {
gp_Pnt anOrigin(0., 0., 0.);
gp_Dir aNormal(-sin(aStartPhiRad), cos(aStartPhiRad), 0.);
- //The section is defined by 4 points and up to 4 wires. In the rmin = 0 case, two of the points will actually be the origin
+ // The section is defined by 4 points and up to 4 wires. In the rmin = 0 case, two of the points
+ // will actually be the origin
double aX = myRMax*sin(myThetaMin * M_PI/180.);
double aZ = myRMax*cos(myThetaMin * M_PI/180.);
gp_Pnt aTopOuterStart(aX*cos(aStartPhiRad), aX*sin(aStartPhiRad), aZ);
anArcOuterBuilder = BRepBuilderAPI_MakeEdge(anOuterCircle, aTopOuterStart, aBaseOuterEnd);
anArcOuterBuilder.Build();
- //Two cases : either we need four edges (one being an arc with curvature radius rmin) or we need three (if rmin=0).
- // In the later case the top and bottom edges intersect at the origin
- // Add the edges to the wire in consecutive order (very important for the face to make sense topologically)
+ // Two cases : either we need four edges (one being an arc with curvature radius rmin)
+ // or we need three (if rmin=0).
+ // In the later case the top and bottom edges intersect at the origin, add the
+ // edges to the wire in consecutive order (very important for the face to make sense
+ // topologically)
if(myRMin >= Precision::Confusion()){
gp_Circ anInnerCircle(gp_Ax2(anOrigin, aNormal), myRMin);
BRepBuilderAPI_MakeEdge anArcInnerBuilder;
gp_Ax1 aZAxis(anOrigin, aZDir);
// Build the solid using the section face we've created and a revolution builder
- BRepPrimAPI_MakeRevol* aRevolBuilder = new BRepPrimAPI_MakeRevol(aFaceBuilder.Face(), aZAxis, myPhiMax * M_PI / 180., Standard_True);
+ BRepPrimAPI_MakeRevol* aRevolBuilder = new BRepPrimAPI_MakeRevol(aFaceBuilder.Face(), aZAxis,
+ myPhiMax * M_PI / 180.,
+ Standard_True);
if(!aRevolBuilder) {
return;
myError = "Sphere builder :: section revolution did not succeed";
}
// Get the shape, verify it, build a GeomAPI_Shape.
- std::shared_ptr<GeomAPI_Shape> aResultShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape()) ;
+ std::shared_ptr<GeomAPI_Shape> aResultShape =
+ std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
aResultShape->setImpl(new TopoDS_Shape(aRevolBuilder->Shape()));
setShape(aResultShape);
--- /dev/null
+// Copyright (C) 2014-2021 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 <GeomAlgoAPI_Tube.h>
+
+#include <BRepAlgo_FaceRestrictor.hxx>
+
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <BRepBuilderAPI_Transform.hxx>
+
+#include <BRepPrimAPI_MakePrism.hxx>
+
+#include <gp_Circ.hxx>
+
+#include <TopoDS_Wire.hxx>
+#include <TopoDS_Face.hxx>
+
+//=================================================================================================
+GeomAlgoAPI_Tube::GeomAlgoAPI_Tube()
+{
+}
+
+//=================================================================================================
+GeomAlgoAPI_Tube::GeomAlgoAPI_Tube(const double theRMin, const double theRMax, const double theZ)
+{
+ myRMin = theRMin;
+ myRMax = theRMax;
+ myZ = theZ;
+}
+
+//=================================================================================================
+bool GeomAlgoAPI_Tube::check()
+{
+ if ((myRMax -myRMin) < Precision::Confusion()) {
+ myError = "Tube builder :: rmin is greater then or equal to rmax.";
+ return false;
+ } else if (myRMin < 0.) {
+ myError = "Tube builder :: rmin is negative.";
+ return false;
+ } else if (myZ < Precision::Confusion()) {
+ myError = "Tube builder :: z is negative or null.";
+ return false;
+ }
+
+ return true;
+}
+
+//=================================================================================================
+void GeomAlgoAPI_Tube::build()
+{
+ buildTube();
+}
+
+//=================================================================================================
+void GeomAlgoAPI_Tube::buildTube()
+{
+ myCreatedFaces.clear();
+
+ // 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 inner wire
+ BRepBuilderAPI_MakeEdge anInnerCircleBuilder(anInnerCircle);
+ anInnerCircleBuilder.Build();
+ BRepBuilderAPI_MakeWire anInnerWireBuilder;
+ anInnerWireBuilder.Add(anInnerCircleBuilder.Edge());
+ anInnerWireBuilder.Build();
+ TopoDS_Wire anInnerWire(anInnerWireBuilder.Wire());
+
+ // 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 withe the outer wire
+ BRepBuilderAPI_MakeFace aFaceBuilder(anOuterWire);
+ aFaceBuilder.Build();
+ TopoDS_Face aFace(aFaceBuilder.Face());
+
+ // Construct the hole face
+ BRepAlgo_FaceRestrictor aFaceRestrictor;
+ aFaceRestrictor.Init(aFace, Standard_False, Standard_True);
+ aFaceRestrictor.Add(anInnerWire);
+ aFaceRestrictor.Add(anOuterWire);
+ aFaceRestrictor.Perform();
+ aFace = TopoDS_Face(aFaceRestrictor.Current());
+
+ // Construct the tube
+ gp_Vec aVec(aNormal);
+ gp_Trsf aTrsf;
+ aTrsf.SetTranslation(aVec * -myZ/2);
+ BRepBuilderAPI_Transform *aTranformBuilder = new BRepBuilderAPI_Transform(aFace, aTrsf);
+ if (!aTranformBuilder || !aTranformBuilder->IsDone()) {
+ myError = "Tube builder :: algorithm failed";
+ return;
+ }
+ TopoDS_Shape aMovedBase = aTranformBuilder->Shape();
+ BRepPrimAPI_MakePrism *aPrismBuilder = new BRepPrimAPI_MakePrism(aMovedBase, aVec * myZ);
+
+ std::shared_ptr<GeomAPI_Shape> aShape = std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+ aShape->setImpl(new TopoDS_Shape(aPrismBuilder->Shape()));
+ setShape(aShape);
+
+ setImpl(aPrismBuilder);
+ setBuilderType(OCCT_BRepBuilderAPI_MakeShape);
+
+ setDone(true);
+}
--- /dev/null
+// Copyright (C) 2017-2021 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 <GeomAlgoAPI_MakeShape.h>
+
+/**\class GeomAlgoAPI_Tube
+ * \ingroup DataAlgo
+ * \brief Allows to create Tube Primitives
+ */
+class GeomAlgoAPI_Tube : public GeomAlgoAPI_MakeShape
+{
+ public:
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_Tube();
+
+ /// Creates a tube.
+ /// \param theRMin The inside radius
+ /// \param theRMax The outside radius
+ /// \param theZ The heigth
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_Tube(const double theRMin,
+ const double theRMax,
+ const double theZ);
+
+ /// Checks if data for the torus construction is OK.
+ GEOMALGOAPI_EXPORT bool check();
+
+ /// Builds the torus.
+ GEOMALGOAPI_EXPORT void build();
+
+private:
+ /// Builds the the tube with the inside radius, the outside radius and the height.
+ void buildTube();
+
+ double myRMin; /// inside radius to create a tube.
+ double myRMax; /// outside radius to create a tube.
+ double myZ; /// height to create a tube.
+};
+
+#endif // GEOMALGOAPI_TUBE_H_
PrimitivesAPI_Cylinder.h
PrimitivesAPI_Sphere.h
PrimitivesAPI_Torus.h
+ PrimitivesAPI_Tube.h
)
SET(PROJECT_SOURCES
PrimitivesAPI_Cylinder.cpp
PrimitivesAPI_Sphere.cpp
PrimitivesAPI_Torus.cpp
+ PrimitivesAPI_Tube.cpp
)
SET(PROJECT_LIBRARIES
%shared_ptr(PrimitivesAPI_Cylinder)
%shared_ptr(PrimitivesAPI_Sphere)
%shared_ptr(PrimitivesAPI_Torus)
+%shared_ptr(PrimitivesAPI_Tube)
// all supported interfaces
%include "PrimitivesAPI_Box.h"
%include "PrimitivesAPI_Cylinder.h"
%include "PrimitivesAPI_Sphere.h"
%include "PrimitivesAPI_Torus.h"
+%include "PrimitivesAPI_Tube.h"
/// \class PrimitivesAPI_Torus
/// \ingroup CPPHighAPI
-/// \brief Interface for primitive Cone feature.
+/// \brief Interface for primitive Torus feature.
class PrimitivesAPI_Torus: public ModelHighAPI_Interface
{
public:
virtual void dump(ModelHighAPI_Dumper& theDumper) const;
};
-/// Pointer on primitive Cone object
+/// Pointer on primitive Torus object
typedef std::shared_ptr<PrimitivesAPI_Torus> TorusPtr;
/// \ingroup CPPHighAPI
-/// \brief Create primitive Cone feature.
+/// \brief Create primitive Torus feature.
PRIMITIVESAPI_EXPORT
TorusPtr addTorus(const std::shared_ptr<ModelAPI_Document>& thePart,
const ModelHighAPI_Selection& theBasePoint,
const ModelHighAPI_Double& theRingRadius);
/// \ingroup CPPHighAPI
-/// \brief Create primitive Cone feature.
+/// \brief Create primitive Torus feature.
PRIMITIVESAPI_EXPORT
TorusPtr addTorus(const std::shared_ptr<ModelAPI_Document>& thePart,
const ModelHighAPI_Double& theRadius,
--- /dev/null
+// Copyright (C) 2017-2021 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 "PrimitivesAPI_Tube.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+PrimitivesAPI_Tube::PrimitivesAPI_Tube(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+//==================================================================================================
+PrimitivesAPI_Tube::PrimitivesAPI_Tube(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Double& theRMin,
+ const ModelHighAPI_Double& theRMax,
+ const ModelHighAPI_Double& theHeight)
+: ModelHighAPI_Interface(theFeature)
+{
+ if (initialize()) {
+ fillAttribute(theRMin, rmin());
+ fillAttribute(theRMax, rmax());
+ setHeight(theHeight);
+ }
+}
+
+//==================================================================================================
+PrimitivesAPI_Tube::~PrimitivesAPI_Tube()
+{
+}
+
+//==================================================================================================
+void PrimitivesAPI_Tube::setRadius(const ModelHighAPI_Double& theRMin,
+ const ModelHighAPI_Double& theRMax)
+{
+ fillAttribute(theRMin, rmin());
+ fillAttribute(theRMax, rmax());
+ execute();
+}
+
+//==================================================================================================
+void PrimitivesAPI_Tube::setHeight(const ModelHighAPI_Double& theHeight)
+{
+ fillAttribute(theHeight, height());
+ execute();
+}
+
+//==================================================================================================
+void PrimitivesAPI_Tube::dump(ModelHighAPI_Dumper& theDumper) const
+{
+ FeaturePtr aBase = feature();
+ const std::string& aDocName = theDumper.name(aBase->document());
+
+ theDumper << aBase << " = model.addTube(" << aDocName;
+
+ AttributeDoublePtr anAttrRMin = aBase->real(PrimitivesPlugin_Tube::RMIN_ID());
+ AttributeDoublePtr anAttrRMax = aBase->real(PrimitivesPlugin_Tube::RMAX_ID());
+ AttributeDoublePtr anAttrHeight = aBase->real(PrimitivesPlugin_Tube::HEIGHT_ID());
+ theDumper << ", " << anAttrRMin << ", " << anAttrRMax << ", " << anAttrHeight;
+
+ theDumper << ")" << std::endl;
+}
+
+//==================================================================================================
+TubePtr addTube(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theRMin,
+ const ModelHighAPI_Double& theRMax,
+ const ModelHighAPI_Double& theHeight)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Tube::ID());
+ return TubePtr(new PrimitivesAPI_Tube(aFeature, theRMin, theRMax, theHeight));
+}
--- /dev/null
+// Copyright (C) 2017-2021 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 PRIMITIVESAPI_TUBE_H_
+#define PRIMITIVESAPI_TUBE_H_
+
+#include "PrimitivesAPI.h"
+
+#include <PrimitivesPlugin_Tube.h>
+
+#include <ModelHighAPI_Double.h>
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+
+/// \class PrimitivesAPI_Tube
+/// \ingroup CPPHighAPI
+/// \brief Interface for primitive Tube feature.
+class PrimitivesAPI_Tube: public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values.
+ PRIMITIVESAPI_EXPORT
+ explicit PrimitivesAPI_Tube(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+ /// Constructor with values.
+ PRIMITIVESAPI_EXPORT
+ explicit PrimitivesAPI_Tube(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Double& theRMin,
+ const ModelHighAPI_Double& theRMax,
+ const ModelHighAPI_Double& theHeight);
+
+ /// Destructor.
+ PRIMITIVESAPI_EXPORT
+ virtual ~PrimitivesAPI_Tube();
+
+ INTERFACE_3(PrimitivesPlugin_Tube::ID(),
+ rmin, PrimitivesPlugin_Tube::RMIN_ID(),
+ ModelAPI_AttributeDouble, /** Inner radius */,
+ rmax, PrimitivesPlugin_Tube::RMAX_ID(),
+ ModelAPI_AttributeDouble, /** Outer radius */,
+ height, PrimitivesPlugin_Tube::HEIGHT_ID(),
+ ModelAPI_AttributeDouble, /** Height */)
+
+ /// Set radius
+ PRIMITIVESAPI_EXPORT
+ void setRadius(const ModelHighAPI_Double& theRMin,
+ const ModelHighAPI_Double& theRMax);
+
+ /// Set height
+ PRIMITIVESAPI_EXPORT
+ void setHeight(const ModelHighAPI_Double& theHeight);
+
+ /// Dump wrapped feature
+ PRIMITIVESAPI_EXPORT
+ virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on primitive Tube object
+typedef std::shared_ptr<PrimitivesAPI_Tube> TubePtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create primitive Tube feature.
+PRIMITIVESAPI_EXPORT
+TubePtr addTube(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theRMin,
+ const ModelHighAPI_Double& theRMax,
+ const ModelHighAPI_Double& theHeight);
+
+#endif // PRIMITIVESAPI_TUBE_H_
#include "PrimitivesAPI_Cylinder.h"
#include "PrimitivesAPI_Sphere.h"
#include "PrimitivesAPI_Torus.h"
+ #include "PrimitivesAPI_Tube.h"
#endif // PRIMITIVESAPI_SWIG_H_
PrimitivesPlugin_Cylinder.h
PrimitivesPlugin_Sphere.h
PrimitivesPlugin_Torus.h
+ PrimitivesPlugin_Tube.h
)
SET(PROJECT_SOURCES
PrimitivesPlugin_Cylinder.cpp
PrimitivesPlugin_Sphere.cpp
PrimitivesPlugin_Torus.cpp
+ PrimitivesPlugin_Tube.cpp
)
SET(XML_RESOURCES
cylinder_widget.xml
sphere_widget.xml
torus_widget.xml
+ tube_widget.xml
)
SET(TEXT_RESOURCES
#include <PrimitivesPlugin_Cylinder.h>
#include <PrimitivesPlugin_Sphere.h>
#include <PrimitivesPlugin_Torus.h>
+#include <PrimitivesPlugin_Tube.h>
#include <ModelAPI_Session.h>
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();
//=================================================================================================
void PrimitivesPlugin_Sphere::initAttributes()
{
- data()->addAttribute(PrimitivesPlugin_Sphere::CREATION_METHOD(), ModelAPI_AttributeString::typeId());
+ data()->addAttribute(PrimitivesPlugin_Sphere::CREATION_METHOD(),
+ ModelAPI_AttributeString::typeId());
// data for the first mode : by a point and a radius
data()->addAttribute(PrimitivesPlugin_Sphere::CENTER_POINT_ID(),
static const std::string MY_RADIUS_ID("radius");
return MY_RADIUS_ID;
}
-
+
/// attribute name of the inner radius
inline static const std::string& RMIN_ID()
{
static const std::string MY_RMIN_ID("rmin");
return MY_RMIN_ID;
}
-
+
/// attribute name of the outer radius
inline static const std::string& RMAX_ID()
{
static const std::string MY_RMAX_ID("rmax");
return MY_RMAX_ID;
}
-
+
/// attribute name of the lower phi limit
inline static const std::string& PHIMIN_ID()
{
static const std::string MY_PHIMIN_ID("phimin");
return MY_PHIMIN_ID;
}
-
+
/// attribute name of the higher phi limit
inline static const std::string& PHIMAX_ID()
{
static const std::string MY_PHIMAX_ID("phimax");
return MY_PHIMAX_ID;
}
-
+
/// attribute name of the lower theta limit
inline static const std::string& THETAMIN_ID()
{
static const std::string MY_THETAMIN_ID("thetamin");
return MY_THETAMIN_ID;
}
-
+
/// attribute name of the higher theta limit
inline static const std::string& THETAMAX_ID()
{
/// Load Naming data structure of the feature to the document
void loadNamingDS(std::shared_ptr<GeomAlgoAPI_Sphere> theSphereAlgo,
std::shared_ptr<ModelAPI_ResultBody> theResultSphere);
-
+
/// Perform the creation of the sphere using a point and a radius
void createSphereByPtRadius();
-
- /// Perform the creation of the sphere using radii (inner and outer) and angle limits (theta and phi)
+
+ /// Perform the creation of the sphere using radii (inner and outer) and angle limits
+ /// (theta and phi)
void createShereByDimensions();
};
--- /dev/null
+// 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 <PrimitivesPlugin_Tube.h>
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_ResultBody.h>
+
+//=================================================================================================
+PrimitivesPlugin_Tube::PrimitivesPlugin_Tube() // Nothing to do during instantiation
+{
+}
+
+//=================================================================================================
+void PrimitivesPlugin_Tube::initAttributes()
+{
+ data()->addAttribute(PrimitivesPlugin_Tube::RMIN_ID(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(PrimitivesPlugin_Tube::RMAX_ID(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(PrimitivesPlugin_Tube::HEIGHT_ID(), ModelAPI_AttributeDouble::typeId());
+}
+
+//=================================================================================================
+void PrimitivesPlugin_Tube::execute()
+{
+ double aRMin = real(PrimitivesPlugin_Tube::RMIN_ID())->value();
+ double aRMax = real(PrimitivesPlugin_Tube::RMAX_ID())->value();
+ double aZ = real(PrimitivesPlugin_Tube::HEIGHT_ID())->value();
+
+ std::shared_ptr<GeomAlgoAPI_Tube> 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::loadNamingDS(std::shared_ptr<GeomAlgoAPI_Tube> theTubeAlgo,
+ std::shared_ptr<ModelAPI_ResultBody> 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<GeomAPI_Shape> > listOfFaces =
+ theTubeAlgo->getCreatedFaces();
+ for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator it = listOfFaces.begin();
+ it != listOfFaces.end();
+ ++it)
+ {
+ theResultTube->generated((*it).second, (*it).first);
+ }
+}
--- /dev/null
+// Copyright (C) 2014-2021 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 <GeomAlgoAPI_Tube.h>
+#include <ModelAPI_Feature.h>
+#include <PrimitivesPlugin.h>
+
+/**\class PrimitivesPlugin_Tube
+ * \ingroup Plugins
+ * \brief Feature for creation of a tube primitive using various methods.
+ *
+ * Tube creates a tuboid - Holed cylinder. It can be built via two methods :
+ * using an inner raidus, an outer radius and a heigth or radii (inner and outer)
+ * and angles.
+ */
+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;
+ }
+
+ /// Attrinute name of the inner radius
+ inline static const std::string& RMIN_ID()
+ {
+ static const std::string MY_RMIN_ID("rmin");
+ return MY_RMIN_ID;
+ }
+
+ /// Attrinute name of the outer radius
+ inline static const std::string& RMAX_ID()
+ {
+ static const std::string MY_RMAX_ID("rmax");
+ return MY_RMAX_ID;
+ }
+
+ /// Attrinute name of the height
+ inline static const std::string& HEIGHT_ID()
+ {
+ static const std::string MY_HEIGHT_ID("height");
+ return MY_HEIGHT_ID;
+ }
+
+ /// Returns the kind of a feature
+ PRIMITIVESPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = PrimitivesPlugin_Tube::ID();
+ return MY_KIND;
+ }
+
+ /// Performs the algorithm and stores results it in the data structure
+ 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<GeomAlgoAPI_Tube> theTubeAlgo,
+ std::shared_ptr<ModelAPI_ResultBody> theResultBox);
+};
+
+#endif
<source>Torus</source>
<translation>Tore</translation>
</message>
+ <message>
+ <source>Tube</source>
+ <translation>Tube</translation>
+ </message>
</context>
<context>
<source>By two points</source>
<translation>Par deux points</translation>
</message>
+ <message>
+ <source>By one point and dimensions</source>
+ <translation>Par un point et des dimensions</translation>
+ </message>
</context>
<context>
<name>Box:FirstPoint</name>
<translation>Dimension en Z</translation>
</message>
</context>
+ <context>
+ <name>Box:ox</name>
+ <message>
+ <source>OX</source>
+ <translation>OX</translation>
+ </message>
+ <message>
+ <source>Enter the coordinate X for the center</source>
+ <translation>Entrez la coodonnée en X du centre</translation>
+ </message>
+ </context>
+ <context>
+ <name>Box:oy</name>
+ <message>
+ <source>OY</source>
+ <translation>OY</translation>
+ </message>
+ <message>
+ <source>Enter the coordinate Y for the center</source>
+ <translation>Entrez la coodonnée en Y du centre</translation>
+ </message>
+ </context>
+ <context>
+ <name>Box:oz</name>
+ <message>
+ <source>OZ</source>
+ <translation>OZ</translation>
+ </message>
+ <message>
+ <source>Enter the coordinate Z for the center</source>
+ <translation>Entrez la coodonnée en Z du centre</translation>
+ </message>
+ </context>
+ <context>
+ <name>Box:half_dx</name>
+ <message>
+ <source>DX</source>
+ <translation>DX</translation>
+ </message>
+ <message>
+ <source>Enter the half length in X</source>
+ <translation>Entrez la demi-longueur en X</translation>
+ </message>
+ </context>
+ <context>
+ <name>Box:half_dy</name>
+ <message>
+ <source>DY</source>
+ <translation>DY</translation>
+ </message>
+ <message>
+ <source>Enter the half length in Y</source>
+ <translation>Entrez la demi-longueur en Y</translation>
+ </message>
+ </context>
+ <context>
+ <name>Box:half_dz</name>
+ <message>
+ <source>DZ</source>
+ <translation>DZ</translation>
+ </message>
+ <message>
+ <source>Enter the half length in Z</source>
+ <translation>Entrez la demi-longueur en Z</translation>
+ </message>
+ </context>
<context>
<name>Cone</name>
<source>Sphere</source>
<translation>Sphère</translation>
</message>
+ <message>
+ <source>Dimensions</source>
+ <translation>Dimensions</translation>
+ </message>
+ <message>
+ <source>Phi/theta range</source>
+ <translation>Intervalles pour Phi/Theta</translation>
+ </message>
+ </context>
+ <context>
+ <name>Sphere:CreationMethod</name>
+ <message>
+ <source>By point and radius</source>
+ <translation>Par un centre et un rayon</translation>
+ </message>
+ <message>
+ <source>By dimensions</source>
+ <translation>Par dimensions</translation>
+ </message>
</context>
<context>
<name>Sphere:center_point</name>
<translation>Rayon</translation>
</message>
</context>
+ <context>
+ <name>Sphere:rmin</name>
+ <message>
+ <source>Enter the inner radius</source>
+ <translation>Entrez le rayon interne</translation>
+ </message>
+ <message>
+ <source>rmin</source>
+ <translation>Rmin</translation>
+ </message>
+ </context>
+ <context>
+ <name>Sphere:rmax</name>
+ <message>
+ <source>Enter the outer radius</source>
+ <translation>Entrez le rayon externe</translation>
+ </message>
+ <message>
+ <source>rmax</source>
+ <translation>Rmax</translation>
+ </message>
+ </context>
+ <context>
+ <name>Sphere:phimin</name>
+ <message>
+ <source>Enter the azimuthal starting angle</source>
+ <translation>Entrez l'angle azimutal de départ</translation>
+ </message>
+ <message>
+ <source>phimin</source>
+ <translation>Phi min</translation>
+ </message>
+ </context>
+ <context>
+ <name>Sphere:phimax</name>
+ <message>
+ <source>Enter the azimuthal revolution angle</source>
+ <translation>Entrez l'angle azimutal de révolution</translation>
+ </message>
+ <message>
+ <source>phimax</source>
+ <translation>Phi max</translation>
+ </message>
+ </context>
+ <context>
+ <name>Sphere:thetamin</name>
+ <message>
+ <source>Enter the polar starting angle</source>
+ <translation>Entrez l'angle polaire de départ</translation>
+ </message>
+ <message>
+ <source>thetamin</source>
+ <translation>Theta min</translation>
+ </message>
+ </context>
+ <context>
+ <name>Sphere:thetamax</name>
+ <message>
+ <source>Enter the polar revolution angle</source>
+ <translation>Entrez l'angle polaire de révolution</translation>
+ </message>
+ <message>
+ <source>thetamax</source>
+ <translation>Theta max</translation>
+ </message>
+ </context>
<context>
<name>Torus</name>
</message>
</context>
+ <context>
+ <name>Tube</name>
+ <message>
+ <source>Create a Tube
+ </source>
+ <translation>Créer un tube</translation>
+ </message>
+ </context>
+ <context>
+ <name>Tube:rmin</name>
+ <message>
+ <source>Enter the inner radius</source>
+ <translation>Entrez le rayon interne</translation>
+ </message>
+ <message>
+ <source>rmin</source>
+ <translation>rmin</translation>
+ </message>
+ </context>
+ <context>
+ <name>Tube:rmax</name>
+ <message>
+ <source>Enter the outer radius</source>
+ <translation>Entrez le rayon externe</translation>
+ </message>
+ <message>
+ <source>rmax</source>
+ <translation>rmax</translation>
+ </message>
+ </context>
+ <context>
+ <name>Tube:height</name>
+ <message>
+ <source>Enter the height</source>
+ <translation>Entrez la hauteur</translation>
+ </message>
+ <message>
+ <source>height</source>
+ <translation>height</translation>
+ </message>
+ </context>
+
</TS>
label="OX"
step="1."
default="0."
- tooltip="Enter the coordinate X for the origin">
+ tooltip="Enter the coordinate X for the center">
</doublevalue>
<doublevalue
id="oy"
label="OY"
step="1."
default="0."
- tooltip="Enter the coordinate Y for the origin">
+ tooltip="Enter the coordinate Y for the center">
</doublevalue>
<doublevalue
id="oz"
label="OZ"
step="1."
default="0."
- tooltip="Enter the coordinate Z for the origin">
+ tooltip="Enter the coordinate Z for the center">
</doublevalue>
</groupbox>
<groupbox title="Half-lengths">
cylinderFeature.rst
sphereFeature.rst
torusFeature.rst
+ tubeFeature.rst
--- /dev/null
+
+ .. _tui_create_tube:
+
+Create / Tube
+==============
+
+.. literalinclude:: examples/tube.py
+ :linenos:
+ :language: python
+
+:download:`Download this script <examples/tube.py>`
+
--- /dev/null
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Torus_1 = model.addTube(Part_1_doc, 3, 5, 12)
+model.do()
+model.end()
--- /dev/null
+.. |Tube_button.icon| image:: images/Tube_button.png
+
+Tube
+====
+
+Tube feature creates a tube solid.
+
+To create a Tube in the active part:
+
+#. select in the Main Menu *Primitives - > Tube* item or
+#. click |Tube_button.icon| **Tube** button in the toolbar
+
+The following property panel appears.
+
+.. figure:: images/Tube.png
+ :align: center
+
+ Tube
+
+Input fields:
+
+- **rmin** defines the inner radius of the the tube;
+- **rmax** defines the outer radius of the the tube;
+- **height** defines the height of the the tube;
+
+**TUI Command**:
+
+.. py:function:: model.addTube(Part_doc, rmin, rmax, height)
+
+ :param part: The current part object.
+ :param real: rmin.
+ :param real: rmax.
+ :param real: height.
+ :return: Result object.
+
+Result
+""""""
+
+An example is shown below.
+
+.. figure:: images/Tube_res.png
+ :align: center
+
+ Tube created
+
+**See Also** a sample TUI Script of :ref:`tui_create_tube` operation.
<source path="cone_widget.xml"/>
</feature>
</group>
+ <group id="Primitives">
+ <feature id="Tube" title="Tube" tooltip="Create a Tube" icon="icons/Primitives/tube.png"
+ helpfile="tubeFeature.html">
+ <source path="tube_widget.xml"/>
+ </feature>
+ </group>
</workbench>
</plugin>
--- /dev/null
+<source>
+ <doublevalue
+ id="rmin"
+ label="rmin"
+ step="1."
+ default="3."
+ min = "0."
+ tooltip="Enter the inner radius">
+ </doublevalue>
+ <doublevalue
+ id="rmax"
+ label = "rmax"
+ step="1."
+ default="5."
+ min="0."
+ tooltip="Enter the outer radius">
+ </doublevalue>
+ <doublevalue
+ id="height"
+ label="height"
+ step="1."
+ default="12."
+ min="0."
+ tooltip="Enter the height">
+ </doublevalue>
+</source>
"""Package for Primitives plugin for the Parametric Geometry API of the Modeler.
"""
-from PrimitivesAPI import addBox, addCone, addCylinder, addSphere, addTorus
+from PrimitivesAPI import addBox, addCone, addCylinder, addSphere, addTorus, addTube
--- /dev/null
+# Copyright (C) 2017-2021 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
+#
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+
+# Parameters
+model.addParameter(Part_1_doc, "rmin", "10")
+model.addParameter(Part_1_doc, "rmax", "12")
+model.addParameter(Part_1_doc, "h", "20.5")
+
+# Tests
+Tube_1 = model.addTube(Part_1_doc, 3, 5, 12)
+Tube_2 = model.addTube(Part_1_doc, "rmin", "rmax", "h")
+Tube_3 = model.addTube(Part_1_doc, 5, 3, 12)
+Tube_4 = model.addTube(Part_1_doc, -2.5, 5, 12)
+Tube_5 = model.addTube(Part_1_doc, 3, 5, -10)
+
+model.do()
+model.end()
+
+# Checks
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Tube_1, 1)
+model.testNbSubResults(Tube_1, [0])
+model.testNbSubShapes(Tube_1, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Tube_1, GeomAPI_Shape.FACE, [4])
+model.testHaveNamingFaces(Tube_1, model, Part_1_doc)
+
+model.testNbResults(Tube_2, 1)
+model.testNbSubResults(Tube_2, [0])
+model.testNbSubShapes(Tube_2, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Tube_2, GeomAPI_Shape.FACE, [4])
+model.testHaveNamingFaces(Tube_2, model, Part_1_doc)
+
+model.testNbResults(Tube_3, 0)
+print(Tube_3.feature().error())
+assert(Tube_3.feature().error() == "Tube builder :: rmin is greater then or equal to rmax.")
+
+model.testNbResults(Tube_4, 0)
+print(Tube_4.feature().error())
+assert(Tube_4.feature().error() == "Tube builder :: rmin is negative.")
+
+model.testNbResults(Tube_5, 0)
+print(Tube_5.feature().error())
+assert(Tube_5.feature().error() == "Tube builder :: z is negative or null.")
Primitives/TestCylinder.py
Primitives/TestSphere.py
Primitives/TestTorus.py
+ Primitives/TestTube.py
Primitives/TestAPI_Box.py
Primitives/TestAPI_Cone.py
Primitives/TestAPI_Cylinder.py