More support of DRW_SEGMENT Bezier curve (support in 3D viewer, and PnS router).

This commit is contained in:
jean-pierre charras 2018-07-09 19:15:36 +02:00
parent e58e5966dc
commit 3c6e8c4a40
3 changed files with 109 additions and 5 deletions

View File

@ -821,6 +821,7 @@ void CINFO3D_VISU::AddShapeWithClearanceToContainer( const DRAWSEGMENT* aDrawSeg
}
break;
case S_CURVE:
case S_POLYGON:
{
const int segcountforcircle = 16;
@ -843,9 +844,6 @@ void CINFO3D_VISU::AddShapeWithClearanceToContainer( const DRAWSEGMENT* aDrawSeg
}
break;
case S_CURVE: // Bezier curve (not yet in use in KiCad)
break;
default:
break;
}

View File

@ -264,6 +264,23 @@ bool ConvertOutlineToPolygon( std::vector<DRAWSEGMENT*>& aSegList, SHAPE_POLY_SE
}
break;
case S_CURVE:
{
graphic->RebuildBezierToSegmentsPointsList( graphic->GetWidth() );
for( unsigned int jj = 0; jj < graphic->GetBezierPoints().size(); jj++ )
{
wxPoint pt = graphic->GetBezierPoints()[jj];
if( pt.x < xmin.x )
{
xmin = pt;
xmini = i;
}
}
}
break;
default:
break;
}
@ -295,7 +312,7 @@ bool ConvertOutlineToPolygon( std::vector<DRAWSEGMENT*>& aSegList, SHAPE_POLY_SE
aPolygons.Append( prevPt );
// Do not append the other end point yet of this 'graphic', this first
// 'graphic' might be an arc.
// 'graphic' might be an arc or a curve.
for(;;)
{
@ -354,6 +371,43 @@ bool ConvertOutlineToPolygon( std::vector<DRAWSEGMENT*>& aSegList, SHAPE_POLY_SE
}
break;
case S_CURVE:
// We do not support Bezier curves in polygons, so approximate
// with a series of short lines and put those
// line segments into the !same! PATH.
{
wxPoint nextPt;
bool reverse = false;
// Use the end point furthest away from
// prevPt as we assume the other end to be ON prevPt or
// very close to it.
if( close_st( prevPt, graphic->GetStart(), graphic->GetEnd() ) )
nextPt = graphic->GetEnd();
else
{
nextPt = graphic->GetStart();
reverse = true;
}
if( reverse )
{
for( int jj = graphic->GetBezierPoints().size()-1;
jj >= 0; jj-- )
aPolygons.Append( graphic->GetBezierPoints()[jj] );
}
else
{
for( unsigned int jj = 0;
jj < graphic->GetBezierPoints().size(); jj++ )
aPolygons.Append( graphic->GetBezierPoints()[jj] );
}
prevPt = nextPt;
}
break;
default:
if( aErrorText )
{
@ -499,6 +553,42 @@ bool ConvertOutlineToPolygon( std::vector<DRAWSEGMENT*>& aSegList, SHAPE_POLY_SE
prevPt = nextPt;
}
case S_CURVE:
// We do not support Bezier curves in polygons, so approximate
// with a series of short lines and put those
// line segments into the !same! PATH.
{
wxPoint nextPt;
bool reverse = false;
// Use the end point furthest away from
// prevPt as we assume the other end to be ON prevPt or
// very close to it.
if( close_st( prevPt, graphic->GetStart(), graphic->GetEnd() ) )
nextPt = graphic->GetEnd();
else
{
nextPt = graphic->GetStart();
reverse = true;
}
if( reverse )
{
for( int jj = graphic->GetBezierPoints().size()-1;
jj >= 0; jj-- )
aPolygons.Append( graphic->GetBezierPoints()[jj], -1, hole );
}
else
{
for( unsigned int jj = 0;
jj < graphic->GetBezierPoints().size(); jj++ )
aPolygons.Append( graphic->GetBezierPoints()[jj], -1, hole );
}
prevPt = nextPt;
}
break;
default:

View File

@ -891,6 +891,22 @@ bool PNS_KICAD_IFACE::syncGraphicalItem( PNS::NODE* aWorld, DRAWSEGMENT* aItem )
break;
}
case S_CURVE:
{
aItem->RebuildBezierToSegmentsPointsList( aItem->GetWidth() );
wxPoint start_pt = aItem->GetBezierPoints()[0];
for( unsigned int jj = 1; jj < aItem->GetBezierPoints().size(); jj++ )
{
wxPoint end_pt = aItem->GetBezierPoints()[jj];
SHAPE_SEGMENT *seg = new SHAPE_SEGMENT(
VECTOR2I( start_pt ), VECTOR2I( end_pt ), aItem->GetWidth() );
segs.push_back( seg );
start_pt = end_pt;
}
}
break;
default:
break;
}