mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-20 05:07:51 -06:00
Ported is_solid() and is_bridge() to XS. Also ported (but not used yet) group() to SurfaceCollection::group()
This commit is contained in:
parent
de9d5403e8
commit
878d587196
6 changed files with 68 additions and 22 deletions
|
@ -1,4 +1,5 @@
|
|||
#include "SurfaceCollection.hpp"
|
||||
#include <map>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
|
@ -18,4 +19,36 @@ SurfaceCollection::simplify(double tolerance)
|
|||
this->surfaces = ss;
|
||||
}
|
||||
|
||||
/* group surfaces by common properties */
|
||||
void
|
||||
SurfaceCollection::group(std::vector<Surfaces> &retval, bool merge_solid) const
|
||||
{
|
||||
typedef std::map<t_surface_group_key,Surfaces> t_unique_map;
|
||||
t_unique_map unique_map;
|
||||
|
||||
for (Surfaces::const_iterator it = this->surfaces.begin(); it != this->surfaces.end(); ++it) {
|
||||
// build the t_surface_group_key struct with this surface's properties
|
||||
t_surface_group_key key;
|
||||
if (merge_solid && it->is_solid()) {
|
||||
key.surface_type = stTop;
|
||||
} else {
|
||||
key.surface_type = it->surface_type;
|
||||
}
|
||||
key.thickness = it->thickness;
|
||||
key.thickness_layers = it->thickness_layers;
|
||||
key.bridge_angle = it->bridge_angle;
|
||||
|
||||
// check whether we already have a group for these properties
|
||||
if (unique_map.find(key) == unique_map.end()) {
|
||||
// no group exists, add it
|
||||
unique_map[key] = Surfaces();
|
||||
}
|
||||
unique_map[key].push_back(*it);
|
||||
}
|
||||
|
||||
retval.reserve(unique_map.size());
|
||||
for (t_unique_map::const_iterator it = unique_map.begin(); it != unique_map.end(); ++it)
|
||||
retval.push_back(it->second);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue