89static std::vector<ODB_TOOL_RECORD>
parseOdbTools(
const fs::path& aToolsFile )
91 std::vector<ODB_TOOL_RECORD>
tools;
92 std::ifstream stream( aToolsFile );
95 auto value = [](
const std::string& aLine ) -> std::string
97 return aLine.substr( aLine.find(
'=' ) + 1 );
100 while( std::getline( stream, line ) )
102 const size_t start = line.find_first_not_of(
" \t" );
104 if( start == std::string::npos )
107 line = line.substr( start );
109 if( line.rfind(
"TOOLS", 0 ) == 0 )
110 tools.emplace_back();
111 else if(
tools.empty() )
113 else if( line.rfind(
"NUM=", 0 ) == 0 )
114 tools.back().m_num = std::stoi( value( line ) );
115 else if( line.rfind(
"FINISH_SIZE=", 0 ) == 0 )
116 tools.back().m_finishSize = std::stod( value( line ) );
117 else if( line.rfind(
"DRILL_SIZE=", 0 ) == 0 )
118 tools.back().m_drillSize = std::stod( value( line ) );
141 std::set<double> expectedSizes;
142 int npthHoleCount = 0;
144 for(
const PAD*
pad : board->GetPads() )
149 expectedSizes.insert(
pcbIUScale.IUTomm( std::min(
pad->GetDrillSizeX(),
150 pad->GetDrillSizeY() ) ) );
155 BOOST_REQUIRE_GT( npthHoleCount, (
int) expectedSizes.size() );
156 BOOST_REQUIRE_GT( expectedSizes.size(), 1 );
159 ODB_EXPORT_STATE_GUARD stateGuard;
162 std::map<std::string, UTF8> props;
163 props[
"units"] =
"mm";
164 props[
"sigfig"] =
"6";
166 BOOST_REQUIRE_NO_THROW( odbExporter.
SaveBoard( tempDir.
Path().string(), *board, &props ) );
170 for(
const fs::directory_entry& entry : fs::recursive_directory_iterator( tempDir.
Path() ) )
172 if( entry.is_regular_file() && entry.path().filename() ==
"tools"
173 && entry.path().parent_path().filename().string().find(
"non-plated" )
174 != std::string::npos )
176 toolsFile = entry.path();
181 BOOST_REQUIRE_MESSAGE( !toolsFile.empty(),
182 "ODB++ export produced no non-plated drill tools file" );
186 std::set<int> seenNums;
187 std::set<double> seenSizes;
191 BOOST_CHECK_MESSAGE( seenNums.insert( tool.m_num ).second,
192 "Drill tool number " << tool.m_num <<
" is used twice" );
194 seenSizes.insert( tool.m_drillSize );
199 expectedSizes.end() );
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::unique_ptr< BOARD > ReadBoardFromFileOrStream(const std::string &aFilename, std::istream &aFallback)
Read a board from a file, or another stream, as appropriate.
BOOST_CHECK_EQUAL(result, "25.4")