mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 06:26:05 +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
|
// assign top and bottom surfaces to layer
|
||||||
SurfaceCollection tmp_coll;
|
SurfaceCollection tmp_coll;
|
||||||
for (const auto& s : neighbor_fill_surfaces.surfaces)
|
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);
|
tmp_coll.append(s);
|
||||||
|
|
||||||
for (auto s : tmp_coll.group()) {
|
for (auto s : tmp_coll.group()) {
|
||||||
|
@ -200,12 +200,23 @@ SurfaceCollection::keep_type(const SurfaceType type)
|
|||||||
void
|
void
|
||||||
SurfaceCollection::keep_types(const SurfaceType *types, size_t ntypes)
|
SurfaceCollection::keep_types(const SurfaceType *types, size_t ntypes)
|
||||||
{
|
{
|
||||||
size_t n {0};
|
size_t j = 0;
|
||||||
for (size_t i = 0; i < ntypes; ++i)
|
for (size_t i = 0; i < surfaces.size(); ++ i) {
|
||||||
n |= types[i]; // form bitmask.
|
bool keep = false;
|
||||||
// Use stl remove_if to remove
|
for (int k = 0; k < ntypes; ++ k) {
|
||||||
auto ptr = std::remove_if(surfaces.begin(), surfaces.end(),[n] (const Surface& s) { return (s.surface_type & n) != s.surface_type; });
|
if (surfaces[i].surface_type == types[k]) {
|
||||||
surfaces.erase(ptr, surfaces.cend());
|
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
|
void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user