]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge remote-tracking branch 'origin/cgt/primitives_1'
authorcg246364 <clarisse.genrault@cea.fr>
Fri, 18 Mar 2022 09:27:38 +0000 (10:27 +0100)
committercg246364 <clarisse.genrault@cea.fr>
Fri, 18 Mar 2022 09:27:38 +0000 (10:27 +0100)
76 files changed:
src/GeomAlgoAPI/CMakeLists.txt
src/GeomAlgoAPI/GeomAlgoAPI_Box.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Box.h
src/GeomAlgoAPI/GeomAlgoAPI_Sphere.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Sphere.h
src/GeomAlgoAPI/GeomAlgoAPI_Tube.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_Tube.h [new file with mode: 0644]
src/PrimitivesAPI/CMakeLists.txt
src/PrimitivesAPI/PrimitivesAPI.i
src/PrimitivesAPI/PrimitivesAPI_Box.cpp
src/PrimitivesAPI/PrimitivesAPI_Box.h
src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp
src/PrimitivesAPI/PrimitivesAPI_Sphere.h
src/PrimitivesAPI/PrimitivesAPI_Torus.h
src/PrimitivesAPI/PrimitivesAPI_Tube.cpp [new file with mode: 0644]
src/PrimitivesAPI/PrimitivesAPI_Tube.h [new file with mode: 0644]
src/PrimitivesAPI/PrimitivesAPI_swig.h
src/PrimitivesPlugin/CMakeLists.txt
src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp
src/PrimitivesPlugin/PrimitivesPlugin_Box.h
src/PrimitivesPlugin/PrimitivesPlugin_Plugin.cpp
src/PrimitivesPlugin/PrimitivesPlugin_Sphere.cpp
src/PrimitivesPlugin/PrimitivesPlugin_Sphere.h
src/PrimitivesPlugin/PrimitivesPlugin_Tube.cpp [new file with mode: 0644]
src/PrimitivesPlugin/PrimitivesPlugin_Tube.h [new file with mode: 0644]
src/PrimitivesPlugin/PrimitivesPlugin_msg_fr.ts
src/PrimitivesPlugin/box_widget.xml
src/PrimitivesPlugin/doc/PrimitivesPlugin.rst
src/PrimitivesPlugin/doc/TUI_boxByPtDims.rst [new file with mode: 0644]
src/PrimitivesPlugin/doc/TUI_coneFeature.rst
src/PrimitivesPlugin/doc/TUI_cylinderFeature.rst
src/PrimitivesPlugin/doc/TUI_cylinderPortion.rst
src/PrimitivesPlugin/doc/TUI_sphereFeature.rst
src/PrimitivesPlugin/doc/TUI_spherePart.rst [new file with mode: 0644]
src/PrimitivesPlugin/doc/TUI_torusFeature.rst
src/PrimitivesPlugin/doc/TUI_tubeFeature.rst [new file with mode: 0644]
src/PrimitivesPlugin/doc/boxFeature.rst
src/PrimitivesPlugin/doc/examples/box3.py [new file with mode: 0644]
src/PrimitivesPlugin/doc/examples/sphere.py [deleted file]
src/PrimitivesPlugin/doc/examples/sphere1.py [new file with mode: 0644]
src/PrimitivesPlugin/doc/examples/sphere2.py [new file with mode: 0644]
src/PrimitivesPlugin/doc/examples/tube.py [new file with mode: 0644]
src/PrimitivesPlugin/doc/images/Box3.png [new file with mode: 0644]
src/PrimitivesPlugin/doc/images/Box_2points.png
src/PrimitivesPlugin/doc/images/Box_dimensions.png
src/PrimitivesPlugin/doc/images/Box_ptAndDims.png [new file with mode: 0644]
src/PrimitivesPlugin/doc/images/Sphere.png [deleted file]
src/PrimitivesPlugin/doc/images/Sphere1.png [new file with mode: 0644]
src/PrimitivesPlugin/doc/images/Sphere2.png [new file with mode: 0644]
src/PrimitivesPlugin/doc/images/Sphere_button.png
src/PrimitivesPlugin/doc/images/Sphere_full.png [new file with mode: 0644]
src/PrimitivesPlugin/doc/images/Sphere_part.png [new file with mode: 0644]
src/PrimitivesPlugin/doc/images/Sphere_res.png [deleted file]
src/PrimitivesPlugin/doc/images/Tube.png [new file with mode: 0644]
src/PrimitivesPlugin/doc/images/Tube_button.png [new file with mode: 0755]
src/PrimitivesPlugin/doc/images/Tube_res.png [new file with mode: 0644]
src/PrimitivesPlugin/doc/images/box.png [deleted file]
src/PrimitivesPlugin/doc/images/box_pt_dxyz_32x32.png [new file with mode: 0644]
src/PrimitivesPlugin/doc/images/sphere_32x32.png [new file with mode: 0644]
src/PrimitivesPlugin/doc/images/sphere_part_32x32.png [new file with mode: 0644]
src/PrimitivesPlugin/doc/sphereFeature.rst
src/PrimitivesPlugin/doc/tubeFeature.rst [new file with mode: 0644]
src/PrimitivesPlugin/icons/box_pt_dxyz_32x32.png [new file with mode: 0644]
src/PrimitivesPlugin/icons/sphere.png
src/PrimitivesPlugin/icons/sphere_32x32.png [new file with mode: 0755]
src/PrimitivesPlugin/icons/sphere_part_32x32.png [new file with mode: 0755]
src/PrimitivesPlugin/icons/tube.png [new file with mode: 0755]
src/PrimitivesPlugin/plugin-Primitives.xml
src/PrimitivesPlugin/sphere_widget.xml
src/PrimitivesPlugin/tube_widget.xml [new file with mode: 0644]
src/PythonAPI/model/primitives/__init__.py
test.API/SHAPER/Primitives/TestAPI_Box.py
test.API/SHAPER/Primitives/TestBox.py
test.API/SHAPER/Primitives/TestSphere.py
test.API/SHAPER/Primitives/TestTube.py [new file with mode: 0644]
test.API/SHAPER/tests.set

