]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1650: Added CPP High API for feature Axis;
authordbv <dbv@opencascade.com>
Wed, 3 Aug 2016 07:06:47 +0000 (10:06 +0300)
committerdbv <dbv@opencascade.com>
Wed, 3 Aug 2016 07:58:16 +0000 (10:58 +0300)
Added test cases for Axis.

src/ConstructionAPI/ConstructionAPI_Axis.cpp
src/ConstructionAPI/ConstructionAPI_Axis.h
src/ConstructionAPI/ConstructionAPI_Point.cpp
src/ConstructionPlugin/ConstructionPlugin_Axis.cpp
src/ConstructionPlugin/ConstructionPlugin_Axis.h
src/ConstructionPlugin/Test/TestAxisCreation.py
src/ConstructionPlugin/axis_widget.xml
src/ModelAPI/Test/Test1064.py
src/ModelHighAPI/ModelHighAPI_Macro.h
src/ModelHighAPI/ModelHighAPI_Tools.cpp
src/ModelHighAPI/ModelHighAPI_Tools.h

index 18e114af3da3f6aa635b1f979c7c60ab3071c5c7..ab3cf13b18a36a33fa5910c52299c9c334842b9f 100644 (file)
 // 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)
+
+//==================================================================================================
+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)
+//==================================================================================================
+ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                           const ModelHighAPI_Selection& theObject1,
+                                           const ModelHighAPI_Selection& theObject2)
 : ModelHighAPI_Interface(theFeature)
 {
-  if (initialize())
-    setPoints(thePoint1, thePoint2);
+  if(initialize()) {
+    GeomAPI_Shape::ShapeType aType1 = getShapeType(theObject1);
+    GeomAPI_Shape::ShapeType aType2 = getShapeType(theObject2);
+    if(aType1 == GeomAPI_Shape::VERTEX && aType2 == GeomAPI_Shape::VERTEX) {
+      setByPoints(theObject1, theObject2);
+    } else if (aType1 == GeomAPI_Shape::FACE && aType2 == GeomAPI_Shape::VERTEX) {
+      setByPlaneAndPoint(theObject1, theObject2);
+    } else if (aType1 == GeomAPI_Shape::FACE && aType2 == GeomAPI_Shape::FACE) {
+      setByTwoPlanes(theObject1, theObject2);
+    }
+  }
 }
 
-ConstructionAPI_Axis::ConstructionAPI_Axis(
-    const std::shared_ptr<ModelAPI_Feature> & theFeature,
-    const ModelHighAPI_Selection & theCylindricalFace)
+//==================================================================================================
+ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                           const ModelHighAPI_Selection& theObject)
 : ModelHighAPI_Interface(theFeature)
 {
-  if (initialize())
-    setCylindricalFace(theCylindricalFace);
+  if(initialize()) {
+    GeomAPI_Shape::ShapeType aType = getShapeType(theObject);
+    if(aType == GeomAPI_Shape::EDGE) {
+      setByLine(theObject);
+    } else if(aType == GeomAPI_Shape::FACE) {
+      setByCylindricalFace(theObject);
+    }
+  }
 }
 
-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)
+//==================================================================================================
+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);
+  if(initialize()) {
+    setByPointAndDirection(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)
+//==================================================================================================
+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);
+  if(initialize()) {
+    setByDimensions(theDX, theDY, theDZ);
+  }
 }
 
-ConstructionAPI_Axis::~ConstructionAPI_Axis()
+//==================================================================================================
+ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                           const ModelHighAPI_Selection& thePlane1,
+                                           const ModelHighAPI_Double& theOffset1,
+                                           const bool theReverseOffset1,
+                                           const ModelHighAPI_Selection& thePlane2,
+                                           const ModelHighAPI_Double& theOffset2,
+                                           const bool theReverseOffset2)
+: ModelHighAPI_Interface(theFeature)
 {
+  if(initialize()) {
+    setByTwoPlanes(thePlane1, theOffset1, theReverseOffset1, thePlane2, theOffset2, theReverseOffset2);
+  }
+}
 
+//==================================================================================================
+ConstructionAPI_Axis::~ConstructionAPI_Axis()
+{
 }
 
-//--------------------------------------------------------------------------------------
-void ConstructionAPI_Axis::setPoints(
-    const ModelHighAPI_Selection & thePoint1,
-    const ModelHighAPI_Selection & thePoint2)
+//==================================================================================================
+void ConstructionAPI_Axis::setByPoints(const ModelHighAPI_Selection& thePoint1,
+                                       const ModelHighAPI_Selection& thePoint2)
 {
-  fillAttribute("AxisByPointsCase", creationMethod());
+  fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_TWO_POINTS(), creationMethod());
   fillAttribute(thePoint1, firstPoint());
   fillAttribute(thePoint2, secondPoint());
 
   execute();
 }
 
