Dxf importer: fix issue when importing some "degenerated" splines.

Sometimes a dxf curve is a "degenerated" bezier curve having only 3 points.
(a control point is at same location as a end point)
This commit fix incorrect import of these curves.
This commit is contained in:
jean-pierre charras 2020-02-03 10:39:29 +01:00
parent 4f82939384
commit 8f3e8cf893
1 changed files with 10 additions and 2 deletions

View File

@ -1040,7 +1040,7 @@ void DXF_IMPORT_PLUGIN::insertSpline( int aWidth )
if( startpoint != endpoint ) if( startpoint != endpoint )
{ {
m_internalImporter.AddLine( startpoint, endpoint ); m_internalImporter.AddLine( startpoint, endpoint, aWidth );
updateImageLimits( startpoint ); updateImageLimits( startpoint );
updateImageLimits( endpoint ); updateImageLimits( endpoint );
@ -1067,12 +1067,20 @@ void DXF_IMPORT_PLUGIN::insertSpline( int aWidth )
// Each Bezier curve uses 4 vertices (a start point, 2 control points and a end point). // Each Bezier curve uses 4 vertices (a start point, 2 control points and a end point).
// So we can have more than one Bezier curve ( there are one curve each four vertices) // So we can have more than one Bezier curve ( there are one curve each four vertices)
// However, one can have one Bezier curve with end point = ctrl point 2, having only 3
// defined points in list.
for( unsigned ii = 0; ii < coords.size(); ii += 8 ) for( unsigned ii = 0; ii < coords.size(); ii += 8 )
{ {
VECTOR2D start( mapX( coords[ii] ), mapY( coords[ii+1] ) ); VECTOR2D start( mapX( coords[ii] ), mapY( coords[ii+1] ) );
VECTOR2D bezierControl1( mapX( coords[ii+2] ), mapY( coords[ii+3] ) ); VECTOR2D bezierControl1( mapX( coords[ii+2] ), mapY( coords[ii+3] ) );
VECTOR2D bezierControl2( mapX( coords[ii+4] ), mapY( coords[ii+5] ) ); VECTOR2D bezierControl2( mapX( coords[ii+4] ), mapY( coords[ii+5] ) );
VECTOR2D end( mapX( coords[ii+6] ), mapY( coords[ii+7] ) ); VECTOR2D end;
if( ii+7 < coords.size() )
end = VECTOR2D( mapX( coords[ii+6] ), mapY( coords[ii+7] ) );
else
end = bezierControl2;
m_internalImporter.AddSpline( start, bezierControl1, bezierControl2, end , aWidth ); m_internalImporter.AddSpline( start, bezierControl1, bezierControl2, end , aWidth );
} }
#endif #endif