SET(PROJECT_HEADERS
GeomAPI.h
GeomAPI_Interface.h
+ GeomAPI_XY.h
GeomAPI_XYZ.h
GeomAPI_Pnt.h
GeomAPI_Pnt2d.h
SET(PROJECT_SOURCES
GeomAPI_Interface.cpp
+ GeomAPI_XY.cpp
GeomAPI_XYZ.cpp
GeomAPI_Pnt.cpp
GeomAPI_Pnt2d.cpp
{
return boost::shared_ptr<GeomAPI_XYZ>(new GeomAPI_XYZ(MY_DIR->X(), MY_DIR->Y(), MY_DIR->Z()));
}
+
+double GeomAPI_Dir::dot(const boost::shared_ptr<GeomAPI_Dir>& theArg) const
+{
+ return MY_DIR->Dot(theArg->impl<gp_Dir>());
+}
/// returns coordinates of the direction
const boost::shared_ptr<GeomAPI_XYZ> xyz();
+
+ /// result is a scalar product of directions
+ double dot(const boost::shared_ptr<GeomAPI_Dir>& theArg) const;
};
#endif
// Author: Artem ZHIDKOV
#include<GeomAPI_Pnt2d.h>
-#include<GeomAPI_XYZ.h>
+#include<GeomAPI_XY.h>
#include<gp_Pnt2d.hxx>
: GeomAPI_Interface(new gp_Pnt2d(theX, theY))
{}
+GeomAPI_Pnt2d::GeomAPI_Pnt2d(const boost::shared_ptr<GeomAPI_XY>& theCoords)
+ : GeomAPI_Interface(new gp_Pnt2d(theCoords->x(), theCoords->y()))
+{}
+
double GeomAPI_Pnt2d::x() const
{
return MY_PNT2D->X();
return MY_PNT2D->SetY(theY);
}
+const boost::shared_ptr<GeomAPI_XY> GeomAPI_Pnt2d::xy()
+{
+ return boost::shared_ptr<GeomAPI_XY>(new GeomAPI_XY(MY_PNT2D->X(), MY_PNT2D->Y()));
+}
+
double GeomAPI_Pnt2d::distance(const boost::shared_ptr<GeomAPI_Pnt2d>& theOther) const
{
return MY_PNT2D->Distance(theOther->impl<gp_Pnt2d>());
#include <GeomAPI_Interface.h>
#include <boost/shared_ptr.hpp>
-class GeomAPI_XYZ;
+class GeomAPI_XY;
/**\class GeomAPI_Pnt2d
* \ingroup DataModel
public:
/// Creation of point by coordinates
GeomAPI_Pnt2d(const double theX, const double theY);
+ /// Creation of point by coordinates
+ GeomAPI_Pnt2d(const boost::shared_ptr<GeomAPI_XY>& theCoords);
/// returns X coordinate
double x() const;
/// sets Y coordinate
void setY(const double theY);
+ /// returns coordinates of the point
+ const boost::shared_ptr<GeomAPI_XY> xy();
+
/// Distance between two points
double distance(const boost::shared_ptr<GeomAPI_Pnt2d>& theOther) const;
};
--- /dev/null
+// File: GeomAPI_XY.cpp
+// Created: 30 May 2014
+// Author: Artem ZHIDKOV
+
+#include<GeomAPI_XY.h>
+
+#include<gp_XY.hxx>
+
+#define MY_XY static_cast<gp_XY*>(myImpl)
+
+GeomAPI_XY::GeomAPI_XY(const double theX, const double theY)
+ : GeomAPI_Interface(new gp_XY(theX, theY))
+{}
+
+double GeomAPI_XY::x() const
+{
+ return MY_XY->X();
+}
+
+double GeomAPI_XY::y() const
+{
+ return MY_XY->Y();
+}
+
+void GeomAPI_XY::setX(const double theX)
+{
+ return MY_XY->SetX(theX);
+}
+
+void GeomAPI_XY::setY(const double theY)
+{
+ return MY_XY->SetY(theY);
+}
+
+const boost::shared_ptr<GeomAPI_XY> GeomAPI_XY::added(
+ const boost::shared_ptr<GeomAPI_XY>& theArg)
+{
+ boost::shared_ptr<GeomAPI_XY> aResult(
+ new GeomAPI_XY(MY_XY->X() + theArg->x(), MY_XY->Y() + theArg->y()));
+ return aResult;
+}
+
+const boost::shared_ptr<GeomAPI_XY> GeomAPI_XY::multiplied(const double theArg)
+{
+ boost::shared_ptr<GeomAPI_XY> aResult(
+ new GeomAPI_XY(MY_XY->X() * theArg, MY_XY->Y() * theArg));
+ return aResult;
+}
+
+double GeomAPI_XY::dot(const boost::shared_ptr<GeomAPI_XY>& theArg) const
+{
+ return MY_XY->Dot(theArg->impl<gp_XY>());
+}
+
+double GeomAPI_XY::cross(const boost::shared_ptr<GeomAPI_XY>& theArg) const
+{
+ return MY_XY->Crossed(theArg->impl<gp_XY>());
+}
+
+double GeomAPI_XY::distance(const boost::shared_ptr<GeomAPI_XY>& theOther) const
+{
+ gp_XY aResult(theOther->x() - x(), theOther->y() - y());
+ return aResult.Modulus();
+}
+
--- /dev/null
+// File: GeomAPI_XY.hxx
+// Created: 30 May 2014
+// Author: Artem ZHIDKOV
+
+#ifndef GeomAPI_XY_HeaderFile
+#define GeomAPI_XY_HeaderFile
+
+#include <GeomAPI_Interface.h>
+#include <boost/shared_ptr.hpp>
+
+/**\class GeomAPI_XY
+ * \ingroup DataModel
+ * \brief 2 coordinates: they may represent vector or point or something else
+ */
+
+class GEOMAPI_EXPORT GeomAPI_XY: public GeomAPI_Interface
+{
+public:
+ /// Creation by coordinates
+ GeomAPI_XY(const double theX, const double theY);
+
+ /// returns X coordinate
+ double x() const;
+ /// returns Y coordinate
+ double y() const;
+
+ /// sets X coordinate
+ void setX(const double theX);
+ /// sets Y coordinate
+ void setY(const double theY);
+
+ /// result is sum of coordinates of this and the given argument
+ const boost::shared_ptr<GeomAPI_XY> added(const boost::shared_ptr<GeomAPI_XY>& theArg);
+ /// result is coordinates multiplied by the argument
+ const boost::shared_ptr<GeomAPI_XY> multiplied(const double theArg);
+
+ /// result is a scalar product of two triplets
+ double dot(const boost::shared_ptr<GeomAPI_XY>& theArg) const;
+ /// result is a cross product of two triplets
+ double cross(const boost::shared_ptr<GeomAPI_XY>& theArg) const;
+
+ /// Distance between two pairs
+ double distance(const boost::shared_ptr<GeomAPI_XY>& theOther) const;
+};
+
+#endif
+
return aResult;
}
+const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::decreased(
+ const boost::shared_ptr<GeomAPI_XYZ>& theArg)
+{
+ boost::shared_ptr<GeomAPI_XYZ> aResult(new GeomAPI_XYZ(MY_XYZ->X() - theArg->x(),
+ MY_XYZ->Y() - theArg->y(), MY_XYZ->Z() - theArg->z()));
+ return aResult;
+}
+
const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::multiplied(const double theArg)
{
boost::shared_ptr<GeomAPI_XYZ> aResult(new GeomAPI_XYZ(MY_XYZ->X() * theArg,
/// result is sum of coordinates of this and the given argument
const boost::shared_ptr<GeomAPI_XYZ> added(const boost::shared_ptr<GeomAPI_XYZ>& theArg);
+ /// result is difference between coordinates of this and the given argument
+ const boost::shared_ptr<GeomAPI_XYZ> decreased(const boost::shared_ptr<GeomAPI_XYZ>& theArg);
/// result is coordinates multiplied by the argument
const boost::shared_ptr<GeomAPI_XYZ> multiplied(const double theArg);
}
}
+void GeomData_Dir::setValue(const boost::shared_ptr<GeomAPI_Dir>& theDir)
+{
+ setValue(theDir->x(), theDir->y(), theDir->z());
+}
+
double GeomData_Dir::x() const
{
return myCoords->Value(0);
public:
/// Defines the double value
GEOMDATA_EXPORT virtual void setValue(const double theX, const double theY, const double theZ);
+ /// Defines the direction
+ GEOMDATA_EXPORT virtual void setValue(const boost::shared_ptr<GeomAPI_Dir>& theDir);
/// Returns the X double value
GEOMDATA_EXPORT virtual double x() const;
}
}
+void GeomData_Point::setValue(const boost::shared_ptr<GeomAPI_Pnt>& thePoint)
+{
+ setValue(thePoint->x(), thePoint->y(), thePoint->z());
+}
+
double GeomData_Point::x() const
{
return myCoords->Value(0);
public:
/// Defines the double value
GEOMDATA_EXPORT virtual void setValue(const double theX, const double theY, const double theZ);
+ /// Defines the point
+ GEOMDATA_EXPORT virtual void setValue(const boost::shared_ptr<GeomAPI_Pnt>& thePoint);
/// Returns the X double value
GEOMDATA_EXPORT virtual double x() const;
#include "GeomData_Point2D.h"
#include "Model_Events.h"
#include <Events_Loop.h>
+#include <GeomAPI_Pnt2d.h>
using namespace std;
}
}
+void GeomData_Point2D::setValue(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
+{
+ setValue(thePoint->x(), thePoint->y());
+}
+
double GeomData_Point2D::x() const
{
return myCoords->Value(0);
return myCoords->Value(1);
}
+boost::shared_ptr<GeomAPI_Pnt2d> GeomData_Point2D::pnt()
+{
+ boost::shared_ptr<GeomAPI_Pnt2d> aResult(
+ new GeomAPI_Pnt2d(myCoords->Value(0), myCoords->Value(1)));
+ return aResult;
+}
+
GeomData_Point2D::GeomData_Point2D(TDF_Label& theLabel)
{
// check the attribute could be already presented in this doc (after load document)
public:
/// Defines the double value
GEOMDATA_EXPORT virtual void setValue(const double theX, const double theY);
+ /// Defines the point
+ GEOMDATA_EXPORT virtual void setValue(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint);
/// Returns the X double value
GEOMDATA_EXPORT virtual double x() const;
/// Returns the Y double value
GEOMDATA_EXPORT virtual double y() const;
+ /// Returns the 2D point
+ GEOMDATA_EXPORT virtual boost::shared_ptr<GeomAPI_Pnt2d> pnt();
protected:
/// Initializes attributes
public:
/// Defines the double value
virtual void setValue(const double theX, const double theY, const double theZ) = 0;
+ /// Defines the direction
+ virtual void setValue(const boost::shared_ptr<GeomAPI_Dir>& theDir) = 0;
/// Returns the X double value
virtual double x() const = 0;
public:
/// Defines the double value
virtual void setValue(const double theX, const double theY, const double theZ) = 0;
+ /// Defines the point
+ virtual void setValue(const boost::shared_ptr<GeomAPI_Pnt>& thePoint) = 0;
/// Returns the X double value
virtual double x() const = 0;
#include "GeomDataAPI.h"
#include <ModelAPI_Attribute.h>
+class GeomAPI_Pnt2d;
+
/**\class GeomDataAPI_Point2D
* \ingroup DataModel
* \brief Attribute that contains 2D point coordinates.
public:
/// Defines the double value
virtual void setValue(const double theX, const double theY) = 0;
+ /// Defines the point
+ virtual void setValue(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) = 0;
/// Returns the X double value
virtual double x() const = 0;
/// Returns the Y double value
virtual double y() const = 0;
+ /// Returns the 2D point
+ virtual boost::shared_ptr<GeomAPI_Pnt2d> pnt() = 0;
/// Returns the type of this class of attributes
static inline std::string type() {return std::string("Point2D");}