mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-22 00:01:09 -06:00
Finished porting group() to XS
This commit is contained in:
parent
67a7e4f769
commit
a331f4d27a
11 changed files with 68 additions and 41 deletions
|
@ -30,6 +30,13 @@ Surface::to_SV_ref() {
|
|||
sv_setref_pv( sv, "Slic3r::Surface::Ref", (void*)this );
|
||||
return sv;
|
||||
}
|
||||
|
||||
SV*
|
||||
Surface::to_SV_clone_ref() const {
|
||||
SV* sv = newSV(0);
|
||||
sv_setref_pv( sv, "Slic3r::Surface", new Surface(*this) );
|
||||
return sv;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
@ -22,10 +22,12 @@ class Surface
|
|||
|
||||
#ifdef SLIC3RXS
|
||||
SV* to_SV_ref();
|
||||
SV* to_SV_clone_ref() const;
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef std::vector<Surface> Surfaces;
|
||||
typedef std::vector<Surface*> SurfacesPtr;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -21,12 +21,12 @@ SurfaceCollection::simplify(double tolerance)
|
|||
|
||||
/* group surfaces by common properties */
|
||||
void
|
||||
SurfaceCollection::group(std::vector<Surfaces> &retval, bool merge_solid) const
|
||||
SurfaceCollection::group(std::vector<SurfacesPtr> &retval, bool merge_solid)
|
||||
{
|
||||
typedef std::map<t_surface_group_key,Surfaces> t_unique_map;
|
||||
typedef std::map<t_surface_group_key,SurfacesPtr> t_unique_map;
|
||||
t_unique_map unique_map;
|
||||
|
||||
for (Surfaces::const_iterator it = this->surfaces.begin(); it != this->surfaces.end(); ++it) {
|
||||
for (Surfaces::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()) {
|
||||
|
@ -41,9 +41,9 @@ SurfaceCollection::group(std::vector<Surfaces> &retval, bool merge_solid) const
|
|||
// 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] = SurfacesPtr();
|
||||
}
|
||||
unique_map[key].push_back(*it);
|
||||
unique_map[key].push_back(&*it);
|
||||
}
|
||||
|
||||
retval.reserve(unique_map.size());
|
||||
|
|
|
@ -25,7 +25,7 @@ class SurfaceCollection
|
|||
public:
|
||||
Surfaces surfaces;
|
||||
void simplify(double tolerance);
|
||||
void group(std::vector<Surfaces> &retval, bool merge_solid = false) const;
|
||||
void group(std::vector<SurfacesPtr> &retval, bool merge_solid = false);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue