Salome HOME
Adding the "Cylinder" primitive (the following).
authorClarisse Genrault <clarisse.genrault@cea.fr>
Fri, 13 Jan 2017 12:38:39 +0000 (13:38 +0100)
committerClarisse Genrault <clarisse.genrault@cea.fr>
Fri, 13 Jan 2017 12:38:39 +0000 (13:38 +0100)
19 files changed:
src/GeomAlgoAPI/CMakeLists.txt
src/GeomAlgoAPI/GeomAlgoAPI_Box.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Cylinder.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Cylinder.h
src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp
src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h
src/GeomAlgoAPI/Test/TestAPI_Cylinder.py [new file with mode: 0644]
src/PrimitivesAPI/PrimitivesAPI.i
src/PrimitivesAPI/PrimitivesAPI_Cylinder.cpp
src/PrimitivesAPI/PrimitivesAPI_Cylinder.h
src/PrimitivesAPI/Test/TestCylinder.py [new file with mode: 0644]
src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.cpp
src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.h
src/PrimitivesPlugin/icons/SVG/cylinder.svg [new file with mode: 0644]
src/PrimitivesPlugin/icons/SVG/cylinder_32x32.svg [new file with mode: 0644]
src/PrimitivesPlugin/icons/SVG/cylinder_portion_32x32.svg [new file with mode: 0644]
src/PrimitivesPlugin/icons/cylinder_32x32.png
src/PrimitivesPlugin/icons/cylinder_portion_32x32.png
src/PythonAPI/model/primitives/__init__.py

index aabc35d119c4f045f25bc666fe4fc718a1e70842..68048d8e9c858202525e6d5b11ee27653ba515eb 100644 (file)
@@ -159,6 +159,7 @@ INSTALL(TARGETS GeomAlgoAPI DESTINATION ${SHAPER_INSTALL_BIN})
 INSTALL(FILES ${SWIG_SCRIPTS} DESTINATION ${SHAPER_INSTALL_SWIG})
 
 ADD_UNIT_TESTS(TestAPI_Box.py
+               TestAPI_Cylinder.py
                TestAPI_GDMLConeSegment.py
                TestAPI_Symmetry.py
                TestAPI_Translation.py)
index 04c730e63aa78665198e998ddfcf8f5b88ab4175..97c13ddde1c6bedd5c3da86cc4645df0794d2f0c 100644 (file)
@@ -65,7 +65,7 @@ bool GeomAlgoAPI_Box::check()
     if (fabs(aDiffX)  < Precision::Confusion() ||
         fabs(aDiffY)  < Precision::Confusion() ||
         fabs(aDiffZ)  < Precision::Confusion()) {
-      myError = 
+      myError =
         "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes";
       return false;
     }
index 4ee724e50e60798fb092d570aa0756fc39467696..e487b6a5558a3b281d355d215b1f2e08b28cd6e4 100644 (file)
@@ -77,20 +77,21 @@ bool GeomAlgoAPI_Cylinder::check()
 void GeomAlgoAPI_Cylinder::build()
 {
   myCreatedFaces.clear();
-  
+
   const gp_Ax2& anAxis = myAxis->impl<gp_Ax2>();
-  
+
   // Construct the cylinder
   BRepPrimAPI_MakeCylinder *aCylinderMaker;
-  
+
   if (withAngle) {
-    aCylinderMaker = new  BRepPrimAPI_MakeCylinder(anAxis, myRadius, myHeight, myAngle * M_PI / 180.);
+    aCylinderMaker =
+      new BRepPrimAPI_MakeCylinder(anAxis, myRadius, myHeight, myAngle * M_PI / 180.);
   } else {
-    aCylinderMaker = new  BRepPrimAPI_MakeCylinder(anAxis, myRadius, myHeight);
+    aCylinderMaker = new BRepPrimAPI_MakeCylinder(anAxis, myRadius, myHeight);
   }
-  
+
   aCylinderMaker->Build();
-  
+
   if (!aCylinderMaker->IsDone()) {
     return;
   }
@@ -105,8 +106,8 @@ void GeomAlgoAPI_Cylinder::build()
     myError = "Cylinder builder :: resulting shape is null.";
     return;
   }
-  
+
   setImpl(aCylinderMaker);
-  
+
   setDone(true);
 }
index b0f91e27cd128f53239ee9bd2c0de069d6b6e875..6bffee998f60d582912ad8f012e919c31afc5089 100644 (file)
@@ -21,16 +21,15 @@ class GeomAlgoAPI_Cylinder : public GeomAlgoAPI_MakeShape
  public:
   GEOMALGOAPI_EXPORT GeomAlgoAPI_Cylinder();
 
-  /// Creates a cylinder
+  /// Creates a cylinder.
   /// \param theAxis The axis of the cylinder
   /// \param theRadius The radius of the cylinder
   /// \param theHeight The height of the cylinder
-  /// \param theAngle The covering angle of the cylinder
   GEOMALGOAPI_EXPORT GeomAlgoAPI_Cylinder(std::shared_ptr<GeomAPI_Ax2> theAxis,
                                           const double theRadius,
                                           const double theHeight);
 
-  /// Creates a cylinder
+  /// Creates a cylinder.
   /// \param theAxis The axis of the cylinder
   /// \param theRadius The radius of the cylinder
   /// \param theHeight The height of the cylinder
@@ -47,8 +46,8 @@ class GeomAlgoAPI_Cylinder : public GeomAlgoAPI_MakeShape
   GEOMALGOAPI_EXPORT void build();
 
  private:
-  bool withAngle;
-  std::shared_ptr<GeomAPI_Pnt> myBasePoint;
+  bool withAngle; /// Boolean indicating if the type of cylinder (full or portion).
+  std::shared_ptr<GeomAPI_Pnt> myBasePoint; /// Center of the lower base of the cylinder.
   std::shared_ptr<GeomAPI_Ax2> myAxis; /// Axis of the cylinder.
   double myRadius; /// Radius of the cylinder.
   double myHeight; /// Height of the cylinder.
index f738e5c41b59bcce2c192b26806b6d28816cdf6c..223517a4a2c3fb79f46c6dc68ace5de8770c29a1 100644 (file)
@@ -7,14 +7,17 @@
 #include "GeomAlgoAPI_ShapeAPI.h"
 
 #include <GeomAlgoAPI_Box.h>
+#include <GeomAlgoAPI_Cylinder.h>
 #include <GeomAlgoAPI_ConeSegment.h>
 #include <GeomAlgoAPI_EdgeBuilder.h>
 #include <GeomAlgoAPI_Symmetry.h>
 #include <GeomAlgoAPI_Translation.h>
 
+#include <GeomAPI_Lin.h>
+
 namespace GeomAlgoAPI_ShapeAPI
 {
-  //=======================================================================================
+  //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(
     const double theDx, const double theDy,
     const double theDz) throw (GeomAlgoAPI_Exception)
@@ -36,7 +39,7 @@ namespace GeomAlgoAPI_ShapeAPI
     return aBoxAlgo.shape();
   }
 
-  //======================================================================================
+  //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeBox(
     std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
     std::shared_ptr<GeomAPI_Pnt> theSecondPoint) throw (GeomAlgoAPI_Exception)
@@ -58,7 +61,115 @@ namespace GeomAlgoAPI_ShapeAPI
     return aBoxAlgo.shape();
   }
 
