From 07568f87c33377e9976e02364c49c7dc7bd3be1f Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 3 Jan 2021 14:52:42 +0100 Subject: [PATCH] Step exporter: better values for min distance between 2 points to merge them. - The default value is 0.01 mm (according to comments and similar to the 3D viewer settings that uses 0.02 mm) - The export dialog has now 3 values 1 micron, 0.01mm (default) and 0.1 mm From Master branch, commits a9feb1c and 5db7580 --- pcbnew/dialogs/dialog_export_step.cpp | 20 +++++++++++++++++--- pcbnew/dialogs/dialog_export_step_base.cpp | 6 +++--- pcbnew/dialogs/dialog_export_step_base.fbp | 4 ++-- pcbnew/dialogs/dialog_export_step_base.h | 2 +- utils/kicad2step/pcb/base.h | 4 ++-- utils/kicad2step/pcb/oce_utils.h | 1 + 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/pcbnew/dialogs/dialog_export_step.cpp b/pcbnew/dialogs/dialog_export_step.cpp index a3338838cc..bc9e7cb34a 100644 --- a/pcbnew/dialogs/dialog_export_step.cpp +++ b/pcbnew/dialogs/dialog_export_step.cpp @@ -315,11 +315,25 @@ void DIALOG_EXPORT_STEP::onExportButton( wxCommandEvent& aEvent ) break; } - if( m_tolerance->GetSelection() != 1 ) + double tolerance = 0.01; // default value in mm + + switch( m_tolerance->GetSelection() ) + { + case 0: // small + tolerance = 0.001; + break; + + default: + case 1: break; // Normal + + case 2: // large + tolerance = 0.1; + break; + } + { LOCALE_IO dummy; - double tolerance = 0.001 * std::pow( 10.0, m_tolerance->GetSelection() - 1 ); - cmdK2S.Append( wxString::Format( " --min-distance=\"%.4f mm\"", tolerance ) ); + cmdK2S.Append( wxString::Format( " --min-distance=\"%.3f mm\"", tolerance ) ); } cmdK2S.Append( " -f -o " ); diff --git a/pcbnew/dialogs/dialog_export_step_base.cpp b/pcbnew/dialogs/dialog_export_step_base.cpp index 90ffbc2e17..bc01619604 100644 --- a/pcbnew/dialogs/dialog_export_step_base.cpp +++ b/pcbnew/dialogs/dialog_export_step_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jan 17 2019) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -163,11 +163,11 @@ DIALOG_EXPORT_STEP_BASE::DIALOG_EXPORT_STEP_BASE( wxWindow* parent, wxWindowID i m_staticText8->Wrap( -1 ); fgSizer4->Add( m_staticText8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - wxString m_toleranceChoices[] = { _("Tight"), _("Standard"), _("Loose"), _("Very loose") }; + wxString m_toleranceChoices[] = { _("Tight (0.001 mm)"), _("Standard (0.01 mm)"), _("Loose (0.1 mm)") }; int m_toleranceNChoices = sizeof( m_toleranceChoices ) / sizeof( wxString ); m_tolerance = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_toleranceNChoices, m_toleranceChoices, 0 ); m_tolerance->SetSelection( 1 ); - m_tolerance->SetToolTip( _("Tolerance sets the distance between two points that are considered joined. Standard is 0.001mm.") ); + m_tolerance->SetToolTip( _("Tolerance sets the distance between two points that are considered joined.") ); fgSizer4->Add( m_tolerance, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); diff --git a/pcbnew/dialogs/dialog_export_step_base.fbp b/pcbnew/dialogs/dialog_export_step_base.fbp index 69c0168afa..6f1ab304bc 100644 --- a/pcbnew/dialogs/dialog_export_step_base.fbp +++ b/pcbnew/dialogs/dialog_export_step_base.fbp @@ -1353,7 +1353,7 @@ 1 0 - "Tight" "Standard" "Loose" "Very loose" + "Tight (0.001 mm)" "Standard (0.01 mm)" "Loose (0.1 mm)" 1 1 @@ -1389,7 +1389,7 @@ ; ; forward_declare 0 - Tolerance sets the distance between two points that are considered joined. Standard is 0.001mm. + Tolerance sets the distance between two points that are considered joined. wxFILTER_NONE wxDefaultValidator diff --git a/pcbnew/dialogs/dialog_export_step_base.h b/pcbnew/dialogs/dialog_export_step_base.h index a54b34849e..8b75850e8b 100644 --- a/pcbnew/dialogs/dialog_export_step_base.h +++ b/pcbnew/dialogs/dialog_export_step_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jan 17 2019) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! diff --git a/utils/kicad2step/pcb/base.h b/utils/kicad2step/pcb/base.h index 1a926e757e..7c3a68f232 100644 --- a/utils/kicad2step/pcb/base.h +++ b/utils/kicad2step/pcb/base.h @@ -30,8 +30,8 @@ #ifndef KICADBASE_H #define KICADBASE_H -///> Minimum distance between points to treat them as separate ones (mm) -static constexpr double MIN_DISTANCE = 0.001; +///> Default minimum distance between points to treat them as separate ones (mm) +static constexpr double MIN_DISTANCE = 0.01; namespace SEXPR { diff --git a/utils/kicad2step/pcb/oce_utils.h b/utils/kicad2step/pcb/oce_utils.h index b8b7e4a3ef..b3203e1b46 100644 --- a/utils/kicad2step/pcb/oce_utils.h +++ b/utils/kicad2step/pcb/oce_utils.h @@ -131,6 +131,7 @@ public: // aThickness > THICKNESS_MIN == use aThickness void SetPCBThickness( double aThickness ); + // Set the minimum distance (in mm) to consider 2 points have the same coordinates void SetMinDistance( double aDistance ); // create the PCB model using the current outlines and drill holes