33 auto& x =
nets_map.emplace( std::piecewise_construct, std::forward_as_tuple( 0 ),
34 std::forward_as_tuple(
nets.size(),
"$NONE$" ) )
49 for(
const auto& subnet :
subnets )
63 auto& net =
nets_map.emplace( std::piecewise_construct,
65 std::forward_as_tuple(
nets.size(), netName ) )
68 nets.push_back( &net );
83 for(
const auto& fid : feature_ids )
92 static const std::map<TYPE, std::string> type_map = {
93 { TYPE::COPPER,
"C" },
97 ost <<
"FID " << type_map.at( type ) <<
" " << layer <<
" " << feature_id << std::endl;
115 static const std::map<FILL_TYPE, std::string> fill_type_map = { { FILL_TYPE::SOLID,
"S" },
116 { FILL_TYPE::OUTLINE,
"O" } };
118 static const std::map<CUTOUT_TYPE, std::string> cutout_type_map = {
119 { CUTOUT_TYPE::CIRCLE,
"C" },
120 { CUTOUT_TYPE::RECT,
"R" },
121 { CUTOUT_TYPE::OCTAGON,
"O" },
122 { CUTOUT_TYPE::EXACT,
"E" }
125 ost <<
"PLN " << fill_type_map.at( fill_type ) <<
" " << cutout_type_map.at( cutout_type )
132 static const std::map<SIDE, std::string> side_map = {
133 { SIDE::BOTTOM,
"B" },
136 ost <<
"TOP " << side_map.at( side ) <<
" " << comp_num <<
" " << toep_num;
143 feature_ids.emplace_back( type, m_edadata->GetLyrIdx( layer ), feature_id );
157 layers.push_back( aLayer );
186 ost <<
"CT" << std::endl;
187 m_surfaces->WriteData( ost );
188 ost <<
"CE" << std::endl;
197 std::shared_ptr<FOOTPRINT> fp(
static_cast<FOOTPRINT*
>( aFp->
Clone() ) );
199 fp->SetParentGroup(
nullptr );
200 fp->SetPosition( { 0, 0 } );
205 fp->Flip( fp->GetPosition(), FLIP_DIRECTION::LEFT_RIGHT );
206 fp->Flip( fp->GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
213 wxString fp_name = fp->GetFPID().GetLibItemName().wx_str();
223 PACKAGE* pkg = &( iter->second );
227 BOX2I bbox = fp->GetBoundingBox();
234 if( fp->Pads().size() < 2 )
237 for(
size_t i = 0; i < fp->Pads().size(); ++i )
239 const PAD* pad1 = fp->Pads()[i];
241 for(
size_t j = i + 1; j < fp->Pads().size(); ++j )
243 const PAD* pad2 = fp->Pads()[j];
254 pkg_outline = courtyard;
258 pkg_outline = courtyard_back;
263 pkg_outline = fp->GetBoundingHull();
270 for(
int ii = 0; ii < pkg_outline.
OutlineCount(); ++ii )
273 std::make_unique<OUTLINE_CONTOUR>( pkg_outline.
Polygon( ii ) ) );
277 for(
size_t i = 0; i < fp->Pads().size(); ++i )
279 const PAD*
pad = fp->Pads()[i];
298 name = wxString::Format(
"NPTH%zu", aPinNum );
299 else if(
name.empty() )
300 name = wxString::Format(
"PAD%zu", aPinNum );
303 std::shared_ptr<PIN>
pin = std::make_shared<PIN>( m_pinsVec.size(),
name );
304 m_pinsVec.push_back(
pin );
312 pin->type = PIN::TYPE::THROUGH_HOLE;
316 pin->type = PIN::TYPE::SURFACE;
344 const std::shared_ptr<SHAPE_POLY_SET>& polygons =
349 if( polygons->OutlineCount() > 0 )
351 pin->m_pinOutlines.push_back( std::make_unique<OUTLINE_CONTOUR>( polygons->Polygon( 0 ) ) );
358 static const std::map<TYPE, std::string> type_map = { { TYPE::SURFACE,
"S" },
359 { TYPE::THROUGH_HOLE,
"T" },
360 { TYPE::BLIND,
"B" } };
362 static const std::map<ELECTRICAL_TYPE, std::string> etype_map = {
363 { ELECTRICAL_TYPE::ELECTRICAL,
"E" },
364 { ELECTRICAL_TYPE::MECHANICAL,
"M" },
365 { ELECTRICAL_TYPE::UNDEFINED,
"U" }
367 static const std::map<MOUNT_TYPE, std::string> mtype_map = { { MOUNT_TYPE::THROUGH_HOLE,
"T" },
368 { MOUNT_TYPE::HOLE,
"H" },
369 { MOUNT_TYPE::SMT,
"S" },
370 { MOUNT_TYPE::UNDEFINED,
"U" } };
372 ost <<
"PIN " << m_name <<
" " << type_map.at( type ) <<
" " << m_center.first <<
" "
373 << m_center.second <<
" 0 " << etype_map.at( etype ) <<
" " << mtype_map.at( mtype )
376 for(
const auto& outline : m_pinOutlines )
378 outline->Write( ost );
389 for(
const auto& outline : m_pkgOutlines )
391 outline->Write( ost );
394 for(
const auto&
pin : m_pinsVec )
403 ost <<
"# " << wxDateTime::Now().FormatISOCombined() << std::endl;
408 for(
const auto& layer :
layers )
417 for(
const auto& net :
nets )
419 ost <<
"#NET " << net->m_index << std::endl;
426 ost <<
"# PKG " << i << std::endl;
429 ost <<
"#" << 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
VECTOR2I GetFPRelativePosition() const
constexpr const Vec & GetPosition() const
constexpr const Vec GetEnd() const
void Write(std::ostream &ost) const
void Write(std::ostream &ost) const
std::list< std::unique_ptr< SUB_NET > > subnets
void AddPin(const PAD *aPad, size_t aPinNum)
void Write(std::ostream &ost) const
std::list< std::unique_ptr< PKG_OUTLINE > > m_pkgOutlines
void Write(std::ostream &ost) const
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
void Write(std::ostream &ost) const
void AddFeatureID(FEATURE_ID::TYPE type, const wxString &layer, size_t feature_id)
std::list< const PACKAGE * > packages
std::map< wxString, size_t > layers_map
std::list< const NET * > nets
std::map< size_t, NET > nets_map
std::vector< wxString > layers
std::map< size_t, PACKAGE > packages_map
void AddNET(const NETINFO_ITEM *aNet)
std::vector< std::shared_ptr< FOOTPRINT > > m_eda_footprints
size_t GetLyrIdx(const wxString &aLayerName)
void AddPackage(const FOOTPRINT *aFp)
void Write(std::ostream &ost) const
Handle the data for a net.
const wxString & GetNetname() const
void Write(std::ostream &ost) const override
void Write(std::ostream &ost) const override
void Write(std::ostream &ost) const override
void Write(std::ostream &ost) const override
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
PAD_ATTRIB GetAttribute() const
const wxString & GetNumber() const
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
bool IsOnCopperLayer() const override
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID aLayer, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
bool HasHole() const override
static std::string m_unitsStr
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
size_t hash_fp_item(const EDA_ITEM *aItem, int aFlags)
Calculate hash of an EDA_ITEM.
@ HASH_POS
use coordinates relative to the parent object
@ REL_COORD
use coordinates relative to the shape position
wxString Data2String(double aVal)
void RemoveWhitespace(wxString &aStr)
std::pair< wxString, wxString > AddXY(const VECTOR2I &aVec)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
constexpr int mmToIU(double mm) const