822 {
828 assert(false);
829
832 {
833 #ifdef SUPPORT_USE_AGG_RASTERIZER
835 #else
836
837 assert(std::abs(2 * offset_in_grid) < m_grid.resolution());
838 Polygons support_polygons_simplified = m_grid.contours_simplified(offset_in_grid, fill_holes);
839 #endif
840
842
843
845
846
847
848
849
851 offset_in_grid > 0 ?
852
854
856
857 std::vector<std::pair<Point,bool>> samples_inside;
858 for (ExPolygon &island : islands) {
860
861 auto it_lower = std::lower_bound(samples.begin(), samples.end(),
Point(bbox.min -
Point(1, 1)));
862 auto it_upper = std::upper_bound(samples.begin(), samples.end(),
Point(bbox.max +
Point(1, 1)));
863 samples_inside.clear();
864 for (auto it = it_lower; it != it_upper; ++ it)
865 if (bbox.contains(*it))
866 samples_inside.push_back(std::make_pair(*it, false));
867 if (! samples_inside.empty()) {
868
869 for (size_t i_contour = 0; i_contour <= island.holes.size(); ++ i_contour) {
874
875
876 for (auto &sample_inside : samples_inside) {
877 if (((*i)(1) > sample_inside.first(1)) != ((*j)(1) > sample_inside.first(1))) {
878 double x1 = (double)sample_inside.first(0);
879 double x2 = (double)(*i)(0) + (double)((*j)(0) - (*i)(0)) * (double)(sample_inside.first(1) - (*i)(1)) / (double)((*j)(1) - (*i)(1));
880 if (x1 < x2)
881 sample_inside.second = !sample_inside.second;
882 }
883 }
884 }
885 }
886
887 for (auto &sample_inside : samples_inside)
888 if (sample_inside.second) {
890 island.clear();
891 break;
892 }
893 }
894 }
895
896 #ifdef SLIC3R_DEBUG
898 if (! islands.empty())
900 if (!out.empty())
902 if (!support_polygons_simplified.empty())
903 bbox.merge(
get_extents(support_polygons_simplified));
904 SVG svg(
debug_out_path(
"extract_support_from_grid_trimmed-%s-%d-%d-%lf.svg", step_name, iRun, layer_id, print_z).c_str(), bbox);
905 if (svg.is_opened()) {
906 svg.draw(
union_ex(support_polygons_simplified),
"gray", 0.25f);
907 svg.draw(islands, "red", 0.5f);
908 svg.draw(
union_ex(out),
"green", 0.5f);
910 svg.draw_outline(islands,
"red",
"red",
scale_(0.05));
913 for (const Point& pt : samples)
915 svg.Close();
916 }
917 #endif
918
921 return out;
922 }
924
927#ifdef SLIC3R_DEBUG
930 { {
union_ex(
smooth_outward(
closing(*
m_support_polygons, closing_distance,
SUPPORT_SURFACES_OFFSET_PARAMETERS), smoothing_distance)) }, {
"regularized",
"red",
"black",
"",
scaled<coord_t>(0.1f), 0.5f } },
932 });
933#endif
934
935
937 }
938 assert(false);
940 }
#define SUPPORT_SURFACES_OFFSET_PARAMETERS
Definition PrintObject.cpp:5148
Points points
Definition MultiPoint.hpp:22
static void export_expolygons(const char *path, const BoundingBox &bbox, const Slic3r::ExPolygons &expolygons, std::string stroke_outer="black", std::string stroke_holes="blue", coordf_t stroke_width=0)
Definition SVG.cpp:381
static Points island_samples(const ExPolygons &expolygons)
Definition SupportMaterial.cpp:1148
Kernel::Point_3 Point
Definition MeshRepair.cpp:81
void smooth_outward(MutablePolygon &polygon, coord_t clip_dist_scaled)
Definition MutablePolygon.cpp:262
BoundingBox scaled(const BoundingBoxf &bb)
Definition BoundingBox.hpp:284
Slic3r::ExPolygons diff_ex(const Slic3r::Polygons &subject, const Slic3r::Polygons &clip, ApplySafetyOffset do_safety_offset)
Definition ClipperUtils.cpp:831
std::vector< ExPolygon > ExPolygons
Definition ExPolygon.hpp:20
Slic3r::Polygons expand(const Slic3r::Polygon &polygon, const float delta, JoinType joinType=DefaultJoinType, double miterLimit=DefaultMiterLimit)
Definition ClipperUtils.hpp:397
std::vector< Polygon, PointsAllocator< Polygon > > Polygons
Definition Polygon.hpp:22
static Polygons contours_simplified(const Vec2i32 &grid_size, const double pixel_size, Point left_bottom, const std::vector< unsigned char > &grid, coord_t offset, bool fill_holes)
Definition SupportMaterial.cpp:236
Slic3r::Polygons closing(const Slic3r::Polygons &polygons, const float delta1, const float delta2, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:670
Slic3r::ExPolygons intersection_ex(const Slic3r::Polygons &subject, const Slic3r::Polygons &clip, ApplySafetyOffset do_safety_offset)
Definition ClipperUtils.cpp:878
std::vector< Point, PointsAllocator< Point > > Points
Definition Point.hpp:73
void polygons_append(Polygons &dst, const ExPolygon &src)
Definition ExPolygon.hpp:411
Slic3r::ExPolygons union_ex(const Slic3r::Polygons &subject, PolyFillType fill_type)
Definition ClipperUtils.cpp:1011
const Polygon & contour(const ExPolygon &p)
Definition AGGRaster.hpp:30
const Polygons & holes(const ExPolygon &p)
Definition AGGRaster.hpp:31
Slic3r::Polygon Polygon
Definition Emboss.cpp:101