31 auto& x =
nets_map.emplace( std::piecewise_construct, std::forward_as_tuple( 0 ),
32 std::forward_as_tuple(
nets.size(),
"$NONE$" ) )
47 for(
const auto& subnet :
subnets )
58 auto& net =
nets_map.emplace( std::piecewise_construct,
63 nets.push_back( &net );
78 for(
const auto& fid : feature_ids )
87 static const std::map<TYPE, std::string> type_map = {
88 { TYPE::COPPER,
"C" },
92 ost <<
"FID " << type_map.at( type ) <<
" " << layer <<
" " << feature_id << std::endl;
110 static const std::map<FILL_TYPE, std::string> fill_type_map = { { FILL_TYPE::SOLID,
"S" },
111 { FILL_TYPE::OUTLINE,
"O" } };
113 static const std::map<CUTOUT_TYPE, std::string> cutout_type_map = {
114 { CUTOUT_TYPE::CIRCLE,
"C" },
115 { CUTOUT_TYPE::RECT,
"R" },
116 { CUTOUT_TYPE::OCTAGON,
"O" },
117 { CUTOUT_TYPE::EXACT,
"E" }
120 ost <<
"PLN " << fill_type_map.at( fill_type ) <<
" " << cutout_type_map.at( cutout_type )
127 static const std::map<SIDE, std::string> side_map = {
128 { SIDE::BOTTOM,
"B" },
131 ost <<
"TOP " << side_map.at( side ) <<
" " << comp_num <<
" " << toep_num;
138 feature_ids.emplace_back( type, m_edadata->GetLyrIdx( layer ), feature_id );
152 layers.push_back( aLayer );
181 ost <<
"CT" << std::endl;
182 m_surfaces->WriteData( ost );
183 ost <<
"CE" << std::endl;
192 std::shared_ptr<FOOTPRINT> fp(
static_cast<FOOTPRINT*
>( aFp->
Clone() ) );
194 fp->SetParentGroup(
nullptr );
195 fp->SetPosition( { 0, 0 } );
197 if( fp->GetLayer() !=
F_Cu )
198 fp->Flip( fp->GetPosition(), FLIP_DIRECTION::TOP_BOTTOM );
204 wxString fp_name = fp->GetFPID().GetLibItemName().wx_str();
213 PACKAGE* pkg = &( iter->second );
217 BOX2I bbox = fp->GetBoundingBox();
224 if( fp->Pads().size() < 2 )
227 for(
size_t i = 0; i < fp->Pads().size(); ++i )
229 const PAD* pad1 = fp->Pads()[i];
230 for(
size_t j = i + 1; j < fp->Pads().size(); ++j )
232 const PAD* pad2 = fp->Pads()[j];
243 pkg_outline = courtyard;
247 pkg_outline = courtyard_back;
252 pkg_outline = fp->GetBoundingHull();
259 for(
int ii = 0; ii < pkg_outline.
OutlineCount(); ++ii )
262 std::make_unique<OUTLINE_CONTOUR>( pkg_outline.
Polygon( ii ) ) );
266 for(
size_t i = 0; i < fp->Pads().size(); ++i )
268 const PAD*
pad = fp->Pads()[i];
284 name = wxString::Format(
"NPTH%zu", aPinNum );
285 else if(
name.empty() )
286 name = wxString::Format(
"PAD%zu", aPinNum );
289 std::shared_ptr<PIN>
pin = std::make_shared<PIN>( m_pinsVec.size(),
name );
290 m_pinsVec.push_back(
pin );
298 pin->type = PIN::TYPE::THROUGH_HOLE;
302 pin->type = PIN::TYPE::SURFACE;
330 const std::shared_ptr<SHAPE_POLY_SET>& polygons =
335 if( polygons->OutlineCount() > 0 )
337 pin->m_pinOutlines.push_back( std::make_unique<OUTLINE_CONTOUR>( polygons->Polygon( 0 ) ) );
344 static const std::map<TYPE, std::string> type_map = { { TYPE::SURFACE,
"S" },
345 { TYPE::THROUGH_HOLE,
"T" },
346 { TYPE::BLIND,
"B" } };
348 static const std::map<ELECTRICAL_TYPE, std::string> etype_map = {
349 { ELECTRICAL_TYPE::ELECTRICAL,
"E" },
350 { ELECTRICAL_TYPE::MECHANICAL,
"M" },
351 { ELECTRICAL_TYPE::UNDEFINED,
"U" }
353 static const std::map<MOUNT_TYPE, std::string> mtype_map = { { MOUNT_TYPE::THROUGH_HOLE,
"T" },
354 { MOUNT_TYPE::HOLE,
"H" },
355 { MOUNT_TYPE::SMT,
"S" },
356 { MOUNT_TYPE::UNDEFINED,
"U" } };
358 ost <<
"PIN " << m_name <<
" " << type_map.at( type ) <<
" " << m_center.first <<
" "
359 << m_center.second <<
" 0 " << etype_map.at( etype ) <<
" " << mtype_map.at( mtype )
362 for(
const auto& outline : m_pinOutlines )
364 outline->Write( ost );
375 for(
const auto& outline : m_pkgOutlines )
377 outline->Write( ost );
380 for(
const auto&
pin : m_pinsVec )
389 ost <<
"# " << wxDateTime::Now().FormatISOCombined() << std::endl;
393 for(
const auto& layer :
layers )
402 for(
const auto& net :
nets )
404 ost <<
"#NET " << net->m_index << std::endl;
411 ost <<
"# PKG " << i << std::endl;
414 ost <<
"#" << std::endl;
constexpr EDA_IU_SCALE pcbIUScale
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)
std::pair< wxString, wxString > AddXY(const VECTOR2I &aVec)
constexpr int mmToIU(double mm) const