From 5b1c84b5dd46eff9093f81a5eb7b15f83efc8bb7 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Sat, 18 May 2024 22:46:07 +0300 Subject: [PATCH] STEP export: allow closing (and constructing) the wire with 1nm edges. This is ok (and required) because we don't mess with BRepBuilderAPI::Precision nowadays. Fixes https://gitlab.com/kicad/code/kicad/-/issues/18030 --- pcbnew/exporters/step/step_pcb_model.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pcbnew/exporters/step/step_pcb_model.cpp b/pcbnew/exporters/step/step_pcb_model.cpp index a20109607b..1893ca4af2 100644 --- a/pcbnew/exporters/step/step_pcb_model.cpp +++ b/pcbnew/exporters/step/step_pcb_model.cpp @@ -694,13 +694,6 @@ bool STEP_PCB_MODEL::MakeShapes( std::vector& aShapes, const SHAPE gp_Pnt start = toPoint( aPt0 ); gp_Pnt end = toPoint( aPt1 ); - // Do not export too short segments: they create broken shape because OCC thinks - // start point and end point are at the same place - double seg_len = std::hypot( end.X() - start.X(), end.Y() - start.Y() ); - - if( seg_len <= m_mergeOCCMaxDist ) - return false; - BRepBuilderAPI_MakeEdge mkEdge( start, end ); if( !mkEdge.IsDone() || mkEdge.Edge().IsNull() ) @@ -826,8 +819,14 @@ bool STEP_PCB_MODEL::MakeShapes( std::vector& aShapes, const SHAPE isFirstShape = false; } - if( lastPt != firstPt ) - addSegment( lastPt, firstPt ); + if( lastPt != firstPt && !addSegment( lastPt, firstPt ) ) + { + ReportMessage( wxString::Format( + wxT( "** Failed to close wire at %d, %d -> %d, %d **\n" ), lastPt.x, + lastPt.y, firstPt.x, firstPt.y ) ); + + return false; + } } catch( const Standard_Failure& e ) { @@ -895,6 +894,7 @@ bool STEP_PCB_MODEL::MakeShapes( std::vector& aShapes, const SHAPE else { wxASSERT( false ); + return false; } }