38 auto& x =
nets_map.emplace( std::piecewise_construct, std::forward_as_tuple( 0 ),
39 std::forward_as_tuple(
nets.size(),
"$NONE$" ) )
58 for(
const auto& subnet :
subnets )
60 if( !aIncludeComponents &&
dynamic_cast<const SUB_NET_TOEPRINT*
>( subnet.get() ) )
72 auto& net =
nets_map.emplace( std::piecewise_construct,
74 std::forward_as_tuple(
nets.size(), aName ) )
77 nets.push_back( &net );
87 net->m_uid = aPlugin.
NewUid();
92 size_t aFeatureIndex, uint32_t aUid )
94 std::set<uint32_t> uids;
96 for(
int code : aNetCodes )
98 if( code > 0 &&
nets_map.count( code ) )
99 uids.insert(
nets_map.at( code ).m_uid );
102 if( uids.size() < 2 )
105 m_shorts.push_back( { std::move( uids ),
GetLyrIdx( aLayer ), aFeatureIndex, aUid } );
127 static const std::map<TYPE, std::string> type_map = {
128 { TYPE::COPPER,
"C" },
150 static const std::map<FILL_TYPE, std::string> fill_type_map = { {
FILL_TYPE::SOLID,
"S" },
153 static const std::map<CUTOUT_TYPE, std::string> cutout_type_map = {
167 static const std::map<SIDE, std::string> side_map = {
192 layers.push_back( aLayer );
224 ost <<
"CT" << std::endl;
226 ost <<
"CE" << std::endl;
235 std::shared_ptr<FOOTPRINT> fp(
static_cast<FOOTPRINT*
>( aFp->
Clone() ) );
237 fp->SetParentGroup(
nullptr );
238 fp->SetPosition( { 0, 0 } );
251 wxString fp_name = fp->GetFPID().GetLibItemName().wx_str();
254 if( fp_name.IsEmpty() )
255 fp_name = wxS(
"__" );
264 PACKAGE* pkg = &( iter->second );
268 BOX2I bbox = fp->GetBoundingBox();
275 if( fp->Pads().size() < 2 )
278 for(
size_t i = 0; i < fp->Pads().size(); ++i )
280 const PAD* pad1 = fp->Pads()[i];
282 for(
size_t j = i + 1; j < fp->Pads().size(); ++j )
284 const PAD* pad2 = fp->Pads()[j];
295 pkg_outline = courtyard;
299 pkg_outline = courtyard_back;
304 pkg_outline = fp->GetBoundingHull();
311 for(
int ii = 0; ii < pkg_outline.
OutlineCount(); ++ii )
314 std::make_unique<OUTLINE_CONTOUR>( pkg_outline.
Polygon( ii ) ) );
318 for(
size_t i = 0; i < fp->Pads().size(); ++i )
320 const PAD*
pad = fp->Pads()[i];
339 name = wxString::Format(
"PAD%zu", aPinNum );
352 pin->type = PIN::TYPE::THROUGH_HOLE;
356 pin->type = PIN::TYPE::SURFACE;
385 if( polygons->OutlineCount() > 0 )
387 pin->m_pinOutlines.push_back( std::make_unique<OUTLINE_CONTOUR>( polygons->Polygon( 0 ) ) );
394 static const std::map<TYPE, std::string> type_map = { { TYPE::SURFACE,
"S" },
395 { TYPE::THROUGH_HOLE,
"T" },
396 { TYPE::BLIND,
"B" } };
398 static const std::map<ELECTRICAL_TYPE, std::string> etype_map = {
409 ost <<
"PIN " <<
m_name.utf8_string() <<
" " << type_map.at(
type ) <<
" " <<
m_center.first <<
" "
410 <<
m_center.second <<
" 0 " << etype_map.at(
etype ) <<
" " << mtype_map.at(
mtype ) << std::endl;
414 outline->Write( ost, aFormat );
433 outline->Write( ost, localFormat );
438 pin->Write( ost, localFormat );
445 ost <<
"# " << wxDateTime::Now().FormatISOCombined() << std::endl;
447 ost <<
"UNITS=" << aFormat.
m_unitsStr << std::endl;
450 for(
const auto& layer :
layers )
461 for(
const auto& net :
nets )
463 ost <<
"#NET " << net->m_index << std::endl;
474 ost <<
"# PKG " << i << std::endl;
476 pkg->Write( ost, aFormat );
477 ost <<
"#" << std::endl;
484 ost <<
"UNITS=" << aFormat.
m_unitsStr << std::endl;
487 for(
const wxString& layer :
layers )
496 for( uint32_t uid : shortNet.m_netUids )
499 ost <<
";ID=" << shortNet.m_uid << std::endl;
500 ost <<
"FID C " << shortNet.m_layerIndex <<
" " << shortNet.m_featureIndex << std::endl;
constexpr EDA_IU_SCALE pcbIUScale
wxString GetBuildVersion()
Get the full KiCad version string.
void WriteAttributes(std::ostream &ost, const std::string &prefix="") const
void WriteAttributes(std::ostream &ost) const
std::map< unsigned int, std::string > m_ODBattributes
VECTOR2I GetFPRelativePosition() const
constexpr const Vec & GetPosition() const
constexpr const Vec GetEnd() const
void Write(std::ostream &ost) const
std::list< std::unique_ptr< SUB_NET > > subnets
void Write(std::ostream &ost, bool aIncludeComponents) const
void AddPin(const PAD *aPad, size_t aPinNum, const ODB_FORMAT &aFormat)
std::vector< std::shared_ptr< PIN > > m_pinsVec
void Write(std::ostream &ost, const ODB_FORMAT &aFormat) const
wxString m_name
<! Reference number of the package to be used in CMP.
std::list< std::unique_ptr< PKG_OUTLINE > > m_pkgOutlines
std::list< std::unique_ptr< PKG_OUTLINE > > m_pinOutlines
void Write(std::ostream &ost, const ODB_FORMAT &aFormat) const
std::pair< wxString, wxString > m_center
void WriteSubnet(std::ostream &ost) const override
void WriteSubnet(std::ostream &ost) const override
void WriteSubnet(std::ostream &ost) const override
void WriteSubnet(std::ostream &ost) const override
std::list< FEATURE_ID > feature_ids
void Write(std::ostream &ost) const
void AddFeatureID(FEATURE_ID::TYPE type, const wxString &layer, size_t feature_id)
virtual void WriteSubnet(std::ostream &ost) const =0
bool AddShort(const std::set< int > &aNetCodes, const wxString &aLayer, size_t aFeatureIndex, uint32_t aUid)
std::list< const PACKAGE * > packages
std::map< wxString, size_t > layers_map
std::map< size_t, NET > nets_map
void AssignNetUids(PCB_IO_ODBPP &aPlugin)
std::vector< wxString > layers
void WriteShortf(std::ostream &ost, const ODB_FORMAT &aFormat) const
void AddPackage(const FOOTPRINT *aFp, const ODB_FORMAT &aFormat)
void Write(std::ostream &ost, const ODB_FORMAT &aFormat) const
std::map< size_t, PACKAGE > packages_map
std::vector< SHORT_NET > m_shorts
void AddNET(const NETINFO_ITEM *aNet, const wxString &aName)
std::vector< std::shared_ptr< FOOTPRINT > > m_eda_footprints
size_t GetLyrIdx(const wxString &aLayerName)
Handle the data for a net.
void Write(std::ostream &ost, const ODB_FORMAT &aFormat) const override
void Write(std::ostream &ost, const ODB_FORMAT &aFormat) const override
std::unique_ptr< ODB_SURFACE_DATA > m_surfaces
void Write(std::ostream &ost, const ODB_FORMAT &aFormat) const override
void Write(std::ostream &ost, const ODB_FORMAT &aFormat) const override
PCB_LAYER_ID EffectiveLayerFor(PCB_LAYER_ID aLayer) const
Determines which geometry layer should be used for the given input layer.
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
const PADSTACK & Padstack() const
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID aLayer, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
bool HasHole() const override
Represent a set of closed polygons.
POLYGON & Polygon(int aIndex)
Return the aIndex-th subpolygon in the set.
int OutlineCount() const
Return the number of outlines in the set.
static constexpr EDA_ANGLE ANGLE_0
FAB_PIN MakeFabPin(const PAD &aPad, size_t aIndexInFootprint)
aIndexInFootprint is the pad's position in its footprint, used to name NPTH and unnumbered pads
size_t hash_fp_item(const EDA_ITEM *aItem, int aFlags)
Calculate hash of an EDA_ITEM.
Hashing functions for EDA_ITEMs.
@ REL_COORD
Use coordinates relative to the parent object.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
PCB_LAYER_ID
A quick note on layer IDs:
@ LEFT_RIGHT
Flip left to right (around the Y axis)
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
void RemoveWhitespace(wxString &aStr)
wxString Data2String(const ODB_FORMAT &aFormat, double aVal)
std::pair< wxString, wxString > AddRelativeXY(const ODB_FORMAT &aFormat, const VECTOR2I &aVec)
FAB_ELECTRICAL m_electrical
VECTOR2< double > VECTOR2D