Part: expose Geom2dCircle::getCircleCenter to Python and fix a regression
This commit is contained in:
@@ -31,6 +31,11 @@ Part.Geom2d.Circle2d(Point1,Point2,Point3)
|
||||
Creates a circle defined by three non-linear points
|
||||
</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="getCircleCenter" Static="true">
|
||||
<Documentation>
|
||||
<UserDocu>Get the circle center defined by three points</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Attribute Name="Radius" ReadOnly="false">
|
||||
<Documentation>
|
||||
<UserDocu>The radius of the circle.</UserDocu>
|
||||
|
||||
@@ -143,6 +143,24 @@ int Circle2dPy::PyInit(PyObject* args, PyObject* kwds)
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyObject* Circle2dPy::getCircleCenter(PyObject *args)
|
||||
{
|
||||
PyObject* p1;
|
||||
PyObject* p2;
|
||||
PyObject* p3;
|
||||
if (!PyArg_ParseTuple(args, "O!O!O!", Base::Vector2dPy::type_object(), &p1
|
||||
, Base::Vector2dPy::type_object(), &p2
|
||||
, Base::Vector2dPy::type_object(), &p3))
|
||||
return nullptr;
|
||||
|
||||
Base::Vector2d v1 = Py::toVector2d(p1);
|
||||
Base::Vector2d v2 = Py::toVector2d(p2);
|
||||
Base::Vector2d v3 = Py::toVector2d(p3);
|
||||
|
||||
Base::Vector2d cnt = Geom2dCircle::getCircleCenter(v1, v2, v3);
|
||||
return Py::new_reference_to(Base::Vector2dPy::create(cnt));
|
||||
}
|
||||
|
||||
Py::Float Circle2dPy::getRadius(void) const
|
||||
{
|
||||
Handle(Geom2d_Circle) circle = Handle(Geom2d_Circle)::DownCast(getGeom2dCirclePtr()->handle());
|
||||
|
||||
@@ -932,7 +932,8 @@ Base::Vector2d Geom2dCircle::getCircleCenter (const Base::Vector2d &p1, const Ba
|
||||
double vv = v*v;
|
||||
double ww = w*w;
|
||||
|
||||
if (abs(uu * vv * ww) < Precision::Confusion())
|
||||
double eps2 = Precision::SquareConfusion();
|
||||
if (uu < eps2 || vv < eps2 || ww < eps2)
|
||||
THROWM(Base::ValueError,"Two points are coincident");
|
||||
|
||||
double uv = -(u*v);
|
||||
@@ -945,7 +946,7 @@ Base::Vector2d Geom2dCircle::getCircleCenter (const Base::Vector2d &p1, const Ba
|
||||
|
||||
double wx = w0 + w1 + w2;
|
||||
|
||||
if( abs(wx) < Precision::Confusion())
|
||||
if (abs(wx) < Precision::Confusion())
|
||||
THROWM(Base::ValueError,"Points are collinear");
|
||||
|
||||
double x = (w0*p1.x + w1*p2.x + w2*p3.x)/wx;
|
||||
|
||||
Reference in New Issue
Block a user