From 744bc0bd1861c103f72b49bc6db43011d371db77 Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Tue, 25 Jan 2022 22:24:01 +0100 Subject: [PATCH] altium: Fix pcb arc import using a hack with PCB_SHAPE as intermediate object It would be nice to not use the workaround with PCB_SHAPE, but better than creating wrong geometries in the first place. This should be improved when I'm more in the mood to think about geometric. --- pcbnew/plugins/altium/altium_pcb.cpp | 33 ++++++++++------------------ 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/pcbnew/plugins/altium/altium_pcb.cpp b/pcbnew/plugins/altium/altium_pcb.cpp index 56d3c56b8d..16393702d4 100644 --- a/pcbnew/plugins/altium/altium_pcb.cpp +++ b/pcbnew/plugins/altium/altium_pcb.cpp @@ -2249,39 +2249,28 @@ void ALTIUM_PCB::ConvertArcs6ToBoardItemOnLayer( const AARC6& aElem, PCB_LAYER_I { if( IsCopperLayer( aLayer ) && aElem.net != ALTIUM_NET_UNCONNECTED ) { - EDA_ANGLE angle( aElem.startangle - aElem.endangle, DEGREES_T ); - angle.Normalize(); + // TODO: This is not the actual board item. We use it for now to calculate the arc points. This could be improved! + PCB_SHAPE shape( nullptr, SHAPE_T::ARC ); + EDA_ANGLE includedAngle( aElem.endangle - aElem.startangle, DEGREES_T ); EDA_ANGLE startAngle( aElem.endangle, DEGREES_T ); - VECTOR2I startOffset = VECTOR2I( KiROUND( startAngle.Cos() * aElem.radius ), - -KiROUND( startAngle.Sin() * aElem.radius ) ); - startOffset += aElem.center; + VECTOR2I startOffset = VECTOR2I( KiROUND( startAngle.Cos() * aElem.radius ), + -KiROUND( startAngle.Sin() * aElem.radius ) ); - // If it's a circle then add two 180-degree arcs - if( aElem.startangle == 0.0 && aElem.endangle == 360.0 ) - angle = ANGLE_180; + shape.SetCenter( aElem.center ); + shape.SetStart( aElem.center + startOffset ); + shape.SetArcAngleAndEnd( includedAngle.Normalize(), true ); - SHAPE_ARC shapeArc( aElem.center, startOffset, angle, aElem.width ); + // Create actual arc + SHAPE_ARC shapeArc( shape.GetCenter(), shape.GetStart(), shape.GetArcAngle(), aElem.width ); PCB_ARC* arc = new PCB_ARC( m_board, &shapeArc ); - m_board->Add( arc, ADD_MODE::APPEND ); arc->SetWidth( aElem.width ); arc->SetLayer( aLayer ); arc->SetNetCode( GetNetCode( aElem.net ) ); - // Add second 180-degree arc for a circle - // TODO: can we remove this workaround? - if( aElem.startangle == 0. && aElem.endangle == 360. ) - { - shapeArc = SHAPE_ARC( aElem.center, startOffset, -angle, aElem.width ); - arc = new PCB_ARC( m_board, &shapeArc ); - m_board->Add( arc, ADD_MODE::APPEND ); - - arc->SetWidth( aElem.width ); - arc->SetLayer( aLayer ); - arc->SetNetCode( GetNetCode( aElem.net ) ); - } + m_board->Add( arc, ADD_MODE::APPEND ); } else {