test_fill.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. #include <catch2/catch.hpp>
  2. #include <numeric>
  3. #include <sstream>
  4. #include "libslic3r/ClipperUtils.hpp"
  5. #include "libslic3r/Fill/Fill.hpp"
  6. #include "libslic3r/Flow.hpp"
  7. #include "libslic3r/Geometry.hpp"
  8. #include "libslic3r/Print.hpp"
  9. #include "libslic3r/SVG.hpp"
  10. #include "libslic3r/libslic3r.h"
  11. #include "test_data.hpp"
  12. using namespace Slic3r;
  13. bool test_if_solid_surface_filled(const ExPolygon& expolygon, double flow_spacing, double angle = 0, double density = 1.0);
  14. #if 0
  15. TEST_CASE("Fill: adjusted solid distance") {
  16. int surface_width = 250;
  17. int distance = Slic3r::Flow::solid_spacing(surface_width, 47);
  18. REQUIRE(distance == Approx(50));
  19. REQUIRE(surface_width % distance == 0);
  20. }
  21. #endif
  22. TEST_CASE("Fill: Pattern Path Length", "[Fill]") {
  23. std::unique_ptr<Slic3r::Fill> filler(Slic3r::Fill::new_from_type("rectilinear"));
  24. filler->angle = float(-(PI)/2.0);
  25. FillParams fill_params;
  26. filler->spacing = 5;
  27. fill_params.dont_adjust = true;
  28. //fill_params.endpoints_overlap = false;
  29. fill_params.density = float(filler->spacing / 50.0);
  30. auto test = [&filler, &fill_params] (const ExPolygon& poly) -> Slic3r::Polylines {
  31. Slic3r::Surface surface(stTop, poly);
  32. return filler->fill_surface(&surface, fill_params);
  33. };
  34. SECTION("Square") {
  35. Slic3r::Points test_set;
  36. test_set.reserve(4);
  37. std::vector<Vec2d> points {Vec2d(0,0), Vec2d(100,0), Vec2d(100,100), Vec2d(0,100)};
  38. for (size_t i = 0; i < 4; ++i) {
  39. std::transform(points.cbegin()+i, points.cend(), std::back_inserter(test_set), [] (const Vec2d& a) -> Point { return Point::new_scale(a.x(), a.y()); } );
  40. std::transform(points.cbegin(), points.cbegin()+i, std::back_inserter(test_set), [] (const Vec2d& a) -> Point { return Point::new_scale(a.x(), a.y()); } );
  41. Slic3r::Polylines paths = test(Slic3r::ExPolygon(test_set));
  42. REQUIRE(paths.size() == 1); // one continuous path
  43. // TODO: determine what the "Expected length" should be for rectilinear fill of a 100x100 polygon.
  44. // This check only checks that it's above scale(3*100 + 2*50) + scaled_epsilon.
  45. // ok abs($paths->[0]->length - scale(3*100 + 2*50)) - scaled_epsilon, 'path has expected length';
  46. REQUIRE(std::abs(paths[0].length() - static_cast<double>(scale_(3*100 + 2*50))) - SCALED_EPSILON > 0); // path has expected length
  47. test_set.clear();
  48. }
  49. }
  50. SECTION("Diamond with endpoints on grid") {
  51. std::vector<Vec2d> points {Vec2d(0,0), Vec2d(100,0), Vec2d(150,50), Vec2d(100,100), Vec2d(0,100), Vec2d(-50,50)};
  52. Slic3r::Points test_set;
  53. test_set.reserve(6);
  54. std::transform(points.cbegin(), points.cend(), std::back_inserter(test_set), [] (const Vec2d& a) -> Point { return Point::new_scale(a.x(), a.y()); } );
  55. Slic3r::Polylines paths = test(Slic3r::ExPolygon(test_set));
  56. REQUIRE(paths.size() == 1); // one continuous path
  57. }
  58. SECTION("Square with hole") {
  59. std::vector<Vec2d> square {Vec2d(0,0), Vec2d(100,0), Vec2d(100,100), Vec2d(0,100)};
  60. std::vector<Vec2d> hole {Vec2d(25,25), Vec2d(75,25), Vec2d(75,75), Vec2d(25,75) };
  61. std::reverse(hole.begin(), hole.end());
  62. Slic3r::Points test_hole;
  63. Slic3r::Points test_square;
  64. std::transform(square.cbegin(), square.cend(), std::back_inserter(test_square), [] (const Vec2d& a) -> Point { return Point::new_scale(a.x(), a.y()); } );
  65. std::transform(hole.cbegin(), hole.cend(), std::back_inserter(test_hole), [] (const Vec2d& a) -> Point { return Point::new_scale(a.x(), a.y()); } );
  66. for (double angle : {-(PI/2.0), -(PI/4.0), -(PI), PI/2.0, PI}) {
  67. for (double spacing : {25.0, 5.0, 7.5, 8.5}) {
  68. fill_params.density = float(filler->spacing / spacing);
  69. filler->angle = float(angle);
  70. ExPolygon e(test_square, test_hole);
  71. Slic3r::Polylines paths = test(e);
  72. #if 0
  73. {
  74. BoundingBox bbox = get_extents(e);
  75. SVG svg("c:\\data\\temp\\square_with_holes.svg", bbox);
  76. svg.draw(e);
  77. svg.draw(paths);
  78. svg.Close();
  79. }
  80. #endif
  81. REQUIRE((paths.size() >= 1 && paths.size() <= 3));
  82. // paths don't cross hole
  83. REQUIRE(diff_pl(paths, offset(e, float(SCALED_EPSILON*10))).size() == 0);
  84. }
  85. }
  86. }
  87. SECTION("Regression: Missing infill segments in some rare circumstances") {
  88. filler->angle = float(PI/4.0);
  89. fill_params.dont_adjust = false;
  90. filler->spacing = 0.654498;
  91. //filler->endpoints_overlap = unscale(359974);
  92. fill_params.density = 1;
  93. filler->layer_id = 66;
  94. filler->z = 20.15;
  95. Slic3r::Points points {Point(25771516,14142125),Point(14142138,25771515),Point(2512749,14142131),Point(14142125,2512749)};
  96. Slic3r::Polylines paths = test(Slic3r::ExPolygon(points));
  97. REQUIRE(paths.size() == 1); // one continuous path
  98. // TODO: determine what the "Expected length" should be for rectilinear fill of a 100x100 polygon.
  99. // This check only checks that it's above scale(3*100 + 2*50) + scaled_epsilon.
  100. // ok abs($paths->[0]->length - scale(3*100 + 2*50)) - scaled_epsilon, 'path has expected length';
  101. REQUIRE(std::abs(paths[0].length() - static_cast<double>(scale_(3*100 + 2*50))) - SCALED_EPSILON > 0); // path has expected length
  102. }
  103. SECTION("Rotated Square") {
  104. Slic3r::Points square { Point::new_scale(0,0), Point::new_scale(50,0), Point::new_scale(50,50), Point::new_scale(0,50)};
  105. Slic3r::ExPolygon expolygon(square);
  106. std::unique_ptr<Slic3r::Fill> filler(Slic3r::Fill::new_from_type("rectilinear"));
  107. filler->bounding_box = get_extents(expolygon.contour);
  108. filler->angle = 0;
  109. Surface surface(stTop, expolygon);
  110. auto flow = Slic3r::Flow(0.69f, 0.4f, 0.50f);
  111. FillParams fill_params;
  112. fill_params.density = 1.0;
  113. filler->spacing = flow.spacing();
  114. REQUIRE(!fill_params.use_arachne); // Make this test fail when Arachne is used because this test is not ready for it.
  115. for (auto angle : { 0.0, 45.0}) {
  116. surface.expolygon.rotate(angle, Point(0,0));
  117. Polylines paths = filler->fill_surface(&surface, fill_params);
  118. REQUIRE(paths.size() == 1);
  119. }
  120. }
  121. #if 0 // Disabled temporarily due to precission issues on the Mac VM
  122. SECTION("Solid surface fill") {
  123. Slic3r::Points points {
  124. Point::new_scale(6883102, 9598327.01296997),
  125. Point::new_scale(6883102, 20327272.01297),
  126. Point::new_scale(3116896, 20327272.01297),
  127. Point::new_scale(3116896, 9598327.01296997)
  128. };
  129. Slic3r::ExPolygon expolygon(points);
  130. REQUIRE(test_if_solid_surface_filled(expolygon, 0.55) == true);
  131. for (size_t i = 0; i <= 20; ++i)
  132. {
  133. expolygon.scale(1.05);
  134. REQUIRE(test_if_solid_surface_filled(expolygon, 0.55) == true);
  135. }
  136. }
  137. #endif
  138. SECTION("Solid surface fill") {
  139. Slic3r::Points points {
  140. Slic3r::Point(59515297,5422499),Slic3r::Point(59531249,5578697),Slic3r::Point(59695801,6123186),
  141. Slic3r::Point(59965713,6630228),Slic3r::Point(60328214,7070685),Slic3r::Point(60773285,7434379),
  142. Slic3r::Point(61274561,7702115),Slic3r::Point(61819378,7866770),Slic3r::Point(62390306,7924789),
  143. Slic3r::Point(62958700,7866744),Slic3r::Point(63503012,7702244),Slic3r::Point(64007365,7434357),
  144. Slic3r::Point(64449960,7070398),Slic3r::Point(64809327,6634999),Slic3r::Point(65082143,6123325),
  145. Slic3r::Point(65245005,5584454),Slic3r::Point(65266967,5422499),Slic3r::Point(66267307,5422499),
  146. Slic3r::Point(66269190,8310081),Slic3r::Point(66275379,17810072),Slic3r::Point(66277259,20697500),
  147. Slic3r::Point(65267237,20697500),Slic3r::Point(65245004,20533538),Slic3r::Point(65082082,19994444),
  148. Slic3r::Point(64811462,19488579),Slic3r::Point(64450624,19048208),Slic3r::Point(64012101,18686514),
  149. Slic3r::Point(63503122,18415781),Slic3r::Point(62959151,18251378),Slic3r::Point(62453416,18198442),
  150. Slic3r::Point(62390147,18197355),Slic3r::Point(62200087,18200576),Slic3r::Point(61813519,18252990),
  151. Slic3r::Point(61274433,18415918),Slic3r::Point(60768598,18686517),Slic3r::Point(60327567,19047892),
  152. Slic3r::Point(59963609,19493297),Slic3r::Point(59695865,19994587),Slic3r::Point(59531222,20539379),
  153. Slic3r::Point(59515153,20697500),Slic3r::Point(58502480,20697500),Slic3r::Point(58502480,5422499)
  154. };
  155. Slic3r::ExPolygon expolygon(points);
  156. REQUIRE(test_if_solid_surface_filled(expolygon, 0.55) == true);
  157. REQUIRE(test_if_solid_surface_filled(expolygon, 0.55, PI/2.0) == true);
  158. }
  159. SECTION("Solid surface fill") {
  160. Slic3r::Points points {
  161. Point::new_scale(0,0),Point::new_scale(98,0),Point::new_scale(98,10), Point::new_scale(0,10)
  162. };
  163. Slic3r::ExPolygon expolygon(points);
  164. REQUIRE(test_if_solid_surface_filled(expolygon, 0.5, 45.0, 0.99) == true);
  165. }
  166. }
  167. /*
  168. {
  169. my $collection = Slic3r::Polyline::Collection->new(
  170. Slic3r::Polyline->new([0,15], [0,18], [0,20]),
  171. Slic3r::Polyline->new([0,10], [0,8], [0,5]),
  172. );
  173. is_deeply
  174. [ map $_->[Y], map @$_, @{$collection->chained_path_from(Slic3r::Point->new(0,30), 0)} ],
  175. [20, 18, 15, 10, 8, 5],
  176. 'chained path';
  177. }
  178. {
  179. my $collection = Slic3r::Polyline::Collection->new(
  180. Slic3r::Polyline->new([4,0], [10,0], [15,0]),
  181. Slic3r::Polyline->new([10,5], [15,5], [20,5]),
  182. );
  183. is_deeply
  184. [ map $_->[X], map @$_, @{$collection->chained_path_from(Slic3r::Point->new(30,0), 0)} ],
  185. [reverse 4, 10, 15, 10, 15, 20],
  186. 'chained path';
  187. }
  188. {
  189. my $collection = Slic3r::ExtrusionPath::Collection->new(
  190. map Slic3r::ExtrusionPath->new(polyline => $_, role => 0, mm3_per_mm => 1),
  191. Slic3r::Polyline->new([0,15], [0,18], [0,20]),
  192. Slic3r::Polyline->new([0,10], [0,8], [0,5]),
  193. );
  194. is_deeply
  195. [ map $_->[Y], map @{$_->polyline}, @{$collection->chained_path_from(Slic3r::Point->new(0,30), 0)} ],
  196. [20, 18, 15, 10, 8, 5],
  197. 'chained path';
  198. }
  199. {
  200. my $collection = Slic3r::ExtrusionPath::Collection->new(
  201. map Slic3r::ExtrusionPath->new(polyline => $_, role => 0, mm3_per_mm => 1),
  202. Slic3r::Polyline->new([15,0], [10,0], [4,0]),
  203. Slic3r::Polyline->new([10,5], [15,5], [20,5]),
  204. );
  205. is_deeply
  206. [ map $_->[X], map @{$_->polyline}, @{$collection->chained_path_from(Slic3r::Point->new(30,0), 0)} ],
  207. [reverse 4, 10, 15, 10, 15, 20],
  208. 'chained path';
  209. }
  210. for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) {
  211. my $config = Slic3r::Config->new_from_defaults;
  212. $config->set('fill_pattern', $pattern);
  213. $config->set('external_fill_pattern', $pattern);
  214. $config->set('perimeters', 1);
  215. $config->set('skirts', 0);
  216. $config->set('fill_density', 20);
  217. $config->set('layer_height', 0.05);
  218. $config->set('perimeter_extruder', 1);
  219. $config->set('infill_extruder', 2);
  220. my $print = Slic3r::Test::init_print('20mm_cube', config => $config, scale => 2);
  221. ok my $gcode = Slic3r::Test::gcode($print), "successful $pattern infill generation";
  222. my $tool = undef;
  223. my @perimeter_points = my @infill_points = ();
  224. Slic3r::GCode::Reader->new->parse($gcode, sub {
  225. my ($self, $cmd, $args, $info) = @_;
  226. if ($cmd =~ /^T(\d+)/) {
  227. $tool = $1;
  228. } elsif ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) {
  229. if ($tool == $config->perimeter_extruder-1) {
  230. push @perimeter_points, Slic3r::Point->new_scale($args->{X}, $args->{Y});
  231. } elsif ($tool == $config->infill_extruder-1) {
  232. push @infill_points, Slic3r::Point->new_scale($args->{X}, $args->{Y});
  233. }
  234. }
  235. });
  236. my $convex_hull = convex_hull(\@perimeter_points);
  237. ok !(defined first { !$convex_hull->contains_point($_) } @infill_points), "infill does not exceed perimeters ($pattern)";
  238. }
  239. {
  240. my $config = Slic3r::Config->new_from_defaults;
  241. $config->set('infill_only_where_needed', 1);
  242. $config->set('bottom_solid_layers', 0);
  243. $config->set('infill_extruder', 2);
  244. $config->set('infill_extrusion_width', 0.5);
  245. $config->set('fill_density', 40);
  246. $config->set('cooling', 0); # for preventing speeds from being altered
  247. $config->set('first_layer_speed', '100%'); # for preventing speeds from being altered
  248. my $test = sub {
  249. my $print = Slic3r::Test::init_print('pyramid', config => $config);
  250. my $tool = undef;
  251. my @infill_extrusions = (); # array of polylines
  252. Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
  253. my ($self, $cmd, $args, $info) = @_;
  254. if ($cmd =~ /^T(\d+)/) {
  255. $tool = $1;
  256. } elsif ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) {
  257. if ($tool == $config->infill_extruder-1) {
  258. push @infill_extrusions, Slic3r::Line->new_scale(
  259. [ $self->X, $self->Y ],
  260. [ $info->{new_X}, $info->{new_Y} ],
  261. );
  262. }
  263. }
  264. });
  265. return 0 if !@infill_extrusions; # prevent calling convex_hull() with no points
  266. my $convex_hull = convex_hull([ map $_->pp, map @$_, @infill_extrusions ]);
  267. return unscale unscale sum(map $_->area, @{offset([$convex_hull], scale(+$config->infill_extrusion_width/2))});
  268. };
  269. my $tolerance = 5; # mm^2
  270. $config->set('solid_infill_below_area', 0);
  271. ok $test->() < $tolerance,
  272. 'no infill is generated when using infill_only_where_needed on a pyramid';
  273. $config->set('solid_infill_below_area', 70);
  274. ok abs($test->() - $config->solid_infill_below_area) < $tolerance,
  275. 'infill is only generated under the forced solid shells';
  276. }
  277. {
  278. my $config = Slic3r::Config->new_from_defaults;
  279. $config->set('skirts', 0);
  280. $config->set('perimeters', 1);
  281. $config->set('fill_density', 0);
  282. $config->set('top_solid_layers', 0);
  283. $config->set('bottom_solid_layers', 0);
  284. $config->set('solid_infill_below_area', 20000000);
  285. $config->set('solid_infill_every_layers', 2);
  286. $config->set('perimeter_speed', 99);
  287. $config->set('external_perimeter_speed', 99);
  288. $config->set('cooling', 0);
  289. $config->set('first_layer_speed', '100%');
  290. my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
  291. my %layers_with_extrusion = ();
  292. Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
  293. my ($self, $cmd, $args, $info) = @_;
  294. if ($cmd eq 'G1' && $info->{dist_XY} > 0 && $info->{extruding}) {
  295. if (($args->{F} // $self->F) != $config->perimeter_speed*60) {
  296. $layers_with_extrusion{$self->Z} = ($args->{F} // $self->F);
  297. }
  298. }
  299. });
  300. ok !%layers_with_extrusion,
  301. "solid_infill_below_area and solid_infill_every_layers are ignored when fill_density is 0";
  302. }
  303. {
  304. my $config = Slic3r::Config->new_from_defaults;
  305. $config->set('skirts', 0);
  306. $config->set('perimeters', 3);
  307. $config->set('fill_density', 0);
  308. $config->set('layer_height', 0.2);
  309. $config->set('first_layer_height', 0.2);
  310. $config->set('nozzle_diameter', [0.35]);
  311. $config->set('infill_extruder', 2);
  312. $config->set('solid_infill_extruder', 2);
  313. $config->set('infill_extrusion_width', 0.52);
  314. $config->set('solid_infill_extrusion_width', 0.52);
  315. $config->set('first_layer_extrusion_width', 0);
  316. my $print = Slic3r::Test::init_print('A', config => $config);
  317. my %infill = (); # Z => [ Line, Line ... ]
  318. my $tool = undef;
  319. Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
  320. my ($self, $cmd, $args, $info) = @_;
  321. if ($cmd =~ /^T(\d+)/) {
  322. $tool = $1;
  323. } elsif ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) {
  324. if ($tool == $config->infill_extruder-1) {
  325. my $z = 1 * $self->Z;
  326. $infill{$z} ||= [];
  327. push @{$infill{$z}}, Slic3r::Line->new_scale(
  328. [ $self->X, $self->Y ],
  329. [ $info->{new_X}, $info->{new_Y} ],
  330. );
  331. }
  332. }
  333. });
  334. my $grow_d = scale($config->infill_extrusion_width)/2;
  335. my $layer0_infill = union([ map @{$_->grow($grow_d)}, @{ $infill{0.2} } ]);
  336. my $layer1_infill = union([ map @{$_->grow($grow_d)}, @{ $infill{0.4} } ]);
  337. my $diff = diff($layer0_infill, $layer1_infill);
  338. $diff = offset2_ex($diff, -$grow_d, +$grow_d);
  339. $diff = [ grep { $_->area > 2*(($grow_d*2)**2) } @$diff ];
  340. is scalar(@$diff), 0, 'no missing parts in solid shell when fill_density is 0';
  341. }
  342. {
  343. # GH: #2697
  344. my $config = Slic3r::Config->new_from_defaults;
  345. $config->set('perimeter_extrusion_width', 0.72);
  346. $config->set('top_infill_extrusion_width', 0.1);
  347. $config->set('infill_extruder', 2); # in order to distinguish infill
  348. $config->set('solid_infill_extruder', 2); # in order to distinguish infill
  349. my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
  350. my %infill = (); # Z => [ Line, Line ... ]
  351. my %other = (); # Z => [ Line, Line ... ]
  352. my $tool = undef;
  353. Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
  354. my ($self, $cmd, $args, $info) = @_;
  355. if ($cmd =~ /^T(\d+)/) {
  356. $tool = $1;
  357. } elsif ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) {
  358. my $z = 1 * $self->Z;
  359. my $line = Slic3r::Line->new_scale(
  360. [ $self->X, $self->Y ],
  361. [ $info->{new_X}, $info->{new_Y} ],
  362. );
  363. if ($tool == $config->infill_extruder-1) {
  364. $infill{$z} //= [];
  365. push @{$infill{$z}}, $line;
  366. } else {
  367. $other{$z} //= [];
  368. push @{$other{$z}}, $line;
  369. }
  370. }
  371. });
  372. my $top_z = max(keys %infill);
  373. my $top_infill_grow_d = scale($config->top_infill_extrusion_width)/2;
  374. my $top_infill = union([ map @{$_->grow($top_infill_grow_d)}, @{ $infill{$top_z} } ]);
  375. my $perimeters_grow_d = scale($config->perimeter_extrusion_width)/2;
  376. my $perimeters = union([ map @{$_->grow($perimeters_grow_d)}, @{ $other{$top_z} } ]);
  377. my $covered = union_ex([ @$top_infill, @$perimeters ]);
  378. my @holes = map @{$_->holes}, @$covered;
  379. ok sum(map unscale unscale $_->area*-1, @holes) < 1, 'no gaps between top solid infill and perimeters';
  380. }
  381. */
  382. bool test_if_solid_surface_filled(const ExPolygon& expolygon, double flow_spacing, double angle, double density)
  383. {
  384. std::unique_ptr<Slic3r::Fill> filler(Slic3r::Fill::new_from_type("rectilinear"));
  385. filler->bounding_box = get_extents(expolygon.contour);
  386. filler->angle = float(angle);
  387. Flow flow(float(flow_spacing), 0.4f, float(flow_spacing));
  388. filler->spacing = flow.spacing();
  389. FillParams fill_params;
  390. fill_params.density = float(density);
  391. fill_params.dont_adjust = false;
  392. Surface surface(stBottom, expolygon);
  393. if (fill_params.use_arachne) // Make this test fail when Arachne is used because this test is not ready for it.
  394. return false;
  395. Slic3r::Polylines paths = filler->fill_surface(&surface, fill_params);
  396. // check whether any part was left uncovered
  397. Polygons grown_paths;
  398. grown_paths.reserve(paths.size());
  399. // figure out what is actually going on here re: data types
  400. float line_offset = float(scale_(filler->spacing / 2.0 + EPSILON));
  401. std::for_each(paths.begin(), paths.end(), [line_offset, &grown_paths] (const Slic3r::Polyline& p) {
  402. polygons_append(grown_paths, offset(p, line_offset));
  403. });
  404. // Shrink the initial expolygon a bit, this simulates the infill / perimeter overlap that we usually apply.
  405. ExPolygons uncovered = diff_ex(offset(expolygon, - float(0.2 * scale_(flow_spacing))), grown_paths, ApplySafetyOffset::Yes);
  406. // ignore very small dots
  407. const double scaled_flow_spacing = std::pow(scale_(flow_spacing), 2);
  408. uncovered.erase(std::remove_if(uncovered.begin(), uncovered.end(), [scaled_flow_spacing](const ExPolygon& poly) { return poly.area() < scaled_flow_spacing; }), uncovered.end());
  409. #if 0
  410. if (! uncovered.empty()) {
  411. BoundingBox bbox = get_extents(expolygon.contour);
  412. bbox.merge(get_extents(uncovered));
  413. bbox.merge(get_extents(grown_paths));
  414. SVG svg("c:\\data\\temp\\test_if_solid_surface_filled.svg", bbox);
  415. svg.draw(expolygon);
  416. svg.draw(uncovered, "red");
  417. svg.Close();
  418. }
  419. #endif
  420. return uncovered.empty(); // solid surface is fully filled
  421. }