Refactoring of the G-code preview for lower memory allocation

and for separation of concerns:

The final G-code preview no more uses ExtrusionPaths structure
to hold the G-code path data extracted by parsing the G-code.
Instead, the ExtrusionPath class has been trimmed down back to
the original size before the G-code preview was introduced,
and a new GCodePreviewData::Extrusion::Path class was created to hold
the additional path data as the extruder ID, color change ID
and fan speed.
This commit is contained in:
bubnikv 2019-09-30 16:25:26 +02:00
parent b425ee50a9
commit 272479826f
7 changed files with 64 additions and 41 deletions

View file

@ -23,7 +23,7 @@ std::vector<unsigned char> GCodePreviewData::Color::as_bytes() const
return ret;
}
GCodePreviewData::Extrusion::Layer::Layer(float z, const ExtrusionPaths& paths)
GCodePreviewData::Extrusion::Layer::Layer(float z, const Paths& paths)
: z(z)
, paths(paths)
{
@ -171,8 +171,8 @@ size_t GCodePreviewData::Extrusion::memory_used() const
size_t out = sizeof(*this);
out += SLIC3R_STDVEC_MEMSIZE(this->layers, Layer);
for (const Layer &layer : this->layers) {
out += SLIC3R_STDVEC_MEMSIZE(layer.paths, ExtrusionPath);
for (const ExtrusionPath &path : layer.paths)
out += SLIC3R_STDVEC_MEMSIZE(layer.paths, Path);
for (const Path &path : layer.paths)
out += SLIC3R_STDVEC_MEMSIZE(path.polyline.points, Point);
}
return out;