ENH: slicing: add cache data load/export for slicing

Change-Id: I88b7c79b6f79ec6bed0f829316b67310cac99b44
(cherry picked from commit 67c1d2e8dd459cc4450ce580632f01e25db038ac)
This commit is contained in:
lane.wei 2022-11-22 15:22:47 +08:00 committed by Lane.Wei
parent 2ffa56633c
commit c3abc64b61
13 changed files with 1471 additions and 192 deletions

View file

@ -6,7 +6,7 @@
namespace Slic3r {
enum SurfaceType {
enum SurfaceType {
// Top horizontal surface, visible from the top.
stTop,
// Bottom horizontal surface, visible from the bottom, printed with a normal extrusion flow.
@ -39,10 +39,14 @@ public:
unsigned short thickness_layers; // in layers
double bridge_angle; // in radians, ccw, 0 = East, only 0+ (negative means undefined)
unsigned short extra_perimeters;
Surface(SurfaceType _surface_type = stInternal)
: surface_type(_surface_type),
thickness(-1), thickness_layers(1), bridge_angle(-1), extra_perimeters(0)
{};
Surface(const Slic3r::Surface &rhs)
: surface_type(rhs.surface_type), expolygon(rhs.expolygon),
thickness(rhs.thickness), thickness_layers(rhs.thickness_layers),
thickness(rhs.thickness), thickness_layers(rhs.thickness_layers),
bridge_angle(rhs.bridge_angle), extra_perimeters(rhs.extra_perimeters)
{};
@ -52,12 +56,12 @@ public:
{};
Surface(const Surface &other, const ExPolygon &_expolygon)
: surface_type(other.surface_type), expolygon(_expolygon),
thickness(other.thickness), thickness_layers(other.thickness_layers),
thickness(other.thickness), thickness_layers(other.thickness_layers),
bridge_angle(other.bridge_angle), extra_perimeters(other.extra_perimeters)
{};
Surface(Surface &&rhs)
: surface_type(rhs.surface_type), expolygon(std::move(rhs.expolygon)),
thickness(rhs.thickness), thickness_layers(rhs.thickness_layers),
thickness(rhs.thickness), thickness_layers(rhs.thickness_layers),
bridge_angle(rhs.bridge_angle), extra_perimeters(rhs.extra_perimeters)
{};
Surface(SurfaceType _surface_type, const ExPolygon &&_expolygon)
@ -66,7 +70,7 @@ public:
{};
Surface(const Surface &other, const ExPolygon &&_expolygon)
: surface_type(other.surface_type), expolygon(std::move(_expolygon)),
thickness(other.thickness), thickness_layers(other.thickness_layers),
thickness(other.thickness), thickness_layers(other.thickness_layers),
bridge_angle(other.bridge_angle), extra_perimeters(other.extra_perimeters)
{};
@ -194,8 +198,8 @@ inline size_t number_polygons(const SurfacesPtr &surfaces)
}
// Append a vector of Surfaces at the end of another vector of polygons.
inline void polygons_append(Polygons &dst, const Surfaces &src)
{
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.emplace_back(it->expolygon.contour);
@ -203,8 +207,8 @@ inline void polygons_append(Polygons &dst, const Surfaces &src)
}
}
inline void polygons_append(Polygons &dst, Surfaces &&src)
{
inline void polygons_append(Polygons &dst, Surfaces &&src)
{
dst.reserve(dst.size() + number_polygons(src));
for (Surfaces::iterator it = src.begin(); it != src.end(); ++ it) {
dst.emplace_back(std::move(it->expolygon.contour));
@ -214,8 +218,8 @@ inline void polygons_append(Polygons &dst, Surfaces &&src)
}
// Append a vector of Surfaces at the end of another vector of polygons.
inline void polygons_append(Polygons &dst, const SurfacesPtr &src)
{
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.emplace_back((*it)->expolygon.contour);
@ -223,8 +227,8 @@ inline void polygons_append(Polygons &dst, const SurfacesPtr &src)
}
}
inline void polygons_append(Polygons &dst, SurfacesPtr &&src)
{
inline void polygons_append(Polygons &dst, SurfacesPtr &&src)
{
dst.reserve(dst.size() + number_polygons(src));
for (SurfacesPtr::const_iterator it = src.begin(); it != src.end(); ++ it) {
dst.emplace_back(std::move((*it)->expolygon.contour));
@ -234,41 +238,41 @@ inline void polygons_append(Polygons &dst, SurfacesPtr &&src)
}
// Append a vector of Surfaces at the end of another vector of polygons.
inline void surfaces_append(Surfaces &dst, const ExPolygons &src, SurfaceType surfaceType)
{
inline void surfaces_append(Surfaces &dst, const ExPolygons &src, SurfaceType surfaceType)
{
dst.reserve(dst.size() + src.size());
for (const ExPolygon &expoly : src)
dst.emplace_back(Surface(surfaceType, expoly));
}
inline void surfaces_append(Surfaces &dst, const ExPolygons &src, const Surface &surfaceTempl)
{
inline void surfaces_append(Surfaces &dst, const ExPolygons &src, const Surface &surfaceTempl)
{
dst.reserve(dst.size() + number_polygons(src));
for (const ExPolygon &expoly : src)
dst.emplace_back(Surface(surfaceTempl, expoly));
}
inline void surfaces_append(Surfaces &dst, const Surfaces &src)
{
inline void surfaces_append(Surfaces &dst, const Surfaces &src)
{
dst.insert(dst.end(), src.begin(), src.end());
}
inline void surfaces_append(Surfaces &dst, ExPolygons &&src, SurfaceType surfaceType)
{
inline void surfaces_append(Surfaces &dst, ExPolygons &&src, SurfaceType surfaceType)
{
dst.reserve(dst.size() + src.size());
for (ExPolygon &expoly : src)
dst.emplace_back(Surface(surfaceType, std::move(expoly)));
src.clear();
}
inline void surfaces_append(Surfaces &dst, ExPolygons &&src, const Surface &surfaceTempl)
{
inline void surfaces_append(Surfaces &dst, ExPolygons &&src, const Surface &surfaceTempl)
{
dst.reserve(dst.size() + number_polygons(src));
for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++ it)
dst.emplace_back(Surface(surfaceTempl, std::move(*it)));
src.clear();
}
inline void surfaces_append(Surfaces &dst, Surfaces &&src)
{
inline void surfaces_append(Surfaces &dst, Surfaces &&src)
{
if (dst.empty()) {
dst = std::move(src);
} else {
@ -283,7 +287,7 @@ extern BoundingBox get_extents(const SurfacesPtr &surfaces);
inline bool surfaces_could_merge(const Surface &s1, const Surface &s2)
{
return
return
s1.surface_type == s2.surface_type &&
s1.thickness == s2.thickness &&
s1.thickness_layers == s2.thickness_layers &&