2013-07-14 12:56:43 +00:00
|
|
|
#ifndef slic3r_SurfaceCollection_hpp_
|
|
|
|
#define slic3r_SurfaceCollection_hpp_
|
|
|
|
|
2015-12-07 23:39:54 +00:00
|
|
|
#include "libslic3r.h"
|
2013-07-14 12:56:43 +00:00
|
|
|
#include "Surface.hpp"
|
2013-11-22 23:07:04 +00:00
|
|
|
#include <vector>
|
2013-07-14 12:56:43 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
|
|
|
class SurfaceCollection
|
|
|
|
{
|
2017-05-03 16:28:22 +00:00
|
|
|
public:
|
2013-08-08 00:10:34 +00:00
|
|
|
Surfaces surfaces;
|
2014-08-03 16:41:09 +00:00
|
|
|
|
2021-05-03 09:39:53 +00:00
|
|
|
SurfaceCollection() = default;
|
|
|
|
SurfaceCollection(const Surfaces& surfaces) : surfaces(surfaces) {};
|
2017-08-02 12:24:32 +00:00
|
|
|
SurfaceCollection(Surfaces &&surfaces) : surfaces(std::move(surfaces)) {};
|
2021-05-03 09:39:53 +00:00
|
|
|
|
2013-11-22 01:16:10 +00:00
|
|
|
void simplify(double tolerance);
|
2014-02-10 12:19:44 +00:00
|
|
|
void group(std::vector<SurfacesPtr> *retval);
|
2017-07-10 11:15:36 +00:00
|
|
|
template <class T> bool any_internal_contains(const T &item) const {
|
|
|
|
for (const Surface &surface : this->surfaces) if (surface.is_internal() && surface.expolygon.contains(item)) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
template <class T> bool any_bottom_contains(const T &item) const {
|
|
|
|
for (const Surface &surface : this->surfaces) if (surface.is_bottom() && surface.expolygon.contains(item)) return true;
|
|
|
|
return false;
|
|
|
|
}
|
2016-09-26 10:42:44 +00:00
|
|
|
SurfacesPtr filter_by_type(const SurfaceType type);
|
|
|
|
SurfacesPtr filter_by_types(const SurfaceType *types, int ntypes);
|
|
|
|
void keep_type(const SurfaceType type);
|
|
|
|
void keep_types(const SurfaceType *types, int ntypes);
|
|
|
|
void remove_type(const SurfaceType type);
|
|
|
|
void remove_types(const SurfaceType *types, int ntypes);
|
2014-12-24 09:20:55 +00:00
|
|
|
void filter_by_type(SurfaceType type, Polygons* polygons);
|
2020-03-14 10:59:50 +00:00
|
|
|
void set_type(SurfaceType type) {
|
|
|
|
for (Surface &surface : this->surfaces)
|
|
|
|
surface.surface_type = type;
|
|
|
|
}
|
2016-12-12 14:54:37 +00:00
|
|
|
|
|
|
|
void clear() { surfaces.clear(); }
|
|
|
|
bool empty() const { return surfaces.empty(); }
|
2019-09-04 14:11:16 +00:00
|
|
|
size_t size() const { return surfaces.size(); }
|
2018-09-17 13:12:13 +00:00
|
|
|
bool has(SurfaceType type) const {
|
|
|
|
for (const Surface &surface : this->surfaces)
|
|
|
|
if (surface.surface_type == type) return true;
|
|
|
|
return false;
|
|
|
|
}
|
2016-12-12 14:54:37 +00:00
|
|
|
|
|
|
|
void set(const SurfaceCollection &coll) { surfaces = coll.surfaces; }
|
|
|
|
void set(SurfaceCollection &&coll) { surfaces = std::move(coll.surfaces); }
|
|
|
|
void set(const ExPolygons &src, SurfaceType surfaceType) { clear(); this->append(src, surfaceType); }
|
|
|
|
void set(const ExPolygons &src, const Surface &surfaceTempl) { clear(); this->append(src, surfaceTempl); }
|
|
|
|
void set(const Surfaces &src) { clear(); this->append(src); }
|
|
|
|
void set(ExPolygons &&src, SurfaceType surfaceType) { clear(); this->append(std::move(src), surfaceType); }
|
|
|
|
void set(ExPolygons &&src, const Surface &surfaceTempl) { clear(); this->append(std::move(src), surfaceTempl); }
|
|
|
|
void set(Surfaces &&src) { clear(); this->append(std::move(src)); }
|
|
|
|
|
|
|
|
void append(const SurfaceCollection &coll) { this->append(coll.surfaces); }
|
|
|
|
void append(SurfaceCollection &&coll) { this->append(std::move(coll.surfaces)); }
|
|
|
|
void append(const ExPolygons &src, SurfaceType surfaceType) { surfaces_append(this->surfaces, src, surfaceType); }
|
|
|
|
void append(const ExPolygons &src, const Surface &surfaceTempl) { surfaces_append(this->surfaces, src, surfaceTempl); }
|
|
|
|
void append(const Surfaces &src) { surfaces_append(this->surfaces, src); }
|
|
|
|
void append(ExPolygons &&src, SurfaceType surfaceType) { surfaces_append(this->surfaces, std::move(src), surfaceType); }
|
|
|
|
void append(ExPolygons &&src, const Surface &surfaceTempl) { surfaces_append(this->surfaces, std::move(src), surfaceTempl); }
|
|
|
|
void append(Surfaces &&src) { surfaces_append(this->surfaces, std::move(src)); }
|
2016-09-30 13:23:18 +00:00
|
|
|
|
|
|
|
// For debugging purposes:
|
|
|
|
void export_to_svg(const char *path, bool show_labels);
|
2013-07-14 12:56:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|