Ported make_perimeters() to C++
This commit is contained in:
parent
15d2522f3d
commit
6ac79e3ed6
7 changed files with 43 additions and 34 deletions
|
@ -25,36 +25,6 @@ sub print { return $_[0]->layer->print; }
|
||||||
|
|
||||||
sub config { return $_[0]->region->config; }
|
sub config { return $_[0]->region->config; }
|
||||||
|
|
||||||
sub make_perimeters {
|
|
||||||
my ($self, $slices, $fill_surfaces) = @_;
|
|
||||||
|
|
||||||
$self->perimeters->clear;
|
|
||||||
$self->thin_fills->clear;
|
|
||||||
|
|
||||||
my $generator = Slic3r::Layer::PerimeterGenerator->new(
|
|
||||||
# input:
|
|
||||||
$slices,
|
|
||||||
$self->height,
|
|
||||||
$self->flow(FLOW_ROLE_PERIMETER),
|
|
||||||
$self->config,
|
|
||||||
$self->layer->object->config,
|
|
||||||
$self->layer->print->config,
|
|
||||||
|
|
||||||
# output:
|
|
||||||
$self->perimeters,
|
|
||||||
$self->thin_fills,
|
|
||||||
$fill_surfaces,
|
|
||||||
);
|
|
||||||
$generator->set_lower_slices($self->layer->lower_layer->slices)
|
|
||||||
if defined($self->layer->lower_layer);
|
|
||||||
$generator->set_layer_id($self->id);
|
|
||||||
$generator->set_ext_perimeter_flow($self->flow(FLOW_ROLE_EXTERNAL_PERIMETER));
|
|
||||||
$generator->set_overhang_flow($self->region->flow(FLOW_ROLE_PERIMETER, -1, 1, 0, -1, $self->layer->object));
|
|
||||||
$generator->set_solid_infill_flow($self->flow(FLOW_ROLE_SOLID_INFILL));
|
|
||||||
|
|
||||||
$generator->process;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub process_external_surfaces {
|
sub process_external_surfaces {
|
||||||
my ($self, $lower_layer) = @_;
|
my ($self, $lower_layer) = @_;
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,7 @@ use Slic3r::Test;
|
||||||
[ map @$_, (@$covered_by_perimeters, @$covered_by_infill) ],
|
[ map @$_, (@$covered_by_perimeters, @$covered_by_infill) ],
|
||||||
);
|
);
|
||||||
|
|
||||||
if (1) {
|
if (0) {
|
||||||
printf "max non covered = %f\n", List::Util::max(map unscale unscale $_->area, @$non_covered);
|
printf "max non covered = %f\n", List::Util::max(map unscale unscale $_->area, @$non_covered);
|
||||||
require "Slic3r/SVG.pm";
|
require "Slic3r/SVG.pm";
|
||||||
Slic3r::SVG::output(
|
Slic3r::SVG::output(
|
||||||
|
|
|
@ -29,6 +29,9 @@ class ExtrusionEntityCollection : public ExtrusionEntity
|
||||||
bool empty() const {
|
bool empty() const {
|
||||||
return this->entities.empty();
|
return this->entities.empty();
|
||||||
};
|
};
|
||||||
|
void clear() {
|
||||||
|
this->entities.clear();
|
||||||
|
};
|
||||||
void swap (ExtrusionEntityCollection &c);
|
void swap (ExtrusionEntityCollection &c);
|
||||||
void append(const ExtrusionEntity &entity);
|
void append(const ExtrusionEntity &entity);
|
||||||
void append(const ExtrusionEntitiesPtr &entities);
|
void append(const ExtrusionEntitiesPtr &entities);
|
||||||
|
|
|
@ -57,6 +57,7 @@ class LayerRegion
|
||||||
Flow flow(FlowRole role, bool bridge = false, double width = -1) const;
|
Flow flow(FlowRole role, bool bridge = false, double width = -1) const;
|
||||||
void merge_slices();
|
void merge_slices();
|
||||||
void prepare_fill_surfaces();
|
void prepare_fill_surfaces();
|
||||||
|
void make_perimeters(const SurfaceCollection &slices, SurfaceCollection* fill_surfaces);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Layer *_layer;
|
Layer *_layer;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "Layer.hpp"
|
#include "Layer.hpp"
|
||||||
#include "ClipperUtils.hpp"
|
#include "ClipperUtils.hpp"
|
||||||
|
#include "PerimeterGenerator.hpp"
|
||||||
#include "Print.hpp"
|
#include "Print.hpp"
|
||||||
#include "Surface.hpp"
|
#include "Surface.hpp"
|
||||||
|
|
||||||
|
@ -53,6 +54,38 @@ LayerRegion::merge_slices()
|
||||||
this->slices.surfaces.push_back(Surface(stInternal, *expoly));
|
this->slices.surfaces.push_back(Surface(stInternal, *expoly));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LayerRegion::make_perimeters(const SurfaceCollection &slices, SurfaceCollection* fill_surfaces)
|
||||||
|
{
|
||||||
|
this->perimeters.clear();
|
||||||
|
this->thin_fills.clear();
|
||||||
|
|
||||||
|
PerimeterGenerator g(
|
||||||
|
// input:
|
||||||
|
&slices,
|
||||||
|
this->layer()->height,
|
||||||
|
this->flow(frPerimeter),
|
||||||
|
&this->region()->config,
|
||||||
|
&this->layer()->object()->config,
|
||||||
|
&this->layer()->object()->print()->config,
|
||||||
|
|
||||||
|
// output:
|
||||||
|
&this->perimeters,
|
||||||
|
&this->thin_fills,
|
||||||
|
fill_surfaces
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this->layer()->lower_layer != NULL)
|
||||||
|
g.lower_slices = &this->layer()->lower_layer->slices;
|
||||||
|
|
||||||
|
g.layer_id = this->layer()->id();
|
||||||
|
g.ext_perimeter_flow = this->flow(frExternalPerimeter);
|
||||||
|
g.overhang_flow = this->region()->flow(frPerimeter, -1, true, false, -1, *this->layer()->object());
|
||||||
|
g.solid_infill_flow = this->flow(frSolidInfill);
|
||||||
|
|
||||||
|
g.process();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
LayerRegion::prepare_fill_surfaces()
|
LayerRegion::prepare_fill_surfaces()
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,8 +30,8 @@ class PerimeterGeneratorLoop {
|
||||||
|
|
||||||
class PerimeterGenerator {
|
class PerimeterGenerator {
|
||||||
public:
|
public:
|
||||||
SurfaceCollection* slices;
|
const SurfaceCollection* slices;
|
||||||
ExPolygonCollection* lower_slices;
|
const ExPolygonCollection* lower_slices;
|
||||||
double layer_height;
|
double layer_height;
|
||||||
int layer_id;
|
int layer_id;
|
||||||
Flow perimeter_flow;
|
Flow perimeter_flow;
|
||||||
|
@ -45,7 +45,7 @@ class PerimeterGenerator {
|
||||||
ExtrusionEntityCollection* gap_fill;
|
ExtrusionEntityCollection* gap_fill;
|
||||||
SurfaceCollection* fill_surfaces;
|
SurfaceCollection* fill_surfaces;
|
||||||
|
|
||||||
PerimeterGenerator(SurfaceCollection* slices, double layer_height, Flow flow,
|
PerimeterGenerator(const SurfaceCollection* slices, double layer_height, Flow flow,
|
||||||
PrintRegionConfig* config, PrintObjectConfig* object_config,
|
PrintRegionConfig* config, PrintObjectConfig* object_config,
|
||||||
PrintConfig* print_config, ExtrusionEntityCollection* loops,
|
PrintConfig* print_config, ExtrusionEntityCollection* loops,
|
||||||
ExtrusionEntityCollection* gap_fill, SurfaceCollection* fill_surfaces)
|
ExtrusionEntityCollection* gap_fill, SurfaceCollection* fill_surfaces)
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
%code%{ RETVAL = THIS->flow(role, bridge, width); %};
|
%code%{ RETVAL = THIS->flow(role, bridge, width); %};
|
||||||
void merge_slices();
|
void merge_slices();
|
||||||
void prepare_fill_surfaces();
|
void prepare_fill_surfaces();
|
||||||
|
void make_perimeters(SurfaceCollection* slices, SurfaceCollection* fill_surfaces)
|
||||||
|
%code%{ THIS->make_perimeters(*slices, fill_surfaces); %};
|
||||||
};
|
};
|
||||||
|
|
||||||
%name{Slic3r::Layer} class Layer {
|
%name{Slic3r::Layer} class Layer {
|
||||||
|
|
Loading…
Reference in a new issue