]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add "Torus" primitive and "Cone" primitive.
authorClarisse Genrault <clarisse.genrault@cea.fr>
Wed, 22 Mar 2017 07:22:03 +0000 (08:22 +0100)
committerClarisse Genrault <clarisse.genrault@cea.fr>
Wed, 22 Mar 2017 07:22:03 +0000 (08:22 +0100)
30 files changed:
src/GeomAlgoAPI/CMakeLists.txt
src/GeomAlgoAPI/GeomAlgoAPI_Cone.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_Cone.h [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_Cylinder.cpp
src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp
src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h
src/GeomAlgoAPI/GeomAlgoAPI_Torus.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_Torus.h [new file with mode: 0644]
src/PrimitivesAPI/CMakeLists.txt
src/PrimitivesAPI/PrimitivesAPI.i
src/PrimitivesAPI/PrimitivesAPI_Cone.cpp [new file with mode: 0644]
src/PrimitivesAPI/PrimitivesAPI_Cone.h [new file with mode: 0644]
src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp
src/PrimitivesAPI/PrimitivesAPI_Torus.cpp [new file with mode: 0644]
src/PrimitivesAPI/PrimitivesAPI_Torus.h [new file with mode: 0644]
src/PrimitivesAPI/PrimitivesAPI_swig.h
src/PrimitivesPlugin/CMakeLists.txt
src/PrimitivesPlugin/PrimitivesPlugin_Cone.cpp [new file with mode: 0644]
src/PrimitivesPlugin/PrimitivesPlugin_Cone.h [new file with mode: 0644]
src/PrimitivesPlugin/PrimitivesPlugin_Plugin.cpp
src/PrimitivesPlugin/PrimitivesPlugin_Torus.cpp [new file with mode: 0644]
src/PrimitivesPlugin/PrimitivesPlugin_Torus.h [new file with mode: 0644]
src/PrimitivesPlugin/cone_widget.xml [new file with mode: 0644]
src/PrimitivesPlugin/icons/SVG/cone.svg [new file with mode: 0644]
src/PrimitivesPlugin/icons/SVG/torus.svg [new file with mode: 0644]
src/PrimitivesPlugin/icons/cone.png [new file with mode: 0644]
src/PrimitivesPlugin/icons/torus.png [new file with mode: 0644]
src/PrimitivesPlugin/plugin-Primitives.xml
src/PrimitivesPlugin/torus_widget.xml [new file with mode: 0644]
src/PythonAPI/model/primitives/__init__.py

index f3390147c6a7c5291eca17f8d7360ec27b77272b..0ad49ca0f7f9607906714d8ca1b945ec2b7dd4ab 100644 (file)
@@ -42,8 +42,10 @@ SET(PROJECT_HEADERS
     GeomAlgoAPI_ShapeAPI.h
     GeomAlgoAPI_Exception.h
     GeomAlgoAPI_Box.h
+    GeomAlgoAPI_Cone.h
     GeomAlgoAPI_Cylinder.h
     GeomAlgoAPI_Sphere.h
+    GeomAlgoAPI_Torus.h
     GeomAlgoAPI_XAOExport.h
     GeomAlgoAPI_XAOImport.h
     GeomAlgoAPI_Copy.h
@@ -88,8 +90,10 @@ SET(PROJECT_SOURCES
     GeomAlgoAPI_ShapeAPI.cpp
     GeomAlgoAPI_Exception.cpp
     GeomAlgoAPI_Box.cpp
+    GeomAlgoAPI_Cone.cpp
     GeomAlgoAPI_Cylinder.cpp
     GeomAlgoAPI_Sphere.cpp
+    GeomAlgoAPI_Torus.cpp
     GeomAlgoAPI_XAOExport.cpp
     GeomAlgoAPI_XAOImport.cpp
     GeomAlgoAPI_Copy.cpp
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Cone.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Cone.cpp
new file mode 100644 (file)
index 0000000..5d9be8c
--- /dev/null
@@ -0,0 +1,86 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAlgoAPI_Cone.cpp
+// Created:     20 Mar 2017
+// Author:      Clarisse Genrault (CEA)
+
+#include <GeomAlgoAPI_Cone.h>
+
+#include <gp_Ax2.hxx>
+
+#include <BRepPrimAPI_MakeCone.hxx>
+
+//=================================================================================================
+GeomAlgoAPI_Cone::GeomAlgoAPI_Cone()
+{
+}
+
+//=================================================================================================
+GeomAlgoAPI_Cone::GeomAlgoAPI_Cone(std::shared_ptr<GeomAPI_Ax2> theAxis,
+                                   const double theBaseRadius,
+                                   const double theTopRadius,
+                                   const double theHeight)
+{
+  myAxis = theAxis;
+  myBaseRadius = theBaseRadius;
+  myTopRadius = theTopRadius;
+  myHeight = theHeight;
+}
+
+//=================================================================================================
+bool GeomAlgoAPI_Cone::check()
+{
+  if (!myAxis) {
+    myError = "Cone builder :: axis is not valid.";
+    return false;
+  } else if (myBaseRadius < Precision::Confusion() && myTopRadius < Precision::Confusion()) {
+    myError = "Cone builder :: base radius and top radius are negative or null.";
+    return false;
+  } else if (myBaseRadius < 0.) {
+    myError = "Cone builder :: base radius is negative.";
+    return false;
+  } else if (myTopRadius < 0.) {
+    myError = "Cone builder :: top radius is negative.";
+    return false;
+  } else if (fabs(myBaseRadius-myTopRadius) < Precision::Confusion()) {
+    myError = "Cone builder :: base radius and top radius are too close.";
+    return false;
+  } else if (myHeight < Precision::Confusion()) {
+    myError = "Cone builder :: height is negative or null.";
+    return false;
+  }
+  return true;
+}
+
+//=================================================================================================
+void GeomAlgoAPI_Cone::build()
+{
+  myCreatedFaces.clear();
+
+  const gp_Ax2& anAxis = myAxis->impl<gp_Ax2>();
+
+  // Construct the torus
+  BRepPrimAPI_MakeCone *aConeMaker =
+    new BRepPrimAPI_MakeCone(anAxis, myBaseRadius, myTopRadius, myHeight);
+
+  aConeMaker->Build();
+
+  if (!aConeMaker->IsDone()) {
+    return;
+  }
+
+  TopoDS_Shape aResult = aConeMaker->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 = "Torus builder :: resulting shape is null.";
+    return;
+  }
+
+  setImpl(aConeMaker);
+
+  setDone(true);
+}
\ No newline at end of file
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Cone.h b/src/GeomAlgoAPI/GeomAlgoAPI_Cone.h
new file mode 100644 (file)
index 0000000..327ef6b
--- /dev/null
@@ -0,0 +1,46 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAlgoAPI_Cone.h
+// Created:     20 Mar 2017
+// Author:      Clarisse Genrault (CEA)
+
+#ifndef GEOMALGOAPI_CONE_H_
+#define GEOMALGOAPI_CONE_H_
+
+#include <GeomAlgoAPI_MakeShape.h>
+
+#include <GeomAPI_Ax2.h>
+
+/**\class GeomAlgoAPI_Cone
+ * \ingroup DataAlgo
+ * \brief Allows to create Cone Primitives
+ */
+class GeomAlgoAPI_Cone : public GeomAlgoAPI_MakeShape
+{
+ public:
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_Cone();
+
+  /// Creates a cone.
+  /// \param theAxis The axis of the cone
+  /// \param theBaseRadius The base radius of the cone
+  /// \param theTopRadius The top radius of the cone
+  /// \param theHeight The height of the cone
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_Cone(std::shared_ptr<GeomAPI_Ax2> theAxis,
+                                      const double theBaseRadius,
+                                      const double theTopRadius,
+                                      const double theHeight);
+
+  /// Checks if data for the cone construction is OK.
+  GEOMALGOAPI_EXPORT bool check();
+
+  /// Builds the cone.
+  GEOMALGOAPI_EXPORT void build();
+
+ private:
+  std::shared_ptr<GeomAPI_Ax2> myAxis; /// Axis of the cone.
+  double myBaseRadius; /// Base radius of the cone.
+  double myTopRadius; /// Top radius of the cone.
+  double myHeight; /// Height of the cone.
+};
+
+#endif // GEOMALGOAPI_CONE_H_
index a7512d382cf8e1f4e78586e82f7d38db87377051..a3d64ae6394f1ed4835099019850508d17bd01f4 100644 (file)
@@ -13,8 +13,6 @@
 
 #include <BRepPrimAPI_MakeCylinder.hxx>
 
-#include <iostream>
-
 //=================================================================================================
 GeomAlgoAPI_Cylinder::GeomAlgoAPI_Cylinder()
 {
index e02a28cc5449449847a653e4d248a1823fbb0c1b..5fdeaee509edf96f3dcc1221aa892d2893f5bee4 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <GeomAlgoAPI_Box.h>
 #include <GeomAlgoAPI_CompoundBuilder.h>
+#include <GeomAlgoAPI_Cone.h>
 #include <GeomAlgoAPI_ConeSegment.h>
 #include <GeomAlgoAPI_Cylinder.h>
 #include <GeomAlgoAPI_EdgeBuilder.h>
@@ -15,6 +16,7 @@
 #include <GeomAlgoAPI_Scale.h>
 #include <GeomAlgoAPI_Sphere.h>
 #include <GeomAlgoAPI_Symmetry.h>
+#include <GeomAlgoAPI_Torus.h>
 #include <GeomAlgoAPI_Translation.h>
 
 #include <GeomAPI_Lin.h>
@@ -240,6 +242,138 @@ namespace GeomAlgoAPI_ShapeAPI
     return aSphereAlgo.shape();
   }
 
+  //===============================================================================================
+  std::shared_ptr<GeomAPI_Shape> makeTorus(std::shared_ptr<GeomAPI_Pnt> theBasePoint,
+                                           std::shared_ptr<GeomAPI_Edge> theEdge,
+                                           double theRadius, double theRingRadius)
+      throw (GeomAlgoAPI_Exception)
+  {
+    // Check if the base point is OK
+    if (!theBasePoint) {
+      throw GeomAlgoAPI_Exception("Torus builder :: the base point is not valid.");
+    }
+    // Check if the edge is OK
+    if (!theEdge) {
+      throw GeomAlgoAPI_Exception("Torus builder :: the axis is not valid.");
+    }
+
+    std::shared_ptr<GeomAPI_Ax2> anAxis;
+    anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
+                                                          theEdge->line()->direction()));
+
+    GeomAlgoAPI_Torus aTorusAlgo(anAxis, theRadius, theRingRadius);
+
+    if (!aTorusAlgo.check()) {
+      throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
+    }
+
+    aTorusAlgo.build();
+
+    if(!aTorusAlgo.isDone()) {
+      throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
+    }
+
+    if (!aTorusAlgo.checkValid("Torus builder")) {
+      throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
+    }
+    return aTorusAlgo.shape();
+  }
+
+  //===============================================================================================
+  std::shared_ptr<GeomAPI_Shape> makeTorus(double theRadius, double theRingRadius)
+      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_Torus aTorusAlgo(anAxis, theRadius, theRingRadius);
+
+    if (!aTorusAlgo.check()) {
+      throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
+    }
+
+    aTorusAlgo.build();
+
+    if(!aTorusAlgo.isDone()) {
+      throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
+    }
+
+    if (!aTorusAlgo.checkValid("Torus builder")) {
+      throw GeomAlgoAPI_Exception(aTorusAlgo.getError());
+    }
+    return aTorusAlgo.shape();
+  }
+
+  //===============================================================================================
+  std::shared_ptr<GeomAPI_Shape> makeCone(std::shared_ptr<GeomAPI_Pnt> theBasePoint,
+                                          std::shared_ptr<GeomAPI_Edge> theEdge,
+                                          double theBaseRadius, double theTopRadius,
+                                          double theHeight) throw (GeomAlgoAPI_Exception)
+  {
+    // Check if the base point is OK
+    if (!theBasePoint) {
+      throw GeomAlgoAPI_Exception("Cone builder :: the base point is not valid.");
+    }
+    // Check if the edge is OK
+    if (!theEdge) {
+      throw GeomAlgoAPI_Exception("Cone builder :: the axis is not valid.");
+    }
+
+    std::shared_ptr<GeomAPI_Ax2> anAxis;
+    anAxis = std::shared_ptr<GeomAPI_Ax2>(new GeomAPI_Ax2(theBasePoint,
+                                                          theEdge->line()->direction()));
+
+    GeomAlgoAPI_Cone aConeAlgo(anAxis, theBaseRadius, theTopRadius, theHeight);
+
+    if (!aConeAlgo.check()) {
+      throw GeomAlgoAPI_Exception(aConeAlgo.getError());
+    }
+
+    aConeAlgo.build();
+
+    if(!aConeAlgo.isDone()) {
+      throw GeomAlgoAPI_Exception(aConeAlgo.getError());
+    }
+
+    if (!aConeAlgo.checkValid("Cone builder")) {
+      throw GeomAlgoAPI_Exception(aConeAlgo.getError());
+    }
+    return aConeAlgo.shape();
+  }
+
+  //===============================================================================================
+  std::shared_ptr<GeomAPI_Shape> makeCone(double theBaseRadius, double theTopRadius,
+                                          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_Cone aConeAlgo(anAxis, theBaseRadius, theTopRadius, theHeight);
+
+    if (!aConeAlgo.check()) {
+      throw GeomAlgoAPI_Exception(aConeAlgo.getError());
+    }
+
+    aConeAlgo.build();
+
+    if(!aConeAlgo.isDone()) {
+      throw GeomAlgoAPI_Exception(aConeAlgo.getError());
+    }
+
+    if (!aConeAlgo.checkValid("Cone builder")) {
+      throw GeomAlgoAPI_Exception(aConeAlgo.getError());
+    }
+    return aConeAlgo.shape();
+  }
+
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeTranslation(
     std::shared_ptr<GeomAPI_Shape> theSourceShape,
index 1743e6d66002a356ed77ccf175c202a4613083ab..d7bd12034b003a410bc56838cce87ee3a9071342 100644 (file)
@@ -78,10 +78,42 @@ public:
                      double theRadius) throw (GeomAlgoAPI_Exception);
 
   /// Creates a sphere using the origin and a radius.
