/*
* 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)
/*
* 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)
{
GeomAPI_Interface.h
GeomAPI_Pnt.h
GeomAPI_Dir.h
+ GeomAPI_Pln.h
GeomAPI_Shape.h
)
GeomAPI_Interface.cpp
GeomAPI_Pnt.cpp
GeomAPI_Dir.cpp
+ GeomAPI_Pln.cpp
GeomAPI_Shape.cpp
)
#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"
delete myImpl;
}
-void* GeomAPI_Interface::implementation()
-{
- return myImpl;
-}
-
-void GeomAPI_Interface::setImplementation(void* theImpl)
+void GeomAPI_Interface::setImpl(void* theImpl)
{
if (myImpl)
delete myImpl;
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
-
--- /dev/null
+// 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()));
+}
--- /dev/null
+// 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
+
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;
}
* \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.
*/
* \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
{
* \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()
{
*/
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>();
}
/*!
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;
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;