]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Completion of the parametric API high level for the construction of an axis from...
authorClarisse Genrault <clarisse.genrault@cea.fr>
Fri, 1 Jul 2016 10:03:27 +0000 (12:03 +0200)
committerdbv <dbv@opencascade.com>
Thu, 7 Jul 2016 09:39:41 +0000 (12:39 +0300)
src/ConstructionAPI/CMakeLists.txt
src/ConstructionAPI/ConstructionAPI_Axis.cpp
src/ConstructionAPI/ConstructionAPI_Axis.h
src/ConstructionAPI/Test/TestAxis.py [new file with mode: 0644]

index 67cad0d490a3d89bee97d5a0164992ba4a439b4e..edf38ae48c2e0bcdf829cca7d6e7d3c391467587 100644 (file)
@@ -78,4 +78,5 @@ INCLUDE(UnitTest)
 
 ADD_UNIT_TESTS(
   TestPoint.py
+  TestAxis.py
 )
index 352320e1d9a8b551a90e899fcef929eeab73c12b..18e114af3da3f6aa635b1f979c7c60ab3071c5c7 100644 (file)
@@ -47,6 +47,17 @@ ConstructionAPI_Axis::ConstructionAPI_Axis(
     setPointAndDirection(thePoint, theX, theY, theZ);
 }
 
+ConstructionAPI_Axis::ConstructionAPI_Axis(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature,
+    const ModelHighAPI_Double & theDX,
+    const ModelHighAPI_Double & theDY,
+    const ModelHighAPI_Double & theDZ)
+: ModelHighAPI_Interface(theFeature)
+{
+  if (initialize())
+    setDimensions(theDX, theDY, theDZ);
+}
+
 ConstructionAPI_Axis::~ConstructionAPI_Axis()
 {
 
@@ -88,6 +99,19 @@ void ConstructionAPI_Axis::setPointAndDirection(
   execute();
 }
 
+void ConstructionAPI_Axis::setDimensions(
+    const ModelHighAPI_Double & theDX,
+    const ModelHighAPI_Double & theDY,
+    const ModelHighAPI_Double & theDZ)
+{
+  fillAttribute("AxisByDimensionsCase", creationMethod());
+  fillAttribute(theDX, xDimension());
+  fillAttribute(theDY, yDimension());
+  fillAttribute(theDZ, zDimension());
+
+  execute();
+}
+
 //--------------------------------------------------------------------------------------
 AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
                 const ModelHighAPI_Selection & thePoint1,
@@ -116,3 +140,13 @@ AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
   return AxisPtr(new ConstructionAPI_Axis(aFeature, thePoint, theX, theY, theZ));
 }
+
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
+                const ModelHighAPI_Double & theDX,
+                const ModelHighAPI_Double & theDY,
+                const ModelHighAPI_Double & theDZ)
+{
+  // TODO(spo): check that thePart is not empty
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
+  return AxisPtr(new ConstructionAPI_Axis(aFeature, theDX, theDY, theDZ));
+}
index 49077c78b136eb3ada3bd50d1a62bd8dc2df3564..ed8f4bc620d006dd457ddce5f565ab0430408a0e 100644 (file)
@@ -1,8 +1,11 @@
+// Copyright (C) 2014-2016 CEA/DEN, EDF R&D
+
 // Name   : ConstructionAPI_Axis.h
 // Purpose: 
 //
 // History:
 // 15/06/16 - Sergey POKHODENKO - Creation of the file
+// 24/06/16 - Clarisse GENRAULT (CEA) - Modification of the file
 
 #ifndef SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_AXIS_H_
 #define SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_AXIS_H_
@@ -44,18 +47,27 @@ public:
                        const ModelHighAPI_Double & theX,
                        const ModelHighAPI_Double & theY,
                        const ModelHighAPI_Double & theZ);
+  /// Constructor with values
+  CONSTRUCTIONAPI_EXPORT
+  ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+                       const ModelHighAPI_Double & theDX,
+                       const ModelHighAPI_Double & theDY,
+                       const ModelHighAPI_Double & theDZ);
   /// Destructor
   CONSTRUCTIONAPI_EXPORT
   virtual ~ConstructionAPI_Axis();
 
