Fixed calculation of the consumed material for the supports

This commit is contained in:
YuSanka 2019-02-19 12:14:13 +01:00
parent 9d0acc010d
commit 9e3434ecc1
2 changed files with 42 additions and 8 deletions

View File

@ -1101,12 +1101,33 @@ void SLAPrint::fill_statistics()
if (index.find(layer.first) == index.end())
continue;
if (index.at(layer.first).model_slices_idx != SLAPrintObject::SliceRecord::NONE) {
for (const ExPolygon& polygon : po->get_model_slices().at(index.at(layer.first).model_slices_idx))
const SLAPrintObject::SliceRecord& record = index.at(layer.first);
if (record.model_slices_idx != SLAPrintObject::SliceRecord::NONE &&
record.support_slices_idx != SLAPrintObject::SliceRecord::NONE)
{
double model_area = 0;
for (const ExPolygon& polygon : po->get_model_slices().at(record.model_slices_idx))
model_area += polygon.area();
layer_model_area += model_area;
Polygons polygons = to_polygons(po->get_model_slices().at(record.model_slices_idx));
append(polygons, to_polygons(po->get_support_slices().at(record.support_slices_idx)));
polygons = union_(polygons);
double poligons_area = 0;
for (const Polygon& polygon : polygons)
poligons_area += polygon.area();
if (poligons_area > model_area)
layer_support_area += (poligons_area-model_area);
}
else if (record.model_slices_idx != SLAPrintObject::SliceRecord::NONE) {
for (const ExPolygon& polygon : po->get_model_slices().at(record.model_slices_idx))
layer_model_area += polygon.area();
}
/*else */if (index.at(layer.first).support_slices_idx != SLAPrintObject::SliceRecord::NONE) {
for (const ExPolygon& polygon : po->get_support_slices().front())
else if (record.support_slices_idx != SLAPrintObject::SliceRecord::NONE) {
for (const ExPolygon& polygon : po->get_support_slices().at(record.support_slices_idx))
layer_support_area += polygon.area();
}
}

View File

@ -99,6 +99,11 @@ public:
wxStaticText *info_facets;
wxStaticText *info_materials;
wxStaticText *info_manifold;
wxStaticText *label_volume;
wxStaticText *label_materials;
std::vector<wxStaticText *> sla_hided_items;
bool showing_manifold_warning_icon;
void show_sizer(bool show);
};
@ -120,15 +125,16 @@ ObjectInfo::ObjectInfo(wxWindow *parent) :
(*info_label)->SetFont(wxGetApp().small_font());
grid_sizer->Add(text, 0);
grid_sizer->Add(*info_label, 0);
return text;
};
init_info_label(&info_size, _(L("Size")));
init_info_label(&info_volume, _(L("Volume")));
label_volume = init_info_label(&info_volume, _(L("Volume")));
init_info_label(&info_facets, _(L("Facets")));
init_info_label(&info_materials, _(L("Materials")));
label_materials = init_info_label(&info_materials, _(L("Materials")));
Add(grid_sizer, 0, wxEXPAND);
auto *info_manifold_text = new wxStaticText(parent, wxID_ANY, _(L("Manifold")));
auto *info_manifold_text = new wxStaticText(parent, wxID_ANY, _(L("Manifold")) + ":");
info_manifold_text->SetFont(wxGetApp().small_font());
info_manifold = new wxStaticText(parent, wxID_ANY, "");
info_manifold->SetFont(wxGetApp().small_font());
@ -139,6 +145,8 @@ ObjectInfo::ObjectInfo(wxWindow *parent) :
sizer_manifold->Add(manifold_warning_icon, 0, wxLEFT, 2);
sizer_manifold->Add(info_manifold, 0, wxLEFT, 2);
Add(sizer_manifold, 0, wxEXPAND | wxTOP, 4);
sla_hided_items = { label_volume, info_volume, label_materials, info_materials };
}
void ObjectInfo::show_sizer(bool show)
@ -811,6 +819,11 @@ void Sidebar::show_info_sizer()
}
p->object_info->show_sizer(true);
if (p->plater->printer_technology() == ptSLA) {
for (auto item: p->object_info->sla_hided_items)
item->Show(false);
}
}
void Sidebar::show_sliced_info_sizer(const bool show)