From f8dac433251e46b11e290f3abb3a6a8b8d48cda4 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Tue, 29 Aug 2023 23:58:21 +0300 Subject: [PATCH] STEP export: add short segments as circles. Because OCC can't connect two arcs together sometimes. --- pcbnew/exporters/step/step_pcb_model.cpp | 50 ++++++++++++++---------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/pcbnew/exporters/step/step_pcb_model.cpp b/pcbnew/exporters/step/step_pcb_model.cpp index 1b34145165..38395206dc 100644 --- a/pcbnew/exporters/step/step_pcb_model.cpp +++ b/pcbnew/exporters/step/step_pcb_model.cpp @@ -599,32 +599,40 @@ bool STEP_PCB_MODEL::MakeShapeAsThickSegment( TopoDS_Shape& aShape, { TopoDS_Edge edge; + if( short_seg ) + { + Handle( Geom_Circle ) circle = GC_MakeCircle( coords3D[1], // arc1 start point + coords3D[2], // arc1 mid point + coords3D[5] // arc2 mid point + ); - if( !short_seg ) // Do not export a too short segment + edge = BRepBuilderAPI_MakeEdge( circle ); + wire.Add( edge ); + } + else { edge = BRepBuilderAPI_MakeEdge( coords3D[0], coords3D[1] ); wire.Add( edge ); - } - Handle(Geom_TrimmedCurve) arcOfCircle = GC_MakeArcOfCircle( coords3D[1], // start point - coords3D[2], // aux point - coords3D[3] // end point - ); - edge = BRepBuilderAPI_MakeEdge( arcOfCircle ); - wire.Add( edge ); + Handle( Geom_TrimmedCurve ) arcOfCircle = + GC_MakeArcOfCircle( coords3D[1], // start point + coords3D[2], // mid point + coords3D[3] // end point + ); + edge = BRepBuilderAPI_MakeEdge( arcOfCircle ); + wire.Add( edge ); - if( !short_seg ) // Do not export a too short segment - { edge = BRepBuilderAPI_MakeEdge( coords3D[3], coords3D[4] ); wire.Add( edge ); - } - Handle(Geom_TrimmedCurve) arcOfCircle2 = GC_MakeArcOfCircle( coords3D[4], // start point - coords3D[5], // aux point - coords3D[0] // end point - ); - edge = BRepBuilderAPI_MakeEdge( arcOfCircle2 ); - wire.Add( edge ); + Handle( Geom_TrimmedCurve ) arcOfCircle2 = + GC_MakeArcOfCircle( coords3D[4], // start point + coords3D[5], // mid point + coords3D[0] // end point + ); + edge = BRepBuilderAPI_MakeEdge( arcOfCircle2 ); + wire.Add( edge ); + } } catch( const Standard_Failure& e ) { @@ -638,7 +646,8 @@ bool STEP_PCB_MODEL::MakeShapeAsThickSegment( TopoDS_Shape& aShape, try { - face = BRepBuilderAPI_MakeFace( wire ); + gp_Pln plane( coords3D[0], gp::DZ() ); + face = BRepBuilderAPI_MakeFace( plane, wire ); } catch( const Standard_Failure& e ) { @@ -787,9 +796,8 @@ bool STEP_PCB_MODEL::MakeShapes( std::vector& aShapes, const SHAPE if( lastPt != currentArc.GetP0() ) addSegment( lastPt, currentArc.GetP0() ); - addArc( currentArc ); - - lastPt = currentArc.GetP1(); + if( addArc( currentArc ) ) + lastPt = currentArc.GetP1(); } else if( !isArc ) {