-  //=========================================================================================================
+  //===============================================================================================
+  std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
+    std::shared_ptr<GeomAPI_Pnt> theBasePoint, std::shared_ptr<GeomAPI_Edge> theEdge,
+    double theRadius, double theHeight) throw (GeomAlgoAPI_Exception)
+  {
+    std::shared_ptr<GeomAPI_Ax2> anAxis;
+    anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
+                                                          theEdge->line()->direction()));
+
+    GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight);
+
+    if (!aCylinderAlgo.check()) {
+      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
+    }
+
+    aCylinderAlgo.build();
+
+    if(!aCylinderAlgo.isDone()) {
+      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
+    }
+    if (!aCylinderAlgo.checkValid("Cylinder builder")) {
+      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
+    }
+    return aCylinderAlgo.shape();
+  }
+
+  //===============================================================================================
+  std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
+    std::shared_ptr<GeomAPI_Pnt> theBasePoint, std::shared_ptr<GeomAPI_Edge> theEdge,
+    double theRadius, double theHeight, double theAngle) throw (GeomAlgoAPI_Exception)
+  {
+    std::shared_ptr<GeomAPI_Ax2> anAxis;
+    anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
+                                                          theEdge->line()->direction()));
+
+    GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight, theAngle);
+
+    if (!aCylinderAlgo.check()) {
+      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
+    }
+
+    aCylinderAlgo.build();
+
+    if(!aCylinderAlgo.isDone()) {
+      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
+    }
+    if (!aCylinderAlgo.checkValid("Cylinder portion builder")) {
+      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
+    }
+    return aCylinderAlgo.shape();
+  }
+
+  //===============================================================================================
+  std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
+    double theRadius, double theHeight) throw (GeomAlgoAPI_Exception)
+  {
+    std::shared_ptr<GeomAPI_Pnt> aBasePoint =
+      std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
+    std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
+    std::shared_ptr<GeomAPI_Ax2> anAxis;
+    anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
+                                                          aEdge->line()->direction()));
+
+    GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight);
+
+    if (!aCylinderAlgo.check()) {
+      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
+    }
+
+    aCylinderAlgo.build();
+
+    if(!aCylinderAlgo.isDone()) {
+      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
+    }
+    if (!aCylinderAlgo.checkValid("Cylinder builder")) {
+      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
+    }
+    return aCylinderAlgo.shape();
+  }
+
+  //===============================================================================================
+  std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeCylinder(
+    double theRadius, double theHeight, double theAngle) throw (GeomAlgoAPI_Exception)
+  {
+    std::shared_ptr<GeomAPI_Pnt> aBasePoint =
+      std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(0.,0.,0.));
+    std::shared_ptr<GeomAPI_Edge> aEdge = GeomAlgoAPI_EdgeBuilder::line(0., 0., 1.);
+    std::shared_ptr<GeomAPI_Ax2> anAxis;
+    anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
+                                                          aEdge->line()->direction()));
+
+    GeomAlgoAPI_Cylinder aCylinderAlgo(anAxis, theRadius, theHeight, theAngle);
+
+    if (!aCylinderAlgo.check()) {
+      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
+    }
+
+    aCylinderAlgo.build();
+
+    if(!aCylinderAlgo.isDone()) {
+      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
+    }
+    if (!aCylinderAlgo.checkValid("Cylinder portion builder")) {
+      throw GeomAlgoAPI_Exception(aCylinderAlgo.getError());
+    }
+    return aCylinderAlgo.shape();
+  }
+
+  //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
     std::shared_ptr<GeomAPI_Ax1>   theAxis,
@@ -81,7 +192,7 @@ namespace GeomAlgoAPI_ShapeAPI
     return aTranslationAlgo.shape();
   }
 
-  //=========================================================================================================
+  //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
     const double theDx,
@@ -105,7 +216,7 @@ namespace GeomAlgoAPI_ShapeAPI
     return aTranslationAlgo.shape();
   }
 
-  //=========================================================================================================
+  //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
     std::shared_ptr<GeomAPI_Pnt>   theStartPoint,
@@ -128,7 +239,7 @@ namespace GeomAlgoAPI_ShapeAPI
     return aTranslationAlgo.shape();
   }
 
-  //=========================================================================================================
+  //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
     std::shared_ptr<GeomAPI_Pnt>   thePoint) throw (GeomAlgoAPI_Exception)
@@ -150,7 +261,7 @@ namespace GeomAlgoAPI_ShapeAPI
     return aSymmetryAlgo.shape();
   }
 
-  //=========================================================================================================
+  //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
     std::shared_ptr<GeomAPI_Ax1>   theAxis) throw (GeomAlgoAPI_Exception)
@@ -172,7 +283,7 @@ namespace GeomAlgoAPI_ShapeAPI
     return aSymmetryAlgo.shape();
   }
 
-  //=========================================================================================================
+  //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeSymmetry(
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
     std::shared_ptr<GeomAPI_Ax2>   thePlane) throw (GeomAlgoAPI_Exception)
@@ -194,7 +305,7 @@ namespace GeomAlgoAPI_ShapeAPI
     return aSymmetryAlgo.shape();
   }
 
-  //=========================================================================================================
+  //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeConeSegment(
     const double theRMin1, const double theRMax1,
     const double theRMin2, const double theRMax2,
index fbed6c1cc33c661397afc31507d25f08f3e60911..454f88495088cce9d0affde6df6d510bbea909e9 100644 (file)
@@ -39,10 +39,42 @@ public:
   static std::shared_ptr<GeomAPI_Shape> makeBox(std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
                      std::shared_ptr<GeomAPI_Pnt> theSecondPoint) throw (GeomAlgoAPI_Exception);
 
+  /// Creates a cylinder using a center, an axis, a radius and a height.
+  /// \param theBasePoint The center of the lower base of the cylinder
+  /// \param theEdge The axis of the cylinder
+  /// \param theRadius The radius of the cylinder
+  /// \param theHeight The heigth of the cylinder
+  static std::shared_ptr<GeomAPI_Shape> makeCylinder(std::shared_ptr<GeomAPI_Pnt> theBasePoint,
+                     std::shared_ptr<GeomAPI_Edge> theEdge, double theRadius, double theHeight)
+                     throw (GeomAlgoAPI_Exception);
+
+  /// Creates a portion of cylinder using a center, an axis, a radius, a height and an angle.
+  /// \param theBasePoint The center of the lower base of the cylinder
+  /// \param theEdge The axis of the cylinder
+  /// \param theRadius The radius of the cylinder
+  /// \param theHeight The heigth of the cylinder
+  /// \param theAngle The angle defining the portion
+  static std::shared_ptr<GeomAPI_Shape> makeCylinder(std::shared_ptr<GeomAPI_Pnt> theBasePoint,
+                     std::shared_ptr<GeomAPI_Edge> theEdge, double theRadius, double theHeight,
+                     double theAngle) throw (GeomAlgoAPI_Exception);
+
+  /// Creates a cylinder using the origin, the OZ axis, a radius and a height.
+  /// \param theRadius The radius of the cylinder
+  /// \param theHeight The heigth of the cylinder
+  static std::shared_ptr<GeomAPI_Shape> makeCylinder(double theRadius, double theHeight)
+                     throw (GeomAlgoAPI_Exception);
+
+  /// Creates a portion of cylinder using the origin, the OZ axis, a radius, a height and an angle.
+  /// \param theRadius The radius of the cylinder
+  /// \param theHeight The heigth of the cylinder
+  /// \param theAngle The angle defining the portion
+  static std::shared_ptr<GeomAPI_Shape> makeCylinder(double theRadius, double theHeight,
+                     double theAngle) throw (GeomAlgoAPI_Exception);
+
   /// Performs a translation from an axis and a distance.
-  /// \param theSourceShape Shape to be moved.
-  /// \param theAxis Movement axis.
-  /// \param theDistance Movement distance.
+  /// \param theSourceShape Shape to be moved
+  /// \param theAxis Movement axis
+  /// \param theDistance Movement distance
   /// \return a shape
   static std::shared_ptr<GeomAPI_Shape> makeTranslation(
                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
@@ -50,10 +82,10 @@ public:
                      const double theDistance) throw (GeomAlgoAPI_Exception);
 
   /// Performs a translation from dimensions.
-  /// \param theSourceShape Shape to be moved.
-  /// \param theDx Movement dimension on X.
-  /// \param theDy Movement dimension on Y.
-  /// \param theDz Movement dimension on Z.
+  /// \param theSourceShape Shape to be moved
+  /// \param theDx Movement dimension on X
+  /// \param theDy Movement dimension on Y
+  /// \param theDz Movement dimension on Z
   /// \return a shape
   static std::shared_ptr<GeomAPI_Shape> makeTranslation(
                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
@@ -62,31 +94,37 @@ public:
                      const double theDz) throw (GeomAlgoAPI_Exception);
 
   /// Performs a translation from two points.
-  /// \param theSourceShape Shape to be moved.
-  /// \param theStartPoint Movement start point.
-  /// \param theEndPoint Movement end point.
+  /// \param theSourceShape Shape to be moved
+  /// \param theStartPoint Movement start point
+  /// \param theEndPoint Movement end point
   /// \return a shape
   static std::shared_ptr<GeomAPI_Shape> makeTranslation(
                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
                      std::shared_ptr<GeomAPI_Pnt>   theStartPoint,
                      std::shared_ptr<GeomAPI_Pnt>   theEndPoint) throw (GeomAlgoAPI_Exception);
 
-  /// Performs a symmetry by a point
+  /// Performs a symmetry by a point.
+  /// \param theSourceShape Shape be symmetrized
+  /// \param thePoint Point of symmetry
   static std::shared_ptr<GeomAPI_Shape> makeSymmetry(
                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
                      std::shared_ptr<GeomAPI_Pnt>   thePoint) throw (GeomAlgoAPI_Exception);
 
-  /// Performs a symmetry by an axis
+  /// Performs a symmetry by an axis.
+  /// \param theSourceShape Shape be symmetrized
+  /// \param theAxis Axis of symmetry
   static std::shared_ptr<GeomAPI_Shape> makeSymmetry(
                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
                      std::shared_ptr<GeomAPI_Ax1>   theAxis) throw (GeomAlgoAPI_Exception);
 
-  /// Performs a symmetry by a plane
+  /// Performs a symmetry by a plane.
+  /// \param theSourceShape Shape be symmetrized
+  /// \param thePlane Plane of symmetry
   static std::shared_ptr<GeomAPI_Shape> makeSymmetry(
                      std::shared_ptr<GeomAPI_Shape> theSourceShape,
                      std::shared_ptr<GeomAPI_Ax2>   thePlane) throw (GeomAlgoAPI_Exception);
 
-  /// Creates a cone segment using standard GDML parameters
+  /// Creates a cone segment using standard GDML parameters.
   /// \param theRMin1 Inner radius at base of cone
   /// \param theRMax1 Outer radius at base of cone
   /// \param theRMin2 Inner radius at top of cone
diff --git a/src/GeomAlgoAPI/Test/TestAPI_Cylinder.py b/src/GeomAlgoAPI/Test/TestAPI_Cylinder.py
new file mode 100644 (file)
index 0000000..50a4b87
--- /dev/null
@@ -0,0 +1,41 @@
+# Copyright (C) 2014-201x CEA/DEN, EDF R&D
+
+# File:        TestAPI_Cylinder.py
+# Created:     13 Jan 2017
+# Author:      Clarisse Genrault (CEA)
+
+from GeomAlgoAPI import GeomAlgoAPI_ShapeAPI as shaperpy
+from GeomAlgoAPI import GeomAlgoAPI_Exception as myExcept
+from GeomAlgoAPI import GeomAlgoAPI_EdgeBuilder as edgeBuilder
+from GeomAPI import GeomAPI_Pnt as pnt
+
+aPoint = pnt(10.,5.,0.)
+anEdge = edgeBuilder.line(1.,0.,0.)
+
+# Create a cylinder
+try :    
+  cylinder1 = shaperpy.makeCylinder(5., 20.)
+  
+except myExcept,ec:
+  print ec.what()
+
+# Create a cylinder
+try :    
+  cylinder2 = shaperpy.makeCylinder(5., 20., 100.)
+  
+except myExcept,ec:
+  print ec.what()
+  
+# Create a cylinder
+try :
+  cylinder3 = shaperpy.makeCylinder(aPoint, anEdge, 5., 20.)
+  
+except myExcept,ec:
+  print ec.what()
+  
+# Create a cylinder
+try :
+  cylinder4 = shaperpy.makeCylinder(aPoint, anEdge, 5., 20., 180.)
+  
+except myExcept,ec:
+  print ec.what()
\ No newline at end of file
index 28b92e23556247fe7041ec08eacacc94152dab5a..3bea92c00cbcb795e1951d631e9cfb76e18db71a 100644 (file)
@@ -20,7 +20,7 @@
 
 // shared pointers
 %shared_ptr(PrimitivesAPI_Box)
- %shared_ptr(PrimitivesAPI_Cylinder)
+%shared_ptr(PrimitivesAPI_Cylinder)
 
 // all supported interfaces
 %include "PrimitivesAPI_Box.h"
index 42c10aed1f8f4ea718893bccf57f4646b2321705..debf4b0541fe06fbb6e3364ec746ef188a5589dd 100644 (file)
@@ -1,8 +1,8 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
 
-// File:        PrimitivesAPI_Cylinder.h
+// File:        PrimitivesAPI_Cylinder.cpp
 // Created:     12 Jan 2017
-// Author:      Clarisse Genrault (CEA)
+// Author:      Clarisse Genrault
 
 #include "PrimitivesAPI_Cylinder.h"
 
@@ -19,44 +19,40 @@ PrimitivesAPI_Cylinder::PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Fe
 
 //==================================================================================================
 PrimitivesAPI_Cylinder::PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                                               const ModelHighAPI_Selection& theBasePoint,
-                                               const ModelHighAPI_Selection& theAxis,
-                                               const ModelHighAPI_Double& theRadius,
-                                               const ModelHighAPI_Double& theHeight)
+                                     const ModelHighAPI_Selection& theBasePoint,
+                                  const ModelHighAPI_Selection& theAxis,
+                                  const ModelHighAPI_Double& theRadius,
+                                  const ModelHighAPI_Double& theHeight)
 : ModelHighAPI_Interface(theFeature)
 {
   if (initialize()) {
-    fillAttribute(PrimitivesPlugin_Cylinder::CREATION_METHOD_CYLINDER(), creationMethod());
-    setObjects(theBasePoint, theAxis);
+    fillAttribute(theBasePoint, basePoint());
+    fillAttribute(theAxis, axis());
     setSizes(theRadius, theHeight);
   }
 }
 
 //==================================================================================================
 PrimitivesAPI_Cylinder::PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                                               const ModelHighAPI_Selection& theBasePoint,
