mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
arc new syntax
This commit is contained in:
parent
a0c99c848a
commit
561dadb877
@ -151,8 +151,17 @@ public:
|
|||||||
return LineTo (oldp.X(), oldp.Y());
|
return LineTo (oldp.X(), oldp.Y());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ArcTo (double h, double v, const gp_Vec tangv, char arcDir)
|
auto Rotate (double angle)
|
||||||
{
|
{
|
||||||
|
oldDir = localpos.Direction();
|
||||||
|
localpos.Rotate(localpos.Location(), angle*M_PI/180);
|
||||||
|
return shared_from_this();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto ArcTo (double h, double v, const gp_Vec tangv, double angle)
|
||||||
|
{
|
||||||
|
double newAngle = fmod(angle,360)<180?fmod(angle,360):(-360+fmod(angle,360));
|
||||||
|
|
||||||
gp_Dir2d dir = localpos.Direction();
|
gp_Dir2d dir = localpos.Direction();
|
||||||
gp_Pnt2d old2d = localpos.Location();
|
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());
|
||||||
@ -167,65 +176,45 @@ public:
|
|||||||
surf->D0(new2d.X(), new2d.Y(), 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;
|
Handle(Geom_TrimmedCurve) curve = GC_MakeArcOfCircle(oldp, tangv, newp);
|
||||||
if(arcDir)
|
|
||||||
curve = GC_MakeArcOfCircle(newp, tangv, oldp);
|
|
||||||
else
|
|
||||||
//curve = GC_MakeArcOfCircle(oldp, tangv, newp);
|
|
||||||
curve = GC_MakeArcOfCircle(newp, tangv, oldp);
|
|
||||||
|
|
||||||
auto edge = BRepBuilderAPI_MakeEdge(curve).Edge();
|
auto edge = BRepBuilderAPI_MakeEdge(curve).Edge();
|
||||||
wire_builder.Add(edge);
|
wire_builder.Add(edge);
|
||||||
|
|
||||||
|
Rotate(newAngle);
|
||||||
return shared_from_this();
|
return shared_from_this();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Arc(double radius, unsigned short arcDir)
|
auto Arc(double radius, double angle)
|
||||||
{
|
{
|
||||||
//char arcDir;
|
double newAngle = fmod(angle,360)<180?fmod(angle,360):(-360+fmod(angle,360));
|
||||||
gp_Dir2d dir = localpos.Direction();
|
newAngle = newAngle*M_PI/180;
|
||||||
//compute center point of arc
|
|
||||||
gp_Dir2d oldDirn;
|
|
||||||
if(oldDir.Angle(dir)>=0)
|
|
||||||
oldDirn = gp_Dir2d(-oldDir.Y(),oldDir.X());
|
|
||||||
else
|
|
||||||
oldDirn = gp_Dir2d(oldDir.Y(),-oldDir.X());
|
|
||||||
|
|
||||||
cout << "dir = " << dir.X() << ", " << dir.Y() << endl;
|
gp_Dir2d dir = localpos.Direction();
|
||||||
|
gp_Dir2d dirn;
|
||||||
|
//compute center point of arc
|
||||||
|
if(newAngle>=0)
|
||||||
|
dirn = gp_Dir2d(-dir.Y(),dir.X());
|
||||||
|
else
|
||||||
|
dirn = gp_Dir2d(dir.Y(),-dir.X());
|
||||||
|
|
||||||
gp_Pnt2d oldp = localpos.Location();
|
gp_Pnt2d oldp = localpos.Location();
|
||||||
|
|
||||||
cout << "oldp = " << oldp.X() << ", " << oldp.Y() << endl;
|
oldp.Translate(radius*dirn);
|
||||||
oldp.Translate(radius*oldDirn);
|
|
||||||
cout << "oldp = " << oldp.X() << ", " << oldp.Y() << endl;
|
|
||||||
|
|
||||||
cout << "angle = " << oldDir.Angle(dir) << endl;
|
dirn.Rotate(newAngle-M_PI);
|
||||||
cout << "olddirn = " << oldDirn.X() << ", " << oldDirn.Y() << endl;
|
oldp.Translate(radius*dirn);
|
||||||
oldDirn.Rotate(oldDir.Angle(dir)-M_PI);
|
|
||||||
cout << "olddirn = " << oldDirn.X() << ", " << oldDirn.Y() << endl;
|
|
||||||
oldp.Translate(radius*oldDirn);
|
|
||||||
cout << "oldp = " << oldp.X() << ", " << oldp.Y() << endl;
|
|
||||||
|
|
||||||
//compute tangent vector in P1
|
//compute tangent vector in P1
|
||||||
//TODO: tangv is not in the correct plane. surf.D1?
|
gp_Pnt tangvEndp = axis.Location() . Translated(dir.X() * axis.XDirection() + dir.Y() * axis.YDirection());
|
||||||
gp_Vec tangv;
|
gp_Vec tangv = gp_Vec(axis.Location(),tangvEndp);
|
||||||
if(arcDir)
|
|
||||||
//tangv = gp_Vec(-oldDir.Y(), axis.Location().Z(), oldDir.X());
|
//cout << "dir = " << occ2ng(dir) << endl;
|
||||||
tangv = gp_Vec(-oldDir.X(), axis.Direction().Z(), -oldDir.Y());
|
cout << "tangv = " << occ2ng(tangv) << endl;
|
||||||
else
|
|
||||||
//tangv = gp_Vec(oldDir.Y(), axis.Location().Z(), -oldDir.X());
|
|
||||||
tangv = gp_Vec(oldDir.X(), axis.Direction().Z(), oldDir.Y());
|
|
||||||
|
|
||||||
//add arc
|
//add arc
|
||||||
return ArcTo (oldp.X(), oldp.Y(), tangv, arcDir);
|
return ArcTo (oldp.X(), oldp.Y(), tangv, newAngle*180/M_PI);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
auto Rotate (double angle)
|
|
||||||
{
|
|
||||||
oldDir = localpos.Direction();
|
|
||||||
localpos.Rotate(localpos.Location(), angle*M_PI/180);
|
|
||||||
return shared_from_this();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Rectangle (double l, double w)
|
auto Rectangle (double l, double w)
|
||||||
|
Loading…
Reference in New Issue
Block a user