GeomAlgoAPI_Defeaturing.h
GeomAlgoAPI_BoundingBox.h
GeomAlgoAPI_NormalToFace.h
+ GeomAlgoAPI_Tube.h
)
SET(PROJECT_SOURCES
GeomAlgoAPI_Defeaturing.cpp
GeomAlgoAPI_BoundingBox.cpp
GeomAlgoAPI_NormalToFace.cpp
+ GeomAlgoAPI_Tube.cpp
)
SET(PROJECT_LIBRARIES
myDy = theDy;
myDz = theDz;
myMethodType = MethodType::BOX_DIM;
+ headError = "Box builder with dimensions";
}
//=================================================================================================
myFirstPoint = theFirstPoint;
mySecondPoint = theSecondPoint;
myMethodType = MethodType::BOX_POINTS;
+ headError = "Box builder with two points";
+}
+
+//=================================================================================================
+GeomAlgoAPI_Box::GeomAlgoAPI_Box(const double theOx, const double theOy, const double theOz,
+ const double theDx, const double theDy, const double theDz)
+{
+ myOx = theOx;
+ myOy = theOy;
+ myOz = theOz;
+ myDx = theDx;
+ myDy = theDy;
+ myDz = theDz;
+ myMethodType = MethodType::BOX_POINT_DIMS;
+ headError = "Box builder with coordinates and dimensions";
}
//=================================================================================================
bool GeomAlgoAPI_Box::check()
{
- if (myMethodType == MethodType::BOX_DIM) {
+ if (myMethodType == MethodType::BOX_DIM || myMethodType == MethodType::BOX_POINT_DIMS) {
if (myDx < Precision::Confusion()) {
- myError = "Box builder with dimensions :: Dx is null or negative.";
+ myError = headError + " :: Dx is null or negative.";
return false;
} else if (myDy < Precision::Confusion()) {
- myError = "Box builder with dimensions :: Dy is null or negative.";
+ myError = headError + " :: Dy is null or negative.";
return false;
} else if (myDz < Precision::Confusion()) {
- myError = "Box builder with dimensions :: Dz is null or negative.";
+ myError = headError + " :: Dz is null or negative.";
return false;
}
} else if (myMethodType == MethodType::BOX_POINTS) {
if (!myFirstPoint.get()) {
- myError = "Box builder with points :: the first point is not valid.";
+ myError = headError + " :: the first point is not valid.";
return false;
}
if (!mySecondPoint.get()) {
- myError = "Box builder with points :: the second point is not valid.";
+ myError = headError + " :: the second point is not valid.";
return false;
}
if (myFirstPoint->distance(mySecondPoint) < Precision::Confusion()) {
- myError = "Box builder with points :: the distance between the two points is null.";
+ myError = headError + " :: the distance between the two points is null.";
return false;
}
double aDiffX = myFirstPoint->x() - mySecondPoint->x();
fabs(aDiffY) < Precision::Confusion() ||
fabs(aDiffZ) < Precision::Confusion()) {
myError =
- "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.";
+ headError + " :: the points belong both to one of the OXY, OYZ or OZX planes.";
return false;
}
} else {
buildWithDimensions();
} else if (myMethodType == MethodType::BOX_POINTS) {
buildWithPoints();
+ } else if (myMethodType == MethodType::BOX_POINT_DIMS) {
+ buildWithPointAndDims();
} else {
myError = "Box builder :: Method not implemented.";
return;
// Test the algorithm
if (!aBoxMaker->IsDone()) {
- myError = "Box builder with dimensions :: algorithm failed.";
+ myError = headError + " :: algorithm failed.";
return;
}
// Test on the shapes
if (!aShape.get() || aShape->isNull()) {
- myError = "Box builder with dimensions :: resulting shape is null.";
+ myError = headError + " :: resulting shape is null.";
return;
}
// Test the algorithm
if(!aBoxMaker->IsDone()) {
- myError = "Box builder with two points :: algorithm failed.";
+ myError = headError + " :: algorithm failed.";
return;
}
// Tests on the shape
if (!aShape.get() || aShape->isNull()) {
- myError = "Box builder with two points :: resulting shape is null.";
+ myError = headError + " :: resulting shape is null.";
return;
}
setDone(true);
}
+//=================================================================================================
+void GeomAlgoAPI_Box::buildWithPointAndDims()
+{
+ // Construct points from cordinates and dimensions to use the method with two points
+ myFirstPoint =
+ std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(myOx - myDx, myOy - myDy, myOz - myDz));
+ mySecondPoint =
+ std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(myOx + myDx, myOy + myDy, myOz + myDz));
+
+ buildWithPoints();
+}
+
//=================================================================================================
void GeomAlgoAPI_Box::prepareNamingFaces()
{
enum MethodType {
BOX_DIM, ///< Box with dimensions
BOX_POINTS, ///< Box with points
+ BOX_POINT_DIMS, ///<Box with coordinates of a point and dimensions
};
GEOMALGOAPI_EXPORT GeomAlgoAPI_Box();
GEOMALGOAPI_EXPORT GeomAlgoAPI_Box(std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
std::shared_ptr<GeomAPI_Pnt> theSecondPoint);
+ /// Creates a box using coordinates of a point (the center of gravity) andthe dimensions.
+ /// \param theOx The X coordinate of the point
+ /// \param theOy The Y coordinate of the point
+ /// \param theOz The Z coordinate of the point
+ /// \param theDx The dimension on X
+ /// \param theDy The dimension on Y
+ /// \param theDz The dimension on Z
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_Box(const double theOx, const double theOy, const double theOz,
+ const double theDx, const double theDy, const double theDz);
+
/// Checks if data for the box construction is OK.
GEOMALGOAPI_EXPORT bool check();
void buildWithDimensions();
/// Builds the box with two points
void buildWithPoints();
+ /// Buils the box with coordinates of a point and dimensions
+ void buildWithPointAndDims();
+ double myOx; /// X coordinate of the point to create a box.
+ double myOy; /// Y coordinate of the point to create a box.
+ double myOz; /// Z coordinate of the point to create a box.
double myDx; /// Dimension on X to create a box.
double myDy; /// Dimension on Y to create a box.
double myDz; /// Dimension Z to create a box.
std::shared_ptr<GeomAPI_Pnt> myFirstPoint; /// First point to create a box.
std::shared_ptr<GeomAPI_Pnt> mySecondPoint; /// Second point to create a box.
MethodType myMethodType; /// Type of method used.
+ std::string headError; /// Head of the error message according to the method
};
#include <GeomAlgoAPI_Sphere.h>
+#include <gp_Circ.hxx>
+
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+
+#include <BRepPrimAPI_MakeRevol.hxx>
#include <BRepPrimAPI_MakeSphere.hxx>
//=================================================================================================
GeomAlgoAPI_Sphere::GeomAlgoAPI_Sphere(std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
const double theRadius)
{
+ isRootGeo = false;
myCenterPoint = theCenterPoint;
myRadius = theRadius;
}
+//=================================================================================================
+GeomAlgoAPI_Sphere::GeomAlgoAPI_Sphere(const double theRMin, const double theRMax,
+ const double thePhiMin, const double thePhiMax,
+ const double theThetaMin, const double theThetaMax)
+{
+ isRootGeo = true;
+ myRMin = theRMin;
+ myRMax = theRMax;
+ myPhiMin = thePhiMin;
+ myPhiMax = thePhiMax;
+ myThetaMin = theThetaMin;
+ myThetaMax = theThetaMax;
+}
+
//=================================================================================================
bool GeomAlgoAPI_Sphere::check()
{
- if (!myCenterPoint) {
- myError = "Sphere builder :: center is not valid.";
- return false;
- }
- if (myRadius < Precision::Confusion()) {
- myError = "Sphere builder :: radius is negative or null.";
- return false;
+ if (isRootGeo) {
+ if ((myRMin-myRMax) > Precision::Confusion()) {
+ myError = "Sphere builder :: RMin is larger than RMax.";
+ return false;
+ }
+ } else {
+ if (!myCenterPoint) {
+ myError = "Sphere builder :: center is not valid.";
+ return false;
+ }
+ if (myRadius < Precision::Confusion()) {
+ myError = "Sphere builder :: radius is negative or null.";
+ return false;
+ }
}
return true;
}
void GeomAlgoAPI_Sphere::build()
{
myCreatedFaces.clear();
+ if (isRootGeo) {
+ buildRootSphere();
+ } else {
+ const gp_Pnt& aCenterPoint = myCenterPoint->impl<gp_Pnt>();
+
+ // Construct the sphere
+ BRepPrimAPI_MakeSphere *aSphereMaker = new BRepPrimAPI_MakeSphere(aCenterPoint, myRadius);
+
+ aSphereMaker->Build();
+
+ if (!aSphereMaker->IsDone()) {
+ return;
+ }
+
+ TopoDS_Shape aResult = aSphereMaker->Shape();
+ std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+ aShape->setImpl(new TopoDS_Shape(aResult));
+ setShape(aShape);
+
+ // Test on the shapes
+ if (!aShape.get() || aShape->isNull()) {
+ myError = "Sphere builder :: resulting shape is null.";
+ return;
+ }
+
+ setImpl(aSphereMaker);
+
+ setDone(true);
+ }
+}
+
+//=================================================================================================
+void GeomAlgoAPI_Sphere::buildRootSphere()
+{
+ myCreatedFaces.clear();
+
+ const double aStartPhiRad = myPhiMin * M_PI / 180.;
+ BRepBuilderAPI_MakeWire aWireBuilder;
+
+ 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
+ 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);
- const gp_Pnt& aCenterPoint = myCenterPoint->impl<gp_Pnt>();
+ aX = myRMax*sin((myThetaMin+myThetaMax) * M_PI/180.);
+ aZ = myRMax*cos((myThetaMin+myThetaMax) * M_PI/180.);
+ gp_Pnt aBaseOuterEnd(aX*cos(aStartPhiRad), aX*sin(aStartPhiRad), aZ);
- // Construct the sphere
- BRepPrimAPI_MakeSphere *aSphereMaker = new BRepPrimAPI_MakeSphere(aCenterPoint, myRadius);
+ aX = myRMin*sin(myThetaMin * M_PI/180.);
+ aZ = myRMin*cos(myThetaMin * M_PI/180.);
+ gp_Pnt aTopInnerStart(aX*cos(aStartPhiRad), aX*sin(aStartPhiRad), aZ);
- aSphereMaker->Build();
+ aX = myRMin*sin((myThetaMin+myThetaMax) * M_PI/180.);
+ aZ = myRMin*cos((myThetaMin+myThetaMax) * M_PI/180.);
+ gp_Pnt aBaseInnerEnd(aX*cos(aStartPhiRad), aX*sin(aStartPhiRad), aZ);
+
+ // There will always be the rmax arc since rmax can't be zero
+ gp_Circ anOuterCircle(gp_Ax2(anOrigin, aNormal), myRMax);
+ BRepBuilderAPI_MakeEdge anArcOuterBuilder;
+ if (aTopOuterStart.IsEqual(aBaseOuterEnd, Precision::Confusion()))
+ anArcOuterBuilder = BRepBuilderAPI_MakeEdge(anOuterCircle);
+ else
+ 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)
+ if(myRMin >= Precision::Confusion()){
+ gp_Circ anInnerCircle(gp_Ax2(anOrigin, aNormal), myRMin);
+ BRepBuilderAPI_MakeEdge anArcInnerBuilder;
+ if (aTopInnerStart.IsEqual(aBaseInnerEnd, Precision::Confusion()))
+ anArcInnerBuilder = BRepBuilderAPI_MakeEdge(anInnerCircle);
+ else
+ anArcInnerBuilder = BRepBuilderAPI_MakeEdge(anInnerCircle, aTopInnerStart, aBaseInnerEnd);
+ anArcInnerBuilder.Build();
+
+ BRepBuilderAPI_MakeEdge anEdgeStartBuilder(aTopInnerStart, aTopOuterStart);
+ anEdgeStartBuilder.Build();
+ BRepBuilderAPI_MakeEdge anEdgeEndBuilder(aBaseInnerEnd, aBaseOuterEnd);
+ anEdgeEndBuilder.Build();
+
+ aWireBuilder.Add(anEdgeStartBuilder.Edge());
+ aWireBuilder.Add(anArcOuterBuilder.Edge());
+ aWireBuilder.Add(anEdgeEndBuilder.Edge());
+ aWireBuilder.Add(anArcInnerBuilder.Edge());
+ }
+ else{
+ BRepBuilderAPI_MakeEdge anEdgeStartBuilder(anOrigin, aTopOuterStart);
+ anEdgeStartBuilder.Build();
+ BRepBuilderAPI_MakeEdge anEdgeEndBuilder(anOrigin, aBaseOuterEnd);
+ anEdgeEndBuilder.Build();
- if (!aSphereMaker->IsDone()) {
+ aWireBuilder.Add(anArcOuterBuilder.Edge());
+ aWireBuilder.Add(anEdgeStartBuilder.Edge());
+ aWireBuilder.Add(anEdgeEndBuilder.Edge());
+ }
+
+ // Make a face from the wire
+ aWireBuilder.Build();
+ BRepBuilderAPI_MakeFace aFaceBuilder(aWireBuilder.Wire());
+ aFaceBuilder.Build();
+
+ if (!aFaceBuilder.IsDone()){
+ myError = "GDML sphere builder :: section is not valid";
+ return;
+ }
+
+ // Mathematical tool objects needed by the revolution builder
+ gp_Dir aZDir(0., 0., 1.);
+ 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);
+ if(!aRevolBuilder) {
+ return;
+ myError = "GDML Sphere builder :: section revolution did not succeed";
+ }
+ if(!aRevolBuilder->IsDone()) {
+ myError = "GDML Sphere builder :: section revolution did not succeed";
return;
}
- TopoDS_Shape aResult = aSphereMaker->Shape();
- std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
- aShape->setImpl(new TopoDS_Shape(aResult));
- setShape(aShape);
+ // Get the shape, verify it, build a 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);
// Test on the shapes
- if (!aShape.get() || aShape->isNull()) {
- myError = "Sphere builder :: resulting shape is null.";
+ if (!(aResultShape).get() || aResultShape->isNull()) {
+ myError = "GDML Sphere builder :: resulting shape is null.";
return;
}
- setImpl(aSphereMaker);
+ setImpl(aRevolBuilder);
+ setBuilderType(OCCT_BRepBuilderAPI_MakeShape);
setDone(true);
}
/// \param theRadius The radius of the sphere
GEOMALGOAPI_EXPORT GeomAlgoAPI_Sphere(std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
const double theRadius);
+ /// Creates a sphere.
+ /// \param theRMin The inner radius of the sphere
+ /// \param theRMax The outer radius of the sphere
+ /// \param thePhiMin The lower phi limit
+ /// \param thePhiMax The higher phi limit
+ /// \param theThetaMin The lower theta limit
+ /// \param theThetaMax The higher theta limit
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_Sphere(const double theRMin, const double theRMax,
+ const double thePhiMin, const double thePhiMax,
+ const double theThetaMin, const double theThetaMax);
/// Checks if data for the sphere construction is OK.
GEOMALGOAPI_EXPORT bool check();
/// Builds the sphere.
GEOMALGOAPI_EXPORT void build();
+ /// Builds the sphere.
+ GEOMALGOAPI_EXPORT void buildRootSphere();
+
private:
+ bool isRootGeo;
std::shared_ptr<GeomAPI_Pnt> myCenterPoint; /// Center of the sphere.
double myRadius;
+ double myRMin, myRMax;
+ double myPhiMin, myPhiMax;
+ double myThetaMin, myThetaMax;
};
#endif // GEOMALGOAPI_SPHERE_H_
--- /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"
setPoints(theFirstPoint, theSecondPoint);
}
+//==================================================================================================
+PrimitivesAPI_Box::PrimitivesAPI_Box(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Double& theOx,
+ const ModelHighAPI_Double& theOy,
+ const ModelHighAPI_Double& theOz,
+ const ModelHighAPI_Double& theHalfX,
+ const ModelHighAPI_Double& theHalfY,
+ const ModelHighAPI_Double& theHalfZ)
+: ModelHighAPI_Interface(theFeature)
+{
+ if (initialize())
+ {
+ fillAttribute(PrimitivesPlugin_Box::CREATION_METHOD_BY_ONE_POINT_AND_DIMS(), creationMethod());
+ fillAttribute(theOx, ox());
+ fillAttribute(theOy, oy());
+ fillAttribute(theOz, oz());
+ fillAttribute(theHalfX, halfdx());
+ fillAttribute(theHalfY, halfdy());
+ fillAttribute(theHalfZ, halfdz());
+ execute();
+ }
+}
+
//==================================================================================================
PrimitivesAPI_Box::~PrimitivesAPI_Box()
{
execute();
}
+//==================================================================================================
+void PrimitivesAPI_Box::setOrigin(const ModelHighAPI_Double& theOx,
+ const ModelHighAPI_Double& theOy,
+ const ModelHighAPI_Double& theOz)
+{
+ fillAttribute(theOx, ox());
+ fillAttribute(theOy, oy());
+ fillAttribute(theOz, oz());
+
+ execute();
+}
+
+//==================================================================================================
+void PrimitivesAPI_Box::setHalfLengths(const ModelHighAPI_Double& theHalfLengthX,
+ const ModelHighAPI_Double& theHalfLengthY,
+ const ModelHighAPI_Double& theHalfLengthZ)
+{
+ fillAttribute(theHalfLengthX, halfdx());
+ fillAttribute(theHalfLengthY, halfdy());
+ fillAttribute(theHalfLengthZ, halfdz());
+
+ execute();
+}
+
//==================================================================================================
void PrimitivesAPI_Box::dump(ModelHighAPI_Dumper& theDumper) const
{
AttributeSelectionPtr anAttrSecondPnt =
aBase->selection(PrimitivesPlugin_Box::POINT_SECOND_ID());
theDumper << ", " << anAttrFirstPnt << ", " << anAttrSecondPnt;
+ } else if (aCreationMethod == PrimitivesPlugin_Box::CREATION_METHOD_BY_ONE_POINT_AND_DIMS()) {
+ AttributeDoublePtr anAttrOx = aBase->real(PrimitivesPlugin_Box::OX_ID());
+ AttributeDoublePtr anAttrOy = aBase->real(PrimitivesPlugin_Box::OY_ID());
+ AttributeDoublePtr anAttrOz = aBase->real(PrimitivesPlugin_Box::OZ_ID());
+ AttributeDoublePtr anAttrHalfLengthX = aBase->real(PrimitivesPlugin_Box::HALF_DX_ID());
+ AttributeDoublePtr anAttrHalfLengthY = aBase->real(PrimitivesPlugin_Box::HALF_DY_ID());
+ AttributeDoublePtr anAttrHalfLengthZ = aBase->real(PrimitivesPlugin_Box::HALF_DZ_ID());
+ theDumper << ", " << anAttrOx << ", " << anAttrOy << ", " << anAttrOz;
+ theDumper << ", " << anAttrHalfLengthX << ", " << anAttrHalfLengthY;
+ theDumper << ", " << anAttrHalfLengthZ;
}
theDumper << ")" << std::endl;
{
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Box::ID());
return BoxPtr(new PrimitivesAPI_Box(aFeature, theFirstPoint, theSecondPoint));
-}
\ No newline at end of file
+}
+
+//==================================================================================================
+BoxPtr addBox(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theOx,
+ const ModelHighAPI_Double& theOy,
+ const ModelHighAPI_Double& theOz,
+ const ModelHighAPI_Double& theHalfLengthX,
+ const ModelHighAPI_Double& theHalfLengthY,
+ const ModelHighAPI_Double& theHalfLengthZ)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Box::ID());
+ return BoxPtr(new PrimitivesAPI_Box(aFeature, theOx, theOy, theOz, theHalfLengthX,
+ theHalfLengthY, theHalfLengthZ));
+}
const ModelHighAPI_Selection& theFirstPoint,
const ModelHighAPI_Selection& theSecondPoint);
+ /// Constructor with values.
+ PRIMITIVESAPI_EXPORT
+ explicit PrimitivesAPI_Box(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Double& theOx,
+ const ModelHighAPI_Double& theOy,
+ const ModelHighAPI_Double& theOz,
+ const ModelHighAPI_Double& theHalfX,
+ const ModelHighAPI_Double& theHalfY,
+ const ModelHighAPI_Double& theHalfZ);
+
/// Destructor.
PRIMITIVESAPI_EXPORT
virtual ~PrimitivesAPI_Box();
- INTERFACE_6(PrimitivesPlugin_Box::ID(),
+ INTERFACE_12(PrimitivesPlugin_Box::ID(),
creationMethod, PrimitivesPlugin_Box::CREATION_METHOD(),
ModelAPI_AttributeString, /** Creation method */,
dx, PrimitivesPlugin_Box::DX_ID(),
firstPoint, PrimitivesPlugin_Box::POINT_FIRST_ID(),
ModelAPI_AttributeSelection, /** First point */,
secondPoint, PrimitivesPlugin_Box::POINT_SECOND_ID(),
- ModelAPI_AttributeSelection, /** Second point */)
+ ModelAPI_AttributeSelection, /** Second point */,
+ ox, PrimitivesPlugin_Box::OX_ID(),
+ ModelAPI_AttributeDouble, /** X coordinate for origin*/,
+ oy, PrimitivesPlugin_Box::OY_ID(),
+ ModelAPI_AttributeDouble, /** Y coordinate for origin*/,
+ oz, PrimitivesPlugin_Box::OZ_ID(),
+ ModelAPI_AttributeDouble, /** Z coordinate for origin*/,
+ halfdx, PrimitivesPlugin_Box::HALF_DX_ID(),
+ ModelAPI_AttributeDouble, /** Half length in X*/,
+ halfdy, PrimitivesPlugin_Box::HALF_DY_ID(),
+ ModelAPI_AttributeDouble, /** Half length in Y*/,
+ halfdz, PrimitivesPlugin_Box::HALF_DZ_ID(),
+ ModelAPI_AttributeDouble, /** Half length in Z*/)
/// Set dimensions
PRIMITIVESAPI_EXPORT
void setPoints(const ModelHighAPI_Selection& theFirstPoint,
const ModelHighAPI_Selection& theSecondPoint);
+ /// Set origin point
+ PRIMITIVESAPI_EXPORT
+ void setOrigin(const ModelHighAPI_Double& theOx,
+ const ModelHighAPI_Double& theOy,
+ const ModelHighAPI_Double& theOz);
+
+ /// Set half lengths
+ PRIMITIVESAPI_EXPORT
+ void setHalfLengths(const ModelHighAPI_Double& theHalfLengthX,
+ const ModelHighAPI_Double& theHalfLengthY,
+ const ModelHighAPI_Double& theHalfLengthZ);
+
/// Dump wrapped feature
PRIMITIVESAPI_EXPORT
virtual void dump(ModelHighAPI_Dumper& theDumper) const;
const ModelHighAPI_Selection& theFirstPoint,
const ModelHighAPI_Selection& theSecondPoint);
-#endif // PRIMITIVESAPI_BOX_H_
\ No newline at end of file
+/// \ingroup CPPHighAPI
+/// \brief Create primitive Box feature.
+PRIMITIVESAPI_EXPORT
+BoxPtr addBox(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theOx,
+ const ModelHighAPI_Double& theOy,
+ const ModelHighAPI_Double& theOz,
+ const ModelHighAPI_Double& theHalfLengthX,
+ const ModelHighAPI_Double& theHalfLengthY,
+ const ModelHighAPI_Double& theHalfLengthZ);
+
+#endif // PRIMITIVESAPI_BOX_H_
: ModelHighAPI_Interface(theFeature)
{
if (initialize()) {
+ fillAttribute(PrimitivesPlugin_Sphere::CREATION_METHOD_BY_PT_RADIUS(), creationMethod());
fillAttribute(theCenterPoint, centerPoint());
setRadius(theRadius);
}
}
+//==================================================================================================
+PrimitivesAPI_Sphere::PrimitivesAPI_Sphere(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Double& theRMin,
+ const ModelHighAPI_Double& theRMax,
+ const ModelHighAPI_Double& thePhiMin,
+ const ModelHighAPI_Double& thePhiMax,
+ const ModelHighAPI_Double& theThetaMin,
+ const ModelHighAPI_Double& theThetaMax)
+: ModelHighAPI_Interface(theFeature)
+{
+ if (initialize()) {
+ fillAttribute(PrimitivesPlugin_Sphere::CREATION_METHOD_BY_DIMENSIONS(), creationMethod());
+ fillAttribute(theRMin, rmin());
+ fillAttribute(theRMax, rmax());
+ fillAttribute(thePhiMin, phimin());
+ fillAttribute(thePhiMax, phimax());
+ fillAttribute(theThetaMin, thetamin());
+ fillAttribute(theThetaMax, thetamax());
+ execute();
+ }
+}
+
//==================================================================================================
PrimitivesAPI_Sphere::~PrimitivesAPI_Sphere()
{
execute();
}
+//==================================================================================================
+void PrimitivesAPI_Sphere::setRadius(const ModelHighAPI_Double& theRMin,
+ const ModelHighAPI_Double& theRMax)
+{
+ fillAttribute(theRMin, rmin());
+ fillAttribute(theRMax, rmax());
+ execute();
+}
+
+//==================================================================================================
+void PrimitivesAPI_Sphere::setPhi(const ModelHighAPI_Double& thePhiMin,
+ const ModelHighAPI_Double& thePhiMax)
+{
+ fillAttribute(thePhiMin, phimin());
+ fillAttribute(thePhiMax, phimax());
+ execute();
+}
+
+//==================================================================================================
+void PrimitivesAPI_Sphere::setTheta(const ModelHighAPI_Double& theThetaMin,
+ const ModelHighAPI_Double& theThetaMax)
+{
+ fillAttribute(theThetaMin, thetamin());
+ fillAttribute(theThetaMax, thetamax());
+ execute();
+}
+
//==================================================================================================
void PrimitivesAPI_Sphere::dump(ModelHighAPI_Dumper& theDumper) const
{
theDumper << aBase << " = model.addSphere(" << aDocName;
- AttributeSelectionPtr anAttrCenterPoint =
- aBase->selection(PrimitivesPlugin_Sphere::CENTER_POINT_ID());
- AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Sphere::RADIUS_ID());
- theDumper << ", " << anAttrCenterPoint << ", " << anAttrRadius;
+ std::string aCreationMethod = aBase->string(PrimitivesPlugin_Sphere::CREATION_METHOD())->value();
+
+ if(aCreationMethod == PrimitivesPlugin_Sphere::CREATION_METHOD_BY_PT_RADIUS()) {
+ AttributeSelectionPtr anAttrCenterPoint =
+ aBase->selection(PrimitivesPlugin_Sphere::CENTER_POINT_ID());
+ AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Sphere::RADIUS_ID());
+ theDumper << ", " << anAttrCenterPoint << ", " << anAttrRadius;
+ } else if(aCreationMethod == PrimitivesPlugin_Sphere::CREATION_METHOD_BY_DIMENSIONS()) {
+ AttributeDoublePtr anAttrRMin = aBase->real(PrimitivesPlugin_Sphere::RMIN_ID());
+ AttributeDoublePtr anAttrRMax = aBase->real(PrimitivesPlugin_Sphere::RMAX_ID());
+ AttributeDoublePtr anAttrPhiMin = aBase->real(PrimitivesPlugin_Sphere::PHIMIN_ID());
+ AttributeDoublePtr anAttrPhiMax = aBase->real(PrimitivesPlugin_Sphere::PHIMAX_ID());
+ AttributeDoublePtr anAttrThetaMin = aBase->real(PrimitivesPlugin_Sphere::THETAMIN_ID());
+ AttributeDoublePtr anAttrThetaMax = aBase->real(PrimitivesPlugin_Sphere::THETAMAX_ID());
+ theDumper << ", " << anAttrRMin << ", " << anAttrRMax;
+ theDumper << ", " << anAttrPhiMin << ", " << anAttrPhiMax;
+ theDumper << ", " << anAttrThetaMin << ", " << anAttrThetaMax;
+ }
theDumper << ")" << std::endl;
}
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Sphere::ID());
return SpherePtr(new PrimitivesAPI_Sphere(aFeature, aCenterPoint, theRadius));
}
+
+//==================================================================================================
+SpherePtr addSphere(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theRMin,
+ const ModelHighAPI_Double& theRMax,
+ const ModelHighAPI_Double& thePhiMin,
+ const ModelHighAPI_Double& thePhiMax,
+ const ModelHighAPI_Double& theThetaMin,
+ const ModelHighAPI_Double& theThetaMax)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Sphere::ID());
+ return SpherePtr(new PrimitivesAPI_Sphere(aFeature, theRMin, theRMax, thePhiMin, thePhiMax,
+ theThetaMin, theThetaMax));
+}
const ModelHighAPI_Selection& theCenterPoint,
const ModelHighAPI_Double& theRadius);
+ /// Constructor with values.
+ PRIMITIVESAPI_EXPORT
+ explicit PrimitivesAPI_Sphere(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Double& theRMin,
+ const ModelHighAPI_Double& theRMax,
+ const ModelHighAPI_Double& thePhiMin,
+ const ModelHighAPI_Double& thePhiMax,
+ const ModelHighAPI_Double& theThetaMin,
+ const ModelHighAPI_Double& theThetaMax);
+
/// Destructor.
PRIMITIVESAPI_EXPORT
virtual ~PrimitivesAPI_Sphere();
- INTERFACE_2(PrimitivesPlugin_Sphere::ID(),
+ INTERFACE_9(PrimitivesPlugin_Sphere::ID(),
+ creationMethod, PrimitivesPlugin_Sphere::CREATION_METHOD(),
+ ModelAPI_AttributeString, /** Creation method */,
centerPoint, PrimitivesPlugin_Sphere::CENTER_POINT_ID(),
ModelAPI_AttributeSelection, /** Center point */,
radius, PrimitivesPlugin_Sphere::RADIUS_ID(),
- ModelAPI_AttributeDouble, /** Radius */)
+ ModelAPI_AttributeDouble, /** Radius */,
+ rmin, PrimitivesPlugin_Sphere::RMIN_ID(),
+ ModelAPI_AttributeDouble, /** The minimum radius*/,
+ rmax, PrimitivesPlugin_Sphere::RMAX_ID(),
+ ModelAPI_AttributeDouble, /** The maximum radius*/,
+ phimin, PrimitivesPlugin_Sphere::PHIMIN_ID(),
+ ModelAPI_AttributeDouble, /** The minimum phi*/,
+ phimax, PrimitivesPlugin_Sphere::PHIMAX_ID(),
+ ModelAPI_AttributeDouble, /** The maximum phi*/,
+ thetamin, PrimitivesPlugin_Sphere::THETAMIN_ID(),
+ ModelAPI_AttributeDouble, /** The minimum theta*/,
+ thetamax,PrimitivesPlugin_Sphere::THETAMAX_ID(),
+ ModelAPI_AttributeDouble, /** The maximum theta*/)
/// Set center point
PRIMITIVESAPI_EXPORT
PRIMITIVESAPI_EXPORT
void setRadius(const ModelHighAPI_Double& theRadius);
+ /// Set minimum and maximum radius
+ PRIMITIVESAPI_EXPORT
+ void setRadius(const ModelHighAPI_Double& theRMin, const ModelHighAPI_Double& theRMax);
+
+ /// Set minimum and maximum phi
+ PRIMITIVESAPI_EXPORT
+ void setPhi(const ModelHighAPI_Double& thePhiMin, const ModelHighAPI_Double& thePhiMax);
+
+ /// Set minimum and maximum theta
+ PRIMITIVESAPI_EXPORT
+ void setTheta(const ModelHighAPI_Double& theThetaMin, const ModelHighAPI_Double& theThetaMax);
+
/// Dump wrapped feature
PRIMITIVESAPI_EXPORT
virtual void dump(ModelHighAPI_Dumper& theDumper) const;
SpherePtr addSphere(const std::shared_ptr<ModelAPI_Document>& thePart,
const ModelHighAPI_Double& theRadius);
+/// \ingroup CPPHighAPI
+/// \brief Create primitive Sphere feature.
+PRIMITIVESAPI_EXPORT
+SpherePtr addSphere(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theRMin,
+ const ModelHighAPI_Double& theRMax,
+ const ModelHighAPI_Double& thePhiMin,
+ const ModelHighAPI_Double& thePhiMax,
+ const ModelHighAPI_Double& theThetaMin,
+ const ModelHighAPI_Double& theThetaMax);
+
#endif // PRIMITIVESAPI_SPHERE_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
{
data()->addAttribute(PrimitivesPlugin_Box::CREATION_METHOD(), ModelAPI_AttributeString::typeId());
+ // Data for the first mode
data()->addAttribute(PrimitivesPlugin_Box::DX_ID(), ModelAPI_AttributeDouble::typeId());
data()->addAttribute(PrimitivesPlugin_Box::DY_ID(), ModelAPI_AttributeDouble::typeId());
data()->addAttribute(PrimitivesPlugin_Box::DZ_ID(), ModelAPI_AttributeDouble::typeId());
+ // Data for the second mode
data()->addAttribute(PrimitivesPlugin_Box::POINT_FIRST_ID(),
ModelAPI_AttributeSelection::typeId());
data()->addAttribute(PrimitivesPlugin_Box::POINT_SECOND_ID(),
ModelAPI_AttributeSelection::typeId());
+
+ // Data for the third mode
+ data()->addAttribute(PrimitivesPlugin_Box::OX_ID(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(PrimitivesPlugin_Box::OY_ID(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(PrimitivesPlugin_Box::OZ_ID(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(PrimitivesPlugin_Box::HALF_DX_ID(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(PrimitivesPlugin_Box::HALF_DY_ID(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(PrimitivesPlugin_Box::HALF_DZ_ID(), ModelAPI_AttributeDouble::typeId());
}
//=================================================================================================
if (aMethodType == CREATION_METHOD_BY_TWO_POINTS())
createBoxByTwoPoints();
+
+ if (aMethodType == CREATION_METHOD_BY_ONE_POINT_AND_DIMS())
+ createBoxByOnePointAndDims();
}
//=================================================================================================
setResult(aResultBox, aResultIndex);
}
+//=================================================================================================
+void PrimitivesPlugin_Box::createBoxByOnePointAndDims()
+{
+ // Getting dx, dy and dz
+ double aDx = real(PrimitivesPlugin_Box::HALF_DX_ID())->value();
+ double aDy = real(PrimitivesPlugin_Box::HALF_DY_ID())->value();
+ double aDz = real(PrimitivesPlugin_Box::HALF_DZ_ID())->value();
+
+ // Getting point coordinates
+ double x = real(PrimitivesPlugin_Box::OX_ID())->value();
+ double y = real(PrimitivesPlugin_Box::OY_ID())->value();
+ double z = real(PrimitivesPlugin_Box::OZ_ID())->value();
+
+ std::shared_ptr<GeomAlgoAPI_Box> aBoxAlgo;
+ aBoxAlgo = std::shared_ptr<GeomAlgoAPI_Box>(new GeomAlgoAPI_Box(x,y,z,aDx,aDy,aDz));
+
+ // These checks should be made to the GUI for the feature but
+ // the corresponding validator does not exist yet.
+ if (!aBoxAlgo->check()) {
+ setError(aBoxAlgo->getError());
+ return;
+ }
+
+ // Build the box
+ aBoxAlgo->build();
+
+ // Check if the creation of the box
+ if(!aBoxAlgo->isDone()) {
+ // The error is not displayed in a popup window. It must be in the message console.
+ setError(aBoxAlgo->getError());
+ return;
+ }
+ if(!aBoxAlgo->checkValid("Box builder with one point and dimensions")) {
+ // The error is not displayed in a popup window. It must be in the message console.
+ setError(aBoxAlgo->getError());
+ return;
+ }
+
+ int aResultIndex = 0;
+ ResultBodyPtr aResultBox = document()->createBody(data(), aResultIndex);
+ loadNamingDS(aBoxAlgo, aResultBox);
+ setResult(aResultBox, aResultIndex);
+}
+
//=================================================================================================
void PrimitivesPlugin_Box::loadNamingDS(std::shared_ptr<GeomAlgoAPI_Box> theBoxAlgo,
std::shared_ptr<ModelAPI_ResultBody> theResultBox)
* \ingroup Plugins
* \brief Feature for creation of a box primitive using various methods.
*
- * Box creates a cuboid - Parallelepiped with 6 rectangular faces. It can be built via two
- * methods : using two points that define a diagonal, or using 3 lengths that define the
+ * Box creates a cuboid - Parallelepiped with 6 rectangular faces. It can be built via three
+ * methods : using two points that define a diagonal, a point that define a center and 3 lengths
+ * that define the half-lengths on X, Y and Z-axes, or using 3 lengths that define the
* rectangular dimensions.
*/
class PrimitivesPlugin_Box : public ModelAPI_Feature
return MY_CREATION_METHOD_ID;
}
+ /// Attribute name for creation method
+ inline static const std::string& CREATION_METHOD_BY_ONE_POINT_AND_DIMS()
+ {
+ static const std::string MY_CREATION_METHOD_ID("BoxByOnePointAndDims");
+ return MY_CREATION_METHOD_ID;
+ }
+
/// Attribute name of first point
inline static const std::string& POINT_FIRST_ID()
{
return MY_DZ_ID;
}
+ /// Attribute name of the first coordinate of the center
+ inline static const std::string& OX_ID()
+ {
+ static const std::string MY_OX_ID("ox");
+ return MY_OX_ID;
+ }
+
+ /// Attribute name of the second coordinate of the center
+ inline static const std::string& OY_ID()
+ {
+ static const std::string MY_OY_ID("oy");
+ return MY_OY_ID;
+ }
+
+ /// Attribute name of the third coordinate of the center
+ inline static const std::string& OZ_ID()
+ {
+ static const std::string MY_OZ_ID("oz");
+ return MY_OZ_ID;
+ }
+
+ /// Attribute name of the half-length on X axis
+ inline static const std::string& HALF_DX_ID()
+ {
+ static const std::string MY_HALF_DX_ID("half_dx");
+ return MY_HALF_DX_ID;
+ }
+
+ /// Attribute name of the half-length on Y axis
+ inline static const std::string& HALF_DY_ID()
+ {
+ static const std::string MY_HALF_DY_ID("half_dy");
+ return MY_HALF_DY_ID;
+ }
+
+ /// Attribute name of the half-length on Z axis
+ inline static const std::string& HALF_DZ_ID()
+ {
+ static const std::string MY_HALF_DZ_ID("half_dz");
+ return MY_HALF_DZ_ID;
+ }
+
/// Returns the kind of a feature
PRIMITIVESPLUGIN_EXPORT virtual const std::string& getKind()
{
///Perform the creation of the box using three cordinates
void createBoxByDimensions();
+ ///Perform the creation of the box using a center and three half-lenths
+ void createBoxByOnePointAndDims();
+
};
#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();
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// File: PrimitivesPlugin_Sphere.h
+// File: PrimitivesPlugin_Sphere.cpp
// Created: 15 Mar 2017
// Author: Clarisse Genrault (CEA)
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeString.h>
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_ResultConstruction.h>
#include <ModelAPI_Session.h>
//=================================================================================================
void PrimitivesPlugin_Sphere::initAttributes()
{
+ 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(),
ModelAPI_AttributeSelection::typeId());
aCenterPoint->setValue(aPointRes, std::shared_ptr<GeomAPI_Shape>());
}
}
+
+ // data for the second mode : by dimensions
+ data()->addAttribute(PrimitivesPlugin_Sphere::RMIN_ID(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(PrimitivesPlugin_Sphere::RMAX_ID(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(PrimitivesPlugin_Sphere::PHIMIN_ID(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(PrimitivesPlugin_Sphere::PHIMAX_ID(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(PrimitivesPlugin_Sphere::THETAMIN_ID(), ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(PrimitivesPlugin_Sphere::THETAMAX_ID(), ModelAPI_AttributeDouble::typeId());
}
//=================================================================================================
void PrimitivesPlugin_Sphere::execute()
+{
+ AttributeStringPtr aMethodTypeAttr = string(PrimitivesPlugin_Sphere::CREATION_METHOD());
+ std::string aMethodType = aMethodTypeAttr->value();
+
+ if (aMethodType == CREATION_METHOD_BY_PT_RADIUS())
+ createSphereByPtRadius();
+
+ if (aMethodType == CREATION_METHOD_BY_DIMENSIONS())
+ createShereByDimensions();
+}
+
+
+//=================================================================================================
+void PrimitivesPlugin_Sphere::createSphereByPtRadius()
{
// Getting point.
std::shared_ptr<GeomAPI_Pnt> aCenterPoint;
// Build the sphere
aSphereAlgo->build();
- // Check if the creation of the cylinder
+ // Check if the creation of the sphere is OK
if(!aSphereAlgo->isDone()) {
setError(aSphereAlgo->getError());
return;
setResult(aResultBox, aResultIndex);
}
+//=================================================================================================
+void PrimitivesPlugin_Sphere::createShereByDimensions()
+{
+ // Getting rmin, rmax, phimin, phimax, thetamin et thetamax
+ double aRMin = real(PrimitivesPlugin_Sphere::RMIN_ID())->value();
+ double aRMax = real(PrimitivesPlugin_Sphere::RMAX_ID())->value();
+ double aPhiMin = real(PrimitivesPlugin_Sphere::PHIMIN_ID())->value();
+ double aPhiMax = real(PrimitivesPlugin_Sphere::PHIMAX_ID())->value();
+ double aThetaMin = real(PrimitivesPlugin_Sphere::THETAMIN_ID())->value();
+ double aThetaMax = real(PrimitivesPlugin_Sphere::THETAMAX_ID())->value();
+
+ std::shared_ptr<GeomAlgoAPI_Sphere> aSphereAlgo = std::shared_ptr<GeomAlgoAPI_Sphere>(
+ new GeomAlgoAPI_Sphere(aRMin, aRMax, aPhiMin, aPhiMax, aThetaMin, aThetaMax));
+
+ // These checks should be made to the GUI for the feature but
+ // the corresponding validator does not exist yet.
+ if (!aSphereAlgo->check()) {
+ setError(aSphereAlgo->getError());
+ return;
+ }
+
+ // Build the sphere
+ aSphereAlgo->build();
+
+ // Check if the creation of the sphere is OK
+ if(!aSphereAlgo->isDone()) {
+ // The error is not displayed in a popup window. It must be in the message console.
+ setError(aSphereAlgo->getError());
+ return;
+ }
+ if(!aSphereAlgo->checkValid("Sphere Builder")) {
+ // The error is not displayed in a popup window. It must be in the message console.
+ setError(aSphereAlgo->getError());
+ return;
+ }
+
+ int aResultIndex = 0;
+ ResultBodyPtr aResultBox = document()->createBody(data(), aResultIndex);
+ loadNamingDS(aSphereAlgo, aResultBox);
+ setResult(aResultBox, aResultIndex);
+}
+
//=================================================================================================
void PrimitivesPlugin_Sphere::loadNamingDS(std::shared_ptr<GeomAlgoAPI_Sphere> theSphereAlgo,
std::shared_ptr<ModelAPI_ResultBody> theResultSphere)
/**\class PrimitivesPlugin_Sphere
* \ingroup Plugins
- * \brief Feature for creation of a sphere.
+ * \brief Feature for creation of a sphere primitive using various methods.
*
- * Creates a sphere from a radius and a center point defaulting to the origin
+ * It can be built via two methods : using a radius and a center point defaulting to the origin,
+ * or radii (inner and outer) and angle limits (theta and phi).
*/
class PrimitivesPlugin_Sphere : public ModelAPI_Feature
{
return MY_SPHERE_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& CREATION_METHOD_BY_PT_RADIUS()
+ {
+ static const std::string MY_CREATION_METHOD_ID("SphereByPointRadius");
+ return MY_CREATION_METHOD_ID;
+ }
+
+ /// Attribute name for creation method
+ inline static const std::string& CREATION_METHOD_BY_DIMENSIONS()
+ {
+ static const std::string MY_CREATION_METHOD_ID("SphereByDimensions");
+ return MY_CREATION_METHOD_ID;
+ }
+
/// Attribute name of the base point
inline static const std::string& CENTER_POINT_ID()
{
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()
+ {
+ static const std::string MY_THETAMAX_ID("thetamax");
+ return MY_THETAMAX_ID;
+ }
+
/// Returns the kind of a feature
PRIMITIVESPLUGIN_EXPORT virtual const std::string& getKind()
{
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)
+ void createShereByDimensions();
+
};
#endif // PRIMITIVESPLUGIN_SPHERE_H_
--- /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>
shape_types="vertex">
</shape_selector>
</box>
+ <box id="BoxByOnePointAndDims" title="By one point and dimensions" icon="icons/Primitives/box_pt_dxyz_32x32.png">
+ <groupbox title="Origin">
+ <doublevalue
+ id="ox"
+ label="OX"
+ step="1."
+ default="0."
+ 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 center">
+ </doublevalue>
+ <doublevalue
+ id="oz"
+ label="OZ"
+ step="1."
+ default="0."
+ tooltip="Enter the coordinate Z for the center">
+ </doublevalue>
+ </groupbox>
+ <groupbox title="Half-lengths">
+ <doublevalue
+ id="half_dx"
+ label="DX"
+ step="1."
+ default="20."
+ tooltip="Enter the half length in X">
+ <validator id="GeomValidators_Positive" parameters="0"/>
+ </doublevalue>
+ <doublevalue
+ id="half_dy"
+ label="DY"
+ step="1."
+ default="20."
+ tooltip="Enter the half length in Y">
+ <validator id="GeomValidators_Positive" parameters="0"/>
+ </doublevalue>
+ <doublevalue
+ id="half_dz"
+ label="DZ"
+ step="1."
+ default="20."
+ tooltip="Enter the half length in Z">
+ <validator id="GeomValidators_Positive" parameters="0"/>
+ </doublevalue>
+ </groupbox>
+ </box>
</toolbox>
</source>
cylinderFeature.rst
sphereFeature.rst
torusFeature.rst
+ tubeFeature.rst
--- /dev/null
+
+ .. _tui_create_boxptdim:
+
+Create Box coordinates of a point and dimensions
+================================================
+
+.. literalinclude:: examples/box3.py
+ :linenos:
+ :language: python
+
+:download:`Download this script <examples/box3.py>`
+
.. _tui_create_cone:
-Create / Cone
-=============
+Create Cone
+===========
.. literalinclude:: examples/cone.py
:linenos:
.. _tui_create_cylinder:
-Create cylinder
-================
+Create Cylinder
+===============
.. literalinclude:: examples/cylinder1.py
:linenos:
.. _tui_create_cylportion:
-Create portion of cylinder
+Create Portion of cylinder
==========================
.. literalinclude:: examples/cylinder2.py
.. _tui_create_sphere:
-Create / Sphere
-===============
+Create Sphere
+=============
-.. literalinclude:: examples/sphere.py
+.. literalinclude:: examples/sphere1.py
:linenos:
:language: python
-:download:`Download this script <examples/sphere.py>`
-
+:download:`Download this script <examples/sphere1.py>`
--- /dev/null
+
+ .. _tui_create_part_sphere:
+
+Create Part of sphere
+=====================
+
+.. literalinclude:: examples/sphere2.py
+ :linenos:
+ :language: python
+
+:download:`Download this script <examples/sphere2.py>`
.. _tui_create_torus:
-Create / Torus
-==============
+Create Torus
+============
.. literalinclude:: examples/torus.py
:linenos:
--- /dev/null
+
+ .. _tui_create_tube:
+
+Create Tube
+===========
+
+.. literalinclude:: examples/tube.py
+ :linenos:
+ :language: python
+
+:download:`Download this script <examples/tube.py>`
+
-.. _box_feature:
+.. |Box_button.icon| image:: images/Box_button.png
Box
===
-.. |box.icon| image:: images/box.png
-
Box feature creates a box solid.
To create a Box in the active part:
#. select in the Main Menu *Primitives - > Box* item or
-#. click |box.icon| **Box** button in the toolbar:
+#. click |Box_button.icon| **Box** button in the toolbar:
-There are 2 algorithms for creation of a Box:
+There are 3 algorithms for creation of a Box:
.. figure:: images/box_dxyz_32x32.png
:align: left
**By two points**
+.. figure:: images/box_pt_dxyz_32x32.png
+ :align: left
+ :height: 24px
+
+**By coordinates of a point and dimensions**
+
--------------------------------------------------------------------------------
By dimensions
:param object: Second vertex of diagonal.
:return: Result object.
-**Arguments**: Part + 2 selected points (opposite vertices of the box)
-
Result
""""""
Created boxes
**See Also** a sample TUI Script of :ref:`tui_create_boxpnt` operation.
+
+By coordinates of a point and dimensions
+----------------------------------------
+
+Box is created by dimensions along X, Y, Z axis starting from the point of coordinates (x,y,z).
+
+.. figure:: images/Box_ptAndDims.png
+ :align: center
+
+Input fields:
+
+- **OX**, **OY**, **OZ** define coordinates of the center of box.
+- **DX**, **DY**, **DZ** define dimensions (hafl length) of the box along the corresponding coordinate axes.
+
+**TUI Command**:
+
+.. py:function:: model.addBox(Part_doc, OX, OY, OZ, DX, DY, DZ)
+
+ :param part: The current part object.
+ :param real: X coordinate of the center point
+ :param real: Y coordinate of the center point
+ :param real: Z coordinate of the center point
+ :param real: Half size along X.
+ :param real: Half size along Y.
+ :param real: Half size along Z.
+ :return: Result object.
+
+Result
+""""""
+
+A solid box whose point coordinates are the center and the dimensions are half lengths on one side and the other on the axes relative to the center.
+
+.. figure:: images/Box3.png
+ :align: center
+
+ Created boxes
+
+**See Also** a sample TUI Script of :ref:`tui_create_boxptdim` operation.
--- /dev/null
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Box_1 = model.addBox(Part_1_doc, 0, 0, 0, 20, 20, 20)
+model.do()
+model.end()
+++ /dev/null
-from salome.shaper import model
-
-model.begin()
-partSet = model.moduleDocument()
-Part_1 = model.addPart(partSet)
-Part_1_doc = Part_1.document()
-Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), 10)
-model.do()
-model.end()
--- /dev/null
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), 10)
+model.do()
+model.end()
--- /dev/null
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sphere_1 = model.addSphere(Part_1_doc,5,10,180,245,0,90)
+model.do()
+model.end()
--- /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()
Sphere
======
-Sphere feature creates a sphere solid.
+Sphere feature creates a sphere solid or a part of a sphere solid.
To create a Sphere in the active part:
#. select in the Main Menu *Primitives - > Sphere* item or
#. click |Sphere_button.icon| **Sphere** button in the toolbar
-The following property panel appears.
+There are 2 algorithms for creation of a Sphere
-.. figure:: images/Sphere.png
+.. figure:: images/sphere_32x32.png
+ :align: left
+ :height: 24px
+
+**By a center and a radius**
+
+.. figure:: images/sphere_part_32x32.png
+ :align: left
+ :height: 24px
+
+**By radii (inner and outer) and angle limits (theta and phi)**
+
+--------------------------------------------------------------------------------
+
+By a center and a radius
+------------------------
+
+Sphere is created by a center (origin by default) and a radius.
+
+.. figure:: images/Sphere_full.png
:align: center
- Sphere property panel
-
Input fields:
- **Point** defines the center of the sphere selected in 3D OCC viewer or object browser;
- **Radius** defines the radius.
-
+
**TUI Command**:
.. py:function:: model.addSphere(Part_doc, Point, Radius)
-
+
:param part: The current part object.
:param object: Vertex.
:param real: Radius.
Result
""""""
-An example is shown below.
+A solid sphere based on the origin and a radius.
-.. figure:: images/Sphere_res.png
+.. figure:: images/Sphere1.png
:align: center
-
- Sphere created
-**See Also** a sample TUI Script of :ref:`tui_create_sphere` operation.
+**See Also** a sample TUI Script of a :ref:`tui_create_sphere` operation.
+
+By radii (inner and outer) and angle limits (theta and phi)
+-----------------------------------------------------------
+
+Part of sphere is created by radii (inner and outer) and angle limits (phi and theta).
+
+.. figure:: images/Sphere_part.png
+ :align: center
+
+Input fields:
+
+- **RMin** defines the inner radius;
+- **RMax** defines the outer radius;
+- **PhiMin** defines the lower phi limit;
+- **PhiMax** defines the higher phi limit;
+- **ThetaMin** defines the lower theta limit;
+- **ThetaMax** defines the higher theta limit.
+
+**TUI Command**:
+
+.. py:function:: model.addSphere(Part_doc, RMin, RMax, PhiMin, PhiMax, ThetaMin, ThetaMax)
+
+ :param part: The current part object.
+ :param real: Inner radius.
+ :param real: Outer radius.
+ :param real: Lower phi.
+ :param real: Hiher phi.
+ :param real: Lower theta.
+ :param real: Hiher theta.
+ :return: Result object.
+
+Result
+""""""
+
+A solid sphere based on the origin with radii (inner and outer) and angles (phi and theta).
+
+.. figure:: images/Sphere2.png
+ :align: center
+
+**See Also** a sample TUI Script of a :ref:`tui_create_part_sphere` operation.
+
+
+
--- /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>
<source>
- <shape_selector id="center_point"
- label="Center point"
- icon="icons/Primitives/point.png"
- tooltip="Select a center point"
- shape_types="vertex">
- </shape_selector>
- <doublevalue id="radius"
- label="Radius"
- icon="icons/Primitives/radius.png"
- tooltip="Enter a radius"
- step="1."
- default="10.">
- </doublevalue>
-</source>
\ No newline at end of file
+ <toolbox id="CreationMethod">
+ <box id="SphereByPointRadius" title="By point and radius" icon="icons/Primitives/sphere_32x32.png">
+ <shape_selector id="center_point"
+ label="Center point"
+ icon="icons/Primitives/point.png"
+ tooltip="Select a center point"
+ shape_types="vertex">
+ </shape_selector>
+ <doublevalue id="radius"
+ label="Radius"
+ icon="icons/Primitives/radius.png"
+ tooltip="Enter a radius"
+ step="1."
+ default="10.">
+ </doublevalue>
+ </box>
+ <box id="SphereByDimensions" title="By dimensions" icon="icons/Primitives/sphere_part_32x32.png">
+ <groupbox title="Dimensions">
+ <doublevalue id="rmin"
+ label="Rmin"
+ step="1."
+ default="0."
+ tooltip="Enter the inner radius">
+ </doublevalue>
+ <doublevalue id="rmax"
+ label="Rmax"
+ step="1."
+ default="10."
+ tooltip="Enter the outer radius">
+ </doublevalue>
+ </groupbox>
+ <label title=""/>
+ <groupbox title="Phi/theta range">
+ <doublevalue id="phimin"
+ label="Phi min"
+ step="1."
+ default="0."
+ tooltip="Enter the azimuthal starting angle">
+ </doublevalue>
+ <doublevalue id="phimax"
+ label="Phi max"
+ step="1."
+ default="360."
+ max="360.0"
+ tooltip="Enter the azimuthal revolution angle">
+ </doublevalue>
+ <doublevalue id="thetamin"
+ label="Theta min"
+ step="1."
+ default="0."
+ max="180.0"
+ tooltip="Enter the polar starting angle">
+ </doublevalue>
+ <doublevalue id="thetamax"
+ label="Theta max"
+ step="1."
+ default="180."
+ max="180.0"
+ tooltip="Enter the polar revolution angle">
+ </doublevalue>
+ </groupbox>
+ </box>
+ </toolbox>
+</source>
--- /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
try :
Box_9 = shaperpy.makeBox(pnt1,pnt1)
except myExcept as ec:
- assert(ec.what() == "Box builder with points :: the distance between the two points is null.")
+ assert(ec.what() == "Box builder with two points :: the distance between the two points is null.")
try :
pnt3 = pnt(0.,50.,50.)
Box_10 = shaperpy.makeBox(pnt1,pnt3)
except myExcept as ec:
- assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.")
+ assert(ec.what() == "Box builder with two points :: the points belong both to one of the OXY, OYZ or OZX planes.")
try :
pnt4 = pnt(50.,0.,50.)
Box_11 = shaperpy.makeBox(pnt1,pnt4)
except myExcept as ec:
- assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.")
+ assert(ec.what() == "Box builder with two points :: the points belong both to one of the OXY, OYZ or OZX planes.")
try :
pnt5 = pnt(50.,50.,0.)
Box_12 = shaperpy.makeBox(pnt1,pnt5)
except myExcept as ec:
- assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.")
+ assert(ec.what() == "Box builder with two points :: the points belong both to one of the OXY, OYZ or OZX planes.")
try :
Box_13 = shaperpy.makeBox(None, pnt2)
except myExcept as ec:
- assert(ec.what() == "Box builder with points :: the first point is not valid.")
+ assert(ec.what() == "Box builder with two points :: the first point is not valid.")
try :
Box_14 = shaperpy.makeBox(pnt2, None)
except myExcept as ec:
- assert(ec.what() == "Box builder with points :: the second point is not valid.")
\ No newline at end of file
+ assert(ec.what() == "Box builder with two points :: the second point is not valid.")
Box_16 = model.addBox(Part_1_doc, model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_6][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_7][Extrusion_2_1/To_Face]"))
Box_17 = model.addBox(Part_1_doc, model.selection("VERTEX", "Vertex_1_1"), model.selection("VERTEX", "Vertex_2_1"))
Box_18 = model.addBox(Part_1_doc, "dx", "dy", "dz")
+Box_19 = model.addBox(Part_1_doc, 0, 0, 0, 20, 20 ,20)
model.do()
model.end()
model.testNbSubShapes(Box_18, GeomAPI_Shape.FACE, [6])
model.testHaveNamingFaces(Box_18, model, Part_1_doc)
+model.testNbResults(Box_19, 1)
+model.testNbSubResults(Box_19, [0])
+model.testNbSubShapes(Box_19, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Box_19, GeomAPI_Shape.FACE, [6])
+model.testHaveNamingFaces(Box_19, model, Part_1_doc)
+
model.testNbResults(Box_2, 0)
assert(Box_2.feature().error() == "Box builder with dimensions :: Dx is null or negative.")
assert(Box_7.feature().error() == "Box builder with dimensions :: Dz is null or negative.")
model.testNbResults(Box_9, 0)
-assert(Box_9.feature().error() == "Box builder with points :: the distance between the two points is null.")
+assert(Box_9.feature().error() == "Box builder with two points :: the distance between the two points is null.")
model.testNbResults(Box_10, 0)
-assert(Box_10.feature().error() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.")
+assert(Box_10.feature().error() == "Box builder with two points :: the points belong both to one of the OXY, OYZ or OZX planes.")
model.testNbResults(Box_11, 0)
-assert(Box_11.feature().error() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.")
+assert(Box_11.feature().error() == "Box builder with two points :: the points belong both to one of the OXY, OYZ or OZX planes.")
model.testNbResults(Box_12, 0)
-assert(Box_12.feature().error() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.")
+assert(Box_12.feature().error() == "Box builder with two points :: the points belong both to one of the OXY, OYZ or OZX planes.")
model.testNbResults(Box_13, 0)
assert(Box_13.feature().error() == "Attribute \"FirstPoint\" is not initialized.")
Sphere_7 = model.addSphere(Part_1_doc, 10)
Sphere_7.setCenterPoint(Point_1)
+Sphere_8 = model.addSphere(Part_1_doc,10,40,0,180,0,180)
+Sphere_9 = model.addSphere(Part_1_doc,40,10,0,180,0,180)
+
model.do()
model.end()
model.testNbSubShapes(Sphere_7, GeomAPI_Shape.FACE, [1])
model.testHaveNamingFaces(Sphere_7, model, Part_1_doc)
+model.testNbResults(Sphere_8, 1)
+model.testNbSubResults(Sphere_8, [0])
+model.testNbSubShapes(Sphere_8, GeomAPI_Shape.SOLID, [1])
+model.testNbSubShapes(Sphere_8, GeomAPI_Shape.FACE, [4])
+model.testHaveNamingFaces(Sphere_8, model, Part_1_doc)
+
model.testNbResults(Sphere_2, 0)
assert(Sphere_2.feature().error() == "Sphere builder :: radius is negative or null.")
model.testNbResults(Sphere_5, 0)
assert(Sphere_5.feature().error() == "Attribute \"center_point\" is not initialized.")
+
+model.testNbResults(Sphere_9, 0)
+assert(Sphere_9.feature().error() == "Sphere builder :: RMin is larger than RMax.")
--- /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