46#include <Message_PrinterOStream.hxx>
47#include <Standard_Failure.hxx>
49#include <Standard_Version.hxx>
55#define OCC_VERSION_MIN 0x070500
57#if OCC_VERSION_HEX < OCC_VERSION_MIN
58#include <Message_Messenger.hxx>
74#if OCC_VERSION_HEX < OCC_VERSION_MIN
75 virtual void Send(
const TCollection_ExtendedString& theString,
76 const Message_Gravity theGravity,
77 const Standard_Boolean theToPutEol )
const override
79 Send( TCollection_AsciiString( theString ), theGravity, theToPutEol );
82 virtual void Send(
const TCollection_AsciiString& theString,
83 const Message_Gravity theGravity,
84 const Standard_Boolean theToPutEol )
const override
86 virtual void send(
const TCollection_AsciiString& theString,
87 const Message_Gravity theGravity )
const override
90 if( theGravity >= Message_Warning
91 || ( wxLog::IsAllowedTraceMask(
traceKiCad2Step ) && theGravity == Message_Info ) )
95#if OCC_VERSION_HEX < OCC_VERSION_MIN
103 if( theGravity == Message_Warning )
106 if( theGravity >= Message_Alarm )
109 if( theGravity == Message_Fail )
126 default:
return wxEmptyString;
139 default:
return wxEmptyString;
150 m_pcbModel( nullptr )
163 m_resolver = std::make_unique<FILENAME_RESOLVER>();
178 bool hasdata =
false;
179 std::vector<PAD*> padsMatchingNetFilter;
196 padsMatchingNetFilter.push_back(
pad );
222 for(
PAD*
pad : padsMatchingNetFilter )
224 if( !
pad->IsOnLayer( pcblayer ) )
227 std::shared_ptr<SHAPE_POLY_SET> padPoly =
pad->GetEffectivePolygon();
230 if( padPoly->Collide( &gfxPoly ) )
254 wxString footprintBasePath = wxEmptyString;
268 footprintBasePath = fpRow->
GetFullURI(
true );
286 if( !fp_model.m_Show || fp_model.m_Filename.empty() )
289 std::vector<wxString> searchedPaths;
290 wxString mname =
m_resolver->ResolvePath( fp_model.m_Filename, footprintBasePath );
293 if( mname.empty() || !wxFileName::FileExists( mname ) )
297 mname = fp_model.m_Filename;
299 ReportMessage( wxString::Format( wxT(
"Could not add 3D model to %s.\n"
300 "File not found: %s\n" ),
305 std::string fname( mname.ToUTF8() );
306 std::string refName( aFootprint->
GetReference().ToUTF8() );
312 VECTOR3D modelRot = fp_model.m_Rotation;
316 if(
m_pcbModel->AddComponent( fname, refName, bottomSide,
319 fp_model.m_Offset, modelRot,
325 catch(
const Standard_Failure& e )
327 ReportMessage( wxString::Format( wxT(
"Could not add 3D model to %s.\n"
328 "OpenCASCADE error: %s\n" ),
345 return m_pcbModel->AddViaShape(
static_cast<const PCB_VIA*
>( aTrack ), aOrigin );
361 m_pcbModel->AddTrackSegment( aTrack, aOrigin );
374 for(
PCB_LAYER_ID layer : zone->GetLayerSet().CuStack() )
377 zone->TransformSolidAreasShapesToPolygon( layer, copper_shape );
383 m_pcbModel->AddCopperPolygonShapes( &copper_shape, layer, aOrigin,
false );
424 wxLogWarning(
_(
"Board outline is malformed. Run DRC for a full analysis." ) );
452 m_pcbModel->SetEnabledLayers( layersToExport );
495 msg.Printf( wxT(
"Board outline: find %d initial points\n" ), pcbOutlines.
FullPointCount() );
500 ReportMessage( wxT(
"could not create PCB solid model\n" ) );
514 Message::DefaultMessenger()->RemovePrinters( STANDARD_TYPE( Message_PrinterOStream ) );
515 Message::DefaultMessenger()->AddPrinter(
new KiCadPrinter(
this ) );
522 fn.SetName( fn.GetName() );
534 ReportMessage(
_(
"\n** Error building STEP board model. Export aborted. **\n" ) );
552 ReportMessage( wxString::Format(
_(
"\n** Error writing %s file. **\n" ),
562 catch(
const Standard_Failure& e )
565 ReportMessage( wxString::Format(
_(
"\n** Error exporting %s file. Export aborted. **\n" ),
571 ReportMessage( wxString::Format(
_(
"\n** Error exporting %s file. Export aborted. **\n" ),
582 msg = wxString::Format(
_(
"Unable to create %s file.\n"
583 "Check that the board has a valid outline and models." ),
588 msg = wxString::Format(
_(
"%s file has been created, but there are warnings." ),
597 ReportMessage( wxString::Format(
_(
"\nExport time %.3f s\n" ), calculation_time ) );
constexpr EDA_IU_SCALE pcbIUScale
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
wxString GetNetname() const
const VECTOR2I & GetGridOrigin()
const VECTOR2I & GetAuxOrigin()
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.
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Information pertinent to a Pcbnew printed circuit board.
BOARD_STACKUP GetStackupOrDefault() const
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr, bool aAllowUseArcsInPolygons=false, bool aIncludeNPTHAsOutlines=false)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
const ZONES & Zones() const
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
const wxString & GetFileName() const
PROJECT * GetProject() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
const DRAWINGS & Drawings() const
KICAD_T Type() const
Returns the type of object.
wxString GetDefaultExportExtension()
bool m_includeUnspecified
void buildZones3DShape(VECTOR2D aOrigin)
KIGFX::COLOR4D m_solderMaskColor
bool buildGraphic3DShape(BOARD_ITEM *aItem, VECTOR2D aOrigin)
std::map< PCB_LAYER_ID, SHAPE_POLY_SET > m_poly_copper_shapes
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 buildBoard3DShapes()
std::unique_ptr< STEP_PCB_MODEL > m_pcbModel
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 t...
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...
LSET is a set of PCB_LAYER_IDs.
static LSET ExternalCuMask()
Return a mask holding the Front and Bottom layers.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
static LSET InternalCuMask()
Return a complete set of internal copper layers which is all Cu layers except F_Cu and B_Cu.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
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.
std::vector< SHAPE_LINE_CHAIN > POLYGON
represents a single polygon outline with holes.
void Unfracture(POLYGON_MODE aFastMode)
Convert a single outline slitted ("fractured") polygon into a set ouf outlines with holes.
void SimplifyOutlines(int aMaxError=0)
Simplifies the lines in the polyset.
const std::vector< POLYGON > & CPolygons() const
Handle a list of polygons defining a copper zone.
void ReportMessage(const wxString &aMessage)
static const std::string AutoSaveFilePrefix
const wxChar *const traceKiCad2Step
Flag to enable KiCad2Step debug tracing.
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
PCB_LAYER_ID
A quick note on layer IDs:
PGM_BASE & Pgm()
The global Program "get" accessor.
int64_t GetRunningMicroSecs()
An alternate way to calculate an elapsed time (in microsecondes) to class PROF_COUNTER.
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
Definition of file extensions used in Kicad.