46 return iu / 1e9 / 0.0254;
63 return m_type == PAD_ATTRIB::NPTH ||
m_type == PAD_ATTRIB::PTH;
107 return outLayers.none();
131 virtual bool Run()
override;
155 case PAD_SHAPE::CIRCLE:
156 case PAD_SHAPE::OVAL:
160 case PAD_SHAPE::ROUNDRECT:
164 case PAD_SHAPE::RECTANGLE:
172 "Hyperlynx exporter (supported shapes are oval, rectangle, "
173 "rounded rectangle, and circle)." ),
183 snprintf( buf,
sizeof( buf ),
"%d, %.9f, %.9f, %.1f, M",
207 std::map<BOARD_ITEM*, HYPERLYNX_PAD_STACK*>
m_padMap;
209 std::shared_ptr<FILE_OUTPUTFORMATTER>
m_out;
249 m_out->Print( 0,
"{VERSION=2.14}\n" );
250 m_out->Print( 0,
"{UNITS=ENGLISH LENGTH}\n\n" );
260 if( outLayers.none() )
265 if( outLayers == layerMask )
273 m_out->Print( 1,
"(\"%s\", %s)\n",
279 m_out->Print( 0,
"}\n\n" );
291 wxLogError(
_(
"Board outline is malformed. Run DRC for a full analysis." ) );
302 m_out->Print( 1,
"(PERIMETER_SEGMENT X1=%.9f Y1=%.9f X2=%.9f Y2=%.9f)\n",
310 m_out->Print( 0,
"}\n\n" );
331 m_out->Print( 0,
"{STACKUP\n" );
340 int plating_thickness = 0;
341 double resistivity = 1.724e-8;
342 m_out->Print( 1,
"(SIGNAL T=%g P=%g C=%g L=\"%.20s\" M=COPPER)\n",
343 iu2hyp( item->GetThickness( 0 ) ),
344 iu2hyp( plating_thickness ),
350 if( item->GetSublayersCount() < 2 )
352 m_out->Print( 1,
"(DIELECTRIC T=%g C=%g L=\"DE_%.17s\" M=\"%.20s\")\n",
353 iu2hyp( item->GetThickness( 0 ) ),
354 item->GetEpsilonR( 0 ),
356 TO_UTF8( item->GetMaterial( 0 ) ) );
358 else for(
int idx = 0; idx < item->GetSublayersCount(); idx++ )
360 m_out->Print( 1,
"(DIELECTRIC T=%g C=%g L=\"DE%d_%.16s\" M=\"%.20s\")\n",
361 iu2hyp( item->GetThickness( idx ) ),
362 item->GetEpsilonR( idx ),
365 TO_UTF8( item->GetMaterial( idx ) ) );
370 m_out->Print( 0,
"}\n\n" );
378 m_out->Print( 0,
"{DEVICES\n" );
382 wxString ref = footprint->GetReference();
386 ref = wxT(
"EMPTY" );
388 m_out->Print( 1,
"(? REF=\"%s\" L=\"%s\")\n",
389 (
const char*) ref.c_str(),
390 (
const char*) layerName.c_str() );
392 m_out->Print( 0,
"}\n\n" );
402 for(
PAD*
pad : footprint->Pads() )
411 if(
PCB_VIA*
via = dyn_cast<PCB_VIA*>( track ) )
429 if(
PAD*
pad = dyn_cast<PAD*>( item ) )
435 wxString ref =
pad->GetParentFootprint()->GetReference();
438 ref = wxT(
"EMPTY" );
440 wxString padName =
pad->GetNumber();
442 if( padName.IsEmpty() )
443 padName = wxT(
"1" );
446 m_out->Print( 1,
"(PIN X=%.10f Y=%.10f R=\"%s.%s\" P=%d)\n",
449 (
const char*) ref.c_str(),
450 (
const char*) padName.c_str(),
451 pstackIter->second->GetId() );
454 else if(
PCB_VIA*
via = dyn_cast<PCB_VIA*>( item ) )
460 m_out->Print( 1,
"(VIA X=%.10f Y=%.10f P=%d)\n",
463 pstackIter->second->GetId() );
466 else if(
PCB_TRACK* track = dyn_cast<PCB_TRACK*>( item ) )
470 m_out->Print( 1,
"(SEG X1=%.10f Y1=%.10f X2=%.10f Y2=%.10f W=%.10f L=\"%s\")\n",
471 iu2hyp( track->GetStart().x ),
472 iu2hyp( track->GetStart().y ),
473 iu2hyp( track->GetEnd().x ),
474 iu2hyp( track->GetEnd().y ),
475 iu2hyp( track->GetWidth() ),
476 (
const char*) layerName.c_str() );
478 else if(
PCB_ARC* arc = dyn_cast<PCB_ARC*>( item ) )
485 std::swap( start, end );
487 m_out->Print( 1,
"(ARC X1=%.10f Y1=%.10f X2=%.10f Y2=%.10f XC=%.10f YC=%.10f R=%.10f W=%.10f L=\"%s\")\n",
492 iu2hyp( arc->GetCenter().x ),
493 iu2hyp( arc->GetCenter().y ),
494 iu2hyp( arc->GetRadius() ),
495 iu2hyp( arc->GetWidth() ),
496 (
const char*) layerName.c_str() );
498 else if(
ZONE* zone = dyn_cast<ZONE*>( item ) )
512 m_out->Print( 1,
"{POLYGON T=POUR L=\"%s\" ID=%d X=%.10f Y=%.10f\n",
513 (
const char*) layerName.c_str(),
520 m_out->Print( 2,
"(LINE X=%.10f Y=%.10f)\n",
526 m_out->Print( 1,
"}\n" );
528 for(
int h = 0; h < fill.
HoleCount( i ); h++ )
533 m_out->Print( 1,
"{POLYVOID ID=%d X=%.10f Y=%.10f\n",
538 for(
int v = 0; v < holeShape.
PointCount(); v++ )
540 m_out->Print( 2,
"(LINE X=%.10f Y=%.10f)\n",
545 m_out->Print( 2,
"(LINE X=%.10f Y=%.10f)\n",
548 m_out->Print( 1,
"}\n" );
563 std::vector<BOARD_ITEM*> rv;
571 if( item->GetNetCode() == netcode || ( netcode < 0 && item->GetNetCode() <= 0 ) )
579 for(
PAD*
pad : footprint->Pads() )
589 rv.push_back( item );
595 rv.push_back( zone );
608 int netcode = netInfo->GetNetCode();
609 bool isNullNet = netInfo->GetNetCode() <= 0 || netInfo->GetNetname().IsEmpty();
616 if( netObjects.size() )
618 m_out->Print( 0,
"{NET=\"%s\"\n", (
const char*) netInfo->GetNetname().c_str() );
620 m_out->Print( 0,
"}\n\n" );
630 m_out->Print( 0,
"{NET=\"EmptyNet%d\"\n", idx );
632 m_out->Print( 0,
"}\n\n" );
669 return exporter.
Run();
@ BS_ITEM_TYPE_DIELECTRIC
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
LSET GetEnabledLayers() const
Return a bit-mask of all the layers that are enabled.
BOARD_STACKUP & GetStackupDescriptor()
void SetOutputFilename(const wxFileName &aPath)
void SetBoard(BOARD *aBoard)
wxFileName m_outputFilePath
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Manage one layer needed to make a physical board.
Manage layers 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, bool aIncludeNPTHAsOutlines=false)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
const NETINFO_LIST & GetNetInfo() const
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
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
virtual bool Run() override
void writeSinglePadStack(HYPERLYNX_PAD_STACK &aStack)
const std::string formatPadShape(const HYPERLYNX_PAD_STACK &aStack)
std::vector< HYPERLYNX_PAD_STACK * > m_padStacks
std::map< BOARD_ITEM *, HYPERLYNX_PAD_STACK * > m_padMap
bool writeNetObjects(const std::vector< BOARD_ITEM * > &aObjects)
HYPERLYNX_PAD_STACK * addPadStack(HYPERLYNX_PAD_STACK stack)
std::shared_ptr< FILE_OUTPUTFORMATTER > m_out
const std::vector< BOARD_ITEM * > collectNetObjects(int netcode)
HYPERLYNX_PAD_STACK(BOARD *aBoard, const PAD *aPad)
bool operator==(const HYPERLYNX_PAD_STACK &other) const
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
LSET is a set of PCB_LAYER_IDs.
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
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.
Handle the data for a net.
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
const VECTOR2I & GetDrillSize() const
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
const VECTOR2I & GetSize(PCB_LAYER_ID aLayer) const
int GetWidth() const override
int GetDrillValue() const
Calculate the drill value for vias (m_drill if > 0, or default drill value for the board).
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
int PointCount() const
Return the number of points (vertices) in this line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
int SegmentCount() const
Return the number of segments in this line chain.
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.
Represent a set of closed polygons.
int HoleCount(int aOutline) const
Returns the number of holes in a given outline.
void Simplify(POLYGON_MODE aFastMode)
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFastMo...
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
int OutlineCount() const
Return the number of outlines in the set.
SHAPE_POLY_SET CloneDropTriangulation() const
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
Handle a list of polygons defining a copper zone.
static double iu2hyp(double iu)
bool ExportBoardToHyperlynx(BOARD *aBoard, const wxFileName &aPath)
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.