336{
339
341
343
346
347
348
349
350 for (ExPolygon expolygon : this->
expolygons) {
351
352 expolygon.rotate(
PI / 2.0 -
angle);
353
354
355
356 for (ExPolygon &expoly :
offset_ex(expolygon, 0.5f *
float(this->
spacing))) {
357
361 for (Polygon &trapezoid : trapezoids) {
362 size_t n_supported = 0;
363 if (!precise) {
364
365
366 for (
const Line &supported_line :
intersection_ln(trapezoid.lines(), anchors))
367 if (supported_line.length() >= this->spacing)
368 ++n_supported;
369 } else {
371 n_supported = intersects.size();
372
373 if (n_supported >= 2) {
374
375 BoundingBox center_bound = intersects[0].bounding_box();
376 coord_t min_y = center_bound.center()(1), max_y = center_bound.center()(1);
377 for (Polygon &poly_bound : intersects) {
378 center_bound = poly_bound.bounding_box();
379 if (min_y > center_bound.center()(1)) min_y = center_bound.center()(1);
380 if (max_y < center_bound.center()(1)) max_y = center_bound.center()(1);
381 }
382 coord_t min_x = trapezoid[0](0), max_x = trapezoid[0](0);
383 for (Point &p : trapezoid.points) {
384 if (min_x > p(0)) min_x = p(0);
385 if (max_x < p(0)) max_x = p(0);
386 }
387
388 min_x -= (this->
spacing / 4 + 1);
389 max_x += (this->
spacing / 4 + 1);
390 coord_t mid_x = (min_x + max_x) / 2;
391 for (Point &p : trapezoid.points) {
392 if (p(1) < min_y) p(1) = min_y;
393 if (p(1) > max_y) p(1) = max_y;
394 if (p(0) > min_x && p(0) < mid_x) p(0) = min_x;
395 if (p(0) < max_x && p(0) > mid_x) p(0) = max_x;
396 }
397 }
398 }
399
400 if (n_supported >= 2) {
401
402 covered.push_back(std::move(trapezoid));
403 }
404 }
405 }
406 }
407
408
409
410 covered =
union_(covered);
411
413
414#if 0
415 {
416 my @lines = map @{$_->lines}, @$trapezoids;
417 $_->rotate(-(
PI/2 - $angle), [0,0])
for @lines;
418
419 require "Slic3r/SVG.pm";
420 Slic3r::SVG::output(
421 "coverage_" .
rad2deg($angle) .
".svg",
423 green_expolygons => $self->_anchor_regions,
424 red_expolygons => $coverage,
425 lines => \@lines,
426 );
427 }
428#endif
429 }
430 return covered;
431}
ExPolygons _anchor_regions
Definition BridgeDetector.hpp:77
double angle
Definition BridgeDetector.hpp:42
int64_t coord_t
Definition libslic3r.h:48
T rad2deg(T angle)
Definition Geometry.hpp:310
Slic3r::Polygons union_(const Slic3r::Polygons &subject)
Definition ClipperUtils.cpp:801
Slic3r::Lines intersection_ln(const Slic3r::Lines &subject, const Slic3r::Polygons &clip)
Definition ClipperUtils.hpp:571
Slic3r::Polygons intersection(const Slic3r::Polygon &subject, const Slic3r::Polygon &clip, ApplySafetyOffset do_safety_offset)
Definition ClipperUtils.cpp:769
static void get_trapezoids2(const ExPolygon &expoly, Polygons *polygons)
Definition BridgeDetector.cpp:247
std::vector< Polygon, PointsAllocator< Polygon > > Polygons
Definition Polygon.hpp:22
Polygons to_polygons(const ExPolygon &src)
Definition ExPolygon.hpp:307
Slic3r::ExPolygons offset_ex(const Slic3r::Polygons &polygons, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:605
void get_trapezoids3_half(const ExPolygon &expoly, Polygons *polygons, float spacing)
Definition BridgeDetector.cpp:288
void polygons_rotate(Polygons &polys, double angle)
Definition Polygon.hpp:169