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

@ -1717,13 +1717,18 @@ static void thick_point_to_verts(const Vec3crd& point,
point_to_indexed_vertex_array(point, width, height, volume.indexed_vertex_array);
}
void _3DScene::extrusionentity_to_verts(const Polyline &polyline, float width, float height, float print_z, GLVolume& volume)
{
if (polyline.size() >= 2) {
size_t num_segments = polyline.size() - 1;
thick_lines_to_verts(polyline.lines(), std::vector<double>(num_segments, width), std::vector<double>(num_segments, height), false, print_z, volume);
}
}
// Fill in the qverts and tverts with quads and triangles for the extrusion_path.
void _3DScene::extrusionentity_to_verts(const ExtrusionPath &extrusion_path, float print_z, GLVolume &volume)
{
Lines lines = extrusion_path.polyline.lines();
std::vector<double> widths(lines.size(), extrusion_path.width);
std::vector<double> heights(lines.size(), extrusion_path.height);
thick_lines_to_verts(lines, widths, heights, false, print_z, volume);
extrusionentity_to_verts(extrusion_path.polyline, extrusion_path.width, extrusion_path.height, print_z, volume);
}
// Fill in the qverts and tverts with quads and triangles for the extrusion_path.