48bool HasIntentionalShorts(
const BOARD& aBoard )
52 if( !footprint->IsNetTie() )
55 std::map<wxString, int> groups = footprint->MapPadNumbersToNetTieGroups();
56 std::map<int, std::set<int>> groupNets;
58 for(
const PAD*
pad : footprint->Pads() )
60 auto group = groups.find(
pad->GetNumber() );
62 if(
group == groups.end() ||
group->second < 0 ||
pad->GetNetCode() <= 0 )
65 if( groupNets[
group->second].insert(
pad->GetNetCode() ).second && groupNets[
group->second].size() > 1 )
95 std::map<int, wxString> bases;
97 : std::map<int, wxString>{};
101 if( net->GetNetCode() <= 0 )
104 wxString base =
m_format.m_anonymizeNets ? anonymous.at( net->GetNetCode() )
106 bases.emplace( net->GetNetCode(), base );
109 std::vector<wxString> baseNames;
110 baseNames.reserve( bases.size() );
112 for(
const auto& entry : bases )
113 baseNames.push_back( entry.second );
115 std::vector<wxString> names =
ODB::UniqueNames( baseNames, { wxS(
"$NONE$" ) }, wxString::npos );
119 for(
const auto& entry : bases )
137 if( !entity->CreateDirectoryTree( writer ) )
138 throw std::runtime_error(
"Failed in create directory tree process" );
142 entity->GenerateFiles( writer );
144 catch(
const std::exception& e )
146 throw std::runtime_error(
"Failed in generate files process.\n" + std::string( e.what() ) );
158 std::shared_ptr<ODB_TREE_WRITER> writer =
159 std::make_shared<ODB_TREE_WRITER>( aFileName );
160 writer->SetRootPath( writer->GetCurrentPath() );
178 entity->InitEntityData();
192 catch(
const std::exception& e )
195 std::cerr << e.what() << std::endl;
203 std::vector<FOOTPRINT*> retval;
208 retval.push_back(
static_cast<FOOTPRINT*
>( fp->Clone() ) );
260 Report(
_(
"ODB++ package section added because components reference packages." ),
272 m_format.m_layerOverrides.push_back(
override );
287 Report( wxString::Format(
_(
"ODB++ precision %d is below the minimum of %d for these units; "
293 Report( wxString::Format(
_(
"ODB++ precision %d is above the maximum of %d; using %d." ),
300 && HasIntentionalShorts( aBoard );
301 m_format.m_writeEdaNets = componentNets || logicalNets || shortNets;
313 THROW_IO_ERROR(
_(
"ODB++ export failed. See the messages above for the cause." ) );
323 if(
auto it = aProperties->find(
"units" ); it != aProperties->end() )
324 options.
m_inch = it->second ==
"inch";
326 if(
auto it = aProperties->find(
"sigfig" ); it != aProperties->end() )
330 Export( aFileName, aBoard, options );
constexpr double PCB_IU_PER_MM
Pcbnew IU is 1 nanometer.
constexpr double PL_IU_PER_MM
Internal units in micron (should be enough).
const VECTOR2I & GetGridOrigin() const
const VECTOR2I & GetAuxOrigin() const
Information pertinent to a Pcbnew printed circuit board.
const std::vector< wxString > & GetVariantNames() const
const FOOTPRINTS & Footprints() const
wxString GetCurrentVariant() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
virtual void Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) const
PROGRESS_REPORTER * m_progressReporter
Progress reporter to track the progress of the operation, may be nullptr.
Handle the data for a net.
std::unique_ptr< FAB_STACKUP > m_fabStackup
void ConfigureExport(BOARD &aBoard, const ODB_EXPORT_OPTIONS &aOptions)
std::vector< FOOTPRINT * > GetImportedCachedLibraryFootprints() override
Return a container with the cached library footprints generated in the last call to Load.
void ClearLoadedFootprints()
void Make(Args &&... args)
std::map< std::pair< PCB_LAYER_ID, ZONE * >, EDA_DATA::SUB_NET_PLANE * > m_plane_subnets
std::map< std::pair< const BOARD_ITEM *, PCB_LAYER_ID >, std::pair< wxString, size_t > > m_netTieFeatures
const FAB_DRILL_MODEL & GetFabDrillModel()
bool ExportODB(const wxString &aFileName)
std::vector< std::shared_ptr< FOOTPRINT > > m_loaded_footprints
static int MinPrecision(bool aInches)
Lowest sigfig that still resolves a 0.1 mil grid: 3 decimal places in mm, 4 in inches.
void Export(const wxString &aFileName, BOARD &aBoard, const ODB_EXPORT_OPTIONS &aOptions)
Write the product model tree at aFileName Throw IO_ERROR when the write fails.
static int MaxPrecision()
Highest sigfig accepted by the exporter, matching the export dialog's spin control.
void SaveBoard(const wxString &aFileName, BOARD &aBoard, const std::map< std::string, UTF8 > *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PCB_IO implementation knows about or it can be u...
std::map< int, wxString > m_netNames
std::vector< std::shared_ptr< ODB_ENTITY_BASE > > m_entities
std::map< const PAD *, EDA_DATA::SUB_NET_TOEPRINT * > m_topeprint_subnets
bool GenerateFiles(ODB_TREE_WRITER &writer)
std::map< PCB_TRACK *, EDA_DATA::SUB_NET * > m_via_trace_subnets
std::unique_ptr< FAB_DRILL_MODEL > m_fabDrillModel
std::map< int, wxString > FabAnonymousNetNames(const BOARD &aBoard)
Anonymous names NET_1 through NET_n keyed and numbered by net code.
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
std::vector< wxString > UniqueNames(const std::vector< wxString > &aBases, const std::set< wxString > &aReserved, size_t aMaxLength)
wxString GenLegalNetName(const wxString &aStr)
wxString GetDefaultVariantName()
static VARIANT_NAMES Build(const std::vector< wxString > &aNames)
What a caller asks of one ODB++ export.
std::optional< wxString > m_variant
Unset exports the current variant of the board.
JOB_EXPORT_PCB_ODB::ORIGIN m_origin
std::optional< FAB::SECTION_SET > m_sections
Unset exports every section.
wxString m_productModelName
std::vector< ODB_LAYER_OVERRIDE > m_layerOverrides