44#include <Message_PrinterOStream.hxx>
45#include <Standard_Failure.hxx>
47#include <Standard_Version.hxx>
53#define OCC_VERSION_MIN 0x070500
55#if OCC_VERSION_HEX < OCC_VERSION_MIN
56#include <Message_Messenger.hxx>
72#if OCC_VERSION_HEX < OCC_VERSION_MIN
73 virtual void Send(
const TCollection_ExtendedString& theString,
74 const Message_Gravity theGravity,
75 const Standard_Boolean theToPutEol )
const override
77 Send( TCollection_AsciiString( theString ), theGravity, theToPutEol );
80 virtual void Send(
const TCollection_AsciiString& theString,
81 const Message_Gravity theGravity,
82 const Standard_Boolean theToPutEol )
const override
84 virtual void send(
const TCollection_AsciiString& theString,
85 const Message_Gravity theGravity )
const override
88 if( theGravity >= Message_Warning
89 || ( wxLog::IsAllowedTraceMask(
traceKiCad2Step ) && theGravity == Message_Info ) )
93#if OCC_VERSION_HEX < OCC_VERSION_MIN
101 if( theGravity == Message_Warning )
104 if( theGravity >= Message_Alarm )
107 if( theGravity == Message_Fail )
122 default:
return wxEmptyString;
133 default:
return wxEmptyString;
144 m_pcbModel( nullptr ),
155 m_resolver = std::make_unique<FILENAME_RESOLVER>();
170 bool hasdata =
false;
212 wxString footprintBasePath = wxEmptyString;
226 footprintBasePath = fpRow->
GetFullURI(
true );
244 if( !fp_model.m_Show || fp_model.m_Filename.empty() )
248 std::vector<wxString> searchedPaths;
249 wxString mname =
m_resolver->ResolvePath( fp_model.m_Filename, footprintBasePath );
252 if( !wxFileName::FileExists( mname ) )
254 ReportMessage( wxString::Format( wxT(
"Could not add 3D model to %s.\n"
255 "File not found: %s\n" ),
260 std::string fname( mname.ToUTF8() );
261 std::string refName( aFootprint->
GetReference().ToUTF8() );
267 VECTOR3D modelRot = fp_model.m_Rotation;
271 if(
m_pcbModel->AddComponent( fname, refName, bottomSide,
274 fp_model.m_Offset, modelRot,
280 catch(
const Standard_Failure& e )
282 ReportMessage( wxString::Format( wxT(
"Could not add 3D model to %s.\n"
283 "OpenCASCADE error: %s\n" ),
297 return m_pcbModel->AddViaShape(
static_cast<const PCB_VIA*
>( aTrack ), aOrigin );
302 if( pcblayer !=
F_Cu && pcblayer !=
B_Cu )
309 if( pcblayer ==
F_Cu )
315 m_pcbModel->AddTrackSegment( aTrack, aOrigin );
327 if( layer ==
F_Cu || layer ==
B_Cu )
330 zone->TransformSolidAreasShapesToPolygon( layer, copper_shape );
333 m_pcbModel->AddCopperPolygonShapes( &copper_shape, layer ==
F_Cu, aOrigin,
false );
349 if( pcblayer !=
F_Cu && pcblayer !=
B_Cu )
356 if( pcblayer ==
F_Cu )
378 wxLogWarning(
_(
"Board outline is malformed. Run DRC for a full analysis." ) );
436 msg.Printf( wxT(
"Board outline: find %d initial points\n" ), pcbOutlines.
FullPointCount() );
439 if( !
m_pcbModel->CreatePCB( pcbOutlines, origin ) )
441 ReportMessage( wxT(
"could not create PCB solid model\n" ) );
461 switch( item->GetType() )
466 for(
int idx = 0; idx < item->GetSublayersCount(); idx++ )
467 thickness += item->GetThickness( idx );
472 if( item->IsEnabled() )
473 thickness += item->GetThickness();
494 Message::DefaultMessenger()->RemovePrinters( STANDARD_TYPE( Message_PrinterOStream ) );
495 Message::DefaultMessenger()->AddPrinter(
new KiCadPrinter(
this ) );
506 fn.SetName( fn.GetName() );
518 ReportMessage(
_(
"\n** Error building STEP board model. Export aborted. **\n" ) );
532 ReportMessage( wxString::Format(
_(
"\n** Error writing %s file. **\n" ),
542 catch(
const Standard_Failure& e )
545 ReportMessage( wxString::Format(
_(
"\n** Error exporting %s file. Export aborted. **\n" ),
551 ReportMessage( wxString::Format(
_(
"\n** Error exporting %s file. Export aborted. **\n" ),
560 msg = wxString::Format(
_(
"Unable to create %s file.\n"
561 "Check that the board has a valid outline and models." ),
566 msg = wxString::Format(
_(
"%s file has been created, but there are warnings." ),
575 ReportMessage( wxString::Format(
_(
"\nExport time %.3f s\n" ), calculation_time ) );
constexpr EDA_IU_SCALE pcbIUScale
#define DEFAULT_BOARD_THICKNESS_MM
@ BS_ITEM_TYPE_DIELECTRIC
Container for design settings for a BOARD object.
const VECTOR2I & GetGridOrigin()
const VECTOR2I & GetAuxOrigin()
BOARD_STACKUP & GetStackupDescriptor()
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Manage one layer needed to make a physical board.
const std::vector< BOARD_STACKUP_ITEM * > & GetList() const
Information pertinent to a Pcbnew printed circuit board.
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr, bool aAllowUseArcsInPolygons=false)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
FOOTPRINTS & Footprints()
const wxString & GetFileName() const
PROJECT * GetProject() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
KICAD_T Type() const
Returns the type of object.
wxString GetDefaultExportExtension()
bool m_includeUnspecified
void buildZones3DShape(VECTOR2D aOrigin)
KIGFX::COLOR4D m_solderMaskColor
SHAPE_POLY_SET m_top_copper_shapes
SHAPE_POLY_SET m_bottom_copper_shapes
bool buildGraphic3DShape(BOARD_ITEM *aItem, VECTOR2D aOrigin)
EXPORTER_STEP_PARAMS m_params
EXPORTER_STEP(BOARD *aBoard, const EXPORTER_STEP_PARAMS &aParams)
wxString m_pcbBaseName
the name of the project (board short filename (no path, no ext) used to identify items in step file
bool buildFootprint3DShapes(FOOTPRINT *aFootprint, VECTOR2D aOrigin)
std::unique_ptr< FILENAME_RESOLVER > m_resolver
bool ExportTracksAndVias()
Return rue to export tracks and vias on top and bottom copper layers.
bool buildBoard3DShapes()
std::unique_ptr< STEP_PCB_MODEL > m_pcbModel
void calculatePcbThickness()
bool buildTrack3DShape(PCB_TRACK *aTrack, VECTOR2D aOrigin)
KIGFX::COLOR4D m_copperColor
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
const FP_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an FP_LIB_TABLE_ROW if aNickName is found in this table or in any chained fall back table frag...
A color representation with 4 components: red, green, blue, alpha.
EXPORTER_STEP * m_converter
KiCadPrinter(EXPORTER_STEP *aConverter)
virtual void Send(const TCollection_ExtendedString &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
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the track shape to a closed polygon.
static FP_LIB_TABLE * PcbFootprintLibs(PROJECT *aProject)
Return the table of footprint libraries without Kiway.
Represent a set of closed polygons.
int FullPointCount() const
Return the number of points in the shape poly set.
void Unfracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
Handle a list of polygons defining a copper zone.
void ReportMessage(const wxString &aMessage)
const wxChar *const traceKiCad2Step
Flag to enable KiCad2Step debug tracing.
PCB_LAYER_ID
A quick note on layer IDs:
unsigned GetRunningMicroSecs()
An alternate way to calculate an elapsed time (in microsecondes) to class PROF_COUNTER.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
static constexpr double OCC_MAX_DISTANCE_TO_MERGE_POINTS
Default distance between points to treat them as separate ones (mm) 0.001 mm or less is a reasonable ...
constexpr double IUTomm(int iu) const
wxLogTrace helper definitions.
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer