Perform additional checks before merging solid surfaces (i.e. take flow and fill pattern into account)

This commit is contained in:
Alessandro Ranellucci 2014-02-10 13:19:44 +01:00
parent 634ccb33ab
commit 3d483722c6
8 changed files with 62 additions and 9 deletions

View file

@ -16,6 +16,13 @@ Surface::is_solid() const
|| this->surface_type == stInternalSolid;
}
bool
Surface::is_external() const
{
return this->surface_type == stTop
|| this->surface_type == stBottom;
}
bool
Surface::is_bridge() const
{

View file

@ -18,6 +18,7 @@ class Surface
unsigned short extra_perimeters;
double area() const;
bool is_solid() const;
bool is_external() const;
bool is_bridge() const;
#ifdef SLIC3RXS

View file

@ -21,14 +21,14 @@ SurfaceCollection::simplify(double tolerance)
/* group surfaces by common properties */
void
SurfaceCollection::group(std::vector<SurfacesPtr> *retval, bool merge_solid)
SurfaceCollection::group(std::vector<SurfacesPtr> *retval)
{
for (Surfaces::iterator it = this->surfaces.begin(); it != this->surfaces.end(); ++it) {
// 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();
if ((gkey->surface_type == it->surface_type || (merge_solid && gkey->is_solid() && it->is_solid()))
if ( gkey->surface_type == it->surface_type
&& gkey->thickness == it->thickness
&& gkey->thickness_layers == it->thickness_layers
&& gkey->bridge_angle == it->bridge_angle) {

View file

@ -11,7 +11,7 @@ class SurfaceCollection
public:
Surfaces surfaces;
void simplify(double tolerance);
void group(std::vector<SurfacesPtr> *retval, bool merge_solid = false);
void group(std::vector<SurfacesPtr> *retval);
};
}

View file

@ -4,7 +4,7 @@ use strict;
use warnings;
use Slic3r::XS;
use Test::More tests => 16;
use Test::More tests => 15;
my $square = [ # ccw
[100, 100],
@ -71,7 +71,6 @@ is $surface->extra_perimeters, 2, 'extra_perimeters';
);
my $collection = Slic3r::Surface::Collection->new(@surfaces);
is scalar(@{$collection->group}), 2, 'group() returns correct number of groups';
is scalar(@{$collection->group(1)}), 1, 'group() returns correct number of solid groups';
}
__END__

View file

@ -16,6 +16,7 @@
%code{% RETVAL = THIS->thickness_layers; %};
double area();
bool is_solid() const;
bool is_external() const;
bool is_bridge() const;
%{

View file

@ -76,12 +76,11 @@ SurfaceCollection::set_surface_type(index, surface_type)
THIS->surfaces[index].surface_type = surface_type;
SV*
SurfaceCollection::group(merge_solid = false)
bool merge_solid
SurfaceCollection::group()
CODE:
// perform grouping
std::vector<SurfacesPtr> groups;
THIS->group(&groups, merge_solid);
THIS->group(&groups);
// build return arrayref
AV* av = newAV();