-                                               const ModelHighAPI_Selection& theAxis,
-                                               const ModelHighAPI_Double& theRadius,
-                                               const ModelHighAPI_Double& theHeight,
-                                               const ModelHighAPI_Double& theAngle)
+                                     const ModelHighAPI_Selection& theBasePoint,
+                                  const ModelHighAPI_Selection& theAxis,
+                                  const ModelHighAPI_Double& theRadius,
+                                  const ModelHighAPI_Double& theHeight,
+                                  const ModelHighAPI_Double& theAngle)
 : ModelHighAPI_Interface(theFeature)
 {
   if (initialize()) {
-    fillAttribute(PrimitivesPlugin_Cylinder::CREATION_METHOD_CYLINDER_PORTION(), creationMethod());
-    setObjects(theBasePoint, theAxis);
+    fillAttribute(theBasePoint, basePoint());
+    fillAttribute(theAxis, axis());
+    fillAttribute(theAngle, angle());
     setSizes(theRadius, theHeight);
-    setAngle(theAngle);
   }
 }
 
 //==================================================================================================
-void PrimitivesAPI_Cylinder::setObjects(const ModelHighAPI_Selection& theBasePoint,
-                                        const ModelHighAPI_Selection& theAxis)
+PrimitivesAPI_Cylinder::~PrimitivesAPI_Cylinder()
 {
-  fillAttribute(theBasePoint, basePoint());
-  fillAttribute(theAxis, axis());
 
-  execute();
 }
 
 //==================================================================================================
@@ -65,15 +61,6 @@ void PrimitivesAPI_Cylinder::setSizes(const ModelHighAPI_Double& theRadius,
 {
   fillAttribute(theRadius, radius());
   fillAttribute(theHeight, height());
-
-  execute();
-}
-
-//==================================================================================================
-void PrimitivesAPI_Cylinder::setAngle(const ModelHighAPI_Double& theAngle)
-{
-  fillAttribute(theAngle, angle());
-
   execute();
 }
 
@@ -85,17 +72,18 @@ void PrimitivesAPI_Cylinder::dump(ModelHighAPI_Dumper& theDumper) const
 
   theDumper << aBase << " = model.addCylinder(" << aDocName;
 
-  std::string aCreationMethod = aBase->string(PrimitivesPlugin_Cylinder::CREATION_METHOD())->value();
-  
   AttributeSelectionPtr anAttrBasePoint =
     aBase->selection(PrimitivesPlugin_Cylinder::BASE_POINT_ID());
   AttributeSelectionPtr anAttrAxis = aBase->selection(PrimitivesPlugin_Cylinder::AXIS_ID());
+  theDumper << ", " << anAttrBasePoint << ", " << anAttrAxis;
+
   AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Cylinder::RADIUS_ID());
   AttributeDoublePtr anAttrHeight = aBase->real(PrimitivesPlugin_Cylinder::HEIGHT_ID());
-  
-  theDumper << ", " << anAttrBasePoint << ", " << anAttrAxis;
   theDumper << ", " << anAttrRadius << ", " << anAttrHeight;
-  
+
+  std::string aCreationMethod =
+    aBase->string(PrimitivesPlugin_Cylinder::CREATION_METHOD())->value();
+
   if (aCreationMethod == PrimitivesPlugin_Cylinder::CREATION_METHOD_CYLINDER_PORTION()) {
     AttributeDoublePtr anAttrAngle = aBase->real(PrimitivesPlugin_Cylinder::ANGLE_ID());
     theDumper << ", " << anAttrAngle;
@@ -109,12 +97,11 @@ CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
                         const ModelHighAPI_Selection& theBasePoint,
                         const ModelHighAPI_Selection& theAxis,
                         const ModelHighAPI_Double& theRadius,
-                        const ModelHighAPI_Double& theHeight,
-                        const ModelHighAPI_Double& theAngle)
+                        const ModelHighAPI_Double& theHeight)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
   return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, theBasePoint, theAxis,
-                                                theRadius, theHeight, theAngle));
+                                                theRadius, theHeight));
 }
 
 //==================================================================================================
@@ -122,34 +109,35 @@ CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
                         const ModelHighAPI_Selection& theBasePoint,
                         const ModelHighAPI_Selection& theAxis,
                         const ModelHighAPI_Double& theRadius,
-                        const ModelHighAPI_Double& theHeight)
+                        const ModelHighAPI_Double& theHeight,
+                        const ModelHighAPI_Double& theAngle)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
   return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, theBasePoint, theAxis,
-                                                theRadius, theHeight));
+                                                theRadius, theHeight, theAngle));
 }
 
 //==================================================================================================
 CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
                         const ModelHighAPI_Double& theRadius,
-                        const ModelHighAPI_Double& theHeight,
-                        const ModelHighAPI_Double& theAngle)
+                        const ModelHighAPI_Double& theHeight)
 {
-  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
   ModelHighAPI_Selection aBasePoint("VERT", "Origin");
   ModelHighAPI_Selection anAxis("EDGE", "OZ");
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
   return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, aBasePoint, anAxis,
-                                                theRadius, theHeight, theAngle));
+                                                theRadius, theHeight));
 }
 
 //==================================================================================================
 CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
                         const ModelHighAPI_Double& theRadius,
-                        const ModelHighAPI_Double& theHeight)
+                        const ModelHighAPI_Double& theHeight,
+                        const ModelHighAPI_Double& theAngle)
 {
-  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
   ModelHighAPI_Selection aBasePoint("VERT", "Origin");
   ModelHighAPI_Selection anAxis("EDGE", "OZ");
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
   return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, aBasePoint, anAxis,
                                                 theRadius, theHeight));
 }
\ No newline at end of file
index 3e16d41c8b812ae3fc0ff8b4905ce119ed9020b0..3d473798b610d11ee24b26d74b201901348a19f8 100644 (file)
@@ -1,8 +1,8 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
 
 // File:        PrimitivesAPI_Cylinder.h
 // Created:     12 Jan 2017
-// Author:      Clarisse Genrault (CEA)
+// Author:      Clarisse Genrault
 
 #ifndef PRIMITIVESAPI_CYLINDER_H_
 #define PRIMITIVESAPI_CYLINDER_H_
@@ -17,9 +17,9 @@
 class ModelHighAPI_Double;
 class ModelHighAPI_Selection;
 
-/// \class PrimitivesAPI_Cylinder
+/// \class PrimitivesAPI_Box
 /// \ingroup CPPHighAPI
-/// \brief Interface for primitive Cylinder feature.
+/// \brief Interface for primitive Box feature.
 class PrimitivesAPI_Cylinder: public ModelHighAPI_Interface
 {
 public:
@@ -27,6 +27,13 @@ public:
   PRIMITIVESAPI_EXPORT
   explicit PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Feature>& theFeature);
 
+  /// Constructor with values.
+  /*PRIMITIVESAPI_EXPORT
+  explicit PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                             const ModelHighAPI_Double& theDx,
+                             const ModelHighAPI_Double& theDy,
+                             const ModelHighAPI_Double& theDz);*/
+
   /// Constructor with values.
   PRIMITIVESAPI_EXPORT
   explicit PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Feature>& theFeature,
