45 return iu / 1e9 / 0.0254;
62 return m_type == PAD_ATTRIB::NPTH ||
m_type == PAD_ATTRIB::PTH;
106 return outLayers.none();
130 virtual bool Run()
override;
154 case PAD_SHAPE::CIRCLE:
155 case PAD_SHAPE::OVAL:
159 case PAD_SHAPE::ROUNDRECT:
163 case PAD_SHAPE::RECTANGLE:
171 "Hyperlynx exporter (supported shapes are oval, rectangle, "
172 "rounded rectangle, and circle)." ),
182 snprintf( buf,
sizeof( buf ),
"%d, %.9f, %.9f, %.1f, M",
206 std::map<BOARD_ITEM*, HYPERLYNX_PAD_STACK*>
m_padMap;
208 std::shared_ptr<FILE_OUTPUTFORMATTER>
m_out;
247 m_out->Print( 0,
"{VERSION=2.14}\n" );
248 m_out->Print( 0,
"{UNITS=ENGLISH LENGTH}\n\n" );
258 if( outLayers.none() )
263 if( outLayers == layerMask )
271 m_out->Print( 1,
"(\"%s\", %s)\n",
277 m_out->Print( 0,
"}\n\n" );
289 wxLogError(
_(
"Board outline is malformed. Run DRC for a full analysis." ) );
300 m_out->Print( 1,
"(PERIMETER_SEGMENT X1=%.9f Y1=%.9f X2=%.9f Y2=%.9f)\n",
308 m_out->Print( 0,
"}\n\n" );
329 m_out->Print( 0,
"{STACKUP\n" );
338 int plating_thickness = 0;
339 double resistivity = 1.724e-8;
340 m_out->Print( 1,
"(SIGNAL T=%g P=%g C=%g L=\"%.20s\" M=COPPER)\n",
341 iu2hyp( item->GetThickness( 0 ) ),
342 iu2hyp( plating_thickness ),
348 if( item->GetSublayersCount() < 2 )
350 m_out->Print( 1,
"(DIELECTRIC T=%g C=%g L=\"DE_%.17s\" M=\"%.20s\")\n",
351 iu2hyp( item->GetThickness( 0 ) ),
352 item->GetEpsilonR( 0 ),
354 TO_UTF8( item->GetMaterial( 0 ) ) );
356 else for(
int idx = 0; idx < item->GetSublayersCount(); idx++ )
358 m_out->Print( 1,
"(DIELECTRIC T=%g C=%g L=\"DE%d_%.16s\" M=\"%.20s\")\n",
359 iu2hyp( item->GetThickness( idx ) ),
360 item->GetEpsilonR( idx ),
363 TO_UTF8( item->GetMaterial( idx ) ) );
368 m_out->Print( 0,
"}\n\n" );
376 m_out->Print( 0,
"{DEVICES\n" );
380 wxString ref = footprint->GetReference();
384 ref = wxT(
"EMPTY" );
386 m_out->Print( 1,
"(? REF=\"%s\" L=\"%s\")\n",
387 (
const char*) ref.c_str(),
388 (
const char*) layerName.c_str() );
390 m_out->Print( 0,
"}\n\n" );
400 for(
PAD*
pad : footprint->Pads() )
409 if(
PCB_VIA*
via = dyn_cast<PCB_VIA*>( track ) )
427 if(
PAD*
pad = dyn_cast<PAD*>( item ) )
433 wxString ref =
pad->GetParentFootprint()->GetReference();
436 ref = wxT(
"EMPTY" );
438 wxString padName =
pad->GetNumber();
440 if( padName.IsEmpty() )
441 padName = wxT(
"1" );
444 m_out->Print( 1,
"(PIN X=%.10f Y=%.10f R=\"%s.%s\" P=%d)\n",
447 (
const char*) ref.c_str(),
448 (
const char*) padName.c_str(),
449 pstackIter->second->GetId() );
452 else if(
PCB_VIA*
via = dyn_cast<PCB_VIA*>( item ) )
458 m_out->Print( 1,
"(VIA X=%.10f Y=%.10f P=%d)\n",
461 pstackIter->second->GetId() );
464 else if(
PCB_TRACK* track = dyn_cast<PCB_TRACK*>( item ) )
468 m_out->Print( 1,
"(SEG X1=%.10f Y1=%.10f X2=%.10f Y2=%.10f W=%.10f L=\"%s\")\n",
469 iu2hyp( track->GetStart().x ),
470 iu2hyp( track->GetStart().y ),
471 iu2hyp( track->GetEnd().x ),
472 iu2hyp( track->GetEnd().y ),
473 iu2hyp( track->GetWidth() ),
474 (
const char*) layerName.c_str() );
476 else if(
PCB_ARC* arc = dyn_cast<PCB_ARC*>( item ) )
483 std::swap( start, end );
485 m_out->Print( 1,
"(ARC X1=%.10f Y1=%.10f X2=%.10f Y2=%.10f XC=%.10f YC=%.10f R=%.10f W=%.10f L=\"%s\")\n",
490 iu2hyp( arc->GetCenter().x ),
491 iu2hyp( arc->GetCenter().y ),
492 iu2hyp( arc->GetRadius() ),
493 iu2hyp( arc->GetWidth() ),
494 (
const char*) layerName.c_str() );
496 else if(
ZONE* zone = dyn_cast<ZONE*>( item ) )
510 m_out->Print( 1,
"{POLYGON T=POUR L=\"%s\" ID=%d X=%.10f Y=%.10f\n",
511 (
const char*) layerName.c_str(),
518 m_out->Print( 2,
"(LINE X=%.10f Y=%.10f)\n",
524 m_out->Print( 1,
"}\n" );
526 for(
int h = 0; h < fill.
HoleCount( i ); h++ )
531 m_out->Print( 1,
"{POLYVOID ID=%d X=%.10f Y=%.10f\n",
536 for(
int v = 0; v < holeShape.
PointCount(); v++ )
538 m_out->Print( 2,
"(LINE X=%.10f Y=%.10f)\n",
543 m_out->Print( 2,
"(LINE X=%.10f Y=%.10f)\n",
546 m_out->Print( 1,
"}\n" );
561 std::vector<BOARD_ITEM*> rv;
569 if( item->GetNetCode() == netcode || ( netcode < 0 && item->GetNetCode() <= 0 ) )
577 for(
PAD*
pad : footprint->Pads() )
587 rv.push_back( item );
593 rv.push_back( zone );
606 int netcode = netInfo->GetNetCode();
607 bool isNullNet = netInfo->GetNetCode() <= 0 || netInfo->GetNetname().IsEmpty();
614 if( netObjects.size() )
616 m_out->Print( 0,
"{NET=\"%s\"\n", (
const char*) netInfo->GetNetname().c_str() );
618 m_out->Print( 0,
"}\n\n" );
628 m_out->Print( 0,
"{NET=\"EmptyNet%d\"\n", idx );
630 m_out->Print( 0,
"}\n\n" );
667 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 Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
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.
Handle the data for a net.
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
const VECTOR2I & GetDrillSize() const
PAD_SHAPE GetShape() const
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
const VECTOR2I & GetSize() const
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.