Fixed memsetting non-trivially-copyable types

Types stl_stats, stl_normal and SurfaceFillParams should not be zeroed by memset
This is not correct and also triggered warnings on gcc
This commit is contained in:
Lukas Matena 2019-09-24 17:09:07 +02:00
parent 7861fa5086
commit b67d8c1614
4 changed files with 43 additions and 43 deletions

View file

@ -15,40 +15,39 @@ namespace Slic3r {
struct SurfaceFillParams
{
SurfaceFillParams() : flow(0.f, 0.f, 0.f, false) { memset(this, 0, sizeof(*this)); }
// Zero based extruder ID.
unsigned int extruder;
unsigned int extruder = 0;
// Infill pattern, adjusted for the density etc.
InfillPattern pattern;
InfillPattern pattern = InfillPattern(0);
// FillBase
// in unscaled coordinates
coordf_t spacing;
coordf_t spacing = 0.;
// infill / perimeter overlap, in unscaled coordinates
coordf_t overlap;
coordf_t overlap = 0.;
// Angle as provided by the region config, in radians.
float angle;
float angle = 0.f;
// Non-negative for a bridge.
float bridge_angle;
float bridge_angle = 0.f;
// FillParams
float density;
float density = 0.f;
// Don't connect the fill lines around the inner perimeter.
bool dont_connect;
bool dont_connect = false;
// Don't adjust spacing to fill the space evenly.
bool dont_adjust;
bool dont_adjust = false;
// width, height of extrusion, nozzle diameter, is bridge
// For the output, for fill generator.
Flow flow;
Flow flow = Flow(0.f, 0.f, 0.f, false);
// For the output
ExtrusionRole extrusion_role;
ExtrusionRole extrusion_role = ExtrusionRole(0);
// Various print settings?
// Index of this entry in a linear vector.
size_t idx;
size_t idx = 0;
bool operator<(const SurfaceFillParams &rhs) const {

View file

@ -246,7 +246,7 @@ static void extract_model_from_archive(
sscanf(normal_buf[2], "%f", &facet.normal(2)) != 1) {
// Normal was mangled. Maybe denormals or "not a number" were stored?
// Just reset the normal and silently ignore it.
memset(&facet.normal, 0, sizeof(facet.normal));
facet.normal = stl_normal::Zero();
}
facets.emplace_back(facet);
}

View file

@ -1462,7 +1462,7 @@ stl_stats ModelObject::get_object_stl_stats() const
return this->volumes[0]->mesh().stl.stats;
stl_stats full_stats;
memset(&full_stats, 0, sizeof(stl_stats));
full_stats.volume = 0.f;
// fill full_stats from all objet's meshes
for (ModelVolume* volume : this->volumes)