diff --git a/pcbnew/exporters/step/exporter_step.cpp b/pcbnew/exporters/step/exporter_step.cpp index 2e04dd1b48..004919e44a 100644 --- a/pcbnew/exporters/step/exporter_step.cpp +++ b/pcbnew/exporters/step/exporter_step.cpp @@ -293,19 +293,7 @@ bool EXPORTER_STEP::buildTrack3DShape( PCB_TRACK* aTrack, VECTOR2D aOrigin ) { if( aTrack->Type() == PCB_VIA_T ) { - PAD dummy( nullptr ); - int hole = static_cast( aTrack )->GetDrillValue(); - dummy.SetDrillSize( VECTOR2I( hole, hole ) ); - dummy.SetPosition( aTrack->GetStart() ); - dummy.SetSize( VECTOR2I( aTrack->GetWidth(), aTrack->GetWidth() ) ); - - if( m_pcbModel->AddPadHole( &dummy, aOrigin ) ) - { - if( m_pcbModel->AddPadShape( &dummy, aOrigin ) ) - return false; - } - - return true; + return m_pcbModel->AddViaShape( static_cast( aTrack ), aOrigin ); } PCB_LAYER_ID pcblayer = aTrack->GetLayer(); @@ -313,12 +301,17 @@ bool EXPORTER_STEP::buildTrack3DShape( PCB_TRACK* aTrack, VECTOR2D aOrigin ) if( pcblayer != F_Cu && pcblayer != B_Cu ) return false; - int maxError = m_board->GetDesignSettings().m_MaxError; + if( aTrack->Type() == PCB_ARC_T ) + { + int maxError = m_board->GetDesignSettings().m_MaxError; - if( pcblayer == F_Cu ) - aTrack->TransformShapeToPolygon( m_top_copper_shapes, pcblayer, 0, maxError, ERROR_INSIDE ); + if( pcblayer == F_Cu ) + aTrack->TransformShapeToPolygon( m_top_copper_shapes, pcblayer, 0, maxError, ERROR_INSIDE ); + else + aTrack->TransformShapeToPolygon( m_bottom_copper_shapes, pcblayer, 0, maxError, ERROR_INSIDE ); + } else - aTrack->TransformShapeToPolygon( m_bottom_copper_shapes, pcblayer, 0, maxError, ERROR_INSIDE ); + m_pcbModel->AddTrackSegment( aTrack, aOrigin ); return true; } diff --git a/pcbnew/exporters/step/step_pcb_model.cpp b/pcbnew/exporters/step/step_pcb_model.cpp index 8f456c0af5..1b34145165 100644 --- a/pcbnew/exporters/step/step_pcb_model.cpp +++ b/pcbnew/exporters/step/step_pcb_model.cpp @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -256,6 +257,47 @@ bool STEP_PCB_MODEL::AddPadShape( const PAD* aPad, const VECTOR2D& aOrigin ) } +bool STEP_PCB_MODEL::AddViaShape( const PCB_VIA* aVia, const VECTOR2D& aOrigin ) +{ + // A via is very similar to a round pad. So, for now, used AddPadHole() to + // create a via+hole shape + PAD dummy( nullptr ); + int hole = aVia->GetDrillValue(); + dummy.SetDrillSize( VECTOR2I( hole, hole ) ); + dummy.SetPosition( aVia->GetStart() ); + dummy.SetSize( VECTOR2I( aVia->GetWidth(), aVia->GetWidth() ) ); + + if( AddPadHole( &dummy, aOrigin ) ) + { + if( !AddPadShape( &dummy, aOrigin ) ) + return false; + } + + return true; +} + + +bool STEP_PCB_MODEL::AddTrackSegment( const PCB_TRACK* aTrack, const VECTOR2D& aOrigin ) +{ + PCB_LAYER_ID pcblayer = aTrack->GetLayer(); + + if( pcblayer != F_Cu && pcblayer != B_Cu ) + return false; + + TopoDS_Shape shape; + double zposition = pcblayer == F_Cu ? m_boardThickness : -m_copperThickness; + + bool success = MakeShapeAsThickSegment( shape, aTrack->GetStart(), aTrack->GetEnd(), + aTrack->GetWidth(), m_copperThickness, + zposition, aOrigin ); + + if( success ) + m_board_copper_tracks.push_back( shape ); + + return success; +} + + bool STEP_PCB_MODEL::AddCopperPolygonShapes( const SHAPE_POLY_SET* aPolyShapes, bool aOnTop, const VECTOR2D& aOrigin, bool aTrack ) { @@ -549,11 +591,20 @@ bool STEP_PCB_MODEL::MakeShapeAsThickSegment( TopoDS_Shape& aShape, BRepBuilderAPI_MakeWire wire; bool success = true; + // Short segments (distance between end points < m_mergeOCCMaxDist(in mm)) must be + // skipped because OCC merge end points, and a null shape is created + bool short_seg = pcbIUScale.IUTomm( len ) <= m_mergeOCCMaxDist; + try { TopoDS_Edge edge; - edge = BRepBuilderAPI_MakeEdge( coords3D[0], coords3D[1] ); - wire.Add( edge ); + + + if( !short_seg ) // Do not export a too short segment + { + edge = BRepBuilderAPI_MakeEdge( coords3D[0], coords3D[1] ); + wire.Add( edge ); + } Handle(Geom_TrimmedCurve) arcOfCircle = GC_MakeArcOfCircle( coords3D[1], // start point coords3D[2], // aux point @@ -562,8 +613,11 @@ bool STEP_PCB_MODEL::MakeShapeAsThickSegment( TopoDS_Shape& aShape, edge = BRepBuilderAPI_MakeEdge( arcOfCircle ); wire.Add( edge ); - edge = BRepBuilderAPI_MakeEdge( coords3D[3], coords3D[4] ); - 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 diff --git a/pcbnew/exporters/step/step_pcb_model.h b/pcbnew/exporters/step/step_pcb_model.h index 7f42063d2c..62c7e05d34 100644 --- a/pcbnew/exporters/step/step_pcb_model.h +++ b/pcbnew/exporters/step/step_pcb_model.h @@ -83,9 +83,15 @@ public: // add a pad hole or slot (must be in final position) bool AddPadHole( const PAD* aPad, const VECTOR2D& aOrigin ); - // add a pad/via shape (must be in final position) + // add a pad shape (must be in final position) bool AddPadShape( const PAD* aPad, const VECTOR2D& aOrigin ); + // add a via shape + bool AddViaShape( const PCB_VIA* aVia, const VECTOR2D& aOrigin ); + + // add a track segment shape (do not use it for track arcs) + bool AddTrackSegment( const PCB_TRACK* aTrack, const VECTOR2D& aOrigin ); + // add a set of polygons (must be in final position) on top or bottom of the board as copper bool AddCopperPolygonShapes( const SHAPE_POLY_SET* aPolyShapes, bool aOnTop, const VECTOR2D& aOrigin, bool aTrack );