Salome HOME
Templates for implementation of Geom classes receiving
authormpv <mikhail.ponikarov@opencascade.com>
Thu, 24 Apr 2014 05:50:51 +0000 (09:50 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Thu, 24 Apr 2014 05:50:51 +0000 (09:50 +0400)
src/Config/Config_XMLReader.cpp
src/GeomAPI/CMakeLists.txt
src/GeomAPI/GeomAPI.i
src/GeomAPI/GeomAPI_Interface.cpp
src/GeomAPI/GeomAPI_Interface.h
src/GeomAPI/GeomAPI_Pln.cpp [new file with mode: 0644]
src/GeomAPI/GeomAPI_Pln.h [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_FaceBuilder.cpp
src/ModuleBase/ModuleBase_Operation.cpp
src/PartSet/PartSet_OperationSketchBase.cpp
src/XGUI/XGUI_PartDataModel.h

index 002c9df493ab611ef9d22774d6147ce70e2800e3..8f4412f3c50acbd92da1eac3e1b123b171896ee4 100644 (file)
@@ -58,7 +58,7 @@ void Config_XMLReader::readAll()
 
 /*
  * Allows to customize reader's behavior for a node. Virtual.
- * The default implementation does nothing. (In debug mode prints
+ * The default impl does nothing. (In debug mode prints
  * some info)
  */
 void Config_XMLReader::processNode(xmlNodePtr aNode)
@@ -72,7 +72,7 @@ void Config_XMLReader::processNode(xmlNodePtr aNode)
 
 /*
  * Defines which nodes should be processed recursively. Virtual.
- * The default implementation is to read all nodes.
+ * The default impl is to read all nodes.
  */
 bool Config_XMLReader::processChildren(xmlNodePtr aNode)
 {
index 15162678616da2275f604cd114e5b2c174ecfe3d..c0c67230e5acef38e77d47571e39a9bc30fc9527 100644 (file)
@@ -9,6 +9,7 @@ SET(PROJECT_HEADERS
     GeomAPI_Interface.h
     GeomAPI_Pnt.h
     GeomAPI_Dir.h
+    GeomAPI_Pln.h
     GeomAPI_Shape.h
 )
 
@@ -16,6 +17,7 @@ SET(PROJECT_SOURCES
     GeomAPI_Interface.cpp
     GeomAPI_Pnt.cpp
     GeomAPI_Dir.cpp
+    GeomAPI_Pln.cpp
     GeomAPI_Shape.cpp
 )
 
index 3f65f05f21ba8978b0bdeec124704d11051ce7bd..67d8297f7baa307eb1c14caacba98ca43a264dd8 100644 (file)
@@ -5,6 +5,8 @@
   #include "GeomAPI.h"
   #include "GeomAPI_Interface.h"
   #include "GeomAPI_Pnt.h"
+  #include "GeomAPI_Dir.h"
+  #include "GeomAPI_Pln.h"
   #include "GeomAPI_Shape.h"
 %}
 
 // %include <boost_shared_ptr.i>
 %shared_ptr(GeomAPI_Interface)
 %shared_ptr(GeomAPI_Pnt)
+%shared_ptr(GeomAPI_Dir)
+%shared_ptr(GeomAPI_Pln)
 %shared_ptr(GeomAPI_Shape)
 
 // all supported interfaces
 %include "GeomAPI_Interface.h"
 %include "GeomAPI_Pnt.h"
+%include "GeomAPI_Dir.h"
+%include "GeomAPI_Pln.h"
 %include "GeomAPI_Shape.h"
index 5e9b257fbb17a6436d864d3ce921126caf2b59e5..a583aa564cb499f9022c84ad94de9169f3d5da48 100644 (file)
@@ -20,12 +20,7 @@ GeomAPI_Interface::~GeomAPI_Interface()
     delete myImpl;
 }
 
-void* GeomAPI_Interface::implementation()
-{
-  return myImpl;
-}
-
-void GeomAPI_Interface::setImplementation(void* theImpl)
+void GeomAPI_Interface::setImpl(void* theImpl)
 {
   if (myImpl)
     delete myImpl;
index 1a605595bf5445069eb36a7c5a25e089337ea1b3..bd9a77ab13078880e6a961b4a9ab86df08e55900 100644 (file)
 class GEOMAPI_EXPORT GeomAPI_Interface
 {
 protected:
-  void* myImpl; ///< pointer to the internal implementation object
+  void* myImpl; ///< pointer to the internal impl object
 
 public:
   /// None - constructor
   GeomAPI_Interface();
 
-  /// Constructor by the implementation pointer (used for internal needs)
+  /// Constructor by the impl 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);
+  /// Returns the pointer to the impl
+  template<class T> inline T* implPtr() {return dynamic_cast<T*>(myImpl);}
+  /// Returns the reference object of the impl
+  template<class T> inline const T& impl() {return *(static_cast<T*>(myImpl));}
+  /// Updates the impl (deletes the old one)
+  void setImpl(void* theImpl);
 };
 
 #endif
-
diff --git a/src/GeomAPI/GeomAPI_Pln.cpp b/src/GeomAPI/GeomAPI_Pln.cpp
new file mode 100644 (file)
index 0000000..d6b476c
--- /dev/null
@@ -0,0 +1,36 @@
+// File:        GeomAPI_Pln.cpp
+// Created:     23 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#include<GeomAPI_Pln.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Dir.h>
+
+#include<gp_Pln.hxx>
+
+using namespace std;
+
+GeomAPI_Pln::GeomAPI_Pln(const shared_ptr<GeomAPI_Pnt>& thePoint,
+            const shared_ptr<GeomAPI_Dir>& theNormal)
+: GeomAPI_Interface(new gp_Pln(thePoint->impl<gp_Pnt>(),
+                               theNormal->impl<gp_Dir>()))
+{
+}
+
+GeomAPI_Pln::GeomAPI_Pln(
+  const double theA, const double theB, const double theC, const double theD)
+: GeomAPI_Interface(new gp_Pln(theA, theB, theC, theD))
+{
+}
+
+shared_ptr<GeomAPI_Pnt> GeomAPI_Pln::location()
+{
+  gp_Pnt aLoc = impl<gp_Pln>().Location();
+  return shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
+}
+
+shared_ptr<GeomAPI_Dir> GeomAPI_Pln::direction()
+{
+  const gp_Dir& aDir = impl<gp_Pln>().Axis().Direction();
+  return shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
+}
diff --git a/src/GeomAPI/GeomAPI_Pln.h b/src/GeomAPI/GeomAPI_Pln.h
new file mode 100644 (file)
index 0000000..49b4a9d
--- /dev/null
@@ -0,0 +1,37 @@
+// File:        GeomAPI_Pln.hxx
+// Created:     23 Apr 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef GeomAPI_Pln_HeaderFile
+#define GeomAPI_Pln_HeaderFile
+
+#include <memory>
+#include <GeomAPI_Interface.h>
+
+class GeomAPI_Pnt;
+class GeomAPI_Dir;
+
+/**\class GeomAPI_Pln
+ * \ingroup DataModel
+ * \brief 3D point defined by three coordinates
+ */
+
+class GEOMAPI_EXPORT GeomAPI_Pln: public GeomAPI_Interface
+{
+public:
+  /// Creation of plane by the point and normal
+  GeomAPI_Pln(const std::shared_ptr<GeomAPI_Pnt>& thePoint,
+              const std::shared_ptr<GeomAPI_Dir>& theNormal);
+
+  /// Creation of plane by coefficients A * X + B * Y + C * Z + D = 0.0 
+  GeomAPI_Pln(const double theA, const double theB, const double theC, const double theD);
+
+  /// Returns a point of this plane
+  std::shared_ptr<GeomAPI_Pnt> location();
+
+  /// Returns a plane normal
+  std::shared_ptr<GeomAPI_Dir> direction();
+};
+
+#endif
+
index 642e90996af905bf1de718affb8156547e6417c4..4b2ebc4d26b6adfd3ca7c27a2e31b08961348584 100644 (file)
@@ -11,13 +11,13 @@ boost::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_FaceBuilder::square(
   boost::shared_ptr<GeomAPI_Pnt> theCenter, boost::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);
+  const gp_Pnt& aCenter = theCenter->impl<gp_Pnt>();
+  const gp_Dir& aDir = theNormal->impl<gp_Dir>();
+  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.);
   boost::shared_ptr<GeomAPI_Shape> aRes(new GeomAPI_Shape);
-  aRes->setImplementation(new TopoDS_Shape(aFaceBuilder.Face()));
+  aRes->setImpl(new TopoDS_Shape(aFaceBuilder.Face()));
   return aRes;
 }
index 8a1ddc82d8026a2fd0e0da390f0e1ccbe2a02985..76459c132203a50b7d311cc2f89c6a73d67885c3 100644 (file)
@@ -100,7 +100,7 @@ bool ModuleBase_Operation::isValid(ModuleBase_Operation*) const
  * \return Returns TRUE if current operation must not be checked for ActiveOperation->IsValid( this )
  *
  * This method must be redefined in derived operation if operation of derived class
- * must be always can start above any launched one. Default implementation returns FALSE,
+ * must be always can start above any launched one. Default impl returns FALSE,
  * so it is being checked for IsValid, but some operations may overload IsGranted()
  * In this case they will always start, no matter what operation is running.
  */
@@ -268,7 +268,7 @@ void ModuleBase_Operation::storeReal(double theValue)
  * \brief Verifies whether operator is ready to start.
  * \return TRUE if operation is ready to start
  *
- * Default implementation returns TRUE. Redefine this method to add own verifications
+ * Default impl returns TRUE. Redefine this method to add own verifications
  */
 bool ModuleBase_Operation::isReadyToStart() const
 {
@@ -279,7 +279,7 @@ bool ModuleBase_Operation::isReadyToStart() const
  * \brief Virtual method called when operation is started
  *
  * Virtual method called when operation started (see start() method for more description)
- * Default implementation calls corresponding slot and commits immediately.
+ * Default impl calls corresponding slot and commits immediately.
  */
 void ModuleBase_Operation::startOperation()
 {
index ec0d695d529d49eaf43aa6d4bb347b3663931221..04d5be75679729c374a514f9a97eb67dff3aeaf6 100644 (file)
@@ -31,8 +31,9 @@ PartSet_OperationSketchBase::~PartSet_OperationSketchBase()
  */
 const TopoDS_Shape& PartSet_OperationSketchBase::preview() const
 {
-  boost::shared_ptr<SketchPlugin_Feature> aFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(feature());
-  return *(static_cast<TopoDS_Shape*>(aFeature->preview()->implementation()));
+  boost::shared_ptr<SketchPlugin_Feature> aFeature = 
+    boost::dynamic_pointer_cast<SketchPlugin_Feature>(feature());
+  return aFeature->preview()->impl<TopoDS_Shape>();
 }
 
 /*!
index f81f303f40fe36c4fb5611c328f859cf9e81249f..e1f0246ef732636aa0f825c1c16ab6539a685c40 100644 (file)
@@ -17,7 +17,7 @@ public:
   XGUI_TopDataModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent);
   virtual ~XGUI_TopDataModel();
 
-  // Reimplementation from QAbstractItemModel
+  // Reimpl from QAbstractItemModel
   virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
   virtual QVariant headerData(int section, Qt::Orientation orientation,
                               int role = Qt::DisplayRole) const;
@@ -66,7 +66,7 @@ public:
   XGUI_PartDataModel(const boost::shared_ptr<ModelAPI_Document>& theDocument, QObject* theParent);
   virtual ~XGUI_PartDataModel();
 
-  // Reimplementation from QAbstractItemModel
+  // Reimpl from QAbstractItemModel
   virtual QVariant data(const QModelIndex& theIndex, int theRole) const;
   virtual QVariant headerData(int section, Qt::Orientation orientation,
                               int role = Qt::DisplayRole) const;