From 2449b4c79c117a3cdc6be4b90fb1e0a310608fae Mon Sep 17 00:00:00 2001 From: shirnschall Date: Wed, 11 Aug 2021 23:02:49 +0200 Subject: [PATCH] testing GCE2d_MakeArcOfCircle for Arc --- libsrc/occ/python_occ_shapes.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index 129fe2f2..54ccccf5 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -158,28 +159,28 @@ public: return shared_from_this(); } - auto ArcTo (double h, double v, const gp_Vec tangv, double angle) + auto ArcTo (double h, double v, const gp_Vec2d tangv, double angle) { - double newAngle = fmod(angle,360)<180?fmod(angle,360):(-360+fmod(angle,360)); + double newAngle = fmod(angle,360); - gp_Dir2d dir = localpos.Direction(); gp_Pnt2d old2d = localpos.Location(); - gp_Pnt oldp = axis.Location() . Translated(old2d.X() * axis.XDirection() + old2d.Y() * axis.YDirection()); + //gp_Pnt oldp = axis.Location() . Translated(old2d.X() * axis.XDirection() + old2d.Y() * axis.YDirection()); 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()); cout << "arcto, newp = " << occ2ng(newp) << endl; - cout << "tangv = " << occ2ng(tangv) << 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 << "p from plane = " << occ2ng(pfromsurf) << endl; //TODO: use GCE2d_MakeArcOfCircle - Handle(Geom_TrimmedCurve) curve = GC_MakeArcOfCircle(oldp, tangv, newp); + Handle(Geom2d_TrimmedCurve) curve2d = GCE2d_MakeArcOfCircle(old2d, tangv, new2d).Value(); - auto edge = BRepBuilderAPI_MakeEdge(curve).Edge(); + auto edge = BRepBuilderAPI_MakeEdge(curve2d, surf).Edge(); + BRepLib::BuildCurves3d(edge); wire_builder.Add(edge); Rotate(newAngle); @@ -188,8 +189,7 @@ public: auto Arc(double radius, double angle) { - double newAngle = fmod(angle,360)<180?fmod(angle,360):(-360+fmod(angle,360)); - newAngle = newAngle*M_PI/180; + double newAngle = fmod(angle,360)*M_PI/180; gp_Dir2d dir = localpos.Direction(); gp_Dir2d dirn; @@ -207,11 +207,9 @@ public: oldp.Translate(radius*dirn); //compute tangent vector in P1 - gp_Pnt tangvEndp = axis.Location() . Translated(dir.X() * axis.XDirection() + dir.Y() * axis.YDirection()); - gp_Vec tangv = gp_Vec(axis.Location(),tangvEndp); + gp_Vec2d tangv = gp_Vec2d(dir.X(),dir.Y()); - //cout << "dir = " << occ2ng(dir) << endl; - cout << "tangv = " << occ2ng(tangv) << endl; + cout << "tangv = (" << tangv.X() << ", " << tangv.Y() << ")" << endl; //add arc return ArcTo (oldp.X(), oldp.Y(), tangv, newAngle*180/M_PI);