Skip to content

Commit

Permalink
Use sum and symdiff in gerberimporter
Browse files Browse the repository at this point in the history
  • Loading branch information
eyal0 committed Feb 4, 2021
1 parent d166f5e commit 4720687
Show file tree
Hide file tree
Showing 313 changed files with 72,580 additions and 72,207 deletions.
28 changes: 15 additions & 13 deletions gerberimporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,13 @@ inline static void unsupported_polarity_throw_exception() {
// or.
struct mp_pair {
mp_pair() {}
mp_pair(multi_polygon_type_fp mp) : shapes(mp) {}
multi_polygon_type_fp filled_closed_lines;
mp_pair(multi_polygon_type_fp shapes) : shapes(shapes) {}
mp_pair(multi_polygon_type_fp shapes,
multi_polygon_type_fp filled_closed_lines) :
shapes(shapes),
filled_closed_lines(filled_closed_lines) {}
multi_polygon_type_fp shapes;
multi_polygon_type_fp filled_closed_lines;
const mp_pair operator+(const mp_pair& rhs) const {
mp_pair ret;
ret.filled_closed_lines = filled_closed_lines ^ rhs.filled_closed_lines;
Expand All @@ -325,17 +329,15 @@ mp_pair merge_multi_draws(const vector<mp_pair>& multi_draws) {
} else if (multi_draws.size() == 1) {
return multi_draws.front();
}
auto current = multi_draws.cbegin();
vector<mp_pair> new_draws;
if (multi_draws.size() % 2 == 1) {
new_draws.push_back(*current);
current++;
}
// There are at least two and the total number is even.
for (; current != multi_draws.cend(); current += 2) {
new_draws.push_back(*current + *(current + 1));
vector<multi_polygon_type_fp> shapes;
vector<multi_polygon_type_fp> filled_closed_lines;
shapes.reserve(multi_draws.size());
filled_closed_lines.reserve(multi_draws.size());
for (const auto& multi_draw : multi_draws) {
shapes.push_back(multi_draw.shapes);
filled_closed_lines.push_back(multi_draw.filled_closed_lines);
}
return merge_multi_draws(new_draws);
return mp_pair(sum(shapes), symdiff(filled_closed_lines));
}

// layers is a vector of layers. Each layer has a polarity, which can
Expand Down Expand Up @@ -565,7 +567,7 @@ map<int, multi_polygon_type_fp> generate_apertures_map(const gerbv_aperture_t *
polarity = parameters[0];
rotation = parameters[4];
break;
case GERBV_APTYPE_MACRO_OUTLINE:
case GERBV_APTYPE_MACRO_OUTLINE: // 4.5.2.6 Outline, Code 4
{
ring_type_fp ring;
for (unsigned int i = 0; i < round(parameters[1]) + 1; i++){
Expand Down
12 changes: 6 additions & 6 deletions testing/gerbv_example/D1MiniGSR/expected/front.ngc
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,8 @@ G01 X12.48439 Y10.17367
G01 X12.62561 Y10.17367
G01 X12.64649 Y10.17588
G01 X12.78441 Y10.20534
G01 X12.80407 Y10.21175
G01 X12.90153 Y10.25495
G01 X12.80412 Y10.21177
G01 X12.90133 Y10.25495
G01 X15.09500 Y10.25495
G01 X15.10470 Y10.25543
G01 X15.18268 Y10.26305
Expand Down Expand Up @@ -843,8 +843,8 @@ G01 X1.77544 Y1.81750
G01 X1.92022 Y1.73394
G01 X1.93719 Y1.72159
G01 X2.06140 Y1.60958
G01 X2.07529 Y1.59414
G01 X2.14364 Y1.50021
G01 X2.07537 Y1.59406
G01 X2.14346 Y1.50021
G01 X2.59284 Y1.50021
G01 X8.39133 Y7.29867
G01 X8.39880 Y7.30545
Expand Down Expand Up @@ -915,8 +915,8 @@ G01 X2.90694 Y0.51204
G01 X2.88756 Y0.50818
G01 X2.80958 Y0.50056
G01 X2.79988 Y0.50008
G01 X2.14387 Y0.50008
G01 X2.07526 Y0.40585
G01 X2.14369 Y0.50008
G01 X2.07534 Y0.40595
G01 X2.06140 Y0.39045
G01 X1.93719 Y0.27844
G01 X1.92022 Y0.26610
Expand Down
40 changes: 20 additions & 20 deletions testing/gerbv_example/D1MiniGSR/expected/outp0_original_back.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 16 additions & 16 deletions testing/gerbv_example/D1MiniGSR/expected/outp1_original_front.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
130 changes: 65 additions & 65 deletions testing/gerbv_example/D1MiniGSR/expected/processed_back.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
104 changes: 52 additions & 52 deletions testing/gerbv_example/D1MiniGSR/expected/processed_front.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 25 additions & 25 deletions testing/gerbv_example/D1MiniGSR/expected/traced_back.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 20 additions & 20 deletions testing/gerbv_example/D1MiniGSR/expected/traced_front.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4720687

Please sign in to comment.