KiCad2Step source code cleaning.

This commit is contained in:
Wayne Stambaugh 2022-07-06 17:32:52 -04:00
parent c12a723d41
commit a830261973
8 changed files with 173 additions and 170 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of kicad2mcad
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2016-2022 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
@ -58,8 +58,11 @@ protected:
virtual void OnOKButtonClick( wxCommandEvent& aEvent ) override;
};
// Horrible hack until we decouple things more
static PANEL_KICAD2STEP* openPanel = nullptr;
void ReportMessage( const wxString& aMessage )
{
if( openPanel != nullptr )
@ -75,33 +78,35 @@ protected:
const Message_Gravity theGravity,
const Standard_Boolean theToPutEol ) const override
{
Send (TCollection_AsciiString (theString), theGravity, theToPutEol);
Send( TCollection_AsciiString( theString ), theGravity, theToPutEol );
}
virtual void Send( const TCollection_AsciiString& theString,
const Message_Gravity theGravity,
const Standard_Boolean theToPutEol) const override
virtual void Send( const TCollection_AsciiString& theString,
const Message_Gravity theGravity,
const Standard_Boolean theToPutEol ) const override
#else
virtual void send( const TCollection_AsciiString& theString,
const Message_Gravity theGravity ) const override
virtual void send( const TCollection_AsciiString& theString,
const Message_Gravity theGravity ) const override
#endif
{
{
if( theGravity >= Message_Info )
{
ReportMessage( theString.ToCString() );
ReportMessage( theString.ToCString() );
#if OCC_VERSION_HEX < OCC_VERSION_MIN
if( theToPutEol )
ReportMessage( wxT( "\n" ) );
ReportMessage( wxT( "\n" ) );
#else
ReportMessage( wxT( "\n" ) );
#endif
}
if( theGravity >= Message_Alarm )
openPanel->m_error = true;
if( theGravity == Message_Fail )
openPanel->m_fail = true;
}
}
};
KICAD2MCAD_PRMS::KICAD2MCAD_PRMS()
@ -122,7 +127,7 @@ KICAD2MCAD_PRMS::KICAD2MCAD_PRMS()
KICAD2STEP_FRAME::KICAD2STEP_FRAME( const wxString& title ) :
KICAD2STEP_FRAME_BASE( NULL, wxID_ANY, title )
KICAD2STEP_FRAME_BASE( nullptr, wxID_ANY, title )
{
}
@ -177,8 +182,7 @@ int PANEL_KICAD2STEP::RunConverter()
{
out_fname.Assign( m_params.m_outputFile );
// Set the file extension if the user's requested
// file name does not have an extension.
// Set the file extension if the user's requested file name does not have an extension.
if( !out_fname.HasExt() )
out_fname.SetExt( m_params.getOutputExt() );
}
@ -198,7 +202,6 @@ int PANEL_KICAD2STEP::RunConverter()
pcb.SetMinDistance( m_params.m_minDistance );
ReportMessage( wxString::Format( _( "Read file: '%s'\n" ), m_params.m_filename ) );
Message::DefaultMessenger()->RemovePrinters( STANDARD_TYPE( Message_PrinterOStream ) );
Message::DefaultMessenger()->AddPrinter( new KiCadPrinter );
@ -273,7 +276,6 @@ int PANEL_KICAD2STEP::RunConverter()
msg = _( "STEP file has been created, but there are warnings." );
}
ReportMessage( msg );
return 0;

View File

