diff --git a/src/libslic3r/KDTreeIndirect.hpp b/src/libslic3r/KDTreeIndirect.hpp index 9aa3682b3e..40e012df1d 100644 --- a/src/libslic3r/KDTreeIndirect.hpp +++ b/src/libslic3r/KDTreeIndirect.hpp @@ -38,10 +38,12 @@ public: KDTreeIndirect(CoordinateFn coordinate, std::vector indices) : coordinate(coordinate) { this->build(indices); } KDTreeIndirect(CoordinateFn coordinate, size_t num_indices) : coordinate(coordinate) { this->build(num_indices); } KDTreeIndirect(KDTreeIndirect &&rhs) : m_nodes(std::move(rhs.m_nodes)), coordinate(std::move(rhs.coordinate)) {} - KDTreeIndirect(const KDTreeIndirect &rhs) : m_nodes(rhs.m_nodes), coordinate(rhs.coordinate) {} KDTreeIndirect& operator=(KDTreeIndirect &&rhs) { m_nodes = std::move(rhs.m_nodes); coordinate = std::move(rhs.coordinate); return *this; } void clear() { m_nodes.clear(); } const std::vector &get_nodes() const { return m_nodes; } + // NOTE: Copy constructor cause failing FDM tests but not each run only from time to time. + // KDTreeIndirect(const KDTreeIndirect &rhs) : m_nodes(rhs.m_nodes), coordinate(rhs.coordinate) {} + KDTreeIndirect get_copy() const { KDTreeIndirect copy(coordinate); copy.m_nodes = m_nodes; return copy; } void build(size_t num_indices) { std::vector indices; diff --git a/src/libslic3r/SLA/SupportPointGenerator.cpp b/src/libslic3r/SLA/SupportPointGenerator.cpp index 53870116e1..a01d29a971 100644 --- a/src/libslic3r/SLA/SupportPointGenerator.cpp +++ b/src/libslic3r/SLA/SupportPointGenerator.cpp @@ -47,6 +47,12 @@ public: explicit NearPoints(LayerSupportPoints* supports_ptr) : m_points(supports_ptr), m_tree(m_points) {} + NearPoints get_copy(){ + NearPoints copy(m_points.m_supports_ptr); + copy.m_tree = m_tree.get_copy(); // copy tree + return copy; + } + /// /// Remove support points from KD-Tree which lay out of expolygons /// @@ -199,7 +205,7 @@ NearPoints create_near_points( NearPoints near_points = (prev_part_it->next_parts.size() == 1)? std::move(prev_grids[index_of_prev_part]) : // Need a copy there are multiple parts above previus one - prev_grids[index_of_prev_part]; // copy + prev_grids[index_of_prev_part].get_copy(); // copy // merge other grid in case of multiple previous parts for (size_t i = 1; i < part.prev_parts.size(); ++i) { @@ -208,7 +214,7 @@ NearPoints create_near_points( if (prev_part_it->next_parts.size() == 1) { near_points.merge(std::move(prev_grids[index_of_prev_part])); } else { // Need a copy there are multiple parts above previus one - NearPoints grid_ = prev_grids[index_of_prev_part]; // copy + NearPoints grid_ = prev_grids[index_of_prev_part].get_copy(); // copy near_points.merge(std::move(grid_)); } }