3d-viewer: Approximate 0-length element is rrect

Apply same logic of using a filled circle to represent a zero-length
element as a filled circle with radius of the line.

Fixes: lp:1785823
* https://bugs.launchpad.net/kicad/+bug/1785823
This commit is contained in:
Seth Hillbrand 2018-09-19 20:18:15 -07:00
parent 618182dcd6
commit 8efcf81cf5
1 changed files with 36 additions and 42 deletions

View File

@ -418,27 +418,24 @@ void CINFO3D_VISU::createNewPadWithClearance( const D_PAD* aPad,
*aPad ) ); *aPad ) );
// Add the PAD contours // Add the PAD contours
// !TODO: check the corners because it cannot add // Round segments cannot have 0-length elements, so we approximate them
// roundsegments that are in the same start and end position // as a small circle
aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[0], for( int i = 1; i <= 4; i++ )
corners3DU[1], {
aClearanceValue.x * 2.0f * m_biuTo3Dunits, if( Is_segment_a_circle( corners3DU[i - 1], corners3DU[i & 3] ) )
*aPad ) ); {
aDstContainer->Add( new CFILLEDCIRCLE2D( corners3DU[i - 1],
aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[1], aClearanceValue.x * 2.0f * m_biuTo3Dunits,
corners3DU[2], *aPad ) );
aClearanceValue.x * 2.0f * m_biuTo3Dunits, }
*aPad ) ); else
{
aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[2], aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[i - 1],
corners3DU[3], corners3DU[i & 3],
aClearanceValue.x * 2.0f * m_biuTo3Dunits, aClearanceValue.x * 2.0f * m_biuTo3Dunits,
*aPad ) ); *aPad ) );
}
aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[3], }
corners3DU[0],
aClearanceValue.x * 2.0f * m_biuTo3Dunits,
*aPad ) );
} }
break; break;
@ -473,27 +470,24 @@ void CINFO3D_VISU::createNewPadWithClearance( const D_PAD* aPad,
*aPad ) ); *aPad ) );
// Add the PAD contours // Add the PAD contours
// !TODO: check the corners because it cannot add // Round segments cannot have 0-length elements, so we approximate them
// roundsegments that are in the same start and end position // as a small circle
aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[0], for( int i = 1; i <= 4; i++ )
corners3DU[1], {
rounding_radius * 2.0f * m_biuTo3Dunits, if( Is_segment_a_circle( corners3DU[i - 1], corners3DU[i & 3] ) )
*aPad ) ); {
aDstContainer->Add( new CFILLEDCIRCLE2D( corners3DU[i - 1],
aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[1], rounding_radius * 2.0f * m_biuTo3Dunits,
corners3DU[2], *aPad ) );
rounding_radius * 2.0f * m_biuTo3Dunits, }
*aPad ) ); else
{
aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[2], aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[i - 1],
corners3DU[3], corners3DU[i & 3],
rounding_radius * 2.0f * m_biuTo3Dunits, rounding_radius * 2.0f * m_biuTo3Dunits,
*aPad ) ); *aPad ) );
}
aDstContainer->Add( new CROUNDSEGMENT2D( corners3DU[3], }
corners3DU[0],
rounding_radius * 2.0f * m_biuTo3Dunits,
*aPad ) );
} }
break; break;