]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' into cgt/devCEA
authorClarisse Genrault <clarisse.genrault@cea.fr>
Fri, 13 Jan 2017 14:49:23 +0000 (15:49 +0100)
committerClarisse Genrault <clarisse.genrault@cea.fr>
Fri, 13 Jan 2017 14:49:23 +0000 (15:49 +0100)
34 files changed:
src/GeomAlgoAPI/CMakeLists.txt
src/GeomAlgoAPI/GeomAlgoAPI_Box.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Cylinder.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_Cylinder.h [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp
src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h
src/GeomAlgoAPI/GeomAlgoAPI_Symmetry.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Symmetry.h
src/GeomAlgoAPI/Test/TestAPI_Cylinder.py [new file with mode: 0644]
src/PrimitivesAPI/CMakeLists.txt
src/PrimitivesAPI/PrimitivesAPI.h
src/PrimitivesAPI/PrimitivesAPI.i
src/PrimitivesAPI/PrimitivesAPI_Box.h
src/PrimitivesAPI/PrimitivesAPI_Cylinder.cpp [new file with mode: 0644]
src/PrimitivesAPI/PrimitivesAPI_Cylinder.h [new file with mode: 0644]
src/PrimitivesAPI/PrimitivesAPI_swig.h
src/PrimitivesAPI/Test/TestCylinder.py [new file with mode: 0644]
src/PrimitivesPlugin/CMakeLists.txt
src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.cpp [new file with mode: 0644]
src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.h [new file with mode: 0644]
src/PrimitivesPlugin/PrimitivesPlugin_Plugin.cpp
src/PrimitivesPlugin/cylinder_widget.xml [new file with mode: 0644]
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/angle.png [new file with mode: 0755]
src/PrimitivesPlugin/icons/axis.png [new file with mode: 0755]
src/PrimitivesPlugin/icons/cylinder.png [new file with mode: 0644]
src/PrimitivesPlugin/icons/cylinder_32x32.png [new file with mode: 0644]
src/PrimitivesPlugin/icons/cylinder_portion_32x32.png [new file with mode: 0644]
src/PrimitivesPlugin/icons/dimension_v.png [new file with mode: 0644]
src/PrimitivesPlugin/icons/radius.png [new file with mode: 0644]
src/PrimitivesPlugin/plugin-Primitives.xml
src/PythonAPI/model/primitives/__init__.py

index a7b04409ca5cf0a85266da861cbd8fe660ddbcd4..68048d8e9c858202525e6d5b11ee27653ba515eb 100644 (file)
@@ -43,6 +43,7 @@ SET(PROJECT_HEADERS
     GeomAlgoAPI_ShapeAPI.h
     GeomAlgoAPI_Exception.h
     GeomAlgoAPI_Box.h
+    GeomAlgoAPI_Cylinder.h
     GeomAlgoAPI_XAOExport.h
     GeomAlgoAPI_XAOImport.h
     GeomAlgoAPI_Copy.h
@@ -86,6 +87,7 @@ SET(PROJECT_SOURCES
     GeomAlgoAPI_ShapeAPI.cpp
     GeomAlgoAPI_Exception.cpp
     GeomAlgoAPI_Box.cpp
+    GeomAlgoAPI_Cylinder.cpp
     GeomAlgoAPI_XAOExport.cpp
     GeomAlgoAPI_XAOImport.cpp
     GeomAlgoAPI_Copy.cpp
@@ -157,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 6c795cfa73fc3db61297cb4c0a04456478b5a2d0..97c13ddde1c6bedd5c3da86cc4645df0794d2f0c 100644 (file)
@@ -65,7 +65,8 @@ bool GeomAlgoAPI_Box::check()
     if (fabs(aDiffX)  < Precision::Confusion() ||
         fabs(aDiffY)  < Precision::Confusion() ||
         fabs(aDiffZ)  < Precision::Confusion()) {
-      myError = "The points belong both to one of the OXY, OYZ or OZX planes";
+      myError =
+        "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes";
       return false;
     }
   } else {
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Cylinder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Cylinder.cpp
new file mode 100644 (file)
index 0000000..e487b6a
--- /dev/null
@@ -0,0 +1,113 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAlgoAPI_Cylinder.cpp
+// Created:     05 Jan 2016
+// Author:      Clarisse Genrault (CEA)
+
+#include <GeomAlgoAPI_Cylinder.h>
+
+#include <gp_Ax2.hxx>
+#include <gp_Dir.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <BRepPrimAPI_MakeCylinder.hxx>
+
+#include <iostream>
+
+//=================================================================================================
+GeomAlgoAPI_Cylinder::GeomAlgoAPI_Cylinder()
+{
+}
+
+//=================================================================================================
+GeomAlgoAPI_Cylinder::GeomAlgoAPI_Cylinder(std::shared_ptr<GeomAPI_Ax2> theAxis,
+                                           const double theRadius,
+                                           const double theHeight)
+{
+  withAngle = false;
+  //myBasePoint = theBasePoint;
+  myAxis = theAxis;
+  myRadius = theRadius;
+  myHeight = theHeight;
+}
+
+//=================================================================================================
+GeomAlgoAPI_Cylinder::GeomAlgoAPI_Cylinder(std::shared_ptr<GeomAPI_Ax2> theAxis,
+                                           const double theRadius,
+                                           const double theHeight,
+                                           const double theAngle)
+{
+  withAngle = true;
+  myAxis = theAxis;
+  myRadius = theRadius;
+  myHeight = theHeight;
+  myAngle = theAngle;
+}
+
+//=================================================================================================
+bool GeomAlgoAPI_Cylinder::check()
+{
+  if (!myAxis) {
+    myError = "Cylinder builder :: axis is invalid.";
+    return false;
+  }
+  if (myRadius < Precision::Confusion()) {
+    myError = "Cylinder builder :: radius is negative or null.";
+    return false;
+  }
+  if (myHeight < Precision::Confusion()) {
+    myError = "Cylinder builder :: height is negative or null.";
+    return false;
+  }
+  if (withAngle) {
+    if (myAngle < Precision::Angular() * 180./M_PI) {
+      myError = "Cylinder builder :: angle is negative or null.";
+      return false;
+    }
+    if (myAngle > 360.) {
+      myError = "Cylinder builder :: angle greater than 360 degrees.";
+      return false;
+    }
+  }
+  return true;
+}
+
+//=================================================================================================
+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.);
+  } else {
+    aCylinderMaker = new BRepPrimAPI_MakeCylinder(anAxis, myRadius, myHeight);
+  }
+
+  aCylinderMaker->Build();
+
+  if (!aCylinderMaker->IsDone()) {
+    return;
+  }
+
+  TopoDS_Shape aResult = aCylinderMaker->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 = "Cylinder builder :: resulting shape is null.";
+    return;
+  }
+
+  setImpl(aCylinderMaker);
+
+  setDone(true);
+}
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Cylinder.h b/src/GeomAlgoAPI/GeomAlgoAPI_Cylinder.h
new file mode 100644 (file)
index 0000000..6bffee9
--- /dev/null
@@ -0,0 +1,58 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAlgoAPI_Cylinder.h
+// Created:     05 Jan 2016
+// Author:      Clarisse Genrault (CEA)
+
+#ifndef GEOMALGOAPI_CYLINDER_H_
+#define GEOMALGOAPI_CYLINDER_H_
+
+#include <GeomAlgoAPI_MakeShape.h>
+
+#include <GeomAPI_Ax2.h>
+#include <GeomAPI_Pnt.h>
+
+/**\class GeomAlgoAPI_Cylinder
+ * \ingroup DataAlgo
+ * \brief Allows to create Cylinder Primitives
+ */
+class GeomAlgoAPI_Cylinder : public GeomAlgoAPI_MakeShape
+{
+ public:
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_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
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_Cylinder(std::shared_ptr<GeomAPI_Ax2> theAxis,
+                                          const double theRadius,
+                                          const double theHeight);
+
+  /// 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,
+                                          const double theAngle);
+
+  /// Checks if data for the cyminder construction is OK.
+  GEOMALGOAPI_EXPORT bool check();
+
+  /// Builds the cylinder.
+  GEOMALGOAPI_EXPORT void build();
+
+ private:
+  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.
+  double myAngle; /// Covering polar angle of the cylinder;
+};
+
+
+#endif // GEOMALGOAPI_CYLINDER_H_
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
index dedd3caa91e66d244c419f4b8af0e05ba79feb75..143f41c4bfc26356b19d1ca76d497b43a38695b6 100644 (file)
@@ -41,39 +41,39 @@ bool GeomAlgoAPI_Symmetry::check()
   switch (myMethodType) {
     case BY_POINT: {
       if (!myPoint) {
-        myError = "Mirror builder :: point is invalid.";
+        myError = "Symmetry builder :: point is invalid.";
         return false;
       }
       if (!mySourceShape) {
-        myError = "Mirror builder :: source shape is invalid.";
+        myError = "Symmetry builder :: source shape is invalid.";
         return false;
       }
       return true;
     }
     case BY_AXIS: {
       if (!myAxis) {
-        myError = "Mirror builder :: axis is invalid.";
+        myError = "Symmetry builder :: axis is invalid.";
         return false;
       }
       if (!mySourceShape) {
-        myError = "Mirror builder :: source shape is invalid.";
+        myError = "Symmetry builder :: source shape is invalid.";
         return false;
       }
       return true;
     }
     case BY_PLANE: {
       if (!myPlane) {
-        myError = "Mirror builder :: plane is invalid.";
+        myError = "Symmetry builder :: plane is invalid.";
         return false;
       }
       if (!mySourceShape) {
-        myError = "Translation builder :: source shape is invalid.";
+        myError = "Symmetry builder :: source shape is invalid.";
         return false;
       }
       return true;
     }
     default: {
-      myError = "Translation builder :: method not implemented.";
+      myError = "Symmetry builder :: method not implemented.";
       return false;
     }
   }