@ -2,7 +2,7 @@
* This program source code file is part of kicad2mcad
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2016-2022 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
@ -40,6 +40,7 @@
#define REGEX_DELIMITER "(?:[\\s]*x)"
#define REGEX_UNIT "([m]{2}|(?:in))"
class KICAD2MCAD_APP : public wxApp
{
public:
@ -161,7 +162,8 @@ bool KICAD2MCAD_APP::OnCmdLineParsed( wxCmdLineParser& parser )
if( tunit.size() > 0 ) // No unit accepted ( default = mm )
{
if( ( !sm.str( 1 ).compare( " " ) || !sm.str( 2 ).compare( " " ) ) || ( sm.size() != 4 ) )
if( ( !sm.str( 1 ).compare( " " ) || !sm.str( 2 ).compare( " " ) ) ||
( sm.size() != 4 ) )
{
parser.Usage();
return false;
@ -213,7 +215,6 @@ bool KICAD2MCAD_APP::OnCmdLineParsed( wxCmdLineParser& parser )
if( parser.Found( wxT( "o" ), &tstr ) )
m_params.m_outputFile = tstr;
if( parser.GetParamCount() < 1 )
{
parser.Usage();

View File

@ -2,7 +2,7 @@
* This program source code file is part kicad2mcad
*
* Copyright (C) 2015-2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2020-2022 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
@ -325,7 +325,7 @@ bool S3D_RESOLVER::addPath( const SEARCH_PATH& aPath )
#ifdef _WIN32
while( tpath.m_Pathexp.EndsWith( wxT( "\\" ) ) )
tpath.m_Pathexp.erase( tpath.m_Pathexp.length() - 1 );
tpath.m_Pathexp.erase( tpath.m_Pathexp.length() - 1 );
#else
while( tpath.m_Pathexp.EndsWith( wxT( "/" ) ) && tpath.m_Pathexp.length() > 1 )
tpath.m_Pathexp.erase( tpath.m_Pathexp.length() - 1 );
@ -566,7 +566,7 @@ wxString S3D_RESOLVER::ShortenPath( const wxString& aFullPathName )
idx = fname.find( fps );
if( std::string::npos != idx && 0 == idx )
if( std::string::npos != idx && 0 == idx )
{
fname = fname.substr( fps.size() );
@ -609,7 +609,6 @@ wxString S3D_RESOLVER::ShortenPath( const wxString& aFullPathName )
}
const std::list< SEARCH_PATH >* S3D_RESOLVER::GetPaths( void )
{
return &m_Paths;
@ -691,7 +690,7 @@ static bool getHollerith( const std::string& aString, size_t& aIndex, wxString&
size_t nchars;
istr >> nchars;
if( (i2 + nchars) >= aString.size() )
if( ( i2 + nchars ) >= aString.size() )
{
wxLogTrace( trace3dResolver, wxT( "%s:%s:%d\n * unexpected end of line in line '%s'" ),
__FILE__, __FUNCTION__, __LINE__, aString );

View File

@ -32,6 +32,8 @@
#include <iostream>
#include <sstream>
#include <../../../libs/kimath/include/geometry/shape_arc.h>
#include <sexpr/sexpr_parser.h>
#include <geometry/shape_line_chain.h>
KICADCURVE::KICADCURVE()
@ -53,8 +55,6 @@ KICADCURVE::~KICADCURVE()
return;
}
#include <sexpr/sexpr_parser.h>
#include <geometry/shape_line_chain.h>
bool KICADCURVE::Read( SEXPR::SEXPR* aEntry, CURVE_TYPE aCurveType )
{
@ -112,7 +112,7 @@ bool KICADCURVE::Read( SEXPR::SEXPR* aEntry, CURVE_TYPE aCurveType )
SEXPR::SEXPR* sub_child = ( *list )[ii];
text = sub_child->GetChild( 0 )->GetSymbol();
// inside pts list, parmeters are xy point coord
// inside pts list, parameters are xy point coord
// or a arc (start, middle, end) points
if( text == "xy" )
{
@ -125,16 +125,18 @@ bool KICADCURVE::Read( SEXPR::SEXPR* aEntry, CURVE_TYPE aCurveType )
{
switch( ii )
{
case 1: m_start = coord; break;
case 1: m_start = coord; break;
case 2: m_bezierctrl1 = coord; break;
case 3: m_bezierctrl2 = coord; break;
case 4: m_end = coord; break;
case 4: m_end = coord; break;
default:
break;
}
}
else
{
m_poly.push_back( coord );
}
}
else if( text == "arc" )
{
@ -164,7 +166,7 @@ bool KICADCURVE::Read( SEXPR::SEXPR* aEntry, CURVE_TYPE aCurveType )
}
// To convert arc edge to segments, we are using SHAPE_ARC, but SHAPE_ARC use
// integer coords. So to avoid truncations, use a scaling factor.
// integer coords. So to avoid truncation, use a scaling factor.
// 1e5 is enough.
const double scale = 1e5;
SHAPE_ARC new_arc( VECTOR2I( arc_start.x*scale, arc_start.y*scale ),
@ -176,8 +178,8 @@ bool KICADCURVE::Read( SEXPR::SEXPR* aEntry, CURVE_TYPE aCurveType )
// Add segments to STEP polygon
for( int ll = 0; ll < segs_from_arc.PointCount(); ll++ )
m_poly.emplace_back( segs_from_arc.CPoint(ll).x/scale,
segs_from_arc.CPoint(ll).y/scale );
m_poly.emplace_back( segs_from_arc.CPoint( ll ).x / scale,
segs_from_arc.CPoint( ll ).y / scale );
}
}
}
@ -237,8 +239,8 @@ bool KICADCURVE::Read( SEXPR::SEXPR* aEntry, CURVE_TYPE aCurveType )
// So convert new params to old params
if( CURVE_ARC == aCurveType && m_arcHasMiddlePoint )
{
// To caculate old params, we are using SHAPE_ARC, but SHAPE_ARC use
// integer coords. So to avoid truncations, use a scaling factor.
// To calculate old params, we are using SHAPE_ARC, but SHAPE_ARC use
// integer coords. So to avoid truncation, use a scaling factor.
// 1e5 is enough.
const double scale = 1e5;
SHAPE_ARC new_arc( VECTOR2I( m_start.x*scale, m_start.y*scale ),
@ -248,10 +250,10 @@ bool KICADCURVE::Read( SEXPR::SEXPR* aEntry, CURVE_TYPE aCurveType )
VECTOR2I center = new_arc.GetCenter();
m_start.x = center.x/scale;
m_start.y = center.y/scale;
m_end.x = new_arc.GetP0().x/scale;
m_end.y = new_arc.GetP0().y/scale;
m_ep.x = new_arc.GetP1().x/scale;
m_ep.y = new_arc.GetP1().y/scale;
m_end.x = new_arc.GetP0().x / scale;
m_end.y = new_arc.GetP0().y / scale;
m_ep.x = new_arc.GetP1().x / scale;
m_ep.y = new_arc.GetP1().y / scale;
m_angle = new_arc.GetCentralAngle().AsRadians();
}
@ -265,28 +267,28 @@ std::string KICADCURVE::Describe() const
switch( m_form )
{
case CURVE_LINE:
desc << "line start: " << m_start << " end: " << m_end;
break;
case CURVE_LINE:
desc << "line start: " << m_start << " end: " << m_end;
break;
case CURVE_ARC:
desc << "arc center: " << m_start << " radius: " << m_radius
<< " angle: " << 180.0 * m_angle / M_PI
<< " arc start: " << m_end << " arc end: " << m_ep;
break;
case CURVE_ARC:
desc << "arc center: " << m_start << " radius: " << m_radius
<< " angle: " << 180.0 * m_angle / M_PI
<< " arc start: " << m_end << " arc end: " << m_ep;
break;
case CURVE_CIRCLE:
desc << "circle center: " << m_start << " radius: " << m_radius;
break;
case CURVE_CIRCLE:
desc << "circle center: " << m_start << " radius: " << m_radius;
break;
case CURVE_BEZIER:
desc << "bezier start: " << m_start << " end: " << m_end
<< " ctrl1: " << m_bezierctrl1 << " ctrl2: " << m_bezierctrl2 ;
break;
case CURVE_BEZIER:
desc << "bezier start: " << m_start << " end: " << m_end
<< " ctrl1: " << m_bezierctrl1 << " ctrl2: " << m_bezierctrl2 ;
break;
default:
desc << "<invalid curve type>";
break;
default:
desc << "<invalid curve type>";
break;
}
return desc.str();

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2016-2022 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
@ -89,10 +89,7 @@ bool KICADMODEL::Read( SEXPR::SEXPR* aEntry )
std::string name = child->GetChild( 0 )->GetSymbol();
bool ret = true;
/*
* Version 4.x and prior used 'at' parameter,
* which was specified in inches.
*/
// Version 4.x and prior used 'at' parameter, which was specified in inches.
if( name == "at" )
{
ret = Get3DCoordinate( child->GetChild( 1 ), m_offset );
@ -104,12 +101,9 @@ bool KICADMODEL::Read( SEXPR::SEXPR* aEntry )
m_offset.z *= 25.4f;
}
}
/*
* From 5.x onwards, 3D model is provided in 'offset',
* which is in millimetres
*/
else if( name == "offset" )
{
// From 5.x onwards, 3D model is provided in 'offset', which is in millimetres.
ret = Get3DCoordinate( child->GetChild( 1 ), m_offset );
}
else if( name == "scale" )

View File

@ -150,7 +150,7 @@ bool KICADPCB::WriteIGES( const wxString& aFileName )
bool KICADPCB::parsePCB( SEXPR::SEXPR* data )
{
if( NULL == data )
if( nullptr == data )
return false;
if( data->IsList() )
@ -209,7 +209,7 @@ bool KICADPCB::parsePCB( SEXPR::SEXPR* data )
bool KICADPCB::parseGeneral( SEXPR::SEXPR* data )
{
size_t nc = data->GetNumberOfChildren();
SEXPR::SEXPR* child = NULL;
SEXPR::SEXPR* child = nullptr;
for( size_t i = 1; i < nc; ++i )
{
@ -240,7 +240,7 @@ bool KICADPCB::parseGeneral( SEXPR::SEXPR* data )
bool KICADPCB::parseLayers( SEXPR::SEXPR* data )
{
size_t nc = data->GetNumberOfChildren();
SEXPR::SEXPR* child = NULL;
SEXPR::SEXPR* child = nullptr;
// Read the layername and the corresponding layer id list:
for( size_t i = 1; i < nc; ++i )
@ -273,7 +273,7 @@ bool KICADPCB::parseStackupLayer( SEXPR::SEXPR* data )
if( data->IsList() && data->GetNumberOfChildren() >= 3 )
{
size_t nc = data->GetNumberOfChildren();
SEXPR::SEXPR* child = NULL;
SEXPR::SEXPR* child = nullptr;
std::string ref;
std::string value;
@ -353,7 +353,7 @@ bool KICADPCB::parseStackupLayer( SEXPR::SEXPR* data )
bool KICADPCB::parseStackup( SEXPR::SEXPR* data )
{
size_t nc = data->GetNumberOfChildren();
SEXPR::SEXPR* child = NULL;
SEXPR::SEXPR* child = nullptr;
for( size_t i = 1; i < nc; ++i )
{
@ -423,7 +423,7 @@ int KICADPCB::GetLayerId( std::string& aLayerName )
bool KICADPCB::parseSetup( SEXPR::SEXPR* data )
{
size_t nc = data->GetNumberOfChildren();
SEXPR::SEXPR* child = NULL;
SEXPR::SEXPR* child = nullptr;
for( size_t i = 1; i < nc; ++i )
{
@ -632,6 +632,7 @@ bool KICADPCB::ComposePCB( bool aComposeVirtual, bool aSubstituteModels )
lcurve.m_end.y = -( lcurve.m_end.y - origin.y );
lcurve.m_start.x -= origin.x;
lcurve.m_end.x -= origin.x;
// used in bezier curves:
lcurve.m_bezierctrl1.y = -( lcurve.m_bezierctrl1.y - origin.y );
lcurve.m_bezierctrl1.x -= origin.x;
@ -653,7 +654,7 @@ bool KICADPCB::ComposePCB( bool aComposeVirtual, bool aSubstituteModels )
{
ReportMessage( wxT( "could not create PCB solid model\n" ) );
delete m_pcb_model;
m_pcb_model = NULL;
m_pcb_model = nullptr;
return false;
}

View File

@ -272,7 +272,7 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve )
if( NULL == aCurve || LAYER_EDGE != aCurve->m_layer || CURVE_NONE == aCurve->m_form )
return false;
if( CURVE_LINE == aCurve->m_form || CURVE_BEZIER == aCurve->m_form )
if( CURVE_LINE == aCurve->m_form || CURVE_BEZIER == aCurve->m_form )
{
// reject zero - length lines
double dx = aCurve->m_end.x - aCurve->m_start.x;
@ -364,74 +364,71 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve )
break;
case CURVE_CIRCLE:
do
{
double dx = aCurve->m_start.x - aCurve->m_radius;
{
double dx = aCurve->m_start.x - aCurve->m_radius;
if( dx < m_minx )
{
m_minx = dx;
m_mincurve = --( m_curves.end() );
}
} while( 0 );
if( dx < m_minx )
{
m_minx = dx;
m_mincurve = --( m_curves.end() );
}
break;
}
case CURVE_ARC:
do
{
double dx0 = aCurve->m_end.x - aCurve->m_start.x;
double dy0 = aCurve->m_end.y - aCurve->m_start.y;
int q0; // quadrant of start point
if( dx0 > 0.0 && dy0 >= 0.0 )
q0 = 1;
else if( dx0 <= 0.0 && dy0 > 0.0 )
q0 = 2;
else if( dx0 < 0.0 && dy0 <= 0.0 )
q0 = 3;
else
q0 = 4;
double dx1 = aCurve->m_ep.x - aCurve->m_start.x;
double dy1 = aCurve->m_ep.y - aCurve->m_start.y;
int q1; // quadrant of end point
if( dx1 > 0.0 && dy1 >= 0.0 )
q1 = 1;
else if( dx1 <= 0.0 && dy1 > 0.0 )
q1 = 2;
else if( dx1 < 0.0 && dy1 <= 0.0 )
q1 = 3;
else
q1 = 4;
// calculate x0, y0 for the start point on a CCW arc
double x0 = aCurve->m_end.x;
double x1 = aCurve->m_ep.x;
if( aCurve->m_angle < 0.0 )
{
double dx0 = aCurve->m_end.x - aCurve->m_start.x;
double dy0 = aCurve->m_end.y - aCurve->m_start.y;
int q0; // quadrant of start point
std::swap( q0, q1 );
std::swap( x0, x1 );
}
if( dx0 > 0.0 && dy0 >= 0.0 )
q0 = 1;
else if( dx0 <= 0.0 && dy0 > 0.0 )
q0 = 2;
else if( dx0 < 0.0 && dy0 <= 0.0 )
q0 = 3;
else
q0 = 4;
double minx;
double dx1 = aCurve->m_ep.x - aCurve->m_start.x;
double dy1 = aCurve->m_ep.y - aCurve->m_start.y;
int q1; // quadrant of end point
if( ( q0 <= 2 && q1 >= 3 ) || ( q0 >= 3 && x0 > x1 ) )
minx = aCurve->m_start.x - aCurve->m_radius;
else
minx = std::min( x0, x1 );
if( dx1 > 0.0 && dy1 >= 0.0 )
q1 = 1;
else if( dx1 <= 0.0 && dy1 > 0.0 )
q1 = 2;
else if( dx1 < 0.0 && dy1 <= 0.0 )
q1 = 3;
else
q1 = 4;
// calculate x0, y0 for the start point on a CCW arc
double x0 = aCurve->m_end.x;
double x1 = aCurve->m_ep.x;
if( aCurve->m_angle < 0.0 )
{
std::swap( q0, q1 );
std::swap( x0, x1 );
}
double minx;
if( ( q0 <= 2 && q1 >= 3 ) || ( q0 >= 3 && x0 > x1 ) )
minx = aCurve->m_start.x - aCurve->m_radius;
else
minx = std::min( x0, x1 );
if( minx < m_minx )
{
m_minx = minx;
m_mincurve = --( m_curves.end() );
}
} while( 0 );
if( minx < m_minx )
{
m_minx = minx;
m_mincurve = --( m_curves.end() );
}
break;
}
case CURVE_BEZIER:
if( aCurve->m_start.x < m_minx )
@ -448,15 +445,13 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve )
break;
default:
// unexpected curve type
do
{
wxString msg;
msg.Printf( wxT( " * AddOutlineSegment() unsupported curve type: %d\n" ),
aCurve->m_form );
ReportMessage( msg );
} while( 0 );
default: // unexpected curve type
{
wxString msg;
msg.Printf( wxT( " * AddOutlineSegment() unsupported curve type: %d\n" ),
aCurve->m_form );
ReportMessage( msg );
}
return false;
}
@ -841,7 +836,9 @@ bool PCBMODEL::CreatePCB()
char_count++;
if( char_count < 80 )
{
ReportMessage( wxT( "." ) );
}
else
{
char_count = 0;
@ -876,16 +873,18 @@ bool PCBMODEL::CreatePCB()
if( m_pcb_label.IsNull() )
return false;
// AddComponent adds a label that has a reference (not a parent/child relation) to the real label
// We need to extract that real label to name it for the STEP output cleanly
// AddComponent adds a label that has a reference (not a parent/child relation) to the real
// label. We need to extract that real label to name it for the STEP output cleanly
// Why are we trying to name the bare board? Because CAD tools like SolidWorks do fun things
// like "deduplicate" imported STEPs by swapping STEP assembly components with already identically named assemblies
// So we want to avoid having the PCB be generally defaulted to "Component" or "Assembly".
// like "deduplicate" imported STEPs by swapping STEP assembly components with already
// identically named assemblies. So we want to avoid having the PCB be generally defaulted
// to "Component" or "Assembly".
Handle( TDataStd_TreeNode ) node;
if( m_pcb_label.FindAttribute( XCAFDoc::ShapeRefGUID(), node ) )
{
TDF_Label label = node->Father()->Label();
if( !label.IsNull() )
{
wxString pcbName = wxString::Format( wxT( "%s PCB" ), m_pcbName );
@ -895,7 +894,6 @@ bool PCBMODEL::CreatePCB()
}
}
// color the PCB
Handle( XCAFDoc_ColorTool ) colorTool = XCAFDoc_DocumentTool::ColorTool( m_doc->Main () );
Quantity_Color color( m_boardColor[0], m_boardColor[1], m_boardColor[2], Quantity_TOC_RGB );
@ -914,6 +912,7 @@ bool PCBMODEL::CreatePCB()
#if ( defined OCC_VERSION_HEX ) && ( OCC_VERSION_HEX > 0x070101 )
m_assy->UpdateAssemblies();
#endif
return true;
}
@ -938,8 +937,10 @@ bool PCBMODEL::WriteIGES( const wxString& aFileName )
IGESData_GlobalSection header = writer.Model()->GlobalSection();
header.SetFileName( new TCollection_HAsciiString( fn.GetFullName().ToAscii() ) );
header.SetSendName( new TCollection_HAsciiString( "KiCad electronic assembly" ) );
header.SetAuthorName( new TCollection_HAsciiString( Interface_Static::CVal( "write.iges.header.author" ) ) );
header.SetCompanyName( new TCollection_HAsciiString( Interface_Static::CVal( "write.iges.header.company" ) ) );
header.SetAuthorName(
new TCollection_HAsciiString( Interface_Static::CVal( "write.iges.header.author" ) ) );
header.SetCompanyName(
new TCollection_HAsciiString( Interface_Static::CVal( "write.iges.header.company" ) ) );
writer.Model()->SetGlobalSection( header );
if( Standard_False == writer.Perform( m_doc, aFileName.c_str() ) )
@ -959,6 +960,7 @@ bool PCBMODEL::WriteSTEP( const wxString& aFileName )
aFileName ) );
return false;
}
wxFileName fn( aFileName );
STEPCAFControl_Writer writer;
@ -1314,11 +1316,11 @@ bool PCBMODEL::readIGES( Handle( TDocStd_Document )& doc, const char* fname )
return false;
// set other translation options
reader.SetColorMode(true); // use model colors
reader.SetNameMode(false); // don't use IGES label names
reader.SetLayerMode(false); // ignore LAYER data
reader.SetColorMode( true ); // use model colors
reader.SetNameMode( false ); // don't use IGES label names
reader.SetLayerMode( false ); // ignore LAYER data
if ( !reader.Transfer( doc ) )
if( !reader.Transfer( doc ) )
{
doc->Close();
return false;
@ -1335,7 +1337,7 @@ bool PCBMODEL::readIGES( Handle( TDocStd_Document )& doc, const char* fname )
}
bool PCBMODEL::readSTEP( Handle(TDocStd_Document)& doc, const char* fname )
bool PCBMODEL::readSTEP( Handle( TDocStd_Document )& doc, const char* fname )
{
STEPCAFControl_Reader reader;
IFSelect_ReturnStatus stat = reader.ReadFile( fname );
@ -1352,11 +1354,11 @@ bool PCBMODEL::readSTEP( Handle(TDocStd_Document)& doc, const char* fname )
return false;
// set other translation options
reader.SetColorMode(true); // use model colors
reader.SetNameMode(false); // don't use label names
reader.SetLayerMode(false); // ignore LAYER data
reader.SetColorMode( true ); // use model colors
reader.SetNameMode( false ); // don't use label names
reader.SetLayerMode( false ); // ignore LAYER data
if ( !reader.Transfer( doc ) )
if( !reader.Transfer( doc ) )
{
doc->Close();
return false;
@ -1385,14 +1387,14 @@ TDF_Label PCBMODEL::transferModel( Handle( TDocStd_Document )& source,
BRepBuilderAPI_GTransform brep( scale_transform );
// s_assy = shape tool for the source
Handle(XCAFDoc_ShapeTool) s_assy = XCAFDoc_DocumentTool::ShapeTool ( source->Main() );
Handle(XCAFDoc_ShapeTool) s_assy = XCAFDoc_DocumentTool::ShapeTool( source->Main() );
// retrieve all free shapes within the assembly
TDF_LabelSequence frshapes;
s_assy->GetFreeShapes( frshapes );
// d_assy = shape tool for the destination
Handle(XCAFDoc_ShapeTool) d_assy = XCAFDoc_DocumentTool::ShapeTool ( dest->Main() );
Handle( XCAFDoc_ShapeTool ) d_assy = XCAFDoc_DocumentTool::ShapeTool ( dest->Main() );
// create a new shape within the destination and set the assembly tool to point to it
TDF_Label component = d_assy->NewShape();
@ -1406,14 +1408,14 @@ TDF_Label PCBMODEL::transferModel( Handle( TDocStd_Document )& source,
while( id <= nshapes )
{
TopoDS_Shape shape = s_assy->GetShape( frshapes.Value(id) );
TopoDS_Shape shape = s_assy->GetShape( frshapes.Value( id ) );
if ( !shape.IsNull() )
if( !shape.IsNull() )
{
brep.Perform( shape, Standard_False );
TopoDS_Shape scaled_shape;
if ( brep.IsDone() )
if( brep.IsDone() )
{
scaled_shape = brep.Shape();
}
@ -1446,9 +1448,9 @@ TDF_Label PCBMODEL::transferModel( Handle( TDocStd_Document )& source,
dcolor->SetColor( dtop.Current(), face_color, XCAFDoc_ColorSurf );
}
}
else if( scolor->GetColor( stop.Current(), XCAFDoc_ColorSurf, face_color )
|| scolor->GetColor( stop.Current(), XCAFDoc_ColorGen, face_color )
|| scolor->GetColor( stop.Current(), XCAFDoc_ColorCurv, face_color ) )
else if( scolor->GetColor( stop.Current(), XCAFDoc_ColorSurf, face_color )
|| scolor->GetColor( stop.Current(), XCAFDoc_ColorGen, face_color )
|| scolor->GetColor( stop.Current(), XCAFDoc_ColorCurv, face_color ) )
{
dcolor->SetColor( dtop.Current(), face_color, XCAFDoc_ColorSurf );
}
@ -1477,9 +1479,9 @@ TDF_Label PCBMODEL::transferModel( Handle( TDocStd_Document )& source,
dcolor->SetColor( dtop.Current(), face_color, XCAFDoc_ColorGen );
}
}
else if( scolor->GetColor( stop.Current(), XCAFDoc_ColorSurf, face_color )
|| scolor->GetColor( stop.Current(), XCAFDoc_ColorGen, face_color )
|| scolor->GetColor( stop.Current(), XCAFDoc_ColorCurv, face_color ) )
else if( scolor->GetColor( stop.Current(), XCAFDoc_ColorSurf, face_color )
|| scolor->GetColor( stop.Current(), XCAFDoc_ColorGen, face_color )
|| scolor->GetColor( stop.Current(), XCAFDoc_ColorCurv, face_color ) )
{
dcolor->SetColor( dtop.Current(), face_color, XCAFDoc_ColorSurf );
}

View File

@ -97,9 +97,9 @@ public:
// add a component at the given position and orientation
bool AddComponent( const std::string& aFileName, const std::string& aRefDes,
bool aBottom, DOUBLET aPosition, double aRotation,
TRIPLET aOffset, TRIPLET aOrientation, TRIPLET aScale,
bool aSubstituteModels = true );
bool aBottom, DOUBLET aPosition, double aRotation,
TRIPLET aOffset, TRIPLET aOrientation, TRIPLET aScale,
bool aSubstituteModels = true );
void SetBoardColor( double r, double g, double b );
@ -167,7 +167,9 @@ private:
std::list<KICADCURVE> m_curves;
std::vector<TopoDS_Shape> m_cutouts;
wxString m_pcbName; // name of the PCB, which will most likely be the file name of the path
/// Name of the PCB, which will most likely be the file name of the path.
wxString m_pcbName;
};
#endif // OCE_VIS_OCE_UTILS_H