Merge remote-tracking branch 'origin/tm_slice_index'

This commit is contained in:
bubnikv 2019-03-22 17:08:38 +01:00
commit 8003dd4991
7 changed files with 517 additions and 206 deletions

View file

@ -5013,32 +5013,56 @@ void GLCanvas3D::_render_sla_slices() const
if ((bottom_obj_triangles.empty() || bottom_sup_triangles.empty() || top_obj_triangles.empty() || top_sup_triangles.empty()) && obj->is_step_done(slaposIndexSlices))
{
const std::vector<ExPolygons>& model_slices = obj->get_model_slices();
const std::vector<ExPolygons>& support_slices = obj->get_support_slices();
// FIXME: is this all right (by Tamas)?
auto slice_range = obj->get_slice_records(coord_t(min_z / SCALING_FACTOR),
coord_t(max_z / SCALING_FACTOR));
const ExPolygons& obj_bottom = obj->get_slices_from_record(slice_range.begin(), soModel);
const ExPolygons& obj_top = obj->get_slices_from_record(std::prev(slice_range.end()), soModel);
const ExPolygons& sup_bottom = obj->get_slices_from_record(slice_range.begin(), soSupport);
const ExPolygons& sup_top = obj->get_slices_from_record(std::prev(slice_range.end()), soSupport);
const SLAPrintObject::SliceIndex& index = obj->get_slice_index();
SLAPrintObject::SliceIndex::const_iterator it_min_z = std::find_if(index.begin(), index.end(), [min_z](const SLAPrintObject::SliceIndex::value_type& id) -> bool { return std::abs(min_z - id.first) < EPSILON; });
SLAPrintObject::SliceIndex::const_iterator it_max_z = std::find_if(index.begin(), index.end(), [max_z](const SLAPrintObject::SliceIndex::value_type& id) -> bool { return std::abs(max_z - id.first) < EPSILON; });
// calculate model bottom cap
if(bottom_obj_triangles.empty() && !obj_bottom.empty())
bottom_obj_triangles = triangulate_expolygons_3d(obj_bottom, min_z, true);
if (it_min_z != index.end())
{
// calculate model bottom cap
if (bottom_obj_triangles.empty() && (it_min_z->second.model_slices_idx < model_slices.size()))
bottom_obj_triangles = triangulate_expolygons_3d(model_slices[it_min_z->second.model_slices_idx], min_z, true);
// calculate support bottom cap
if (bottom_sup_triangles.empty() && (it_min_z->second.support_slices_idx < support_slices.size()))
bottom_sup_triangles = triangulate_expolygons_3d(support_slices[it_min_z->second.support_slices_idx], min_z, true);
}
// calculate support bottom cap
if(bottom_sup_triangles.empty() && !sup_bottom.empty())
bottom_sup_triangles = triangulate_expolygons_3d(sup_bottom, min_z, true);
if (it_max_z != index.end())
{
// calculate model top cap
if (top_obj_triangles.empty() && (it_max_z->second.model_slices_idx < model_slices.size()))
top_obj_triangles = triangulate_expolygons_3d(model_slices[it_max_z->second.model_slices_idx], max_z, false);
// calculate support top cap
if (top_sup_triangles.empty() && (it_max_z->second.support_slices_idx < support_slices.size()))
top_sup_triangles = triangulate_expolygons_3d(support_slices[it_max_z->second.support_slices_idx], max_z, false);
}
// calculate model top cap
if(top_obj_triangles.empty() && !obj_top.empty())
top_obj_triangles = triangulate_expolygons_3d(obj_top, max_z, false);
// calculate support top cap
if(top_sup_triangles.empty() && !sup_top.empty())
top_sup_triangles = triangulate_expolygons_3d(sup_top, max_z, false);
// const std::vector<ExPolygons>& model_slices = obj->get_model_slices();
// const std::vector<ExPolygons>& support_slices = obj->get_support_slices();
// const SLAPrintObject::SliceIndex& index = obj->get_slice_index();
// SLAPrintObject::SliceIndex::const_iterator it_min_z = std::find_if(index.begin(), index.end(), [min_z](const SLAPrintObject::SliceIndex::value_type& id) -> bool { return std::abs(min_z - id.first) < EPSILON; });
// SLAPrintObject::SliceIndex::const_iterator it_max_z = std::find_if(index.begin(), index.end(), [max_z](const SLAPrintObject::SliceIndex::value_type& id) -> bool { return std::abs(max_z - id.first) < EPSILON; });
// if (it_min_z != index.end())
// {
// // calculate model bottom cap
// if (bottom_obj_triangles.empty() && (it_min_z->second.model_slices_idx < model_slices.size()))
// bottom_obj_triangles = triangulate_expolygons_3d(model_slices[it_min_z->second.model_slices_idx], min_z, true);
// // calculate support bottom cap
// if (bottom_sup_triangles.empty() && (it_min_z->second.support_slices_idx < support_slices.size()))
// bottom_sup_triangles = triangulate_expolygons_3d(support_slices[it_min_z->second.support_slices_idx], min_z, true);
// }
// if (it_max_z != index.end())
// {
// // calculate model top cap
// if (top_obj_triangles.empty() && (it_max_z->second.model_slices_idx < model_slices.size()))
// top_obj_triangles = triangulate_expolygons_3d(model_slices[it_max_z->second.model_slices_idx], max_z, false);
// // calculate support top cap
// if (top_sup_triangles.empty() && (it_max_z->second.support_slices_idx < support_slices.size()))
// top_sup_triangles = triangulate_expolygons_3d(support_slices[it_max_z->second.support_slices_idx], max_z, false);
// }
}
if (!bottom_obj_triangles.empty() || !top_obj_triangles.empty() || !bottom_sup_triangles.empty() || !top_sup_triangles.empty())

View file

@ -775,10 +775,10 @@ void Preview::load_print_as_sla()
double shift_z = obj->get_current_elevation();
if (obj->is_step_done(slaposIndexSlices))
{
const SLAPrintObject::SliceIndex& index = obj->get_slice_index();
for (const SLAPrintObject::SliceIndex::value_type& id : index)
auto slicerecords = obj->get_slice_records();
for (auto& rec : slicerecords)
{
zs.insert(shift_z + id.first);
zs.insert(shift_z + /*rec.slice_level()*/ rec.key() * SCALING_FACTOR);
}
}
}