index 955e06ad61a54d211d92b9c13f3159fb0bbacc0c..153f451adb91f592d99f7ad0acafb10adeba7b92 100644 (file)
@@ -23,15 +23,15 @@ class GeomAlgoAPI_Symmetry : public GeomAlgoAPI_MakeShape
 public:
   /// Type of mirror operation
   enum MethodType {
-    BY_POINT, ///< Mirror by point.
-    BY_AXIS,  ///< Mirror by axis.
-    BY_PLANE  ///< Mirror by plane.
+    BY_POINT, ///< Symmetry by point.
+    BY_AXIS,  ///< Symmetry by axis.
+    BY_PLANE  ///< Symmetry by plane.
   };
 
   /// \brief Creates an object which is obtained from current object by performing
   ///        a symmetry operation by a point.
   /// \param[in] theSourceShape  a shape to be moved.
-  /// \param[in] thePoint         symmetry point.
+  /// \param[in] thePoint        symmetry point.
   GEOMALGOAPI_EXPORT GeomAlgoAPI_Symmetry(std::shared_ptr<GeomAPI_Shape> theSourceShape,
                                           std::shared_ptr<GeomAPI_Pnt>   thePoint);
 
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 5453b7ad449d5fd3a125888503bf3d51e388a9e7..d0fa875935caaa4ea44297e45e07f6d6cd92ebfd 100644 (file)
@@ -6,10 +6,12 @@ INCLUDE(UnitTest)
 SET(PROJECT_HEADERS
   PrimitivesAPI.h
   PrimitivesAPI_Box.h
+  PrimitivesAPI_Cylinder.h
 )
 
 SET(PROJECT_SOURCES
   PrimitivesAPI_Box.cpp
+  PrimitivesAPI_Cylinder.cpp
 )
 
 SET(PROJECT_LIBRARIES
@@ -67,4 +69,5 @@ INSTALL(TARGETS PrimitivesAPI DESTINATION ${SHAPER_INSTALL_BIN})
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/PrimitivesAPI.py DESTINATION ${SHAPER_INSTALL_SWIG})
 
 # Tests