@@ -34,6 +41,8 @@ public:
                                   const ModelHighAPI_Selection& theAxis,
                                   const ModelHighAPI_Double& theRadius,
                                   const ModelHighAPI_Double& theHeight);
+
+  /// Constructor with values.
   PRIMITIVESAPI_EXPORT
   explicit PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                                   const ModelHighAPI_Selection& theBasePoint,
@@ -42,44 +51,29 @@ public:
                                   const ModelHighAPI_Double& theHeight,
                                   const ModelHighAPI_Double& theAngle);
 
-  /// Constructor with values.
-  /*PRIMITIVESAPI_EXPORT
-  explicit PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                                  const ModelHighAPI_Selection& theFirstPoint,
-                                  const ModelHighAPI_Selection& theSecondPoint);*/
-
   /// Destructor.
   PRIMITIVESAPI_EXPORT
   virtual ~PrimitivesAPI_Cylinder();
 
   INTERFACE_6(PrimitivesPlugin_Cylinder::ID(),
-              creationMethod, PrimitivesPlugin_Cylinder::CREATION_METHOD(),
-              ModelAPI_AttributeString, /** Creation method */,
-              basePoint, PrimitivesPlugin_Cylinder::BASE_POINT_ID(),
-              ModelAPI_AttributeSelection, /** Base point */,
-              axis, PrimitivesPlugin_Cylinder::AXIS_ID(),
-              ModelAPI_AttributeSelection, /** Axis */,
-              radius, PrimitivesPlugin_Cylinder::RADIUS_ID(),
-              ModelAPI_AttributeDouble, /** Radius */,
-              height, PrimitivesPlugin_Cylinder::HEIGHT_ID(),
-              ModelAPI_AttributeDouble, /** Height */,
-              angle, PrimitivesPlugin_Cylinder::ANGLE_ID(),
-              ModelAPI_AttributeDouble, /** Angle */)
-  
-  /// Set base point and axis
-  PRIMITIVESAPI_EXPORT
-  void setObjects(const ModelHighAPI_Selection& theBasePoint,
-                  const ModelHighAPI_Selection& theAxis);
-
-  /// Set radius and height
+             creationMethod, PrimitivesPlugin_Cylinder::CREATION_METHOD(),
+             ModelAPI_AttributeString, /** Creation method */,
+             basePoint, PrimitivesPlugin_Cylinder::BASE_POINT_ID(),
+             ModelAPI_AttributeSelection, /** Dimension in X */,
+             axis, PrimitivesPlugin_Cylinder::AXIS_ID(),
+             ModelAPI_AttributeSelection, /** Dimension in Y */,
+             radius, PrimitivesPlugin_Cylinder::RADIUS_ID(),
+             ModelAPI_AttributeDouble, /** Dimension in Z */,
+             height, PrimitivesPlugin_Cylinder::HEIGHT_ID(),
+             ModelAPI_AttributeDouble, /** First point */,
+             angle, PrimitivesPlugin_Cylinder::ANGLE_ID(),
+             ModelAPI_AttributeDouble, /** Second point */)
+
+  /// Set dimensions
   PRIMITIVESAPI_EXPORT
   void setSizes(const ModelHighAPI_Double& theRadius,
                 const ModelHighAPI_Double& theHeight);
 
-  /// Set angle
-  PRIMITIVESAPI_EXPORT
-  void setAngle(const ModelHighAPI_Double& theAngle);
-
   /// Dump wrapped feature
   PRIMITIVESAPI_EXPORT
   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
@@ -89,36 +83,37 @@ public:
 typedef std::shared_ptr<PrimitivesAPI_Cylinder> CylinderPtr;
 
 /// \ingroup CPPHighAPI
-/// \brief Create primitive Cylinder feature.
+/// \brief Create primitive Box feature.
 PRIMITIVESAPI_EXPORT
 CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
                         const ModelHighAPI_Selection& theBasePoint,
                         const ModelHighAPI_Selection& theAxis,
                         const ModelHighAPI_Double& theRadius,
-                        const ModelHighAPI_Double& theHeight,
-                        const ModelHighAPI_Double& theAngle);
+                        const ModelHighAPI_Double& theHeight);
 
 /// \ingroup CPPHighAPI
-/// \brief Create primitive Cylinder feature.
+/// \brief Create primitive Box feature.
 PRIMITIVESAPI_EXPORT
 CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
                         const ModelHighAPI_Selection& theBasePoint,
                         const ModelHighAPI_Selection& theAxis,
                         const ModelHighAPI_Double& theRadius,
-                        const ModelHighAPI_Double& theHeight);
+                        const ModelHighAPI_Double& theHeight,
+                        const ModelHighAPI_Double& theAngle);
+
 /// \ingroup CPPHighAPI
-/// \brief Create primitive Cylinder feature.
+/// \brief Create primitive Box feature.
 PRIMITIVESAPI_EXPORT
 CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
                         const ModelHighAPI_Double& theRadius,
-                        const ModelHighAPI_Double& theHeight,
-                        const ModelHighAPI_Double& theAngle);
+                        const ModelHighAPI_Double& theHeight);
 
 /// \ingroup CPPHighAPI
-/// \brief Create primitive Cylinder feature.
+/// \brief Create primitive Box feature.
 PRIMITIVESAPI_EXPORT
 CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
                         const ModelHighAPI_Double& theRadius,
-                        const ModelHighAPI_Double& theHeight);
+                        const ModelHighAPI_Double& theHeight,
+                        const ModelHighAPI_Double& theAngle);
 
 #endif // PRIMITIVESAPI_CYLINDER_H_
