From 69f1f65a8bba85a677434746af86ebc6d4a87a8f Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 12 Jan 2014 16:01:14 +0100 Subject: [PATCH] Because of numerical instability, lower_bound() was not including a layer having z == 0.8 even if the facet's min_z == 0.8. #1672 --- xs/src/TriangleMesh.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xs/src/TriangleMesh.cpp b/xs/src/TriangleMesh.cpp index 3ed7e777b6..246d94a6dd 100644 --- a/xs/src/TriangleMesh.cpp +++ b/xs/src/TriangleMesh.cpp @@ -276,8 +276,8 @@ TriangleMesh::slice(const std::vector &z, std::vector* layers) // find layer extents std::vector::const_iterator min_layer, max_layer; - min_layer = std::lower_bound(z.begin(), z.end(), min_z); // first layer whose slice_z is >= min_z - max_layer = std::upper_bound(z.begin() + (min_layer - z.begin()), z.end(), max_z) - 1; // last layer whose slice_z is <= max_z + min_layer = std::lower_bound(z.begin(), z.end(), min_z - EPSILON); // first layer whose slice_z is >= min_z + max_layer = std::upper_bound(z.begin() + (min_layer - z.begin()), z.end(), max_z + EPSILON) - 1; // last layer whose slice_z is <= max_z #ifdef SLIC3R_DEBUG printf("layers: min = %d, max = %d\n", (int)(min_layer - z.begin()), (int)(max_layer - z.begin())); #endif