-ADD_UNIT_TESTS(TestBox.py)
\ No newline at end of file
+ADD_UNIT_TESTS(TestBox.py
+               TestCylinder.py)
\ No newline at end of file
index 5ef0b78fc91cf489c4439b5f9141035cf5f45ea7..45d5f57ce552884535aa976f93f4c4d8f33f760d 100644 (file)
@@ -17,4 +17,4 @@
 #endif
 #endif
 
-#endif
+#endif //PRIMITIVESAPI_H
index a84b85a3390a8d6005a07e09fcd81dfbfc0c1dda..3bea92c00cbcb795e1951d631e9cfb76e18db71a 100644 (file)
@@ -20,6 +20,8 @@
 
 // shared pointers
 %shared_ptr(PrimitivesAPI_Box)
+%shared_ptr(PrimitivesAPI_Cylinder)
 
 // all supported interfaces
 %include "PrimitivesAPI_Box.h"
+%include "PrimitivesAPI_Cylinder.h"
index 17249ed29e5390455167432c633d5840af619e35..ca0dc20a9acda78a254f0c8aba7df84a3f9c93ae 100644 (file)
@@ -4,8 +4,8 @@
 // Created:     28 June 2016
 // Author:      Clarisse Genrault (CEA)
 
-#ifndef PrimitivesAPI_Box_H_
-#define PrimitivesAPI_Box_H_
+#ifndef PRIMITIVESAPI_BOX_H_
+#define PRIMITIVESAPI_BOX_H_
 
 #include "PrimitivesAPI.h"
 
