| 1 |
|
| #ifndef clipper_offset_h_ |
| 2 |
|
| #define clipper_offset_h_ |
| 3 |
|
| |
| 4 |
|
| #include "myinit.h" |
| 5 |
|
| |
| 6 |
|
| void |
| 7 |
10 |
| _scale_polygons(ClipperLib::Polygons* polygons, const double scale) |
| 8 |
|
| { |
| 9 |
22 |
▶ | for (ClipperLib::Polygons::size_type i = 0; i != (*polygons).size(); i++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (ClipperLib::Polygons::size_type i = 0; i != (*polygons).size(); i++) { |
12 |
10 |
22 |
|
| 10 |
12 |
| ClipperLib::Polygon* mypoly = &(*polygons)[i]; |
| 11 |
60 |
▶ | for (ClipperLib::Polygon::size_type j = 0; j != (*mypoly).size(); j++) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (ClipperLib::Polygon::size_type j = 0; j != (*mypoly).size(); j++) { |
48 |
12 |
60 |
|
| 12 |
48 |
| (*mypoly)[j].X *= scale; |
| 13 |
48 |
| (*mypoly)[j].Y *= scale; |
| 14 |
|
| } |
| 15 |
|
| } |
| 16 |
10 |
| } |
| 17 |
|
| |
| 18 |
|
| ClipperLib::Polygons* |
| 19 |
3 |
| _int_offset(ClipperLib::Polygons* polygons, const float delta, const double scale, ClipperLib::JoinType jointype, const double MiterLimit) |
| 20 |
|
| { |
| 21 |
|
| // scale |
| 22 |
3 |
| _scale_polygons(polygons, scale); |
| 23 |
|
| |
| 24 |
|
| // perform offset |
| 25 |
3 |
| ClipperLib::Polygons* retval = new ClipperLib::Polygons(); |
| 26 |
3 |
| ClipperLib::OffsetPolygons(*polygons, *retval, (delta*scale), jointype, MiterLimit); |
| 27 |
|
| |
| 28 |
|
| // unscale |
| 29 |
3 |
| _scale_polygons(retval, 1/scale); |
| 30 |
|
| |
| 31 |
3 |
| return retval; |
| 32 |
|
| } |
| 33 |
|
| |
| 34 |
|
| #endif |