From c9fb364cc07f3e87a6da39b9d186c23deaf90e28 Mon Sep 17 00:00:00 2001 From: shirnschall Date: Fri, 13 Aug 2021 01:48:29 +0200 Subject: [PATCH] now using three points to construct arc in 2d --- libsrc/occ/python_occ_shapes.cpp | 61 ++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index 54ccccf5..d9dc6712 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -47,6 +46,7 @@ #include #include #include +#include #if OCC_VERSION_MAJOR>=7 && OCC_VERSION_MINOR>=4 #define OCC_HAVE_DUMP_JSON @@ -159,30 +159,61 @@ public: return shared_from_this(); } - auto ArcTo (double h, double v, const gp_Vec2d tangv, double angle) + auto ArcTo (double h, double v, const gp_Vec2d t, double angle) { double newAngle = fmod(angle,360); - gp_Pnt2d old2d = localpos.Location(); - //gp_Pnt oldp = axis.Location() . Translated(old2d.X() * axis.XDirection() + old2d.Y() * axis.YDirection()); + gp_Pnt2d P1 = localpos.Location(); localpos.SetLocation (gp_Pnt2d(h,v)); - gp_Pnt2d new2d = localpos.Location(); - gp_Pnt newp = axis.Location() . Translated(new2d.X() * axis.XDirection() + new2d.Y() * axis.YDirection()); + gp_Pnt2d P2 = localpos.Location(); - cout << "arcto, newp = " << occ2ng(newp) << endl; - cout << "tangv = (" << tangv.X() << ", " << tangv.Y() << ")" << endl; - gp_Pnt pfromsurf; - surf->D0(new2d.X(), new2d.Y(), pfromsurf); - //cout << "p from plane = " << occ2ng(pfromsurf) << endl; + cout << "ArcTo:" << endl; + cout << "P1 = (" << P1.X() <<", " << P1.Y() << ")"< -M_PI/2 && t.Angle(p12n) < M_PI/2) + P3 = gp_Pnt2d(M.X() + r * p12n.X() , M.Y() + r * p12n.Y()); + else + P3 = gp_Pnt2d(M.X() - r * p12n.X() , M.Y() - r * p12n.Y()); + + cout << "r = " << r <