@@ -92,4 +92,4 @@ 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
+#endif // PRIMITIVESAPI_BOX_H_
\ No newline at end of file
diff --git a/src/PrimitivesAPI/PrimitivesAPI_Cylinder.cpp b/src/PrimitivesAPI/PrimitivesAPI_Cylinder.cpp
new file mode 100644 (file)
index 0000000..7d342b9
--- /dev/null
@@ -0,0 +1,145 @@
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
+
+// File:        PrimitivesAPI_Cylinder.cpp
+// Created:     12 Jan 2017
+// Author:      Clarisse Genrault
+
+#include "PrimitivesAPI_Cylinder.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Selection.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+PrimitivesAPI_Cylinder::PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+//==================================================================================================
+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)
+: ModelHighAPI_Interface(theFeature)
+{
+  if (initialize()) {
+    fillAttribute(PrimitivesPlugin_Cylinder::CREATION_METHOD_CYLINDER(), creationMethod());
+    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)
+: ModelHighAPI_Interface(theFeature)
+{
+  if (initialize()) {
+    fillAttribute(PrimitivesPlugin_Cylinder::CREATION_METHOD_CYLINDER_PORTION(), creationMethod());
+    fillAttribute(theBasePoint, basePoint());
+    fillAttribute(theAxis, axis());
+    fillAttribute(theAngle, angle());
+    setSizes(theRadius, theHeight);
+  }
+}
+
+//==================================================================================================
+PrimitivesAPI_Cylinder::~PrimitivesAPI_Cylinder()
+{
+
+}
+
+//==================================================================================================
+void PrimitivesAPI_Cylinder::setSizes(const ModelHighAPI_Double& theRadius,
+                                      const ModelHighAPI_Double& theHeight)
+{
+  fillAttribute(theRadius, radius());
+  fillAttribute(theHeight, height());
+  execute();
+}
+
+//==================================================================================================
+void PrimitivesAPI_Cylinder::dump(ModelHighAPI_Dumper& theDumper) const
+{
+  FeaturePtr aBase = feature();
+  const std::string& aDocName = theDumper.name(aBase->document());
+
+  theDumper << aBase << " = model.addCylinder(" << aDocName;
+
+  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 << ", " << 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;
+  }
+
+  theDumper << ")" << std::endl;
+}
+
+//==================================================================================================
+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)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
+  return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, theBasePoint, theAxis,
+                                                theRadius, theHeight));
+}
+
+//==================================================================================================
+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)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
+  return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, theBasePoint, theAxis,
+                                                theRadius, theHeight, theAngle));
+}
+
+//==================================================================================================
+CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
+                        const ModelHighAPI_Double& theRadius,
+                        const ModelHighAPI_Double& theHeight)
+{
+  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));
+}
+
+//==================================================================================================
+CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
+                        const ModelHighAPI_Double& theRadius,
+                        const ModelHighAPI_Double& theHeight,
+                        const ModelHighAPI_Double& theAngle)
+{
+  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
diff --git a/src/PrimitivesAPI/PrimitivesAPI_Cylinder.h b/src/PrimitivesAPI/PrimitivesAPI_Cylinder.h
new file mode 100644 (file)
index 0000000..3d47379
--- /dev/null
@@ -0,0 +1,119 @@
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
+
+// File:        PrimitivesAPI_Cylinder.h
+// Created:     12 Jan 2017
+// Author:      Clarisse Genrault
+
+#ifndef PRIMITIVESAPI_CYLINDER_H_
+#define PRIMITIVESAPI_CYLINDER_H_
+
+#include "PrimitivesAPI.h"
+
+#include <PrimitivesPlugin_Cylinder.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Double;
+class ModelHighAPI_Selection;
+
+/// \class PrimitivesAPI_Box
+/// \ingroup CPPHighAPI
+/// \brief Interface for primitive Box feature.
+class PrimitivesAPI_Cylinder: public ModelHighAPI_Interface
+{
+public:
+  /// Constructor without values.
+  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,
+                                  const ModelHighAPI_Selection& theBasePoint,
+                                  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,
+                                  const ModelHighAPI_Selection& theAxis,
+                                  const ModelHighAPI_Double& theRadius,
+                                  const ModelHighAPI_Double& theHeight,
+                                  const ModelHighAPI_Double& theAngle);
+
+  /// 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, /** 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);
+
+  /// Dump wrapped feature
+  PRIMITIVESAPI_EXPORT
+  virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on primitive Box object
+typedef std::shared_ptr<PrimitivesAPI_Cylinder> CylinderPtr;
+
+/// \ingroup CPPHighAPI
+/// \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);
+
+/// \ingroup CPPHighAPI
+/// \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);
+
+/// \ingroup CPPHighAPI
+/// \brief Create primitive Box feature.
+PRIMITIVESAPI_EXPORT
+CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
+                        const ModelHighAPI_Double& theRadius,
+                        const ModelHighAPI_Double& theHeight);
+
+/// \ingroup CPPHighAPI
+/// \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);
+
+#endif // PRIMITIVESAPI_CYLINDER_H_
\ No newline at end of file
index dc7f95a4c9a2e2a24f1e2eb8eb255cfb8fa4bbb6..98fc5bf038f2e06b8e44092be534341ffa97a30b 100644 (file)
@@ -4,12 +4,13 @@
 // Created: 28 June 2016
 // Author:  Clarisse Genrault (CEA)
 
