GeomAPI_ICustomPrs.h
GeomAPI_Vertex.h
GeomAPI_Ax1.h
+ GeomAPI_Ax2.h
GeomAPI_Ax3.h
GeomAPI_Trsf.h
)
GeomAPI_Vertex.cpp
GeomAPI_ICustomPrs.cpp
GeomAPI_Ax1.cpp
+ GeomAPI_Ax2.cpp
GeomAPI_Ax3.cpp
GeomAPI_IPresentable.cpp
GeomAPI_Trsf.cpp
#include "GeomAPI.h"
#include "GeomAPI_AISObject.h"
#include "GeomAPI_Ax1.h"
+ #include "GeomAPI_Ax2.h"
#include "GeomAPI_Ax3.h"
#include "GeomAPI_Circ.h"
#include "GeomAPI_Circ2d.h"
// shared pointers
%shared_ptr(GeomAPI_AISObject)
%shared_ptr(GeomAPI_Ax1)
+%shared_ptr(GeomAPI_Ax2)
%shared_ptr(GeomAPI_Ax3)
%shared_ptr(GeomAPI_Circ)
%shared_ptr(GeomAPI_Circ2d)
%include "GeomAPI_Shape.h"
%include "GeomAPI_AISObject.h"
%include "GeomAPI_Ax1.h"
+%include "GeomAPI_Ax2.h"
%include "GeomAPI_Ax3.h"
%include "GeomAPI_Circ.h"
%include "GeomAPI_Circ2d.h"
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAPI_Ax2.cpp
+// Created: 08 September 2015
+// Author: Dmitry Bobylev
+
+#include <GeomAPI_Ax2.h>
+
+#include <gp_Ax2.hxx>
+
+#define MY_AX1 implPtr<gp_Ax2>()
+
+//=================================================================================================
+GeomAPI_Ax2::GeomAPI_Ax2()
+: GeomAPI_Interface(new gp_Ax2())
+{
+}
+
+//=================================================================================================
+GeomAPI_Ax2::GeomAPI_Ax2(std::shared_ptr<GeomAPI_Pnt> theOrigin,
+ std::shared_ptr<GeomAPI_Dir> theN,
+ std::shared_ptr<GeomAPI_Dir> theVX)
+: GeomAPI_Interface(new gp_Ax2(theOrigin->impl<gp_Pnt>(),
+ theN->impl<gp_Dir>(),
+ theVX->impl<gp_Dir>()))
+{
+}
+
+//=================================================================================================
+GeomAPI_Ax2::GeomAPI_Ax2(std::shared_ptr<GeomAPI_Pnt> theOrigin,
+ std::shared_ptr<GeomAPI_Dir> theDir)
+: GeomAPI_Interface(new gp_Ax2(theOrigin->impl<gp_Pnt>(),
+ theDir->impl<gp_Dir>()))
+{
+}
+
+//=================================================================================================
+void GeomAPI_Ax2::setOrigin(const std::shared_ptr<GeomAPI_Pnt>& theOrigin)
+{
+ MY_AX1->SetLocation(theOrigin->impl<gp_Pnt>());
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Pnt> GeomAPI_Ax2::origin() const
+{
+ gp_Pnt aPnt = MY_AX1->Location();
+ return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aPnt.X(),aPnt.Y(),aPnt.Z()));
+}
+
+//=================================================================================================
+void GeomAPI_Ax2::setDir(const std::shared_ptr<GeomAPI_Dir>& theDir)
+{
+ MY_AX1->SetDirection(theDir->impl<gp_Dir>());
+}
+
+//=================================================================================================
+std::shared_ptr<GeomAPI_Dir> GeomAPI_Ax2::dir() const
+{
+ gp_Dir aDir = MY_AX1->Direction();
+ return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAPI_Ax2.h
+// Created: 12 May 2015
+// Author: Dmitry Bobylev
+
+#ifndef GeomAPI_Ax2_H_
+#define GeomAPI_Ax2_H_
+
+#include <GeomAPI.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Dir.h>
+
+/** \ingroup DataModel
+ * \brief The class represents an axis in 3D space.
+ */
+class GeomAPI_Ax2 : public GeomAPI_Interface
+{
+public:
+ /// Default constructor.
+ GEOMAPI_EXPORT
+ GeomAPI_Ax2();
+
+ /** \brief Ñonstructor.
+ * \param[in] theOrigin point of origin.
+ * \param[in] theN direction of axis.
+ * \param[in] theVX x direction of axis.
+ */
+ GEOMAPI_EXPORT
+ GeomAPI_Ax2(std::shared_ptr<GeomAPI_Pnt> theOrigin,
+ std::shared_ptr<GeomAPI_Dir> theN,
+ std::shared_ptr<GeomAPI_Dir> theVX);
+
+ /** \brief Ñonstructor.
+ * \param[in] theOrigin point of origin.
+ * \param[in] theDir direction of axis.
+ */
+ GEOMAPI_EXPORT
+ GeomAPI_Ax2(std::shared_ptr<GeomAPI_Pnt> theOrigin,
+ std::shared_ptr<GeomAPI_Dir> theDir);
+
+ /// Sets origin point.
+ GEOMAPI_EXPORT
+ void setOrigin(const std::shared_ptr<GeomAPI_Pnt>& theOrigin);
+
+ /// \return the plane origin point.
+ GEOMAPI_EXPORT
+ std::shared_ptr<GeomAPI_Pnt> origin() const;
+
+ /// Sets direction vector.
+ GEOMAPI_EXPORT
+ void setDir(const std::shared_ptr<GeomAPI_Dir>& theDir);
+
+ /// \return direction vector.
+ GEOMAPI_EXPORT
+ std::shared_ptr<GeomAPI_Dir> dir() const;
+};
+
+#endif
// Author: Artem ZHIDKOV
#include <GeomAPI_Circ.h>
+
+#include <GeomAPI_Ax2.h>
#include <GeomAPI_Pnt.h>
#include <GeomAPI_Dir.h>
#include <Geom_Circle.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
+#include <GeomLib_Tool.hxx>
#define MY_CIRC implPtr<gp_Circ>()
return new gp_Circ(gp_Ax2(theCenter, theDir), theRadius);
}
+//=================================================================================================
+GeomAPI_Circ::GeomAPI_Circ(const std::shared_ptr<GeomAPI_Ax2> theAx2,
+ const double theRadius)
+: GeomAPI_Interface(new gp_Circ(theAx2->impl<gp_Ax2>(), theRadius))
+{
+
+}
+
+
+//=================================================================================================
GeomAPI_Circ::GeomAPI_Circ(const std::shared_ptr<GeomAPI_Pnt>& theCenter,
const std::shared_ptr<GeomAPI_Dir>& theDir, double theRadius)
: GeomAPI_Interface(newCirc(theCenter->impl<gp_Pnt>(), theDir->impl<gp_Dir>(), theRadius))
{
}
+//=================================================================================================
+const std::shared_ptr<GeomAPI_Pnt> GeomAPI_Circ::center() const
+{
+ const gp_Pnt& aCenter = MY_CIRC->Location();
+ return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aCenter.X(), aCenter.Y(), aCenter.Z()));
+}
+
+//=================================================================================================
+double GeomAPI_Circ::radius() const
+{
+ return MY_CIRC->Radius();
+}
+
+//=================================================================================================
const std::shared_ptr<GeomAPI_Pnt> GeomAPI_Circ::project(
const std::shared_ptr<GeomAPI_Pnt>& thePoint) const
{
return aResult;
}
-const std::shared_ptr<GeomAPI_Pnt> GeomAPI_Circ::center() const
-{
- const gp_Pnt& aCenter = MY_CIRC->Location();
- return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aCenter.X(), aCenter.Y(), aCenter.Z()));
-}
-
-double GeomAPI_Circ::radius() const
+//=================================================================================================
+const bool GeomAPI_Circ::parameter(const std::shared_ptr<GeomAPI_Pnt> thePoint,
+ const double theTolerance,
+ double& theParameter) const
{
- return MY_CIRC->Radius();
+ Handle(Geom_Circle) aCurve = new Geom_Circle(*MY_CIRC);
+ return GeomLib_Tool::Parameter(aCurve, thePoint->impl<gp_Pnt>(), theTolerance, theParameter);
}
#include <GeomAPI_Interface.h>
#include <memory>
+class GeomAPI_Ax2;
class GeomAPI_Pnt;
class GeomAPI_Dir;
class GeomAPI_Circ : public GeomAPI_Interface
{
public:
+
+ /** \brief Constructs a circle of radius Radius, where theAx2 locates the circle and defines its orientation in 3D space such that:\n
+ * - the center of the circle is the origin of theAx2;\n
+ * - the origin, "X Direction" and "Y Direction" of theAx2 define the plane of the circle;\n
+ * - theAx2 is the local coordinate system of the circle.\n
+ * Note: It is possible to create a circle where Radius is equal to 0.0. raised if Radius < 0.
+ */
+ GEOMAPI_EXPORT GeomAPI_Circ(const std::shared_ptr<GeomAPI_Ax2> theAx2,
+ const double theRadius);
+
/// Creation of circle defined by center point, direction and circle radius
GEOMAPI_EXPORT GeomAPI_Circ(const std::shared_ptr<GeomAPI_Pnt>& theCenter,
const std::shared_ptr<GeomAPI_Dir>& theDir, double theRadius);
/// Project point on circle
GEOMAPI_EXPORT const std::shared_ptr<GeomAPI_Pnt> project(
const std::shared_ptr<GeomAPI_Pnt>& thePoint) const;
+
+ /** \brief Computes the parameter of a given point on a circle. The point must be
+ * located either on the circle itself or relatively to the latter
+ * at a distance less than the tolerance value. Return FALSE if the point
+ * is beyond the tolerance limit or if computation fails.
+ * Max Tolerance value is currently limited to 1.e-4
+ * \param[in] theOrigin point of origin.
+ * \param[in] theDir direction of axis.
+ */
+ GEOMAPI_EXPORT const bool parameter(const std::shared_ptr<GeomAPI_Pnt> thePoint,
+ const double theTolerance,
+ double& theParameter) const;
};
#endif
#include <ModelAPI_Validator.h>
#include <ModelAPI_Session.h>
+#include <GeomAPI_Ax2.h>
#include <GeomAPI_Circ2d.h>
#include <GeomAPI_Circ.h>
#include <GeomAPI_Pnt2d.h>
#include <math.h>
const double tolerance = 1e-7;
+const double paramTolerance = 1.e-4;
+const double PI =3.141592653589793238463;
SketchPlugin_Arc::SketchPlugin_Arc()
: SketchPlugin_SketchEntity()
// default values
myXEndBefore = 0;
myYEndBefore = 0;
+
+ myForwardDirection = true;
+ myParamBefore = 0;
}
void SketchPlugin_Arc::initAttributes()
*/
std::shared_ptr<GeomAPI_Pnt> aEndPoint(aSketch->to3D(anEndAttr->x(), anEndAttr->y()));
- std::shared_ptr<GeomAPI_Shape> aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircleArc(
- aCenter, aStartPoint, aEndPoint, aNormal);
+ std::shared_ptr<GeomAPI_Dir> anXDir(new GeomAPI_Dir(aStartPoint->xyz()->decreased(aCenter->xyz())));
+ std::shared_ptr<GeomAPI_Ax2> anAx2(new GeomAPI_Ax2(aCenter, aNormal, anXDir));
+ std::shared_ptr<GeomAPI_Circ> aCirc(new GeomAPI_Circ(anAx2, aCenter->distance(aStartPoint)));
+ double aParameterNew = 0.0;
+ if(aCirc->parameter(aEndPoint, paramTolerance, aParameterNew)) {
+ if(0 < myParamBefore && myParamBefore <= PI / 2.0
+ && PI * 1.5 < aParameterNew && aParameterNew <= PI * 2.0) {
+ myForwardDirection = false;
+ } else if(PI * 1.5 < myParamBefore && myParamBefore <= PI * 2.0
+ && 0 < aParameterNew && aParameterNew <= PI / 2.0) {
+ myForwardDirection = true;
+ }
+ }
+ myParamBefore = aParameterNew;
+
+ std::shared_ptr<GeomAPI_Shape> aCircleShape;
+ if(myForwardDirection) {
+ aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aStartPoint, aEndPoint, aNormal);
+ } else {
+ aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aEndPoint, aStartPoint, aNormal);
+ }
+
if (aCircleShape) {
std::shared_ptr<ModelAPI_ResultConstruction> aConstr2 = document()->createConstruction(
data(), 1);
/// to avoid (if possible) additional modification of changed coordinate (issue #855)
double myXEndBefore, myYEndBefore;
+ /// to define in which direction draw arc
+ bool myForwardDirection;
+ double myParamBefore;
+
public:
/// Arc feature kind
inline static const std::string& ID()