index 19ace76ed583fa94ea0ad1f2edf14ed861b63a24..17eec671e669f6f73e0de20d4c26b9108e597f8c 100644 (file)
@@ -92,6 +92,7 @@ SET(PROJECT_HEADERS
     GeomAlgoAPI_Defeaturing.h
     GeomAlgoAPI_BoundingBox.h
     GeomAlgoAPI_NormalToFace.h
+    GeomAlgoAPI_Tube.h
 )
 
 SET(PROJECT_SOURCES
@@ -163,6 +164,7 @@ SET(PROJECT_SOURCES
     GeomAlgoAPI_Defeaturing.cpp
     GeomAlgoAPI_BoundingBox.cpp
     GeomAlgoAPI_NormalToFace.cpp
+    GeomAlgoAPI_Tube.cpp
 )
 
 SET(PROJECT_LIBRARIES
index 1dcc9fa97598539ecabe9f714740eba5ad9fd0ef..4ba9fd2ad3757be38c63f205661420eab0e27325 100644 (file)
@@ -34,6 +34,7 @@ GeomAlgoAPI_Box::GeomAlgoAPI_Box(const double theDx, const double theDy, const d
   myDy = theDy;
   myDz = theDz;
   myMethodType = MethodType::BOX_DIM;
+  headError = "Box builder with dimensions";
 }
 
 //=================================================================================================
@@ -43,33 +44,48 @@ GeomAlgoAPI_Box::GeomAlgoAPI_Box(std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
   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();
@@ -79,7 +95,7 @@ bool GeomAlgoAPI_Box::check()
         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 {
@@ -96,6 +112,8 @@ void GeomAlgoAPI_Box::build()
     buildWithDimensions();
   } else if (myMethodType == MethodType::BOX_POINTS) {
     buildWithPoints();
+  } else if (myMethodType == MethodType::BOX_POINT_DIMS) {
+    buildWithPointAndDims();
   } else {
     myError = "Box builder :: Method not implemented.";
     return;
@@ -113,7 +131,7 @@ void GeomAlgoAPI_Box::buildWithDimensions()
 
   // Test the algorithm
   if (!aBoxMaker->IsDone()) {
-    myError = "Box builder with dimensions  :: algorithm failed.";
+    myError = headError + " :: algorithm failed.";
     return;
   }
 
@@ -124,7 +142,7 @@ void GeomAlgoAPI_Box::buildWithDimensions()
 
   // 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;
   }
 
@@ -147,7 +165,7 @@ void GeomAlgoAPI_Box::buildWithPoints()
 
   // Test the algorithm
   if(!aBoxMaker->IsDone()) {
-    myError = "Box builder with two points  :: algorithm failed.";
+    myError = headError + " :: algorithm failed.";
     return;
   }
 
@@ -159,7 +177,7 @@ void GeomAlgoAPI_Box::buildWithPoints()
 
   // 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;
   }
 
@@ -168,6 +186,18 @@ void GeomAlgoAPI_Box::buildWithPoints()
   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()
 {
index c6f1269f1c811273587dd0287bf1b4c0cca214f0..b64131f9baffbca09bd9799139d4e7b90f196ccf 100644 (file)
@@ -34,6 +34,7 @@ class GeomAlgoAPI_Box : public GeomAlgoAPI_MakeShape
   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();
@@ -50,6 +51,16 @@ class GeomAlgoAPI_Box : public GeomAlgoAPI_MakeShape
   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();
 
@@ -64,13 +75,19 @@ class GeomAlgoAPI_Box : public GeomAlgoAPI_MakeShape
   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
 };
 
 
index f2b8db42c5fbefdbd43353fdca3a580eddca8110..7a045049fa3ae5abc021a013fcee1698c6686a9c 100644 (file)
 
 #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;
 }
@@ -51,30 +80,151 @@ bool GeomAlgoAPI_Sphere::check()
 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);
 }
