mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-12 21:39:07 +08:00
remove bad algo from keep_types
This commit is contained in:
parent
8b9ea5fe1c
commit
5d1e01839c
@ -1641,7 +1641,7 @@ PrintObject::_discover_neighbor_horizontal_shells(LayerRegion* layerm, const siz
|
||||
// assign top and bottom surfaces to layer
|
||||
SurfaceCollection tmp_coll;
|
||||
for (const auto& s : neighbor_fill_surfaces.surfaces)
|
||||
if (s.surface_type == stTop || s.is_bottom())
|
||||
if (s.is_top() || s.is_bottom())
|
||||
tmp_coll.append(s);
|
||||
|
||||
for (auto s : tmp_coll.group()) {
|
||||
|
@ -200,12 +200,23 @@ SurfaceCollection::keep_type(const SurfaceType type)
|
||||
void
|
||||
SurfaceCollection::keep_types(const SurfaceType *types, size_t ntypes)
|
||||
{
|
||||
size_t n {0};
|
||||
for (size_t i = 0; i < ntypes; ++i)
|
||||
n |= types[i]; // form bitmask.
|
||||
// Use stl remove_if to remove
|
||||
auto ptr = std::remove_if(surfaces.begin(), surfaces.end(),[n] (const Surface& s) { return (s.surface_type & n) != s.surface_type; });
|
||||
surfaces.erase(ptr, surfaces.cend());
|
||||
size_t j = 0;
|
||||
for (size_t i = 0; i < surfaces.size(); ++ i) {
|
||||
bool keep = false;
|
||||
for (int k = 0; k < ntypes; ++ k) {
|
||||
if (surfaces[i].surface_type == types[k]) {
|
||||
keep = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (keep) {
|
||||
if (j < i)
|
||||
std::swap(surfaces[i], surfaces[j]);
|
||||
++ j;
|
||||
}
|
||||
}
|
||||
if (j < surfaces.size())
|
||||
surfaces.erase(surfaces.begin() + j, surfaces.end());
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
x
Reference in New Issue
Block a user