\ No newline at end of file
diff --git a/src/PrimitivesAPI/Test/TestCylinder.py b/src/PrimitivesAPI/Test/TestCylinder.py
new file mode 100644 (file)
index 0000000..38e6d26
--- /dev/null
@@ -0,0 +1,44 @@
+"""
+Test case for Primitive Cylinder feature. 
+Written on High API.
+"""
+from ModelAPI import *
+from GeomAPI import *
+
+from salome.shaper import model
+
+# Get session
+aSession = ModelAPI_Session.get()
+
+# Create a part
+aDocument = aSession.activeDocument()
+aSession.startOperation()
+model.addPart(aDocument)
+aDocument = aSession.activeDocument()
+aSession.finishOperation()
+
+aSession.startOperation()
+aBasePoint = model.addPoint(aDocument, 0, 0, 0).result()
+anAxis = model.addAxis(aDocument, 10, 0, 0).result()
+aSession.finishOperation()
+
+aSession.startOperation()
+aCylinder1 = model.addCylinder(aDocument, aBasePoint, anAxis, 5., 20.)
+assert (aCylinder1 is not None)
+aSession.finishOperation()
+
+aSession.startOperation()
+aCylinder2 = model.addCylinder(aDocument, aBasePoint, anAxis, 5., 20., 100.)
+assert (aCylinder2 is not None)
+aSession.finishOperation()
+
+aSession.startOperation()
+aCylinder3 = model.addCylinder(aDocument, 5., 20.)
+assert (aCylinder3 is not None)
+aSession.finishOperation()
+
+aSession.startOperation()
+aCylinder4 = model.addCylinder(aDocument, 5., 20., 100.)
+assert (aCylinder4 is not None)
+aSession.finishOperation()
+
index fd336ae8bfe73efce1fb3ca3b47887b11629a426..63236482bb97af00fc59b730ffed008dc4997eb4 100644 (file)
@@ -31,19 +31,19 @@ void PrimitivesPlugin_Cylinder::initAttributes()
 {
   data()->addAttribute(PrimitivesPlugin_Cylinder::CREATION_METHOD(),
                        ModelAPI_AttributeString::typeId());
-  
+
   data()->addAttribute(PrimitivesPlugin_Cylinder::BASE_POINT_ID(),
                        ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(PrimitivesPlugin_Cylinder::AXIS_ID(),
                        ModelAPI_AttributeSelection::typeId());
-  
+
   data()->addAttribute(PrimitivesPlugin_Cylinder::RADIUS_ID(),
                        ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(PrimitivesPlugin_Cylinder::HEIGHT_ID(),
                        ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(PrimitivesPlugin_Cylinder::ANGLE_ID(),
                        ModelAPI_AttributeDouble::typeId());
-  
+
   // Initialize the base point of the cylinder at the origin if the base point is not filled.
   AttributeSelectionPtr aBasePoint = data()->selection(BASE_POINT_ID());
   if (!aBasePoint->isInitialized()) {
@@ -54,10 +54,10 @@ void PrimitivesPlugin_Cylinder::initAttributes()
       aBasePoint->setValue(aPointRes, std::shared_ptr<GeomAPI_Shape>());
     }
   }
-  
+
   // Initialize the axis at the OZ axis if the axis is not filled.
   AttributeSelectionPtr anAxis = data()->selection(AXIS_ID());
-  if (!anAxis->isInitialized()) { 
+  if (!anAxis->isInitialized()) {
     ObjectPtr anAxisObj = ModelAPI_Session::get()->moduleDocument()
       ->objectByName(ModelAPI_ResultConstruction::group(), "OZ");
     if (anAxisObj.get()) {
@@ -98,7 +98,7 @@ void PrimitivesPlugin_Cylinder::createCylinder(bool withAngle)
       aBasePoint = GeomAlgoAPI_PointBuilder::point(aShape1);
     }
   }
+
   // Getting axis.
   std::shared_ptr<GeomAPI_Ax2> anAxis;
   std::shared_ptr<GeomAPI_Edge> anEdge;
@@ -114,21 +114,21 @@ void PrimitivesPlugin_Cylinder::createCylinder(bool withAngle)
     anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(aBasePoint,
                                                           anEdge->line()->direction()));
   }
-  
+
   // Getting radius and height
   double aRadius = real(PrimitivesPlugin_Cylinder::RADIUS_ID())->value();
   double aHeight = real(PrimitivesPlugin_Cylinder::HEIGHT_ID())->value();
-  
+
   std::shared_ptr<GeomAlgoAPI_Cylinder> aCylinderAlgo;
   if (withAngle) {
     // Getting angle
     double anAngle = real(PrimitivesPlugin_Cylinder::ANGLE_ID())->value();
-    aCylinderAlgo = 
+    aCylinderAlgo =
       std::shared_ptr<GeomAlgoAPI_Cylinder>(new GeomAlgoAPI_Cylinder(anAxis,
                                                                      aRadius, aHeight,
                                                                      anAngle));
   } else {
-    aCylinderAlgo = 
+    aCylinderAlgo =
       std::shared_ptr<GeomAlgoAPI_Cylinder>(new GeomAlgoAPI_Cylinder(anAxis,
                                                                      aRadius, aHeight));
   }
@@ -165,7 +165,6 @@ void PrimitivesPlugin_Cylinder::createCylinder(bool withAngle)
 void PrimitivesPlugin_Cylinder::loadNamingDS(std::shared_ptr<GeomAlgoAPI_Cylinder> theCylinderAlgo,
                                              std::shared_ptr<ModelAPI_ResultBody> theResultCylinder)
 {
-  
   // Load the result
   theResultCylinder->store(theCylinderAlgo->shape());
 
index 1f3dce27c0bf20c010ec6be8eb66c46b6acabf6d..250bf881b6771d93699d6f5cdc4ac8a026cfac24 100644 (file)
@@ -37,14 +37,14 @@ class PrimitivesPlugin_Cylinder : public ModelAPI_Feature
     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_CYLINDER()
   {
     static const std::string MY_CREATION_METHOD_ID("Cylinder");
     return MY_CREATION_METHOD_ID;
   }
-  
+
   /// Attribute name for creation method
   inline static const std::string& CREATION_METHOD_CYLINDER_PORTION()
   {
diff --git a/src/PrimitivesPlugin/icons/SVG/cylinder.svg b/src/PrimitivesPlugin/icons/SVG/cylinder.svg
new file mode 100644 (file)
index 0000000..e6365bd
--- /dev/null
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="16"
+   height="16"
+   id="svg3352"
+   version="1.1"
+   inkscape:version="0.91 r13725"
+   viewBox="0 0 16 16"
+   sodipodi:docname="cylinder.svg"
+   inkscape:export-filename="/export/home/ldigallo/DOC_ALYOTECH/icones/Primitives/cylinder.png"
+   inkscape:export-xdpi="90"
+   inkscape:export-ydpi="90">
+  <defs
+     id="defs3354">
+    <linearGradient
+       id="linearGradient4223"
+       osb:paint="solid">
+      <stop
+         style="stop-color:#000000;stop-opacity:1;"
+         offset="0"
+         id="stop4225" />
+    </linearGradient>
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="31.672166"
+     inkscape:cx="16.392822"
+     inkscape:cy="11.031694"
+     inkscape:current-layer="layer1"
+     showgrid="true"
+     inkscape:grid-bbox="true"
+     inkscape:document-units="px"
+     showguides="true"
+     inkscape:window-width="1920"
+     inkscape:window-height="1006"
+     inkscape:window-x="0"
+     inkscape:window-y="25"
+     inkscape:window-maximized="1"
+     inkscape:showpageshadow="false">
+    <inkscape:grid
+       type="xygrid"
+       id="grid3398" />
+  </sodipodi:namedview>
+  <metadata
+     id="metadata3357">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     id="layer1"
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer"
+     transform="translate(0,-16)">
+    <g
+       id="g4142"
+       transform="matrix(0.50611145,0,0,0.50611145,-0.09985814,15.941804)">
+      <g
+         transform="matrix(1.337139,0,0,1.0393351,-4.0398283,-0.85518679)"
+         id="g4141">
+        <path
+           style="fill:none;fill-rule:evenodd;stroke:#1b4955;stroke-width:4;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+           d="m 7.9776742,6.1069675 0,20.0000005"
+           id="path3400"
+           inkscape:connector-curvature="0" />
+        <path
+           style="fill:none;fill-rule:evenodd;stroke:#1b4955;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+           d="m 21.977674,5.9730127 0,20.0000003"
+           id="path3402"
+           inkscape:connector-curvature="0" />
+        <path
+           style="fill:none;fill-opacity:1;stroke:#1b4955;stroke-width:4;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+           id="path3404-3"
+           sodipodi:type="arc"
+           sodipodi:cx="14.977674"
+           sodipodi:cy="26.080961"
+           sodipodi:rx="7"
+           sodipodi:ry="3.1079483"
+           sodipodi:start="6.1688662"
+           sodipodi:end="3.1989972"
+           d="m 21.931982,25.726437 a 7,3.1079483 0 0 1 -3.11418,2.953054 7,3.1079483 0 0 1 -7.341119,0.09278 7,3.1079483 0 0 1 -3.4874791,-2.869621"
+           sodipodi:open="true" />
+        <ellipse
+           style="fill:#b7d9ea;fill-opacity:1;stroke:#1b4955;stroke-width:4;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+           id="path3404-3-0-9"
+           transform="scale(1,-1)"
+           cx="14.981355"
+           cy="-6.1497636"
+           rx="7"
+           ry="3.1079483" />
+        <path
+           style="fill:#b7d9ea;fill-opacity:1;stroke:#b7d9ea;stroke-width:0.12629385;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+           d="M 13.38883,28.075268 C 11.624221,27.87219 10.037848,27.303122 9.3391283,26.622548 l -0.3074363,-0.299452 0,-8.648097 0,-8.6480963 0.5525356,0.2379569 c 3.0800834,1.3264784 7.6875904,1.3533244 10.6337444,0.061957 0.324842,-0.1423858 0.626142,-0.2743649 0.669555,-0.2932868 0.06293,-0.027428 0.07889,1.7050652 0.0787,8.5445472 -2.53e-4,8.294429 -0.0042,8.585428 -0.119319,8.774236 -0.47948,0.7863 -2.286639,1.49933 -4.377175,1.727049 -0.710171,0.07736 -2.392563,0.07512 -3.080901,-0.0041 z"
+           id="path4145"
+           inkscape:connector-curvature="0" />
+      </g>
+    </g>
+  </g>
+</svg>
diff --git a/src/PrimitivesPlugin/icons/SVG/cylinder_32x32.svg b/src/PrimitivesPlugin/icons/SVG/cylinder_32x32.svg
new file mode 100644 (file)
index 0000000..5800784
--- /dev/null
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="32"
+   height="32"
+   id="svg3352"
+   version="1.1"
+   inkscape:version="0.48.4 r9939"
+   viewBox="0 0 32 32"
+   sodipodi:docname="cylinder_32x32_cla.svg"
+   inkscape:export-filename="/export/home/cgenraul/SHAPER-CEA-FD20_64/INSTALL/SHAPER/share/salome/resources/shaper/icons/Primitives/cylinder_32x32.png"
+   inkscape:export-xdpi="90"
+   inkscape:export-ydpi="90">
+  <defs
+     id="defs3354">
+    <linearGradient
+       id="linearGradient4223"
+       osb:paint="solid">
+      <stop
+         style="stop-color:#000000;stop-opacity:1;"
+         offset="0"
+         id="stop4225" />
+    </linearGradient>
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="15.836083"
+     inkscape:cx="10.55697"
+     inkscape:cy="19.400616"
+     inkscape:current-layer="layer1"
+     showgrid="true"
+     inkscape:grid-bbox="true"
+     inkscape:document-units="px"
+     showguides="true"
+     inkscape:window-width="1920"
+     inkscape:window-height="1110"
+     inkscape:window-x="-2"
+     inkscape:window-y="32"
+     inkscape:window-maximized="1"
+     showborder="true"
+     inkscape:showpageshadow="false">
+    <inkscape:grid
+       type="xygrid"
+       id="grid3398"
+       empspacing="5"
+       visible="true"
+       enabled="true"
+       snapvisiblegridlinesonly="true" />
+  </sodipodi:namedview>
+  <metadata
+     id="metadata3357">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     id="layer1"
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer">
+    <path
+       style="fill:#b7d9ea;fill-opacity:1;stroke:#b7d9ea;stroke-width:0.18526213;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       d="M 13.182776,29.487897 C 9.8774461,29.254602 6.9059739,28.600862 5.5971891,27.819018 l -0.575868,-0.344006 0,-9.934896 0,-9.9348943 1.0349683,0.2733641 C 11.82566,9.4024394 20.456092,9.4332793 25.974601,7.9497624 26.583072,7.7861867 27.14744,7.6345711 27.228758,7.6128329 c 0.117871,-0.0315 0.147774,1.9587736 0.147427,9.8159421 -4.75e-4,9.5286 -0.0079,9.862898 -0.223499,10.079799 -0.898127,0.903301 -4.283156,1.722424 -8.198987,1.984027 -1.33024,0.08889 -4.481566,0.08633 -5.770907,-0.0048 z"
+       id="path4145"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:none;stroke:#1b4955;stroke-width:1.20723967;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       id="path3404-3"
+       sodipodi:type="arc"
+       sodipodi:cx="14.977674"
+       sodipodi:cy="26.080961"
+       sodipodi:rx="7"
+       sodipodi:ry="3.1079483"
+       sodipodi:start="6.1688662"
+       sodipodi:end="9.4821825"
+       d="M 21.931982,25.726437 A 7,3.1079483 0 1 1 7.9892038,25.902649"
+       sodipodi:open="true"
+       transform="matrix(1.658174,0,0,1.6551711,-8.8162043,-18.273731)" />
+    <path
+       style="fill:none;stroke:#1b4955;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       d="m 27.59775,6.7001261 0,18.1037449"
+       id="path3402"
+       inkscape:connector-curvature="0" />
+    <ellipse
+       style="fill:#b7d9ea;fill-opacity:1;stroke:#1b4955;stroke-width:1.46138835;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       id="path3404-3-0-9"
+       transform="matrix(1.6451704,0,0,-1.4676935,-8.6236034,-2.4341761)"
+       cx="14.981355"
+       cy="-6.1497636"
+       rx="7"
+       ry="3.1079483"
+       sodipodi:cx="14.981355"
+       sodipodi:cy="-6.1497636"
+       sodipodi:rx="7"
+       sodipodi:ry="3.1079483" />
+    <path
+       style="fill:none;stroke:#1b4955;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       d="m 4.3782992,6.1071278 0,18.6104482"
+       id="path3400"
+       inkscape:connector-curvature="0" />
+  </g>
+</svg>
diff --git a/src/PrimitivesPlugin/icons/SVG/cylinder_portion_32x32.svg b/src/PrimitivesPlugin/icons/SVG/cylinder_portion_32x32.svg
new file mode 100644 (file)
index 0000000..46351d5
--- /dev/null
@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:osb="http://www.openswatchbook.org/uri/2009/osb"
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   width="32"
+   height="32"
+   id="svg3352"
+   version="1.1"
+   inkscape:version="0.48.4 r9939"
+   viewBox="0 0 32 32"
+   sodipodi:docname="cylinder_portion_32x32_cla.svg"
+   inkscape:export-filename="/export/home/cgenraul/SHAPER-CEA-FD20_64/INSTALL/SHAPER/share/salome/resources/shaper/icons/Primitives/cylinder_portion_32x32.png"
+   inkscape:export-xdpi="90"
+   inkscape:export-ydpi="90">
+  <defs
+     id="defs3354">
+    <inkscape:path-effect
+       effect="spiro"
+       id="path-effect4188"
+       is_visible="true" />
+    <linearGradient
+       id="linearGradient4223"
+       osb:paint="solid">
+      <stop
+         style="stop-color:#000000;stop-opacity:1;"
+         offset="0"
+         id="stop4225" />
+    </linearGradient>
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="16"
+     inkscape:cx="3.3340758"
+     inkscape:cy="14.83048"
+     inkscape:current-layer="layer1"
+     showgrid="true"
+     inkscape:grid-bbox="true"
+     inkscape:document-units="px"
+     showguides="false"
+     inkscape:window-width="1920"
+     inkscape:window-height="1110"
+     inkscape:window-x="-2"
+     inkscape:window-y="32"
+     inkscape:window-maximized="1"
+     inkscape:snap-bbox="true"
+     inkscape:snap-others="false"
+     inkscape:snap-grids="false"
+     inkscape:object-paths="false"
+     inkscape:snap-smooth-nodes="true"
+     inkscape:snap-nodes="true"
+     inkscape:object-nodes="true"
+     inkscape:snap-intersection-paths="false"
+     inkscape:snap-midpoints="false"
+     inkscape:bbox-nodes="true"
+     inkscape:showpageshadow="false">
+    <inkscape:grid
+       type="xygrid"
+       id="grid3398"
+       empspacing="5"
+       visible="true"
+       enabled="true"
+       snapvisiblegridlinesonly="true" />
+  </sodipodi:namedview>
+  <metadata
+     id="metadata3357">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     id="layer1"
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer">
+    <path
+       style="fill:#b7d9ea;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none;fill-opacity:1"
+       d="M 22.235579,11.804264 26.75,8.6875 l 0.09629,18.310773 -4.62734,3.543844 z"
+       id="path4503"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:#b7d9ea;stroke:#000000;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none;fill-opacity:1"
+       d="M 10.460421,11.521399 16.168853,7.4906673 16.108369,26.39488 10.343036,30.466349 z"
+       id="path4483"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:none;stroke:#1b4955;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       d="m 26.759017,7.9134682 0,19.7134698"
+       id="path3402"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+       d="M 19.4713,8.8277471 Z"
+       id="path4215"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:none;stroke:#1b4955;stroke-width:2.11622119;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       d="M 10.343036,30.466349 16.108369,26.39488"
+       id="path4219"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:#b7d9ea;fill-opacity:1;stroke:#b7d9ea;stroke-width:0.18596868;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       d="M 9.5677965,30.401949 C 8.4630616,30.17651 7.7812389,29.985062 7.0504131,29.695093 6.205534,29.359872 5.7973275,29.071585 5.7311083,28.763365 5.7047195,28.640557 5.6533663,24.333156 5.6169878,19.191366 L 5.550838,9.8426537 6.4802499,10.085544 c 0.7373697,0.192702 2.57171,0.559638 3.4754138,0.695212 0.096039,0.0144 0.1644643,0.471733 0.2158493,1.442438 0.09561,1.805969 0.16767,18.310804 0.07994,18.307425 -0.03602,-0.0013 -0.343683,-0.05929 -0.6836805,-0.12867 z"
+       id="path4155"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:none;stroke:#1b4955;stroke-width:2.00294089;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       d="M 5.3556579,7.4617626 5.4417241,28.282926"
+       id="path4209"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="cc" />
+    <path
+       style="fill:none;stroke:#1b4955;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       d="m 10.196535,10.749669 0.08839,19.774791"
+       id="path4221"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:none;stroke:#1b4955;stroke-width:1.9978863;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       d="M 16.16991,7.4896105 16.14441,25.671337"
+       id="path4227"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="cc" />
+    <path
+       style="fill:#b7d9ea;fill-opacity:1;stroke:#b7d9ea;stroke-width:0.15230079;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       d="m 19.456987,28.653705 c -1.203104,-0.33894 -2.204439,-0.628935 -2.225186,-0.64443 -0.02075,-0.0155 -0.02767,-4.203777 -0.0154,-9.307289 l 0.02233,-9.2791141 2.290969,0.6386571 2.290969,0.638658 0.02414,9.139751 c 0.01325,5.026864 0.0027,9.206384 -0.02372,9.287826 -0.02632,0.08143 -0.07682,0.146752 -0.11225,0.145136 -0.03543,-0.0015 -1.048766,-0.280252 -2.25187,-0.619195 z"
+       id="path4159"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:none;stroke:#1b4955;stroke-width:1.93488965;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       id="path3404-3-0-9-39"
+       transform="matrix(1.1011193,0,0,-0.97031605,-4.5048213,2.5369224)"
+       sodipodi:type="arc"
+       sodipodi:cx="16.007248"
+       sodipodi:cy="-25.924555"
+       sodipodi:rx="7"
+       sodipodi:ry="3.1079483"
+       sodipodi:start="3.1415927"
+       sodipodi:end="4.3308797"
+       d="m 9.0072479,-25.924555 a 7,3.1079483 0 0 1 4.3937481,-2.884498"
+       sodipodi:open="true" />
+    <path
+       style="fill:#b7d9ea;fill-opacity:1;stroke:#1b4955;stroke-width:1.42327809;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       id="path3404-3-0-9"
+       transform="matrix(1.5190222,0,0,-1.5346995,-8.0747405,-1.9471515)"
+       sodipodi:type="arc"
+       sodipodi:cx="15.918855"
+       sodipodi:cy="-6.1497636"
+       sodipodi:rx="7"
+       sodipodi:ry="3.1079483"
+       sodipodi:start="5.2670034"
+       sodipodi:end="10.432426"
+       d="m 19.605164,-8.7918415 a 7,3.1079483 0 1 1 -7.423266,0.014063 l 3.736957,2.6280145 z" />
+    <path
+       style="fill:none;stroke:#1b4955;stroke-width:2;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       d="m 22.235579,11.804264 -0.01663,18.737853"
+       id="path4225"
+       inkscape:connector-curvature="0" />
+    <path
+       style="fill:none;stroke:#1b4955;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       d="m 16.398168,26.684679 5.502463,4.09669"
+       id="path4190"
+       inkscape:connector-curvature="0"
+       sodipodi:nodetypes="cc" />
+    <path
+       style="fill:none;stroke:#1b4955;stroke-width:1.69513776;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
+       id="path3404-3-0-9-39-2"
+       transform="matrix(-1.1057497,0,0,-1.2589056,36.718779,-5.4865086)"
+       sodipodi:type="arc"
+       sodipodi:cx="16.007248"
+       sodipodi:cy="-25.924555"
+       sodipodi:rx="7"
+       sodipodi:ry="3.1079483"
+       sodipodi:start="3.1415927"
+       sodipodi:end="4.3308797"
+       d="m 9.0072479,-25.924555 a 7,3.1079483 0 0 1 4.3937481,-2.884498"
+       sodipodi:open="true" />
+  </g>
+</svg>
index 80a39989dbc692aca1a11a9040af18cb801e0d96..6de9c1c6b1ba34a3ae04400a2b79e57dd32c5267 100644 (file)
Binary files a/src/PrimitivesPlugin/icons/cylinder_32x32.png and b/src/PrimitivesPlugin/icons/cylinder_32x32.png differ
index 4f8177c43fdddbc80b4aad9b96528a93f7eb9fcd..790d6abe9cb001c4afc053ce297a103fca6ce309 100644 (file)
Binary files a/src/PrimitivesPlugin/icons/cylinder_portion_32x32.png and b/src/PrimitivesPlugin/icons/cylinder_portion_32x32.png differ
index aeb61cd51556d84f471b85800f57a6da55623194..49d9adb32d9ef049dae12a859c730bd050130bff 100644 (file)
@@ -1,4 +1,4 @@
 """Package for Primitives plugin for the Parametric Geometry API of the Modeler.
 """
 
-from PrimitivesAPI import addBox
+from PrimitivesAPI import addBox, addCylinder