// Count a nuber of polygons stored inside the vector of expolygons. // Useful for allocating space for polygons when converting expolygons to polygons. inline size_t number_polygons(const Surfaces &surfaces) { size_t n_polygons = 0; for (Surfaces::const_iterator it = surfaces.begin(); it != surfaces.end(); ++ it) n_polygons += it->expolygon.holes.size() + 1; return n_polygons; }
inline ExPolygons to_expolygons(const Surfaces &src) { ExPolygons expolygons; expolygons.reserve(src.size()); for (Surfaces::const_iterator it = src.begin(); it != src.end(); ++it) expolygons.push_back(it->expolygon); return expolygons; }
inline Polygons to_polygons(const Surfaces &surfaces) { Slic3r::Polygons pp; for (Surfaces::const_iterator s = surfaces.begin(); s != surfaces.end(); ++s) append_to(pp, (Polygons)*s); return pp; }
// Append a vector of Surfaces at the end of another vector of polygons. inline void polygons_append(Polygons &dst, const Surfaces &src) { dst.reserve(dst.size() + number_polygons(src)); for (Surfaces::const_iterator it = src.begin(); it != src.end(); ++ it) { dst.push_back(it->expolygon.contour); dst.insert(dst.end(), it->expolygon.holes.begin(), it->expolygon.holes.end()); } }
void SVG::draw_outline(const Surfaces &surfaces, std::string stroke_outer, std::string stroke_holes, coordf_t stroke_width) { for (Surfaces::const_iterator it = surfaces.begin(); it != surfaces.end(); ++ it) draw_outline(*it, stroke_outer, stroke_holes, stroke_width); }
void SVG::draw(const Surfaces &surfaces, std::string fill, const float fill_opacity) { for (Surfaces::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it) this->draw(*it, fill, fill_opacity); }