Kicad2step: Many fixes in oce_utils.
- Better code and messages. - Speedup calculations when removing cutouts and holes from main board. - Do not stop step generation when trying to load a 3D modele having issues.
This commit is contained in:
parent
b68bdc22d7
commit
5143f87678
|
@ -36,7 +36,6 @@
|
|||
#include <widgets/text_ctrl_eval.h>
|
||||
#include <wx_html_report_panel.h>
|
||||
|
||||
#define OPTKEY_STEP_OVERWRITE "STEP_Overwrite"
|
||||
|
||||
class DIALOG_EXPORT_STEP: public DIALOG_EXPORT_STEP_BASE
|
||||
{
|
||||
|
@ -55,7 +54,7 @@ private:
|
|||
// The last preference for STEP Origin:
|
||||
STEP_ORG_OPT m_STEP_org_opt;
|
||||
bool m_noVirtual; // remember last preference for No Virtual Component
|
||||
bool m_overwriteFile; // remember last preference for overwrite file
|
||||
static bool m_overwriteFile; // remember last preference for overwrite file
|
||||
int m_OrgUnits; // remember last units for User Origin
|
||||
double m_XOrg; // remember last User Origin X value
|
||||
double m_YOrg; // remember last User Origin Y value
|
||||
|
@ -118,6 +117,8 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
bool DIALOG_EXPORT_STEP::m_overwriteFile = false;
|
||||
|
||||
|
||||
DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString& aBoardPath ) :
|
||||
DIALOG_EXPORT_STEP_BASE( aParent )
|
||||
|
@ -161,7 +162,6 @@ DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP( PCB_EDIT_FRAME* aParent, const wxString&
|
|||
m_noVirtual = cfg->m_ExportStep.no_virtual;
|
||||
|
||||
m_cbRemoveVirtual->SetValue( m_noVirtual );
|
||||
m_config->Read( OPTKEY_STEP_OVERWRITE, &m_overwriteFile, false );
|
||||
m_cbOverwriteFile->SetValue( m_overwriteFile );
|
||||
|
||||
m_STEP_OrgUnitChoice->SetSelection( m_OrgUnits );
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "wx/wx.h"
|
||||
#include <wx/app.h>
|
||||
#include <wx/cmdline.h>
|
||||
|
@ -31,11 +30,11 @@
|
|||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <Standard_Failure.hxx> // In open cascade
|
||||
|
||||
#include "pcb/kicadpcb.h"
|
||||
#include "kicad2step_frame_base.h"
|
||||
#include "panel_kicad2step.h"
|
||||
#include <Standard_Failure.hxx> // In open cascade
|
||||
|
||||
class KICAD2STEP_FRAME;
|
||||
|
||||
|
@ -130,7 +129,7 @@ bool KICAD2MCAD_APP::OnInit()
|
|||
m_Panel = m_frame->m_panelKicad2Step;
|
||||
m_Panel->m_params = m_params;
|
||||
|
||||
// and show it (a wxRrame is not shown when created initially)
|
||||
// and show it (a wxFrame is not shown when created initially)
|
||||
m_frame->Show( true );
|
||||
m_frame->Iconize( false );
|
||||
|
||||
|
@ -142,6 +141,7 @@ int KICAD2MCAD_APP::OnRun()
|
|||
{
|
||||
int diag = m_Panel->RunConverter();
|
||||
wxApp::OnRun(); // Start the main loop event, to manage the main frame
|
||||
|
||||
return diag;
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ bool KICAD2MCAD_APP::OnCmdLineParsed( wxCmdLineParser& parser )
|
|||
class STREAMBUF_SWAPPER
|
||||
{
|
||||
public:
|
||||
STREAMBUF_SWAPPER( ostream & orig, ostream & replacement )
|
||||
STREAMBUF_SWAPPER( std::ostream & orig, std::ostream & replacement )
|
||||
: m_buf( orig.rdbuf() ), m_str( orig )
|
||||
{
|
||||
orig.rdbuf( replacement.rdbuf() );
|
||||
|
@ -368,8 +368,8 @@ int PANEL_KICAD2STEP::RunConverter()
|
|||
// msgs_from_opencascade and errors_from_opencascade
|
||||
std::ostringstream msgs_from_opencascade;
|
||||
std::ostringstream errors_from_opencascade;
|
||||
STREAMBUF_SWAPPER swapper_cout(cout, msgs_from_opencascade);
|
||||
STREAMBUF_SWAPPER swapper_cerr(cerr, errors_from_opencascade);
|
||||
STREAMBUF_SWAPPER swapper_cout(std::cout, msgs_from_opencascade);
|
||||
STREAMBUF_SWAPPER swapper_cerr(std::cerr, errors_from_opencascade);
|
||||
|
||||
if( pcb.ReadFile( m_params.m_filename ) )
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Jul 11 2018)
|
||||
// C++ code generated with wxFormBuilder (version Jul 10 2019)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -12,17 +12,17 @@
|
|||
KICAD2STEP_FRAME_BASE::KICAD2STEP_FRAME_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
|
||||
{
|
||||
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
|
||||
|
||||
|
||||
wxBoxSizer* bSizerMain;
|
||||
bSizerMain = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
|
||||
m_panelKicad2Step = new PANEL_KICAD2STEP( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
bSizerMain->Add( m_panelKicad2Step, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
|
||||
|
||||
this->SetSizer( bSizerMain );
|
||||
this->Layout();
|
||||
|
||||
|
||||
this->Centre( wxBOTH );
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<wxFormBuilder_Project>
|
||||
<FileVersion major="1" minor="14" />
|
||||
<FileVersion major="1" minor="15" />
|
||||
<object class="Project" expanded="1">
|
||||
<property name="class_decoration"></property>
|
||||
<property name="code_generation">C++</property>
|
||||
|
@ -14,6 +14,7 @@
|
|||
<property name="file">kicad2step_frame_base</property>
|
||||
<property name="first_id">1000</property>
|
||||
<property name="help_provider">none</property>
|
||||
<property name="image_path_wrapper_function_name"></property>
|
||||
<property name="indent_with_spaces"></property>
|
||||
<property name="internationalize">1</property>
|
||||
<property name="name">kicad2step_frame</property>
|
||||
|
@ -25,6 +26,7 @@
|
|||
<property name="skip_php_events">1</property>
|
||||
<property name="skip_python_events">1</property>
|
||||
<property name="ui_table">UI</property>
|
||||
<property name="use_array_enum">0</property>
|
||||
<property name="use_enum">0</property>
|
||||
<property name="use_microsoft_bom">0</property>
|
||||
<object class="Frame" expanded="1">
|
||||
|
@ -45,8 +47,8 @@
|
|||
<property name="minimum_size"></property>
|
||||
<property name="name">KICAD2STEP_FRAME_BASE</property>
|
||||
<property name="pos"></property>
|
||||
<property name="size">500,300</property>
|
||||
<property name="style">wxDEFAULT_FRAME_STYLE</property>
|
||||
<property name="size">644,300</property>
|
||||
<property name="style">wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER</property>
|
||||
<property name="subclass">; forward_declare; forward_declare</property>
|
||||
<property name="title">Kicad2step Converter</property>
|
||||
<property name="tooltip"></property>
|
||||
|
@ -54,54 +56,6 @@
|
|||
<property name="window_name"></property>
|
||||
<property name="window_style">wxTAB_TRAVERSAL</property>
|
||||
<property name="xrc_skip_sizer">1</property>
|
||||
<event name="OnActivate"></event>
|
||||
<event name="OnActivateApp"></event>
|
||||
<event name="OnAuiPaneActivated"></event>
|
||||
<event name="OnAuiPaneButton"></event>
|
||||
<event name="OnAuiPaneClose"></event>
|
||||
<event name="OnAuiPaneMaximize"></event>
|
||||
<event name="OnAuiPaneRestore"></event>
|
||||
<event name="OnAuiRender"></event>
|
||||
<event name="OnAux1DClick"></event>
|
||||
<event name="OnAux1Down"></event>
|
||||
<event name="OnAux1Up"></event>
|
||||
<event name="OnAux2DClick"></event>
|
||||
<event name="OnAux2Down"></event>
|
||||
<event name="OnAux2Up"></event>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnCharHook"></event>
|
||||
<event name="OnClose"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnHibernate"></event>
|
||||
<event name="OnIconize"></event>
|
||||
<event name="OnIdle"></event>
|
||||
<event name="OnKeyDown"></event>
|
||||
<event name="OnKeyUp"></event>
|
||||
<event name="OnKillFocus"></event>
|
||||
<event name="OnLeaveWindow"></event>
|
||||
<event name="OnLeftDClick"></event>
|
||||
<event name="OnLeftDown"></event>
|
||||
<event name="OnLeftUp"></event>
|
||||
<event name="OnMaximize"></event>
|
||||
<event name="OnMiddleDClick"></event>
|
||||
<event name="OnMiddleDown"></event>
|
||||
<event name="OnMiddleUp"></event>
|
||||
<event name="OnMotion"></event>
|
||||
<event name="OnMouseEvents"></event>
|
||||
<event name="OnMouseWheel"></event>
|
||||
<event name="OnMove"></event>
|
||||
<event name="OnMoveEnd"></event>
|
||||
<event name="OnMoveStart"></event>
|
||||
<event name="OnMoving"></event>
|
||||
<event name="OnPaint"></event>
|
||||
<event name="OnRightDClick"></event>
|
||||
<event name="OnRightDown"></event>
|
||||
<event name="OnRightUp"></event>
|
||||
<event name="OnSetFocus"></event>
|
||||
<event name="OnShow"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">bSizerMain</property>
|
||||
|
@ -162,36 +116,6 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style">wxTAB_TRAVERSAL</property>
|
||||
<event name="OnAux1DClick"></event>
|
||||
<event name="OnAux1Down"></event>
|
||||
<event name="OnAux1Up"></event>
|
||||
<event name="OnAux2DClick"></event>
|
||||
<event name="OnAux2Down"></event>
|
||||
<event name="OnAux2Up"></event>
|
||||
<event name="OnChar"></event>
|
||||
<event name="OnCharHook"></event>
|
||||
<event name="OnEnterWindow"></event>
|
||||
<event name="OnEraseBackground"></event>
|
||||
<event name="OnKeyDown"></event>
|
||||
<event name="OnKeyUp"></event>
|
||||
<event name="OnKillFocus"></event>
|
||||
<event name="OnLeaveWindow"></event>
|
||||
<event name="OnLeftDClick"></event>
|
||||
<event name="OnLeftDown"></event>
|
||||
<event name="OnLeftUp"></event>
|
||||
<event name="OnMiddleDClick"></event>
|
||||
<event name="OnMiddleDown"></event>
|
||||
<event name="OnMiddleUp"></event>
|
||||
<event name="OnMotion"></event>
|
||||
<event name="OnMouseEvents"></event>
|
||||
<event name="OnMouseWheel"></event>
|
||||
<event name="OnPaint"></event>
|
||||
<event name="OnRightDClick"></event>
|
||||
<event name="OnRightDown"></event>
|
||||
<event name="OnRightUp"></event>
|
||||
<event name="OnSetFocus"></event>
|
||||
<event name="OnSize"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Jul 11 2018)
|
||||
// C++ code generated with wxFormBuilder (version Jul 10 2019)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef __KICAD2STEP_FRAME_BASE_H__
|
||||
#define __KICAD2STEP_FRAME_BASE_H__
|
||||
#pragma once
|
||||
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
|
@ -27,19 +26,18 @@
|
|||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class KICAD2STEP_FRAME_BASE
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class KICAD2STEP_FRAME_BASE : public wxFrame
|
||||
class KICAD2STEP_FRAME_BASE : public wxFrame
|
||||
{
|
||||
private:
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
public:
|
||||
PANEL_KICAD2STEP* m_panelKicad2Step;
|
||||
|
||||
KICAD2STEP_FRAME_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Kicad2step Converter"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,300 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
|
||||
|
||||
|
||||
KICAD2STEP_FRAME_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Kicad2step Converter"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 644,300 ), long style = wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL );
|
||||
|
||||
~KICAD2STEP_FRAME_BASE();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //__KICAD2STEP_FRAME_BASE_H__
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <limits>
|
||||
#include <sstream>
|
||||
|
||||
#include <Standard_Failure.hxx>
|
||||
|
||||
KICADMODULE::KICADMODULE( KICADPCB* aParent )
|
||||
{
|
||||
|
@ -378,10 +379,17 @@ bool KICADMODULE::ComposePCB( class PCBMODEL* aPCB, S3D_RESOLVER* resolver,
|
|||
std::string fname( resolver->ResolvePath(
|
||||
wxString::FromUTF8Unchecked( i->m_modelname.c_str() ) ).ToUTF8() );
|
||||
|
||||
if( aPCB->AddComponent( fname, m_refdes, LAYER_BOTTOM == m_side ? true : false,
|
||||
newpos, m_rotation, i->m_offset, i->m_rotation, i->m_scale ) )
|
||||
hasdata = true;
|
||||
|
||||
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 ) )
|
||||
hasdata = true;
|
||||
}
|
||||
catch( const Standard_Failure& e)
|
||||
{
|
||||
ReportMessage( wxString::Format( "could not add component %s\n>>Opencascade error: %s\n ",
|
||||
m_refdes, e.GetMessageString() ) );
|
||||
}
|
||||
}
|
||||
|
||||
return hasdata;
|
||||
|
|
|
@ -164,13 +164,11 @@ FormatType fileType( const char* aFileName )
|
|||
|
||||
if( !lfile.FileExists() )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
#ifdef DEBUG
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
#endif /* DEBUG */
|
||||
ostr << " * no such file: '" << aFileName << "'\n";
|
||||
wxLogMessage( "%s", ostr.str().c_str() );
|
||||
wxString msg;
|
||||
msg.Printf( " * fileType(): no such file: %s\n",
|
||||
wxString::FromUTF8Unchecked( aFileName ) );
|
||||
|
||||
ReportMessage( msg );
|
||||
return FMT_NONE;
|
||||
}
|
||||
|
||||
|
@ -257,12 +255,9 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve )
|
|||
|
||||
if( distance < m_minDistance2 )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
#ifdef DEBUG
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
#endif /* DEBUG */
|
||||
ostr << " * rejected a zero-length " << aCurve->Describe() << "\n";
|
||||
wxLogMessage( "%s", ostr.str().c_str() );
|
||||
wxString msg;
|
||||
msg.Printf( " * AddOutlineSegment() rejected a zero-length %s\n", aCurve->Describe() );
|
||||
ReportMessage( msg );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -276,12 +271,9 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve )
|
|||
|
||||
if( rad < m_minDistance2 )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
#ifdef DEBUG
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
#endif /* DEBUG */
|
||||
ostr << " * rejected a zero-radius " << aCurve->Describe() << "\n";
|
||||
wxLogMessage( "%s", ostr.str().c_str() );
|
||||
wxString msg;
|
||||
msg.Printf( " * AddOutlineSegment() rejected a zero-radius %s\n", aCurve->Describe() );
|
||||
ReportMessage( msg );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -316,13 +308,10 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve )
|
|||
|
||||
if( rad < m_minDistance2 )
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
#ifdef DEBUG
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
#endif /* DEBUG */
|
||||
ostr << " * rejected an arc with equivalent end points, "
|
||||
<< aCurve->Describe() << "\n";
|
||||
wxLogMessage( "%s", ostr.str().c_str() );
|
||||
wxString msg;
|
||||
msg.Printf( " * AddOutlineSegment() rejected an arc with equivalent end points, %s\n",
|
||||
aCurve->Describe() );
|
||||
ReportMessage( msg );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -422,12 +411,10 @@ bool PCBMODEL::AddOutlineSegment( KICADCURVE* aCurve )
|
|||
// unexpected curve type
|
||||
do
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
#ifdef DEBUG
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
#endif /* DEBUG */
|
||||
ostr << " * unsupported curve type: '" << aCurve->m_form << "'\n";
|
||||
wxLogMessage( "%s", ostr.str().c_str() );
|
||||
wxString msg;
|
||||
msg.Printf( " * AddOutlineSegment() unsupported curve type: %s\n",
|
||||
aCurve->m_form );
|
||||
ReportMessage( msg );
|
||||
} while( 0 );
|
||||
|
||||
return false;
|
||||
|
@ -664,7 +651,8 @@ bool PCBMODEL::CreatePCB()
|
|||
oln.AddSegment( *m_mincurve );
|
||||
m_curves.erase( m_mincurve );
|
||||
|
||||
ReportMessage( wxString::Format( "Build board outline (%d items)\n", (int)m_curves.size() ) );
|
||||
ReportMessage( wxString::Format( "Build board outline (%d items)\n",
|
||||
(int)m_curves.size() ) );
|
||||
|
||||
while( !m_curves.empty() )
|
||||
{
|
||||
|
@ -764,12 +752,10 @@ bool PCBMODEL::CreatePCB()
|
|||
}
|
||||
|
||||
// subtract cutouts (if any)
|
||||
for( const auto& i : m_cutouts )
|
||||
board = BRepAlgoAPI_Cut( board, i );
|
||||
|
||||
if( m_cutouts.size() )
|
||||
ReportMessage( wxString::Format( "Build board cutout (%d holes)\n", (int)m_cutouts.size() ) );
|
||||
ReportMessage( wxString::Format( "Build board cutouts and holes (%d holes)\n", (int)m_cutouts.size() ) );
|
||||
|
||||
#if 0 // First version for holes removing: very slow when having many (> 300) holes
|
||||
// Substract holes (cutouts) can be time consuming, so display activity
|
||||
// state to be sure there is no hang:
|
||||
int char_count = 0;
|
||||
|
@ -791,7 +777,23 @@ bool PCBMODEL::CreatePCB()
|
|||
ReportMessage( wxString::Format( ". %d/%d\n", cur_count, cntmax ) );
|
||||
}
|
||||
}
|
||||
#else // Much faster than first version: group all holes and cut only once
|
||||
{
|
||||
BRepAlgoAPI_Cut Cut;
|
||||
TopTools_ListOfShape mainbrd;
|
||||
mainbrd.Append( board );
|
||||
|
||||
Cut.SetArguments( mainbrd );
|
||||
TopTools_ListOfShape holelist;
|
||||
|
||||
for( auto hole : m_cutouts )
|
||||
holelist.Append( hole );
|
||||
|
||||
Cut.SetTools( holelist );
|
||||
Cut.Build();
|
||||
board = Cut.Shape();
|
||||
}
|
||||
#endif
|
||||
// push the board to the data structure
|
||||
ReportMessage( "\nGenerate board full shape\n" );
|
||||
m_pcb_label = m_assy->AddComponent( m_assy_label, board );
|
||||
|
@ -827,7 +829,8 @@ bool PCBMODEL::WriteIGES( const wxString& aFileName )
|
|||
{
|
||||
if( m_pcb_label.IsNull() )
|
||||
{
|
||||
ReportMessage( wxString::Format( "No valid PCB assembly; cannot create output file %s\n", aFileName ) );
|
||||
ReportMessage( wxString::Format(
|
||||
"No valid PCB assembly; cannot create output file %s\n", aFileName ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -837,7 +840,7 @@ bool PCBMODEL::WriteIGES( const wxString& aFileName )
|
|||
writer.SetColorMode( Standard_True );
|
||||
writer.SetNameMode( Standard_True );
|
||||
IGESData_GlobalSection header = writer.Model()->GlobalSection();
|
||||
header.SetFileName( new TCollection_HAsciiString( fn.GetFullName().ToUTF8() ) );
|
||||
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" ) ) );
|
||||
|
@ -869,10 +872,12 @@ bool PCBMODEL::WriteSTEP( const wxString& aFileName )
|
|||
|
||||
APIHeaderSection_MakeHeader hdr( writer.ChangeWriter().Model() );
|
||||
wxFileName fn( aFileName );
|
||||
hdr.SetName( new TCollection_HAsciiString( fn.GetFullName().ToUTF8() ) );
|
||||
// Note: use only Ascii7 chars, non Ascii7 chars (therefore UFT8 chars)
|
||||
// are creating issues in the step file
|
||||
hdr.SetName( new TCollection_HAsciiString( fn.GetFullName().ToAscii() ) );
|
||||
// TODO: how to control and ensure consistency with IGES?
|
||||
hdr.SetAuthorValue( 1, new TCollection_HAsciiString( "An Author" ) );
|
||||
hdr.SetOrganizationValue( 1, new TCollection_HAsciiString( "A Company" ) );
|
||||
hdr.SetAuthorValue( 1, new TCollection_HAsciiString( "Pcbnew" ) );
|
||||
hdr.SetOrganizationValue( 1, new TCollection_HAsciiString( "Kicad" ) );
|
||||
hdr.SetOriginatingSystem( new TCollection_HAsciiString( "KiCad to STEP converter" ) );
|
||||
hdr.SetDescriptionValue( 1, new TCollection_HAsciiString( "KiCad electronic assembly" ) );
|
||||
|
||||
|
@ -880,7 +885,11 @@ bool PCBMODEL::WriteSTEP( const wxString& aFileName )
|
|||
// Creates a temporary file with a ascii7 name, because writer does not know
|
||||
// unicode filenames
|
||||
wxString currCWD = wxGetCwd();
|
||||
wxSetWorkingDirectory( fn.GetPath() );
|
||||
wxString workCWD =fn.GetPath();
|
||||
|
||||
if( !workCWD.IsEmpty() )
|
||||
wxSetWorkingDirectory( workCWD );
|
||||
|
||||
char tmpfname[] = "$tempfile$.step";
|
||||
|
||||
if( Standard_False == writer.Write( tmpfname ) )
|
||||
|
@ -899,7 +908,8 @@ bool PCBMODEL::WriteSTEP( const wxString& aFileName )
|
|||
|
||||
bool PCBMODEL::getModelLabel( const std::string aFileName, TRIPLET aScale, TDF_Label& aLabel )
|
||||
{
|
||||
std::string model_key = aFileName + "_" + std::to_string( aScale.x ) + "_" + std::to_string( aScale.y ) + "_" + std::to_string( aScale.z );
|
||||
std::string model_key = aFileName + "_" + std::to_string( aScale.x )
|
||||
+ "_" + std::to_string( aScale.y ) + "_" + std::to_string( aScale.z );
|
||||
|
||||
MODEL_MAP::const_iterator mm = m_models.find( model_key );
|
||||
|
||||
|
@ -921,7 +931,8 @@ bool PCBMODEL::getModelLabel( const std::string aFileName, TRIPLET aScale, TDF_L
|
|||
case FMT_IGES:
|
||||
if( !readIGES( doc, aFileName.c_str() ) )
|
||||
{
|
||||
ReportMessage( wxString::Format( "readIGES() failed on filename %s\n", aFileName ) );
|
||||
ReportMessage( wxString::Format( "readIGES() failed on filename %s\n",
|
||||
aFileName ) );
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
@ -929,7 +940,8 @@ bool PCBMODEL::getModelLabel( const std::string aFileName, TRIPLET aScale, TDF_L
|
|||
case FMT_STEP:
|
||||
if( !readSTEP( doc, aFileName.c_str() ) )
|
||||
{
|
||||
ReportMessage( wxString::Format( "readSTEP() failed on filename %s\n", aFileName ) );
|
||||
ReportMessage( wxString::Format( "readSTEP() failed on filename %s\n",
|
||||
aFileName ) );
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
@ -1001,7 +1013,7 @@ bool PCBMODEL::getModelLabel( const std::string aFileName, TRIPLET aScale, TDF_L
|
|||
|
||||
if( aLabel.IsNull() )
|
||||
{
|
||||
ReportMessage( wxString::Format( "could not transfer model data from file %s", aFileName ) );
|
||||
ReportMessage( wxString::Format( "could not transfer model data from file %s\n", aFileName ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1192,15 +1204,14 @@ TDF_Label PCBMODEL::transferModel( Handle( TDocStd_Document )& source,
|
|||
brep.Perform( shape, Standard_False );
|
||||
TopoDS_Shape scaled_shape;
|
||||
|
||||
if ( brep.IsDone() ) {
|
||||
if ( brep.IsDone() )
|
||||
{
|
||||
scaled_shape = brep.Shape();
|
||||
} else {
|
||||
std::ostringstream ostr;
|
||||
#ifdef DEBUG
|
||||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||
#endif /* DEBUG */
|
||||
ostr << " * failed to scale model\n";
|
||||
wxLogMessage( "%s", ostr.str().c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportMessage( " * transfertModel(): failed to scale model\n" );
|
||||
|
||||
scaled_shape = shape;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue