42#include <Message_PrinterOStream.hxx>
43#include <Standard_Failure.hxx>
45#include <Standard_Version.hxx>
50#define OCC_VERSION_MIN 0x070500
52#if OCC_VERSION_HEX < OCC_VERSION_MIN
53#include <Message_Messenger.hxx>
69#if OCC_VERSION_HEX < OCC_VERSION_MIN
70 virtual void Send(
const TCollection_ExtendedString& theString,
71 const Message_Gravity theGravity,
72 const Standard_Boolean theToPutEol )
const override
74 Send( TCollection_AsciiString( theString ), theGravity, theToPutEol );
77 virtual void Send(
const TCollection_AsciiString& theString,
78 const Message_Gravity theGravity,
79 const Standard_Boolean theToPutEol )
const override
81 virtual void send(
const TCollection_AsciiString& theString,
82 const Message_Gravity theGravity )
const override
85 if( theGravity >= Message_Warning
86 || ( wxLog::IsAllowedTraceMask(
traceKiCad2Step ) && theGravity == Message_Info ) )
90#if OCC_VERSION_HEX < OCC_VERSION_MIN
98 if( theGravity == Message_Warning )
101 if( theGravity >= Message_Alarm )
104 if( theGravity == Message_Fail )
118 m_hasDrillOrigin( false ),
119 m_hasGridOrigin( false ),
121 m_pcbModel( nullptr ),
132 m_resolver = std::make_unique<FILENAME_RESOLVER>();
147 bool hasdata =
false;
189 wxString footprintBasePath = wxEmptyString;
203 footprintBasePath = fpRow->
GetFullURI(
true );
221 if( !fp_model.m_Show || fp_model.m_Filename.empty() )
225 std::vector<wxString> searchedPaths;
226 wxString mname =
m_resolver->ResolvePath( fp_model.m_Filename, footprintBasePath );
229 if( !wxFileName::FileExists( mname ) )
231 ReportMessage( wxString::Format( wxT(
"Could not add 3D model to %s.\n"
232 "File not found: %s\n" ),
237 std::string fname( mname.ToUTF8() );
238 std::string refName( aFootprint->
GetReference().ToUTF8() );
244 VECTOR3D modelRot = fp_model.m_Rotation;
248 if(
m_pcbModel->AddComponent( fname, refName, bottomSide,
251 fp_model.m_Offset, modelRot,
257 catch(
const Standard_Failure& e )
259 ReportMessage( wxString::Format( wxT(
"Could not add 3D model to %s.\n"
260 "OpenCASCADE error: %s\n" ),
275 int hole =
static_cast<PCB_VIA*
>( aTrack )->GetDrillValue();
291 if( pcblayer !=
F_Cu && pcblayer !=
B_Cu )
296 if( pcblayer ==
F_Cu )
314 if( pcblayer !=
F_Cu && pcblayer !=
B_Cu )
321 if( pcblayer ==
F_Cu )
343 wxLogWarning(
_(
"Board outline is malformed. Run DRC for a full analysis." ) );
399 msg.Printf( wxT(
"Board outline: find %d initial points\n" ), pcbOutlines.
FullPointCount() );
402 if( !
m_pcbModel->CreatePCB( pcbOutlines, origin ) )
404 ReportMessage( wxT(
"could not create PCB solid model\n" ) );
424 switch( item->GetType() )
429 for(
int idx = 0; idx < item->GetSublayersCount(); idx++ )
430 thickness += item->GetThickness( idx );
435 if( item->IsEnabled() )
436 thickness += item->GetThickness();
454 Message::DefaultMessenger()->RemovePrinters( STANDARD_TYPE( Message_PrinterOStream ) );
455 Message::DefaultMessenger()->AddPrinter(
new KiCadPrinter(
this ) );
469 ReportMessage(
_(
"\n** Error building STEP board model. Export aborted. **\n" ) );
485 catch(
const Standard_Failure& e )
488 ReportMessage(
_(
"\n** Error exporting STEP file. Export aborted. **\n" ) );
493 ReportMessage(
_(
"\n** Error exporting STEP file. Export aborted. **\n" ) );
501 msg =
_(
"Unable to create STEP file.\n"
502 "Check that the board has a valid outline and models." );
506 msg =
_(
"STEP file has been created, but there are warnings." );
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.
bool m_includeUnspecified
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.
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.
const VECTOR2I & GetStart() const
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Represent a set of closed polygons.
void Fracture(POLYGON_MODE aFastMode)
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
int FullPointCount() const
Return the number of points in the shape poly set.
void ReportMessage(const wxString &aMessage)
const wxChar *const traceKiCad2Step
Flag to enable KiCad2Step debug tracing.
PCB_LAYER_ID
A quick note on layer IDs:
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
std::vector< FAB_LAYER_COLOR > dummy
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)