-  INTERFACE_7(ConstructionPlugin_Axis::ID(),
+  INTERFACE_10(ConstructionPlugin_Axis::ID(),
               creationMethod, ConstructionPlugin_Axis::METHOD(), ModelAPI_AttributeString, /** Creation method */,
               firstPoint, ConstructionPlugin_Axis::POINT_FIRST(), ModelAPI_AttributeSelection, /** First point */,
               secondPoint, ConstructionPlugin_Axis::POINT_SECOND(), ModelAPI_AttributeSelection, /** Second point */,
               cylindricalFace, ConstructionPlugin_Axis::CYLINDRICAL_FACE(), ModelAPI_AttributeSelection, /** Cylindrical face */,
               xDirection, ConstructionPlugin_Axis::X_DIRECTION(), ModelAPI_AttributeDouble, /** X direction */,
               yDirection, ConstructionPlugin_Axis::Y_DIRECTION(), ModelAPI_AttributeDouble, /** Y direction */,
-              zDirection, ConstructionPlugin_Axis::Z_DIRECTION(), ModelAPI_AttributeDouble, /** Z direction */
+              zDirection, ConstructionPlugin_Axis::Z_DIRECTION(), ModelAPI_AttributeDouble, /** Z direction */,
+              xDimension, ConstructionPlugin_Axis::DX(), ModelAPI_AttributeDouble, /** X dimension */,
+              yDimension, ConstructionPlugin_Axis::DY(), ModelAPI_AttributeDouble, /** Y dimension */,
+              zDimension, ConstructionPlugin_Axis::DZ(), ModelAPI_AttributeDouble, /** Z dimension */
   )
 
   /// Set points
@@ -73,6 +85,12 @@ public:
                             const ModelHighAPI_Double & theX,
                             const ModelHighAPI_Double & theY,
                             const ModelHighAPI_Double & theZ);
+  
+  /// Set dimensions
+  CONSTRUCTIONAPI_EXPORT
+  void setDimensions(const ModelHighAPI_Double & theDX,
+                     const ModelHighAPI_Double & theDY,
+                     const ModelHighAPI_Double & theDZ);
 };
 
 //! Pointer on Axis object
@@ -103,6 +121,15 @@ AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
                 const ModelHighAPI_Double & theY,
                 const ModelHighAPI_Double & theZ);
 
+/**\ingroup CPPHighAPI
+ * \brief Create Axis feature
+ */
+CONSTRUCTIONAPI_EXPORT
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
+                const ModelHighAPI_Double & theDX,
+                const ModelHighAPI_Double & theDY,
+                const ModelHighAPI_Double & theDZ);
+
 //--------------------------------------------------------------------------------------
 //--------------------------------------------------------------------------------------
 #endif /* SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_AXIS_H_ */
diff --git a/src/ConstructionAPI/Test/TestAxis.py b/src/ConstructionAPI/Test/TestAxis.py
new file mode 100644 (file)
index 0000000..626ff62
--- /dev/null
@@ -0,0 +1,26 @@
+import unittest
+
+import ModelAPI
+import ConstructionAPI
+
+class AxisTestCase(unittest.TestCase):
+
+    def setUp(self):
+        self.session = ModelAPI.ModelAPI_Session.get()
+        self.doc = self.session.moduleDocument()
+        self.session.startOperation()
+        self.feature = self.doc.addFeature("Axis")
+        self.feature.execute()
+        self.session.finishOperation()
+
+    def tearDown(self):
+        self.session.closeAll()
+
+    def test_ConstructorWithDimensions(self):
+        axis = ConstructionAPI.ConstructionAPI_Axis(self.feature, 10, 50, 100)
+        self.assertEqual(10,axis.xDimension().value())
+        self.assertEqual(50,axis.yDimension().value())
+        self.assertEqual(100,axis.zDimension().value())
+
+if __name__ == "__main__":
+    unittest.main()