-#ifndef PrimitivesAPI_swig_H_
-#define PrimitivesAPI_swig_H_
+#ifndef PRIMITIVESAPI_SWIG_H_
+#define PRIMITIVESAPI_SWIG_H_
 
   #include <ModelHighAPI_swig.h>
 
   #include "PrimitivesAPI.h"
   #include "PrimitivesAPI_Box.h"
+  #include "PrimitivesAPI_Cylinder.h"
 
-#endif // PrimitivesAPI_swig_H_
+#endif // PRIMITIVESAPI_SWIG_H_
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 2623477a50d91b975caf65a92367371d35d640dd..e8aa0147acde67309a3543252281d6b48914215c 100644 (file)
@@ -8,16 +8,19 @@ SET(PROJECT_HEADERS
     PrimitivesPlugin.h
     PrimitivesPlugin_Plugin.h
     PrimitivesPlugin_Box.h
+    PrimitivesPlugin_Cylinder.h
 )
 
 SET(PROJECT_SOURCES
     PrimitivesPlugin_Plugin.cpp
     PrimitivesPlugin_Box.cpp
+    PrimitivesPlugin_Cylinder.cpp
 )
 
 SET(XML_RESOURCES
   plugin-Primitives.xml
   box_widget.xml
+  cylinder_widget.xml
 )
 
 INCLUDE_DIRECTORIES(
diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.cpp
new file mode 100644 (file)
index 0000000..6323648
--- /dev/null
@@ -0,0 +1,183 @@
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D
+
+// File:        PrimitivesPlugin_Cylinder.cpp
+// Created:     09 Jan 2017
+// Author:      Clarisse Genrault (CEA)
+
+#include <PrimitivesPlugin_Cylinder.h>
+
+#include <GeomAPI_Dir.h>
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_Lin.h>
+
+#include <GeomAlgoAPI_PointBuilder.h>
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_Session.h>
+
+#include <iostream>
+
+//=================================================================================================
+PrimitivesPlugin_Cylinder::PrimitivesPlugin_Cylinder()
+{
+}
+
+//=================================================================================================
+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()) {
+    ObjectPtr aPointObj = ModelAPI_Session::get()->moduleDocument()
+      ->objectByName(ModelAPI_ResultConstruction::group(), "Origin");
+    if (aPointObj.get()) {
+      ResultPtr aPointRes = std::dynamic_pointer_cast<ModelAPI_Result>(aPointObj);
+      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()) {
+    ObjectPtr anAxisObj = ModelAPI_Session::get()->moduleDocument()
+      ->objectByName(ModelAPI_ResultConstruction::group(), "OZ");
+    if (anAxisObj.get()) {
+      ResultPtr anAxisRes = std::dynamic_pointer_cast<ModelAPI_Result>(anAxisObj);
+      anAxis->setValue(anAxisRes, std::shared_ptr<GeomAPI_Shape>());
+    }
+  }
+}
+
+//=================================================================================================
+void PrimitivesPlugin_Cylinder::execute()
+{
+  AttributeStringPtr aMethodTypeAttr = string(PrimitivesPlugin_Cylinder::CREATION_METHOD());
+  std::string aMethodType = aMethodTypeAttr->value();
+
+  if (aMethodType == CREATION_METHOD_CYLINDER()) {
+    createCylinder(false);
+  }
+
+  if (aMethodType == CREATION_METHOD_CYLINDER_PORTION()) {
+    createCylinder(true);
+  }
+}
+
+//=================================================================================================
+void PrimitivesPlugin_Cylinder::createCylinder(bool withAngle)
+{
+  // Getting point.
+  std::shared_ptr<GeomAPI_Pnt> aBasePoint;
+  std::shared_ptr<ModelAPI_AttributeSelection> aPointRef =
+    selection(PrimitivesPlugin_Cylinder::BASE_POINT_ID());
+  if (aPointRef.get() != NULL) {
+    GeomShapePtr aShape1 = aPointRef->value();
+    if (!aShape1.get()) {
+      aShape1 = aPointRef->context()->shape();
+    }
+    if (aShape1) {
+      aBasePoint = GeomAlgoAPI_PointBuilder::point(aShape1);
+    }
+  }
+
+  // Getting axis.
+  std::shared_ptr<GeomAPI_Ax2> anAxis;
+  std::shared_ptr<GeomAPI_Edge> anEdge;
+  std::shared_ptr<ModelAPI_AttributeSelection> anEdgeRef =
+    selection(PrimitivesPlugin_Cylinder::AXIS_ID());
+  if(anEdgeRef && anEdgeRef->value() && anEdgeRef->value()->isEdge()) {
+    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anEdgeRef->value()));
+  } else if (anEdgeRef && !anEdgeRef->value() && anEdgeRef->context() &&
+             anEdgeRef->context()->shape() && anEdgeRef->context()->shape()->isEdge()) {
+    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(anEdgeRef->context()->shape()));
+  }
+  if(anEdge) {
+    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 =
+      std::shared_ptr<GeomAlgoAPI_Cylinder>(new GeomAlgoAPI_Cylinder(anAxis,
+                                                                     aRadius, aHeight,
+                                                                     anAngle));
+  } else {
+    aCylinderAlgo =
+      std::shared_ptr<GeomAlgoAPI_Cylinder>(new GeomAlgoAPI_Cylinder(anAxis,
+                                                                     aRadius, aHeight));
+  }
+
+  // These checks should be made to the GUI for the feature but
+  // the corresponding validator does not exist yet.
+  if (!aCylinderAlgo->check()) {
+    setError(aCylinderAlgo->getError(), false);
+    return;
+  }
+
+  // Build the cylinder
+  aCylinderAlgo->build();
+
+  // Check if the creation of the cylinder
+  if(!aCylinderAlgo->isDone()) {
+    // The error is not displayed in a popup window. It must be in the message console.
+    setError(aCylinderAlgo->getError(), false);
+    return;
+  }
+  if(!aCylinderAlgo->checkValid("Cylinder builder")) {
+    // The error is not displayed in a popup window. It must be in the message console.
+    setError(aCylinderAlgo->getError(), false);
+    return;
+  }
+
+  int aResultIndex = 0;
+  ResultBodyPtr aResultBox = document()->createBody(data(), aResultIndex);
+  loadNamingDS(aCylinderAlgo, aResultBox);
+  setResult(aResultBox, aResultIndex);
+}
+
+//=================================================================================================
+void PrimitivesPlugin_Cylinder::loadNamingDS(std::shared_ptr<GeomAlgoAPI_Cylinder> theCylinderAlgo,
+                                             std::shared_ptr<ModelAPI_ResultBody> theResultCylinder)
+{
+  // Load the result
+  theResultCylinder->store(theCylinderAlgo->shape());
+
+  // Prepare the naming
+  theCylinderAlgo->prepareNamingFaces();
+
+  // Insert to faces
+  int num = 1;
+  std::map< std::string, std::shared_ptr<GeomAPI_Shape> > listOfFaces =
+    theCylinderAlgo->getCreatedFaces();
+  for (std::map< std::string, std::shared_ptr<GeomAPI_Shape> >::iterator
+       it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) {
+    std::shared_ptr<GeomAPI_Shape> aFace = (*it).second;
+    theResultCylinder->generated(aFace, (*it).first, num++);
+  }
+}
diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.h b/src/PrimitivesPlugin/PrimitivesPlugin_Cylinder.h
new file mode 100644 (file)
index 0000000..250bf88
--- /dev/null
@@ -0,0 +1,116 @@
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D
+
+// File:        PrimitivesPlugin_Cylinder.h
+// Created:     09 Jan 2017
+// Author:      Clarisse Genrault (CEA)
+
+#ifndef PRIMITIVESPLUGIN_CYLINDER_H_
+#define PRIMITIVESPLUGIN_CYLINDER_H_
+
+#include <PrimitivesPlugin.h>
+#include <ModelAPI_Feature.h>
+#include <GeomAlgoAPI_Cylinder.h>
+
+class GeomAPI_Shape;
+class ModelAPI_ResultBody;
+
+/**\class PrimitivesPlugin_Cylinder
+ * \ingroup Plugins
+ * \brief Feature for creation of a cylinder.
+ *
+ * Creates a cylinder from a radius, a height, an angle, a center point defaulting to
+ * the origin and an axis defaulting to OZ
+ */
+class PrimitivesPlugin_Cylinder : public ModelAPI_Feature
+{
+ public:
+  /// Cylinder kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_CYLINDER_ID("Cylinder");
+    return MY_CYLINDER_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_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()
+  {
+    static const std::string MY_CREATION_METHOD_ID("CylinderPortion");
+    return MY_CREATION_METHOD_ID;
+  }
+
+  /// Attribute name of the base point
+  inline static const std::string& BASE_POINT_ID()
+  {
+    static const std::string MY_BASE_POINT_ID("base_point");
+    return MY_BASE_POINT_ID;
+  }
+
+  /// Attribute name of the axis
+  inline static const std::string& AXIS_ID()
+  {
+    static const std::string MY_AXIS_ID("axis");
+    return MY_AXIS_ID;
+  }
+
+  /// Attribute name of the radius
+  inline static const std::string& RADIUS_ID()
+  {
+    static const std::string MY_RADIUS_ID("radius");
+    return MY_RADIUS_ID;
+  }
+
+  /// Attribute name of the height
+  inline static const std::string& HEIGHT_ID()
+  {
+    static const std::string MY_HEIGHT_ID("height");
+    return MY_HEIGHT_ID;
+  }
+
+  /// Attribute name of the angle
+  inline static const std::string& ANGLE_ID()
+  {
+    static const std::string MY_ANGLE_ID("angle");
+    return MY_ANGLE_ID;
+  }
+
+  /// Returns the kind of a feature
+  PRIMITIVESPLUGIN_EXPORT virtual const std::string& getKind()
+  {
+    static std::string MY_KIND = PrimitivesPlugin_Cylinder::ID();
+    return MY_KIND;
+  }
+
+  /// Creates a new part document if needed
+  PRIMITIVESPLUGIN_EXPORT virtual void execute();
+
+  /// Request for initialization of data model of the feature: adding all attributes
+  PRIMITIVESPLUGIN_EXPORT virtual void initAttributes();
+
+  /// Use plugin manager for features creation
+  PrimitivesPlugin_Cylinder();
+
+ private:
+  /// Load Naming data structure of the feature to the document
+  void loadNamingDS(std::shared_ptr<GeomAlgoAPI_Cylinder> theCylinderAlgo,
+                    std::shared_ptr<ModelAPI_ResultBody> theResultCylinder);
+
+  ///Perform the creation of a cylinder
+  void createCylinder(bool withAngle);
+
+};
+
+#endif // PRIMITIVESPLUGIN_CYLINDER_H_
index bf3e1716c034b8933e2c194c13d556d16debc16e..b3ef9cbf35386cb2001d694ad4b01b6bfc0d2455 100644 (file)
@@ -7,6 +7,7 @@
 #include <PrimitivesPlugin_Plugin.h>
 
 #include <PrimitivesPlugin_Box.h>
