diff --git a/utils/kicad2step/pcb/kicadfootprint.cpp b/utils/kicad2step/pcb/kicadfootprint.cpp index 428845e1d6..0feaa2ec6a 100644 --- a/utils/kicad2step/pcb/kicadfootprint.cpp +++ b/utils/kicad2step/pcb/kicadfootprint.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo - * Copyright 2018-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright 2018-2021 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -54,13 +54,13 @@ KICADFOOTPRINT::KICADFOOTPRINT( KICADPCB* aParent ) KICADFOOTPRINT::~KICADFOOTPRINT() { - for( auto i : m_pads ) + for( KICADPAD* i : m_pads ) delete i; - for( auto i : m_curves ) + for( KICADCURVE* i : m_curves ) delete i; - for( auto i : m_models ) + for( KICADMODEL* i : m_models ) delete i; return; @@ -69,7 +69,7 @@ KICADFOOTPRINT::~KICADFOOTPRINT() bool KICADFOOTPRINT::Read( SEXPR::SEXPR* aEntry ) { - if( NULL == aEntry ) + if( !aEntry ) return false; if( aEntry->IsList() ) @@ -120,27 +120,27 @@ bool KICADFOOTPRINT::Read( SEXPR::SEXPR* aEntry ) symname = child->GetChild( 0 )->GetSymbol(); if( symname == "layer" ) - result = result && parseLayer( child ); + result = parseLayer( child ); else if( symname == "at" ) - result = result && parsePosition( child ); + result = parsePosition( child ); else if( symname == "attr" ) - result = result && parseAttribute( child ); + result = parseAttribute( child ); else if( symname == "fp_text" ) - result = result && parseText( child ); + result = parseText( child ); else if( symname == "fp_arc" ) - result = result && parseCurve( child, CURVE_ARC ); + result = parseCurve( child, CURVE_ARC ); else if( symname == "fp_line" ) - result = result && parseCurve( child, CURVE_LINE ); + result = parseCurve( child, CURVE_LINE ); else if( symname == "fp_circle" ) - result = result && parseCurve( child, CURVE_CIRCLE ); + result = parseCurve( child, CURVE_CIRCLE ); else if( symname == "fp_rect" ) - result = result && parseRect( child ); + result = parseRect( child ); else if( symname == "fp_curve" ) - result = result && parseCurve( child, CURVE_BEZIER ); + result = parseCurve( child, CURVE_BEZIER ); else if( symname == "pad" ) - result = result && parsePad( child ); + result = parsePad( child ); else if( symname == "model" ) - result = result && parseModel( child ); + result = parseModel( child ); } return result; @@ -386,7 +386,7 @@ bool KICADFOOTPRINT::ComposePCB( class PCBMODEL* aPCB, S3D_RESOLVER* resolver, } - for( auto i : m_pads ) + for( KICADPAD* i : m_pads ) { if( !i->IsThruHole() ) continue; @@ -415,22 +415,25 @@ bool KICADFOOTPRINT::ComposePCB( class PCBMODEL* aPCB, S3D_RESOLVER* resolver, DOUBLET newpos( posX, posY ); - for( auto i : m_models ) + for( KICADMODEL* i : m_models ) { - std::string fname( resolver->ResolvePath( - wxString::FromUTF8Unchecked( i->m_modelname.c_str() ) ).ToUTF8() ); + wxString mname = wxString::FromUTF8Unchecked( i->m_modelname.c_str() ); + std::string fname( resolver->ResolvePath( mname ).ToUTF8() ); try { if( aPCB->AddComponent( fname, m_refdes, LAYER_BOTTOM == m_side ? true : false, newpos, m_rotation, i->m_offset, i->m_rotation, i->m_scale, aSubstituteModels ) ) + { hasdata = true; + } } catch( const Standard_Failure& e) { - ReportMessage( wxString::Format( "could not add component %s\n>>Opencascade " - "error: %s\n ", - m_refdes, e.GetMessageString() ) ); + ReportMessage( wxString::Format( "could not add component %s\n" + "Open CASCADE error: %s\n ", + m_refdes, + e.GetMessageString() ) ); } } diff --git a/utils/kicad2step/pcb/oce_utils.cpp b/utils/kicad2step/pcb/oce_utils.cpp index 85bc6e12ba..7d06f44903 100644 --- a/utils/kicad2step/pcb/oce_utils.cpp +++ b/utils/kicad2step/pcb/oce_utils.cpp @@ -330,11 +330,9 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve ) if( rad < m_minDistance2 ) { - wxString msg; - msg.Printf( " * AddOutlineSegment() rejected an arc with equivalent end " - "points, %s\n", - aCurve->Describe() ); - ReportMessage( msg ); + ReportMessage( wxString::Format( " * AddOutlineSegment() rejected an arc with " + "equivalent end points, %s\n", + aCurve->Describe() ) ); return false; } } @@ -1240,14 +1238,14 @@ bool PCBMODEL::getModelLocation( bool aBottom, DOUBLET aPosition, double aRotati lPos.Multiply( lOff ); gp_Trsf lOrient; - lOrient.SetRotation( gp_Ax1( gp_Pnt( 0.0, 0.0, 0.0 ), - gp_Dir( 0.0, 0.0, 1.0 ) ), -aOrientation.z ); + lOrient.SetRotation( gp_Ax1( gp_Pnt( 0.0, 0.0, 0.0 ), gp_Dir( 0.0, 0.0, 1.0 ) ), + -aOrientation.z ); lPos.Multiply( lOrient ); - lOrient.SetRotation( gp_Ax1( gp_Pnt( 0.0, 0.0, 0.0 ), - gp_Dir( 0.0, 1.0, 0.0 ) ), -aOrientation.y ); + lOrient.SetRotation( gp_Ax1( gp_Pnt( 0.0, 0.0, 0.0 ), gp_Dir( 0.0, 1.0, 0.0 ) ), + -aOrientation.y ); lPos.Multiply( lOrient ); - lOrient.SetRotation( gp_Ax1( gp_Pnt( 0.0, 0.0, 0.0 ), - gp_Dir( 1.0, 0.0, 0.0 ) ), -aOrientation.x ); + lOrient.SetRotation( gp_Ax1( gp_Pnt( 0.0, 0.0, 0.0 ), gp_Dir( 1.0, 0.0, 0.0 ) ), + -aOrientation.x ); lPos.Multiply( lOrient ); aLocation = TopLoc_Location( lPos ); @@ -1409,7 +1407,6 @@ TDF_Label PCBMODEL::transferModel( Handle( TDocStd_Document )& source, || scolor->GetColor( stop.Current(), XCAFDoc_ColorGen, face_color ) || scolor->GetColor( stop.Current(), XCAFDoc_ColorCurv, face_color ) ) { - dcolor->SetColor( dtop.Current(), face_color, XCAFDoc_ColorSurf ); } @@ -1575,7 +1572,7 @@ bool OUTLINE::MakeShape( TopoDS_Shape& aShape, double aThickness ) DOUBLET lastPoint; getCurveEndPoint( m_curves.back(), lastPoint ); - for( auto i : m_curves ) + for( KICADCURVE& i : m_curves ) { bool success = false; @@ -1591,9 +1588,11 @@ bool OUTLINE::MakeShape( TopoDS_Shape& aShape, double aThickness ) if( !success ) { - ReportMessage( wxString::Format( - "failed to add an edge:\n%s\nlast valid outline point: %f %f\n", - i.Describe().c_str(), lastPoint.x, lastPoint.y ) ); + ReportMessage( wxString::Format( "failed to add edge: %s\n" + "last valid outline point: %f %f\n", + i.Describe().c_str(), + lastPoint.x, + lastPoint.y ) ); return false; } } @@ -1649,6 +1648,7 @@ bool OUTLINE::addEdge( BRepBuilderAPI_MakeWire* aWire, KICADCURVE& aCurve, DOUBL { TColgp_Array1OfPnt poles( 0, 3 ); gp_Pnt pt = gp_Pnt( aCurve.m_start.x, aCurve.m_start.y, 0.0 ); + poles( 0 ) = pt; pt = gp_Pnt( aCurve.m_bezierctrl1.x, aCurve.m_bezierctrl1.y, 0.0 ); poles( 1 ) = pt; @@ -1687,6 +1687,7 @@ bool OUTLINE::testClosed( const KICADCURVE& aFrontCurve, const KICADCURVE& aBack { double spx0, spy0, epx0, epy0; getEndPoints( aFrontCurve, spx0, spy0, epx0, epy0 ); + double spx1, spy1, epx1, epy1; getEndPoints( aBackCurve, spx1, spy1, epx1, epy1 );