Skip to content

Commit

Permalink
style: Whitespace in ExcellonProcessor::optimize_bits
Browse files Browse the repository at this point in the history
  • Loading branch information
eyal0 committed Sep 10, 2022
1 parent 727f8b2 commit 14f425a
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions drill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,33 +837,33 @@ map<int, multi_linestring_type_fp> ExcellonProcessor::optimize_holes(
/******************************************************************************/
map<int, drillbit> ExcellonProcessor::optimize_bits() {
map<int, drillbit> bits(parsed_bits);
// If there is a list of available bits, round the holes to the nearest
// available bit.
if (available_drills.size() > 0) {
for (auto& wanted_drill : bits) {
auto& wanted_drill_bit = wanted_drill.second;
auto old_string = drill_to_string(wanted_drill_bit);
const Length& wanted_length = wanted_drill_bit.as_length();
auto best_available_drill = std::min_element(
available_drills.begin(), available_drills.end(),
[&](AvailableDrill a, AvailableDrill b) {
return a.difference(wanted_length, inputFactor).value_or(std::numeric_limits<double>::infinity()) <
b.difference(wanted_length, inputFactor).value_or(std::numeric_limits<double>::infinity());
});

const auto difference = best_available_drill->difference(wanted_length, inputFactor);
if (difference) {
wanted_drill_bit.diameter = best_available_drill->diameter().asInch(inputFactor);
wanted_drill_bit.unit = "inch";
if (abs(*difference) > 1e-6) {
cerr << "Info: bit " << wanted_drill.first << " ("
<< old_string << ") is rounded to "
<< drill_to_string(wanted_drill_bit) << std::endl;
}
}
// If there is a list of available bits, round the holes to the nearest
// available bit.
if (available_drills.size() > 0) {
for (auto& wanted_drill : bits) {
auto& wanted_drill_bit = wanted_drill.second;
auto old_string = drill_to_string(wanted_drill_bit);
const Length& wanted_length = wanted_drill_bit.as_length();
auto best_available_drill = std::min_element(
available_drills.begin(), available_drills.end(),
[&](AvailableDrill a, AvailableDrill b) {
return a.difference(wanted_length, inputFactor).value_or(std::numeric_limits<double>::infinity()) <
b.difference(wanted_length, inputFactor).value_or(std::numeric_limits<double>::infinity());
});

const auto difference = best_available_drill->difference(wanted_length, inputFactor);
if (difference) {
wanted_drill_bit.diameter = best_available_drill->diameter().asInch(inputFactor);
wanted_drill_bit.unit = "inch";
if (abs(*difference) > 1e-6) {
cerr << "Info: bit " << wanted_drill.first << " ("
<< old_string << ") is rounded to "
<< drill_to_string(wanted_drill_bit) << std::endl;
}
}
}
return bits;
}
return bits;
}

/******************************************************************************/
Expand Down

0 comments on commit 14f425a

Please sign in to comment.