From 6d5f20efe329d0762a12822018982f42f34b8c48 Mon Sep 17 00:00:00 2001 From: spo Date: Wed, 15 Jun 2016 14:21:34 +0300 Subject: [PATCH] Add ConstructionAPI_Axis --- src/ConstructionAPI/CMakeLists.txt | 2 + src/ConstructionAPI/ConstructionAPI.i | 2 + src/ConstructionAPI/ConstructionAPI_Axis.cpp | 120 +++++++++++++++++++ src/ConstructionAPI/ConstructionAPI_Axis.h | 105 ++++++++++++++++ src/ConstructionAPI/ConstructionAPI_swig.h | 1 + 5 files changed, 230 insertions(+) create mode 100644 src/ConstructionAPI/ConstructionAPI_Axis.cpp create mode 100644 src/ConstructionAPI/ConstructionAPI_Axis.h diff --git a/src/ConstructionAPI/CMakeLists.txt b/src/ConstructionAPI/CMakeLists.txt index 68342d5eb..2dcb3b5a9 100644 --- a/src/ConstructionAPI/CMakeLists.txt +++ b/src/ConstructionAPI/CMakeLists.txt @@ -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 ) diff --git a/src/ConstructionAPI/ConstructionAPI.i b/src/ConstructionAPI/ConstructionAPI.i index d09f8d516..ab4f400aa 100644 --- a/src/ConstructionAPI/ConstructionAPI.i +++ b/src/ConstructionAPI/ConstructionAPI.i @@ -19,9 +19,11 @@ %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 index 000000000..2d42f790e --- /dev/null +++ b/src/ConstructionAPI/ConstructionAPI_Axis.cpp @@ -0,0 +1,120 @@ +// Name : ConstructionAPI_Axis.cpp +// Purpose: +// +// History: +// 15/06/16 - Sergey POKHODENKO - Creation of the file + +//-------------------------------------------------------------------------------------- +#include "ConstructionAPI_Axis.h" +//-------------------------------------------------------------------------------------- +#include +//-------------------------------------------------------------------------------------- +ConstructionAPI_Axis::ConstructionAPI_Axis( + const std::shared_ptr & theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +ConstructionAPI_Axis::ConstructionAPI_Axis( + const std::shared_ptr & 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 & theFeature, + const ModelHighAPI_Selection & theCylindricalFace) +: ModelHighAPI_Interface(theFeature) +{ + if (initialize()) + setCylindricalFace(theCylindricalFace); +} + +ConstructionAPI_Axis::ConstructionAPI_Axis( + const std::shared_ptr & 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 & thePart, + const ModelHighAPI_Selection & thePoint1, + const ModelHighAPI_Selection & thePoint2) +{ + // TODO(spo): check that thePart is not empty + std::shared_ptr aFeature = thePart->addFeature(ConstructionAPI_Axis::ID()); + return AxisPtr(new ConstructionAPI_Axis(aFeature, thePoint1, thePoint2)); +} + +AxisPtr addAxis(const std::shared_ptr & thePart, + const ModelHighAPI_Selection & theCylindricalFace) +{ + // TODO(spo): check that thePart is not empty + std::shared_ptr aFeature = thePart->addFeature(ConstructionAPI_Axis::ID()); + return AxisPtr(new ConstructionAPI_Axis(aFeature, theCylindricalFace)); +} + +AxisPtr addAxis(const std::shared_ptr & 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 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 index 000000000..a473aeffb --- /dev/null +++ b/src/ConstructionAPI/ConstructionAPI_Axis.h @@ -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 + +#include +#include +//-------------------------------------------------------------------------------------- +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 & theFeature); + /// Constructor with values + CONSTRUCTIONAPI_EXPORT + ConstructionAPI_Axis(const std::shared_ptr & theFeature, + const ModelHighAPI_Selection & thePoint1, + const ModelHighAPI_Selection & thePoint2); + /// Constructor with values + CONSTRUCTIONAPI_EXPORT + ConstructionAPI_Axis(const std::shared_ptr & theFeature, + const ModelHighAPI_Selection & theCylindricalFace); + /// Constructor with values + CONSTRUCTIONAPI_EXPORT + ConstructionAPI_Axis(const std::shared_ptr & 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 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_ */ diff --git a/src/ConstructionAPI/ConstructionAPI_swig.h b/src/ConstructionAPI/ConstructionAPI_swig.h index 32d24c265..8970f5bd4 100644 --- a/src/ConstructionAPI/ConstructionAPI_swig.h +++ b/src/ConstructionAPI/ConstructionAPI_swig.h @@ -10,6 +10,7 @@ #include #include "ConstructionAPI.h" + #include "ConstructionAPI_Axis.h" #include "ConstructionAPI_Plane.h" #include "ConstructionAPI_Point.h" -- 2.39.2