Salome HOME
Add SketchAPI and Line feature. Also fix tests.
authorspo <sergey.pokhodenko@opencascade.com>
Wed, 8 Jun 2016 09:23:22 +0000 (12:23 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 17 Jun 2016 11:41:05 +0000 (14:41 +0300)
18 files changed:
CMakeLists.txt
src/ModelHighAPI/ModelHighAPI_Tools.cpp
src/ModelHighAPI/ModelHighAPI_Tools.h
src/PythonAPI/Test/TestSketcherAddLine.py
src/PythonAPI/model/__init__.py
src/PythonAPI/model/services.py
src/PythonAPI/model/sketcher/__init__.py
src/SketchAPI/CMakeLists.txt [new file with mode: 0644]
src/SketchAPI/SketchAPI.h [new file with mode: 0644]
src/SketchAPI/SketchAPI.i [new file with mode: 0644]
src/SketchAPI/SketchAPI_Line.cpp [new file with mode: 0644]
src/SketchAPI/SketchAPI_Line.h [new file with mode: 0644]
src/SketchAPI/SketchAPI_Sketch.cpp [new file with mode: 0644]
src/SketchAPI/SketchAPI_Sketch.h [new file with mode: 0644]
src/SketchAPI/SketchAPI_SketchEntity.cpp [new file with mode: 0644]
src/SketchAPI/SketchAPI_SketchEntity.h [new file with mode: 0644]
src/SketchAPI/SketchAPI_swig.h [new file with mode: 0644]
src/SketchAPI/Test/TestSketch.py [new file with mode: 0644]

index 854053df0333441adcef8ecdd4134ef96e94c9a3..53625f7bc1aaff38bd63cea6690f285d46018d94 100644 (file)
@@ -98,6 +98,7 @@ ADD_SUBDIRECTORY (src/PythonAPI)
 ADD_SUBDIRECTORY (src/ModelHighAPI)
 ADD_SUBDIRECTORY (src/ConstructionAPI)
 ADD_SUBDIRECTORY (src/ExchangeAPI)
+ADD_SUBDIRECTORY (src/SketchAPI)
 
 IF(${HAVE_SALOME})
     ADD_SUBDIRECTORY (src/SHAPERGUI)
index 0c82867a682b8d00b9240a0efa55a8abf7404775..46bf241bd0ad867b36057eaacec6b8ae94624c75 100644 (file)
@@ -38,6 +38,12 @@ void fillAttribute(const std::shared_ptr<GeomAPI_Pnt2d> & theValue,
   theAttribute->setValue(theValue);
 }
 
+void fillAttribute(const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute,
+                   double theX, double theY)
+{
+  theAttribute->setValue(theX, theY);
+}
+
 //--------------------------------------------------------------------------------------
 void fillAttribute(const std::shared_ptr<GeomAPI_Dir> & theValue,
                    const std::shared_ptr<GeomDataAPI_Dir> & theAttribute)
index fbfd81f97991f48e63be7a150676de0c4d86be0c..91163898d444ffe37b36aa66877d77ec9d689b82 100644 (file)
@@ -42,6 +42,10 @@ MODELHIGHAPI_EXPORT
 void fillAttribute(const std::shared_ptr<GeomAPI_Pnt2d> & theValue,
                    const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute);
 
+MODELHIGHAPI_EXPORT
+void fillAttribute(const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute,
+                   double theX, double theY);
+
 MODELHIGHAPI_EXPORT
 void fillAttribute(const std::shared_ptr<GeomAPI_Dir> & theValue,
                    const std::shared_ptr<GeomDataAPI_Dir> & theAttribute);
index fa4ed94c666e029451f39d47be6711abb3617b35..25f53b3383d0388e596ed1e9b3a79af000d5021d 100644 (file)
@@ -2,22 +2,22 @@ import unittest
 import model
 from TestSketcher import SketcherTestCase
 
-class SketcherAddLine(SketcherTestCase):    
+class SketcherAddLine(SketcherTestCase):
     def test_add_line(self):
         line = self.sketch.addLine(0, 0, 0, 1)
         model.do()
-        self.assertEqual(line.getStartPoint().x(), line.getEndPoint().x())        
-        self.assertNotEqual(line.getStartPoint().y(), line.getEndPoint().y())
+        self.assertEqual(line.startPoint().x(), line.endPoint().x())
+        self.assertNotEqual(line.startPoint().y(), line.endPoint().y())
 
     def test_modify_line(self):
         line = self.sketch.addLine(0, 0, 0, 1)
         model.do()
         line.setStartPoint(0, 1)
         line.setEndPoint(1, 1)
-        self.assertEqual(line.getStartPoint().x(), 0)
-        self.assertEqual(line.getStartPoint().y(), 1)
-        self.assertEqual(line.getEndPoint().x(), 1)
-        self.assertEqual(line.getEndPoint().y(), 1)
+        self.assertEqual(line.startPoint().x(), 0)
+        self.assertEqual(line.startPoint().y(), 1)
+        self.assertEqual(line.endPoint().x(), 1)
+        self.assertEqual(line.endPoint().y(), 1)
 
 
 if __name__ == "__main__":
index 3a8c553ae55484d033b6f615776865496ef2d784..c5b71cbf40ccce7e3dfcf16ba5da6ee283bc980e 100644 (file)
@@ -14,7 +14,7 @@ from tools import Selection
 
 # Built-in features
 
-from sketcher.sketch  import addSketch
+from sketcher import *
 from connection import *
 from construction import *
 from exchange import *
index b978bd0255f496e2bf6b956f9c941b3bbd8fa918..593505f5602deb51d969c290286411b752d31ed4 100644 (file)
@@ -43,7 +43,7 @@ def defaultPlane (name):
         n = GeomAPI.GeomAPI_Dir(1, 0, 0)
         x = GeomAPI.GeomAPI_Dir(0, 1, 0)
 
-    return geom.Ax3(o, n, x)
+    return GeomAPI.GeomAPI_Ax3(o, n, x)
 
 
 def begin ():
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..ca52438730f3b8e1c5c6a6f0653ad7eeafefe127 100644 (file)
@@ -0,0 +1,4 @@
+"""Package for Sketch plugin for the Parametric Geometry API of the Modeler.
+"""
+
+from SketchAPI import addSketch
\ No newline at end of file
diff --git a/src/SketchAPI/CMakeLists.txt b/src/SketchAPI/CMakeLists.txt
new file mode 100644 (file)
index 0000000..4a62c01
--- /dev/null
@@ -0,0 +1,83 @@
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+INCLUDE(Common)
+
+SET(PROJECT_HEADERS
+  SketchAPI.h
+  SketchAPI_Line.h
+  SketchAPI_Sketch.h
+  SketchAPI_SketchEntity.h
+)
+
+SET(PROJECT_SOURCES
+  SketchAPI_Line.cpp
+  SketchAPI_Sketch.cpp
+  SketchAPI_SketchEntity.cpp
+)
+
+SET(PROJECT_LIBRARIES
+  ModelAPI
+  ModelHighAPI
+)
+
+INCLUDE_DIRECTORIES(
+  ${PROJECT_SOURCE_DIR}/src/Events
+  ${PROJECT_SOURCE_DIR}/src/GeomDataAPI
+  ${PROJECT_SOURCE_DIR}/src/ModelAPI
+  ${PROJECT_SOURCE_DIR}/src/ModelHighAPI
+)
+
+# Plugin headers dependency
+INCLUDE_DIRECTORIES(
+  # TODO(spo): modify ConstructionPlugin headers to remove dependency on GeomAPI headers
+  ${PROJECT_SOURCE_DIR}/src/Config
+  ${PROJECT_SOURCE_DIR}/src/GeomAPI
+  ${PROJECT_SOURCE_DIR}/src/SketchPlugin
+)
+
+#TODO(spo): is ${CAS_DEFINITIONS} necessary?
+ADD_DEFINITIONS(-DSKETCHAPI_EXPORTS ${CAS_DEFINITIONS})
+ADD_LIBRARY(SketchAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+TARGET_LINK_LIBRARIES(SketchAPI ${PROJECT_LIBRARIES})
+
+# SWIG wrapper
+
+INCLUDE(PythonAPI)
+
+SET_SOURCE_FILES_PROPERTIES(SketchAPI.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(SketchAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+
+#TODO(spo): is ModelAPI necessary or it could be received by INTERFACE_ (may require modern CMake)?
+SET(SWIG_LINK_LIBRARIES
+  SketchAPI
+  ModelHighAPI
+  ModelAPI
+  ${PYTHON_LIBRARIES}
+)
+
+SET(SWIG_MODULE_SketchAPI_EXTRA_DEPS ${SWIG_MODULE_SketchAPI_EXTRA_DEPS}
+  ${PROJECT_SOURCE_DIR}/src/ModelHighAPI/ModelHighAPI.i
+  doxyhelp.i
+  ${PROJECT_HEADERS}
+)
+
+SWIG_ADD_MODULE(SketchAPI python SketchAPI.i ${PROJECT_HEADERS})
+SWIG_LINK_LIBRARIES(SketchAPI ${SWIG_LINK_LIBRARIES})
+
+IF(WIN32)
+  SET_TARGET_PROPERTIES(_SketchAPI PROPERTIES DEBUG_OUTPUT_NAME _SketchAPI_d)
+ENDIF(WIN32)
+
+INSTALL(TARGETS _SketchAPI DESTINATION ${SHAPER_INSTALL_SWIG})
+INSTALL(TARGETS SketchAPI DESTINATION ${SHAPER_INSTALL_BIN})
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/SketchAPI.py DESTINATION ${SHAPER_INSTALL_SWIG})
+
+# Tests
+
+INCLUDE(UnitTest)
+
+ADD_UNIT_TESTS(
+  TestSketch.py
+)
+
+# ADD_SUBDIRECTORY (Test)
diff --git a/src/SketchAPI/SketchAPI.h b/src/SketchAPI/SketchAPI.h
new file mode 100644 (file)
index 0000000..f55dd62
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#ifndef SKETCHAPI_H
+#define SKETCHAPI_H
+
+#if defined SKETCHAPI_EXPORTS
+#if defined WIN32
+#define SKETCHAPI_EXPORT __declspec( dllexport )
+#else
+#define SKETCHAPI_EXPORT
+#endif
+#else
+#if defined WIN32
+#define SKETCHAPI_EXPORT __declspec( dllimport )
+#else
+#define SKETCHAPI_EXPORT
+#endif
+#endif
+
+#endif
diff --git a/src/SketchAPI/SketchAPI.i b/src/SketchAPI/SketchAPI.i
new file mode 100644 (file)
index 0000000..854d74f
--- /dev/null
@@ -0,0 +1,30 @@
+/* SketchAPI.i */
+
+%module SketchAPI
+
+%{
+  #include "SketchAPI_swig.h"
+%}
+
+%include "doxyhelp.i"
+
+// import other modules
+%import "ModelHighAPI.i"
+
+// to avoid error on this
+#define SKETCHAPI_EXPORT
+
+// standard definitions
+%include "typemaps.i"
+%include "std_list.i"
+%include "std_shared_ptr.i"
+
+// shared pointers
+%shared_ptr(SketchAPI_Line)
+%shared_ptr(SketchAPI_Sketch)
+%shared_ptr(SketchAPI_SketchEntity)
+
+// all supported interfaces
+%include "SketchAPI_Line.h"
+%include "SketchAPI_Sketch.h"
+%include "SketchAPI_SketchEntity.h"
diff --git a/src/SketchAPI/SketchAPI_Line.cpp b/src/SketchAPI/SketchAPI_Line.cpp
new file mode 100644 (file)
index 0000000..f36c91c
--- /dev/null
@@ -0,0 +1,129 @@
+// Name   : SketchAPI_Line.cpp
+// Purpose: 
+//
+// History:
+// 07/06/16 - Sergey POKHODENKO - Creation of the file
+
+//--------------------------------------------------------------------------------------
+#include "SketchAPI_Line.h"
+//--------------------------------------------------------------------------------------
+#include <GeomAPI_Pnt2d.h>
+//--------------------------------------------------------------------------------------
+#include <ModelHighAPI_Selection.h>
+#include <ModelHighAPI_Tools.h>
+//--------------------------------------------------------------------------------------
+SketchAPI_Line::SketchAPI_Line(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+SketchAPI_Line::SketchAPI_Line(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature,
+    double theX1, double theY1, double theX2, double theY2)
+: ModelHighAPI_Interface(theFeature)
+{
+  if (initialize()) {
+    setByCoordinates(theX1, theY1, theX2, theY2);
+  }
+}
+
+SketchAPI_Line::SketchAPI_Line(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature,
+    const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
+    const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
+: ModelHighAPI_Interface(theFeature)
+{
+  if (initialize()) {
+    setByPoints(theStartPoint, theEndPoint);
+  }
+}
+
+SketchAPI_Line::SketchAPI_Line(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature,
+    const ModelHighAPI_Selection & theExternal )
+: ModelHighAPI_Interface(theFeature)
+{
+  if (initialize()) {
+    setByExternal(theExternal);
+  }
+}
+
+SketchAPI_Line::SketchAPI_Line(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature,
+    const std::string & theExternalName )
+: ModelHighAPI_Interface(theFeature)
+{
+  if (initialize()) {
+    setByExternalName(theExternalName);
+  }
+}
+
+SketchAPI_Line::~SketchAPI_Line()
+{
+
+}
+
+//--------------------------------------------------------------------------------------
+void SketchAPI_Line::setByCoordinates(
+    double theX1, double theY1, double theX2, double theY2)
+{
+  fillAttribute(startPoint(), theX1, theY1);
+  fillAttribute(endPoint(), theX2, theY2);
+
+  execute();
+}
+
+void SketchAPI_Line::setByPoints(
+    const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
+    const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
+{
+  fillAttribute(theStartPoint, startPoint());
+  fillAttribute(theEndPoint, endPoint());
+
+  execute();
+}
+
+void SketchAPI_Line::setByExternal(const ModelHighAPI_Selection & theExternal)
+{
+  fillAttribute(theExternal, external());
+
+  execute();
+}
+
+void SketchAPI_Line::setByExternalName(const std::string & theExternalName)
+{
+  fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
+
+  execute();
+}
+
+//--------------------------------------------------------------------------------------
+void SketchAPI_Line::setStartPoint(double theX, double theY)
+{
+  fillAttribute(startPoint(), theX, theY);
+
+  execute();
+}
+void SketchAPI_Line::setStartPoint(const std::shared_ptr<GeomAPI_Pnt2d> & thePoint)
+{
+  fillAttribute(thePoint, startPoint());
+
+  execute();
+}
+void SketchAPI_Line::setEndPoint(double theX, double theY)
+{
+  fillAttribute(endPoint(), theX, theY);
+
+  execute();
+}
+void SketchAPI_Line::setEndPoint(const std::shared_ptr<GeomAPI_Pnt2d> & thePoint)
+{
+  fillAttribute(thePoint, endPoint());
+
+  execute();
+}
+
+//--------------------------------------------------------------------------------------
+
diff --git a/src/SketchAPI/SketchAPI_Line.h b/src/SketchAPI/SketchAPI_Line.h
new file mode 100644 (file)
index 0000000..5796c66
--- /dev/null
@@ -0,0 +1,98 @@
+// Name   : SketchAPI_Line.h
+// Purpose: 
+//
+// History:
+// 07/06/16 - Sergey POKHODENKO - Creation of the file
+
+#ifndef SRC_SKETCHAPI_SKETCHAPI_LINE_H_
+#define SRC_SKETCHAPI_SKETCHAPI_LINE_H_
+
+//--------------------------------------------------------------------------------------
+#include "SketchAPI.h"
+
+#include <GeomDataAPI_Point2D.h>
+
+#include <SketchPlugin_Line.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+//--------------------------------------------------------------------------------------
+class ModelHighAPI_Selection;
+//--------------------------------------------------------------------------------------
+/**\class SketchAPI_Line
+ * \ingroup CPPHighAPI
+ * \brief Interface for Line feature
+ */
+class SketchAPI_Line : public ModelHighAPI_Interface
+{
+public:
+  /// Constructor without values
+  SKETCHAPI_EXPORT
+  explicit SketchAPI_Line(const std::shared_ptr<ModelAPI_Feature> & theFeature);
+  /// Constructor with values
+  SKETCHAPI_EXPORT
+  SketchAPI_Line(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+                 double theX1, double theY1, double theX2, double theY2);
+  /// Constructor with values
+  SKETCHAPI_EXPORT
+  SketchAPI_Line(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+                 const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
+                 const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
+  /// Constructor with values
+  SKETCHAPI_EXPORT
+  SketchAPI_Line(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+                 const ModelHighAPI_Selection & theExternal);
+  /// Constructor with values
+  SKETCHAPI_EXPORT
+  SketchAPI_Line(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+                 const std::string & theExternalName);
+  /// Destructor
+  SKETCHAPI_EXPORT
+  virtual ~SketchAPI_Line();
+
+  INTERFACE_3(SketchPlugin_Line::ID(),
+              startPoint, SketchPlugin_Line::START_ID(), GeomDataAPI_Point2D, /** Start point */,
+              endPoint, SketchPlugin_Line::END_ID(), GeomDataAPI_Point2D, /** End point */,
+              external, SketchPlugin_Line::EXTERNAL_ID(), ModelAPI_AttributeSelection, /** External */
+  )
+
+  /// Set by coordinates
+  SKETCHAPI_EXPORT
+  void setByCoordinates(double theX1, double theY1, double theX2, double theY2);
+
+  /// Set by points
+  SKETCHAPI_EXPORT
+  void setByPoints(const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
+                   const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
+
+  /// Set by external
+  SKETCHAPI_EXPORT
+  void setByExternal(const ModelHighAPI_Selection & theExternal);
+
+  /// Set by external name
+  SKETCHAPI_EXPORT
+  void setByExternalName(const std::string & theExternalName);
+
+  /// Set start point
+  SKETCHAPI_EXPORT
+  void setStartPoint(double theX, double theY);
+
+  /// Set start point
+  SKETCHAPI_EXPORT
+  void setStartPoint(const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
+
+  /// Set end point
+  SKETCHAPI_EXPORT
+  void setEndPoint(double theX, double theY);
+
+  /// Set end point
+  SKETCHAPI_EXPORT
+  void setEndPoint(const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
+};
+
+//! Pointer on Line object
+typedef std::shared_ptr<SketchAPI_Line> LinePtr;
+
+//--------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------
+#endif /* SRC_SKETCHAPI_SKETCHAPI_LINE_H_ */
diff --git a/src/SketchAPI/SketchAPI_Sketch.cpp b/src/SketchAPI/SketchAPI_Sketch.cpp
new file mode 100644 (file)
index 0000000..93d70ed
--- /dev/null
@@ -0,0 +1,110 @@
+// Name   : SketchAPI_Sketch.cpp
+// Purpose: 
+//
+// History:
+// 07/06/16 - Sergey POKHODENKO - Creation of the file
+
+//--------------------------------------------------------------------------------------
+#include "SketchAPI_Sketch.h"
+//--------------------------------------------------------------------------------------
+#include <ModelAPI_CompositeFeature.h>
+#include <ModelHighAPI_Tools.h>
+#include "SketchAPI_Line.h"
+//--------------------------------------------------------------------------------------
+SketchAPI_Sketch::SketchAPI_Sketch(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+SketchAPI_Sketch::SketchAPI_Sketch(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature,
+    const std::shared_ptr<GeomAPI_Ax3> & thePlane)
+: ModelHighAPI_Interface(theFeature)
+{
+  if (initialize()) {
+    setPlane(thePlane);
+  }
+}
+
+SketchAPI_Sketch::SketchAPI_Sketch(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature,
+    const ModelHighAPI_Selection & theExternal)
+: ModelHighAPI_Interface(theFeature)
+{
+  if (initialize()) {
+    setExternal(theExternal);
+  }
+}
+
+SketchAPI_Sketch::~SketchAPI_Sketch()
+{
+
+}
+
+//--------------------------------------------------------------------------------------
+std::shared_ptr<ModelAPI_CompositeFeature> SketchAPI_Sketch::compositeFeature() const
+{
+  return std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(feature());
+}
+
+//--------------------------------------------------------------------------------------
+void SketchAPI_Sketch::setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane)
+{
+  fillAttribute(thePlane->origin(), myorigin);
+  fillAttribute(thePlane->dirX(), mydirX);
+  fillAttribute(thePlane->normal(), mynormal);
+
+  execute();
+}
+
+void SketchAPI_Sketch::setExternal(const ModelHighAPI_Selection & theExternal)
+{
+  fillAttribute(theExternal, myexternal);
+
+  execute();
+}
+
+//--------------------------------------------------------------------------------------
+SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
+                    const std::shared_ptr<GeomAPI_Ax3> & thePlane)
+{
+  // TODO(spo): check that thePart is not empty
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(SketchAPI_Sketch::ID());
+  return SketchPtr(new SketchAPI_Sketch(aFeature, thePlane));
+}
+
+SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
+                    const ModelHighAPI_Selection & theExternal)
+{
+  // TODO(spo): check that thePart is not empty
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(SketchAPI_Sketch::ID());
+  return SketchPtr(new SketchAPI_Sketch(aFeature, theExternal));
+}
+
+//--------------------------------------------------------------------------------------
+std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(double theX1, double theY1, double theX2, double theY2)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
+  return LinePtr(new SketchAPI_Line(aFeature, theX1, theY1, theX2, theY2));
+}
+std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(
+    const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
+    const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
+  return LinePtr(new SketchAPI_Line(aFeature, theStartPoint, theEndPoint));
+}
+std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(const ModelHighAPI_Selection & theExternal)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
+  return LinePtr(new SketchAPI_Line(aFeature, theExternal));
+}
+std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(const std::string & theExternalName)
+{
+  // TODO(spo): Add constraint SketchConstraintRigid like in PythonAPI. Is it necessary?
+  std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
+  return LinePtr(new SketchAPI_Line(aFeature, theExternalName));
+}
+//--------------------------------------------------------------------------------------
diff --git a/src/SketchAPI/SketchAPI_Sketch.h b/src/SketchAPI/SketchAPI_Sketch.h
new file mode 100644 (file)
index 0000000..a85e8ef
--- /dev/null
@@ -0,0 +1,103 @@
+// Name   : SketchAPI_Sketch.h
+// Purpose: 
+//
+// History:
+// 07/06/16 - Sergey POKHODENKO - Creation of the file
+
+#ifndef SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
+#define SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
+
+//--------------------------------------------------------------------------------------
+#include "SketchAPI.h"
+
+#include <SketchPlugin_Sketch.h>
+#include <SketchPlugin_SketchEntity.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+//--------------------------------------------------------------------------------------
+class ModelAPI_CompositeFeature;
+class ModelHighAPI_Selection;
+class SketchAPI_Line;
+//--------------------------------------------------------------------------------------
+/**\class SketchAPI_Sketch
+ * \ingroup CPPHighAPI
+ * \brief Interface for Sketch feature
+ */
+class SketchAPI_Sketch : public ModelHighAPI_Interface
+{
+public:
+  /// Constructor without values
+  SKETCHAPI_EXPORT
+  explicit SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature);
+  /// Constructor with values
+  SKETCHAPI_EXPORT
+  SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+                   const std::shared_ptr<GeomAPI_Ax3> & thePlane);
+  /// Constructor with values
+  SKETCHAPI_EXPORT
+  SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+                   const ModelHighAPI_Selection & theExternal);
+  /// Destructor
+  SKETCHAPI_EXPORT
+  virtual ~SketchAPI_Sketch();
+
+  INTERFACE_7(SketchPlugin_Sketch::ID(),
+              origin, SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point, /** Origin point */,
+              dirX, SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir, /** Direction of X */,
+              normal, SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir, /** Normal */,
+              features, SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList, /** Features */,
+              external, SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection, /** External */,
+              solverError, SketchPlugin_Sketch::SOLVER_ERROR(), ModelAPI_AttributeString, /** Solver error */,
+              solverDOF, SketchPlugin_Sketch::SOLVER_DOF(), ModelAPI_AttributeString, /** Solver DOF */
+  )
+
+  /// Set plane
+  SKETCHAPI_EXPORT
+  void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
+
+  /// Set external
+  SKETCHAPI_EXPORT
+  void setExternal(const ModelHighAPI_Selection & theExternal);
+
+  /// Add line
+  SKETCHAPI_EXPORT
+  std::shared_ptr<SketchAPI_Line> addLine(
+      double theX1, double theY1, double theX2, double theY2);
+  /// Add line
+  SKETCHAPI_EXPORT
+  std::shared_ptr<SketchAPI_Line> addLine(
+      const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
+      const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
+  /// Add line
+  SKETCHAPI_EXPORT
+  std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
+  /// Add line
+  SKETCHAPI_EXPORT
+  std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
+
+protected:
+  std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
+
+};
+
+//! Pointer on Sketch object
+typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
+
+/**\ingroup CPPHighAPI
+ * \brief Create Sketch feature
+ */
+SKETCHAPI_EXPORT
+SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
+                    const std::shared_ptr<GeomAPI_Ax3> & thePlane);
+
+/**\ingroup CPPHighAPI
+ * \brief Create Sketch feature
+ */
+SKETCHAPI_EXPORT
+SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
+                    const ModelHighAPI_Selection & theExternal);
+
+//--------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------
+#endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */
diff --git a/src/SketchAPI/SketchAPI_SketchEntity.cpp b/src/SketchAPI/SketchAPI_SketchEntity.cpp
new file mode 100644 (file)
index 0000000..a017576
--- /dev/null
@@ -0,0 +1,45 @@
+// Name   : SketchAPI_SketchEntity.cpp
+// Purpose: 
+//
+// History:
+// 07/06/16 - Sergey POKHODENKO - Creation of the file
+
+//--------------------------------------------------------------------------------------
+#include "SketchAPI_SketchEntity.h"
+//--------------------------------------------------------------------------------------
+#include <ModelHighAPI_Tools.h>
+//--------------------------------------------------------------------------------------
+SketchAPI_SketchEntity::SketchAPI_SketchEntity(
+    const std::shared_ptr<ModelAPI_Feature> & theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+SketchAPI_SketchEntity::~SketchAPI_SketchEntity()
+{
+
+}
+
+//--------------------------------------------------------------------------------------
+bool SketchAPI_SketchEntity::initialize()
+{
+  SET_ATTRIBUTE(Auxiliary, ModelAPI_AttributeBoolean, SketchPlugin_SketchEntity::AUXILIARY_ID())
+
+  return true;
+}
+
+//--------------------------------------------------------------------------------------
+std::shared_ptr<ModelAPI_AttributeBoolean> SketchAPI_SketchEntity::auxiliary() const
+{
+  return myAuxiliary;
+}
+
+void SketchAPI_SketchEntity::setAuxiliary(bool theAuxiliary)
+{
+  fillAttribute(theAuxiliary, myAuxiliary);
+
+  execute();
+}
+
+//--------------------------------------------------------------------------------------
diff --git a/src/SketchAPI/SketchAPI_SketchEntity.h b/src/SketchAPI/SketchAPI_SketchEntity.h
new file mode 100644 (file)
index 0000000..5ac166a
--- /dev/null
@@ -0,0 +1,51 @@
+// Name   : SketchAPI_SketchEntity.h
+// Purpose: 
+//
+// History:
+// 07/06/16 - Sergey POKHODENKO - Creation of the file
+
+#ifndef SRC_SKETCHAPI_SKETCHAPI_SKETCHENTITY_H_
+#define SRC_SKETCHAPI_SKETCHAPI_SKETCHENTITY_H_
+
+//--------------------------------------------------------------------------------------
+#include "SketchAPI.h"
+
+#include <SketchPlugin_SketchEntity.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+//--------------------------------------------------------------------------------------
+/**\class SketchAPI_SketchEntity
+ * \ingroup CPPHighAPI
+ * \brief Base class for Sketch feature interfaces
+ */
+class SketchAPI_SketchEntity : public ModelHighAPI_Interface
+{
+public:
+  /// Constructor without values
+  SKETCHAPI_EXPORT
+  explicit SketchAPI_SketchEntity(const std::shared_ptr<ModelAPI_Feature> & theFeature);
+  /// Destructor
+  SKETCHAPI_EXPORT
+  virtual ~SketchAPI_SketchEntity();
+
+  /// Auxiliary
+  SKETCHAPI_EXPORT
+  std::shared_ptr<ModelAPI_AttributeBoolean> auxiliary() const;
+
+  /// Set auxiliary
+  SKETCHAPI_EXPORT
+  void setAuxiliary(bool theAuxiliary);
+
+protected:
+  std::shared_ptr<ModelAPI_AttributeBoolean> myAuxiliary;
+
+  bool initialize();
+};
+
+//! Pointer on SketchEntity object
+typedef std::shared_ptr<SketchAPI_SketchEntity> SketchEntityPtr;
+
+//--------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------
+#endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCHENTITY_H_ */
diff --git a/src/SketchAPI/SketchAPI_swig.h b/src/SketchAPI/SketchAPI_swig.h
new file mode 100644 (file)
index 0000000..67b2725
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:    SketchAPI_swig.h
+// Created: 07/06/16
+// Author:  Sergey POKHODENKO
+
+#ifndef SRC_SKETCHAPI_SKETCHAPI_SWIG_H_
+#define SRC_SKETCHAPI_SKETCHAPI_SWIG_H_
+
+  #include <ModelHighAPI_swig.h>
+
+  #include "SketchAPI.h"
+  #include "SketchAPI_Line.h"
+  #include "SketchAPI_Sketch.h"
+  #include "SketchAPI_SketchEntity.h"
+
+#endif /* SRC_SKETCHAPI_SKETCHAPI_SWIG_H_ */
diff --git a/src/SketchAPI/Test/TestSketch.py b/src/SketchAPI/Test/TestSketch.py
new file mode 100644 (file)
index 0000000..5f1576c
--- /dev/null
@@ -0,0 +1,26 @@
+import unittest
+
+import ModelAPI
+import ExchangeAPI
+
+class PointTestCase(unittest.TestCase):
+
+    def setUp(self):
+        self.session = ModelAPI.ModelAPI_Session.get()
+        self.doc = self.session.moduleDocument()
+
+    def tearDown(self):
+        self.session.closeAll()
+
+    def test_addImport(self):
+        self.session.startOperation()
+        self.feature = ExchangeAPI.addImport(self.doc, "file_path")
+        self.session.finishOperation()
+
+    def test_addExport(self):
+        self.session.startOperation()
+        self.feature = ExchangeAPI.exportToFile(self.doc, "file_path", "file_format", [])
+        self.session.finishOperation()
+
+if __name__ == "__main__":
+    unittest.main()