47#include <Message_PrinterOStream.hxx>
48#include <Standard_Failure.hxx>
50#include <Standard_Version.hxx>
56#define OCC_VERSION_MIN 0x070500
58#if OCC_VERSION_HEX < OCC_VERSION_MIN
59#include <Message_Messenger.hxx>
75#if OCC_VERSION_HEX < OCC_VERSION_MIN
76 virtual void Send(
const TCollection_ExtendedString& theString,
77 const Message_Gravity theGravity,
78 const Standard_Boolean theToPutEol )
const override
80 Send( TCollection_AsciiString( theString ), theGravity, theToPutEol );
83 virtual void Send(
const TCollection_AsciiString& theString,
84 const Message_Gravity theGravity,
85 const Standard_Boolean theToPutEol )
const override
87 virtual void send(
const TCollection_AsciiString& theString,
88 const Message_Gravity theGravity )
const override
91 if( theGravity >= Message_Warning
92 || ( wxLog::IsAllowedTraceMask(
traceKiCad2Step ) && theGravity == Message_Info ) )
96#if OCC_VERSION_HEX < OCC_VERSION_MIN
104 if( theGravity == Message_Warning )
107 if( theGravity >= Message_Alarm )
110 if( theGravity == Message_Fail )
125 m_pcbModel( nullptr )
145 m_resolver = std::make_unique<FILENAME_RESOLVER>();
160 bool hasdata =
false;
161 std::vector<PAD*> padsMatchingNetFilter;
167 std::shared_ptr<SHAPE_SEGMENT> holeShape =
pad->GetEffectiveHoleShape();
174 if(
pad->IsOnLayer( pcblayer ) )
182 if(
m_pcbModel->AddHole( *holeShape, platingThickness,
F_Cu,
B_Cu,
false, aOrigin,
true,
213 pad->TransformShapeToPolygon( poly, cuLayer,
214 pad->GetSolderMaskExpansion( cuLayer ), maxError,
222 padsMatchingNetFilter.push_back(
pad );
247 for(
PAD*
pad : padsMatchingNetFilter )
249 if( !
pad->IsOnLayer( pcblayer ) )
252 std::shared_ptr<SHAPE_POLY_SET> padPoly =
pad->GetEffectivePolygon( pcblayer );
255 if( padPoly->Collide( &gfxPoly ) )
278 wxString footprintBasePath = wxEmptyString;
292 footprintBasePath = fpRow->
GetFullURI(
true );
307 std::vector<wxString> componentFilterPatterns;
309 if( componentFilter )
313 while( tokenizer.HasMoreTokens() )
314 componentFilterPatterns.push_back( tokenizer.GetNextToken().Trim(
false ) );
318 for(
const wxString& pattern : componentFilterPatterns )
335 if( !fp_model.m_Show || fp_model.m_Filename.empty() )
338 std::vector<wxString> searchedPaths;
339 wxString mname =
m_resolver->ResolvePath( fp_model.m_Filename, footprintBasePath, aFootprint );
342 if( mname.empty() || !wxFileName::FileExists( mname ) )
346 mname = fp_model.m_Filename;
348 ReportMessage( wxString::Format( wxT(
"Could not add 3D model to %s.\n"
349 "File not found: %s\n" ),
354 std::string fname( mname.ToUTF8() );
355 std::string refName( aFootprint->
GetReference().ToUTF8() );
361 VECTOR3D modelRot = fp_model.m_Rotation;
365 if(
m_pcbModel->AddComponent( fname, refName, bottomSide,
368 fp_model.m_Offset, modelRot,
374 catch(
const Standard_Failure& e )
376 ReportMessage( wxString::Format( wxT(
"Could not add 3D model to %s.\n"
377 "OpenCASCADE error: %s\n" ),
399 std::shared_ptr<SHAPE_SEGMENT> holeShape =
via->GetEffectiveHoleShape();
406 via->LayerPair( &top_layer, &bot_layer );
412 const std::shared_ptr<SHAPE>& shape =
via->GetEffectiveShape( pcblayer );
420 m_pcbModel->AddBarrel( *holeShape, top_layer, bot_layer,
true, aOrigin );
454 LSET layers = zone->GetLayerSet();
465 zone->TransformSolidAreasShapesToPolygon( layer, fill_shape );
491 switch( aItem->
Type() )
529 default: wxFAIL_MSG(
"buildGraphic3DShape: unhandled item type" );
543 m_pcbModel->SpecializeVariant( OUTPUT_FORMAT::FMT_OUT_STEP );
547 m_pcbModel->SpecializeVariant( OUTPUT_FORMAT::FMT_OUT_BREP );
551 m_pcbModel->SpecializeVariant( OUTPUT_FORMAT::FMT_OUT_XAO );
555 m_pcbModel->SpecializeVariant( OUTPUT_FORMAT::FMT_OUT_GLTF );
559 m_pcbModel->SpecializeVariant( OUTPUT_FORMAT::FMT_OUT_PLY );
563 m_pcbModel->SpecializeVariant( OUTPUT_FORMAT::FMT_OUT_STL );
567 m_pcbModel->SpecializeVariant( OUTPUT_FORMAT::FMT_OUT_UNKNOWN );
584 wxLogWarning(
_(
"Board outline is malformed. Run DRC for a full analysis." ) );
670 m_pcbModel->AddPolygonShapes( &poly, pcblayer, origin );
676 msg.Printf( wxT(
"Board outline: find %d initial points\n" ), pcbOutlines.
FullPointCount() );
681 ReportMessage( wxT(
"could not create PCB solid model\n" ) );
695 Message::DefaultMessenger()->RemovePrinters( STANDARD_TYPE( Message_PrinterOStream ) );
696 Message::DefaultMessenger()->AddPrinter(
new KiCadPrinter(
this ) );
703 fn.SetName( fn.GetName() );
734 ReportMessage(
_(
"\n** Error building STEP board model. Export aborted. **\n" ) );
756 ReportMessage( wxString::Format(
_(
"\n** Error writing %s file. **\n" ),
766 catch(
const Standard_Failure& e )
769 ReportMessage( wxString::Format(
_(
"\n** Error exporting %s file. Export aborted. **\n" ),
775 ReportMessage( wxString::Format(
_(
"\n** Error exporting %s file. Export aborted. **\n" ),
786 msg = wxString::Format(
_(
"Unable to create %s file.\n"
787 "Check that the board has a valid outline and models." ),
792 msg = wxString::Format(
_(
"%s file has been created, but there are warnings." ),
801 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.
BASE_SET & set(size_t pos)
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.
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.
bool m_IncludeUnspecified
wxString m_ComponentFilter
wxString GetFormatName() const
wxString GetDefaultExportExtension() const
void buildZones3DShape(VECTOR2D aOrigin)
std::map< PCB_LAYER_ID, SHAPE_POLY_SET > m_poly_holes
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 buildBoard3DShapes()
std::unique_ptr< STEP_PCB_MODEL > m_pcbModel
std::map< PCB_LAYER_ID, SHAPE_POLY_SET > m_poly_shapes
bool buildTrack3DShape(PCB_TRACK *aTrack, VECTOR2D aOrigin)
KIGFX::COLOR4D m_copperColor
KIGFX::COLOR4D m_padColor
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.
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.
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
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 TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc) const
Function TransformTextToPolySet Convert the text to a polygonSet describing the actual character stro...
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.
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset difference For aFastMode meaning, see function booleanOp.
void ClearArcs()
Removes all arc references from all the outlines and holes in the polyset.
int FullPointCount() const
Return the number of points in the shape poly set.
void BooleanIntersection(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset intersection For aFastMode meaning, see function booleanOp.
std::vector< SHAPE_LINE_CHAIN > POLYGON
represents a single polygon outline with holes.
void Simplify(POLYGON_MODE aFastMode)
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFastMo...
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.
void TransformToPolygon(SHAPE_POLY_SET &aBuffer, int aError, ERROR_LOC aErrorLoc) const override
Fills a SHAPE_POLY_SET with a polygon representation of this shape.
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.
bool IsInnerCopperLayer(int aLayerId)
Tests whether a layer is an inner (In1_Cu to In30_Cu) 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
constexpr int mmToIU(double mm) const
wxLogTrace helper definitions.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_TABLE_T
class PCB_TABLE, table of PCB_TABLECELLs
Definition of file extensions used in Kicad.