Merge branch 'master' into xs-model
This commit is contained in:
commit
0339d5423d
@ -171,7 +171,7 @@ sub bounding_box {
|
|||||||
if (!defined $self->_bounding_box) {
|
if (!defined $self->_bounding_box) {
|
||||||
$self->_bounding_box(Slic3r::Geometry::BoundingBox->merge(map $_->bounding_box, @{$self->objects}));
|
$self->_bounding_box(Slic3r::Geometry::BoundingBox->merge(map $_->bounding_box, @{$self->objects}));
|
||||||
}
|
}
|
||||||
return $self->_bounding_box;
|
return $self->_bounding_box->clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub align_to_origin {
|
sub align_to_origin {
|
||||||
@ -368,7 +368,7 @@ sub bounding_box {
|
|||||||
$bounding_box->merge(Slic3r::Geometry::BoundingBox->new_from_bb($_->bb3)) for @meshes;
|
$bounding_box->merge(Slic3r::Geometry::BoundingBox->new_from_bb($_->bb3)) for @meshes;
|
||||||
$self->_bounding_box($bounding_box);
|
$self->_bounding_box($bounding_box);
|
||||||
}
|
}
|
||||||
return $self->_bounding_box;
|
return $self->_bounding_box->clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub align_to_origin {
|
sub align_to_origin {
|
||||||
|
@ -21,34 +21,31 @@ SurfaceCollection::simplify(double tolerance)
|
|||||||
|
|
||||||
/* group surfaces by common properties */
|
/* group surfaces by common properties */
|
||||||
void
|
void
|
||||||
SurfaceCollection::group(std::vector<SurfacesPtr> &retval, bool merge_solid)
|
SurfaceCollection::group(std::vector<SurfacesPtr> *retval, bool merge_solid)
|
||||||
{
|
{
|
||||||
typedef std::map<t_surface_group_key,SurfacesPtr> t_unique_map;
|
|
||||||
t_unique_map unique_map;
|
|
||||||
|
|
||||||
for (Surfaces::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
|
// find a group with the same properties
|
||||||
t_surface_group_key key;
|
SurfacesPtr* group = NULL;
|
||||||
if (merge_solid && it->is_solid()) {
|
for (std::vector<SurfacesPtr>::iterator git = retval->begin(); git != retval->end(); ++git) {
|
||||||
key.surface_type = stTop;
|
Surface* gkey = git->front();
|
||||||
} else {
|
if ((gkey->surface_type == it->surface_type || (merge_solid && gkey->is_solid() && it->is_solid()))
|
||||||
key.surface_type = it->surface_type;
|
&& gkey->thickness == it->thickness
|
||||||
|
&& gkey->thickness_layers == it->thickness_layers
|
||||||
|
&& gkey->bridge_angle == it->bridge_angle) {
|
||||||
|
group = &*git;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
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 no group with these properties exists, add one
|
||||||
if (unique_map.find(key) == unique_map.end()) {
|
if (group == NULL) {
|
||||||
// no group exists, add it
|
retval->resize(retval->size() + 1);
|
||||||
unique_map[key] = SurfacesPtr();
|
group = &retval->back();
|
||||||
}
|
}
|
||||||
unique_map[key].push_back(&*it);
|
|
||||||
|
// append surface to group
|
||||||
|
group->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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,26 +6,12 @@
|
|||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
struct t_surface_group_key {
|
|
||||||
SurfaceType surface_type;
|
|
||||||
double thickness;
|
|
||||||
unsigned short thickness_layers;
|
|
||||||
double bridge_angle;
|
|
||||||
|
|
||||||
bool operator< (const t_surface_group_key &key) const {
|
|
||||||
return (this->surface_type < key.surface_type)
|
|
||||||
|| (this->thickness < key.thickness)
|
|
||||||
|| (this->thickness_layers < key.thickness_layers)
|
|
||||||
|| (this->bridge_angle < key.bridge_angle);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class SurfaceCollection
|
class SurfaceCollection
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Surfaces surfaces;
|
Surfaces surfaces;
|
||||||
void simplify(double tolerance);
|
void simplify(double tolerance);
|
||||||
void group(std::vector<SurfacesPtr> &retval, bool merge_solid = false);
|
void group(std::vector<SurfacesPtr> *retval, bool merge_solid = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ SurfaceCollection::group(merge_solid = false)
|
|||||||
CODE:
|
CODE:
|
||||||
// perform grouping
|
// perform grouping
|
||||||
std::vector<SurfacesPtr> groups;
|
std::vector<SurfacesPtr> groups;
|
||||||
THIS->group(groups, merge_solid);
|
THIS->group(&groups, merge_solid);
|
||||||
|
|
||||||
// build return arrayref
|
// build return arrayref
|
||||||
AV* av = newAV();
|
AV* av = newAV();
|
||||||
|
Loading…
Reference in New Issue
Block a user