Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ double Board::get_height() {
return layers.begin()->second->surface->get_height_in();
}

void Board::prepareLayer(string layername, shared_ptr<GerberImporter> importer, shared_ptr<RoutingMill> manufacturer, bool backside) {
void Board::prepareLayer(string layername, shared_ptr<GerberImporter> importer, shared_ptr<RoutingMill> manufacturer, bool backside, bool ymirror) {
// see comment for prep_t in board.hpp
prepared_layers.insert(std::make_pair(layername, make_tuple(importer, manufacturer, backside)));
prepared_layers.insert(std::make_pair(layername, make_tuple(importer, manufacturer, backside, ymirror)));
}

/******************************************************************************/
Expand Down Expand Up @@ -139,7 +139,8 @@ void Board::createLayers()
auto layer = make_shared<Layer>(prepared_layer.first,
surface,
get<1>(prepared_layer.second),
get<2>(prepared_layer.second)); // see comment for prep_t in board.hpp
get<2>(prepared_layer.second),
get<3>(prepared_layer.second)); // see comment for prep_t in board.hpp
layers.insert(std::make_pair(layer->get_name(), layer));
}

Expand Down
4 changes: 2 additions & 2 deletions board.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Board
bool render_paths_to_shapes);

void prepareLayer(std::string layername, std::shared_ptr<GerberImporter> importer,
std::shared_ptr<RoutingMill> manufacturer, bool backside);
std::shared_ptr<RoutingMill> manufacturer, bool backside, bool ymirror);
void set_margins(double margins) { margin = margins; }
coordinate_type_fp get_width();
coordinate_type_fp get_height();
Expand Down Expand Up @@ -88,7 +88,7 @@ class Board
* prep_t tuples, whose signature must basically match the construction
* signature of Layer.
*/
typedef std::tuple<std::shared_ptr<GerberImporter>, std::shared_ptr<RoutingMill>, bool> prep_t;
typedef std::tuple<std::shared_ptr<GerberImporter>, std::shared_ptr<RoutingMill>, bool, bool> prep_t;
std::map<std::string, prep_t> prepared_layers;
std::map<std::string, std::shared_ptr<Layer> > layers;
};
Expand Down
38 changes: 26 additions & 12 deletions drill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ ExcellonProcessor::ExcellonProcessor(const boost::program_options::variables_map
yoffset((options["zero-start"].as<bool>() ? min.y() : 0) -
options["y-offset"].as<Length>().asInch(inputFactor)),
mirror_axis(options["mirror-axis"].as<Length>()),
mirror_yaxis(options["mirror-yaxis"].as<bool>()),
min_milldrill_diameter(options["min-milldrill-hole-diameter"].as<Length>()),
mill_feed_direction(options["mill-feed-direction"].as<MillFeedDirection::MillFeedDirection>()),
available_drills(flatten(options["drills-available"].as<std::vector<AvailableDrills>>())),
Expand Down Expand Up @@ -141,7 +142,7 @@ double ExcellonProcessor::get_xvalue(double xvalue)
{
double retval;

if (drillfront) //drill from the front, no calculation needed
if (drillfront || mirror_yaxis) //drill from the front, no calculation needed
{
retval = xvalue;
}
Expand All @@ -153,6 +154,22 @@ double ExcellonProcessor::get_xvalue(double xvalue)
return retval;
}

double ExcellonProcessor::get_yvalue(double yvalue)
{
double retval;

if (drillfront || !mirror_yaxis)
{
retval = yvalue;
}
else
{
retval = 2 * (yoffset + mirror_axis.asInch(inputFactor)) - yvalue - (tileInfo.tileY-1) * (tileInfo.boardHeight);
}

return retval;
}

string ExcellonProcessor::drill_to_string(drillbit drillbit) {
auto diameter = drillbit.diameter;
if (drillbit.unit == "mm" && !bMetricOutput) {
Expand Down Expand Up @@ -324,18 +341,15 @@ void ExcellonProcessor::export_ngc(const string of_dir, const boost::optional<st

if( nog81 )
{
of << "G0 X"
<< ( get_xvalue(x) - xoffsetTot ) * cfactor
<< " Y" << ( ( y - yoffsetTot ) * cfactor) << "\n";
of << "G0 X" << ( ( get_xvalue(x) - xoffsetTot ) * cfactor)
<< " Y" << ( ( get_yvalue(y) - yoffsetTot ) * cfactor) << "\n";
of << "G1 Z" << driller->zwork * cfactor << '\n';
of << "G1 Z" << driller->zsafe * cfactor << '\n';
}
else
{
of << "X"
<< ( get_xvalue(x) - xoffsetTot )
* cfactor
<< " Y" << ( ( y - yoffsetTot ) * cfactor) << "\n";
of << "X" << ( ( get_xvalue(x) - xoffsetTot ) * cfactor)
<< " Y" << ( ( get_yvalue(y) - yoffsetTot ) * cfactor) << "\n";
}
}
}
Expand Down Expand Up @@ -627,8 +641,8 @@ void ExcellonProcessor::export_ngc(const string of_dir, const boost::optional<st
const auto& end_x = line.back().x();
const auto& end_y = line.back().y();
if (!millhole(of,
get_xvalue(start_x) - xoffsetTot, start_y - yoffsetTot,
get_xvalue(end_x ) - xoffsetTot, end_y - yoffsetTot,
get_xvalue(start_x) - xoffsetTot, get_yvalue(start_y) - yoffsetTot,
get_xvalue(end_x ) - xoffsetTot, get_yvalue( end_y) - yoffsetTot,
target, diameter)) {
++badHoles;
}
Expand Down Expand Up @@ -805,9 +819,9 @@ map<int, multi_linestring_type_fp> ExcellonProcessor::optimize_holes(
//Optimize the holes path
for (auto& path : holes) {
if (tsp_2opt) {
tsp_solver::tsp_2opt(path.second, point_type_fp(get_xvalue(0) + xoffset, yoffset));
tsp_solver::tsp_2opt(path.second, point_type_fp(get_xvalue(0) + xoffset, get_yvalue(0) + yoffset));
} else {
tsp_solver::nearest_neighbour(path.second, point_type_fp(get_xvalue(0) + xoffset, yoffset));
tsp_solver::nearest_neighbour(path.second, point_type_fp(get_xvalue(0) + xoffset, get_yvalue(0) + yoffset));
}
}

Expand Down
2 changes: 2 additions & 0 deletions drill.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class ExcellonProcessor
double stop_x, double stop_y,
std::shared_ptr<Cutter> cutter, double holediameter);
double get_xvalue(double);
double get_yvalue(double);
std::string drill_to_string(drillbit drillbit);

std::map<int, multi_linestring_type_fp> optimize_holes(std::map<int, drillbit>& bits, bool onedrill,
Expand Down Expand Up @@ -135,6 +136,7 @@ class ExcellonProcessor
const double xoffset;
const double yoffset;
const Length mirror_axis;
const bool mirror_yaxis;
// The minimum size hole that is milldrilled. Below this, holes are drilled regularly.
const boost::optional<Length> min_milldrill_diameter;
const MillFeedDirection::MillFeedDirection mill_feed_direction;
Expand Down
222 changes: 222 additions & 0 deletions extras/example_board_new/example_board-B.Cu.gbr
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
G04 #@! TF.GenerationSoftware,KiCad,Pcbnew,5.0.2+dfsg1-1*
G04 #@! TF.CreationDate,2021-04-08T14:27:20-06:00*
G04 #@! TF.ProjectId,example_board,6578616d-706c-4655-9f62-6f6172642e6b,rev?*
G04 #@! TF.SameCoordinates,Original*
G04 #@! TF.FileFunction,Copper,L2,Bot*
G04 #@! TF.FilePolarity,Positive*
%FSLAX46Y46*%
G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)*
G04 Created by KiCad (PCBNEW 5.0.2+dfsg1-1) date Thu 08 Apr 2021 02:27:20 PM MDT*
%MOMM*%
%LPD*%
G01*
G04 APERTURE LIST*
G04 #@! TA.AperFunction,NonConductor*
%ADD10C,0.300000*%
G04 #@! TD*
G04 #@! TA.AperFunction,NonConductor*
%ADD11C,2.000000*%
G04 #@! TD*
G04 #@! TA.AperFunction,ViaPad*
%ADD12C,0.600000*%
G04 #@! TD*
G04 #@! TA.AperFunction,Conductor*
%ADD13C,0.250000*%
G04 #@! TD*
G04 APERTURE END LIST*
D10*
X49545714Y-13643571D02*
X49188571Y-14643571D01*
X48831428Y-13643571D02*
X49188571Y-14643571D01*
X49331428Y-15000714D01*
X49402857Y-15072142D01*
X49545714Y-15143571D01*
X48260000Y-13857857D02*
X47117142Y-13857857D01*
X47117142Y-14286428D02*
X48260000Y-14286428D01*
X50010000Y-17050714D02*
X49938571Y-17122142D01*
X50010000Y-17193571D01*
X50081428Y-17122142D01*
X50010000Y-17050714D01*
X50010000Y-17193571D01*
X48581428Y-15693571D02*
X49295714Y-15693571D01*
X49367142Y-16407857D01*
X49295714Y-16336428D01*
X49152857Y-16265000D01*
X48795714Y-16265000D01*
X48652857Y-16336428D01*
X48581428Y-16407857D01*
X48510000Y-16550714D01*
X48510000Y-16907857D01*
X48581428Y-17050714D01*
X48652857Y-17122142D01*
X48795714Y-17193571D01*
X49152857Y-17193571D01*
X49295714Y-17122142D01*
X49367142Y-17050714D01*
X47867142Y-17193571D02*
X47867142Y-16193571D01*
X47867142Y-15693571D02*
X47938571Y-15765000D01*
X47867142Y-15836428D01*
X47795714Y-15765000D01*
X47867142Y-15693571D01*
X47867142Y-15836428D01*
X47152857Y-16193571D02*
X47152857Y-17193571D01*
X47152857Y-16336428D02*
X47081428Y-16265000D01*
X46938571Y-16193571D01*
X46724285Y-16193571D01*
X46581428Y-16265000D01*
X46510000Y-16407857D01*
X46510000Y-17193571D01*
X28471428Y-678571D02*
X27685714Y321428D01*
X28471428Y321428D02*
X27685714Y-678571D01*
X27114285Y107142D02*
X25971428Y107142D01*
X25971428Y-321428D02*
X27114285Y-321428D01*
X24471428Y-678571D02*
X25328571Y-678571D01*
X24900000Y-678571D02*
X24900000Y821428D01*
X25042857Y607142D01*
X25185714Y464285D01*
X25328571Y392857D01*
X23828571Y-678571D02*
X23828571Y321428D01*
X23828571Y821428D02*
X23900000Y750000D01*
X23828571Y678571D01*
X23757142Y750000D01*
X23828571Y821428D01*
X23828571Y678571D01*
X23114285Y321428D02*
X23114285Y-678571D01*
X23114285Y178571D02*
X23042857Y250000D01*
X22900000Y321428D01*
X22685714Y321428D01*
X22542857Y250000D01*
X22471428Y107142D01*
X22471428Y-678571D01*
X-1524285Y821428D02*
X-2524285Y821428D01*
X-1524285Y-678571D01*
X-2524285Y-678571D01*
X-3667142Y-607142D02*
X-3524285Y-678571D01*
X-3238571Y-678571D01*
X-3095714Y-607142D01*
X-3024285Y-464285D01*
X-3024285Y107142D01*
X-3095714Y250000D01*
X-3238571Y321428D01*
X-3524285Y321428D01*
X-3667142Y250000D01*
X-3738571Y107142D01*
X-3738571Y-35714D01*
X-3024285Y-178571D01*
X-4381428Y-678571D02*
X-4381428Y321428D01*
X-4381428Y35714D02*
X-4452857Y178571D01*
X-4524285Y250000D01*
X-4667142Y321428D01*
X-4809999Y321428D01*
X-5524285Y-678571D02*
X-5381428Y-607142D01*
X-5309999Y-535714D01*
X-5238571Y-392857D01*
X-5238571Y35714D01*
X-5309999Y178571D01*
X-5381428Y250000D01*
X-5524285Y321428D01*
X-5738571Y321428D01*
X-5881428Y250000D01*
X-5952857Y178571D01*
X-6024285Y35714D01*
X-6024285Y-392857D01*
X-5952857Y-535714D01*
X-5881428Y-607142D01*
X-5738571Y-678571D01*
X-5524285Y-678571D01*
D11*
X40821428Y-16872857D02*
X39007142Y-17477619D01*
X38402380Y-18082380D01*
X37797619Y-19291904D01*
X37797619Y-21106190D01*
X38402380Y-22315714D01*
X39007142Y-22920476D01*
X40216666Y-23525238D01*
X45054761Y-23525238D01*
X45054761Y-10825238D01*
X40821428Y-10825238D01*
X39611904Y-11430000D01*
X39007142Y-12034761D01*
X38402380Y-13244285D01*
X38402380Y-14453809D01*
X39007142Y-15663333D01*
X39611904Y-16268095D01*
X40821428Y-16872857D01*
X45054761Y-16872857D01*
X26911904Y-23525238D02*
X26911904Y-16872857D01*
X27516666Y-15663333D01*
X28726190Y-15058571D01*
X31145238Y-15058571D01*
X32354761Y-15663333D01*
X26911904Y-22920476D02*
X28121428Y-23525238D01*
X31145238Y-23525238D01*
X32354761Y-22920476D01*
X32959523Y-21710952D01*
X32959523Y-20501428D01*
X32354761Y-19291904D01*
X31145238Y-18687142D01*
X28121428Y-18687142D01*
X26911904Y-18082380D01*
X15421428Y-22920476D02*
X16630952Y-23525238D01*
X19050000Y-23525238D01*
X20259523Y-22920476D01*
X20864285Y-22315714D01*
X21469047Y-21106190D01*
X21469047Y-17477619D01*
X20864285Y-16268095D01*
X20259523Y-15663333D01*
X19050000Y-15058571D01*
X16630952Y-15058571D01*
X15421428Y-15663333D01*
X9978571Y-23525238D02*
X9978571Y-10825238D01*
X8769047Y-18687142D02*
X5140476Y-23525238D01*
X5140476Y-15058571D02*
X9978571Y-19896666D01*
D12*
G04 #@! TO.N,*
X22860000Y-11430000D03*
X41910000Y-13970000D03*
X41910000Y-20320000D03*
G04 #@! TD*
D13*
G04 #@! TO.N,*
X0Y1270000D02*
X0Y-1270000D01*
X-1270000Y0D02*
X1270000Y0D01*
X25400000Y-1270000D02*
X25400000Y-2540000D01*
X48260000Y-12700000D02*
X49530000Y-12700000D01*
G04 #@! TD*
M02*
26 changes: 26 additions & 0 deletions extras/example_board_new/example_board-Edge.Cuts.gbr
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
G04 #@! TF.GenerationSoftware,KiCad,Pcbnew,5.0.2+dfsg1-1*
G04 #@! TF.CreationDate,2021-04-08T14:27:20-06:00*
G04 #@! TF.ProjectId,example_board,6578616d-706c-4655-9f62-6f6172642e6b,rev?*
G04 #@! TF.SameCoordinates,Original*
G04 #@! TF.FileFunction,Profile,NP*
%FSLAX46Y46*%
G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)*
G04 Created by KiCad (PCBNEW 5.0.2+dfsg1-1) date Thu 08 Apr 2021 02:27:20 PM MDT*
%MOMM*%
%LPD*%
G01*
G04 APERTURE LIST*
%ADD10C,0.150000*%
G04 APERTURE END LIST*
D10*
X-1270000Y-27940000D02*
X-1270000Y1270000D01*
X50800000Y-27940000D02*
X-1270000Y-27940000D01*
X50800000Y-2540000D02*
X50800000Y-27940000D01*
X46990000Y1270000D02*
X50800000Y-2540000D01*
X-1270000Y1270000D02*
X46990000Y1270000D01*
M02*
Loading