]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add ConstructionAPI_Axis
authorspo <sergey.pokhodenko@opencascade.com>
Wed, 15 Jun 2016 11:21:34 +0000 (14:21 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 17 Jun 2016 11:41:09 +0000 (14:41 +0300)
src/ConstructionAPI/CMakeLists.txt
src/ConstructionAPI/ConstructionAPI.i
src/ConstructionAPI/ConstructionAPI_Axis.cpp [new file with mode: 0644]
src/ConstructionAPI/ConstructionAPI_Axis.h [new file with mode: 0644]
src/ConstructionAPI/ConstructionAPI_swig.h

index 68342d5eb6146b2e45abf85ef741e7b7eca19828..2dcb3b5a9a2fe78cf41528681d6aca43a5d2fd7b 100644 (file)
@@ -4,11 +4,13 @@ INCLUDE(Common)
 
 SET(PROJECT_HEADERS
   ConstructionAPI.h
+  ConstructionAPI_Axis.h
   ConstructionAPI_Plane.h
   ConstructionAPI_Point.h
 )
 
 SET(PROJECT_SOURCES
+  ConstructionAPI_Axis.cpp
   ConstructionAPI_Plane.cpp
   ConstructionAPI_Point.cpp
 )
index d09f8d516484be5cc5986d6e2e19b007e02bc000..ab4f400aa0e35cacfec186896eebb7dc809ac69b 100644 (file)
 %include "std_shared_ptr.i"
 
 // shared pointers
+%shared_ptr(ConstructionAPI_Axis)
 %shared_ptr(ConstructionAPI_Plane)
 %shared_ptr(ConstructionAPI_Point)
 
 // all supported interfaces
+%include "ConstructionAPI_Axis.h"
 %include "ConstructionAPI_Plane.h"
 %include "ConstructionAPI_Point.h"
diff --git a/src/ConstructionAPI/ConstructionAPI_Axis.cpp b/src/ConstructionAPI/ConstructionAPI_Axis.cpp
new file mode 100644 (file)
index 0000000..2d42f79
--- /dev/null
@@ -0,0 +1,120 @@
+// Name   : ConstructionAPI_Axis.cpp
+// Purpose: 
+//
+// History:
+// 15/06/16 - Sergey POKHODENKO - Creation of the file
+
+//--------------------------------------------------------------------------------------
+#include "ConstructionAPI_Axis.h"
+//--------------------------------------------------------------------------------------
+#include <ModelHighAPI_Tools.h>
+//--------------------------------------------------------------------------------------
+ConstructionAPI_Axis::ConstructionAPI_Axis(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+ConstructionAPI_Axis::ConstructionAPI_Axis(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature,
+    const ModelHighAPI_Selection & thePoint1,
+    const ModelHighAPI_Selection & thePoint2)
+: ModelHighAPI_Interface(theFeature)
+{
+  if (initialize())
+    setPoints(thePoint1, thePoint2);
+}
+
+ConstructionAPI_Axis::ConstructionAPI_Axis(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature,
+    const ModelHighAPI_Selection & theCylindricalFace)
+: ModelHighAPI_Interface(theFeature)
+{
+  if (initialize())
+    setCylindricalFace(theCylindricalFace);
+}
+
+ConstructionAPI_Axis::ConstructionAPI_Axis(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature,
+    const ModelHighAPI_Selection & thePoint,
+    const ModelHighAPI_Double & theX,
+    const ModelHighAPI_Double & theY,
+    const ModelHighAPI_Double & theZ)
+: ModelHighAPI_Interface(theFeature)
+{
+  if (initialize())
+    setPointAndDirection(thePoint, theX, theY, theZ);
+}
+
+ConstructionAPI_Axis::~ConstructionAPI_Axis()
+{
+
+}
+
+//--------------------------------------------------------------------------------------
+void ConstructionAPI_Axis::setPoints(
+    const ModelHighAPI_Selection & thePoint1,
+    const ModelHighAPI_Selection & thePoint2)
+{
+  fillAttribute("AxisByPointsCase", creationMethod());
+  fillAttribute(thePoint1, firstPoint());
+  fillAttribute(thePoint2, secondPoint());
+
+  execute();
+}
+
+void ConstructionAPI_Axis::setCylindricalFace(
+    const ModelHighAPI_Selection & theCylindricalFace)
+{
+  fillAttribute("AxisByCylindricalFaceCase", creationMethod());
+  fillAttribute(theCylindricalFace, cylindricalFace());
+
+  execute();
+}
+
+void ConstructionAPI_Axis::setPointAndDirection(
+    const ModelHighAPI_Selection & thePoint,
+    const ModelHighAPI_Double & theX,
+    const ModelHighAPI_Double & theY,
+    const ModelHighAPI_Double & theZ)
+{
+  fillAttribute("AxisByPointAndDirection", creationMethod());
+  fillAttribute(thePoint, firstPoint());
+  fillAttribute(theX, xDirection());
+  fillAttribute(theY, yDirection());
+  fillAttribute(theZ, zDirection());
+
+  execute();
+}
+
+//--------------------------------------------------------------------------------------
+// TODO(spo): make add* as static functions of the class
+
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
+                const ModelHighAPI_Selection & thePoint1,
+                const ModelHighAPI_Selection & thePoint2)
+{
+  // 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, thePoint1, thePoint2));
+}
+
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
+                const ModelHighAPI_Selection & theCylindricalFace)
+{
+  // 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, theCylindricalFace));
+}
+
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
+                const ModelHighAPI_Selection & thePoint,
+                const ModelHighAPI_Double & theX,
+                const ModelHighAPI_Double & theY,
+                const ModelHighAPI_Double & theZ)
+{
+  // 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, thePoint, theX, theY, theZ));
+}
diff --git a/src/ConstructionAPI/ConstructionAPI_Axis.h b/src/ConstructionAPI/ConstructionAPI_Axis.h
new file mode 100644 (file)
index 0000000..a473aef
--- /dev/null
@@ -0,0 +1,105 @@
+// Name   : ConstructionAPI_Axis.h
+// Purpose: 
+//
+// History:
+// 15/06/16 - Sergey POKHODENKO - Creation of the file
+
+#ifndef SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_AXIS_H_
+#define SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_AXIS_H_
+
+//--------------------------------------------------------------------------------------
+#include "ConstructionAPI.h"
+
+#include <ConstructionPlugin_Axis.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+//--------------------------------------------------------------------------------------
+class ModelHighAPI_Double;
+class ModelHighAPI_Selection;
+//--------------------------------------------------------------------------------------
+/**\class ConstructionAPI_Axis
+ * \ingroup CPPHighAPI
+ * \brief Interface for Axis feature
+ */
+class ConstructionAPI_Axis : public ModelHighAPI_Interface
+{
+public:
+  /// Constructor without values
+  CONSTRUCTIONAPI_EXPORT
+  explicit ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature> & theFeature);
+  /// Constructor with values
+  CONSTRUCTIONAPI_EXPORT
+  ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+                       const ModelHighAPI_Selection & thePoint1,
+                       const ModelHighAPI_Selection & thePoint2);
+  /// Constructor with values
+  CONSTRUCTIONAPI_EXPORT
+  ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+                       const ModelHighAPI_Selection & theCylindricalFace);
+  /// Constructor with values
+  CONSTRUCTIONAPI_EXPORT
+  ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+                       const ModelHighAPI_Selection & thePoint,
+                       const ModelHighAPI_Double & theX,
+                       const ModelHighAPI_Double & theY,
+                       const ModelHighAPI_Double & theZ);
+  /// Destructor
+  CONSTRUCTIONAPI_EXPORT
+  virtual ~ConstructionAPI_Axis();
+
+  INTERFACE_7(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 */
+  )
+
+  /// Set points
+  CONSTRUCTIONAPI_EXPORT
+  void setPoints(const ModelHighAPI_Selection & thePoint1,
+                 const ModelHighAPI_Selection & thePoint2);
+
+  /// Set cylindrical face
+  CONSTRUCTIONAPI_EXPORT
+  void setCylindricalFace(const ModelHighAPI_Selection & theCylindricalFace);
+
+  /// Set direction
+  CONSTRUCTIONAPI_EXPORT
+  void setPointAndDirection(const ModelHighAPI_Selection & thePoint,
+                            const ModelHighAPI_Double & theX,
+                            const ModelHighAPI_Double & theY,
+                            const ModelHighAPI_Double & theZ);
+};
+
+//! Pointer on Axis object
+typedef std::shared_ptr<ConstructionAPI_Axis> AxisPtr;
+
+/**\ingroup CPPHighAPI
+ * \brief Create Axis feature
+ */
+CONSTRUCTIONAPI_EXPORT
+AxisPtr addAxis(const ModelHighAPI_Selection & thePoint1,
+                const ModelHighAPI_Selection & thePoint2);
+
+/**\ingroup CPPHighAPI
+ * \brief Create Axis feature
+ */
+CONSTRUCTIONAPI_EXPORT
+AxisPtr addAxis(const ModelHighAPI_Selection & theCylindricalFace);
+
+/**\ingroup CPPHighAPI
+ * \brief Create Axis feature
+ */
+CONSTRUCTIONAPI_EXPORT
+AxisPtr addAxis(const ModelHighAPI_Selection & thePoint,
+                const ModelHighAPI_Double & theX,
+                const ModelHighAPI_Double & theY,
+                const ModelHighAPI_Double & theZ);
+
+//--------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------
+#endif /* SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_AXIS_H_ */
index 32d24c26516273e8b55560e4fc4e237f89ff1ba0..8970f5bd42a473c5ec51af1dce28a63e2d7b4052 100644 (file)
@@ -10,6 +10,7 @@
   #include <ModelHighAPI_swig.h>
 
   #include "ConstructionAPI.h"
+  #include "ConstructionAPI_Axis.h"
   #include "ConstructionAPI_Plane.h"
   #include "ConstructionAPI_Point.h"