+#include <PrimitivesPlugin_Cylinder.h>
 #include <ModelAPI_Session.h>
 
 #include <string>
@@ -26,6 +27,8 @@ FeaturePtr PrimitivesPlugin_Plugin::createFeature(std::string theFeatureID)
 {
   if (theFeatureID == PrimitivesPlugin_Box::ID()) {
     return FeaturePtr(new PrimitivesPlugin_Box);
+  } else if (theFeatureID == PrimitivesPlugin_Cylinder::ID()) {
+    return FeaturePtr(new PrimitivesPlugin_Cylinder);
   }
   // feature of such kind is not found
   return FeaturePtr();
diff --git a/src/PrimitivesPlugin/cylinder_widget.xml b/src/PrimitivesPlugin/cylinder_widget.xml
new file mode 100644 (file)
index 0000000..a946974
--- /dev/null
@@ -0,0 +1,101 @@
+<!-- Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
+
+<source>
+  <toolbox id="CreationMethod">
+    <box id="Cylinder" title="Cylinder" icon="icons/Primitives/cylinder_32x32.png">
+      <shape_selector
+          id="base_point"
+          label="base_point"
+          default=""
+          shape_types="vertex"
+          icon="icons/Primitives/point.png"
+          tooltip="Select the center of the base of the cylinder">
+        <validator id="GeomValidators_ConstructionComposite"/>
+        <validator id="GeomValidators_ShapeType" parameters="vertex"/>
+      </shape_selector>
+      <shape_selector
+          id="axis"
+          label="axis"
+          default=""
+          shape_types="edge"
+          icon="icons/Primitives/axis.png"
+          tooltip="Select the axis of the cylinder">
+        <validator id="GeomValidators_ConstructionComposite"/>
+        <validator id="GeomValidators_ShapeType" parameters="line"/>
+      </shape_selector>
+      <doublevalue
+          id="radius"
+          label="radius"
+          step="1."
+          default="5."
+          min="0."
+          icon="icons/Primitives/radius.png"
+          tooltip="Enter the radius of the cylinder">
+        <validator id="GeomValidators_Positive"/>
+      </doublevalue>
+      <doublevalue
+          id="height"
+          label="height"
+          step="1."
+          default="10."
+          min="0."
+          icon="icons/Primitives/dimension_v.png"
+          tooltip="Enter the height of the cylinder">
+        <validator id="GeomValidators_Positive"/>
+      </doublevalue>
+    </box>
+    <box id="CylinderPortion" title="Portion of cylinder" icon="icons/Primitives/cylinder_portion_32x32.png">
+      <shape_selector
+          id="base_point"
+          label="base_point"
+          default=""
+          shape_types="vertex"
+          icon="icons/Primitives/point.png"
+          tooltip="Select the center of the base of the cylinder">
+        <validator id="GeomValidators_ConstructionComposite"/>
+        <validator id="GeomValidators_ShapeType" parameters="vertex"/>
+      </shape_selector>
+      <shape_selector
+          id="axis"
+          label="axis"
+          default=""
+          shape_types="edge"
+          icon="icons/Primitives/axis.png"
+          tooltip="Select the axis of the cylinder">
+        <validator id="GeomValidators_ConstructionComposite"/>
+        <validator id="GeomValidators_ShapeType" parameters="line"/>
+      </shape_selector>
+      <doublevalue
+          id="radius"
+          label="radius"
+          step="1."
+          default="5."
+          min="0."
+          icon="icons/Primitives/radius.png"
+          tooltip="Enter the radius of the cylinder">
+        <validator id="GeomValidators_Positive"/>
+      </doublevalue>
+      <doublevalue
+          id="height"
+          label="height"
+          step="1."
+          default="10."
+          min="0."
+          icon="icons/Primitives/dimension_v.png"
+          tooltip="Enter the height of the cylinder">
+        <validator id="GeomValidators_Positive"/>
+      </doublevalue>
+      <doublevalue
+          id="angle"
+          label="angle"
+          step="10."
+          default="45.0"
+          min="0."
+          max="360."
+          icon="icons/Primitives/angle.png"
+          tooltip="Enter the angle of the portion of the cylinder">
+        <validator id="GeomValidators_Positive"/>
+      </doublevalue>
+    </box>
+  </toolbox>
+</source>
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>
diff --git a/src/PrimitivesPlugin/icons/angle.png b/src/PrimitivesPlugin/icons/angle.png
new file mode 100755 (executable)
index 0000000..e401acd
Binary files /dev/null and b/src/PrimitivesPlugin/icons/angle.png differ
diff --git a/src/PrimitivesPlugin/icons/axis.png b/src/PrimitivesPlugin/icons/axis.png
new file mode 100755 (executable)
index 0000000..015d270
Binary files /dev/null and b/src/PrimitivesPlugin/icons/axis.png differ
diff --git a/src/PrimitivesPlugin/icons/cylinder.png b/src/PrimitivesPlugin/icons/cylinder.png
new file mode 100644 (file)
index 0000000..200b9d1
Binary files /dev/null and b/src/PrimitivesPlugin/icons/cylinder.png differ
diff --git a/src/PrimitivesPlugin/icons/cylinder_32x32.png b/src/PrimitivesPlugin/icons/cylinder_32x32.png
new file mode 100644 (file)
index 0000000..6de9c1c
Binary files /dev/null and b/src/PrimitivesPlugin/icons/cylinder_32x32.png differ
diff --git a/src/PrimitivesPlugin/icons/cylinder_portion_32x32.png b/src/PrimitivesPlugin/icons/cylinder_portion_32x32.png
new file mode 100644 (file)
index 0000000..790d6ab
Binary files /dev/null and b/src/PrimitivesPlugin/icons/cylinder_portion_32x32.png differ
diff --git a/src/PrimitivesPlugin/icons/dimension_v.png b/src/PrimitivesPlugin/icons/dimension_v.png
new file mode 100644 (file)
index 0000000..15e26af
Binary files /dev/null and b/src/PrimitivesPlugin/icons/dimension_v.png differ
diff --git a/src/PrimitivesPlugin/icons/radius.png b/src/PrimitivesPlugin/icons/radius.png
new file mode 100644 (file)
index 0000000..7ff3b4d
Binary files /dev/null and b/src/PrimitivesPlugin/icons/radius.png differ
index e3ababf71245c1bc6db147a792aebc567e61f5ab..13e22414ae0bbf3ce18b30b2a5dc29e8741ad7c7 100644 (file)
@@ -8,5 +8,10 @@
         <source path="box_widget.xml"/>
       </feature>
     </group>
+    <group id="Primitives">
+      <feature id="Cylinder" title="Cylinder" tooltip="Create a cylinder" icon="icons/Primitives/cylinder.png">
+        <source path="cylinder_widget.xml"/>
+      </feature>
+    </group>
   </workbench>
 </plugin>
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