• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pcb2gcode / pcb2gcode / 19811714133

24 Nov 2025 02:34PM UTC coverage: 59.007% (-15.0%) from 74.006%
19811714133

push

github

web-flow
Merge pull request #730 from mar0x/master

Enable windows build in CI

2199 of 4409 branches covered (49.88%)

Branch coverage included in aggregate %.

1902 of 2541 relevant lines covered (74.85%)

117318.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

48.84
/bg_helpers.cpp
1
#include "eulerian_paths.hpp"
2
#ifdef GEOS_VERSION
3
#include <geos/operation/buffer/BufferOp.h>
4
#include "geos_helpers.hpp"
5
#endif // GEOS_VERSION
6

7
#include "bg_operators.hpp"
8
#include "bg_helpers.hpp"
9
#include "common.hpp"
10

11
namespace bg_helpers {
12

13
// The below implementations of buffer are similar to bg::buffer but
14
// always convert to floating-point before doing work, if needed, and
15
// convert back afterward, if needed.  Also, they work if expand_by is
16
// 0, unlike bg::buffer.
17

18
multi_polygon_type_fp buffer(multi_polygon_type_fp const & geometry_in, coordinate_type_fp expand_by) {
×
19
  if (expand_by == 0 || geometry_in.size() == 0) {
×
20
    return geometry_in;
21
  }
22
  auto const points_per_circle = std::max(32., expand_by * 2 * bg::math::pi<double>() / 0.0004);
×
23
#ifdef GEOS_VERSION
24
  auto geos_in = to_geos(geometry_in);
×
25
  return from_geos<multi_polygon_type_fp>(
26
      std::unique_ptr<geos::geom::Geometry>(
×
27
          geos::operation::buffer::BufferOp::bufferOp(geos_in.get(), expand_by, points_per_circle/4)));
×
28
#else
29
  multi_polygon_type_fp geometry_out;
30
  bg::buffer(geometry_in, geometry_out,
31
             bg::strategy::buffer::distance_symmetric<coordinate_type_fp>(expand_by),
32
             bg::strategy::buffer::side_straight(),
33
             bg::strategy::buffer::join_round(points_per_circle),
34
             bg::strategy::buffer::end_round(points_per_circle),
35
             bg::strategy::buffer::point_circle(points_per_circle));
36
  return geometry_out;
37
#endif
38
}
×
39

40
multi_polygon_type_fp buffer_miter(multi_polygon_type_fp const & geometry_in, coordinate_type_fp expand_by) {
23✔
41
  if (expand_by == 0) {
23!
42
    return geometry_in;
43
  } else {
44
    multi_polygon_type_fp geometry_out;
45
    auto const points_per_circle = std::max(32., expand_by * 2 * bg::math::pi<double>() / 0.0004);
23✔
46
    bg::buffer(geometry_in, geometry_out,
23!
47
               bg::strategy::buffer::distance_symmetric<coordinate_type_fp>(expand_by),
23✔
48
               bg::strategy::buffer::side_straight(),
23✔
49
               bg::strategy::buffer::join_miter(expand_by),
23✔
50
               bg::strategy::buffer::end_round(points_per_circle),
23✔
51
               bg::strategy::buffer::point_circle(points_per_circle));
46✔
52
    return geometry_out;
53
  }
54
}
55

56
template<typename CoordinateType>
57
multi_polygon_type_fp buffer(polygon_type_fp const & geometry_in, CoordinateType expand_by) {
×
58
  return buffer(multi_polygon_type_fp{geometry_in}, expand_by);
×
59
}
×
60

61
template multi_polygon_type_fp buffer(polygon_type_fp const&, double);
62

63
template<typename CoordinateType>
64
multi_polygon_type_fp buffer_miter(polygon_type_fp const & geometry_in, CoordinateType expand_by) {
23✔
65
  return buffer_miter(multi_polygon_type_fp{geometry_in}, expand_by);
69!
66
}
23✔
67

68
template<typename CoordinateType>
69
multi_polygon_type_fp buffer(linestring_type_fp const & geometry_in, CoordinateType expand_by) {
70
  if (expand_by == 0) {
71
    return {};
72
  }
73
  auto const points_per_circle = std::max(32., expand_by * 2 * bg::math::pi<double>() / 0.0004);
74
#ifdef GEOS_VERSION
75
  auto geos_in = to_geos(geometry_in);
76
  return from_geos<multi_polygon_type_fp>(
77
      std::unique_ptr<geos::geom::Geometry>(
78
          geos::operation::buffer::BufferOp::bufferOp(geos_in.get(), expand_by, points_per_circle/4)));
79
#else
80
  multi_polygon_type_fp geometry_out;
81
  bg::buffer(geometry_in, geometry_out,
82
             bg::strategy::buffer::distance_symmetric<coordinate_type_fp>(expand_by),
83
             bg::strategy::buffer::side_straight(),
84
             bg::strategy::buffer::join_round(points_per_circle),
85
             bg::strategy::buffer::end_round(points_per_circle),
86
             bg::strategy::buffer::point_circle(points_per_circle));
87
  return geometry_out;
88
#endif
89
}
90

91
template<typename CoordinateType>
92
multi_polygon_type_fp buffer(multi_linestring_type_fp const & geometry_in, CoordinateType expand_by) {
17✔
93
  if (expand_by == 0 || geometry_in.size() == 0) {
17!
94
    return {};
95
  }
96
  // bg::buffer of multilinestring is broken in boost.  Converting the
97
  // multilinestring to non-intersecting paths seems to help.
98
  multi_linestring_type_fp mls = eulerian_paths::make_eulerian_paths(geometry_in, true, true);
17✔
99
#ifdef GEOS_VERSION
100
  auto const points_per_circle = std::max(32., expand_by * 2 * bg::math::pi<double>() / 0.0004);
17!
101
  auto geos_in = to_geos(mls);
17!
102
  return from_geos<multi_polygon_type_fp>(
103
      std::unique_ptr<geos::geom::Geometry>(
17✔
104
          geos::operation::buffer::BufferOp::bufferOp(geos_in.get(), expand_by, points_per_circle/4)));
17!
105
#else
106
  if (expand_by == 0) {
107
    return {};
108
  }
109
  multi_polygon_type_fp ret;
110
  for (const auto& ls : mls) {
111
    ret = ret + buffer(ls, expand_by);
112
  }
113
  return ret;
114
#endif
115
}
17✔
116

117
template multi_polygon_type_fp buffer(const multi_linestring_type_fp&, double expand_by);
118

119
template<typename CoordinateType>
120
multi_polygon_type_fp buffer_miter(ring_type_fp const & geometry_in, CoordinateType expand_by) {
23✔
121
  return buffer_miter(polygon_type_fp{geometry_in}, expand_by);
69!
122
}
123

124
template multi_polygon_type_fp buffer_miter(ring_type_fp const&, double);
125

126
} // namespace bg_helpers
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc