]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Added interfaces to OCC data and algos: features must not depend on OCC
authormpv <mikhail.ponikarov@opencascade.com>
Wed, 23 Apr 2014 08:01:23 +0000 (12:01 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Wed, 23 Apr 2014 08:01:23 +0000 (12:01 +0400)
25 files changed:
CMakeLists.txt
src/Config/plugin-Sketch.xml [deleted file]
src/GeomAPI/CMakeLists.txt [new file with mode: 0644]
src/GeomAPI/GeomAPI.h [new file with mode: 0644]
src/GeomAPI/GeomAPI.i [new file with mode: 0644]
src/GeomAPI/GeomAPI_Dir.cpp [new file with mode: 0644]
src/GeomAPI/GeomAPI_Dir.h [new file with mode: 0644]
src/GeomAPI/GeomAPI_Interface.cpp [new file with mode: 0644]
src/GeomAPI/GeomAPI_Interface.h [new file with mode: 0644]
src/GeomAPI/GeomAPI_Pnt.cpp [new file with mode: 0644]
src/GeomAPI/GeomAPI_Pnt.h [new file with mode: 0644]
src/GeomAPI/GeomAPI_Shape.cpp [new file with mode: 0644]
src/GeomAPI/GeomAPI_Shape.h [new file with mode: 0644]
src/GeomAlgoAPI/CMakeLists.txt [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI.h [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI.i [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.h [new file with mode: 0644]
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_OperationSketchBase.cpp
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_Feature.cpp
src/SketchPlugin/SketchPlugin_Feature.h
src/SketchPlugin/SketchPlugin_Sketch.cpp
src/SketchPlugin/SketchPlugin_Sketch.h

index dc4b8fd191e0706ff1d6fbfeffaf69c846558569..b61b627094ba80b70ff55a7be3a27b81ec3a8ae6 100644 (file)
@@ -22,11 +22,13 @@ ADD_SUBDIRECTORY (src/Config)
 ADD_SUBDIRECTORY (src/Event)
 ADD_SUBDIRECTORY (src/Model)
 ADD_SUBDIRECTORY (src/ModelAPI)
-ADD_SUBDIRECTORY (src/ModuleBase)
-ADD_SUBDIRECTORY (src/PartSet)
+ADD_SUBDIRECTORY (src/GeomAPI)
+ADD_SUBDIRECTORY (src/GeomAlgoAPI)
 ADD_SUBDIRECTORY (src/PartSetPlugin)
 ADD_SUBDIRECTORY (src/ConstructionPlugin)
 ADD_SUBDIRECTORY (src/SketchPlugin)
+ADD_SUBDIRECTORY (src/ModuleBase)
+ADD_SUBDIRECTORY (src/PartSet)
 ADD_SUBDIRECTORY (src/PyConsole)
 ADD_SUBDIRECTORY (src/PyEvent)
 ADD_SUBDIRECTORY (src/PyInterp)
diff --git a/src/Config/plugin-Sketch.xml b/src/Config/plugin-Sketch.xml
deleted file mode 100644 (file)
index 755458b..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<plugin>
-  <workbench id="Sketch">
-    <group id="Basic">
-      <feature id="Sketch" text="New sketch" tooltip="Create a new sketch or edit an existing sketch" icon=":icons/sketch.png"/>
-    </group>
-    <group id="Operations">
-      <feature id="Point" text="New point" tooltip="Create a new point" icon=":icons/point.png">
-        <doublevalue id="x" label="X:" min="0" max="" step="0.1" default="0"
-               icon=":pictures/x_point.png" tooltip="Set X"/>
-        <doublevalue id="y" label="Y:" min="0" max="" step="0.1" default="1"
-               icon=":pictures/y_point.png" tooltip="Set Y"/>
-        <doublevalue id="z" label="Z:" min="0" max="10" step="0.1" default="2"
-               icon=":pictures/z_point.png" tooltip="Set Z"/>
-      </feature>
-      <feature id="Line" text="New line" tooltip="Create a new line" icon=":icons/line.png"/>
-    </group>
-  </workbench>
-</plugin>
diff --git a/src/GeomAPI/CMakeLists.txt b/src/GeomAPI/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1516267
--- /dev/null
@@ -0,0 +1,54 @@
+FIND_PACKAGE(SWIG REQUIRED)
+INCLUDE(FindCAS)
+
+INCLUDE(${SWIG_USE_FILE})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+SET(PROJECT_HEADERS
+    GeomAPI.h
+    GeomAPI_Interface.h
+    GeomAPI_Pnt.h
+    GeomAPI_Dir.h
+    GeomAPI_Shape.h
+)
+
+SET(PROJECT_SOURCES
+    GeomAPI_Interface.cpp
+    GeomAPI_Pnt.cpp
+    GeomAPI_Dir.cpp
+    GeomAPI_Shape.cpp
+)
+
+ADD_DEFINITIONS(-DGEOMAPI_EXPORTS ${CAS_DEFINITIONS})
+ADD_LIBRARY(GeomAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+
+SET(CMAKE_SWIG_FLAGS "")
+
+SET_SOURCE_FILES_PROPERTIES(GeomAPI.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(GeomAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+
+INCLUDE_DIRECTORIES(
+  ${CAS_INCLUDE_DIRS}
+)
+
+TARGET_LINK_LIBRARIES(GeomAPI ${PROJECT_LIBRARIES} ${CAS_KERNEL})
+
+SET(SWIG_SCRIPTS
+  ${CMAKE_CURRENT_BINARY_DIR}/GeomAPI.py
+)
+
+SET(SWIG_LINK_LIBRARIES
+  GeomAPI
+  ${PYTHON_LIBRARIES}
+)
+
+SWIG_ADD_MODULE(GeomAPI python GeomAPI.i ${PROJECT_HEADERS})
+SWIG_LINK_LIBRARIES(GeomAPI ${SWIG_LINK_LIBRARIES})
+
+IF(WIN32)
+  SET_TARGET_PROPERTIES(_GeomAPI PROPERTIES DEBUG_OUTPUT_NAME _GeomAPI_d)
+ENDIF(WIN32)
+
+INSTALL(TARGETS _GeomAPI DESTINATION swig)
+INSTALL(TARGETS GeomAPI DESTINATION bin)
+INSTALL(FILES ${SWIG_SCRIPTS} DESTINATION swig)
diff --git a/src/GeomAPI/GeomAPI.h b/src/GeomAPI/GeomAPI.h
new file mode 100644 (file)
index 0000000..f27fc48
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef GEOMAPI_H
+#define GEOMAPI_H
+
+#if defined GEOMAPI_EXPORTS
+#if defined WIN32
+#define GEOMAPI_EXPORT              __declspec( dllexport )
+#else
+#define GEOMAPI_EXPORT
+#endif
+#else
+#if defined WIN32
+#define GEOMAPI_EXPORT              __declspec( dllimport )
+#else
+#define GEOMAPI_EXPORT
+#endif
+#endif
+
+#endif
diff --git a/src/GeomAPI/GeomAPI.i b/src/GeomAPI/GeomAPI.i
new file mode 100644 (file)
index 0000000..717c7d2
--- /dev/null
@@ -0,0 +1,28 @@
+/* GeomAPI.i */
+%module GeomAPI
+%{
+  #include "memory"
+  #include "GeomAPI.h"
+  #include "GeomAPI_Interface.h"
+  #include "GeomAPI_Pnt.h"
+  #include "GeomAPI_Shape.h"
+%}
+
+// to avoid error on this
+#define GEOMAPI_EXPORT
+
+// standard definitions
+%include "typemaps.i"
+%include "std_string.i"
+%include <std_shared_ptr.i>
+
+// boost pointers
+// %include <boost_shared_ptr.i>
+%shared_ptr(GeomAPI_Interface)
+%shared_ptr(GeomAPI_Pnt)
+%shared_ptr(GeomAPI_Shape)
+
+// all supported interfaces
+%include "GeomAPI_Interface.h"
+%include "GeomAPI_Pnt.h"
+%include "GeomAPI_Shape.h"
diff --git a/src/GeomAPI/GeomAPI_Dir.cpp b/src/GeomAPI/GeomAPI_Dir.cpp
new file mode 100644 (file)
index 0000000..bf0941c
--- /dev/null
@@ -0,0 +1,28 @@
+// File:        GeomAPI_Dir.cpp
+// Created:     23 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#include<GeomAPI_Dir.h>
+
+#include<gp_Dir.hxx>
+
+#define MY_DIR static_cast<gp_Pnt*>(myImpl)
+
+GeomAPI_Dir::GeomAPI_Dir(const double theX, const double theY, const double theZ)
+  : GeomAPI_Interface(new gp_Dir(theX, theY, theZ))
+{}
+
+double GeomAPI_Dir::x() const
+{
+  return MY_DIR->X();
+}
+
+double GeomAPI_Dir::y() const
+{
+  return MY_DIR->Y();
+}
+
+double GeomAPI_Dir::z() const
+{
+  return MY_DIR->Z();
+}
diff --git a/src/GeomAPI/GeomAPI_Dir.h b/src/GeomAPI/GeomAPI_Dir.h
new file mode 100644 (file)
index 0000000..a003d38
--- /dev/null
@@ -0,0 +1,30 @@
+// File:        GeomAPI_Dir.hxx
+// Created:     23 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef GeomAPI_Dir_HeaderFile
+#define GeomAPI_Dir_HeaderFile
+
+#include <GeomAPI_Interface.h>
+
+/**\class GeomAPI_Dir
+ * \ingroup DataModel
+ * \brief 3D direction defined by three normalized coordinates
+ */
+
+class GEOMAPI_EXPORT GeomAPI_Dir: public GeomAPI_Interface
+{
+public:
+  /// Creation of direction by coordinates
+  GeomAPI_Dir(const double theX, const double theY, const double theZ);
+
+  /// returns X coordinate
+  double x() const;
+  /// returns Y coordinate
+  double y() const;
+  /// returns Z coordinate
+  double z() const;
+};
+
+#endif
+
diff --git a/src/GeomAPI/GeomAPI_Interface.cpp b/src/GeomAPI/GeomAPI_Interface.cpp
new file mode 100644 (file)
index 0000000..5e9b257
--- /dev/null
@@ -0,0 +1,33 @@
+// File:        GeomAPI_Interface.cpp
+// Created:     23 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#include <GeomAPI_Interface.h>
+
+GeomAPI_Interface::GeomAPI_Interface()
+{
+  myImpl = 0;
+}
+
+GeomAPI_Interface::GeomAPI_Interface(void* theImpl)
+{
+  myImpl = theImpl;
+}
+
+GeomAPI_Interface::~GeomAPI_Interface()
+{
+  if (myImpl)
+    delete myImpl;
+}
+
+void* GeomAPI_Interface::implementation()
+{
+  return myImpl;
+}
+
+void GeomAPI_Interface::setImplementation(void* theImpl)
+{
+  if (myImpl)
+    delete myImpl;
+  myImpl = theImpl;
+}
diff --git a/src/GeomAPI/GeomAPI_Interface.h b/src/GeomAPI/GeomAPI_Interface.h
new file mode 100644 (file)
index 0000000..1a60559
--- /dev/null
@@ -0,0 +1,37 @@
+// File:        GeomAPI_Interface.hxx
+// Created:     23 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef GeomAPI_Interface_HeaderFile
+#define GeomAPI_Interface_HeaderFile
+
+#include <GeomAPI.h>
+
+/**\class GeomAPI_Interface
+ * \ingroup DataModel
+ * \brief General base class for all interfaces in this package
+ */
+
+class GEOMAPI_EXPORT GeomAPI_Interface
+{
+protected:
+  void* myImpl; ///< pointer to the internal implementation object
+
+public:
+  /// None - constructor
+  GeomAPI_Interface();
+
+  /// Constructor by the implementation pointer (used for internal needs)
+  GeomAPI_Interface(void* theImpl);
+  
+  /// Destructor
+  virtual ~GeomAPI_Interface();
+
+  /// Returns the pointer to the implementation
+  void* implementation();
+  /// Updates the implementation (deletes the old one)
+  void setImplementation(void* theImpl);
+};
+
+#endif
+
diff --git a/src/GeomAPI/GeomAPI_Pnt.cpp b/src/GeomAPI/GeomAPI_Pnt.cpp
new file mode 100644 (file)
index 0000000..6414a2d
--- /dev/null
@@ -0,0 +1,43 @@
+// File:        GeomAPI_Pnt.cpp
+// Created:     23 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#include<GeomAPI_Pnt.h>
+
+#include<gp_Pnt.hxx>
+
+#define MY_PNT static_cast<gp_Pnt*>(myImpl)
+
+GeomAPI_Pnt::GeomAPI_Pnt(const double theX, const double theY, const double theZ)
+  : GeomAPI_Interface(new gp_Pnt(theX, theY, theZ))
+{}
+
+double GeomAPI_Pnt::x() const
+{
+  return MY_PNT->X();
+}
+
+double GeomAPI_Pnt::y() const
+{
+  return MY_PNT->Y();
+}
+
+double GeomAPI_Pnt::z() const
+{
+  return MY_PNT->Z();
+}
+
+void GeomAPI_Pnt::setX(const double theX)
+{
+  return MY_PNT->SetX(theX);
+}
+
+void GeomAPI_Pnt::setY(const double theY)
+{
+  return MY_PNT->SetY(theY);
+}
+
+void GeomAPI_Pnt::setZ(const double theZ)
+{
+  return MY_PNT->SetZ(theZ);
+}
diff --git a/src/GeomAPI/GeomAPI_Pnt.h b/src/GeomAPI/GeomAPI_Pnt.h
new file mode 100644 (file)
index 0000000..8f80bef
--- /dev/null
@@ -0,0 +1,37 @@
+// File:        GeomAPI_Pnt.hxx
+// Created:     23 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef GeomAPI_Pnt_HeaderFile
+#define GeomAPI_Pnt_HeaderFile
+
+#include <GeomAPI_Interface.h>
+
+/**\class GeomAPI_Pnt
+ * \ingroup DataModel
+ * \brief 3D point defined by three coordinates
+ */
+
+class GEOMAPI_EXPORT GeomAPI_Pnt: public GeomAPI_Interface
+{
+public:
+  /// Creation of point by coordinates
+  GeomAPI_Pnt(const double theX, const double theY, const double theZ);
+
+  /// returns X coordinate
+  double x() const;
+  /// returns Y coordinate
+  double y() const;
+  /// returns Z coordinate
+  double z() const;
+
+  /// sets X coordinate
+  void setX(const double theX);
+  /// sets Y coordinate
+  void setY(const double theY);
+  /// sets Z coordinate
+  void setZ(const double theZ);
+};
+
+#endif
+
diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp
new file mode 100644 (file)
index 0000000..e662ea2
--- /dev/null
@@ -0,0 +1,13 @@
+// File:        GeomAPI_Shape.cpp
+// Created:     23 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#include<GeomAPI_Shape.h>
+
+#include<TopoDS_Shape.hxx>
+
+#define MY_PNT static_cast<gp_Pnt*>(myImpl)
+
+GeomAPI_Shape::GeomAPI_Shape()
+  : GeomAPI_Interface(new TopoDS_Shape())
+{}
diff --git a/src/GeomAPI/GeomAPI_Shape.h b/src/GeomAPI/GeomAPI_Shape.h
new file mode 100644 (file)
index 0000000..8a9d3b2
--- /dev/null
@@ -0,0 +1,23 @@
+// File:        GeomAPI_Shape.hxx
+// Created:     23 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef GeomAPI_Shape_HeaderFile
+#define GeomAPI_Shape_HeaderFile
+
+#include <GeomAPI_Interface.h>
+
+/**\class GeomAPI_Shape
+ * \ingroup DataModel
+ * \brief Interface to the topological shape object
+ */
+
+class GEOMAPI_EXPORT GeomAPI_Shape: public GeomAPI_Interface
+{
+public:
+  /// Creation of empty (null) shape
+  GeomAPI_Shape();
+};
+
+#endif
+
diff --git a/src/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt
new file mode 100644 (file)
index 0000000..509d8ac
--- /dev/null
@@ -0,0 +1,49 @@
+FIND_PACKAGE(SWIG REQUIRED)
+INCLUDE(FindCAS)
+
+INCLUDE(${SWIG_USE_FILE})
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+
+SET(PROJECT_HEADERS
+    GeomAlgoAPI.h
+    GeomAlgoAPI_FaceBuilder.h
+)
+
+SET(PROJECT_SOURCES
+    GeomAlgoAPI_FaceBuilder.cpp
+)
+
+ADD_DEFINITIONS(-DGEOMALGOAPI_EXPORTS ${CAS_DEFINITIONS})
+ADD_LIBRARY(GeomAlgoAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+
+SET(CMAKE_SWIG_FLAGS "")
+
+SET_SOURCE_FILES_PROPERTIES(GeomAlgoAPI.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(GeomAlgoAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+
+INCLUDE_DIRECTORIES(
+  ../GeomAPI
+  ${CAS_INCLUDE_DIRS}
+)
+
+TARGET_LINK_LIBRARIES(GeomAlgoAPI ${PROJECT_LIBRARIES} GeomAPI ${CAS_KERNEL} ${CAS_MODELER})
+
+SET(SWIG_SCRIPTS
+  ${CMAKE_CURRENT_BINARY_DIR}/GeomAlgoAPI.py
+)
+
+SET(SWIG_LINK_LIBRARIES
+  GeomAlgoAPI
+  ${PYTHON_LIBRARIES}
+)
+
+SWIG_ADD_MODULE(GeomAlgoAPI python GeomAlgoAPI.i ${PROJECT_HEADERS})
+SWIG_LINK_LIBRARIES(GeomAlgoAPI ${SWIG_LINK_LIBRARIES})
+
+IF(WIN32)
+  SET_TARGET_PROPERTIES(_GeomAlgoAPI PROPERTIES DEBUG_OUTPUT_NAME _GeomAlgoAPI_d)
+ENDIF(WIN32)
+
+INSTALL(TARGETS _GeomAlgoAPI DESTINATION swig)
+INSTALL(TARGETS GeomAlgoAPI DESTINATION bin)
+INSTALL(FILES ${SWIG_SCRIPTS} DESTINATION swig)
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI.h b/src/GeomAlgoAPI/GeomAlgoAPI.h
new file mode 100644 (file)
index 0000000..fc7d33b
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef GEOMALGOAPI_H
+#define GEOMALGOAPI_H
+
+#if defined GEOMALGOAPI_EXPORTS
+#if defined WIN32
+#define GEOMALGOAPI_EXPORT              __declspec( dllexport )
+#else
+#define GEOMALGOAPI_EXPORT
+#endif
+#else
+#if defined WIN32
+#define GEOMALGOAPI_EXPORT              __declspec( dllimport )
+#else
+#define GEOMALGOAPI_EXPORT
+#endif
+#endif
+
+#endif
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI.i b/src/GeomAlgoAPI/GeomAlgoAPI.i
new file mode 100644 (file)
index 0000000..4e71ea1
--- /dev/null
@@ -0,0 +1,18 @@
+/* GeomAPI.i */
+%module GeomAlgoAPI
+%{
+  #include "memory"
+  #include "GeomAlgoAPI.h"
+  #include "GeomAlgoAPI_FaceBuilder.h"
+%}
+
+// to avoid error on this
+#define GEOMALGOAPI_EXPORT
+
+// standard definitions
+%include "typemaps.i"
+%include "std_string.i"
+%include <std_shared_ptr.i>
+
+// all supported interfaces
+%include "GeomAlgoAPI_FaceBuilder.h"
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp
new file mode 100644 (file)
index 0000000..bec2c7f
--- /dev/null
@@ -0,0 +1,23 @@
+// File:        GeomAlgoAPI_FaceBuilder.cpp
+// Created:     23 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#include <GeomAlgoAPI_FaceBuilder.h>
+#include <gp_Pln.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <TopoDS_Face.hxx>
+
+std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::square(
+  std::shared_ptr<GeomAPI_Pnt> theCenter, std::shared_ptr<GeomAPI_Dir> theNormal,
+  const double theSize)
+{
+  gp_Pnt* aCenter = static_cast<gp_Pnt*>(theCenter->implementation());
+  gp_Dir* aDir = static_cast<gp_Dir*>(theNormal->implementation());
+  gp_Pln aPlane(*aCenter, *aDir);
+  // half of the size in each direction from the center
+  BRepBuilderAPI_MakeFace aFaceBuilder(aPlane, 
+    -theSize / 2., theSize / 2., -theSize / 2., theSize / 2.);
+  std::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
+  aRes->setImplementation(new TopoDS_Shape(aFaceBuilder.Face()));
+  return aRes;
+}
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.h b/src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.h
new file mode 100644 (file)
index 0000000..15243f2
--- /dev/null
@@ -0,0 +1,28 @@
+// File:        GeomAlgoAPI_FaceBuilder.h
+// Created:     23 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef GeomAlgoAPI_FaceBuilder_HeaderFile
+#define GeomAlgoAPI_FaceBuilder_HeaderFile
+
+#include <GeomAlgoAPI.h>
+#include <GeomAPI_Shape.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Dir.h>
+#include <memory>
+
+/**\class GeomAlgoAPI_FaceBuilder
+ * \ingroup DataAlgo
+ * \brief Allows to create face-shapes by different parameters
+ */
+
+class GEOMALGOAPI_EXPORT GeomAlgoAPI_FaceBuilder
+{
+public:
+  /// Creates square planar face by given point of the center,
+  /// normal to the plane and size of square
+  static std::shared_ptr<GeomAPI_Shape> square(std::shared_ptr<GeomAPI_Pnt> theCenter,
+    std::shared_ptr<GeomAPI_Dir> theNormal, const double theSize);
+};
+
+#endif
index c4d25a782b504e5b99d66092d66f8f95f72c9f05..a50b8cb1f4e6cdce63495d1a653567f3e5d2fcaf 100644 (file)
@@ -27,6 +27,7 @@ SET(TEXT_RESOURCES
 SET(PROJECT_LIBRARIES
     ModuleBase
     Config
+    GeomAPI
     ${QT_LIBRARIES}
     ${CAS_KERNEL}
 )
@@ -47,6 +48,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/XGUI
                     ${CMAKE_SOURCE_DIR}/src/ModuleBase
                     ${CMAKE_SOURCE_DIR}/src/ModelAPI
                     ${CMAKE_SOURCE_DIR}/src/SketchPlugin
+                    ${CMAKE_SOURCE_DIR}/src/GeomAPI
                     ${CAS_INCLUDE_DIRS}
 )
 
index c5b70b0e00d49e2615606c9a9b790d522b6685bb..0201255b81cc0b51778e9a61f56c66e31f9c281d 100644 (file)
@@ -32,7 +32,7 @@ PartSet_OperationSketchBase::~PartSet_OperationSketchBase()
 const TopoDS_Shape& PartSet_OperationSketchBase::preview() const
 {
   shared_ptr<SketchPlugin_Feature> aFeature = dynamic_pointer_cast<SketchPlugin_Feature>(feature());
-  return aFeature->preview();
+  return *(static_cast<TopoDS_Shape*>(aFeature->preview()->implementation()));
 }
 
 /*!
index f9e47c7a8608186c549be337a2117c65bd373da2..c075da118ed41a99d4bdb784058506ec5c116ec1 100644 (file)
@@ -1,5 +1,4 @@
 INCLUDE(Common)
-INCLUDE(FindCAS)
 
 SET(PROJECT_HEADERS
     SketchPlugin.h
@@ -15,17 +14,18 @@ SET(PROJECT_SOURCES
 )
 
 SET(PROJECT_LIBRARIES
-    ${CAS_KERNEL}
-    ${CAS_MODELER}
+    GeomAPI
+    GeomAlgoAPI
 )
 
-ADD_DEFINITIONS(-DSKETCHPLUGIN_EXPORTS ${BOOST_DEFINITIONS} ${CAS_DEFINITIONS})
+ADD_DEFINITIONS(-DSKETCHPLUGIN_EXPORTS ${BOOST_DEFINITIONS})
 ADD_LIBRARY(SketchPlugin SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
-TARGET_LINK_LIBRARIES(SketchPlugin ${PROJECT_LIBRARIES} ModelAPI)
+TARGET_LINK_LIBRARIES(SketchPlugin ${PROJECT_LIBRARIES} ModelAPI GeomAPI GeomAlgoAPI)
 
 INCLUDE_DIRECTORIES(
-  ${CAS_INCLUDE_DIRS}
   ../ModelAPI
+  ../GeomAPI
+  ../GeomAlgoAPI
 )
 
 SET(XML_RESOURCES
index 57bc3582d406a411e1e1cecd1029b40c14d2077c..27040b92d88233ed76e4bd3597fec416f546ca31 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * Returns the sketch preview
  */
-const TopoDS_Shape& SketchPlugin_Feature::preview()
+const std::shared_ptr<GeomAPI_Shape>& SketchPlugin_Feature::preview()
 {
   return myPreview;
 }
@@ -12,7 +12,7 @@ const TopoDS_Shape& SketchPlugin_Feature::preview()
  * Set the shape to the internal preview field
  * \param theShape a preview shape
  */
-void SketchPlugin_Feature::setPreview(const TopoDS_Shape& theShape)
+void SketchPlugin_Feature::setPreview(const std::shared_ptr<GeomAPI_Shape>& theShape)
 {
   myPreview = theShape;
 }
index 4b91631c9ed43e799a43ae00cf83959c8ffa2f5a..a440dbdfdd2a353e6f6c74530c5a990a277344da 100644 (file)
@@ -8,7 +8,7 @@
 #include "SketchPlugin.h"
 #include <ModelAPI_Feature.h>
 
-#include "TopoDS_Shape.hxx"
+#include <GeomAPI_Shape.h>
 
 /**\class SketchPlugin_Feature
  * \ingroup DataModel
 class SketchPlugin_Feature: public ModelAPI_Feature
 {
 public:
- SKETCHPLUGIN_EXPORT virtual const TopoDS_Shape& preview() = 0;
+ SKETCHPLUGIN_EXPORT virtual const std::shared_ptr<GeomAPI_Shape>& preview() = 0;
 
 protected:
-  void setPreview(const TopoDS_Shape& theShape); ///< the preview shape
+  void setPreview(const std::shared_ptr<GeomAPI_Shape>& theShape); ///< the preview shape
 
 private:
-  TopoDS_Shape myPreview; ///< the preview shape
+  std::shared_ptr<GeomAPI_Shape> myPreview; ///< the preview shape
 };
 
 #endif
index 7fb20f0798af5a74af220aebc6a835e99173ccda..9a3624daf39295bae1573005d6092ae084019731 100644 (file)
@@ -3,25 +3,13 @@
 // Author:      Mikhail PONIKAROV
 
 #include "SketchPlugin_Sketch.h"
-#include "ModelAPI_Data.h"
-#include "ModelAPI_AttributeDocRef.h"
+#include <ModelAPI_Data.h>
+#include <GeomAlgoAPI_FaceBuilder.h>
 
 using namespace std;
-#include <gp_Pln.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Vec.hxx>
 
-#include <TopoDS.hxx>
-#include <TopoDS_Shape.hxx>
-
-#include <BRep_Tool.hxx>
-#include <BRep_Builder.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
-
-const double PLANE_U_MIN = -100;
-const double PLANE_U_MAX = 100;
-const double PLANE_V_MIN = -100;
-const double PLANE_V_MAX = 100;
+// face of the square-face displayed for selection of general plane
+const double PLANE_SIZE = 200;
 
 SketchPlugin_Sketch::SketchPlugin_Sketch()
 {
@@ -29,28 +17,23 @@ SketchPlugin_Sketch::SketchPlugin_Sketch()
 
 void SketchPlugin_Sketch::initAttributes()
 {
-  data()->addAttribute(PART_ATTR_DOC_REF, ModelAPI_AttributeDocRef::type());
+  //data()->addAttribute(PART_ATTR_DOC_REF, ModelAPI_AttributeDocRef::type());
 }
 
 void SketchPlugin_Sketch::execute() 
 {
-  /*shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->docRef(PART_ATTR_DOC_REF);
-  if (!aDocRef->value()) { // create a document if not yet created
-    shared_ptr<ModelAPI_Document> aPartSetDoc = ModelAPI_PluginManager::get()->rootDocument();
-    aDocRef->setValue(aPartSetDoc->subDocument(data()->getName()));
-  }*/
 }
 
-const TopoDS_Shape& SketchPlugin_Sketch::preview()
+const shared_ptr<GeomAPI_Shape>& SketchPlugin_Sketch::preview()
 {
-  if (SketchPlugin_Feature::preview().IsNull())
+  if (!SketchPlugin_Feature::preview())
   {
-    gp_Pnt anOrigin(0, 0, 0);
-    gp_Dir aDir(gp_Vec(gp_Pnt(0,0,0), gp_Pnt(1,0,0)));
-    gp_Pln aPlane(anOrigin, aDir);
-    BRepBuilderAPI_MakeFace aFaceBuilder(aPlane, PLANE_U_MIN, PLANE_U_MAX, PLANE_V_MIN,
-                                         PLANE_V_MAX);
-    setPreview(aFaceBuilder.Face());
+
+    shared_ptr<GeomAPI_Pnt> anOrigin(new GeomAPI_Pnt(0, 0, 0));
+    shared_ptr<GeomAPI_Dir> aNormal(new GeomAPI_Dir(1, 0, 0));
+    shared_ptr<GeomAPI_Shape> aFace = 
+      GeomAlgoAPI_FaceBuilder::square(anOrigin, aNormal, PLANE_SIZE);
+    setPreview(aFace);
   }
   return SketchPlugin_Feature::preview();
 }
index a2b63388a83d7d4a75af49ae21cd2071671865e1..e261df1a8625dc9c275c17af60b3aac5fb3e1a00 100644 (file)
@@ -8,8 +8,6 @@
 #include "SketchPlugin.h"
 #include <SketchPlugin_Feature.h>
 
-#include <TopoDS_Shape.hxx>
-
 /// part reference attribute
 const std::string PART_ATTR_DOC_REF = "SketchDocument";
 
@@ -35,7 +33,7 @@ public:
  SKETCHPLUGIN_EXPORT virtual void initAttributes();
 
   /// Returns the sketch preview
-  SKETCHPLUGIN_EXPORT virtual const TopoDS_Shape& preview();
+  SKETCHPLUGIN_EXPORT virtual const std::shared_ptr<GeomAPI_Shape>& preview();
 
   /// Use plugin manager for features creation
   SketchPlugin_Sketch();