-  /// \param theRadius The radius of the cylinder
+  /// \param theRadius The radius of the sphere
   static std::shared_ptr<GeomAPI_Shape> makeSphere(double theRadius)
                      throw (GeomAlgoAPI_Exception);
 
+  /// Creates a torus using a base point, an axis, a radius and a ring radius.
+  /// \param theBasePoint The center of the torus
+  /// \param theEdge The axis of the torus
+  /// \param theRadius The radius of the torus
+  /// \param theRingRadius The ring radius of the torus
+  static std::shared_ptr<GeomAPI_Shape> makeTorus(std::shared_ptr<GeomAPI_Pnt> theBasePoint,
+                     std::shared_ptr<GeomAPI_Edge> theEdge, double theRadius, double theRingRadius)
+                     throw (GeomAlgoAPI_Exception);
+
+  /// Creates a torus using a radius and a ring radius.
+  /// \param theRadius The radius of the torus
+  /// \param theRingRadius The ring radius of the torus
+  static std::shared_ptr<GeomAPI_Shape> makeTorus(double theRadius, double theRingRadius)
+                     throw (GeomAlgoAPI_Exception);
+
+  /// Creates a cone using a base point, an axis, a base radius, a top radius and a height.
+  /// \param theBasePoint The center of the lower base of the cone
+  /// \param theEdge The axis of the cone
+  /// \param theBaseRadius The base radius of the cone
+  /// \param theTopRadius The top radius of the cone
+  /// \param theHeight The height of the cone
+  static std::shared_ptr<GeomAPI_Shape> makeCone(std::shared_ptr<GeomAPI_Pnt> theBasePoint,
+                     std::shared_ptr<GeomAPI_Edge> theEdge, double theBaseRadius,
+                     double theTopRadius, double theHeight) throw (GeomAlgoAPI_Exception);
+
+  /// Creates a cone using a base radius, a top radius and a height.
+  /// \param theBaseRadius The base radius of the cone
+  /// \param theTopRadius The top radius of the cone
+  /// \param theHeight The height of the cone
+  static std::shared_ptr<GeomAPI_Shape> makeCone(double theBaseRadius, double theTopRadius,
+                     double theHeight) throw (GeomAlgoAPI_Exception);
+
   /// Performs a translation from an axis and a distance.
   /// \param theSourceShape Shape to be moved
   /// \param theAxis Movement axis
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Torus.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Torus.cpp
new file mode 100644 (file)
index 0000000..3bc0653
--- /dev/null
@@ -0,0 +1,78 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAlgoAPI_Torus.cpp
+// Created:     20 Mar 2017
+// Author:      Clarisse Genrault (CEA)
+
+#include <GeomAlgoAPI_Torus.h>
+
+#include <gp_Ax2.hxx>
+
+#include <BRepPrimAPI_MakeTorus.hxx>
+
+//=================================================================================================
+GeomAlgoAPI_Torus::GeomAlgoAPI_Torus()
+{
+}
+
+//=================================================================================================
+GeomAlgoAPI_Torus::GeomAlgoAPI_Torus(std::shared_ptr<GeomAPI_Ax2> theAxis,
+                                     const double theRadius,
+                                     const double theRingRadius)
+{
+  myAxis = theAxis;
+  myRadius = theRadius;
+  myRingRadius = theRingRadius;
+}
+
+//=================================================================================================
+bool GeomAlgoAPI_Torus::check()
+{
+  if (!myAxis) {
+    myError = "Torus builder :: axis is not valid.";
+    return false;
+  } else if (myRadius < Precision::Confusion()) {
+    myError = "Torus builder :: radius is negative or null.";
+    return false;
+  } else if (myRingRadius < Precision::Confusion()) {
+    myError = "Torus builder :: ring radius is negative or null.";
+    return false;
+  } else if (myRadius < myRingRadius) {
+    myError = "Torus builder :: ring radius is greater than the radius.";
+    return false;
+  }
+  return true;
+}
+
+//=================================================================================================
+void GeomAlgoAPI_Torus::build()
+{
+  myCreatedFaces.clear();
+
+  const gp_Ax2& anAxis = myAxis->impl<gp_Ax2>();
+
+  // Construct the torus
+  BRepPrimAPI_MakeTorus *aTorusMaker =
+    new BRepPrimAPI_MakeTorus(anAxis, myRadius, myRingRadius);
+
+  aTorusMaker->Build();
+
+  if (!aTorusMaker->IsDone()) {
+    return;
+  }
+
+  TopoDS_Shape aResult = aTorusMaker->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 = "Torus builder :: resulting shape is null.";
+    return;
+  }
+
+  setImpl(aTorusMaker);
+
+  setDone(true);
+}
\ No newline at end of file
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Torus.h b/src/GeomAlgoAPI/GeomAlgoAPI_Torus.h
new file mode 100644 (file)
index 0000000..10f66f5
--- /dev/null
@@ -0,0 +1,43 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        GeomAlgoAPI_Torus.h
+// Created:     20 Mar 2017
+// Author:      Clarisse Genrault (CEA)
+
+#ifndef GEOMALGOAPI_TORUS_H_
+#define GEOMALGOAPI_TORUS_H_
+
+#include <GeomAlgoAPI_MakeShape.h>
+
+#include <GeomAPI_Ax2.h>
+
+/**\class GeomAlgoAPI_Torus
+ * \ingroup DataAlgo
+ * \brief Allows to create Torus Primitives
+ */
+class GeomAlgoAPI_Torus : public GeomAlgoAPI_MakeShape
+{
+ public:
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_Torus();
+
+  /// Creates a torus.
+  /// \param theAxis The axis of the torus
+  /// \param theRadius The radius of the torus
+  /// \param theRingRadius The ring radius of the torus
+  GEOMALGOAPI_EXPORT GeomAlgoAPI_Torus(std::shared_ptr<GeomAPI_Ax2> theAxis,
+                                       const double theRadius,
+                                       const double theRingRadius);
+
+  /// Checks if data for the torus construction is OK.
+  GEOMALGOAPI_EXPORT bool check();
+
+  /// Builds the torus.
+  GEOMALGOAPI_EXPORT void build();
+
+ private:
+  std::shared_ptr<GeomAPI_Ax2> myAxis; /// Axis of the torus.
+  double myRadius; /// Radius of the torus.
+  double myRingRadius; /// Ring radius of the torus.
+};
+
+#endif // GEOMALGOAPI_TORUS_H_
\ No newline at end of file
index cbe3c9aade2871a784d144bcdac7b28f6053bbc2..83a1426f38ccd73e4d5e5f413e66995adf121b95 100644 (file)
@@ -5,14 +5,18 @@ INCLUDE(Common)
 SET(PROJECT_HEADERS
   PrimitivesAPI.h
   PrimitivesAPI_Box.h
+  PrimitivesAPI_Cone.h
   PrimitivesAPI_Cylinder.h
   PrimitivesAPI_Sphere.h
+  PrimitivesAPI_Torus.h
 )
 
 SET(PROJECT_SOURCES
   PrimitivesAPI_Box.cpp
+  PrimitivesAPI_Cone.cpp
   PrimitivesAPI_Cylinder.cpp
   PrimitivesAPI_Sphere.cpp
+  PrimitivesAPI_Torus.cpp
 )
 
 SET(PROJECT_LIBRARIES
index d708a40cdb3fb03ba69749d71af49bae15240996..1651b0788774a8ba6bb0692225a655d3453d6b3a 100644 (file)
 
 // shared pointers
 %shared_ptr(PrimitivesAPI_Box)
+%shared_ptr(PrimitivesAPI_Cone)
 %shared_ptr(PrimitivesAPI_Cylinder)
 %shared_ptr(PrimitivesAPI_Sphere)
+%shared_ptr(PrimitivesAPI_Torus)
 
 // all supported interfaces
 %include "PrimitivesAPI_Box.h"
+%include "PrimitivesAPI_Cone.h"
 %include "PrimitivesAPI_Cylinder.h"
 %include "PrimitivesAPI_Sphere.h"
+%include "PrimitivesAPI_Torus.h"
diff --git a/src/PrimitivesAPI/PrimitivesAPI_Cone.cpp b/src/PrimitivesAPI/PrimitivesAPI_Cone.cpp
new file mode 100644 (file)
index 0000000..da564cc
--- /dev/null
@@ -0,0 +1,105 @@
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
+
+// File:        PrimitivesAPI_Cone.cpp
+// Created:     20 Mar 2017
+// Author:      Clarisse Genrault
+
+#include "PrimitivesAPI_Cone.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Selection.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+PrimitivesAPI_Cone::PrimitivesAPI_Cone(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+//==================================================================================================
+PrimitivesAPI_Cone::PrimitivesAPI_Cone(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                       const ModelHighAPI_Selection& theBasePoint,
+                                       const ModelHighAPI_Selection& theAxis,
+                                       const ModelHighAPI_Double& theBaseRadius,
+                                       const ModelHighAPI_Double& theTopRadius,
+                                       const ModelHighAPI_Double& theHeight)
+: ModelHighAPI_Interface(theFeature)
+{
+  if (initialize()) {
+    fillAttribute(theBasePoint, basePoint());
+    fillAttribute(theAxis, axis());
+    fillAttribute(theBaseRadius, baseRadius());
+    fillAttribute(theTopRadius, topRadius());
+    setHeight(theHeight);
+  }
+}
+
+//==================================================================================================
+PrimitivesAPI_Cone::~PrimitivesAPI_Cone()
+{
+}
+
+//==================================================================================================
+void PrimitivesAPI_Cone::setRadius(const ModelHighAPI_Double& theBaseRadius,
+                                   const ModelHighAPI_Double& theTopRadius)
+{
+  fillAttribute(theBaseRadius, baseRadius());
+  fillAttribute(theTopRadius, topRadius());
+  execute();
+}
+
+//==================================================================================================
+void PrimitivesAPI_Cone::setHeight(const ModelHighAPI_Double& theHeight)
+{
+  fillAttribute(theHeight, height());
+  execute();
+}
+
+//==================================================================================================
+void PrimitivesAPI_Cone::dump(ModelHighAPI_Dumper& theDumper) const
+{
+  FeaturePtr aBase = feature();
+  const std::string& aDocName = theDumper.name(aBase->document());
+
+  theDumper << aBase << " = model.addCone(" << aDocName;
+
+  AttributeSelectionPtr anAttrBasePoint =
+      aBase->selection(PrimitivesPlugin_Cone::BASE_POINT_ID());
+  AttributeSelectionPtr anAttrAxis =
+      aBase->selection(PrimitivesPlugin_Cone::AXIS_ID());
+  theDumper << ", " << anAttrBasePoint << ", " << anAttrAxis;
+
+  AttributeDoublePtr anAttrBaseRadius = aBase->real(PrimitivesPlugin_Cone::BASE_RADIUS_ID());
+  AttributeDoublePtr anAttrTopRadius = aBase->real(PrimitivesPlugin_Cone::TOP_RADIUS_ID());
+  AttributeDoublePtr anAttrHeight = aBase->real(PrimitivesPlugin_Cone::HEIGHT_ID());
+  theDumper << ", " << anAttrBaseRadius << ", " << anAttrTopRadius << ", " << anAttrHeight;
+
+  theDumper << ")" << std::endl;
+}
+
+//==================================================================================================
+ConePtr addCone(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const ModelHighAPI_Selection& theBasePoint,
+                const ModelHighAPI_Selection& theAxis,
+                const ModelHighAPI_Double& theBaseRadius,
+                const ModelHighAPI_Double& theTopRadius,
+                const ModelHighAPI_Double& theHeight)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cone::ID());
+  return ConePtr(new PrimitivesAPI_Cone(aFeature, theBasePoint, theAxis, theBaseRadius,
+                                        theTopRadius, theHeight));
+}
+
+//==================================================================================================
+ConePtr addCone(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const ModelHighAPI_Double& theBaseRadius,
+                const ModelHighAPI_Double& theTopRadius,
+                const ModelHighAPI_Double& theHeight)
+{
+  ModelHighAPI_Selection aBasePoint("VERTEX", "PartSet/Origin");
+  ModelHighAPI_Selection anAxis("EDGE", "PartSet/OZ");
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cone::ID());
+  return ConePtr(new PrimitivesAPI_Cone(aFeature, aBasePoint, anAxis, theBaseRadius,
+                                        theTopRadius, theHeight));
+}
\ No newline at end of file
diff --git a/src/PrimitivesAPI/PrimitivesAPI_Cone.h b/src/PrimitivesAPI/PrimitivesAPI_Cone.h
new file mode 100644 (file)
index 0000000..a83f78a
--- /dev/null
@@ -0,0 +1,90 @@
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
+
+// File:        PrimitivesAPI_Cone.h
+// Created:     20 Mar 2017
+// Author:      Clarisse Genrault
+
+#ifndef PRIMITIVESAPI_CONE_H_
+#define PRIMITIVESAPI_CONE_H_
+
+#include "PrimitivesAPI.h"
+
+#include <PrimitivesPlugin_Cone.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Double;
+class ModelHighAPI_Selection;
+
+/// \class PrimitivesAPI_Cone
+/// \ingroup CPPHighAPI
+/// \brief Interface for primitive Cone feature.
+class PrimitivesAPI_Cone: public ModelHighAPI_Interface
+{
+public:
+  /// Constructor without values.
+  PRIMITIVESAPI_EXPORT
+  explicit PrimitivesAPI_Cone(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+  /// Constructor with values.
+  PRIMITIVESAPI_EXPORT
+  explicit PrimitivesAPI_Cone(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                              const ModelHighAPI_Selection& theBasePoint,
+                              const ModelHighAPI_Selection& theAxis,
+                              const ModelHighAPI_Double& theBaseRadius,
+                              const ModelHighAPI_Double& theTopRadius,
+                              const ModelHighAPI_Double& theHeight);
+
+  /// Destructor.
+  PRIMITIVESAPI_EXPORT
+  virtual ~PrimitivesAPI_Cone();
+
+  INTERFACE_5(PrimitivesPlugin_Cone::ID(),
+             basePoint, PrimitivesPlugin_Cone::BASE_POINT_ID(),
+             ModelAPI_AttributeSelection, /** Base point */,
+             axis, PrimitivesPlugin_Cone::AXIS_ID(),
+             ModelAPI_AttributeSelection, /** Axis */,
+             baseRadius, PrimitivesPlugin_Cone::BASE_RADIUS_ID(),
+             ModelAPI_AttributeDouble, /** Base radius */,
+             topRadius, PrimitivesPlugin_Cone::TOP_RADIUS_ID(),
+             ModelAPI_AttributeDouble, /** Top radius */,
+             height, PrimitivesPlugin_Cone::HEIGHT_ID(),
+             ModelAPI_AttributeDouble, /** Height */)
+
+  /// Set radius
+  PRIMITIVESAPI_EXPORT
+  void setRadius(const ModelHighAPI_Double& theBaseRadius,
+                 const ModelHighAPI_Double& theTopRadius);
+
+  /// Set height
+  PRIMITIVESAPI_EXPORT
+  void setHeight(const ModelHighAPI_Double& theHeight);
+
+  /// Dump wrapped feature
+  PRIMITIVESAPI_EXPORT
+  virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on primitive Cone object
+typedef std::shared_ptr<PrimitivesAPI_Cone> ConePtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create primitive Cone feature.
+PRIMITIVESAPI_EXPORT
+ConePtr addCone(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const ModelHighAPI_Selection& theBasePoint,
+                const ModelHighAPI_Selection& theAxis,
+                const ModelHighAPI_Double& theBaseRadius,
+                const ModelHighAPI_Double& theTopRadius,
+                const ModelHighAPI_Double& theHeight);
+
+/// \ingroup CPPHighAPI
+/// \brief Create primitive Cone feature.
+PRIMITIVESAPI_EXPORT
+ConePtr addCone(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const ModelHighAPI_Double& theBaseRadius,
+                const ModelHighAPI_Double& theTopRadius,
+                const ModelHighAPI_Double& theHeight);
+
+#endif // PRIMITIVESAPI_CONE_H_
index eaba588f7489a1e617304d065aa03372acfa6952..dc8b6aba6b36e17bc208617183f8c07c24ebe4b6 100644 (file)
@@ -19,14 +19,14 @@ PrimitivesAPI_Sphere::PrimitivesAPI_Sphere(const std::shared_ptr<ModelAPI_Featur
 
 //==================================================================================================
 PrimitivesAPI_Sphere::PrimitivesAPI_Sphere(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                                                      const ModelHighAPI_Selection& theCenterPoint,
-                                                      const ModelHighAPI_Double& theRadius)
+                                           const ModelHighAPI_Selection& theCenterPoint,
+                                           const ModelHighAPI_Double& theRadius)
 : ModelHighAPI_Interface(theFeature)
 {
-       if (initialize()) {
-         fillAttribute(theCenterPoint, centerPoint());
-         setRadius(theRadius);
-       }
+  if (initialize()) {
+    fillAttribute(theCenterPoint, centerPoint());
+    setRadius(theRadius);
+  }
 }
 
 //==================================================================================================
diff --git a/src/PrimitivesAPI/PrimitivesAPI_Torus.cpp b/src/PrimitivesAPI/PrimitivesAPI_Torus.cpp
new file mode 100644 (file)
index 0000000..825c2b9
--- /dev/null
@@ -0,0 +1,91 @@
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
+
+// File:        PrimitivesAPI_Torus.cpp
+// Created:     20 Mar 2017
+// Author:      Clarisse Genrault
+
+#include "PrimitivesAPI_Torus.h"
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Selection.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+PrimitivesAPI_Torus::PrimitivesAPI_Torus(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+//==================================================================================================
+PrimitivesAPI_Torus::PrimitivesAPI_Torus(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                       const ModelHighAPI_Selection& theBasePoint,
+                                       const ModelHighAPI_Selection& theAxis,
+                                       const ModelHighAPI_Double& theRadius,
+                                       const ModelHighAPI_Double& theRingRadius)
+: ModelHighAPI_Interface(theFeature)
+{
+  if (initialize()) {
+    fillAttribute(theBasePoint, basePoint());
+    fillAttribute(theAxis, axis());
+    setRadius(theRadius, theRingRadius);
+  }
+}
+
+//==================================================================================================
+PrimitivesAPI_Torus::~PrimitivesAPI_Torus()
+{
+}
+
+//==================================================================================================
+void PrimitivesAPI_Torus::setRadius(const ModelHighAPI_Double& theRadius,
+                                    const ModelHighAPI_Double& theRingRadius)
+{
+  fillAttribute(theRadius, radius());
+  fillAttribute(theRingRadius, ringRadius());
+  execute();
+}
+
+//==================================================================================================
+void PrimitivesAPI_Torus::dump(ModelHighAPI_Dumper& theDumper) const
+{
+  FeaturePtr aBase = feature();
+  const std::string& aDocName = theDumper.name(aBase->document());
+
+  theDumper << aBase << " = model.addTorus(" << aDocName;
+
+  AttributeSelectionPtr anAttrBasePoint =
+      aBase->selection(PrimitivesPlugin_Torus::BASE_POINT_ID());
+  AttributeSelectionPtr anAttrAxis =
+      aBase->selection(PrimitivesPlugin_Torus::AXIS_ID());
+  theDumper << ", " << anAttrBasePoint << ", " << anAttrAxis;
+
+  AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Torus::RADIUS_ID());
+  AttributeDoublePtr anAttrRingRadius = aBase->real(PrimitivesPlugin_Torus::RING_RADIUS_ID());
+  theDumper << ", " << anAttrRadius << ", " << anAttrRingRadius;
+
+  theDumper << ")" << std::endl;
+}
+
+//==================================================================================================
+TorusPtr addTorus(const std::shared_ptr<ModelAPI_Document>& thePart,
+                  const ModelHighAPI_Selection& theBasePoint,
+                  const ModelHighAPI_Selection& theAxis,
+                  const ModelHighAPI_Double& theRadius,
+                  const ModelHighAPI_Double& theRingRadius)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Torus::ID());
+  return TorusPtr(new PrimitivesAPI_Torus(aFeature, theBasePoint, theAxis,
+                                          theRadius, theRingRadius));
+}
+
+//==================================================================================================
+TorusPtr addTorus(const std::shared_ptr<ModelAPI_Document>& thePart,
+                  const ModelHighAPI_Double& theRadius,
+                  const ModelHighAPI_Double& theRingRadius)
+{
+  ModelHighAPI_Selection aBasePoint("VERTEX", "PartSet/Origin");
+  ModelHighAPI_Selection anAxis("EDGE", "PartSet/OZ");
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Torus::ID());
+  return TorusPtr(new PrimitivesAPI_Torus(aFeature, aBasePoint, anAxis, theRadius, theRingRadius));
+}
\ No newline at end of file
diff --git a/src/PrimitivesAPI/PrimitivesAPI_Torus.h b/src/PrimitivesAPI/PrimitivesAPI_Torus.h
new file mode 100644 (file)
index 0000000..32c7d10
--- /dev/null
@@ -0,0 +1,81 @@
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
+
+// File:        PrimitivesAPI_Torus.h
+// Created:     20 Mar 2017
+// Author:      Clarisse Genrault
+
+#ifndef PRIMITIVESAPI_TORUS_H_
+#define PRIMITIVESAPI_TORUS_H_
+
+#include "PrimitivesAPI.h"
+
+#include <PrimitivesPlugin_Torus.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Double;
+class ModelHighAPI_Selection;
+
+/// \class PrimitivesAPI_Torus
+/// \ingroup CPPHighAPI
+/// \brief Interface for primitive Cone feature.
+class PrimitivesAPI_Torus: public ModelHighAPI_Interface
+{
+public:
+  /// Constructor without values.
+  PRIMITIVESAPI_EXPORT
+  explicit PrimitivesAPI_Torus(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+  /// Constructor with values.
+  PRIMITIVESAPI_EXPORT
+  explicit PrimitivesAPI_Torus(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                               const ModelHighAPI_Selection& theBasePoint,
+                               const ModelHighAPI_Selection& theAxis,
+                               const ModelHighAPI_Double& theRadius,
+                               const ModelHighAPI_Double& theRingRadius);
+
+  /// Destructor.
+  PRIMITIVESAPI_EXPORT
+  virtual ~PrimitivesAPI_Torus();
+
+  INTERFACE_4(PrimitivesPlugin_Torus::ID(),
+             basePoint, PrimitivesPlugin_Torus::BASE_POINT_ID(),
+             ModelAPI_AttributeSelection, /** Base point */,
+             axis, PrimitivesPlugin_Torus::AXIS_ID(),
+             ModelAPI_AttributeSelection, /** Axis */,
+             radius, PrimitivesPlugin_Torus::RADIUS_ID(),
+             ModelAPI_AttributeDouble, /** Radius */,
+             ringRadius, PrimitivesPlugin_Torus::RING_RADIUS_ID(),
+             ModelAPI_AttributeDouble, /** Ring radius */)
+
+  /// Set radius
+  PRIMITIVESAPI_EXPORT
+  void setRadius(const ModelHighAPI_Double& theRadius,
+                 const ModelHighAPI_Double& theRingRadius);
+
+  /// Dump wrapped feature
+  PRIMITIVESAPI_EXPORT
+  virtual void dump(ModelHighAPI_Dumper& theDumper) const;
+};
+
+/// Pointer on primitive Cone object
+typedef std::shared_ptr<PrimitivesAPI_Torus> TorusPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create primitive Cone feature.
+PRIMITIVESAPI_EXPORT
+TorusPtr addTorus(const std::shared_ptr<ModelAPI_Document>& thePart,
+                  const ModelHighAPI_Selection& theBasePoint,
+                  const ModelHighAPI_Selection& theAxis,
+                  const ModelHighAPI_Double& theRadius,
+                  const ModelHighAPI_Double& theRingRadius);
+
+/// \ingroup CPPHighAPI
+/// \brief Create primitive Cone feature.
+PRIMITIVESAPI_EXPORT
+TorusPtr addTorus(const std::shared_ptr<ModelAPI_Document>& thePart,
+                  const ModelHighAPI_Double& theRadius,
+                  const ModelHighAPI_Double& theRingRadius);
+
+#endif // PRIMITIVESAPI_TORUS_H_
index 04b3e3716152911dc7afd9ecf100baa9b7b61b8a..698317f0368c4b28cf641d5552b7016910ace825 100644 (file)
@@ -11,7 +11,9 @@
 
   #include "PrimitivesAPI.h"
   #include "PrimitivesAPI_Box.h"
+  #include "PrimitivesAPI_Cone.h"
   #include "PrimitivesAPI_Cylinder.h"
   #include "PrimitivesAPI_Sphere.h"
+  #include "PrimitivesAPI_Torus.h"
 
 #endif // PRIMITIVESAPI_SWIG_H_
index 8df0d67db8291933c29821c16aa4e7b920a69cf6..cfbf186098aeab79f2ed4d2a1f8155aa13826252 100644 (file)
@@ -8,22 +8,28 @@ SET(PROJECT_HEADERS
     PrimitivesPlugin.h
     PrimitivesPlugin_Plugin.h
     PrimitivesPlugin_Box.h
+    PrimitivesPlugin_Cone.h
     PrimitivesPlugin_Cylinder.h
     PrimitivesPlugin_Sphere.h
+    PrimitivesPlugin_Torus.h
 )
 
 SET(PROJECT_SOURCES
     PrimitivesPlugin_Plugin.cpp
     PrimitivesPlugin_Box.cpp
+    PrimitivesPlugin_Cone.cpp
     PrimitivesPlugin_Cylinder.cpp
     PrimitivesPlugin_Sphere.cpp
+    PrimitivesPlugin_Torus.cpp
 )
 
 SET(XML_RESOURCES
   plugin-Primitives.xml
   box_widget.xml
+  cone_widget.xml
   cylinder_widget.xml
   sphere_widget.xml
+  torus_widget.xml
 )
 
 INCLUDE_DIRECTORIES(
diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Cone.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Cone.cpp
new file mode 100644 (file)
index 0000000..fba4eb4
--- /dev/null
@@ -0,0 +1,153 @@
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D
+
+// File:        PrimitivesPlugin_Cone.cpp
+// Created:     17 Mar 2017
+// Author:      Clarisse Genrault (CEA)
+
+#include <PrimitivesPlugin_Cone.h>
+
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_Lin.h>
+
+#include <GeomAlgoAPI_PointBuilder.h>
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_Session.h>
+
+//=================================================================================================
+PrimitivesPlugin_Cone::PrimitivesPlugin_Cone()
+{
+}
+
+//=================================================================================================
+void PrimitivesPlugin_Cone::initAttributes()
+{
+  data()->addAttribute(PrimitivesPlugin_Cone::BASE_POINT_ID(),
+                       ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(PrimitivesPlugin_Cone::AXIS_ID(),
+                       ModelAPI_AttributeSelection::typeId());
+
+  data()->addAttribute(PrimitivesPlugin_Cone::BASE_RADIUS_ID(),
+                       ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(PrimitivesPlugin_Cone::TOP_RADIUS_ID(),
+                       ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(PrimitivesPlugin_Cone::HEIGHT_ID(),
+                       ModelAPI_AttributeDouble::typeId());
+
+  // Initialize the base point of the cone at the origin if the base point is not filled.
+  AttributeSelectionPtr aCenterPoint =
+    data()->selection(PrimitivesPlugin_Cone::BASE_POINT_ID());
+  if (!aCenterPoint->isInitialized()) {
+    ObjectPtr aPointObj = ModelAPI_Session::get()->moduleDocument()
+      ->objectByName(ModelAPI_ResultConstruction::group(), "Origin");
+    if (aPointObj.get()) {
+      ResultPtr aPointRes = std::dynamic_pointer_cast<ModelAPI_Result>(aPointObj);
+      aCenterPoint->setValue(aPointRes, std::shared_ptr<GeomAPI_Shape>());
+    }
+  }
+
+  // Initialize the axis at the OZ axis if the axis is not filled.
+  AttributeSelectionPtr anAxis = data()->selection(PrimitivesPlugin_Cone::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_Cone::execute()
+{
+  // Getting base point.
+  std::shared_ptr<GeomAPI_Pnt> aBasePoint;
+  std::shared_ptr<ModelAPI_AttributeSelection> aPointRef =
+    selection(PrimitivesPlugin_Cone::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_Cone::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 base radius, top radius and height
+  double aBaseRadius = real(PrimitivesPlugin_Cone::BASE_RADIUS_ID())->value();
+  double aTopRadius = real(PrimitivesPlugin_Cone::TOP_RADIUS_ID())->value();
+  double aHeight = real(PrimitivesPlugin_Cone::HEIGHT_ID())->value();
+
+  std::shared_ptr<GeomAlgoAPI_Cone> aConeAlgo =
+    std::shared_ptr<GeomAlgoAPI_Cone>(new GeomAlgoAPI_Cone(anAxis,
+                                                           aBaseRadius,
+                                                           aTopRadius,
+                                                           aHeight));
+
+  // These checks should be made to the GUI for the feature but
+  // the corresponding validator does not exist yet.
+  if (!aConeAlgo->check()) {
+    setError(aConeAlgo->getError());
+    return;
+  }
+
+  // Build the sphere
+  aConeAlgo->build();
+
+  // Check if the creation of the cylinder
+  if(!aConeAlgo->isDone()) {
+    setError(aConeAlgo->getError());
+    return;
+  }
+  if(!aConeAlgo->checkValid("Cone builder")) {
+    setError(aConeAlgo->getError());
+    return;
+  }
+
+  int aResultIndex = 0;
+  ResultBodyPtr aResultBox = document()->createBody(data(), aResultIndex);
+  loadNamingDS(aConeAlgo, aResultBox);
+  setResult(aResultBox, aResultIndex);
+}
+
+//=================================================================================================
+void PrimitivesPlugin_Cone::loadNamingDS(std::shared_ptr<GeomAlgoAPI_Cone> theConeAlgo,
+                                         std::shared_ptr<ModelAPI_ResultBody> theResultCone)
+{
+  // Load the result
+  theResultCone->store(theConeAlgo->shape());
+
+  // Prepare the naming
+  theConeAlgo->prepareNamingFaces();
+
+  // Insert to faces
+  int num = 1;
+  std::map< std::string, std::shared_ptr<GeomAPI_Shape> > listOfFaces =
+      theConeAlgo->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;
+    theResultCone->generated(aFace, (*it).first, num++);
+  }
+}
\ No newline at end of file
diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Cone.h b/src/PrimitivesPlugin/PrimitivesPlugin_Cone.h
new file mode 100644 (file)
index 0000000..9cbc0b1
--- /dev/null
@@ -0,0 +1,88 @@
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D
+
+// File:        PrimitivesPlugin_Cone.h
+// Created:     17 Mar 2017
+// Author:      Clarisse Genrault (CEA)
+
+#ifndef PRIMITIVESPLUGIN_CONE_H_
+#define PRIMITIVESPLUGIN_CONE_H_
+
+#include <PrimitivesPlugin.h>
+#include <ModelAPI_Feature.h>
+#include <GeomAlgoAPI_Cone.h>
+
+/**\class PrimitivesPlugin_Cone
+ * \ingroup Plugins
+ * \brief Feature for creation of a cone.
+ *
+ * Creates a cone from a 
+ */
+class PrimitivesPlugin_Cone : public ModelAPI_Feature
+{
+ public:
+  /// Cone kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_CONE_ID("Cone");
+    return MY_CONE_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 base radius
+  inline static const std::string& BASE_RADIUS_ID()
+  {
+    static const std::string MY_BASE_RADIUS_ID("base_radius");
+    return MY_BASE_RADIUS_ID;
+  }
+
+  /// Attribute name of the radius
+  inline static const std::string& TOP_RADIUS_ID()
+  {
+    static const std::string MY_TOP_RADIUS_ID("top_radius");
+    return MY_TOP_RADIUS_ID;
+  }
+
+  /// Attribute name of the radius
+  inline static const std::string& HEIGHT_ID()
+  {
+    static const std::string MY_HEIGHT_ID("height");
+    return MY_HEIGHT_ID;
+  }
+
+  /// Returns the kind of a feature
+  PRIMITIVESPLUGIN_EXPORT virtual const std::string& getKind()
+  {
+    static std::string MY_KIND = PrimitivesPlugin_Cone::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_Cone();
+
+ private:
+  /// Load Naming data structure of the feature to the document
+  void loadNamingDS(std::shared_ptr<GeomAlgoAPI_Cone> theConeAlgo,
+                    std::shared_ptr<ModelAPI_ResultBody> theResultCone);
+
+};
+
+#endif // PRIMITIVESPLUGIN_CONE_H_
index 36c77fa8a64cb7e172bbd753b71422baefb32b0c..8db8d5d167a3f41202f9535e4b1e02af089db6e2 100644 (file)
@@ -7,8 +7,10 @@
 #include <PrimitivesPlugin_Plugin.h>
 
 #include <PrimitivesPlugin_Box.h>
+#include <PrimitivesPlugin_Cone.h>
 #include <PrimitivesPlugin_Cylinder.h>
 #include <PrimitivesPlugin_Sphere.h>
+#include <PrimitivesPlugin_Torus.h>
 
 #include <ModelAPI_Session.h>
 
@@ -29,10 +31,14 @@ FeaturePtr PrimitivesPlugin_Plugin::createFeature(std::string theFeatureID)
 {
   if (theFeatureID == PrimitivesPlugin_Box::ID()) {
     return FeaturePtr(new PrimitivesPlugin_Box);
+  } else if (theFeatureID == PrimitivesPlugin_Cone::ID()) {
+    return FeaturePtr(new PrimitivesPlugin_Cone);
   } else if (theFeatureID == PrimitivesPlugin_Cylinder::ID()) {
     return FeaturePtr(new PrimitivesPlugin_Cylinder);
   } else if (theFeatureID == PrimitivesPlugin_Sphere::ID()) {
     return FeaturePtr(new PrimitivesPlugin_Sphere);
+  } else if (theFeatureID == PrimitivesPlugin_Torus::ID()) {
+    return FeaturePtr(new PrimitivesPlugin_Torus);
   }
   // feature of such kind is not found
   return FeaturePtr();
diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Torus.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Torus.cpp
new file mode 100644 (file)
index 0000000..817714a
--- /dev/null
@@ -0,0 +1,149 @@
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D
+
+// File:        PrimitivesPlugin_Torus.cpp
+// Created:     17 Mar 2017
+// Author:      Clarisse Genrault (CEA)
+
+#include <PrimitivesPlugin_Torus.h>
+
+#include <GeomAPI_Edge.h>
+#include <GeomAPI_Lin.h>
+
+#include <GeomAlgoAPI_PointBuilder.h>
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeSelection.h>
+#include <ModelAPI_ResultBody.h>
+#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_Session.h>
+
+//=================================================================================================
+PrimitivesPlugin_Torus::PrimitivesPlugin_Torus()
+{
+}
+
+//=================================================================================================
+void PrimitivesPlugin_Torus::initAttributes()
+{
+  data()->addAttribute(PrimitivesPlugin_Torus::BASE_POINT_ID(),
+                       ModelAPI_AttributeSelection::typeId());
+  data()->addAttribute(PrimitivesPlugin_Torus::AXIS_ID(),
+                       ModelAPI_AttributeSelection::typeId());
+
+  data()->addAttribute(PrimitivesPlugin_Torus::RADIUS_ID(),
+                       ModelAPI_AttributeDouble::typeId());
+  data()->addAttribute(PrimitivesPlugin_Torus::RING_RADIUS_ID(),
+                       ModelAPI_AttributeDouble::typeId());
+
+  // Initialize the base point of the torus at the origin if the base point is not filled.
+  AttributeSelectionPtr aCenterPoint =
+    data()->selection(PrimitivesPlugin_Torus::BASE_POINT_ID());
+  if (!aCenterPoint->isInitialized()) {
+    ObjectPtr aPointObj = ModelAPI_Session::get()->moduleDocument()
+      ->objectByName(ModelAPI_ResultConstruction::group(), "Origin");
+    if (aPointObj.get()) {
+      ResultPtr aPointRes = std::dynamic_pointer_cast<ModelAPI_Result>(aPointObj);
+      aCenterPoint->setValue(aPointRes, std::shared_ptr<GeomAPI_Shape>());
+    }
+  }
+
+  // Initialize the axis at the OZ axis if the axis is not filled.
+  AttributeSelectionPtr anAxis = data()->selection(PrimitivesPlugin_Torus::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_Torus::execute()
+{
+  // Getting base point.
+  std::shared_ptr<GeomAPI_Pnt> aBasePoint;
+  std::shared_ptr<ModelAPI_AttributeSelection> aPointRef =
+    selection(PrimitivesPlugin_Torus::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_Torus::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 ring radius
+  double aRadius = real(PrimitivesPlugin_Torus::RADIUS_ID())->value();
+  double aRingRadius = real(PrimitivesPlugin_Torus::RING_RADIUS_ID())->value();
+
+  std::shared_ptr<GeomAlgoAPI_Torus> aTorusAlgo =
+    std::shared_ptr<GeomAlgoAPI_Torus>(new GeomAlgoAPI_Torus(anAxis,
+                                                             aRadius,
+                                                             aRingRadius));
+
+  // These checks should be made to the GUI for the feature but
+  // the corresponding validator does not exist yet.
+  if (!aTorusAlgo->check()) {
+    setError(aTorusAlgo->getError());
+    return;
+  }
+
+  // Build the sphere
+  aTorusAlgo->build();
+
+  // Check if the creation of the cylinder
+  if(!aTorusAlgo->isDone()) {
+    setError(aTorusAlgo->getError());
+    return;
+  }
+  if(!aTorusAlgo->checkValid("Torus builder")) {
+    setError(aTorusAlgo->getError());
+    return;
+  }
+
+  int aResultIndex = 0;
+  ResultBodyPtr aResultBox = document()->createBody(data(), aResultIndex);
+  loadNamingDS(aTorusAlgo, aResultBox);
+  setResult(aResultBox, aResultIndex);
+}
+
+//=================================================================================================
+void PrimitivesPlugin_Torus::loadNamingDS(std::shared_ptr<GeomAlgoAPI_Torus> theTorusAlgo,
+                                          std::shared_ptr<ModelAPI_ResultBody> theResultTorus)
+{
+  // Load the result
+  theResultTorus->store(theTorusAlgo->shape());
+
+  // Prepare the naming
+  theTorusAlgo->prepareNamingFaces();
+
+  // Insert to faces
+  int num = 1;
+  std::map< std::string, std::shared_ptr<GeomAPI_Shape> > listOfFaces =
+      theTorusAlgo->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;
+    theResultTorus->generated(aFace, (*it).first, num++);
+  }
+}
\ No newline at end of file
diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Torus.h b/src/PrimitivesPlugin/PrimitivesPlugin_Torus.h
new file mode 100644 (file)
index 0000000..69ea8bf
--- /dev/null
@@ -0,0 +1,81 @@
+// Copyright (C) 2014-201x CEA/DEN, EDF R&D
+
+// File:        PrimitivesPlugin_Torus.h
+// Created:     17 Mar 2017
+// Author:      Clarisse Genrault (CEA)
+
+#ifndef PRIMITIVESPLUGIN_TORUS_H_
+#define PRIMITIVESPLUGIN_TORUS_H_
+
+#include <PrimitivesPlugin.h>
+#include <ModelAPI_Feature.h>
+#include <GeomAlgoAPI_Torus.h>
+
+/**\class PrimitivesPlugin_Torus
+ * \ingroup Plugins
+ * \brief Feature for creation of a torus.
+ *
+ * Creates a torus from a 
+ */
+class PrimitivesPlugin_Torus : public ModelAPI_Feature
+{
+ public:
+  /// Torus kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_TORUS_ID("Torus");
+    return MY_TORUS_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 section radius
+  inline static const std::string& RING_RADIUS_ID()
+  {
+    static const std::string MY_RING_RADIUS_ID("ring_radius");
+    return MY_RING_RADIUS_ID;
+  }
+
+  /// Returns the kind of a feature
+  PRIMITIVESPLUGIN_EXPORT virtual const std::string& getKind()
+  {
+    static std::string MY_KIND = PrimitivesPlugin_Torus::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_Torus();
+
+ private:
+  /// Load Naming data structure of the feature to the document
+  void loadNamingDS(std::shared_ptr<GeomAlgoAPI_Torus> theTorusAlgo,
+                    std::shared_ptr<ModelAPI_ResultBody> theResultTorus);
+
+};
+
+#endif // PRIMITIVESPLUGIN_TORUS_H_
diff --git a/src/PrimitivesPlugin/cone_widget.xml b/src/PrimitivesPlugin/cone_widget.xml
new file mode 100644 (file)
index 0000000..4f1acd5
--- /dev/null
@@ -0,0 +1,46 @@
+<!-- Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
+
+<source>
+  <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 cone">
+    <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 cone">
+    <validator id="GeomValidators_ConstructionComposite"/>
+    <validator id="GeomValidators_ShapeType" parameters="line"/>
+  </shape_selector>
+  <doublevalue
+    id="base_radius"
+    label="Base radius"
+    step="1."
+    default="10."
+    tooltip="Enter the base radius of the cone">
+  </doublevalue>
+  <doublevalue
+    id="top_radius"
+    label="Top radius"
+    step="1."
+    default="5."
+    tooltip="Enter the top radius of the cone">
+  </doublevalue>
+  <doublevalue
+    id="height"
+    label="height"
+    step="1."
+    default="10."
+    icon="icons/Primitives/dimension_v.png"
+    tooltip="Enter the height of the cone">
+  </doublevalue>
+</source>
\ No newline at end of file
diff --git a/src/PrimitivesPlugin/icons/SVG/cone.svg b/src/PrimitivesPlugin/icons/SVG/cone.svg
new file mode 100644 (file)
index 0000000..bcf82d6
--- /dev/null
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   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="svg4157"
+   version="1.1"
+   inkscape:version="0.91 r13725"
+   viewBox="0 0 16 16"
+   sodipodi:docname="cone.svg"
+   inkscape:export-filename="/export/home/ldigallo/DOC_ALYOTECH/icones/Primitives/cone.png"
+   inkscape:export-xdpi="90"
+   inkscape:export-ydpi="90">
+  <defs
+     id="defs4159" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="44.791208"
+     inkscape:cx="10.619534"
+     inkscape:cy="7.8334642"
+     inkscape:current-layer="layer1"
+     showgrid="true"
+     inkscape:grid-bbox="true"
+     inkscape:document-units="px"
+     showguides="true"
+     inkscape:snap-others="true"
+     inkscape:snap-nodes="false"
+     inkscape:snap-object-midpoints="false"
+     inkscape:snap-center="true"
+     inkscape:snap-text-baseline="false"
+     inkscape:object-nodes="true"
+     inkscape:snap-smooth-nodes="true"
+     inkscape:snap-intersection-paths="true"
+     inkscape:snap-page="false"
+     inkscape:snap-grids="false"
+     inkscape:object-paths="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="grid4705" />
+  </sodipodi:namedview>
+  <metadata
+     id="metadata4162">
+    <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="g4140"
+       transform="matrix(0.48922312,0,0,0.49910601,0.29944485,16.003478)">
+      <ellipse
+         ry="2.0393512"
+         rx="3.7681725"
+         cy="4.1903658"
+         cx="15.684584"
+         id="path4707"
+         style="fill:#000000;fill-opacity:1;stroke:#1b4955;stroke-width:4.19104528;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+      <path
+         sodipodi:open="true"
+         d="m 27.924641,24.480045 a 12.381138,4.5885401 0 0 1 -5.389494,4.630461 12.381138,4.5885401 0 0 1 -13.6070929,0 12.381138,4.5885401 0 0 1 -5.3894938,-4.630461"
+         sodipodi:end="3.3161256"
+         sodipodi:start="6.1086524"
+         sodipodi:ry="4.5885401"
+         sodipodi:rx="12.381138"
+         sodipodi:cy="25.276836"
+         sodipodi:cx="15.731601"
+         sodipodi:type="arc"
+         id="path4713"
+         style="fill:none;fill-opacity:1;stroke:#1b4955;stroke-width:4.19104528;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+      <path
+         inkscape:connector-curvature="0"
+         id="path4786"
+         d="M 11.916411,4.190366 3.5058978,24.55204"
+         style="fill:none;fill-rule:evenodd;stroke:#1b4955;stroke-width:4.19099998;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+      <path
+         inkscape:connector-curvature="0"
+         id="path4788"
+         d="m 19.452756,4.190366 8.523265,20.406455"
+         style="fill:none;fill-rule:evenodd;stroke:#1b4955;stroke-width:4.19104528;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+      <path
+         inkscape:connector-curvature="0"
+         id="path4792"
+         d="M 14.290381,28.788695 C 10.180956,28.613169 6.4375964,27.579732 5.0085088,26.226233 4.6609485,25.897057 4.4594815,25.552368 4.4594815,25.286905 c 0,-0.138879 0.9795392,-2.55794 3.8491936,-9.505936 2.1170569,-5.125808 3.8663729,-9.3363317 3.8873699,-9.356719 0.021,-0.020387 0.142544,0.025619 0.270103,0.1022359 0.127559,0.076617 0.427949,0.2108717 0.667533,0.2983439 0.917499,0.3349788 1.766737,0.459885 2.862003,0.4209446 1.069767,-0.038034 1.89748,-0.229734 2.734381,-0.6332892 0.250542,-0.1208116 0.45974,-0.2144914 0.464884,-0.2081775 0.0052,0.00631 1.764658,4.2160153 3.910029,9.3548903 2.91379,6.979495 3.900674,9.39029 3.900674,9.528701 0,0.578492 -0.809317,1.319189 -2.086026,1.909156 -1.978433,0.914234 -4.683823,1.458828 -7.928702,1.596046 -1.178869,0.04985 -1.440285,0.04942 -2.700543,-0.0044 l 0,-3e-6 z"
+         style="fill:#b7d9ea;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+      <ellipse
+         ry="1.8799957"
+         rx="3.5278082"
+         cy="3.3025274"
+         cx="15.636511"
+         id="path4707-9"
+         style="fill:#b7d9ea;fill-opacity:1;stroke:none;stroke-width:4;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+    </g>
+  </g>
+</svg>
diff --git a/src/PrimitivesPlugin/icons/SVG/torus.svg b/src/PrimitivesPlugin/icons/SVG/torus.svg
new file mode 100644 (file)
index 0000000..1f4e436
--- /dev/null
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   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="svg4700"
+   version="1.1"
+   inkscape:version="0.91 r13725"
+   viewBox="0 0 16 16"
+   sodipodi:docname="torus.svg"
+   inkscape:export-filename="/export/home/ldigallo/DOC_ALYOTECH/icones/Primitives/torus.png"
+   inkscape:export-xdpi="90"
+   inkscape:export-ydpi="90">
+  <defs
+     id="defs4702">
+    <marker
+       inkscape:stockid="Arrow1Lstart"
+       orient="auto"
+       refY="0"
+       refX="0"
+       id="marker4450"
+       style="overflow:visible"
+       inkscape:isstock="true">
+      <path
+         id="path4452"
+         d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+         style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
+         transform="matrix(0.8,0,0,0.8,10,0)"
+         inkscape:connector-curvature="0" />
+    </marker>
+    <marker
+       inkscape:stockid="Arrow1Lstart"
+       orient="auto"
+       refY="0"
+       refX="0"
+       id="marker4434"
+       style="overflow:visible"
+       inkscape:isstock="true">
+      <path
+         id="path4436"
+         d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+         style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
+         transform="matrix(0.8,0,0,0.8,10,0)"
+         inkscape:connector-curvature="0" />
+    </marker>
+    <marker
+       inkscape:stockid="Arrow1Lstart"
+       orient="auto"
+       refY="0"
+       refX="0"
+       id="Arrow1Lstart"
+       style="overflow:visible"
+       inkscape:isstock="true">
+      <path
+         id="path4170"
+         d="M 0,0 5,-5 -12.5,0 5,5 0,0 Z"
+         style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
+         transform="matrix(0.8,0,0,0.8,10,0)"
+         inkscape:connector-curvature="0" />
+    </marker>
+  </defs>
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="42.71875"
+     inkscape:cx="7.4081323"
+     inkscape:cy="8.3624015"
+     inkscape:current-layer="layer1"
+     showgrid="true"
+     inkscape:grid-bbox="true"
+     inkscape:document-units="px"
+     showguides="true"
+     inkscape:snap-object-midpoints="false"
+     inkscape:snap-center="true"
+     inkscape:window-width="1920"
+     inkscape:window-height="1006"
+     inkscape:window-x="0"
+     inkscape:window-y="25"
+     inkscape:window-maximized="1"
+     inkscape:snap-others="true"
+     inkscape:snap-nodes="false"
+     inkscape:snap-grids="false"
+     inkscape:showpageshadow="false"
+     showborder="true">
+    <inkscape:grid
+       type="xygrid"
+       id="grid5248" />
+  </sodipodi:namedview>
+  <metadata
+     id="metadata4705">
+    <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="g4179"
+       transform="matrix(1,0,0,1.1022834,-0.04681784,-2.5396163)">
+      <ellipse
+         ry="2.1029613"
+         rx="2.5721776"
+         cy="24.088104"
+         cx="8.0245848"
+         id="path5250"
+         style="fill:none;fill-opacity:1;stroke:#1b4955;stroke-width:2.28365493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+      <ellipse
+         ry="5.5472407"
+         rx="6.7849512"
+         cy="24.088104"
+         cx="8.0245848"
+         id="path5250-7"
+         style="opacity:1;fill:none;fill-opacity:1;stroke:#1b4955;stroke-width:2.28365493;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
+      <path
+         inkscape:connector-curvature="0"
+         id="path4163"
+         d="M 7.3830656,28.970613 C 6.9591888,28.93369 6.5847252,28.865163 6.1216233,28.739766 3.939623,28.148936 2.3343232,26.553308 2.0542907,24.69694 c -0.059727,-0.395941 -0.026579,-1.199534 0.06393,-1.549817 0.2441973,-0.945074 0.7282812,-1.715403 1.5083369,-2.400239 1.0414383,-0.914309 2.439622,-1.460679 3.968098,-1.550617 2.6285644,-0.154668 5.0553554,1.09409 6.0316174,3.103697 0.249677,0.513954 0.374766,1.022658 0.401375,1.632277 0.129471,2.966315 -3.01956,5.354123 -6.6445827,5.038372 z m 1.4750261,-2.21691 c 0.5665465,-0.119025 1.0649768,-0.349607 1.5010603,-0.694414 1.344125,-1.062792 1.365432,-2.81722 0.04742,-3.904876 -0.4423445,-0.365035 -0.933834,-0.599155 -1.5404683,-0.7338 -0.3675822,-0.08159 -1.0965106,-0.10042 -1.4681193,-0.03793 -0.6943238,0.116752 -1.2018962,0.334626 -1.7037842,0.731346 -0.4370814,0.345495 -0.7235718,0.734014 -0.9039922,1.225935 -0.083643,0.228056 -0.091134,0.286581 -0.093426,0.730023 -0.00271,0.522574 0.017695,0.620916 0.2185705,1.053794 0.3591292,0.77391 1.2591819,1.416179 2.2924167,1.635845 0.5068234,0.107752 1.1197254,0.105554 1.6503207,-0.0059 z"
+         style="opacity:1;fill:#b7d9ea;fill-opacity:1;stroke:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+    </g>
+  </g>
+</svg>
diff --git a/src/PrimitivesPlugin/icons/cone.png b/src/PrimitivesPlugin/icons/cone.png
new file mode 100644 (file)
index 0000000..4c89e62
Binary files /dev/null and b/src/PrimitivesPlugin/icons/cone.png differ
diff --git a/src/PrimitivesPlugin/icons/torus.png b/src/PrimitivesPlugin/icons/torus.png
new file mode 100644 (file)
index 0000000..254cd0a
Binary files /dev/null and b/src/PrimitivesPlugin/icons/torus.png differ
index 9880e628b6a63bd5c9528fa8b746ba8014b31240..4c087288e24499cd13b5d5904fb6b33ab5f904a4 100644 (file)
         <source path="sphere_widget.xml"/>
       </feature>
     </group>
+    <group id="Primitives">
+      <feature id="Torus" title="Torus" tooltip="Create a Torus" icon="icons/Primitives/torus.png">
+        <source path="torus_widget.xml"/>
+      </feature>
+    </group>
+    <group id="Primitives">
+      <feature id="Cone" title="Cone" tooltip="Create a Cone" icon="icons/Primitives/cone.png">
+        <source path="cone_widget.xml"/>
+      </feature>
+    </group>
   </workbench>
 </plugin>
diff --git a/src/PrimitivesPlugin/torus_widget.xml b/src/PrimitivesPlugin/torus_widget.xml
new file mode 100644 (file)
index 0000000..44d0ce6
--- /dev/null
@@ -0,0 +1,38 @@
+<!-- Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
+
+<source>
+  <shape_selector
+      id="base_point"
+      label="base_point"
+      default=""
+      shape_types="vertex"
+      icon="icons/Primitives/point.png"
+      tooltip="Select the center of the torus">
+    <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 torus">
+    <validator id="GeomValidators_ConstructionComposite"/>
+    <validator id="GeomValidators_ShapeType" parameters="line"/>
+  </shape_selector>
+  <doublevalue
+    id="radius"
+    label="Radius"
+    step="1."
+    default="15."
+    tooltip="Enter the radius of the torus">
+  </doublevalue>
+  <doublevalue
+    id="ring_radius"
+    label="Ring radius"
+    step="1."
+    default="3."
+    tooltip="Enter the ring radius of the torus">
+  </doublevalue>
+</source>
\ No newline at end of file
index 6f0b8e061282152776bf681cf487a37feed05c4f..a707b9cfe838c0a5dfa011fb07adea1e62adaa4a 100644 (file)
@@ -1,4 +1,4 @@
 """Package for Primitives plugin for the Parametric Geometry API of the Modeler.
 """
 
-from PrimitivesAPI import addBox, addCylinder, addSphere
+from PrimitivesAPI import addBox, addCone, addCylinder, addSphere, addTorus