Step export: fix Bezier curves export.
Fixes #6054 https://gitlab.com/kicad/code/kicad/issues/6054
This commit is contained in:
parent
f8a4edb1c9
commit
d4eb7b0f3d
|
@ -480,11 +480,18 @@ bool KICADPCB::ComposePCB( bool aComposeVirtual )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// adjust the coordinate system
|
// adjust the coordinate system
|
||||||
|
// Note: we negate the Y coordinates due to the fact in Pcbnew the Y axis
|
||||||
|
// is from top to bottom.
|
||||||
KICADCURVE lcurve = *i;
|
KICADCURVE lcurve = *i;
|
||||||
lcurve.m_start.y = -( lcurve.m_start.y - origin.y );
|
lcurve.m_start.y = -( lcurve.m_start.y - origin.y );
|
||||||
lcurve.m_end.y = -( lcurve.m_end.y - origin.y );
|
lcurve.m_end.y = -( lcurve.m_end.y - origin.y );
|
||||||
lcurve.m_start.x -= origin.x;
|
lcurve.m_start.x -= origin.x;
|
||||||
lcurve.m_end.x -= origin.x;
|
lcurve.m_end.x -= origin.x;
|
||||||
|
// used in bezier curves:
|
||||||
|
lcurve.m_bezierctrl1.y = -( lcurve.m_bezierctrl1.y - origin.y );
|
||||||
|
lcurve.m_bezierctrl1.x -= origin.x;
|
||||||
|
lcurve.m_bezierctrl2.y = -( lcurve.m_bezierctrl2.y - origin.y );
|
||||||
|
lcurve.m_bezierctrl2.x -= origin.x;
|
||||||
|
|
||||||
if( CURVE_ARC == lcurve.m_form )
|
if( CURVE_ARC == lcurve.m_form )
|
||||||
lcurve.m_angle = -lcurve.m_angle;
|
lcurve.m_angle = -lcurve.m_angle;
|
||||||
|
|
|
@ -80,6 +80,7 @@
|
||||||
#include <gp_Circ.hxx>
|
#include <gp_Circ.hxx>
|
||||||
#include <gp_Dir.hxx>
|
#include <gp_Dir.hxx>
|
||||||
#include <gp_Pnt.hxx>
|
#include <gp_Pnt.hxx>
|
||||||
|
#include <Geom_BezierCurve.hxx>
|
||||||
|
|
||||||
static constexpr double USER_PREC = 1e-4;
|
static constexpr double USER_PREC = 1e-4;
|
||||||
static constexpr double USER_ANGLE_PREC = 1e-6;
|
static constexpr double USER_ANGLE_PREC = 1e-6;
|
||||||
|
@ -1550,7 +1551,6 @@ bool OUTLINE::MakeShape( TopoDS_Shape& aShape, double aThickness )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <Geom_BezierCurve.hxx>
|
|
||||||
|
|
||||||
bool OUTLINE::addEdge( BRepBuilderAPI_MakeWire* aWire, KICADCURVE& aCurve, DOUBLET& aLastPoint )
|
bool OUTLINE::addEdge( BRepBuilderAPI_MakeWire* aWire, KICADCURVE& aCurve, DOUBLET& aLastPoint )
|
||||||
{
|
{
|
||||||
|
@ -1587,23 +1587,18 @@ bool OUTLINE::addEdge( BRepBuilderAPI_MakeWire* aWire, KICADCURVE& aCurve, DOUBL
|
||||||
|
|
||||||
case CURVE_BEZIER:
|
case CURVE_BEZIER:
|
||||||
{
|
{
|
||||||
#if 0 // TODO: this code is not working. so fix it or replace the curve by a set of segments
|
|
||||||
TColgp_Array1OfPnt poles(0, 3);
|
TColgp_Array1OfPnt poles(0, 3);
|
||||||
gp_Pnt pt = gp_Pnt( aCurve.m_start.x, aCurve.m_start.y, 0.0 );
|
gp_Pnt pt = gp_Pnt( aCurve.m_start.x, aCurve.m_start.y, 0.0 );
|
||||||
poles(0) = pt;
|
poles(0) = pt;
|
||||||
pt = gp_Pnt( aCurve.m_bezierctrl1.x, -aCurve.m_bezierctrl1.y, 0.0 );
|
pt = gp_Pnt( aCurve.m_bezierctrl1.x, aCurve.m_bezierctrl1.y, 0.0 );
|
||||||
poles(1) = pt;
|
poles(1) = pt;
|
||||||
pt = gp_Pnt( aCurve.m_bezierctrl2.x, -aCurve.m_bezierctrl2.y, 0.0 );
|
pt = gp_Pnt( aCurve.m_bezierctrl2.x, aCurve.m_bezierctrl2.y, 0.0 );
|
||||||
poles(2) = pt;
|
poles(2) = pt;
|
||||||
pt = gp_Pnt( endPoint.x, endPoint.y, 0.0 );
|
pt = gp_Pnt( endPoint.x, endPoint.y, 0.0 );
|
||||||
poles(3) = pt;
|
poles(3) = pt;
|
||||||
|
|
||||||
Geom_BezierCurve* bezier_curve = new Geom_BezierCurve( poles );
|
Geom_BezierCurve* bezier_curve = new Geom_BezierCurve( poles );
|
||||||
edge = BRepBuilderAPI_MakeEdge( bezier_curve );
|
edge = BRepBuilderAPI_MakeEdge( bezier_curve );
|
||||||
#else // Generate a segment between ends
|
|
||||||
edge = BRepBuilderAPI_MakeEdge( gp_Pnt( aLastPoint.x, aLastPoint.y, 0.0 ),
|
|
||||||
gp_Pnt( endPoint.x, endPoint.y, 0.0 ) );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue