inline size_t number_polygons(const SurfacesPtr &surfaces) { size_t n_polygons = 0; for (SurfacesPtr::const_iterator it = surfaces.begin(); it != surfaces.end(); ++ it) n_polygons += (*it)->expolygon.holes.size() + 1; return n_polygons; }
/* group surfaces by common properties */ void SurfaceCollection::group(std::vector<SurfacesPtr> *retval, bool merge_solid) { for (Surfaces::iterator it = this->surfaces.begin(); it != this->surfaces.end(); ++it) { // find a group with the same properties SurfacesPtr* group = NULL; for (std::vector<SurfacesPtr>::iterator git = retval->begin(); git != retval->end(); ++git) { Surface* gkey = git->front(); if ((gkey->surface_type == it->surface_type || (merge_solid && gkey->is_solid() && it->is_solid())) && gkey->thickness == it->thickness && gkey->thickness_layers == it->thickness_layers && gkey->bridge_angle == it->bridge_angle) { group = &*git; break; } } // if no group with these properties exists, add one if (group == NULL) { retval->resize(retval->size() + 1); group = &retval->back(); } // append surface to group group->push_back(&*it); } }
inline ExPolygons to_expolygons(const SurfacesPtr &src) { ExPolygons expolygons; expolygons.reserve(src.size()); for (SurfacesPtr::const_iterator it = src.begin(); it != src.end(); ++it) expolygons.push_back((*it)->expolygon); return expolygons; }
inline Polygons to_polygons(const SurfacesPtr &surfaces) { Slic3r::Polygons pp; for (SurfacesPtr::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 SurfacesPtr &src) { dst.reserve(dst.size() + number_polygons(src)); for (SurfacesPtr::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()); } }
SurfacesPtr SurfaceCollection::filter_by_type(SurfaceType type) { SurfacesPtr ss; for (Surfaces::iterator surface = this->surfaces.begin(); surface != this->surfaces.end(); ++surface) { if (surface->surface_type == type) ss.push_back(&*surface); } return ss; }
SurfacesPtr SurfaceCollection::filter_by_types(const SurfaceType *types, int ntypes) { SurfacesPtr ss; for (Surfaces::iterator surface = this->surfaces.begin(); surface != this->surfaces.end(); ++surface) { for (int i = 0; i < ntypes; ++ i) { if (surface->surface_type == types[i]) { ss.push_back(&*surface); break; } } } return ss; }
/* group surfaces by common properties */ void SurfaceCollection::group(std::vector<SurfacesPtr> *retval) { for (Surfaces::iterator it = this->surfaces.begin(); it != this->surfaces.end(); ++it) { // find a group with the same properties SurfacesPtr* group = NULL; for (std::vector<SurfacesPtr>::iterator git = retval->begin(); git != retval->end(); ++git) if (! git->empty() && surfaces_could_merge(*git->front(), *it)) { group = &*git; break; } // if no group with these properties exists, add one if (group == NULL) { retval->resize(retval->size() + 1); group = &retval->back(); } // append surface to group group->push_back(&*it); } }
void SVG::draw_outline(const SurfacesPtr &surfaces, std::string stroke_outer, std::string stroke_holes, coordf_t stroke_width) { for (SurfacesPtr::const_iterator it = surfaces.begin(); it != surfaces.end(); ++ it) draw_outline(*(*it), stroke_outer, stroke_holes, stroke_width); }
void SVG::draw(const SurfacesPtr &surfaces, std::string fill, const float fill_opacity) { for (SurfacesPtr::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it) this->draw(*(*it), fill, fill_opacity); }