-void ConstructionAPI_Axis::setCylindricalFace(
-    const ModelHighAPI_Selection & theCylindricalFace)
+//==================================================================================================
+void ConstructionAPI_Axis::setByCylindricalFace(const ModelHighAPI_Selection& theCylindricalFace)
 {
-  fillAttribute("AxisByCylindricalFaceCase", creationMethod());
+  fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_CYLINDRICAL_FACE(), 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)
+//==================================================================================================
+void ConstructionAPI_Axis::setByPointAndDirection(const ModelHighAPI_Selection& thePoint,
+                                                  const ModelHighAPI_Double& theX,
+                                                  const ModelHighAPI_Double& theY,
+                                                  const ModelHighAPI_Double& theZ)
 {
-  fillAttribute("AxisByPointAndDirection", creationMethod());
+  fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_POINT_AND_DIRECTION(), creationMethod());
   fillAttribute(thePoint, firstPoint());
   fillAttribute(theX, xDirection());
   fillAttribute(theY, yDirection());
@@ -99,12 +129,12 @@ void ConstructionAPI_Axis::setPointAndDirection(
   execute();
 }
 
-void ConstructionAPI_Axis::setDimensions(
-    const ModelHighAPI_Double & theDX,
-    const ModelHighAPI_Double & theDY,
-    const ModelHighAPI_Double & theDZ)
+//==================================================================================================
+void ConstructionAPI_Axis::setByDimensions(const ModelHighAPI_Double& theDX,
+                                           const ModelHighAPI_Double& theDY,
+                                           const ModelHighAPI_Double& theDZ)
 {
-  fillAttribute("AxisByDimensionsCase", creationMethod());
+  fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_DIMENSIONS(), creationMethod());
   fillAttribute(theDX, xDimension());
   fillAttribute(theDY, yDimension());
   fillAttribute(theDZ, zDimension());
@@ -112,41 +142,113 @@ void ConstructionAPI_Axis::setDimensions(
   execute();
 }
 
-//--------------------------------------------------------------------------------------
-AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
-                const ModelHighAPI_Selection & thePoint1,
-                const ModelHighAPI_Selection & thePoint2)
+//==================================================================================================
+void ConstructionAPI_Axis::setByLine(const ModelHighAPI_Selection& theLine)
+{
+  fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_LINE(), creationMethod());
+  fillAttribute(theLine, line());
+
+  execute();
+}
+
+//==================================================================================================
+void ConstructionAPI_Axis::setByPlaneAndPoint(const ModelHighAPI_Selection& thePlane,
+                                              const ModelHighAPI_Selection& thePoint)
+{
+  fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_PLANE_AND_POINT(), creationMethod());
+  fillAttribute(thePlane, plane());
+  fillAttribute(thePoint, point());
+
+  execute();
+}
+
+//==================================================================================================
+void ConstructionAPI_Axis::setByTwoPlanes(const ModelHighAPI_Selection& thePlane1,
+                                          const ModelHighAPI_Selection& thePlane2)
+{
+  fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_TWO_PLANES(), creationMethod());
+  fillAttribute(thePlane1, plane1());
+  fillAttribute("", useOffset1());
+  fillAttribute(thePlane2, plane2());
+  fillAttribute("", useOffset2());
+
+  execute();
+}
+
+//==================================================================================================
+void ConstructionAPI_Axis::setByTwoPlanes(const ModelHighAPI_Selection& thePlane1,
+                                          const ModelHighAPI_Double& theOffset1,
+                                          const bool theReverseOffset1,
+                                          const ModelHighAPI_Selection& thePlane2,
+                                          const ModelHighAPI_Double& theOffset2,
+                                          const bool theReverseOffset2)
+{
+  fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_TWO_PLANES(), creationMethod());
+  fillAttribute(thePlane1, plane1());
+  fillAttribute(ConstructionPlugin_Axis::USE_OFFSET1(), useOffset1());
+  fillAttribute(theOffset1, offset1());
+  fillAttribute(theReverseOffset1, reverseOffset1());
+  fillAttribute(thePlane2, plane2());
+  fillAttribute(ConstructionPlugin_Axis::USE_OFFSET2(), useOffset2());
+  fillAttribute(theOffset2, offset2());
+  fillAttribute(theReverseOffset2, reverseOffset2());
+
+  execute();
+}
+
+//==================================================================================================
+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)
+//==================================================================================================
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const ModelHighAPI_Selection& theObject)
 {
   // 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));
+  return AxisPtr(new ConstructionAPI_Axis(aFeature, theObject));
 }
 
-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)
+//==================================================================================================
+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));
 }
 
-AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
-                const ModelHighAPI_Double & theDX,
-                const ModelHighAPI_Double & theDY,
-                const ModelHighAPI_Double & theDZ)
+//==================================================================================================
+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));
 }
+
+//==================================================================================================
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const ModelHighAPI_Selection& thePlane1,
+                const ModelHighAPI_Double& theOffset1,
+                const bool theReverseOffset1,
+                const ModelHighAPI_Selection& thePlane2,
+                const ModelHighAPI_Double& theOffset2,
+                const bool theReverseOffset2)
+{
+  // 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, thePlane1, theOffset1, theReverseOffset1,
+                                                    thePlane2, theOffset2, theReverseOffset2));
+}
index ed8f4bc620d006dd457ddce5f565ab0430408a0e..0b62587a637ac2a0d3e85d80cd188877d2ab6ee9 100644 (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
+
+/// \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);
+  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);
+  ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                       const ModelHighAPI_Selection& theObject1,
+                       const ModelHighAPI_Selection& theObject2);
+
   /// Constructor with values
   CONSTRUCTIONAPI_EXPORT
-  ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature> & theFeature,
-                       const ModelHighAPI_Selection & theCylindricalFace);
+  ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                       const ModelHighAPI_Selection& theObject);
+
   /// 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);
+  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);
+
   /// 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);
+  ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                       const ModelHighAPI_Double& theDX,
+                       const ModelHighAPI_Double& theDY,
+                       const ModelHighAPI_Double& theDZ);
+
+  /// Constructor with values
+  CONSTRUCTIONAPI_EXPORT
+  ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                       const ModelHighAPI_Selection& thePlane1,
+                       const ModelHighAPI_Double& theOffset1,
+                       const bool theReverseOffset1,
+                       const ModelHighAPI_Selection& thePlane2,
+                       const ModelHighAPI_Double& theOffset2,
+                       const bool theReverseOffset2);
+
   /// Destructor
   CONSTRUCTIONAPI_EXPORT
   virtual ~ConstructionAPI_Axis();
 
-  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 */,
-              xDimension, ConstructionPlugin_Axis::DX(), ModelAPI_AttributeDouble, /** X dimension */,
-              yDimension, ConstructionPlugin_Axis::DY(), ModelAPI_AttributeDouble, /** Y dimension */,
-              zDimension, ConstructionPlugin_Axis::DZ(), ModelAPI_AttributeDouble, /** Z dimension */
-  )
+  INTERFACE_21(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 */,
+               xDimension, ConstructionPlugin_Axis::DX(), ModelAPI_AttributeDouble, /** X dimension */,
+               yDimension, ConstructionPlugin_Axis::DY(), ModelAPI_AttributeDouble, /** Y dimension */,
+               zDimension, ConstructionPlugin_Axis::DZ(), ModelAPI_AttributeDouble, /** Z dimension */,
+               line, ConstructionPlugin_Axis::LINE(), ModelAPI_AttributeSelection, /** Line */,
+               plane, ConstructionPlugin_Axis::PLANE(), ModelAPI_AttributeSelection, /** Plane */,
+               point, ConstructionPlugin_Axis::POINT(), ModelAPI_AttributeSelection, /** Point */,
+               plane1, ConstructionPlugin_Axis::PLANE1(), ModelAPI_AttributeSelection, /** Plane 1 */,
+               useOffset1, ConstructionPlugin_Axis::USE_OFFSET1(), ModelAPI_AttributeString, /** Use offset 1 */,
+               offset1, ConstructionPlugin_Axis::OFFSET1(), ModelAPI_AttributeDouble, /** Offset 1 */,
+               reverseOffset1, ConstructionPlugin_Axis::REVERSE_OFFSET1(), ModelAPI_AttributeBoolean, /** Reverse offset 1 */,
+               plane2, ConstructionPlugin_Axis::PLANE2(), ModelAPI_AttributeSelection, /** Plane 2 */,
+               useOffset2, ConstructionPlugin_Axis::USE_OFFSET2(), ModelAPI_AttributeString, /** Use offset 2 */,
+               offset2, ConstructionPlugin_Axis::OFFSET2(), ModelAPI_AttributeDouble, /** Offset 2 */,
+               reverseOffset2, ConstructionPlugin_Axis::REVERSE_OFFSET2(), ModelAPI_AttributeBoolean, /** Reverse offset 2 */)
 
   /// Set points
   CONSTRUCTIONAPI_EXPORT
-  void setPoints(const ModelHighAPI_Selection & thePoint1,
-                 const ModelHighAPI_Selection & thePoint2);
+  void setByPoints(const ModelHighAPI_Selection& thePoint1,
+                   const ModelHighAPI_Selection& thePoint2);
 
   /// Set cylindrical face
   CONSTRUCTIONAPI_EXPORT
-  void setCylindricalFace(const ModelHighAPI_Selection & theCylindricalFace);
+  void setByCylindricalFace(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);
-  
+  void setByPointAndDirection(const ModelHighAPI_Selection& thePoint,
+                              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);
+  void setByDimensions(const ModelHighAPI_Double& theDX,
+                       const ModelHighAPI_Double& theDY,
+                       const ModelHighAPI_Double& theDZ);
+
+  /// Set by line
+  CONSTRUCTIONAPI_EXPORT
+  void setByLine(const ModelHighAPI_Selection& theCylindricalFace);
+
+  /// Set by plane and point
+  CONSTRUCTIONAPI_EXPORT
+  void setByPlaneAndPoint(const ModelHighAPI_Selection& thePlane,
+                          const ModelHighAPI_Selection& thePoint);
+
+  /// Set by two planes
+  CONSTRUCTIONAPI_EXPORT
+  void setByTwoPlanes(const ModelHighAPI_Selection& thePlane1,
+                      const ModelHighAPI_Selection& thePlane2);
+
+  /// Set by two planes
+  CONSTRUCTIONAPI_EXPORT
+  void setByTwoPlanes(const ModelHighAPI_Selection& thePlane1,
+                      const ModelHighAPI_Double& theOffset1,
+                      const bool theReverseOffset1,
+                      const ModelHighAPI_Selection& thePlane2,
+                      const ModelHighAPI_Double& theOffset2,
+                      const bool theReverseOffset2);
 };
 
-//! Pointer on Axis object
+/// Pointer on Axis object
 typedef std::shared_ptr<ConstructionAPI_Axis> AxisPtr;
 
-/**\ingroup CPPHighAPI
- * \brief Create Axis feature
- */
+/// \ingroup CPPHighAPI
+/// \brief Create Axis feature
 CONSTRUCTIONAPI_EXPORT
-AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
-                const ModelHighAPI_Selection & thePoint1,
-                const ModelHighAPI_Selection & thePoint2);
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const ModelHighAPI_Selection& theObject1,
+                const ModelHighAPI_Selection& theObject2);
 
-/**\ingroup CPPHighAPI
- * \brief Create Axis feature
- */
+/// \ingroup CPPHighAPI
+/// \brief Create Axis feature
 CONSTRUCTIONAPI_EXPORT
-AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
-                const ModelHighAPI_Selection & theCylindricalFace);
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const ModelHighAPI_Selection& theObject);
 
-/**\ingroup CPPHighAPI
- * \brief Create Axis feature
- */
+/// \ingroup CPPHighAPI
+/// \brief Create Axis feature
 CONSTRUCTIONAPI_EXPORT
-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);
-
-/**\ingroup CPPHighAPI
- * \brief Create Axis feature
- */
+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);
+
+/// \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);
+
+/// \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);
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const ModelHighAPI_Selection& thePlane1,
+                const ModelHighAPI_Double& theOffset1,
+                const bool theReverseOffset1,
+                const ModelHighAPI_Selection& thePlane2,
+                const ModelHighAPI_Double& theOffset2,
+                const bool theReverseOffset2);
 
-//--------------------------------------------------------------------------------------
-//--------------------------------------------------------------------------------------
 #endif /* SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_AXIS_H_ */
index 511eb42f1546313dbd42cf29440542eddbc9f865..c503c16fa9c0885473a0ee4c8a672a558cb832d5 100644 (file)
 #include <ModelHighAPI_Selection.h>
 #include <ModelHighAPI_Tools.h>
 
-#include <algorithm>
-
-/*static GeomAPI_Shape::ShapeType shapeTypeByStr(const std::string& theShapeTypeStr);
-static GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection);*/
-
 //==================================================================================================
 ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature)
 : ModelHighAPI_Interface(theFeature)
@@ -169,64 +164,4 @@ PointPtr addPoint(const std::shared_ptr<ModelAPI_Document> & thePart,
   // TODO(spo): check that thePart is not empty
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
   return PointPtr(new ConstructionAPI_Point(aFeature, theObject1, theObject2));
-}
-
-//==================================================================================================
-GeomAPI_Shape::ShapeType shapeTypeByStr(const std::string& theShapeTypeStr)
-{
-  GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE;
-
-  std::string aShapeTypeStr = theShapeTypeStr;
-  std::transform(aShapeTypeStr.begin(), aShapeTypeStr.end(), aShapeTypeStr.begin(), ::tolower);
-
-  if(theShapeTypeStr == "compound") {
-    aShapeType = GeomAPI_Shape::COMPOUND;
-  } else if(theShapeTypeStr == "compsolid") {
-    aShapeType = GeomAPI_Shape::COMPSOLID;
-  } else if(theShapeTypeStr == "solid") {
-    aShapeType = GeomAPI_Shape::SOLID;
-  } else if(theShapeTypeStr == "shell") {
-    aShapeType = GeomAPI_Shape::SHELL;
-  } else if(theShapeTypeStr == "face") {
-    aShapeType = GeomAPI_Shape::FACE;
-  } else if(theShapeTypeStr == "wire") {
-    aShapeType = GeomAPI_Shape::WIRE;
-  } else if(theShapeTypeStr == "edge") {
-    aShapeType = GeomAPI_Shape::EDGE;
-  } else if(theShapeTypeStr == "vertex") {
-    aShapeType = GeomAPI_Shape::VERTEX;
-  } else if(theShapeTypeStr == "shape") {
-    aShapeType = GeomAPI_Shape::SHAPE;
-  }
-
-  return aShapeType;
-}
-
-//==================================================================================================
-GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection)
-{
-  GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE;
-
-  switch(theSelection.variantType()) {
-    case ModelHighAPI_Selection::VT_ResultSubShapePair: {
-      ResultSubShapePair aPair = theSelection.resultSubShapePair();
-      GeomShapePtr aShape = aPair.second;
-      if(!aShape.get()) {
-        aShape = aPair.first->shape();
-      }
-      if(!aShape.get()) {
-        return aShapeType;
-      }
-      aShapeType = aShape->shapeType();
-      break;
-    }
-    case ModelHighAPI_Selection::VT_TypeSubShapeNamePair: {
-      TypeSubShapeNamePair aPair = theSelection.typeSubShapeNamePair();
-      std::string aType = aPair.first;
-      aShapeType = shapeTypeByStr(aType);
-      break;
-    }
-  }
-
-  return aShapeType;
 }*/
index d1335f646dd1c2ea507badf5304331f0c2e98292..1317356de7f708746508ccba492e7957ccfad393 100644 (file)
@@ -291,13 +291,13 @@ void ConstructionPlugin_Axis::execute()
 {
   AttributeStringPtr aMethodTypeAttr = string(ConstructionPlugin_Axis::METHOD());
   std::string aMethodType = aMethodTypeAttr->value();
-  if (aMethodType == "AxisByPointsCase") {
+  if (aMethodType == CREATION_METHOD_BY_TWO_POINTS()) {
     createAxisByTwoPoints();
-  } else if (aMethodType == "AxisByCylindricalFaceCase") {
+  } else if (aMethodType == CREATION_METHOD_BY_CYLINDRICAL_FACE()) {
     createAxisByCylindricalFace();
-  } else if (aMethodType == "AxisByPointAndDirection") {
+  } else if (aMethodType == CREATION_METHOD_BY_POINT_AND_DIRECTION()) {
     createAxisByPointAndDirection();
-  } else if (aMethodType == "AxisByDimensionsCase") {
+  } else if (aMethodType == CREATION_METHOD_BY_DIMENSIONS()) {
     createAxisByDimensions();
   } else if(aMethodType == CREATION_METHOD_BY_LINE()) {
     createAxisByLine();
index 438effd1f175d204eab13eb5ea4c0238f346f5ad..afd1e45fc6b793277fc7cf64d72a30bbf97976a0 100644 (file)
@@ -42,6 +42,34 @@ class ConstructionPlugin_Axis : public ModelAPI_Feature, public GeomAPI_ICustomP
     return METHOD_ATTR;
   }
 
+  /// Attribute name for creation method.
+  inline static const std::string& CREATION_METHOD_BY_TWO_POINTS()
+  {
+    static const std::string METHOD_ATTR("AxisByPointsCase");
+    return METHOD_ATTR;
+  }
+
+  /// Attribute name for creation method.
+  inline static const std::string& CREATION_METHOD_BY_CYLINDRICAL_FACE()
+  {
+    static const std::string METHOD_ATTR("AxisByCylindricalFaceCase");
+    return METHOD_ATTR;
+  }
+
+  /// Attribute name for creation method.
+  inline static const std::string& CREATION_METHOD_BY_POINT_AND_DIRECTION()
+  {
+    static const std::string METHOD_ATTR("AxisByPointAndDirection");
+    return METHOD_ATTR;
+  }
+
+  /// Attribute name for creation method.
+  inline static const std::string& CREATION_METHOD_BY_DIMENSIONS()
+  {
+    static const std::string METHOD_ATTR("AxisByDimensionsCase");
+    return METHOD_ATTR;
+  }
+
   /// Attribute name for creation method.
   inline static const std::string& CREATION_METHOD_BY_LINE()
   {
index def1153d33471f664b54cb173797fae7fdcdb4d7..86ce8bc3771f001a72de3916b8147e34a8820052 100644 (file)
@@ -8,6 +8,8 @@ from GeomAPI import *
 import math
 from ModelAPI import *
 
+import model
+
 aSession = ModelAPI_Session.get()
 aDocument = aSession.moduleDocument()
 
@@ -134,3 +136,55 @@ aSession.finishOperation()
 assert (len(anAxisFeature.results()) > 0)
 anAxisResult = modelAPI_ResultConstruction(anAxisFeature.firstResult())
 assert (anAxisResult is not None)
+
+# Create a sketch with line
+aSession.startOperation()
+anOrigin = GeomAPI_Pnt(0, 0, 0)
+aDirX = GeomAPI_Dir(1, 0, 0)
+aNorm = GeomAPI_Dir(0, 0, 1)
+aSketch = model.addSketch(aPart, GeomAPI_Ax3(anOrigin, aDirX, aNorm))
+aSketchLine = aSketch.addLine(0, 0, 100, 100)
+aSession.finishOperation()
+
+# Test an axis by line
+aSession.startOperation()
+anAxis = model.addAxis(aPart, aSketchLine.result()[0])
+aSession.finishOperation()
+assert (len(anAxis.result()) > 0)
+
+# Create plane
+aSession.startOperation()
+aPlane1 = model.addPlane(aPart, 1, 1, 1, 0)
+aSession.finishOperation()
+
+# Create a sketch with point
+aSession.startOperation()
+anOrigin = GeomAPI_Pnt(0, 0, 0)
+aDirX = GeomAPI_Dir(1, 0, 0)
+aNorm = GeomAPI_Dir(0, 0, 1)
+aSketch = model.addSketch(aPart, GeomAPI_Ax3(anOrigin, aDirX, aNorm))
+aSketchPoint = aSketch.addPoint(50, 50)
+aSession.finishOperation()
+
+# Test an axis by plane and point
+aSession.startOperation()
+anAxis = model.addAxis(aPart, aPlane1.result()[0], aSketchPoint.result()[0])
+aSession.finishOperation()
+assert (len(anAxis.result()) > 0)
+
+# Create plane
+aSession.startOperation()
+aPlane2 = model.addPlane(aPart, 0, 1, 1, 0)
+aSession.finishOperation()
+
+# Test an axis by two planes
+aSession.startOperation()
+anAxis = model.addAxis(aPart, aPlane1.result()[0], aPlane2.result()[0])
+aSession.finishOperation()
+assert (len(anAxis.result()) > 0)
+
+# Test an axis by two planes and offsets
+aSession.startOperation()
+anAxis = model.addAxis(aPart, aPlane1.result()[0], 50, False, aPlane2.result()[0], 100, True)
+aSession.finishOperation()
+assert (len(anAxis.result()) > 0)
index ac192ec6e007ca0652b064f88eb378beb6653e48..d675d5624ad8e54950bb9dc498d584cf64a11627 100644 (file)
@@ -4,6 +4,11 @@
 
 <source>
   <toolbox id="CreationMethod">
+    <box id="AxisByDimensionsCase" title="By three dimensions" icon="icons/Construction/axis_dxyz_32x32.png">
+      <doublevalue id="DX" label="DX " tooltip="X dimension" default="0"/>
+      <doublevalue id="DY" label="DY " tooltip="Y dimension" default="0"/>
+      <doublevalue id="DZ" label="DZ " tooltip="Z dimension" default="10"/>
+    </box>
     <box id="AxisByPointsCase" title="By two points" icon="icons/Construction/by_two_points_32x32.png">
       <shape_selector id="FirstPoint"
         label="First point"
         <validator id="GeomValidators_DifferentShapes"/>
       </shape_selector>
     </box>
-    <box id="AxisByCylindricalFaceCase" title="As axis of cylindrical face" icon="icons/Construction/cylindrical_face_32x32.png">
-      <shape_selector id="CylindricalFace"
-        label="Main object" 
-        icon="icons/Construction/circle.png" 
-        tooltip="Select a cylindrical object"
-        shape_types="face">
-        <validator id="GeomValidators_Face" parameters="cylinder"/>
-      </shape_selector>
-    </box>
-    <box id="AxisByDimensionsCase" title="By three dimensions" icon="icons/Construction/axis_dxyz_32x32.png">
-      <doublevalue id="DX" label="DX " tooltip="X dimension" default="0"/>
-      <doublevalue id="DY" label="DY " tooltip="Y dimension" default="0"/>
-      <doublevalue id="DZ" label="DZ " tooltip="Z dimension" default="10"/>
-    </box>
     <box id="by_line" title="By line" icon="icons/Construction/axis_by_line_32x32.png">
       <shape_selector id="line"
                       label="Line"
         <validator id="GeomValidators_ShapeType" parameters="line"/>
       </shape_selector>
     </box>
+    <box id="AxisByCylindricalFaceCase" title="As axis of cylindrical face" icon="icons/Construction/cylindrical_face_32x32.png">
+      <shape_selector id="CylindricalFace"
+        label="Main object" 
+        icon="icons/Construction/circle.png" 
+        tooltip="Select a cylindrical object"
+        shape_types="face">
+        <validator id="GeomValidators_Face" parameters="cylinder"/>
+      </shape_selector>
+    </box>
     <box id="by_plane_and_point" title="By plane and point" icon="icons/Construction/axis_by_plane_and_point_32x32.png">
       <shape_selector id="plane"
                       label="Plane"
index f3b42c126e33cd5ce5ae5ac145611abde1d28ad4..efd57540f94c848aca85c6707da89cb253fa8510 100644 (file)
@@ -74,8 +74,8 @@ aPlane = aPartSet.addFeature("Plane")
 aPlane.string("creation_method").setValue("by_other_plane")
 aPlane.string("by_other_plane_option").setValue("by_distance_from_other")
 aPlane.selection("plane").selectSubShape("face", "Part_1/Extrusion_1_1/Generated_Face_3")
-aPlane.real("distance").setValue(0)
-aPlane.boolean("distance_reverse").setValue(False)
+aPlane.real("distance").setValue(0.001)
+aPlane.boolean("reverse").setValue(False)
 aSession.finishOperation()
 
 #=========================================================================
index 944929e6b2b8ae2de2c32b5572e5d5b37176a1c4..26d4b52ccec1504d228d333a740b510062c9fee4 100644 (file)
     END_INIT() \
   public:
 
+//--------------------------------------------------------------------------------------
+#define INTERFACE_21(KIND, \
+                     N_0, AN_0, T_0, C_0, \
+                     N_1, AN_1, T_1, C_1, \
+                     N_2, AN_2, T_2, C_2, \
+                     N_3, AN_3, T_3, C_3, \
+                     N_4, AN_4, T_4, C_4, \
+                     N_5, AN_5, T_5, C_5, \
+                     N_6, AN_6, T_6, C_6, \
+                     N_7, AN_7, T_7, C_7, \
+                     N_8, AN_8, T_8, C_8, \
+                     N_9, AN_9, T_9, C_9, \
+                     N_10, AN_10, T_10, C_10, \
+                     N_11, AN_11, T_11, C_11, \
+                     N_12, AN_12, T_12, C_12, \
+                     N_13, AN_13, T_13, C_13, \
+                     N_14, AN_14, T_14, C_14, \
+                     N_15, AN_15, T_15, C_15, \
+                     N_16, AN_16, T_16, C_16, \
+                     N_17, AN_17, T_17, C_17, \
+                     N_18, AN_18, T_18, C_18, \
+                     N_19, AN_19, T_19, C_19, \
+                     N_20, AN_20, T_20, C_20) \
+  public: \
+    INTERFACE_COMMON(KIND) \
+    DEFINE_ATTRIBUTE(N_0, T_0, C_0) \
+    DEFINE_ATTRIBUTE(N_1, T_1, C_1) \
+    DEFINE_ATTRIBUTE(N_2, T_2, C_2) \
+    DEFINE_ATTRIBUTE(N_3, T_3, C_3) \
+    DEFINE_ATTRIBUTE(N_4, T_4, C_4) \
+    DEFINE_ATTRIBUTE(N_5, T_5, C_5) \
+    DEFINE_ATTRIBUTE(N_6, T_6, C_6) \
+    DEFINE_ATTRIBUTE(N_7, T_7, C_7) \
+    DEFINE_ATTRIBUTE(N_8, T_8, C_8) \
+    DEFINE_ATTRIBUTE(N_9, T_9, C_9) \
+    DEFINE_ATTRIBUTE(N_10, T_10, C_10) \
+    DEFINE_ATTRIBUTE(N_11, T_11, C_11) \
+    DEFINE_ATTRIBUTE(N_12, T_12, C_12) \
+    DEFINE_ATTRIBUTE(N_13, T_13, C_13) \
+    DEFINE_ATTRIBUTE(N_14, T_14, C_14) \
+    DEFINE_ATTRIBUTE(N_15, T_15, C_15) \
+    DEFINE_ATTRIBUTE(N_16, T_16, C_16) \
+    DEFINE_ATTRIBUTE(N_17, T_17, C_17) \
+    DEFINE_ATTRIBUTE(N_18, T_18, C_18) \
+    DEFINE_ATTRIBUTE(N_19, T_19, C_19) \
+    DEFINE_ATTRIBUTE(N_20, T_20, C_20) \
+  protected: \
+    START_INIT() \
+      SET_ATTRIBUTE(N_0, T_0, AN_0) \
+      SET_ATTRIBUTE(N_1, T_1, AN_1) \
+      SET_ATTRIBUTE(N_2, T_2, AN_2) \
+      SET_ATTRIBUTE(N_3, T_3, AN_3) \
+      SET_ATTRIBUTE(N_4, T_4, AN_4) \
+      SET_ATTRIBUTE(N_5, T_5, AN_5) \
+      SET_ATTRIBUTE(N_6, T_6, AN_6) \
+      SET_ATTRIBUTE(N_7, T_7, AN_7) \
+      SET_ATTRIBUTE(N_8, T_8, AN_8) \
+      SET_ATTRIBUTE(N_9, T_9, AN_9) \
+      SET_ATTRIBUTE(N_10, T_10, AN_10) \
+      SET_ATTRIBUTE(N_11, T_11, AN_11) \
+      SET_ATTRIBUTE(N_12, T_12, AN_12) \
+      SET_ATTRIBUTE(N_13, T_13, AN_13) \
+      SET_ATTRIBUTE(N_14, T_14, AN_14) \
+      SET_ATTRIBUTE(N_15, T_15, AN_15) \
+      SET_ATTRIBUTE(N_16, T_16, AN_16) \
+      SET_ATTRIBUTE(N_17, T_17, AN_17) \
+      SET_ATTRIBUTE(N_18, T_18, AN_18) \
+      SET_ATTRIBUTE(N_19, T_19, AN_19) \
+      SET_ATTRIBUTE(N_20, T_20, AN_20) \
+    END_INIT() \
+  public:
+
 //--------------------------------------------------------------------------------------
 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_MACRO_H_ */
index ff191e5cadf5f19797f4040c01ff265f81fcc354..fb1df5c4c4d14639fa679a78c0700898e518c572 100644 (file)
@@ -33,6 +33,8 @@
 #include "ModelHighAPI_RefAttr.h"
 #include "ModelHighAPI_Selection.h"
 
+#include <algorithm>
+
 //--------------------------------------------------------------------------------------
 void fillAttribute(const std::shared_ptr<GeomAPI_Pnt2d> & theValue,
                    const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute)
@@ -146,4 +148,64 @@ void fillAttribute(const char * theValue,
   theAttribute->setValue(theValue);
 }
 
+//==================================================================================================
+GeomAPI_Shape::ShapeType shapeTypeByStr(const std::string& theShapeTypeStr)
+{
+  GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE;
+
+  std::string aShapeTypeStr = theShapeTypeStr;
+  std::transform(aShapeTypeStr.begin(), aShapeTypeStr.end(), aShapeTypeStr.begin(), ::tolower);
+
+  if(theShapeTypeStr == "compound") {
+    aShapeType = GeomAPI_Shape::COMPOUND;
+  } else if(theShapeTypeStr == "compsolid") {
+    aShapeType = GeomAPI_Shape::COMPSOLID;
+  } else if(theShapeTypeStr == "solid") {
+    aShapeType = GeomAPI_Shape::SOLID;
+  } else if(theShapeTypeStr == "shell") {
+    aShapeType = GeomAPI_Shape::SHELL;
+  } else if(theShapeTypeStr == "face") {
+    aShapeType = GeomAPI_Shape::FACE;
+  } else if(theShapeTypeStr == "wire") {
+    aShapeType = GeomAPI_Shape::WIRE;
+  } else if(theShapeTypeStr == "edge") {
+    aShapeType = GeomAPI_Shape::EDGE;
+  } else if(theShapeTypeStr == "vertex") {
+    aShapeType = GeomAPI_Shape::VERTEX;
+  } else if(theShapeTypeStr == "shape") {
+    aShapeType = GeomAPI_Shape::SHAPE;
+  }
+
+  return aShapeType;
+}
+
+//==================================================================================================
+GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection)
+{
+  GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE;
+
+  switch(theSelection.variantType()) {
+    case ModelHighAPI_Selection::VT_ResultSubShapePair: {
+      ResultSubShapePair aPair = theSelection.resultSubShapePair();
+      GeomShapePtr aShape = aPair.second;
+      if(!aShape.get()) {
+        aShape = aPair.first->shape();
+      }
+      if(!aShape.get()) {
+        return aShapeType;
+      }
+      aShapeType = aShape->shapeType();
+      break;
+    }
+    case ModelHighAPI_Selection::VT_TypeSubShapeNamePair: {
+      TypeSubShapeNamePair aPair = theSelection.typeSubShapeNamePair();
+      std::string aType = aPair.first;
+      aShapeType = shapeTypeByStr(aType);
+      break;
+    }
+  }
+
+  return aShapeType;
+}
+
 //--------------------------------------------------------------------------------------
index dc3378df2ee02cae4cd1508956b1b6b7c9b1ea0b..d731086b1d801df2fe826448c3b2136628040f12 100644 (file)
@@ -10,6 +10,8 @@
 //--------------------------------------------------------------------------------------
 #include "ModelHighAPI.h"
 
+#include <GeomAPI_Shape.h>
+
 #include <list>
 #include <memory>
 #include <string>
@@ -105,6 +107,12 @@ MODELHIGHAPI_EXPORT
 void fillAttribute(const char * theValue,
                    const std::shared_ptr<ModelAPI_AttributeString> & theAttribute);
 
+MODELHIGHAPI_EXPORT
+GeomAPI_Shape::ShapeType shapeTypeByStr(const std::string& theShapeTypeStr);
+
+MODELHIGHAPI_EXPORT
+GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection);
+
 //--------------------------------------------------------------------------------------
 //--------------------------------------------------------------------------------------
 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_TOOLS_H_ */