From 2a31f5e6fc81438984bd28de707505458d817b9f Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Mon, 26 Nov 2018 15:03:57 +0100 Subject: [PATCH] Refinement of the slice index interface --- src/libslic3r/SLAPrint.cpp | 10 ++++++++++ src/libslic3r/SLAPrint.hpp | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index a40aebc45..605391a9d 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -564,6 +564,8 @@ void SLAPrint::process() // layers according to quantized height levels std::map levels; + // We have the layer polygon collection but we need to unite them into + // an index where the key is the height level in discrete levels (clipper) auto index_slices = [this, ilh, ilhd, &levels](SLAPrintObject& po) { auto sih = LevelID(scale_(ilh)); @@ -606,11 +608,18 @@ void SLAPrint::process() } } + // shortcut for empty index into the slice vectors + static const auto EMPTY_SLICE = SLAPrintObject::SliceRecord::NONE; + for(int i = 0; i < oslices.size(); ++i) { LevelID h = levelids[i]; auto& lyrs = levels[h]; // this initializes a new record lyrs.emplace_back(oslices[i], po.m_instances); + + // now for the public slice index: SLAPrintObject::SliceRecord& sr = po.m_slice_index[h]; + // There should be only one slice layer for each print object + assert(sr.model_slices_idx == EMPTY_SLICE); sr.model_slices_idx = i; } @@ -625,6 +634,7 @@ void SLAPrint::process() lyrs.emplace_back(sslices[i], po.m_instances); SLAPrintObject::SliceRecord& sr = po.m_slice_index[h]; + assert(sr.support_slices_idx == EMPTY_SLICE); sr.support_slices_idx = i; } } diff --git a/src/libslic3r/SLAPrint.hpp b/src/libslic3r/SLAPrint.hpp index 1f6695dbf..88b207d82 100644 --- a/src/libslic3r/SLAPrint.hpp +++ b/src/libslic3r/SLAPrint.hpp @@ -87,12 +87,16 @@ public: const std::vector& get_model_slices() const; const std::vector& get_support_slices() const; + // An index record referencing the slices + // (get_model_slices(), get_support_slices()) where the keys are the height + // levels of the model in scaled-clipper coordinates. The levels correspond + // to the z coordinate of the object coordinate system. struct SliceRecord { using Key = long long; inline static float scale_back(Key h) { return float(scale_(h)); } using Idx = size_t; - static const Idx NONE = ULONG_MAX; // std::numeric_limits::max() // damn msvc 2013... ; + static const Idx NONE = Idx(-1); // this will be the max limit of size_t Idx model_slices_idx = NONE; Idx support_slices_idx = NONE;