From 58fc4f512da48efb1ea5633ee661282ee7db62fc Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Fri, 8 Oct 2021 20:07:21 +0100 Subject: [PATCH] CADSTAR PCB: Don't create zero width tracks Fixes a bug in the route offsetting part of the import that was resulting in zero-width tracks being imported. --- .../cadstar/cadstar_pcb_archive_loader.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp index cb82c118ec..24746f686e 100644 --- a/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp +++ b/pcbnew/plugins/cadstar/cadstar_pcb_archive_loader.cpp @@ -2187,7 +2187,8 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadNets() // For junction points we need to find out the biggest size of the other routes connecting // at the junction in order to correctly apply the same "route offset" operation that the - // CADSTAR post processor applies when generating Manufacturing output + // CADSTAR post processor applies when generating Manufacturing output. The only exception + // is if there is just a single route at the junction point, we use that route width auto getJunctionSize = [&]( NETELEMENT_ID aJptNetElemId, const NET_PCB::CONNECTION_PCB& aConnectionToIgnore ) -> int { @@ -2200,7 +2201,9 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadNets() if( connection.StartNode == aConnectionToIgnore.StartNode && connection.EndNode == aConnectionToIgnore.EndNode ) + { continue; + } if( connection.StartNode == aJptNetElemId ) { @@ -2214,6 +2217,18 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadNets() } } + if( jptsize == 0 ) + { + // aConnectionToIgnore is actually the only one that has a route, so lets use that + // to determine junction size + NET_PCB::ROUTE_VERTEX vertex = aConnectionToIgnore.Route.RouteVertices.front(); + + if( aConnectionToIgnore.EndNode == aJptNetElemId ) + vertex = aConnectionToIgnore.Route.RouteVertices.back(); + + jptsize = getKiCadLength( vertex.RouteWidth ); + } + return jptsize; }; @@ -3743,7 +3758,9 @@ double CADSTAR_PCB_ARCHIVE_LOADER::getPolarAngle( const wxPoint& aPoint ) NETINFO_ITEM* CADSTAR_PCB_ARCHIVE_LOADER::getKiCadNet( const NET_ID& aCadstarNetID ) { if( aCadstarNetID.IsEmpty() ) + { return nullptr; + } else if( m_netMap.find( aCadstarNetID ) != m_netMap.end() ) { return m_netMap.at( aCadstarNetID );