51#include <Message_PrinterOStream.hxx>
52#include <Standard_Failure.hxx>
54#include <Standard_Version.hxx>
60#define OCC_VERSION_MIN 0x070500
62#if OCC_VERSION_HEX < OCC_VERSION_MIN
63#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 wxString msg( theString.ToCString() );
93#if OCC_VERSION_HEX < OCC_VERSION_MIN
127 m_reporter( aReporter ),
129 m_pcbModel( nullptr )
149 m_resolver = std::make_unique<FILENAME_RESOLVER>();
165 bool hasdata =
false;
166 std::vector<PAD*> padsMatchingNetFilter;
172 bool castellated =
pad->GetProperty() == PAD_PROP::CASTELLATED;
173 std::shared_ptr<SHAPE_SEGMENT> holeShape =
pad->GetEffectiveHoleShape();
183 if(
pad->IsOnLayer( pcblayer ) )
191 if(
m_pcbModel->AddHole( *holeShape, platingThickness,
F_Cu,
B_Cu,
false, aOrigin,
true,
211 castellated ? aClipPolygon :
nullptr) )
223 pad->TransformShapeToPolygon( poly, cuLayer,
224 pad->GetSolderMaskExpansion( cuLayer ), maxError,
232 padsMatchingNetFilter.push_back(
pad );
254 std::map<const SHAPE_POLY_SET::POLYGON*, PAD*> polyPadMap;
259 for(
PAD*
pad : padsMatchingNetFilter )
261 if( !
pad->IsOnLayer( pcblayer ) )
264 std::shared_ptr<SHAPE_POLY_SET> padPoly =
pad->GetEffectivePolygon( pcblayer );
267 if( padPoly->Collide( &gfxPoly ) )
269 polyPadMap[&poly] =
pad;
281 auto it = polyPadMap.find( &poly );
283 if( it == polyPadMap.end() )
303 wxString footprintBasePath = wxEmptyString;
317 footprintBasePath = fpRow->
GetFullURI(
true );
332 std::vector<wxString> componentFilterPatterns;
334 if( componentFilter )
338 while( tokenizer.HasMoreTokens() )
339 componentFilterPatterns.push_back( tokenizer.GetNextToken().Trim(
false ) );
343 for(
const wxString& pattern : componentFilterPatterns )
360 if( !fp_model.m_Show || fp_model.m_Filename.empty() )
363 std::vector<wxString> searchedPaths;
364 std::vector<const EMBEDDED_FILES*> embeddedFilesStack;
368 wxString mname =
m_resolver->ResolvePath( fp_model.m_Filename, footprintBasePath, embeddedFilesStack );
370 if( mname.empty() || !wxFileName::FileExists( mname ) )
374 mname = fp_model.m_Filename;
377 "File not found: %s\n" ),
384 std::string fname( mname.ToUTF8() );
385 std::string refName( aFootprint->
GetReference().ToUTF8() );
391 VECTOR3D modelRot = fp_model.m_Rotation;
395 if(
m_pcbModel->AddComponent( fname, refName, bottomSide,
398 fp_model.m_Offset, modelRot,
404 catch(
const Standard_Failure& e )
407 "OpenCASCADE error: %s\n" ),
409 e.GetMessageString() ),
443 std::shared_ptr<SHAPE_SEGMENT> holeShape =
via->GetEffectiveHoleShape();
453 via->LayerPair( &top_layer, &bot_layer );
459 const std::shared_ptr<SHAPE>& shape =
via->GetEffectiveShape( pcblayer );
467 m_pcbModel->AddBarrel( *holeShape, top_layer, bot_layer,
true, aOrigin,
via->GetNetname() );
502 LSET layers = zone->GetLayerSet();
513 zone->TransformSolidAreasShapesToPolygon( layer, fill_shape );
518 m_poly_shapes[layer][zone->GetNetname()].Append( fill_shape );
539 switch( aItem->
Type() )
553 if( lineStyle == LINE_STYLE::SOLID )
567 for(
SHAPE* shape : shapes )
572 SHAPE_SEGMENT seg( a, b, graphic->GetWidth() );
573 seg.TransformToPolygon( m_poly_shapes[pcblayer][graphic->GetNetname()],
574 maxError, ERROR_INSIDE );
578 for(
SHAPE* shape : shapes )
604 text->TransformTextToPolySet(
m_poly_shapes[pcblayer][wxEmptyString], 0, maxError,
616 textbox->PCB_SHAPE::TransformShapeToPolygon(
m_poly_shapes[pcblayer][wxEmptyString],
632 cell->TransformTextToPolySet(
m_poly_shapes[pcblayer][wxEmptyString], 0, maxError,
647 default: wxFAIL_MSG(
"buildGraphic3DShape: unhandled item type" );
661 m_pcbModel->SpecializeVariant( OUTPUT_FORMAT::FMT_OUT_STEP );
665 m_pcbModel->SpecializeVariant( OUTPUT_FORMAT::FMT_OUT_BREP );
669 m_pcbModel->SpecializeVariant( OUTPUT_FORMAT::FMT_OUT_XAO );
673 m_pcbModel->SpecializeVariant( OUTPUT_FORMAT::FMT_OUT_GLTF );
677 m_pcbModel->SpecializeVariant( OUTPUT_FORMAT::FMT_OUT_PLY );
681 m_pcbModel->SpecializeVariant( OUTPUT_FORMAT::FMT_OUT_STL );
685 m_pcbModel->SpecializeVariant( OUTPUT_FORMAT::FMT_OUT_UNKNOWN );
702 wxLogWarning(
_(
"Board outline is malformed. Run DRC for a full analysis." ) );
780 m_pcbModel->AddPolygonShapes( &mask, pcblayer, origin, wxEmptyString );
792 poly.BooleanSubtract( holes );
795 poly.BooleanIntersection( pcbOutlinesNoArcs );
797 m_pcbModel->AddPolygonShapes( &poly, pcblayer, origin, netname );
804 m_reporter->
Report( wxString::Format( wxT(
"Board outline: found %d initial points.\n" ),
824 Message::DefaultMessenger()->RemovePrinters( STANDARD_TYPE( Message_PrinterOStream ) );
832 fn.SetName( fn.GetName() );
865 "** Error building STEP board model. Export aborted. **\n" ),
890 "** Error writing %s file. **\n" ),
903 catch(
const Standard_Failure& e )
907 "** Error exporting %s file. Export aborted. **\n" ),
915 "** Error exporting %s file. Export aborted. **\n" ),
924 "Export time %.3f s\n" ),
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
const VECTOR2I & GetAuxOrigin() const
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...
EMBEDDED_FILES * GetEmbeddedFiles() override
const ZONES & Zones() const
const FOOTPRINTS & Footprints() const
const TRACKS & Tracks() const
const wxString & GetFileName() const
const PCB_PLOT_PARAMS & GetPlotOptions() const
PROJECT * GetProject() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
const DRAWINGS & Drawings() const
KICAD_T Type() const
Returns the type of object.
const SHAPE_POLY_SET & GetHatching() const
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
bool IsHatchedFill() const
LINE_STYLE GetLineStyle() const
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)
bool buildFootprint3DShapes(FOOTPRINT *aFootprint, VECTOR2D aOrigin, SHAPE_POLY_SET *aClipPolygon)
EXPORTER_STEP_PARAMS m_params
wxString m_pcbBaseName
the name of the project (board short filename (no path, no ext) used to identify items in step file
std::unique_ptr< FILENAME_RESOLVER > m_resolver
bool buildBoard3DShapes()
std::unique_ptr< STEP_PCB_MODEL > m_pcbModel
std::map< PCB_LAYER_ID, std::map< wxString, SHAPE_POLY_SET > > m_poly_shapes
bool buildTrack3DShape(PCB_TRACK *aTrack, VECTOR2D aOrigin)
KIGFX::COLOR4D m_copperColor
EXPORTER_STEP(BOARD *aBoard, const EXPORTER_STEP_PARAMS &aParams, REPORTER *aReporter)
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...
virtual void Send(const TCollection_ExtendedString &theString, const Message_Gravity theGravity, const Standard_Boolean theToPutEol) const override
SEVERITY getSeverity(const Message_Gravity theGravity) const
KICAD_PRINTER(REPORTER *aReporter)
virtual void Send(const TCollection_AsciiString &theString, const Message_Gravity theGravity, const Standard_Boolean theToPutEol) const override
A color representation with 4 components: red, green, blue, alpha.
PCB specific render settings.
void SetGapLengthRatio(double aRatio)
void SetDashLengthRatio(double aRatio)
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 AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
static const LSET & ExternalCuMask()
Return a mask holding the Front and Bottom layers.
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
static const LSET & InternalCuMask()
Return a complete set of internal copper layers which is all Cu layers except F_Cu and B_Cu.
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
Parameters and options when plotting/printing a board.
double GetDashedLineGapRatio() const
double GetDashedLineDashRatio() const
int GetWidth() const override
int GetSolderMaskExpansion() const
void TransformShapeToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc) const override
Convert the item shape to a polyset.
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.
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
bool IsBorderEnabled() const
Disables the border, this is done by changing the stroke internally.
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...
int GetSolderMaskExpansion() const
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.
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
static FP_LIB_TABLE * PcbFootprintLibs(PROJECT *aProject)
Return the table of footprint libraries without Kiway.
A pure virtual class used to derive REPORTER objects from.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
virtual bool HasMessageOfSeverity(int aSeverityMask) const
Returns true if the reporter has one or more messages matching the specified severity mask.
Represent a set of closed polygons.
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 Simplify()
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections)
std::vector< SHAPE_LINE_CHAIN > POLYGON
represents a single polygon outline with holes.
void Unfracture()
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 Deflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError)
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.
void BooleanSubtract(const SHAPE_POLY_SET &b)
Perform boolean polyset difference.
const std::vector< POLYGON > & CPolygons() const
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.
An abstract shape on 2D plane.
Simple container to manage line stroke parameters.
static void Stroke(const SHAPE *aShape, LINE_STYLE aLineStyle, int aWidth, const KIGFX::RENDER_SETTINGS *aRenderSettings, const std::function< void(const VECTOR2I &a, const VECTOR2I &b)> &aStroker)
Handle a list of polygons defining a copper zone.
static const std::string AutoSaveFilePrefix
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
bool IsInnerCopperLayer(int aLayerId)
Test 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 ...
LINE_STYLE
Dashed line types.
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.