GeomAPI_Interface.h
GeomAPI_XYZ.h
GeomAPI_Pnt.h
+ GeomAPI_Pnt2d.h
+ GeomAPI_Lin.h
+ GeomAPI_Lin2d.h
GeomAPI_Dir.h
GeomAPI_Pln.h
GeomAPI_Shape.h
GeomAPI_Interface.cpp
GeomAPI_XYZ.cpp
GeomAPI_Pnt.cpp
+ GeomAPI_Pnt2d.cpp
+ GeomAPI_Lin.cpp
+ GeomAPI_Lin2d.cpp
GeomAPI_Dir.cpp
GeomAPI_Pln.cpp
GeomAPI_Shape.cpp
${CAS_INCLUDE_DIRS}
)
-TARGET_LINK_LIBRARIES(GeomAPI ${PROJECT_LIBRARIES} ${CAS_KERNEL})
+TARGET_LINK_LIBRARIES(GeomAPI ${PROJECT_LIBRARIES} ${CAS_KERNEL} ${CAS_MODELER})
SET(SWIG_SCRIPTS
${CMAKE_CURRENT_BINARY_DIR}/GeomAPI.py
#include <gp_Dir.hxx>
-#define MY_DIR static_cast<gp_Pnt*>(myImpl)
+#define MY_DIR static_cast<gp_Dir*>(myImpl)
GeomAPI_Dir::GeomAPI_Dir(const double theX, const double theY, const double theZ)
: GeomAPI_Interface(new gp_Dir(theX, theY, theZ))
{}
+GeomAPI_Dir::GeomAPI_Dir(const boost::shared_ptr<GeomAPI_XYZ>& theCoords)
+ : GeomAPI_Interface(new gp_Dir(theCoords->x(), theCoords->y(), theCoords->z()))
+{}
+
double GeomAPI_Dir::x() const
{
return MY_DIR->X();
public:
/// Creation of direction by coordinates
GeomAPI_Dir(const double theX, const double theY, const double theZ);
+ /// Creation of direction by coordinates
+ GeomAPI_Dir(const boost::shared_ptr<GeomAPI_XYZ>& theCoords);
/// returns X coordinate
double x() const;
--- /dev/null
+// File: GeomAPI_Lin.cpp
+// Created: 29 May 2014
+// Author: Artem ZHIDKOV
+
+#include <GeomAPI_Lin.h>
+#include <GeomAPI_Pnt.h>
+
+#include <gp_Dir.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Lin2d.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_XYZ.hxx>
+
+#include <ElSLib.hxx>
+#include <IntAna2d_AnaIntersection.hxx>
+#include <Precision.hxx>
+#include <ProjLib.hxx>
+
+#define MY_LIN static_cast<gp_Lin*>(myImpl)
+
+static gp_Lin* newLine(const double theStartX, const double theStartY, const double theStartZ,
+ const double theEndX, const double theEndY, const double theEndZ)
+{
+ gp_XYZ aDir(theEndX - theStartX, theEndY - theStartY, theEndZ - theStartZ);
+ gp_Pnt aStart(theStartX, theStartY, theStartZ);
+ return new gp_Lin(aStart, gp_Dir(aDir));
+}
+
+
+GeomAPI_Lin::GeomAPI_Lin(const double theStartX, const double theStartY, const double theStartZ,
+ const double theEndX, const double theEndY, const double theEndZ)
+ : GeomAPI_Interface(newLine(theStartX, theStartY, theStartZ, theEndX, theEndY, theEndZ))
+{}
+
+GeomAPI_Lin::GeomAPI_Lin(const boost::shared_ptr<GeomAPI_Pnt>& theStart,
+ const boost::shared_ptr<GeomAPI_Pnt>& theEnd)
+ : GeomAPI_Interface(newLine(theStart->x(), theStart->y(), theStart->z(),
+ theEnd->x(), theEnd->y(), theEnd->z()))
+{}
+
+double GeomAPI_Lin::distance(const boost::shared_ptr<GeomAPI_Pnt>& thePoint) const
+{
+ return MY_LIN->Distance(thePoint->impl<gp_Pnt>());
+}
+
+const boost::shared_ptr<GeomAPI_Pnt> GeomAPI_Lin::intersect(
+ const boost::shared_ptr<GeomAPI_Lin>& theLine) const
+{
+ if (MY_LIN->SquareDistance(theLine->impl<gp_Lin>()) > Precision::Confusion())
+ return boost::shared_ptr<GeomAPI_Pnt>();
+
+ const gp_Dir& aDir1 = MY_LIN->Direction();
+ const gp_Dir& aDir2 = theLine->impl<gp_Lin>().Direction();
+ gp_Dir aCross = aDir1.Crossed(aDir2);
+ gp_Pln aPlane(MY_LIN->Location(), aCross); // plane containing both lines
+
+ gp_Lin2d aPrjLine1 = ProjLib::Project(aPlane, *MY_LIN);
+ gp_Lin2d aPrjLine2 = ProjLib::Project(aPlane, theLine->impl<gp_Lin>());
+
+ IntAna2d_AnaIntersection anInter(aPrjLine1, aPrjLine1);
+ if (!anInter.IsDone() || anInter.IsEmpty())
+ return boost::shared_ptr<GeomAPI_Pnt>();
+ const gp_Pnt2d& anIntPnt2d = anInter.Point(0).Value();
+ gp_Pnt aResult = ElSLib::Value(anIntPnt2d.X(), anIntPnt2d.Y(), aPlane);
+
+ return boost::shared_ptr<GeomAPI_Pnt>(
+ new GeomAPI_Pnt(aResult.X(), aResult.Y(), aResult.Z()));
+}
+
+const boost::shared_ptr<GeomAPI_Pnt> GeomAPI_Lin::project(const boost::shared_ptr<GeomAPI_Pnt>& thePoint) const
+{
+ const gp_XYZ& aDir = MY_LIN->Direction().XYZ();
+ const gp_XYZ& aLoc = MY_LIN->Location().XYZ();
+ const gp_XYZ& aPnt = thePoint->impl<gp_Pnt>().XYZ();
+ double aParam = aDir.Dot(aPnt - aLoc);
+
+ gp_XYZ aResult = aPnt + aDir * aParam;
+ return boost::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aResult.X(), aResult.Y(), aResult.Z()));
+}
+
--- /dev/null
+// File: GeomAPI_Lin.h
+// Created: 29 May 2014
+// Author: Artem ZHIDKOV
+
+#ifndef GeomAPI_Lin_HeaderFile
+#define GeomAPI_Lin_HeaderFile
+
+#include <GeomAPI_Interface.h>
+#include <boost/shared_ptr.hpp>
+
+class GeomAPI_Pnt;
+
+/**\class GeomAPI_Lin
+ * \ingroup DataModel
+ * \brief Line in 3D
+ */
+
+class GEOMAPI_EXPORT GeomAPI_Lin: public GeomAPI_Interface
+{
+public:
+ /// Creation of line defined by cordinates of start and end points
+ GeomAPI_Lin(const double theStartX, const double theStartY, const double theStartZ,
+ const double theEndX, const double theEndY, const double theEndZ);
+ /// Creation of line defined by start and end points
+ GeomAPI_Lin(const boost::shared_ptr<GeomAPI_Pnt>& theStart,
+ const boost::shared_ptr<GeomAPI_Pnt>& theEnd);
+
+ /// Distance between two points
+ double distance(const boost::shared_ptr<GeomAPI_Pnt>& thePoint) const;
+ /// Intersection of two lines
+ const boost::shared_ptr<GeomAPI_Pnt> intersect(const boost::shared_ptr<GeomAPI_Lin>& theLine) const;
+ /// Project point on line
+ const boost::shared_ptr<GeomAPI_Pnt> project(const boost::shared_ptr<GeomAPI_Pnt>& thePoint) const;
+};
+
+#endif
+
--- /dev/null
+// File: GeomAPI_Lin2d.cpp
+// Created: 29 May 2014
+// Author: Artem ZHIDKOV
+
+#include <GeomAPI_Lin2d.h>
+#include <GeomAPI_Pnt2d.h>
+
+#include <gp_Dir2d.hxx>
+#include <gp_Lin2d.hxx>
+#include <gp_Pnt2d.hxx>
+#include <gp_XY.hxx>
+
+#include <IntAna2d_AnaIntersection.hxx>
+
+#define MY_LIN2D static_cast<gp_Lin2d*>(myImpl)
+
+static gp_Lin2d* newLine2d(const double theStartX, const double theStartY,
+ const double theEndX, const double theEndY)
+{
+ gp_XY aDir(theEndX - theStartX, theEndY - theStartY);
+ gp_Pnt2d aStart(theStartX, theStartY);
+ return new gp_Lin2d(aStart, gp_Dir2d(aDir));
+}
+
+
+GeomAPI_Lin2d::GeomAPI_Lin2d(const double theStartX, const double theStartY,
+ const double theEndX, const double theEndY)
+ : GeomAPI_Interface(newLine2d(theStartX, theStartY, theEndX, theEndY))
+{}
+
+GeomAPI_Lin2d::GeomAPI_Lin2d(const boost::shared_ptr<GeomAPI_Pnt2d>& theStart,
+ const boost::shared_ptr<GeomAPI_Pnt2d>& theEnd)
+ : GeomAPI_Interface(newLine2d(theStart->x(), theStart->y(),
+ theEnd->x(), theEnd->y()))
+{}
+
+double GeomAPI_Lin2d::distance(const boost::shared_ptr<GeomAPI_Pnt2d>& theOther) const
+{
+ return MY_LIN2D->Distance(theOther->impl<gp_Pnt2d>());
+}
+
+const boost::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Lin2d::intersect(
+ const boost::shared_ptr<GeomAPI_Lin2d>& theLine) const
+{
+ IntAna2d_AnaIntersection anInter(*MY_LIN2D, theLine->impl<gp_Lin2d>());
+ if (!anInter.IsDone() || anInter.IsEmpty())
+ return boost::shared_ptr<GeomAPI_Pnt2d>();
+ const gp_Pnt2d& aResult = anInter.Point(0).Value();
+ return boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aResult.X(), aResult.Y()));
+}
+
+const boost::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Lin2d::project(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) const
+{
+ const gp_XY& aDir = MY_LIN2D->Direction().XY();
+ const gp_XY& aLoc = MY_LIN2D->Location().XY();
+ const gp_XY& aPnt = thePoint->impl<gp_Pnt2d>().XY();
+ double aParam = aDir.Dot(aPnt - aLoc);
+
+ gp_XY aResult = aPnt + aDir * aParam;
+ return boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aResult.X(), aResult.Y()));
+}
+
--- /dev/null
+// File: GeomAPI_Lin2d.h
+// Created: 29 May 2014
+// Author: Artem ZHIDKOV
+
+#ifndef GeomAPI_Lin2d_HeaderFile
+#define GeomAPI_Lin2d_HeaderFile
+
+#include <GeomAPI_Interface.h>
+#include <boost/shared_ptr.hpp>
+
+class GeomAPI_Pnt2d;
+
+/**\class GeomAPI_Lin2d
+ * \ingroup DataModel
+ * \brief Line in 2D
+ */
+
+class GEOMAPI_EXPORT GeomAPI_Lin2d: public GeomAPI_Interface
+{
+public:
+ /// Creation of line defined by cordinates of start and end points
+ GeomAPI_Lin2d(const double theStartX, const double theStartY,
+ const double theEndX, const double theEndY);
+ /// Creation of line defined by start and end points
+ GeomAPI_Lin2d(const boost::shared_ptr<GeomAPI_Pnt2d>& theStart,
+ const boost::shared_ptr<GeomAPI_Pnt2d>& theEnd);
+
+ /// Distance between two points
+ double distance(const boost::shared_ptr<GeomAPI_Pnt2d>& theOther) const;
+ /// Intersection of two lines
+ const boost::shared_ptr<GeomAPI_Pnt2d> intersect(const boost::shared_ptr<GeomAPI_Lin2d>& theLine) const;
+ /// Project point on line
+ const boost::shared_ptr<GeomAPI_Pnt2d> project(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) const;
+};
+
+#endif
+
{
return boost::shared_ptr<GeomAPI_XYZ>(new GeomAPI_XYZ(MY_PNT->X(), MY_PNT->Y(), MY_PNT->Z()));
}
+
+double GeomAPI_Pnt::distance(const boost::shared_ptr<GeomAPI_Pnt>& theOther) const
+{
+ return MY_PNT->Distance(theOther->impl<gp_Pnt>());
+}
/// returns coordinates of the point
const boost::shared_ptr<GeomAPI_XYZ> xyz();
+
+ /// Distance between two points
+ double distance(const boost::shared_ptr<GeomAPI_Pnt>& theOther) const;
};
#endif
--- /dev/null
+// File: GeomAPI_Pnt2d.cpp
+// Created: 29 May 2014
+// Author: Artem ZHIDKOV
+
+#include<GeomAPI_Pnt2d.h>
+#include<GeomAPI_XYZ.h>
+
+#include<gp_Pnt2d.hxx>
+
+#define MY_PNT2D static_cast<gp_Pnt2d*>(myImpl)
+
+GeomAPI_Pnt2d::GeomAPI_Pnt2d(const double theX, const double theY)
+ : GeomAPI_Interface(new gp_Pnt2d(theX, theY))
+{}
+
+double GeomAPI_Pnt2d::x() const
+{
+ return MY_PNT2D->X();
+}
+
+double GeomAPI_Pnt2d::y() const
+{
+ return MY_PNT2D->Y();
+}
+
+void GeomAPI_Pnt2d::setX(const double theX)
+{
+ return MY_PNT2D->SetX(theX);
+}
+
+void GeomAPI_Pnt2d::setY(const double theY)
+{
+ return MY_PNT2D->SetY(theY);
+}
+
+double GeomAPI_Pnt2d::distance(const boost::shared_ptr<GeomAPI_Pnt2d>& theOther) const
+{
+ return MY_PNT2D->Distance(theOther->impl<gp_Pnt2d>());
+}
--- /dev/null
+// File: GeomAPI_Pnt2d.h
+// Created: 29 May 2014
+// Author: Artem ZHIDKOV
+
+#ifndef GeomAPI_Pnt2d_HeaderFile
+#define GeomAPI_Pnt2d_HeaderFile
+
+#include <GeomAPI_Interface.h>
+#include <boost/shared_ptr.hpp>
+
+class GeomAPI_XYZ;
+
+/**\class GeomAPI_Pnt2d
+ * \ingroup DataModel
+ * \brief 2D point defined by two coordinates
+ */
+
+class GEOMAPI_EXPORT GeomAPI_Pnt2d: public GeomAPI_Interface
+{
+public:
+ /// Creation of point by coordinates
+ GeomAPI_Pnt2d(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);
+
+ /// Distance between two points
+ double distance(const boost::shared_ptr<GeomAPI_Pnt2d>& theOther) const;
+};
+
+#endif
+
MY_XYZ->Y() * theArg, MY_XYZ->Z() * theArg));
return aResult;
}
+
+double GeomAPI_XYZ::dot(const boost::shared_ptr<GeomAPI_XYZ>& theArg) const
+{
+ return MY_XYZ->Dot(theArg->impl<gp_XYZ>());
+}
+
+const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::cross(const boost::shared_ptr<GeomAPI_XYZ>& theArg) const
+{
+ gp_XYZ aResult = MY_XYZ->Crossed(theArg->impl<gp_XYZ>());
+ return boost::shared_ptr<GeomAPI_XYZ>(new GeomAPI_XYZ(aResult.X(), aResult.Y(), aResult.Z()));
+}
+
+double GeomAPI_XYZ::distance(const boost::shared_ptr<GeomAPI_XYZ>& theOther) const
+{
+ gp_XYZ aResult(theOther->x() - x(), theOther->y() - y(), theOther->z() - z());
+ return aResult.Modulus();
+}
+
const boost::shared_ptr<GeomAPI_XYZ> added(const boost::shared_ptr<GeomAPI_XYZ>& theArg);
/// result is coordinates multiplied by the argument
const boost::shared_ptr<GeomAPI_XYZ> multiplied(const double theArg);
+
+ /// result is a scalar product of two triplets
+ double dot(const boost::shared_ptr<GeomAPI_XYZ>& theArg) const;
+ /// result is a cross product of two triplets
+ const boost::shared_ptr<GeomAPI_XYZ> cross(const boost::shared_ptr<GeomAPI_XYZ>& theArg) const;
+
+ /// Distance between two triplets
+ double distance(const boost::shared_ptr<GeomAPI_XYZ>& theOther) const;
};
#endif