index 8fb4499489fdb818bb2ab2dcfc7544698c12face..1f29859bc267f32d2555d60a046a9b009c6f73e9 100644 (file)
@@ -40,6 +40,16 @@ class GeomAlgoAPI_Sphere : public GeomAlgoAPI_MakeShape
   /// \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();
@@ -47,9 +57,16 @@ class GeomAlgoAPI_Sphere : public GeomAlgoAPI_MakeShape
   /// 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_
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Tube.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Tube.cpp
new file mode 100644 (file)
index 0000000..55296f3
--- /dev/null
@@ -0,0 +1,132 @@
+// 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);
+}
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Tube.h b/src/GeomAlgoAPI/GeomAlgoAPI_Tube.h
new file mode 100644 (file)
index 0000000..73cfe48
--- /dev/null
@@ -0,0 +1,57 @@
+// 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_
index 507b54c4530e920cd20127fcb852ae06f74c7180..e6df736f5b9edcd804bdbdc87a66a7e822e76564 100644 (file)
@@ -26,6 +26,7 @@ SET(PROJECT_HEADERS
   PrimitivesAPI_Cylinder.h
   PrimitivesAPI_Sphere.h
   PrimitivesAPI_Torus.h
+  PrimitivesAPI_Tube.h
 )
 
 SET(PROJECT_SOURCES
@@ -34,6 +35,7 @@ SET(PROJECT_SOURCES
   PrimitivesAPI_Cylinder.cpp
   PrimitivesAPI_Sphere.cpp
   PrimitivesAPI_Torus.cpp
+  PrimitivesAPI_Tube.cpp
 )
 
 SET(PROJECT_LIBRARIES
index 5fa74c454b6acc7c07266fcf572b1f6d8f07e088..3e6dc352134329fb42d75525b38c9b9246e58c9b 100644 (file)
@@ -43,6 +43,7 @@
 %shared_ptr(PrimitivesAPI_Cylinder)
 %shared_ptr(PrimitivesAPI_Sphere)
 %shared_ptr(PrimitivesAPI_Torus)
+%shared_ptr(PrimitivesAPI_Tube)
 
 // all supported interfaces
 %include "PrimitivesAPI_Box.h"
@@ -50,3 +51,4 @@
 %include "PrimitivesAPI_Cylinder.h"
 %include "PrimitivesAPI_Sphere.h"
 %include "PrimitivesAPI_Torus.h"
+%include "PrimitivesAPI_Tube.h"
index 04b73f6ee420c50d5ed9c814cb9ec950780e0341..67fbe339611605441ca62dca07cd7e7e9d1b9490 100644 (file)
@@ -50,6 +50,29 @@ PrimitivesAPI_Box::PrimitivesAPI_Box(const std::shared_ptr<ModelAPI_Feature>& th
     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()
 {
@@ -80,6 +103,30 @@ void PrimitivesAPI_Box::setPoints(const ModelHighAPI_Selection& theFirstPoint,
   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
 {
@@ -101,6 +148,16 @@ 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;
@@ -123,4 +180,18 @@ BoxPtr addBox(const std::shared_ptr<ModelAPI_Document>& thePart,
 {
   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));
+}
index 2fda32494230c01332c9bf4a1c54e9c2e3a7d630..33b412bea8fa41fa7d492054ec23aef7a9011b86 100644 (file)
@@ -53,11 +53,21 @@ public:
                              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(),
@@ -69,7 +79,19 @@ public:
              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
@@ -82,6 +104,18 @@ public:
   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;
@@ -105,4 +139,15 @@ BoxPtr addBox(const std::shared_ptr<ModelAPI_Document>& thePart,
               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_
index 4b3b594ad59854bcdab790cb0cffc552158f42a8..20e9cbd1c93b43caa81c5c43a6e0323234c29570 100644 (file)
@@ -41,11 +41,34 @@ PrimitivesAPI_Sphere::PrimitivesAPI_Sphere(const std::shared_ptr<ModelAPI_Featur
 : 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()
 {
@@ -65,6 +88,33 @@ void PrimitivesAPI_Sphere::setRadius(const ModelHighAPI_Double& theRadius)
   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
 {
@@ -73,10 +123,24 @@ 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;
 }
@@ -98,3 +162,17 @@ SpherePtr addSphere(const std::shared_ptr<ModelAPI_Document>& thePart,
   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));
+}
index 68e0ca5df180265bd1bccdb1b55a56669e547af3..3c4691a460168cf5b47143df5794bbcdef4d3c64 100644 (file)
@@ -50,15 +50,39 @@ public:
                                 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
@@ -68,6 +92,18 @@ public:
   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;
@@ -89,4 +125,15 @@ PRIMITIVESAPI_EXPORT
 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_
index b460da8263410719fdf6e61a9df243b70e8131db..9a65372a19d43627945c2fa029035e8766a5bb5a 100644 (file)
@@ -36,7 +36,7 @@ class ModelHighAPI_Selection;
 
 /// \class PrimitivesAPI_Torus
 /// \ingroup CPPHighAPI
-/// \brief Interface for primitive Cone feature.
+/// \brief Interface for primitive Torus feature.
 class PrimitivesAPI_Torus: public ModelHighAPI_Interface
 {
 public:
@@ -76,11 +76,11 @@ 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,
@@ -89,7 +89,7 @@ TorusPtr addTorus(const std::shared_ptr<ModelAPI_Document>& thePart,
                   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,
diff --git a/src/PrimitivesAPI/PrimitivesAPI_Tube.cpp b/src/PrimitivesAPI/PrimitivesAPI_Tube.cpp
new file mode 100644 (file)
index 0000000..8bdd639
--- /dev/null
@@ -0,0 +1,91 @@
+// 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));
+}
diff --git a/src/PrimitivesAPI/PrimitivesAPI_Tube.h b/src/PrimitivesAPI/PrimitivesAPI_Tube.h
new file mode 100644 (file)
index 0000000..dd582b1
--- /dev/null
@@ -0,0 +1,86 @@
+// 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_
index 21934d3a08eecfbe21dd77c35878602e47d634ff..7473a911ba2264be2e026052aec2f76e4429c2a9 100644 (file)
@@ -28,5 +28,6 @@
   #include "PrimitivesAPI_Cylinder.h"
   #include "PrimitivesAPI_Sphere.h"
   #include "PrimitivesAPI_Torus.h"
+  #include "PrimitivesAPI_Tube.h"
 
 #endif // PRIMITIVESAPI_SWIG_H_
index 4504f17eea529c93373f03dd635d6261d649cdee..9c0272d1426cb449ea8b89d22e36f344eebafe79 100644 (file)
@@ -25,6 +25,7 @@ SET(PROJECT_HEADERS
     PrimitivesPlugin_Cylinder.h
     PrimitivesPlugin_Sphere.h
     PrimitivesPlugin_Torus.h
+    PrimitivesPlugin_Tube.h
 )
 
 SET(PROJECT_SOURCES
@@ -34,6 +35,7 @@ SET(PROJECT_SOURCES
     PrimitivesPlugin_Cylinder.cpp
     PrimitivesPlugin_Sphere.cpp
     PrimitivesPlugin_Torus.cpp
+    PrimitivesPlugin_Tube.cpp
 )
 
 SET(XML_RESOURCES
@@ -43,6 +45,7 @@ SET(XML_RESOURCES
   cylinder_widget.xml
   sphere_widget.xml
   torus_widget.xml
+  tube_widget.xml
 )
 
 SET(TEXT_RESOURCES
index 30caf171d39a45ee0e48b2da7d36edc8aaded731..feea6763d29bb0f9d8b8daabda8cd42279bc1340 100644 (file)
@@ -40,14 +40,24 @@ void PrimitivesPlugin_Box::initAttributes()
 {
   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());
 }
 
 //=================================================================================================
@@ -61,6 +71,9 @@ void PrimitivesPlugin_Box::execute()
 
   if (aMethodType == CREATION_METHOD_BY_TWO_POINTS())
     createBoxByTwoPoints();
+
+  if (aMethodType == CREATION_METHOD_BY_ONE_POINT_AND_DIMS())
+    createBoxByOnePointAndDims();
 }
 
 //=================================================================================================
@@ -148,6 +161,50 @@ void PrimitivesPlugin_Box::createBoxByTwoPoints()
   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)
index 252cf52f3b17e6709708c995ddc1a9c8513e4eef..6d2b64095d80d60b2f7abf946337d5726f3cb99d 100644 (file)
@@ -31,8 +31,9 @@ class ModelAPI_ResultBody;
  * \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
@@ -66,6 +67,13 @@ 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()
   {
@@ -101,6 +109,48 @@ class PrimitivesPlugin_Box : public ModelAPI_Feature
     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()
   {
@@ -128,6 +178,9 @@ class PrimitivesPlugin_Box : public ModelAPI_Feature
   ///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();
+
 };
 
 
index 876f4dd9ad2ead88b2a668e02d5f26708cadaafd..5a248113390f4ee8159dd1ee5d661fe46bd6405a 100644 (file)
@@ -24,6 +24,7 @@
 #include <PrimitivesPlugin_Cylinder.h>
 #include <PrimitivesPlugin_Sphere.h>
 #include <PrimitivesPlugin_Torus.h>
+#include <PrimitivesPlugin_Tube.h>
 
 #include <ModelAPI_Session.h>
 
@@ -52,6 +53,8 @@ FeaturePtr PrimitivesPlugin_Plugin::createFeature(std::string theFeatureID)
     return FeaturePtr(new PrimitivesPlugin_Sphere);
   } else if (theFeatureID == PrimitivesPlugin_Torus::ID()) {
     return FeaturePtr(new PrimitivesPlugin_Torus);
+  } else if (theFeatureID == PrimitivesPlugin_Tube::ID()) {
+    return FeaturePtr(new PrimitivesPlugin_Tube);
   }
   // feature of such kind is not found
   return FeaturePtr();
index 00ca224b09375f01193c573a8803fb105a41fe9a..f6da4b6cb8aa3690829b560288a271b8c87e3c2e 100644 (file)
@@ -17,7 +17,7 @@
 // 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)
 
@@ -29,6 +29,7 @@
 
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeString.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultConstruction.h>
 #include <ModelAPI_Session.h>
@@ -43,6 +44,10 @@ PrimitivesPlugin_Sphere::PrimitivesPlugin_Sphere()
 //=================================================================================================
 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());
 
@@ -60,10 +65,32 @@ void PrimitivesPlugin_Sphere::initAttributes()
       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;
@@ -95,7 +122,7 @@ void PrimitivesPlugin_Sphere::execute()
   // 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;
@@ -111,6 +138,48 @@ void PrimitivesPlugin_Sphere::execute()
   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)
index 2f00e989e717b924c7e19a66a937689b4f89c028..2e54765cde9c5c47c4426672ab02007b30c9cd34 100644 (file)
 
 /**\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
 {
@@ -44,6 +45,27 @@ 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()
   {
@@ -58,6 +80,48 @@ class PrimitivesPlugin_Sphere : public ModelAPI_Feature
     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()
   {
@@ -79,6 +143,13 @@ class PrimitivesPlugin_Sphere : public ModelAPI_Feature
   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_
diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Tube.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Tube.cpp
new file mode 100644 (file)
index 0000000..d9a90d9
--- /dev/null
@@ -0,0 +1,78 @@
+// 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);
+  }
+}
diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Tube.h b/src/PrimitivesPlugin/PrimitivesPlugin_Tube.h
new file mode 100644 (file)
index 0000000..c3af279
--- /dev/null
@@ -0,0 +1,88 @@
+// 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
index 22d0de57f5bed891432a160f85a67128885d0db5..a046099c653bf6a4a57e3f6bd3353bc76f4434ab 100644 (file)
       <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&apos;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&apos;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&apos;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&apos;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>
index f968b51548329378954dbe794c2071d46aaa8609..23ac51326ea41c56ebf264187edcbdef29467a1f 100644 (file)
         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>
index 364373d009333bba79ac55e9fac59664b5641536..02e0b8702525d2bb8a8d500e8d7915a379ee9601 100644 (file)
@@ -15,3 +15,4 @@ The Primitives plug-in contains features for creation of geometrical primitives.
    cylinderFeature.rst
    sphereFeature.rst
    torusFeature.rst
+   tubeFeature.rst
diff --git a/src/PrimitivesPlugin/doc/TUI_boxByPtDims.rst b/src/PrimitivesPlugin/doc/TUI_boxByPtDims.rst
new file mode 100644 (file)
index 0000000..2b5aa31
--- /dev/null
@@ -0,0 +1,12 @@
+
+  .. _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>` 
+
index aa95fa132464297d50e54570c7d7af5071a220fe..4c5b3ffdcf696541f532b03eabbe10ef22796ff6 100644 (file)
@@ -1,8 +1,8 @@
 
   .. _tui_create_cone:
 
-Create Cone
-=============
+Create Cone
+===========
 
 .. literalinclude:: examples/cone.py
     :linenos:
index dc326819c09a2f66d32f2cef1a77646fb938d7a3..bb9030e5333da58dd5f53b85071f0b59e408ccf3 100644 (file)
@@ -1,8 +1,8 @@
 
   .. _tui_create_cylinder:
 
-Create cylinder
-================
+Create Cylinder
+===============
 
 .. literalinclude:: examples/cylinder1.py
     :linenos:
index 8d2bad8fb82a9f75e0817ab42ea2a0f682940262..5014c936d9873a142ac7f22c14d078c75835b855 100644 (file)
@@ -1,7 +1,7 @@
 
   .. _tui_create_cylportion:
 
-Create portion of cylinder
+Create Portion of cylinder
 ==========================
 
 .. literalinclude:: examples/cylinder2.py
index f4012bcce14e5670e4fe75f89632b8343d009838..45a63db54c9f62686a24d8978f5ca1c6177b1f32 100644 (file)
@@ -1,12 +1,11 @@
 
   .. _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>` 
diff --git a/src/PrimitivesPlugin/doc/TUI_spherePart.rst b/src/PrimitivesPlugin/doc/TUI_spherePart.rst
new file mode 100644 (file)
index 0000000..56b3447
--- /dev/null
@@ -0,0 +1,11 @@
+
+  .. _tui_create_part_sphere:
+
+Create Part of sphere
+=====================
+
+.. literalinclude:: examples/sphere2.py
+    :linenos:
+    :language: python
+
+:download:`Download this script <examples/sphere2.py>` 
index 5c4a63261553d3979b4e02bc32d842aaa87f8135..07a422740bac3bcaec7b2037a233a5be39e06aaf 100644 (file)
@@ -1,8 +1,8 @@
 
   .. _tui_create_torus:
 
-Create Torus
-==============
+Create Torus
+============
 
 .. literalinclude:: examples/torus.py
     :linenos:
diff --git a/src/PrimitivesPlugin/doc/TUI_tubeFeature.rst b/src/PrimitivesPlugin/doc/TUI_tubeFeature.rst
new file mode 100644 (file)
index 0000000..551c854
--- /dev/null
@@ -0,0 +1,12 @@
+
+  .. _tui_create_tube:
+
+Create Tube
+===========
+
+.. literalinclude:: examples/tube.py
+    :linenos:
+    :language: python
+
+:download:`Download this script <examples/tube.py>` 
+   
index 759fc9eb8361c1f615e11a1e902f0c88bc29ef6e..e91466c20a7808e51c04ff57042b576f08c8aada 100644 (file)
@@ -1,18 +1,16 @@
-.. _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
@@ -26,6 +24,12 @@ There are 2 algorithms for creation of a Box:
 
 **By two points** 
 
+.. figure:: images/box_pt_dxyz_32x32.png
+   :align: left
+   :height: 24px
+
+**By coordinates of a point and dimensions** 
+
 --------------------------------------------------------------------------------
 
 By dimensions
@@ -81,8 +85,6 @@ Input fields:
     :param object: Second vertex of diagonal.
     :return: Result object.
 
-**Arguments**:   Part + 2 selected points (opposite vertices of the box)
-
 Result
 """"""
 
@@ -94,3 +96,41 @@ A solid box based on two points and with edges parallel to the coordinate axes.
    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.
diff --git a/src/PrimitivesPlugin/doc/examples/box3.py b/src/PrimitivesPlugin/doc/examples/box3.py
new file mode 100644 (file)
index 0000000..4931439
--- /dev/null
@@ -0,0 +1,9 @@
+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()
diff --git a/src/PrimitivesPlugin/doc/examples/sphere.py b/src/PrimitivesPlugin/doc/examples/sphere.py
deleted file mode 100644 (file)
index 05320ce..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-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()
diff --git a/src/PrimitivesPlugin/doc/examples/sphere1.py b/src/PrimitivesPlugin/doc/examples/sphere1.py
new file mode 100644 (file)
index 0000000..05320ce
--- /dev/null
@@ -0,0 +1,9 @@
+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()
diff --git a/src/PrimitivesPlugin/doc/examples/sphere2.py b/src/PrimitivesPlugin/doc/examples/sphere2.py
new file mode 100644 (file)
index 0000000..81f469e
--- /dev/null
@@ -0,0 +1,9 @@
+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()
diff --git a/src/PrimitivesPlugin/doc/examples/tube.py b/src/PrimitivesPlugin/doc/examples/tube.py
new file mode 100644 (file)
index 0000000..99567f9
--- /dev/null
@@ -0,0 +1,9 @@
+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()
diff --git a/src/PrimitivesPlugin/doc/images/Box3.png b/src/PrimitivesPlugin/doc/images/Box3.png
new file mode 100644 (file)
index 0000000..a1b5e5f
Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/Box3.png differ
index 77bec595da76cdf9e2a1efbba0331c072b05c177..fa73200da002f7194253bad088aaa85dc0c69c35 100644 (file)
Binary files a/src/PrimitivesPlugin/doc/images/Box_2points.png and b/src/PrimitivesPlugin/doc/images/Box_2points.png differ
index 8fee3ead8cf821908470c1bbab1465b51958d9ee..40ef70117ac902da70866de7ade1e43c02df05bb 100644 (file)
Binary files a/src/PrimitivesPlugin/doc/images/Box_dimensions.png and b/src/PrimitivesPlugin/doc/images/Box_dimensions.png differ
diff --git a/src/PrimitivesPlugin/doc/images/Box_ptAndDims.png b/src/PrimitivesPlugin/doc/images/Box_ptAndDims.png
new file mode 100644 (file)
index 0000000..3fedaf7
Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/Box_ptAndDims.png differ
diff --git a/src/PrimitivesPlugin/doc/images/Sphere.png b/src/PrimitivesPlugin/doc/images/Sphere.png
deleted file mode 100644 (file)
index a507c8a..0000000
Binary files a/src/PrimitivesPlugin/doc/images/Sphere.png and /dev/null differ
diff --git a/src/PrimitivesPlugin/doc/images/Sphere1.png b/src/PrimitivesPlugin/doc/images/Sphere1.png
new file mode 100644 (file)
index 0000000..87214a7
Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/Sphere1.png differ
diff --git a/src/PrimitivesPlugin/doc/images/Sphere2.png b/src/PrimitivesPlugin/doc/images/Sphere2.png
new file mode 100644 (file)
index 0000000..b2ad67a
Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/Sphere2.png differ
index fb13d34b0bd2fabae5d537415f0cae279ea97ae8..add03e29a5a0dbd6ee8459e52b14aac430aa87d8 100644 (file)
Binary files a/src/PrimitivesPlugin/doc/images/Sphere_button.png and b/src/PrimitivesPlugin/doc/images/Sphere_button.png differ
diff --git a/src/PrimitivesPlugin/doc/images/Sphere_full.png b/src/PrimitivesPlugin/doc/images/Sphere_full.png
new file mode 100644 (file)
index 0000000..4b5351b
Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/Sphere_full.png differ
diff --git a/src/PrimitivesPlugin/doc/images/Sphere_part.png b/src/PrimitivesPlugin/doc/images/Sphere_part.png
new file mode 100644 (file)
index 0000000..15007d6
Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/Sphere_part.png differ
diff --git a/src/PrimitivesPlugin/doc/images/Sphere_res.png b/src/PrimitivesPlugin/doc/images/Sphere_res.png
deleted file mode 100644 (file)
index 1ffba02..0000000
Binary files a/src/PrimitivesPlugin/doc/images/Sphere_res.png and /dev/null differ
diff --git a/src/PrimitivesPlugin/doc/images/Tube.png b/src/PrimitivesPlugin/doc/images/Tube.png
new file mode 100644 (file)
index 0000000..314d232
Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/Tube.png differ
diff --git a/src/PrimitivesPlugin/doc/images/Tube_button.png b/src/PrimitivesPlugin/doc/images/Tube_button.png
new file mode 100755 (executable)
index 0000000..26db05d
Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/Tube_button.png differ
diff --git a/src/PrimitivesPlugin/doc/images/Tube_res.png b/src/PrimitivesPlugin/doc/images/Tube_res.png
new file mode 100644 (file)
index 0000000..69adee6
Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/Tube_res.png differ
diff --git a/src/PrimitivesPlugin/doc/images/box.png b/src/PrimitivesPlugin/doc/images/box.png
deleted file mode 100644 (file)
index 2b0757b..0000000
Binary files a/src/PrimitivesPlugin/doc/images/box.png and /dev/null differ
diff --git a/src/PrimitivesPlugin/doc/images/box_pt_dxyz_32x32.png b/src/PrimitivesPlugin/doc/images/box_pt_dxyz_32x32.png
new file mode 100644 (file)
index 0000000..db199ea
Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/box_pt_dxyz_32x32.png differ
diff --git a/src/PrimitivesPlugin/doc/images/sphere_32x32.png b/src/PrimitivesPlugin/doc/images/sphere_32x32.png
new file mode 100644 (file)
index 0000000..18dc864
Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/sphere_32x32.png differ
diff --git a/src/PrimitivesPlugin/doc/images/sphere_part_32x32.png b/src/PrimitivesPlugin/doc/images/sphere_part_32x32.png
new file mode 100644 (file)
index 0000000..c74269a
Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/sphere_part_32x32.png differ
index 71688a99939f994305f033fbf35fdd7daae1706f..ade5249995db228ec0b9f30f485c9ade0e335482 100644 (file)
@@ -3,29 +3,46 @@
 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.
@@ -34,11 +51,52 @@ Input fields:
 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.
+   
+
+   
diff --git a/src/PrimitivesPlugin/doc/tubeFeature.rst b/src/PrimitivesPlugin/doc/tubeFeature.rst
new file mode 100644 (file)
index 0000000..feb2ac4
--- /dev/null
@@ -0,0 +1,46 @@
+.. |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.
diff --git a/src/PrimitivesPlugin/icons/box_pt_dxyz_32x32.png b/src/PrimitivesPlugin/icons/box_pt_dxyz_32x32.png
new file mode 100644 (file)
index 0000000..db199ea
Binary files /dev/null and b/src/PrimitivesPlugin/icons/box_pt_dxyz_32x32.png differ
index 000d658ab846ac9fdd66be422f6ad446f88c8c52..add03e29a5a0dbd6ee8459e52b14aac430aa87d8 100644 (file)
Binary files a/src/PrimitivesPlugin/icons/sphere.png and b/src/PrimitivesPlugin/icons/sphere.png differ
diff --git a/src/PrimitivesPlugin/icons/sphere_32x32.png b/src/PrimitivesPlugin/icons/sphere_32x32.png
new file mode 100755 (executable)
index 0000000..18dc864
Binary files /dev/null and b/src/PrimitivesPlugin/icons/sphere_32x32.png differ
diff --git a/src/PrimitivesPlugin/icons/sphere_part_32x32.png b/src/PrimitivesPlugin/icons/sphere_part_32x32.png
new file mode 100755 (executable)
index 0000000..c74269a
Binary files /dev/null and b/src/PrimitivesPlugin/icons/sphere_part_32x32.png differ
diff --git a/src/PrimitivesPlugin/icons/tube.png b/src/PrimitivesPlugin/icons/tube.png
new file mode 100755 (executable)
index 0000000..26db05d
Binary files /dev/null and b/src/PrimitivesPlugin/icons/tube.png differ
index f250b587e9cd95b2ecf4c16192284ada1e166f7a..f743fef211e6d05d204d8d647333b42fb9d3ea19 100644 (file)
         <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>
index d2f29ce1e1ea49c0b1d5d623992ba7e25f5a5eca..389d8c5bca84a928a2efd0522b83d809ebe91f12 100644 (file)
@@ -1,15 +1,65 @@
 <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>
diff --git a/src/PrimitivesPlugin/tube_widget.xml b/src/PrimitivesPlugin/tube_widget.xml
new file mode 100644 (file)
index 0000000..4fc4293
--- /dev/null
@@ -0,0 +1,26 @@
+<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>
index 6e2110eca9ac4a3a535ae2a524f77a2ac81f3807..3c2e749019f4e10feb2605a2b977532f376e596b 100644 (file)
@@ -19,4 +19,4 @@
 """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
index f4711ed19a03c2379459922d23cd2efd0050ee09..856192817fb487584c4bde84496b86068ee8ec75 100644 (file)
@@ -62,32 +62,32 @@ Box_8 = shaperpy.makeBox(pnt1,pnt2)
 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.")
index 7d228addc81d5e14e5ae60035a3558d04303469d..c3c58a2fe079eb153ae698e6e9297fafb5762904 100644 (file)
@@ -84,6 +84,7 @@ Box_15 = model.addBox(Part_1_doc, model.selection("VERTEX", "Sketch_1/SketchLine
 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()
 
@@ -126,6 +127,12 @@ model.testNbSubShapes(Box_18, GeomAPI_Shape.SOLID, [1])
 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.")
 
@@ -145,16 +152,16 @@ model.testNbResults(Box_7, 0)
 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.")
index 33782eadbffeb5e90ce94a85eea957ac2723c864..36a8208560d7b5fe0eac770092968271f04888eb 100644 (file)
@@ -41,6 +41,9 @@ Sphere_6 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin
 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()
 
@@ -71,6 +74,12 @@ model.testNbSubShapes(Sphere_7, GeomAPI_Shape.SOLID, [1])
 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.")
 
@@ -79,3 +88,6 @@ assert(Sphere_3.feature().error() == "Sphere builder :: radius is negative or nu
 
 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.")
diff --git a/test.API/SHAPER/Primitives/TestTube.py b/test.API/SHAPER/Primitives/TestTube.py
new file mode 100644 (file)
index 0000000..b170cc4
--- /dev/null
@@ -0,0 +1,66 @@
+# 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.")
index d3bd600bda0aae7aaee10bad66f402b78cfbe1bd..b36fa9d9d470f8a66e67d52e26fc807cc637f5ab 100644 (file)
@@ -23,6 +23,7 @@ SET(TEST_NAMES
   Primitives/TestCylinder.py
   Primitives/TestSphere.py
   Primitives/TestTorus.py
+  Primitives/TestTube.py
   Primitives/TestAPI_Box.py
   Primitives/TestAPI_Cone.py
   Primitives/TestAPI_Cylinder.py