Fix some issues in STEP exporter

This commit is contained in:
jean-pierre charras 2022-10-07 18:53:31 +02:00
parent 863184e3dc
commit b8dfbe02ad
4 changed files with 14 additions and 2 deletions

View File

@ -29,6 +29,6 @@ JOB_EXPORT_STEP::JOB_EXPORT_STEP( bool aIsCli ) : JOB( "step", aIsCli )
m_substModels = false;
m_xOrigin = 0.0;
m_yOrigin = 0.0;
m_minDistance = 0.0;
m_minDistance = 0.01; // 0.01 mm is a good value to connect 2 items of the board outlines
m_gui = false;
}

View File

@ -46,6 +46,8 @@
#include <Standard_Version.hxx>
#include <locale_io.h>
#define OCC_VERSION_MIN 0x070500
#if OCC_VERSION_HEX < OCC_VERSION_MIN
@ -240,11 +242,17 @@ int KICAD2STEP::DoRun()
return CLI::EXIT_CODES::ERR_INVALID_OUTPUT_CONFLICT;
}
LOCALE_IO dummy;
wxString outfile = out_fname.GetFullPath();
KICADPCB pcb( fname.GetName() );
pcb.SetOrigin( m_params.m_xOrigin, m_params.m_yOrigin );
pcb.SetMinDistance( m_params.m_minDistance );
// Set the min dist in mm to consider 2 points at the same place
// This is also the tolerance to consider 2 lines or arcs are connected
// A min value (0.001mm) is needed to have closed board outlines
// 0.01 mm is a good value
pcb.SetMinDistance( std::max( m_params.m_minDistance, MIN_ACCEPTABLE_DISTANCE ) );
ReportMessage( wxString::Format( _( "Read file: '%s'\n" ), m_params.m_filename ) );
Message::DefaultMessenger()->RemovePrinters( STANDARD_TYPE( Message_PrinterOStream ) );

View File

@ -36,6 +36,7 @@
///< Default minimum distance between points to treat them as separate ones (mm)
static constexpr double MIN_DISTANCE = 0.01;
static constexpr double MIN_ACCEPTABLE_DISTANCE = 0.001;
namespace SEXPR
{

View File

@ -678,6 +678,9 @@ void PCBMODEL::SetBoardColor( double r, double g, double b )
void PCBMODEL::SetMinDistance( double aDistance )
{
// Ensure a minimal value (in mm)
aDistance = std::max( aDistance, MIN_ACCEPTABLE_DISTANCE );
// m_minDistance2 keeps a squared distance value
m_minDistance2 = aDistance * aDistance;
BRepBuilderAPI::Precision( aDistance );