diff options
Diffstat (limited to 'xs/src/libslic3r/SlicingAdaptive.cpp')
-rw-r--r-- | xs/src/libslic3r/SlicingAdaptive.cpp | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/xs/src/libslic3r/SlicingAdaptive.cpp b/xs/src/libslic3r/SlicingAdaptive.cpp index b7f116770..d501d6f62 100644 --- a/xs/src/libslic3r/SlicingAdaptive.cpp +++ b/xs/src/libslic3r/SlicingAdaptive.cpp @@ -22,22 +22,13 @@ std::pair<float, float> face_z_span(const stl_facet *f) void SlicingAdaptive::prepare() { // 1) Collect faces of all meshes. - { - int nfaces_total = 0; - for (std::vector<const TriangleMesh*>::const_iterator it_mesh = m_meshes.begin(); it_mesh != m_meshes.end(); ++ it_mesh) - nfaces_total += (*it_mesh)->stl.stats.number_of_facets; - m_faces.reserve(nfaces_total); - } - m_max_z = 0; - for (std::vector<const TriangleMesh*>::const_iterator it_mesh = m_meshes.begin(); it_mesh != m_meshes.end(); ++ it_mesh) { - const stl_facet *faces = (*it_mesh)->stl.facet_start; - int nfaces = (*it_mesh)->stl.stats.number_of_facets; - for (int i = 0; i < nfaces; ++ i) { - const stl_facet *facet = faces + i; - m_faces.push_back(facet); - m_max_z = std::max(std::max(m_max_z, facet->vertex[0].z), std::max(facet->vertex[1].z, facet->vertex[2].z)); - } - } + int nfaces_total = 0; + for (std::vector<const TriangleMesh*>::const_iterator it_mesh = m_meshes.begin(); it_mesh != m_meshes.end(); ++ it_mesh) + nfaces_total += (*it_mesh)->stl.stats.number_of_facets; + m_faces.reserve(nfaces_total); + for (std::vector<const TriangleMesh*>::const_iterator it_mesh = m_meshes.begin(); it_mesh != m_meshes.end(); ++ it_mesh) + for (int i = 0; i < (*it_mesh)->stl.stats.number_of_facets; ++ i) + m_faces.push_back((*it_mesh)->stl.facet_start + i); // 2) Sort faces lexicographically by their Z span. std::sort(m_faces.begin(), m_faces.end(), [](const stl_facet *f1, const stl_facet *f2) { @@ -54,7 +45,7 @@ void SlicingAdaptive::prepare() float SlicingAdaptive::cusp_height(float z, float cusp_value, int ¤t_facet) { - float height = m_layer_height_max; + float height = m_slicing_params.max_layer_height; bool first_hit = false; // find all facets intersecting the slice-layer @@ -81,10 +72,10 @@ float SlicingAdaptive::cusp_height(float z, float cusp_value, int ¤t_facet } // lower height limit due to printer capabilities - height = std::max(height, m_layer_height_min); + height = std::max(height, float(m_slicing_params.min_layer_height)); // check for sloped facets inside the determined layer and correct height if necessary - if (height > m_layer_height_min) { + if (height > m_slicing_params.min_layer_height) { for (; ordered_id < int(m_faces.size()); ++ ordered_id) { std::pair<float, float> zspan = face_z_span(m_faces[ordered_id]); // facet's minimum is higher than slice_z + height -> end loop @@ -119,7 +110,7 @@ float SlicingAdaptive::cusp_height(float z, float cusp_value, int ¤t_facet } } // lower height limit due to printer capabilities again - height = std::max(height, m_layer_height_min); + height = std::max(height, float(m_slicing_params.min_layer_height)); } // Slic3r::debugf "cusp computation, layer-bottom at z:%f, cusp_value:%f, resulting layer height:%f\n", unscale $z, $cusp_value, $height; @@ -133,7 +124,7 @@ float SlicingAdaptive::horizontal_facet_distance(float z) for (size_t i = 0; i < m_faces.size(); ++ i) { std::pair<float, float> zspan = face_z_span(m_faces[i]); // facet's minimum is higher than max forward distance -> end loop - if (zspan.first > z + m_layer_height_max) + if (zspan.first > z + m_slicing_params.max_layer_height) break; // min_z == max_z -> horizontal facet if (zspan.first > z && zspan.first == zspan.second) @@ -141,9 +132,9 @@ float SlicingAdaptive::horizontal_facet_distance(float z) } // objects maximum? - return (z + m_layer_height_max > m_max_z) ? - std::max<float>(m_max_z - z, 0.f) : - m_layer_height_max; + return (z + m_slicing_params.max_layer_height > m_slicing_params.object_print_z_height()) ? + std::max<float>(m_slicing_params.object_print_z_height() - z, 0.f) : + m_slicing_params.max_layer_height; } }; // namespace Slic3r |