]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Added CPP High API for FeaturesPlugin_Revolution
authordbv <dbv@opencascade.com>
Wed, 15 Jun 2016 11:35:35 +0000 (14:35 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 17 Jun 2016 11:41:09 +0000 (14:41 +0300)
12 files changed:
src/FeaturesAPI/CMakeLists.txt
src/FeaturesAPI/FeaturesAPI.i
src/FeaturesAPI/FeaturesAPI_Extrusion.cpp
src/FeaturesAPI/FeaturesAPI_Revolution.cpp [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_Revolution.h [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_swig.h
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/FeaturesPlugin/FeaturesPlugin_Extrusion.h
src/FeaturesPlugin/FeaturesPlugin_Revolution.cpp
src/FeaturesPlugin/FeaturesPlugin_Revolution.h
src/PythonAPI/Test/TestFeaturesExtrusion.py
src/PythonAPI/Test/TestFeaturesRevolution.py

index 0809f3fe6bd4f0f281a0fbc303e006cfc75efac4..ec14e58dedc64752e63b880cc042676cb2006185 100644 (file)
@@ -8,6 +8,7 @@ SET(PROJECT_HEADERS
   FeaturesAPI_Extrusion.h
   FeaturesAPI_Group.h
   FeaturesAPI_Placement.h
+  FeaturesAPI_Revolution.h
   FeaturesAPI_Rotation.h
   FeaturesAPI_Translation.h
 )
@@ -18,6 +19,7 @@ SET(PROJECT_SOURCES
   FeaturesAPI_Group.cpp
   FeaturesAPI_Placement.cpp
   FeaturesAPI_Rotation.cpp
+  FeaturesAPI_Revolution.cpp
   FeaturesAPI_Translation.cpp
 )
 
index 7801850d12356acbdacb38e6544c8fbf6acf91d2..6fc57716fd79e943cbbe8b6f59815f823a58d619 100644 (file)
@@ -23,6 +23,7 @@
 %shared_ptr(FeaturesAPI_Extrusion)
 %shared_ptr(FeaturesAPI_Group)
 %shared_ptr(FeaturesAPI_Placement)
+%shared_ptr(FeaturesAPI_Revolution)
 %shared_ptr(FeaturesAPI_Rotation)
 %shared_ptr(FeaturesAPI_Translation)
 
@@ -31,5 +32,6 @@
 %include "FeaturesAPI_Extrusion.h"
 %include "FeaturesAPI_Group.h"
 %include "FeaturesAPI_Placement.h"
+%include "FeaturesAPI_Revolution.h"
 %include "FeaturesAPI_Rotation.h"
 %include "FeaturesAPI_Translation.h"
index 8bb243a0224572348d5be1ef9d2a2c08ff355516..7c993db0be3edc4b1ef40b3dfd56c781c1ba0200 100644 (file)
@@ -128,7 +128,7 @@ void FeaturesAPI_Extrusion::setDirection(const ModelHighAPI_Selection& theDirect
 void FeaturesAPI_Extrusion::setSizes(const ModelHighAPI_Double& theToSize,
                                      const ModelHighAPI_Double& theFromSize)
 {
-  fillAttribute("BySizes", mycreationMethod);
+  fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
   fillAttribute(theToSize, mytoSize);
   fillAttribute(theFromSize, myfromSize);
 
@@ -138,7 +138,7 @@ void FeaturesAPI_Extrusion::setSizes(const ModelHighAPI_Double& theToSize,
 //==================================================================================================
 void FeaturesAPI_Extrusion::setSize(const ModelHighAPI_Double& theSize)
 {
-  fillAttribute("BySizes", mycreationMethod);
+  fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
   fillAttribute(theSize, mytoSize);
   fillAttribute(ModelHighAPI_Double(), myfromSize);
 
@@ -151,7 +151,7 @@ void FeaturesAPI_Extrusion::setPlanesAndOffsets(const ModelHighAPI_Selection& th
                                                 const ModelHighAPI_Selection& theFromObject,
                                                 const ModelHighAPI_Double& theFromOffset)
 {
-  fillAttribute("ByPlanesAndOffsets", mycreationMethod);
+  fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES(), mycreationMethod);
   fillAttribute(theToObject, mytoObject);
   fillAttribute(theToOffset, mytoOffset);
   fillAttribute(theFromObject, myfromObject);
diff --git a/src/FeaturesAPI/FeaturesAPI_Revolution.cpp b/src/FeaturesAPI/FeaturesAPI_Revolution.cpp
new file mode 100644 (file)
index 0000000..bae189a
--- /dev/null
@@ -0,0 +1,166 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        FeaturesAPI_Revolution.cpp
+// Created:     09 June 2016
+// Author:      Dmitry Bobylev
+
+#include "FeaturesAPI_Revolution.h"
+
+#include <ModelHighAPI_Double.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+FeaturesAPI_Revolution::FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+//==================================================================================================
+FeaturesAPI_Revolution::FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                               const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                                               const ModelHighAPI_Selection& theAxis,
+                                               const ModelHighAPI_Double& theAngle)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    fillAttribute(theBaseObjects, mybaseObjects);
+    fillAttribute(theAxis, myaxis);
+    setAngles(theAngle, ModelHighAPI_Double());
+  }
+}
+
+//==================================================================================================
+FeaturesAPI_Revolution::FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                               const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                                               const ModelHighAPI_Selection& theAxis,
+                                               const ModelHighAPI_Double& theToAngle,
+                                               const ModelHighAPI_Double& theFromAngle)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    fillAttribute(theBaseObjects, mybaseObjects);
+    fillAttribute(theAxis, myaxis);
+    setAngles(theToAngle, theFromAngle);
+  }
+}
+
+//==================================================================================================
+FeaturesAPI_Revolution::FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                               const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                                               const ModelHighAPI_Selection& theAxis,
+                                               const ModelHighAPI_Selection& theToObject,
+                                               const ModelHighAPI_Double& theToOffset,
+                                               const ModelHighAPI_Selection& theFromObject,
+                                               const ModelHighAPI_Double& theFromOffset)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    fillAttribute(theBaseObjects, mybaseObjects);
+    fillAttribute(theAxis, myaxis);
+    setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset);
+  }
+}
+
+//==================================================================================================
+FeaturesAPI_Revolution::~FeaturesAPI_Revolution()
+{
+
+}
+
+//==================================================================================================
+void FeaturesAPI_Revolution::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
+{
+  fillAttribute(theBaseObjects, mybaseObjects);
+
+  execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Revolution::setAxis(const ModelHighAPI_Selection& theAxis)
+{
+  fillAttribute(theAxis, myaxis);
+
+  execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Revolution::setAngles(const ModelHighAPI_Double& theToAngle,
+                                       const ModelHighAPI_Double& theFromAngle)
+{
+  fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_BY_ANGLES(), mycreationMethod);
+  fillAttribute(theToAngle, mytoAngle);
+  fillAttribute(theFromAngle, myfromAngle);
+
+  execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Revolution::setAngle(const ModelHighAPI_Double& theAngle)
+{
+  fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_BY_ANGLES(), mycreationMethod);
+  fillAttribute(theAngle, mytoAngle);
+  fillAttribute(ModelHighAPI_Double(), myfromAngle);
+
+  execute();
+}
+
+//==================================================================================================
+void FeaturesAPI_Revolution::setPlanesAndOffsets(const ModelHighAPI_Selection& theToObject,
+                                                const ModelHighAPI_Double& theToOffset,
+                                                const ModelHighAPI_Selection& theFromObject,
+                                                const ModelHighAPI_Double& theFromOffset)
+{
+  fillAttribute("ByPlanesAndOffsets", mycreationMethod);
+  fillAttribute(theToObject, mytoObject);
+  fillAttribute(theToOffset, mytoOffset);
+  fillAttribute(theFromObject, myfromObject);
+  fillAttribute(theFromOffset, myfromOffset);
+
+  execute();
+}
+
+// TODO(spo): make add* as static functions of the class
+//==================================================================================================
+RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
+                            const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                            const ModelHighAPI_Selection& theAxis,
+                            const ModelHighAPI_Double& theAngle)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Revolution::ID());
+  return RevolutionPtr(new FeaturesAPI_Revolution(aFeature, theBaseObjects, theAxis, theAngle));
+}
+
+//==================================================================================================
+RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
+                            const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                            const ModelHighAPI_Selection& theAxis,
+                            const ModelHighAPI_Double& theToAngle,
+                            const ModelHighAPI_Double& theFromAngle)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Revolution::ID());
+  return RevolutionPtr(new FeaturesAPI_Revolution(aFeature,
+                                                theBaseObjects,
+                                                theAxis,
+                                                theToAngle,
+                                                theFromAngle));
+}
+
+//==================================================================================================
+RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
+                            const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                            const ModelHighAPI_Selection& theAxis,
+                            const ModelHighAPI_Selection& theToObject,
+                            const ModelHighAPI_Double& theToOffset,
+                            const ModelHighAPI_Selection& theFromObject,
+                            const ModelHighAPI_Double& theFromOffset)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Revolution::ID());
+  return RevolutionPtr(new FeaturesAPI_Revolution(aFeature,
+                                                theBaseObjects,
+                                                theAxis,
+                                                theToObject,
+                                                theToOffset,
+                                                theFromObject,
+                                                theFromOffset));
+}
diff --git a/src/FeaturesAPI/FeaturesAPI_Revolution.h b/src/FeaturesAPI/FeaturesAPI_Revolution.h
new file mode 100644 (file)
index 0000000..a7c0a09
--- /dev/null
@@ -0,0 +1,126 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File:        FeaturesAPI_Revolution.h
+// Created:     09 June 2016
+// Author:      Dmitry Bobylev
+
+#ifndef FeaturesAPI_Revolution_H_
+#define FeaturesAPI_Revolution_H_
+
+#include "FeaturesAPI.h"
+
+#include <FeaturesPlugin_Revolution.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+class ModelHighAPI_Double;
+class ModelHighAPI_Selection;
+
+/// \class FeaturesAPI_Revolution
+/// \ingroup CPPHighAPI
+/// \brief Interface for Revolution feature.
+class FeaturesAPI_Revolution: public ModelHighAPI_Interface
+{
+public:
+  /// Constructor without values.
+  FEATURESAPI_EXPORT
+  explicit FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+  /// Constructor with values.
+  FEATURESAPI_EXPORT
+  explicit FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                  const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                                  const ModelHighAPI_Selection& theAxis,
+                                  const ModelHighAPI_Double& theAngle);
+
+  /// Constructor with values.
+  FEATURESAPI_EXPORT
+  explicit FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                  const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                                  const ModelHighAPI_Selection& theAxis,
+                                  const ModelHighAPI_Double& theToAngle,
+                                  const ModelHighAPI_Double& theFromAngle);
+
+  /// Constructor with values.
+  FEATURESAPI_EXPORT
+  explicit FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                  const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                                  const ModelHighAPI_Selection& theAxis,
+                                  const ModelHighAPI_Selection& theToObject,
+                                  const ModelHighAPI_Double& theToOffset,
+                                  const ModelHighAPI_Selection& theFromObject,
+                                  const ModelHighAPI_Double& theFromOffset);
+
+  /// Destructor.
+  FEATURESAPI_EXPORT
+  virtual ~FeaturesAPI_Revolution();
+
+  INTERFACE_10(FeaturesPlugin_Revolution::ID(),
+               baseObjects, FeaturesPlugin_CompositeSketch::BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList, /** Base objects */,
+               axis, FeaturesPlugin_Revolution::AXIS_OBJECT_ID(), ModelAPI_AttributeSelection, /** Axis */,
+               creationMethod, FeaturesPlugin_Revolution::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */,
+               toAngle, FeaturesPlugin_Revolution::TO_ANGLE_ID(), ModelAPI_AttributeDouble, /** To angle */,
+               fromAngle, FeaturesPlugin_Revolution::FROM_ANGLE_ID(), ModelAPI_AttributeDouble, /** From angle */,
+               toObject, FeaturesPlugin_Revolution::TO_OBJECT_ID(), ModelAPI_AttributeSelection, /** To object */,
+               toOffset, FeaturesPlugin_Revolution::TO_OFFSET_ID(), ModelAPI_AttributeDouble, /** To offset */,
+               fromObject, FeaturesPlugin_Revolution::FROM_OBJECT_ID(), ModelAPI_AttributeSelection, /** From object */,
+               fromOffset, FeaturesPlugin_Revolution::FROM_OFFSET_ID(), ModelAPI_AttributeDouble, /** From offset */,
+               sketchLauncher, FeaturesPlugin_CompositeSketch::SKETCH_ID(), ModelAPI_AttributeReference, /** Sketch launcher */)
+
+  /// Modify base attribute of the feature.
+  FEATURESAPI_EXPORT
+  void setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects);
+
+  /// Modify axis_object attribute of the feature.
+  FEATURESAPI_EXPORT
+  void setAxis(const ModelHighAPI_Selection& theAxis);
+
+  /// Modify CreationMethod, to_angle, from_angle attributes of the feature.
+  FEATURESAPI_EXPORT
+  void setAngles(const ModelHighAPI_Double& theToAngle, const ModelHighAPI_Double& theFromAngle);
+
+  /// Modify CreationMethod, to_angle, from_angle attributes of the feature.
+  FEATURESAPI_EXPORT
+  void setAngle(const ModelHighAPI_Double& theAngle);
+
+  /// Modify CreationMethod, to_object, to_offset, from_object, from_offset attributes of the feature.
+  FEATURESAPI_EXPORT
+  void setPlanesAndOffsets(const ModelHighAPI_Selection& theToObject,
+                           const ModelHighAPI_Double& theToOffset,
+                           const ModelHighAPI_Selection& theFromObject,
+                           const ModelHighAPI_Double& theFromOffset);
+};
+
+/// Pointer on Revolution object.
+typedef std::shared_ptr<FeaturesAPI_Revolution> RevolutionPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create Revolution feature.
+FEATURESAPI_EXPORT
+RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
+                            const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                            const ModelHighAPI_Selection& theAxis,
+                            const ModelHighAPI_Double& theAngle);
+
+/// \ingroup CPPHighAPI
+/// \brief Create Revolution feature.
+FEATURESAPI_EXPORT
+RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
+                            const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                            const ModelHighAPI_Selection& theAxis,
+                            const ModelHighAPI_Double& theToAngle,
+                            const ModelHighAPI_Double& theFromAngle);
+
+/// \ingroup CPPHighAPI
+/// \brief Create Revolution feature.
+FEATURESAPI_EXPORT
+RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
+                            const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                            const ModelHighAPI_Selection& theAxis,
+                            const ModelHighAPI_Selection& theToObject,
+                            const ModelHighAPI_Double& theToOffset,
+                            const ModelHighAPI_Selection& theFromObject,
+                            const ModelHighAPI_Double& theFromOffset);
+
+#endif // FeaturesAPI_Revolution_H_
index bc9c57a24b967f12875114fd6f065458c6167a5c..8caf40e977b4886b98252a1a9b906ad70d0935e9 100644 (file)
@@ -14,6 +14,7 @@
   #include "FeaturesAPI_Extrusion.h"
   #include "FeaturesAPI_Group.h"
   #include "FeaturesAPI_Placement.h"
+  #include "FeaturesAPI_Revolution.h"
   #include "FeaturesAPI_Rotation.h"
   #include "FeaturesAPI_Translation.h"
 
index 225e3cf481e78ac7398aab43b1fa18bcad0c055c..8238b174388404eddc675eb24d0363e3b7d48b60 100644 (file)
@@ -100,7 +100,7 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes,
   double aToSize = 0.0;
   double aFromSize = 0.0;
 
-  if(string(CREATION_METHOD())->value() == "BySizes") {
+  if(string(CREATION_METHOD())->value() == CREATION_METHOD_BY_SIZES()) {
     aToSize = real(TO_SIZE_ID())->value();
     aFromSize = real(FROM_SIZE_ID())->value();
   } else {
@@ -112,7 +112,7 @@ bool FeaturesPlugin_Extrusion::makeExtrusions(ListOfShape& theBaseShapes,
   GeomShapePtr aToShape;
   GeomShapePtr aFromShape;
 
-  if(string(CREATION_METHOD())->value() == "ByPlanesAndOffsets") {
+  if(string(CREATION_METHOD())->value() == CREATION_METHOD_BY_PLANES()) {
     aSelection = selection(TO_OBJECT_ID());
     if(aSelection.get()) {
       aToShape = std::dynamic_pointer_cast<GeomAPI_Shape>(aSelection->value());
index f2a8fc1776acfd582445b48d89dac1b329227645..aa2b483618da5cde068777cdfd436b3e650dd3ce 100644 (file)
@@ -40,6 +40,20 @@ public:
     return MY_CREATION_METHOD_ID;
   }
 
+  /// Attribute name for creation method.
+  inline static const std::string& CREATION_METHOD_BY_SIZES()
+  {
+    static const std::string MY_CREATION_METHOD_ID("BySizes");
+    return MY_CREATION_METHOD_ID;
+  }
+
+  /// Attribute name for creation method.
+  inline static const std::string& CREATION_METHOD_BY_PLANES()
+  {
+    static const std::string MY_CREATION_METHOD_ID("ByPlanesAndOffsets");
+    return MY_CREATION_METHOD_ID;
+  }
+
   /// Attribute name of an object to which the extrusion grows.
   inline static const std::string& DIRECTION_OBJECT_ID()
   {
index 12e053e324da48bab8f9b41016bf42da0fe62b40..53e4e532888f5d988101c30d59447dd23f158dc8 100644 (file)
@@ -103,7 +103,7 @@ bool FeaturesPlugin_Revolution::makeRevolutions(ListOfShape& theBaseShapes,
   double aToAngle = 0.0;
   double aFromAngle = 0.0;
 
-  if(string(CREATION_METHOD())->value() == "ByAngles") {
+  if(string(CREATION_METHOD())->value() == CREATION_METHOD_BY_ANGLES()) {
     aToAngle = real(TO_ANGLE_ID())->value();
     aFromAngle = real(FROM_ANGLE_ID())->value();
   } else {
@@ -115,7 +115,7 @@ bool FeaturesPlugin_Revolution::makeRevolutions(ListOfShape& theBaseShapes,
   GeomShapePtr aToShape;
   GeomShapePtr aFromShape;
 
-  if(string(CREATION_METHOD())->value() == "ByPlanesAndOffsets") {
+  if(string(CREATION_METHOD())->value() == CREATION_METHOD_BY_PLANES()) {
     aSelection = selection(TO_OBJECT_ID());
     if(aSelection.get()) {
       aToShape = std::dynamic_pointer_cast<GeomAPI_Shape>(aSelection->value());
index f31e4c917e0640e7a1287bd5ec73a40ab1362221..2ebbf84a3d67b4402834403e585817ee3ac93599 100644 (file)
@@ -35,6 +35,20 @@ public:
     return MY_CREATION_METHOD_ID;
   }
 
+  /// Attribute name for creation method.
+  inline static const std::string& CREATION_METHOD_BY_ANGLES()
+  {
+    static const std::string MY_CREATION_METHOD_ID("ByAngles");
+    return MY_CREATION_METHOD_ID;
+  }
+
+  /// Attribute name for creation method.
+  inline static const std::string& CREATION_METHOD_BY_PLANES()
+  {
+    static const std::string MY_CREATION_METHOD_ID("ByPlanesAndOffsets");
+    return MY_CREATION_METHOD_ID;
+  }
+
   /// Attribute name of an revolution axis.
   inline static const std::string& AXIS_OBJECT_ID()
   {
index 0405e58d8adbe28dc20d2046c70d1e2b4dc04d4a..ce3935cd9578b770336b0452fe938dfab241dcd7 100644 (file)
@@ -30,7 +30,7 @@ class FeaturesExtrusionFixture(FeaturesAddExtrusionFixture):
         circle = sketch.addCircle(0, 0, 10)
         model.do()
 
-        base = sketch.selectFace(circle.result())
+        base = sketch.selectFace()
         self.extrusion = model.addExtrusion(self.part, base, 10, 0)
         model.do()
 
@@ -47,17 +47,17 @@ class FeaturesAddExtrusionTestCase(FeaturesAddExtrusionFixture):
         circle = sketch.addCircle(0, 0, 10)
         model.do()
 
-        base = sketch.selectFace(circle.result())
+        base = sketch.selectFace()
         extrusion = model.addExtrusion(self.part, base, 10, 0)
         model.do()
 
-        self.assertEqual(extrusion.getCreationMethod().value(), "BySizes")
-        self.assertEqual(extrusion.getToSize().value(), 10)
-        self.assertEqual(extrusion.getFromSize().value(), 0)
-        self.assertEqual(extrusion.getToObject().context(), None)
-        self.assertEqual(extrusion.getToOffset().value(), 0)
-        self.assertEqual(extrusion.getFromObject().context(), None)
-        self.assertEqual(extrusion.getFromOffset().value(), 0)
+        self.assertEqual(extrusion.creationMethod().value(), "BySizes")
+        self.assertEqual(extrusion.toSize().value(), 10)
+        self.assertEqual(extrusion.fromSize().value(), 0)
+        self.assertEqual(extrusion.toObject().context(), None)
+        self.assertEqual(extrusion.toOffset().value(), 0)
+        self.assertEqual(extrusion.fromObject().context(), None)
+        self.assertEqual(extrusion.fromOffset().value(), 0)
 
     def test_add_extrusion_by_face_and_planes(self):
         # base
@@ -76,22 +76,22 @@ class FeaturesAddExtrusionTestCase(FeaturesAddExtrusionFixture):
 
         model.do()
 
-        base = base_sketch.selectFace(base_circle.result())
-        to_object = to_sketch.selectFace(to_circle.result())[0]
-        from_object = from_sketch.selectFace(from_circle.result())[0]
+        base = base_sketch.selectFace()
+        to_object = to_sketch.selectFace()[0]
+        from_object = from_sketch.selectFace()[0]
         extrusion = model.addExtrusion(self.part, base,
                                        to_object, 15,
                                        from_object, 20)
 
-        self.assertEqual(extrusion.getCreationMethod().value(), "ByPlanesAndOffsets")
-        self.assertEqual(extrusion.getToSize().value(), 0)
-        self.assertEqual(extrusion.getFromSize().value(), 0)
+        self.assertEqual(extrusion.creationMethod().value(), "ByPlanesAndOffsets")
+        self.assertEqual(extrusion.toSize().value(), 0)
+        self.assertEqual(extrusion.fromSize().value(), 0)
 #         self.assertEqual(extrusion.getToObject().context(),
 #                          to_sketch.result())
-        self.assertEqual(extrusion.getToOffset().value(), 15)
+        self.assertEqual(extrusion.toOffset().value(), 15)
 #         self.assertEqual(extrusion.getFromObject().context(),
 #                          from_sketch.result())
-        self.assertEqual(extrusion.getFromOffset().value(), 20)
+        self.assertEqual(extrusion.fromOffset().value(), 20)
 
 
 class FeaturesExtrusionTestCase(FeaturesExtrusionFixture):
@@ -102,32 +102,32 @@ class FeaturesExtrusionTestCase(FeaturesExtrusionFixture):
 
     def test_extrusion_get_attribute(self):
         # call method of the feature
-        self.assertTrue(isinstance(self.extrusion.getBase(),
+        self.assertTrue(isinstance(self.extrusion.baseObjects(),
                                    ModelAPI.ModelAPI_AttributeSelectionList))
-        self.assertTrue(isinstance(self.extrusion.getCreationMethod(),
+        self.assertTrue(isinstance(self.extrusion.creationMethod(),
                                    ModelAPI.ModelAPI_AttributeString))
-        self.assertTrue(isinstance(self.extrusion.getToSize(),
+        self.assertTrue(isinstance(self.extrusion.toSize(),
                                    ModelAPI.ModelAPI_AttributeDouble))
-        self.assertTrue(isinstance(self.extrusion.getFromSize(),
+        self.assertTrue(isinstance(self.extrusion.fromSize(),
                                    ModelAPI.ModelAPI_AttributeDouble))
-        self.assertTrue(isinstance(self.extrusion.getToObject(),
+        self.assertTrue(isinstance(self.extrusion.toObject(),
                                    ModelAPI.ModelAPI_AttributeSelection))
-        self.assertTrue(isinstance(self.extrusion.getToOffset(),
+        self.assertTrue(isinstance(self.extrusion.toOffset(),
                                    ModelAPI.ModelAPI_AttributeDouble))
-        self.assertTrue(isinstance(self.extrusion.getFromObject(),
+        self.assertTrue(isinstance(self.extrusion.fromObject(),
                                    ModelAPI.ModelAPI_AttributeSelection))
-        self.assertTrue(isinstance(self.extrusion.getFromOffset(),
+        self.assertTrue(isinstance(self.extrusion.fromOffset(),
                                    ModelAPI.ModelAPI_AttributeDouble))
 
     def test_extrusion_set_sizes(self):
         self.extrusion.setSizes(15, 20)
-        self.assertEqual(self.extrusion.getCreationMethod().value(), "BySizes")
-        self.assertEqual(self.extrusion.getToSize().value(), 15)
-        self.assertEqual(self.extrusion.getFromSize().value(), 20)
-        self.assertEqual(self.extrusion.getToObject().context(), None)
-        self.assertEqual(self.extrusion.getToOffset().value(), 0)
-        self.assertEqual(self.extrusion.getFromObject().context(), None)
-        self.assertEqual(self.extrusion.getFromOffset().value(), 0)
+        self.assertEqual(self.extrusion.creationMethod().value(), "BySizes")
+        self.assertEqual(self.extrusion.toSize().value(), 15)
+        self.assertEqual(self.extrusion.fromSize().value(), 20)
+        self.assertEqual(self.extrusion.toObject().context(), None)
+        self.assertEqual(self.extrusion.toOffset().value(), 0)
+        self.assertEqual(self.extrusion.fromObject().context(), None)
+        self.assertEqual(self.extrusion.fromOffset().value(), 0)
 
     def test_extrusion_set_planes_and_offsets(self):
         # to
@@ -143,8 +143,8 @@ class FeaturesExtrusionTestCase(FeaturesExtrusionFixture):
 
         model.do()
 
-        to_object = to_sketch.selectFace(to_circle.result())[0]
-        from_object = from_sketch.selectFace(from_circle.result())[0]
+        to_object = to_sketch.selectFace()[0]
+        from_object = from_sketch.selectFace()[0]
         self.extrusion.setPlanesAndOffsets(to_object, 15, from_object, 20)
 
 
index a7fbfde5a3fbdc9bd73a61c24157ccb2edeab68b..1c2084183b3a6c4d0e8827c64ce52325431ec123 100644 (file)
@@ -36,9 +36,9 @@ class FeaturesRevolutionFixture(FeaturesAddRevolutionFixture):
 
         model.do()
 
-        base = base_sketch.selectFace(circle.lastResult())
-        axis_object = Selection(axis_sketch.firstResult(),
-                                line.firstResult().shape())
+        base = base_sketch.selectFace()
+        axis_object = Selection(axis_sketch.result()[0],
+                                line.result()[0])
 
         self.revolution = model.addRevolution(self.part, base, axis_object,
                                               0, 180)
@@ -64,66 +64,62 @@ class FeaturesAddRevolutionTestCase(FeaturesAddRevolutionFixture):
         # base
         base_sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
         circle = base_sketch.addCircle(0, 0, 10)
-        # axis
-        axis_sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
-        line = axis_sketch.addLine(20, -10, 20, 10)
 
         model.do()
 
-        base = base_sketch.selectFace(circle.lastResult())
-        axis_object = Selection(axis_sketch.firstResult(),
-                                line.firstResult().shape())
+        base = base_sketch.selectFace()
+        axis_point1 = model.addPoint(self.part, 20, -10, 0)
+        axis_point2 = model.addPoint(self.part, 20, 10, 0)
+        axis_object = model.addAxis(self.part, axis_point1.result()[0], axis_point2.result()[0]).result()[0]
 
         revolution = model.addRevolution(self.part, base, axis_object,
                                          0, 180)
 
-        self.assertEqual(revolution.getCreationMethod().value(), "ByAngles")
-        self.assertEqual(revolution.getToAngle().value(), 0)
-        self.assertEqual(revolution.getFromAngle().value(), 180)
-        self.assertEqual(revolution.getToObject().context(), None)
-        self.assertEqual(revolution.getToOffset().value(), 0)
-        self.assertEqual(revolution.getFromObject().context(), None)
-        self.assertEqual(revolution.getFromOffset().value(), 0)
+        self.assertEqual(revolution.creationMethod().value(), "ByAngles")
+        self.assertEqual(revolution.toAngle().value(), 0)
+        self.assertEqual(revolution.fromAngle().value(), 180)
+        self.assertEqual(revolution.toObject().context(), None)
+        self.assertEqual(revolution.toOffset().value(), 0)
+        self.assertEqual(revolution.fromObject().context(), None)
+        self.assertEqual(revolution.fromOffset().value(), 0)
 
     def test_add_revolution_by_face_and_planes(self):
         # base
         base_sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
         base_circle = base_sketch.addCircle(0, 0, 10)
-        # axis
-        axis_sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
-        line = axis_sketch.addLine(20, -10, 20, 10)
         # to
         to_plane = model.defaultPlane("XOY")
-        to_plane.location().setZ(10)
+        to_plane.origin().setZ(10)
         to_sketch = model.addSketch(self.part, to_plane)
         to_circle = to_sketch.addCircle(0, 0, 10)
         # from
         from_plane = model.defaultPlane("XOY")
-        from_plane.location().setZ(-10)
+        from_plane.origin().setZ(-10)
         from_sketch = model.addSketch(self.part, from_plane)
         from_circle = from_sketch.addCircle(0, 0, 10)
 
         model.do()
 
-        base = base_sketch.selectFace(base_circle.result())
-        axis_object = Selection(axis_sketch.firstResult(),
-                                line.firstResult().shape())
-        to_obejct = to_sketch.selectFace(to_circle.result())[0]
-        from_object = from_sketch.selectFace(from_circle.result())[0]
+        base = base_sketch.selectFace()
+        axis_point1 = model.addPoint(self.part, 20, -10, 0)
+        axis_point2 = model.addPoint(self.part, 20, 10, 0)
+        axis_object = model.addAxis(self.part, axis_point1.result()[0], axis_point2.result()[0]).result()[0]
+        to_obejct = to_sketch.selectFace()[0]
+        from_object = from_sketch.selectFace()[0]
 
         revolution = model.addRevolution(self.part, base, axis_object,
                                          to_obejct, 15,
                                          from_object, 20)
 
-        self.assertEqual(revolution.getCreationMethod().value(), "ByPlanesAndOffsets")
-        self.assertEqual(revolution.getToAngle().value(), 0)
-        self.assertEqual(revolution.getFromAngle().value(), 0)
+        self.assertEqual(revolution.creationMethod().value(), "ByPlanesAndOffsets")
+        self.assertEqual(revolution.toAngle().value(), 0)
+        self.assertEqual(revolution.fromAngle().value(), 0)
 #         self.assertEqual(revolution.getToObject().context(),
 #                          to_sketch.result())
-        self.assertEqual(revolution.getToOffset().value(), 15)
+        self.assertEqual(revolution.toOffset().value(), 15)
 #         self.assertEqual(revolution.getFromObject().context(),
 #                          from_sketch.result())
-        self.assertEqual(revolution.getFromOffset().value(), 20)
+        self.assertEqual(revolution.fromOffset().value(), 20)
 
 
 class FeaturesRevolutionTestCase(FeaturesRevolutionFixture):
@@ -134,70 +130,68 @@ class FeaturesRevolutionTestCase(FeaturesRevolutionFixture):
 
     def test_revolution_get_attribute(self):
         # call method of the feature
-        self.assertTrue(isinstance(self.revolution.getBase(),
+        self.assertTrue(isinstance(self.revolution.base(),
                                    ModelAPI.ModelAPI_AttributeSelectionList))
-        self.assertTrue(isinstance(self.revolution.getAxisObject(),
+        self.assertTrue(isinstance(self.revolution.axisObject(),
                                    ModelAPI.ModelAPI_AttributeSelection))
-        self.assertTrue(isinstance(self.revolution.getCreationMethod(),
+        self.assertTrue(isinstance(self.revolution.creationMethod(),
                                    ModelAPI.ModelAPI_AttributeString))
-        self.assertTrue(isinstance(self.revolution.getToAngle(),
+        self.assertTrue(isinstance(self.revolution.toAngle(),
                                    ModelAPI.ModelAPI_AttributeDouble))
-        self.assertTrue(isinstance(self.revolution.getFromAngle(),
+        self.assertTrue(isinstance(self.revolution.fromAngle(),
                                    ModelAPI.ModelAPI_AttributeDouble))
-        self.assertTrue(isinstance(self.revolution.getToObject(),
+        self.assertTrue(isinstance(self.revolution.toObject(),
                                    ModelAPI.ModelAPI_AttributeSelection))
-        self.assertTrue(isinstance(self.revolution.getToOffset(),
+        self.assertTrue(isinstance(self.revolution.toOffset(),
                                    ModelAPI.ModelAPI_AttributeDouble))
-        self.assertTrue(isinstance(self.revolution.getFromObject(),
+        self.assertTrue(isinstance(self.revolution.fromObject(),
                                    ModelAPI.ModelAPI_AttributeSelection))
-        self.assertTrue(isinstance(self.revolution.getFromOffset(),
+        self.assertTrue(isinstance(self.revolution.fromOffset(),
                                    ModelAPI.ModelAPI_AttributeDouble))
 
     def test_revolution_set_angles(self):
         self.revolution.setAngles(90, 270)
-        self.assertEqual(self.revolution.getCreationMethod().value(), "ByAngles")
-        self.assertEqual(self.revolution.getToAngle().value(), 90)
-        self.assertEqual(self.revolution.getFromAngle().value(), 270)
-        self.assertEqual(self.revolution.getToObject().context(), None)
-        self.assertEqual(self.revolution.getToOffset().value(), 0)
-        self.assertEqual(self.revolution.getFromObject().context(), None)
-        self.assertEqual(self.revolution.getFromOffset().value(), 0)
+        self.assertEqual(self.revolution.creationMethod().value(), "ByAngles")
+        self.assertEqual(self.revolution.toAngle().value(), 90)
+        self.assertEqual(self.revolution.fromAngle().value(), 270)
+        self.assertEqual(self.revolution.toObject().context(), None)
+        self.assertEqual(self.revolution.toOffset().value(), 0)
+        self.assertEqual(self.revolution.fromObject().context(), None)
+        self.assertEqual(self.revolution.fromOffset().value(), 0)
 
     def test_revolution_set_planes_and_offsets(self):
         # base
         base_sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
         base_circle = base_sketch.addCircle(0, 0, 10)
-        # axis
-        axis_sketch = model.addSketch(self.part, model.defaultPlane("XOY"))
-        line = axis_sketch.addLine(20, -10, 20, 10)
         # to
         to_plane = model.defaultPlane("XOY")
-        to_plane.location().setZ(10)
+        to_plane.origin().setZ(10)
         to_sketch = model.addSketch(self.part, to_plane)
         to_circle = to_sketch.addCircle(0, 0, 10)
         # from
         from_plane = model.defaultPlane("XOY")
-        from_plane.location().setZ(-10)
+        from_plane.origin().setZ(-10)
         from_sketch = model.addSketch(self.part, from_plane)
         from_circle = from_sketch.addCircle(0, 0, 10)
 
         model.do()
 
-        base = base_sketch.selectFace(base_circle.result())
-        axis_object = Selection(axis_sketch.firstResult(),
-                                line.firstResult().shape())
-        to_obejct = to_sketch.selectFace(to_circle.result())[0]
-        from_object = from_sketch.selectFace(from_circle.result())[0]
+        base = base_sketch.selectFace()
+        axis_point1 = model.addPoint(self.part, 20, -10, 0)
+        axis_point2 = model.addPoint(self.part, 20, 10, 0)
+        axis_object = model.addAxis(self.part, axis_point1.result()[0], axis_point2.result()[0]).result()[0]
+        to_obejct = to_sketch.selectFace()[0]
+        from_object = from_sketch.selectFace()[0]
 
         self.revolution.setPlanesAndOffsets(to_obejct, 15, from_object, 20)
 
-        self.assertEqual(self.revolution.getCreationMethod().value(), "ByPlanesAndOffsets")
-        self.assertEqual(self.revolution.getToAngle().value(), 0)
-        self.assertEqual(self.revolution.getFromAngle().value(), 0)
+        self.assertEqual(self.revolution.creationMethod().value(), "ByPlanesAndOffsets")
+        self.assertEqual(self.revolution.toAngle().value(), 0)
+        self.assertEqual(self.revolution.fromAngle().value(), 0)
 #         self.assertEqual(self.revolution.getToObject().context(), None)
-        self.assertEqual(self.revolution.getToOffset().value(), 15)
+        self.assertEqual(self.revolution.toOffset().value(), 15)
 #         self.assertEqual(self.revolution.getFromObject().context(), None)
-        self.assertEqual(self.revolution.getFromOffset().value(), 20)
+        self.assertEqual(self.revolution.fromOffset().value(), 20)
 
 
 if __name__ == "__main__":