Using same slicing grid for the supports and the model.

This commit is contained in:
tamasmeszaros 2019-03-21 16:14:26 +01:00
parent 0ffc0c3a84
commit 63a899b239
4 changed files with 54 additions and 40 deletions

View file

@ -2240,6 +2240,18 @@ SlicedSupports SLASupportTree::slice(float layerh, float init_layerh) const
return ret; return ret;
} }
SlicedSupports SLASupportTree::slice(const std::vector<float> &heights,
float cr) const
{
TriangleMesh fullmesh = m_impl->merged_mesh();
fullmesh.merge(get_pad());
TriangleMeshSlicer slicer(&fullmesh);
SlicedSupports ret;
slicer.slice(heights, cr, &ret, get().ctl().cancelfn);
return ret;
}
const TriangleMesh &SLASupportTree::add_pad(const SliceLayer& baseplate, const TriangleMesh &SLASupportTree::add_pad(const SliceLayer& baseplate,
const PoolConfig& pcfg) const const PoolConfig& pcfg) const
{ {

View file

@ -181,6 +181,8 @@ public:
/// Get the sliced 2d layers of the support geometry. /// Get the sliced 2d layers of the support geometry.
SlicedSupports slice(float layerh, float init_layerh = -1.0) const; SlicedSupports slice(float layerh, float init_layerh = -1.0) const;
SlicedSupports slice(const std::vector<float>&, float closing_radius) const;
/// Adding the "pad" (base pool) under the supports /// Adding the "pad" (base pool) under the supports
const TriangleMesh& add_pad(const SliceLayer& baseplate, const TriangleMesh& add_pad(const SliceLayer& baseplate,
const PoolConfig& pcfg) const; const PoolConfig& pcfg) const;

View file

@ -856,11 +856,19 @@ void SLAPrint::process()
// Slicing the support geometries similarly to the model slicing procedure. // Slicing the support geometries similarly to the model slicing procedure.
// If the pad had been added previously (see step "base_pool" than it will // If the pad had been added previously (see step "base_pool" than it will
// be part of the slices) // be part of the slices)
auto slice_supports = [ilh](SLAPrintObject& po) { auto slice_supports = [](SLAPrintObject& po) {
auto& sd = po.m_supportdata; auto& sd = po.m_supportdata;
if(sd && sd->support_tree_ptr) { if(sd && sd->support_tree_ptr) {
auto lh = float(po.m_config.layer_height.getFloat()); sd->support_slices.clear();
sd->support_slices = sd->support_tree_ptr->slice(lh, ilh);
std::vector<float> heights; heights.reserve(po.m_slice_index.size());
for(auto& rec : po.m_slice_index) {
heights.emplace_back(rec.slice_level());
}
sd->support_slices = sd->support_tree_ptr->slice(
heights, float(po.config().slice_closing_radius.value));
} }
for(size_t i = 0; for(size_t i = 0;
@ -1613,20 +1621,6 @@ SLAPrintObject::search_slice_index(SLAPrintObject::SliceRecord::Key key) const
return it; return it;
} }
SliceIterator SLAPrintObject::get_slices(SliceOrigin so, LevelID k) const
{
SliceIterator ret = so == soModel ? get_model_slices().end() :
get_support_slices().end();
auto it = search_slice_index(k);
if(it != m_slice_index.end()) {
ret = it->get_slices(*this, so);
}
return ret;
}
SliceRange SLAPrintObject::get_slices(SliceOrigin so, SliceRange SLAPrintObject::get_slices(SliceOrigin so,
float from_level, float from_level,
float to_level) const float to_level) const
@ -1658,23 +1652,6 @@ SLAPrintObject::get_slice_index() const
return m_slice_index; return m_slice_index;
} }
//std::vector<float> SLAPrintObject::get_slice_levels(float from_eq) const
//{
// using SlRec = SLAPrintObject::SliceRecord;
// auto it = std::lower_bound(m_slice_index.begin(),
// m_slice_index.end(),
// from_eq, // model start z
// [](const SlRec& sr1, const SlRec& sr2){
// return sr1.slice_level() < sr2.slice_level();
// });
// std::vector<float> heights; heights.reserve(m_slice_index.size());
// for(; it != m_slice_index.end(); ++it)
// heights.emplace_back(it->slice_level());
//}
const std::vector<ExPolygons> &SLAPrintObject::get_model_slices() const const std::vector<ExPolygons> &SLAPrintObject::get_model_slices() const
{ {
// assert(is_step_done(slaposObjectSlice)); // assert(is_step_done(slaposObjectSlice));

View file

@ -122,7 +122,7 @@ private:
size_t m_model_slices_idx = NONE; size_t m_model_slices_idx = NONE;
size_t m_support_slices_idx = NONE; size_t m_support_slices_idx = NONE;
LevelID m_print_z = 0; // Top of the layer LevelID m_print_z = 0; // Top of the layer
float m_slice_z = 0.f; // Exact level of the slice float m_slice_z = 0.f; // Exact level of the slice
float m_height = 0.f; // Height of the sliced layer float m_height = 0.f; // Height of the sliced layer
@ -131,34 +131,54 @@ private:
SliceRecord(Key key, float slicez, float height): SliceRecord(Key key, float slicez, float height):
m_print_z(key), m_slice_z(slicez), m_height(height) {} m_print_z(key), m_slice_z(slicez), m_height(height) {}
// The key will be the integer height level of the top of the layer.
inline Key key() const { return m_print_z; } inline Key key() const { return m_print_z; }
// Returns the exact floating point Z coordinate of the slice
inline float slice_level() const { return m_slice_z; } inline float slice_level() const { return m_slice_z; }
// Returns the current layer height
inline float layer_height() const { return m_height; } inline float layer_height() const { return m_height; }
SliceIterator get_slices(const SLAPrintObject& po, // Returns the slices for eighter the model or the supports. The return
SliceOrigin so) const; // value is an iterator to po.get_model_slices() or po.get_support_slices
// depending on the SliceOrigin parameter.
SliceIterator get_slices(const SLAPrintObject& po, SliceOrigin so) const;
// Methods for setting the indixes into the slice vectors.
void set_model_slice_idx(size_t id) { m_model_slices_idx = id; } void set_model_slice_idx(size_t id) { m_model_slices_idx = id; }
void set_support_slice_idx(size_t id) { m_support_slices_idx = id; } void set_support_slice_idx(size_t id) { m_support_slices_idx = id; }
}; };
// Slice index will be a plain vector sorted by the integer height levels
using SliceIndex = std::vector<SliceRecord>; using SliceIndex = std::vector<SliceRecord>;
// Retrieve the slice index which is readable only after slaposIndexSlices // Retrieve the slice index which is readable only after slaposIndexSlices
// is done. // is done.
const SliceIndex& get_slice_index() const; const SliceIndex& get_slice_index() const;
// Search slice index for the closest slice to the given level
SliceIndex::iterator search_slice_index(float slice_level); SliceIndex::iterator search_slice_index(float slice_level);
SliceIndex::const_iterator search_slice_index(float slice_level) const; SliceIndex::const_iterator search_slice_index(float slice_level) const;
// Search the slice index for a particular level in integer coordinates.
// If no such layer is present, it will return m_slice_index.end()
SliceIndex::iterator search_slice_index(SliceRecord::Key key); SliceIndex::iterator search_slice_index(SliceRecord::Key key);
SliceIndex::const_iterator search_slice_index(SliceRecord::Key key) const; SliceIndex::const_iterator search_slice_index(SliceRecord::Key key) const;
public: public:
SliceIterator get_slices(SliceOrigin so, LevelID k) const; // /////////////////////////////////////////////////////////////////////////
// The following methods can be used after the model and the support slicing
// steps have been succesfully finished.
// /////////////////////////////////////////////////////////////////////////
// Getting slices for either the model or the supports for a particular
// height ID.
// SliceIterator get_slices(SliceOrigin so, LevelID k) const;
// Getting slices (model or supports) for a Z coordinate range. The returned
// iterators should include the slices for the given boundaries as well.
SliceRange get_slices( SliceRange get_slices(
SliceOrigin so, SliceOrigin so,
float from_level, float from_level,
@ -171,7 +191,10 @@ public:
const std::vector<ExPolygons>& get_model_slices() const; const std::vector<ExPolygons>& get_model_slices() const;
const std::vector<ExPolygons>& get_support_slices() const; const std::vector<ExPolygons>& get_support_slices() const;
// Returns the total number of slices in the slice grid (model and supports)
inline size_t get_slice_count() const { return m_slice_index.size(); } inline size_t get_slice_count() const { return m_slice_index.size(); }
// One can query the Z coordinate of the slice for a given
inline float get_slice_level(size_t idx) const { inline float get_slice_level(size_t idx) const {
return m_slice_index[idx].slice_level(); return m_slice_index[idx].slice_level();
} }