70#define EXPORT_CUSTOM_PADS_CONVEX_HULL
97 errorText = ioe.
What();
106 SetStatusText( wxString(
_(
"BOARD exported OK." ) ) );
118 db.
SetPCB( SPECCTRA_DB::MakePCB() );
124 wxLogWarning(
_(
"Board outline is malformed. Run DRC for a full analysis." ) );
157static inline double scale(
int kicadDist )
165static inline double IU2um(
int kicadDist )
171static inline double mapX(
int x )
177static inline double mapY(
int y )
225 path->AppendPoint( aStart );
226 path->AppendPoint( aEnd );
227 path->SetLayerId( aLayerName.c_str() );
241 std::string uniqifier;
248 int reportedLayers = 0;
255 bool onAllCopperLayers = ( (aPad->
GetLayerSet() & all_cu) == all_cu );
257 if( onAllCopperLayers )
262 for(
int layer=0; layer<copperCount; ++layer )
266 if( onAllCopperLayers || aPad->
IsOnLayer( kilayer ) )
268 layerName[reportedLayers++] =
m_layerIds[layer].c_str();
270 if( !onAllCopperLayers )
274 else if( layer == copperCount - 1 )
277 uniqifier += char(
'0' + layer);
292 dsnOffset =
mapPt( offset );
295 sprintf( offsetTxt,
"[%.6g,%.6g]", dsnOffset.
x, dsnOffset.
y );
297 uniqifier += offsetTxt;
306 for(
int ndx = 0; ndx < reportedLayers; ++ndx )
310 padstack->
Append( shape );
321 snprintf(
name,
sizeof(
name),
"Round%sPad_%.6g_um",
335 POINT lowerLeft( -dx, -dy );
336 POINT upperRight( dx, dy );
338 lowerLeft += dsnOffset;
339 upperRight += dsnOffset;
341 for(
int ndx = 0; ndx < reportedLayers; ++ndx )
345 padstack->
Append( shape );
355 snprintf(
name,
sizeof(
name ),
"Rect%sPad_%.6gx%.6g_um", uniqifier.c_str(),
377 pstart =
POINT( -dr, 0.0 );
378 pstop =
POINT( dr, 0.0 );
385 pstart =
POINT( 0.0, -dr );
386 pstop =
POINT( 0.0, dr );
392 for(
int ndx = 0; ndx < reportedLayers; ++ndx )
398 shape =
new SHAPE( padstack );
400 padstack->
Append( shape );
403 path->aperture_width = 2.0 * radius;
406 snprintf(
name,
sizeof(
name ),
"Oval%sPad_%.6gx%.6g_um", uniqifier.c_str(),
423 POINT lowerLeft( -dx - ddy, -dy - ddx );
424 POINT upperLeft( -dx + ddy, +dy + ddx );
425 POINT upperRight( +dx - ddy, +dy - ddx );
426 POINT lowerRight( +dx + ddy, -dy + ddx );
428 lowerLeft += dsnOffset;
429 upperLeft += dsnOffset;
430 upperRight += dsnOffset;
431 lowerRight += dsnOffset;
433 for(
int ndx = 0; ndx < reportedLayers; ++ndx )
437 padstack->
Append( shape );
440 PATH* polygon =
new PATH( shape, T_polygon );
453 snprintf(
name,
sizeof(
name ),
"Trapz%sPad_%.6gx%.6g_%c%.6gx%c%.6g_um", uniqifier.c_str(),
467 const int circleToSegmentsCount = 36;
479 double correctionFactor = cos( M_PI / (
double) circleToSegmentsCount );
480 int extra_clearance =
KiROUND( rradius * ( 1.0 - correctionFactor ) );
482 psize.
x += extra_clearance * 2;
483 psize.
y += extra_clearance * 2;
484 rradius += extra_clearance;
495 for(
int ndx = 0; ndx < reportedLayers; ++ndx )
499 padstack->
Append( shape );
502 PATH* polygon =
new PATH( shape, T_polygon );
511 for(
int idx = 0; idx < polygonal_shape.
PointCount(); idx++ )
519 first_corner = corner;
526 snprintf(
name,
sizeof(
name ),
"RoundRect%sPad_%.6gx%.6g_%.6g_um_%f_%X", uniqifier.c_str(),
539 std::vector<VECTOR2I> polygonal_shape;
543#ifdef EXPORT_CUSTOM_PADS_CONVEX_HULL
548 for(
int ii = 0; ii < p_outline.
PointCount(); ++ii )
549 polygonal_shape.push_back( wxPoint( p_outline.
CPoint( ii ) ) );
553 if( polygonal_shape.front() != polygonal_shape.back() )
554 polygonal_shape.push_back( polygonal_shape.front() );
556 for(
int ndx = 0; ndx < reportedLayers; ++ndx )
560 padstack->
Append( shape );
563 PATH* polygon =
new PATH( shape, T_polygon );
569 for(
unsigned idx = 0; idx < polygonal_shape.size(); idx++ )
571 POINT corner(
scale( polygonal_shape[idx].x ),
scale( -polygonal_shape[idx].y ) );
580 snprintf(
name,
sizeof(
name ),
"Cust%sPad_%.6gx%.6g_%.6gx_%.6g_%d_um_%s",
583 hash.
Format(
true ).c_str() );
614 for(
int p = 0; p < fpItems.
GetCount(); ++p )
621 double diameter =
scale(
pad->GetDrillSize().x );
626 for(
int layer=0; layer<layerCount; ++layer )
630 image->keepouts.push_back( keepout );
647 if( !mask_copper_layers.any() )
651 PADSTACKSET::iterator iter =
m_padstackset.find( *padstack );
657 padstack = (
PADSTACK*) *iter.base();
666 padNumber =
pad->GetNumber();
669 if( padNumber != wxEmptyString && pinmap.find( padNumber ) == pinmap.end() )
671 pinmap[ padNumber ] = 0;
676 int duplicates = ++pinmap[ padNumber ];
678 sprintf( buf,
"@%d", duplicates );
683 pin->kiNetCode =
pad->GetNetCode();
690 pin->SetRotation(
angle.Normalize().AsDegrees() );
701 for(
int i = 0; i < fpItems.
GetCount(); ++i )
712 image->Append( outline );
717 path->SetLayerId(
"signal" );
727 image->Append( outline );
733 path->SetLayerId(
"signal" );
742 for(
int ii = 0; ii < polyline.
PointCount(); ++ii )
755 image->Append( outline );
760 path->SetLayerId(
"signal" );
782 image->Append( outline );
786 path->SetAperture( 0 );
787 path->SetLayerId(
"signal" );
807 arcAngle = -arcAngle;
826 for(
int ii = polyline.
PointCount() - 1; ii >= 0; --ii )
844 for(
int ii = 0; ii < poly.
PointCount(); ++ii )
860 if( !zone->GetIsRuleArea() )
864 ZONE untransformedZone( *zone );
876 if( zone->GetDoNotAllowVias() && zone->GetDoNotAllowTracks() )
877 keepout_type = T_keepout;
878 else if( zone->GetDoNotAllowVias() )
879 keepout_type = T_via_keepout;
880 else if( zone->GetDoNotAllowTracks() )
881 keepout_type = T_wire_keepout;
883 keepout_type = T_keepout;
889 for(
int layer = 0; layer < copperCount; layer++ )
891 if( layer == copperCount-1 )
898 image->keepouts.push_back( keepout );
900 PATH* mainPolygon =
new PATH( keepout, T_polygon );
907 bool is_first_point =
true;
910 for( iterator = untransformedZone.
IterateWithHoles(); iterator; iterator++ )
912 VECTOR2I point( iterator->x, iterator->y );
919 is_first_point =
false;
933 PATH* cutout =
nullptr;
934 bool isStartContour =
true;
937 for( iterator++; iterator; iterator++ )
941 is_first_point =
true;
942 window =
new WINDOW( keepout );
945 cutout =
new PATH( window, T_polygon );
957 VECTOR2I point( iterator->x, iterator->y );
964 is_first_point =
false;
981 int aTopLayer,
int aBotLayer )
985 double dsnDiameter =
scale( aCopperDiameter );
987 for(
int layer=aTopLayer; layer<=aBotLayer; ++layer )
991 padstack->
Append( shape );
1001 snprintf(
name,
sizeof(
name ),
"Via[%d-%d]_%.6g:%.6g_um",
1002 aTopLayer, aBotLayer, dsnDiameter,
1004 IU2um( aDrillDiameter ) );
1018 aVia->
LayerPair( &topLayerNum, &botLayerNum );
1023 if( topLayer > botLayer )
1024 std::swap( topLayer, botLayer );
1036 path->layer_id =
"pcb";
1040 for(
int ii = 0; ii < outline.
PointCount(); ii++ )
1055 PATH* poly_ko =
new PATH(
nullptr, T_polygon );
1063 for(
int jj = 0; jj < hole.
PointCount(); jj++ )
1092 if( footprint->GetReference() == wxEmptyString )
1095 "reference designator." ),
1096 footprint->GetValue() ) );
1102 if( !refpair.second )
1105 "designator '%s'." ),
1106 footprint->GetReference() ) );
1123 for(
int pcbNdx=0; pcbNdx<layerCount; ++pcbNdx )
1136 case LT_SIGNAL: layerType = T_signal;
break;
1137 case LT_POWER: layerType = T_power;
break;
1141 case LT_MIXED: layerType = T_signal;
break;
1142 case LT_JUMPER: layerType = T_jumper;
break;
1149 property->name =
"index";
1151 sprintf( temp,
"%d", pcbNdx );
1152 property->value = temp;
1182 int defaultTrackWidth = netSettings->m_DefaultNetClass->GetTrackWidth();
1183 int defaultClearance = netSettings->m_DefaultNetClass->GetClearance();
1184 double clearance =
scale( defaultClearance );
1188 sprintf( rule,
"(width %.6g)",
scale( defaultTrackWidth ) );
1189 rules.push_back( rule );
1191 sprintf( rule,
"(clearance %.6g)", clearance +
safetyMargin );
1192 rules.push_back( rule );
1202 if( default_smd <= 6.0 )
1205 sprintf( rule,
"(clearance %.6g (type default_smd))", default_smd );
1207 rules.push_back( rule );
1212 clearance =
scale( defaultClearance ) / 4;
1214 sprintf( rule,
"(clearance %.6g (type smd_smd))", clearance );
1215 rules.push_back( rule );
1221 int netlessZones = 0;
1225 if( zone->GetIsRuleArea() )
1236 PATH* mainPolygon =
new PATH( plane, T_polygon );
1241 if( plane->
name.size() == 0 )
1249 sprintf(
name,
"@:no_net_%d", netlessZones++ );
1264 bool is_first_point =
true;
1266 for( iterator = zone->IterateWithHoles(); iterator; iterator++ )
1268 VECTOR2I point( iterator->x, iterator->y );
1270 if( is_first_point )
1273 is_first_point =
false;
1290 bool isStartContour =
true;
1293 for( iterator++; iterator; iterator++ )
1295 if( isStartContour )
1297 is_first_point =
true;
1298 window =
new WINDOW( plane );
1301 cutout =
new PATH( window, T_polygon );
1313 VECTOR2I point( iterator->x, iterator->y );
1315 if( is_first_point )
1318 is_first_point =
false;
1334 if( !zone->GetIsRuleArea() )
1342 if( zone->GetDoNotAllowVias() && zone->GetDoNotAllowTracks() )
1343 keepout_type = T_keepout;
1344 else if( zone->GetDoNotAllowVias() )
1345 keepout_type = T_via_keepout;
1346 else if( zone->GetDoNotAllowTracks() )
1347 keepout_type = T_wire_keepout;
1349 keepout_type = T_keepout;
1355 for(
int layer = 0; layer < copperCount; layer++ )
1357 if( layer == copperCount - 1 )
1366 PATH* mainPolygon =
new PATH( keepout, T_polygon );
1373 bool is_first_point =
true;
1376 for( iterator = zone->IterateWithHoles(); iterator; iterator++ )
1378 VECTOR2I point( iterator->x, iterator->y );
1380 if( is_first_point )
1383 is_first_point =
false;
1396 WINDOW* window =
nullptr;
1397 PATH* cutout =
nullptr;
1399 bool isStartContour =
true;
1402 for( iterator++; iterator; iterator++ )
1404 if( isStartContour )
1406 is_first_point =
true;
1407 window =
new WINDOW( keepout );
1410 cutout =
new PATH( window, T_polygon );
1420 VECTOR2I point( iterator->x, iterator->y );
1422 if( is_first_point )
1425 is_first_point =
false;
1441 std::string componentId;
1442 int highestNetCode = 0;
1447 highestNetCode = std::max( highestNetCode, i->GetNetCode() );
1452 m_nets.resize( highestNetCode + 1,
nullptr );
1454 for(
unsigned i = 1 ; i <
m_nets.size(); ++i )
1459 if( i->GetNetCode() > 0 )
1460 m_nets[i->GetNetCode()]->net_id =
TO_UTF8( i->GetNetname() );
1469 componentId =
TO_UTF8( footprint->GetReference() );
1477 for(
unsigned p = 0; p <
image->pins.size(); ++p )
1480 int netcode =
pin->kiNetCode;
1508 comp->
places.push_back( place );
1510 place->
SetRotation( footprint->GetOrientationDegrees() );
1516 if( footprint->GetFlag() )
1521 place->
side = T_back;
1537 for(
unsigned n = 1; n <
m_nets.size(); ++n )
1541 if( net->
pins.size() )
1563 netSettings->m_DefaultNetClass->GetViaDrill(),
1576 for(
const auto& [
name, netclass ] : netSettings->m_NetClasses )
1578 via =
makeVia( netclass->GetViaDiameter(), netclass->GetViaDrill(),
1592 std::string netname;
1596 int old_netcode = -1;
1602 if( !track->IsType( { PCB_TRACE_T, PCB_ARC_T } ) )
1605 int netcode = track->GetNetCode();
1610 if( old_netcode != netcode
1611 || old_width != track->GetWidth()
1612 || old_layer != track->GetLayer()
1613 || (
path &&
path->points.back() !=
mapPt( track->GetStart() ) ) )
1615 old_width = track->GetWidth();
1616 old_layer = track->GetLayer();
1618 if( old_netcode != netcode )
1620 old_netcode = netcode;
1628 wiring->
wires.push_back( wire );
1631 if( track->IsLocked() )
1636 int kiLayer = track->GetLayer();
1642 path->aperture_width =
scale( old_width );
1643 path->AppendPoint(
mapPt( track->GetStart() ) );
1647 path->AppendPoint(
mapPt( track->GetEnd() ) );
1660 int netcode =
via->GetNetCode();
1685 if(
via->IsLocked() )
1710 for(
const auto& [
name, netclass ] : netSettings->m_NetClasses )
1757 if( net->GetNetClass()->GetName() == clazz->
class_id )
1761 clazz->
rules =
new RULE( clazz, T_rule );
1764 int trackWidth = aNetClass->GetTrackWidth();
1765 sprintf(
text,
"(width %.6g)",
scale( trackWidth ) );
1769 int clearance = aNetClass->GetClearance();
1783 snprintf(
text,
sizeof(
text),
"(use_via %s)",
via->GetPadstackId().c_str() );
1797 footprint->SetFlag( 0 );
1799 if( footprint->GetLayer() ==
B_Cu )
1801 footprint->Flip( footprint->GetPosition(),
false );
1802 footprint->SetFlag( 1 );
1820 if( footprint->GetFlag() )
1822 footprint->Flip( footprint->GetPosition(),
false );
1823 footprint->SetFlag( 0 );
constexpr int ARC_HIGH_DEF
constexpr EDA_IU_SCALE pcbIUScale
Handles how to draw a screen (a board, a schematic ...)
bool IsContentModified() const
void SetContentModified(bool aModified=true)
std::shared_ptr< NET_SETTINGS > m_NetSettings
Information pertinent to a Pcbnew printed circuit board.
const NETINFO_LIST & GetNetInfo() const
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Return the type of the copper layer given by aLayer.
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
FOOTPRINTS & Footprints()
int GetCopperLayerCount() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
coord_type GetHeight() const
coord_type GetWidth() const
int GetCount() const
Return the number of objects in the list.
void SetLayerId(const char *aLayerId)
void SetVertex(const POINT &aVertex)
void SetDiameter(double aDiameter)
The <class_descriptor> in the specctra spec.
STRINGS circuit
circuit descriptor list
Implement a <component_descriptor> in the specctra dsn spec.
A <plane_descriptor> in the specctra dsn spec.
Used for <keepout_descriptor> and <plane_descriptor>.
void AddWindow(WINDOW *aWindow)
void SetShape(ELEM *aShape)
DSN_T layer_type
one of: T_signal, T_power, T_mixed, T_jumper
PADSTACK * LookupVia(PADSTACK *aVia)
Add the via only if one exactly like it does not already exist in the padstack container.
void AppendVia(PADSTACK *aVia)
Add aVia to the internal via container.
IMAGE * LookupIMAGE(IMAGE *aImage)
Add the image only if one exactly like it does not already exist in the image container.
void AddPadstack(PADSTACK *aPadstack)
A <net_descriptor> in the DSN spec.
Hold either a via or a pad definition.
void SetPadstackId(const char *aPadstackId)
bool space_in_quoted_tokens
Support both the <path_descriptor> and the <polygon_descriptor> per the specctra dsn spec.
void SetLayerId(const char *aLayerId)
void AppendPoint(const POINT &aPoint)
COMPONENT * LookupCOMPONENT(const std::string &imageName)
Look up a COMPONENT by name.
Implement a <placement_reference> in the specctra dsn spec.
void SetVertex(const POINT &aVertex)
std::string component_id
reference designator
void SetRotation(double aRotation)
void SetCorners(const POINT &aPoint0, const POINT &aPoint1)
void SetLayerId(const char *aLayerId)
A <rule_descriptor> in the specctra dsn spec.
STRINGS rules
rules are saved in std::string form.
A "(shape ..)" element in the specctra dsn spec.
A DSN data tree, usually coming from a DSN file.
int m_top_via_layer
specctra cu layers, 0 based index:
IMAGE * makeIMAGE(BOARD *aBoard, FOOTPRINT *aFootprint)
Allocates an I::MAGE on the heap and creates all the PINs according to the PADs in the FOOTPRINT.
void buildLayerMaps(BOARD *aBoard)
Create a few data translation structures for layer name and number mapping between the DSN::PCB struc...
void ExportPCB(const wxString &aFilename, bool aNameChange=false)
Write the internal PCB instance out as a SPECTRA DSN format file.
SHAPE_POLY_SET m_brd_outlines
void FlipFOOTPRINTs(BOARD *aBoard)
Flip the footprints which are on the back side of the board to the front.
STRINGS m_layerIds
indexed by PCB layer number
bool m_footprintsAreFlipped
void deleteNETs()
Delete all the NETs that may be in here.
void fillBOUNDARY(BOARD *aBoard, BOUNDARY *aBoundary)
Make the board perimeter for the DSN file by filling the BOUNDARY element in the specctra element tre...
PADSTACK * makePADSTACK(BOARD *aBoard, PAD *aPad)
Create a #PADSTACK which matches the given pad.
void SetPCB(PCB *aPcb)
Delete any existing PCB and replaces it with the given one.
static PCB * MakePCB()
Make a PCB with all the default ELEMs and parts on the heap.
std::vector< PCB_LAYER_ID > m_pcbLayer2kicad
maps PCB layer number to BOARD layer numbers
bool BuiltBoardOutlines(BOARD *aBoard)
Build the board outlines and store it in m_brd_outlines.
std::vector< int > m_kicadLayer2pcb
maps BOARD layer number to PCB layer numbers
PADSTACK * makeVia(int aCopperDiameter, int aDrillDiameter, int aTopLayer, int aBotLayer)
Make a round through hole #PADSTACK using the given KiCad diameter in deci-mils.
std::vector< NET * > m_nets
we don't want ownership here permanently, so we don't use boost::ptr_vector
PADSTACKSET m_padstackset
void exportNETCLASS(const std::shared_ptr< NETCLASS > &aNetClass, BOARD *aBoard)
Export aNetClass to the DSN file.
void FromBOARD(BOARD *aBoard)
Add the entire BOARD to the PCB but does not write it out.
void RevertFOOTPRINTs(BOARD *aBoard)
Flip the footprints which were on the back side of the board back to the back.
void SetBOUNDARY(BOUNDARY *aBoundary)
A <via_descriptor> in the specctra dsn spec.
void AppendVia(const char *aViaName)
void SetShape(ELEM *aShape)
A <wire_via_descriptor> in the specctra dsn spec.
A <wire_shape_descriptor> in the specctra dsn spec.
void SetShape(ELEM *aShape)
A <wiring_descriptor> in the specctra dsn spec.
EDA_ANGLE GetArcAngle() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
const VECTOR2I & GetEnd0() const
VECTOR2I GetCenter0() const
const VECTOR2I & GetStart0() const
A specialization of ZONE for use in footprints.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
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.
std::string Format(bool aCompactForm=false)
static const char Default[]
the name of the default NETCLASS
Handle the data for a net.
const wxString & GetNetname() const
Container for NETINFO_ITEM elements, which are the nets.
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
const VECTOR2I & GetDrillSize() const
void MergePrimitivesAsPolygon(SHAPE_POLY_SET *aMergedPolygon, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Merge all basic shapes to a SHAPE_POLY_SET.
int GetRoundRectCornerRadius() const
bool IsOnLayer(PCB_LAYER_ID aLayer, bool aIncludeCourtyards=false) const override
Test to see if this object is on the given layer.
const VECTOR2I & GetOffset() const
const VECTOR2I & GetDelta() const
PAD_SHAPE GetShape() const
int GetChamferPositions() const
const VECTOR2I & GetSize() const
double GetChamferRectRatio() const
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool ExportSpecctraFile(const wxString &aFullFilename)
Export the current BOARD to a specctra dsn file.
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Collect all BOARD_ITEM objects of a given set of KICAD_T type(s).
void Collect(BOARD_ITEM *aBoard, const std::vector< KICAD_T > &aTypes)
Collect BOARD_ITEM objects using this class's Inspector method, which does the collection.
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
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.
void Clear()
Remove all points from the line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Base class for iterating over all vertices in a given SHAPE_POLY_SET.
bool IsEndContour() const
Represent a set of closed polygons.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
int HoleCount(int aOutline) const
Return the reference to aIndex-th outline in the set.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
void Simplify(POLYGON_MODE aFastMode)
SHAPE_LINE_CHAIN & Outline(int aIndex)
SHAPE_LINE_CHAIN & Hole(int aOutline, int aHole)
Return the aIndex-th subpolygon in the set.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
const char * c_str() const
Handle a list of polygons defining a copper zone.
SHAPE_POLY_SET::ITERATOR IterateWithHoles()
Return an iterator to visit all points of the zone's main outline with holes.
void Rotate(const VECTOR2I &aCentre, const EDA_ANGLE &aAngle) override
Rotate the outlines.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
int ConvertArcToPolyline(SHAPE_LINE_CHAIN &aPolyline, VECTOR2I aCenter, int aRadius, const EDA_ANGLE &aStartAngleDeg, const EDA_ANGLE &aArcAngleDeg, double aAccuracy, ERROR_LOC aErrorLoc)
Generate a polyline to approximate a arc.
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aBuffer, const VECTOR2I &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a circle to a polygon, using multiple straight lines.
void TransformRoundChamferedRectToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aPosition, const VECTOR2I &aSize, const EDA_ANGLE &aRotation, int aCornerRadius, double aChamferRatio, int aChamferCorners, int aInflate, int aError, ERROR_LOC aErrorLoc)
Convert a rectangle with rounded corners and/or chamfered corners to a polygon.
void BuildConvexHull(std::vector< VECTOR2I > &aResult, const std::vector< VECTOR2I > &aPoly)
Calculate the convex hull of a list of points in counter-clockwise order.
static bool empty(const wxTextEntryBase *aCtrl)
static constexpr EDA_ANGLE & ANGLE_180
static constexpr EDA_ANGLE & ANGLE_360
static constexpr EDA_ANGLE & ANGLE_0
a few functions useful in geometry calculations.
#define THROW_IO_ERROR(msg)
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
This source file implements export and import capabilities to the specctra dsn file format.
std::vector< std::string > STRINGS
std::map< wxString, int > PINMAP
data type used to ensure unique-ness of pin names, holding (wxString and int)
static double mapX(int x)
static double mapY(int y)
static double IU2um(int kicadDist)
static POINT mapPt(const VECTOR2I &pt)
Convert a KiCad point into a DSN file point.
static bool isRoundKeepout(PAD *aPad)
Decide if the pad is a copper-less through hole which needs to be made into a round keepout.
std::set< std::string > STRINGSET
static double scale(int kicadDist)
Convert a distance from Pcbnew internal units to the reported Specctra DSN units in floating point fo...
static PATH * makePath(const POINT &aStart, const POINT &aEnd, const std::string &aLayerName)
Create a PATH element with a single straight line, a pair of vertices.
std::pair< STRINGSET::iterator, bool > STRINGSET_PAIR
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
void ExportBoardToSpecctraFile(BOARD *aBoard, const wxString &aFullFilename)
Helper method to export board to DSN file.
static const double safetyMargin
A <pin_reference> definition in the specctra dsn spec.
A point in the SPECCTRA DSN coordinate system.
void FixNegativeZero()
Change negative zero to positive zero in the IEEE floating point storage format.
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_PAD_T
class PAD, a pad in a footprint
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".