2013-11-22 01:16:10 +00:00
|
|
|
#include "SurfaceCollection.hpp"
|
2013-11-22 23:07:04 +00:00
|
|
|
#include <map>
|
2013-11-22 01:16:10 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
|
|
|
void
|
2013-11-22 15:01:50 +00:00
|
|
|
SurfaceCollection::simplify(double tolerance)
|
2013-11-22 01:16:10 +00:00
|
|
|
{
|
2013-11-22 15:01:50 +00:00
|
|
|
Surfaces ss;
|
|
|
|
for (Surfaces::const_iterator it_s = this->surfaces.begin(); it_s != this->surfaces.end(); ++it_s) {
|
|
|
|
ExPolygons expp;
|
|
|
|
it_s->expolygon.simplify(tolerance, expp);
|
|
|
|
for (ExPolygons::const_iterator it_e = expp.begin(); it_e != expp.end(); ++it_e) {
|
|
|
|
Surface s = *it_s;
|
|
|
|
s.expolygon = *it_e;
|
|
|
|
ss.push_back(s);
|
|
|
|
}
|
2013-11-22 01:16:10 +00:00
|
|
|
}
|
2013-11-22 15:01:50 +00:00
|
|
|
this->surfaces = ss;
|
2013-11-22 01:16:10 +00:00
|
|
|
}
|
|
|
|
|
2013-11-22 23:07:04 +00:00
|
|
|
/* group surfaces by common properties */
|
|
|
|
void
|
2014-02-10 12:19:44 +00:00
|
|
|
SurfaceCollection::group(std::vector<SurfacesPtr> *retval)
|
2013-11-22 23:07:04 +00:00
|
|
|
{
|
2013-11-23 17:15:59 +00:00
|
|
|
for (Surfaces::iterator it = this->surfaces.begin(); it != this->surfaces.end(); ++it) {
|
2013-12-03 23:10:31 +00:00
|
|
|
// find a group with the same properties
|
|
|
|
SurfacesPtr* group = NULL;
|
|
|
|
for (std::vector<SurfacesPtr>::iterator git = retval->begin(); git != retval->end(); ++git) {
|
|
|
|
Surface* gkey = git->front();
|
2014-02-10 12:19:44 +00:00
|
|
|
if ( gkey->surface_type == it->surface_type
|
2013-12-03 23:10:31 +00:00
|
|
|
&& gkey->thickness == it->thickness
|
|
|
|
&& gkey->thickness_layers == it->thickness_layers
|
|
|
|
&& gkey->bridge_angle == it->bridge_angle) {
|
|
|
|
group = &*git;
|
|
|
|
break;
|
|
|
|
}
|
2013-11-22 23:07:04 +00:00
|
|
|
}
|
|
|
|
|
2013-12-03 23:10:31 +00:00
|
|
|
// if no group with these properties exists, add one
|
|
|
|
if (group == NULL) {
|
|
|
|
retval->resize(retval->size() + 1);
|
|
|
|
group = &retval->back();
|
2013-11-22 23:07:04 +00:00
|
|
|
}
|
2013-12-03 23:10:31 +00:00
|
|
|
|
|
|
|
// append surface to group
|
|
|
|
group->push_back(&*it);
|
2013-11-22 23:07:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-27 17:18:53 +00:00
|
|
|
#ifdef SLIC3RXS
|
|
|
|
REGISTER_CLASS(SurfaceCollection, "Surface::Collection");
|
|
|
|
#endif
|
|
|
|
|
2013-11-22 01:16:10 +00:00
|
|
|
}
|