Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2016-11-02 12:47:00 +0300
committerbubnikv <bubnikv@gmail.com>2016-11-02 12:47:00 +0300
commit95ede7c4b8cc40fe0fcf1960f25dfa9c66843b29 (patch)
tree609d320018e09d27f4b945915572d0fdf6e8c906 /xs/src/libslic3r/Fill
parent3a31d37d3574093565ed4fc8baa7f90428d9324e (diff)
Rewrote Fill2.pm to C++, deleted Perl infills for good.
Removed dependency on Perl Math::PlanePath module. Fixed compilation with Visual Studio and SLIC3R_DEBUG: Visual Studio older than 2015 does not support the prinf type specifier %zu. Use %Iu instead. C++11 move semantics enabled.
Diffstat (limited to 'xs/src/libslic3r/Fill')
-rw-r--r--xs/src/libslic3r/Fill/Fill.cpp322
-rw-r--r--xs/src/libslic3r/Fill/Fill.hpp5
-rw-r--r--xs/src/libslic3r/Fill/FillBase.cpp18
-rw-r--r--xs/src/libslic3r/Fill/FillHoneycomb.cpp3
-rw-r--r--xs/src/libslic3r/Fill/FillRectilinear.hpp2
-rw-r--r--xs/src/libslic3r/Fill/FillRectilinear2.cpp30
-rw-r--r--xs/src/libslic3r/Fill/FillRectilinear2.hpp11
7 files changed, 190 insertions, 201 deletions
diff --git a/xs/src/libslic3r/Fill/Fill.cpp b/xs/src/libslic3r/Fill/Fill.cpp
index 19ba1c6be..ad6f28e15 100644
--- a/xs/src/libslic3r/Fill/Fill.cpp
+++ b/xs/src/libslic3r/Fill/Fill.cpp
@@ -1,14 +1,17 @@
+#include <assert.h>
#include <stdio.h>
#include "../ClipperUtils.hpp"
-#include "../Surface.hpp"
+#include "../Geometry.hpp"
+#include "../Layer.hpp"
+#include "../Print.hpp"
#include "../PrintConfig.hpp"
+#include "../Surface.hpp"
#include "FillBase.hpp"
namespace Slic3r {
-#if 0
// Generate infills for Slic3r::Layer::Region.
// The Slic3r::Layer::Region at this point of time may contain
// surfaces of various types (internal/bridge/top/bottom/solid).
@@ -31,8 +34,8 @@ void make_fill(LayerRegion &layerm, ExtrusionEntityCollection &out)
// without any angle (shouldn't this logic be moved to process_external_surfaces()?)
{
SurfacesPtr surfaces_with_bridge_angle;
- surfaces_with_bridge_angle.reserve(layerm->fill_surfaces.surfaces.size());
- for (Surfaces::iterator it = layerm->fill_surfaces.surfaces.begin(); it != layerm->fill_surfaces.surfaces.end(); ++ it)
+ surfaces_with_bridge_angle.reserve(layerm.fill_surfaces.surfaces.size());
+ for (Surfaces::iterator it = layerm.fill_surfaces.surfaces.begin(); it != layerm.fill_surfaces.surfaces.end(); ++ it)
if (it->bridge_angle >= 0)
surfaces_with_bridge_angle.push_back(&(*it));
@@ -40,76 +43,61 @@ void make_fill(LayerRegion &layerm, ExtrusionEntityCollection &out)
// group is of type Slic3r::SurfaceCollection
//FIXME: Use some smart heuristics to merge similar surfaces to eliminate tiny regions.
std::vector<SurfacesPtr> groups;
- layerm->fill_surfaces.group(&groups);
+ layerm.fill_surfaces.group(&groups);
// merge compatible groups (we can generate continuous infill for them)
{
// cache flow widths and patterns used for all solid groups
// (we'll use them for comparing compatible groups)
- my @is_solid = my @fw = my @pattern = ();
- for (my $i = 0; $i <= $num_ groups; $i++) {
+ std::vector<char> is_solid(groups.size(), false);
+ std::vector<float> fw(groups.size(), 0.f);
+ std::vector<int> pattern(groups.size(), -1);
+ for (size_t i = 0; i < groups.size(); ++ i) {
// we can only merge solid non-bridge surfaces, so discard
// non-solid surfaces
- if ($groups[$i][0]->is_solid && (!$groups[$i][0]->is_bridge || $layerm->layer->id == 0)) {
- $is_solid[$i] = 1;
- $fw[$i] = ($groups[$i][0]->surface_type == S_TYPE_TOP)
- ? $top_solid_infill_flow->width
- : $solid_infill_flow->width;
- $pattern[$i] = $groups[$i][0]->is_external
- ? $layerm->region->config->external_fill_pattern
- : 'rectilinear';
- } else {
- $is_solid[$i] = 0;
- $fw[$i] = 0;
- $pattern[$i] = 'none';
+ const Surface &surface = *groups[i].front();
+ if (surface.is_solid() && (!surface.is_bridge() || layerm.layer()->id() == 0)) {
+ is_solid[i] = true;
+ fw[i] = (surface.surface_type == stTop) ? top_solid_infill_flow.width : solid_infill_flow.width;
+ pattern[i] = surface.is_external() ? layerm.region()->config.external_fill_pattern.value : ipRectilinear;
}
}
-
// loop through solid groups
- for (my $i = 0; $i <= $num_groups; $i++) {
- next if !$is_solid[$i];
-
- // find compatible groups and append them to this one
- for (my $j = $i+1; $j <= $num_groups; $j++) {
- next if !$is_solid[$j];
-
- if ($fw[$i] == $fw[$j] && $pattern[$i] eq $pattern[$j]) {
- // groups are compatible, merge them
- push @{$groups[$i]}, @{$groups[$j]};
- splice @groups, $j, 1;
- splice @is_solid, $j, 1;
- splice @fw, $j, 1;
- splice @pattern, $j, 1;
+ for (size_t i = 0; i < groups.size(); ++ i) {
+ if (is_solid[i]) {
+ // find compatible groups and append them to this one
+ for (size_t j = i + 1; j < groups.size(); ++ j) {
+ if (is_solid[j] && fw[i] == fw[j] && pattern[i] == pattern[j]) {
+ // groups are compatible, merge them
+ groups[i].insert(groups[i].end(), groups[j].begin(), groups[j].end());
+ groups.erase(groups.begin() + j);
+ is_solid.erase(is_solid.begin() + j);
+ fw.erase(fw.begin() + j);
+ pattern.erase(pattern.begin() + j);
+ }
}
}
}
}
- // give priority to bridges
- @groups = sort { ($a->[0]->bridge_angle >= 0) ? -1 : 0 } @groups;
-
- foreach my $group (@groups) {
- // Make a union of polygons defining the infiill regions of a group, use a safety offset.
- my $union_p = union([ map $_->p, @$group ], 1);
-
- // Subtract surfaces having a defined bridge_angle from any other, use a safety offset.
- if (@surfaces_with_bridge_angle && $group->[0]->bridge_angle < 0) {
- $union_p = diff(
- $union_p,
- [ map $_->p, @surfaces_with_bridge_angle ],
- 1,
- );
+ // Give priority to bridges. Process the bridges in the first round, the rest of the surfaces in the 2nd round.
+ for (size_t round = 0; round < 2; ++ round) {
+ for (std::vector<SurfacesPtr>::iterator it_group = groups.begin(); it_group != groups.end(); ++ it_group) {
+ const SurfacesPtr &group = *it_group;
+ bool is_bridge = group.front()->bridge_angle >= 0;
+ if (is_bridge != (round == 0))
+ continue;
+ // Make a union of polygons defining the infiill regions of a group, use a safety offset.
+ Polygons union_p = union_(to_polygons(*it_group), true);
+ // Subtract surfaces having a defined bridge_angle from any other, use a safety offset.
+ if (! surfaces_with_bridge_angle.empty() && it_group->front()->bridge_angle < 0)
+ union_p = diff(union_p, to_polygons(surfaces_with_bridge_angle), true);
+ // subtract any other surface already processed
+ //FIXME Vojtech: Because the bridge surfaces came first, they are subtracted twice!
+ ExPolygons union_expolys = diff_ex(union_p, to_polygons(surfaces), true);
+ for (ExPolygons::const_iterator it_expoly = union_expolys.begin(); it_expoly != union_expolys.end(); ++ it_expoly)
+ surfaces.push_back(Surface(*it_group->front(), *it_expoly));
}
-
- // subtract any other surface already processed
- //FIXME Vojtech: Because the bridge surfaces came first, they are subtracted twice!
- my $union = diff_ex(
- $union_p,
- [ map $_->p, @surfaces ],
- 1,
- );
-
- push @surfaces, map $group->[0]->clone(expolygon => $_), @$union;
}
}
@@ -123,149 +111,140 @@ void make_fill(LayerRegion &layerm, ExtrusionEntityCollection &out)
// TODO: detect and investigate whether there could be narrow regions without
// any void neighbors
{
- my $distance_between_surfaces = max(
- $infill_flow->scaled_spacing,
- $solid_infill_flow->scaled_spacing,
- $top_solid_infill_flow->scaled_spacing,
- );
- my $collapsed = diff(
- [ map @{$_->expolygon}, @surfaces ],
- offset2([ map @{$_->expolygon}, @surfaces ], -$distance_between_surfaces/2, +$distance_between_surfaces/2),
- 1,
- );
- push @surfaces, map Slic3r::Surface->new(
- expolygon => $_,
- surface_type => S_TYPE_INTERNALSOLID,
- ), @{intersection_ex(
- offset($collapsed, $distance_between_surfaces),
- [
- (map @{$_->expolygon}, grep $_->surface_type == S_TYPE_INTERNALVOID, @surfaces),
- (@$collapsed),
- ],
- 1,
- )};
+ coord_t distance_between_surfaces = std::max(
+ std::max(infill_flow.scaled_spacing(), solid_infill_flow.scaled_spacing()),
+ top_solid_infill_flow.scaled_spacing());
+ Polygons surfaces_polygons = to_polygons(surfaces);
+ Polygons collapsed = diff(
+ surfaces_polygons,
+ offset2(surfaces_polygons, -distance_between_surfaces/2, +distance_between_surfaces/2),
+ true);
+ Polygons to_subtract;
+ to_subtract.reserve(collapsed.size() + number_polygons(surfaces));
+ for (Surfaces::const_iterator it_surface = surfaces.begin(); it_surface != surfaces.end(); ++ it_surface)
+ if (it_surface->surface_type == stInternalVoid)
+ polygons_append(to_subtract, *it_surface);
+ polygons_append(to_subtract, collapsed);
+ surfaces_append(
+ surfaces,
+ intersection_ex(
+ offset(collapsed, distance_between_surfaces),
+ to_subtract,
+ true),
+ stInternalSolid);
}
-
+
if (0) {
- require "Slic3r/SVG.pm";
- Slic3r::SVG::output("fill_" . $layerm->print_z . ".svg",
- expolygons => [ map $_->expolygon, grep !$_->is_solid, @surfaces ],
- red_expolygons => [ map $_->expolygon, grep $_->is_solid, @surfaces ],
- );
+// require "Slic3r/SVG.pm";
+// Slic3r::SVG::output("fill_" . $layerm->print_z . ".svg",
+// expolygons => [ map $_->expolygon, grep !$_->is_solid, @surfaces ],
+// red_expolygons => [ map $_->expolygon, grep $_->is_solid, @surfaces ],
+// );
}
-
- SURFACE: foreach my $surface (@surfaces) {
- next if $surface->surface_type == S_TYPE_INTERNALVOID;
- my $filler = $layerm->region->config->fill_pattern;
- my $density = $fill_density;
- my $role = ($surface->surface_type == S_TYPE_TOP) ? FLOW_ROLE_TOP_SOLID_INFILL
- : $surface->is_solid ? FLOW_ROLE_SOLID_INFILL
- : FLOW_ROLE_INFILL;
- my $is_bridge = $layerm->layer->id > 0 && $surface->is_bridge;
- my $is_solid = $surface->is_solid;
+
+ for (Surfaces::const_iterator surface_it = surfaces.begin(); surface_it != surfaces.end(); ++ surface_it) {
+ const Surface &surface = *surface_it;
+ if (surface.surface_type == stInternalVoid)
+ continue;
+ InfillPattern fill_pattern = layerm.region()->config.fill_pattern.value;
+ double density = fill_density;
+ FlowRole role = (surface.surface_type == stTop) ? frTopSolidInfill :
+ (surface.is_solid() ? frSolidInfill : frInfill);
+ bool is_bridge = layerm.layer()->id() > 0 && surface.is_bridge();
- if ($surface->is_solid) {
- $density = 100;
- $filler = 'rectilinear';
- if ($surface->is_external && !$is_bridge) {
- $filler = $layerm->region->config->external_fill_pattern;
- }
- } else {
- next SURFACE unless $density > 0;
- }
+ if (surface.is_solid()) {
+ density = 100;
+ fill_pattern = (surface.is_external() && ! is_bridge) ?
+ layerm.region()->config.external_fill_pattern.value :
+ ipRectilinear;
+ } else if (density <= 0)
+ continue;
// get filler object
- my $f = $self->filler($filler);
+ std::auto_ptr<Fill> f = std::auto_ptr<Fill>(Fill::new_from_type(fill_pattern));
+ f->set_bounding_box(layerm.layer()->object()->bounding_box());
// calculate the actual flow we'll be using for this infill
- my $h = $surface->thickness == -1 ? $layerm->layer->height : $surface->thickness;
- my $flow = $layerm->region->flow(
- $role,
- $h,
- $is_bridge || $f->use_bridge_flow,
- $layerm->layer->id == 0,
- -1,
- $layerm->layer->object,
+ coordf_t h = (surface.thickness == -1) ? layerm.layer()->height : surface.thickness;
+ Flow flow = layerm.region()->flow(
+ role,
+ h,
+ is_bridge || f->use_bridge_flow(), // bridge flow?
+ layerm.layer()->id() == 0, // first layer?
+ -1, // auto width
+ *layerm.layer()->object()
);
// calculate flow spacing for infill pattern generation
- my $using_internal_flow = 0;
- if (!$is_solid && !$is_bridge) {
+ bool using_internal_flow = false;
+ if (! surface.is_solid() && ! is_bridge) {
// it's internal infill, so we can calculate a generic flow spacing
// for all layers, for avoiding the ugly effect of
// misaligned infill on first layer because of different extrusion width and
// layer height
- my $internal_flow = $layerm->region->flow(
- FLOW_ROLE_INFILL,
- $layerm->layer->object->config->layer_height, // TODO: handle infill_every_layers?
- 0, // no bridge
- 0, // no first layer
- -1, // auto width
- $layerm->layer->object,
+ Flow internal_flow = layerm.region()->flow(
+ frInfill,
+ layerm.layer()->object()->config.layer_height.value, // TODO: handle infill_every_layers?
+ false, // no bridge
+ false, // no first layer
+ -1, // auto width
+ *layerm.layer()->object()
);
- $f->set_spacing($internal_flow->spacing);
- $using_internal_flow = 1;
+ f->spacing = internal_flow.spacing();
+ using_internal_flow = 1;
} else {
- $f->set_spacing($flow->spacing);
+ f->spacing = flow.spacing();
}
- my $link_max_length = 0;
- if (! $is_bridge) {
- $link_max_length = $layerm->region->config->get_abs_value_over($surface->is_external ? 'external_fill_link_max_length' : 'fill_link_max_length', $flow->spacing);
- print "flow spacing: ", $flow->spacing, " is_external: ", $surface->is_external, ", link_max_length: $link_max_length\n";
+ double link_max_length = 0.;
+ if (! is_bridge) {
+ link_max_length = layerm.region()->config.get_abs_value(surface.is_external() ? "external_fill_link_max_length" : "fill_link_max_length", flow.spacing());
+// printf("flow spacing: %f, is_external: %d, link_max_length: %lf\n", flow.spacing(), int(surface.is_external()), link_max_length);
}
- $f->set_layer_id($layerm->layer->id);
- $f->set_z($layerm->layer->print_z);
- $f->set_angle(deg2rad($layerm->region->config->fill_angle));
+ f->layer_id = layerm.layer()->id();
+ f->z = layerm.layer()->print_z;
+ f->angle = Geometry::deg2rad(layerm.region()->config.fill_angle.value);
// Maximum length of the perimeter segment linking two infill lines.
- $f->set_link_max_length(scale($link_max_length));
+ f->link_max_length = scale_(link_max_length);
// Used by the concentric infill pattern to clip the loops to create extrusion paths.
- $f->set_loop_clipping(scale($flow->nozzle_diameter) * &Slic3r::LOOP_CLIPPING_LENGTH_OVER_NOZZLE_DIAMETER);
-
+ f->loop_clipping = scale_(flow.nozzle_diameter) * LOOP_CLIPPING_LENGTH_OVER_NOZZLE_DIAMETER;
+// f->layer_height = h;
+
// apply half spacing using this flow's own spacing and generate infill
- my @polylines = $f->fill_surface(
- $surface,
- density => $density/100,
- layer_height => $h,
- );
- next unless @polylines;
+ FillParams params;
+ params.density = 0.01 * density;
+ params.dont_adjust = true;
+ Polylines polylines = f->fill_surface(&surface, params);
+ if (polylines.empty())
+ continue;
-
// calculate actual flow from spacing (which might have been adjusted by the infill
// pattern generator)
- if ($using_internal_flow) {
+ if (using_internal_flow) {
// if we used the internal flow we're not doing a solid infill
// so we can safely ignore the slight variation that might have
// been applied to $f->flow_spacing
} else {
- $flow = Slic3r::Flow->new_from_spacing(
- spacing => $f->spacing,
- nozzle_diameter => $flow->nozzle_diameter,
- layer_height => $h,
- bridge => $is_bridge || $f->use_bridge_flow,
- );
+ flow = Flow::new_from_spacing(f->spacing, flow.nozzle_diameter, h, is_bridge || f->use_bridge_flow());
}
// save into layer
{
- my $role = $is_bridge ? EXTR_ROLE_BRIDGE
- : $is_solid ? (($surface->surface_type == S_TYPE_TOP) ? EXTR_ROLE_TOPSOLIDFILL : EXTR_ROLE_SOLIDFILL)
- : EXTR_ROLE_FILL;
-
- out.
- push @fills, my $collection = Slic3r::ExtrusionPath::Collection->new;
+ ExtrusionRole role = is_bridge ? erBridgeInfill :
+ (surface.is_solid() ? ((surface.surface_type == stTop) ? erTopSolidInfill : erSolidInfill) : erInternalInfill);
+ ExtrusionEntityCollection &collection = *(new ExtrusionEntityCollection());
+ out.entities.push_back(&collection);
// Only concentric fills are not sorted.
- $collection->no_sort($f->no_sort);
- $collection->append(
- map Slic3r::ExtrusionPath->new(
- polyline => $_,
- role => $role,
- mm3_per_mm => $flow->mm3_per_mm,
- width => $flow->width,
- height => $flow->height,
- ), map @$_, @polylines,
- );
+ collection.no_sort = f->no_sort();
+ for (Polylines::iterator it = polylines.begin(); it != polylines.end(); ++ it) {
+ ExtrusionPath *path = new ExtrusionPath(role);
+ collection.entities.push_back(path);
+ path->polyline.points.swap(it->points);
+ path->mm3_per_mm = flow.mm3_per_mm();
+ path->width = flow.width,
+ path->height = flow.height;
+ }
}
}
@@ -275,12 +254,15 @@ void make_fill(LayerRegion &layerm, ExtrusionEntityCollection &out)
// The path type could be ExtrusionPath, ExtrusionLoop or ExtrusionEntityCollection.
// Why the paths are unpacked?
for (ExtrusionEntitiesPtr::iterator thin_fill = layerm.thin_fills.entities.begin(); thin_fill != layerm.thin_fills.entities.end(); ++ thin_fill) {
- // ExtrusionEntityCollection
- out.append(new ExtrusionEntityCollection->new($thin_fill);
+ #if 0
+ out.entities.push_back((*thin_fill)->clone());
+ assert(dynamic_cast<ExtrusionEntityCollection*>(out.entities.back()) != NULL);
+ #else
+ ExtrusionEntityCollection &collection = *(new ExtrusionEntityCollection());
+ out.entities.push_back(&collection);
+ collection.entities.push_back((*thin_fill)->clone());
+ #endif
}
-
- return @fills;
}
-#endif
} // namespace Slic3r
diff --git a/xs/src/libslic3r/Fill/Fill.hpp b/xs/src/libslic3r/Fill/Fill.hpp
index d3a436719..c04305c04 100644
--- a/xs/src/libslic3r/Fill/Fill.hpp
+++ b/xs/src/libslic3r/Fill/Fill.hpp
@@ -13,7 +13,8 @@
namespace Slic3r {
-class Surface;
+class ExtrusionEntityCollection;
+class LayerRegion;
// An interface class to Perl, aggregating an instance of a Fill and a FillData.
class Filler
@@ -28,6 +29,8 @@ public:
FillParams params;
};
+void make_fill(LayerRegion &layerm, ExtrusionEntityCollection &out);
+
} // namespace Slic3r
#endif // slic3r_Fill_hpp_
diff --git a/xs/src/libslic3r/Fill/FillBase.cpp b/xs/src/libslic3r/Fill/FillBase.cpp
index 9043bcd83..f471d539c 100644
--- a/xs/src/libslic3r/Fill/FillBase.cpp
+++ b/xs/src/libslic3r/Fill/FillBase.cpp
@@ -60,15 +60,25 @@ Polylines Fill::fill_surface(const Surface *surface, const FillParams &params)
// Calculate a new spacing to fill width with possibly integer number of lines,
// the first and last line being centered at the interval ends.
-//FIXME Vojtech: This
// This function possibly increases the spacing, never decreases,
-// and for a narrow width the increase in spacing may become severe!
+// and for a narrow width the increase in spacing may become severe,
+// therefore the adjustment is limited to 20% increase.
coord_t Fill::_adjust_solid_spacing(const coord_t width, const coord_t distance)
{
- coord_t number_of_intervals = coord_t(coordf_t(width) / coordf_t(distance));
- return (number_of_intervals == 0) ?
+ assert(width >= 0);
+ assert(distance > 0);
+ // floor(width / distance)
+ coord_t number_of_intervals = width / distance;
+ coord_t distance_new = (number_of_intervals == 0) ?
distance :
(width / number_of_intervals);
+ const coordf_t factor = coordf_t(distance_new) / coordf_t(distance);
+ assert(factor > 1. - 1e-5);
+ // How much could the extrusion width be increased? By 20%.
+ const coordf_t factor_max = 1.2;
+ if (factor > factor_max)
+ distance_new = coord_t(floor((coordf_t(distance) * factor_max + 0.5)));
+ return distance_new;
}
// Returns orientation of the infill and the reference point of the infill pattern.
diff --git a/xs/src/libslic3r/Fill/FillHoneycomb.cpp b/xs/src/libslic3r/Fill/FillHoneycomb.cpp
index a8e38806c..b264d80cc 100644
--- a/xs/src/libslic3r/Fill/FillHoneycomb.cpp
+++ b/xs/src/libslic3r/Fill/FillHoneycomb.cpp
@@ -17,7 +17,8 @@ void FillHoneycomb::_fill_surface_single(
CacheID cache_id(params.density, this->spacing);
Cache::iterator it_m = this->cache.find(cache_id);
if (it_m == this->cache.end()) {
-#if SLIC3R_CPPVER > 11
+#if 0
+// #if SLIC3R_CPPVER > 11
it_m = this->cache.emplace_hint(it_m);
#else
it_m = this->cache.insert(it_m, std::pair<CacheID, CacheData>(cache_id, CacheData()));
diff --git a/xs/src/libslic3r/Fill/FillRectilinear.hpp b/xs/src/libslic3r/Fill/FillRectilinear.hpp
index 8c13b8bc1..2971a90a3 100644
--- a/xs/src/libslic3r/Fill/FillRectilinear.hpp
+++ b/xs/src/libslic3r/Fill/FillRectilinear.hpp
@@ -67,7 +67,7 @@ public:
virtual ~FillGrid() {}
protected:
- // The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill::Base.
+ // The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill.
virtual float _layer_angle(size_t idx) const { return 0.f; }
// Flag for Slic3r::Fill::Rectilinear to fill both directions.
virtual bool _horizontal_lines() const { return true; }
diff --git a/xs/src/libslic3r/Fill/FillRectilinear2.cpp b/xs/src/libslic3r/Fill/FillRectilinear2.cpp
index 4fc4a9b46..17952606b 100644
--- a/xs/src/libslic3r/Fill/FillRectilinear2.cpp
+++ b/xs/src/libslic3r/Fill/FillRectilinear2.cpp
@@ -790,10 +790,8 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillP
std::pair<float, Point> rotate_vector = this->_infill_direction(surface);
rotate_vector.first += angleBase;
- this->_min_spacing = scale_(this->spacing);
myassert(params.density > 0.0001f && params.density <= 1.f);
- this->_line_spacing = coord_t(coordf_t(this->_min_spacing) / params.density);
- this->_diagonal_distance = this->_line_spacing * 2;
+ coord_t line_spacing = coord_t(scale_(this->spacing) / params.density);
// On the polygons of poly_with_offset, the infill lines will be connected.
ExPolygonWithOffset poly_with_offset(
@@ -811,24 +809,24 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillP
// define flow spacing according to requested density
bool full_infill = params.density > 0.9999f;
if (full_infill && !params.dont_adjust) {
-// this->_min_spacing = this->_line_spacing = this->_adjust_solid_spacing(bounding_box.size().x, this->_line_spacing);
-// this->spacing = unscale(this->_line_spacing);
+ line_spacing = this->_adjust_solid_spacing(bounding_box.size().x, line_spacing);
+ this->spacing = unscale(line_spacing);
} else {
// extend bounding box so that our pattern will be aligned with other layers
// Transform the reference point to the rotated coordinate system.
Point refpt = rotate_vector.second.rotated(- rotate_vector.first);
// _align_to_grid will not work correctly with positive pattern_shift.
- coord_t pattern_shift_scaled = coord_t(scale_(pattern_shift)) % this->_line_spacing;
- refpt.x -= (pattern_shift_scaled > 0) ? pattern_shift_scaled : (this->_line_spacing + pattern_shift_scaled);
+ coord_t pattern_shift_scaled = coord_t(scale_(pattern_shift)) % line_spacing;
+ refpt.x -= (pattern_shift_scaled > 0) ? pattern_shift_scaled : (line_spacing + pattern_shift_scaled);
bounding_box.merge(_align_to_grid(
bounding_box.min,
- Point(this->_line_spacing, this->_line_spacing),
+ Point(line_spacing, line_spacing),
refpt));
}
// Intersect a set of euqally spaced vertical lines wiht expolygon.
- size_t n_vlines = (bounding_box.max.x - bounding_box.min.x + SCALED_EPSILON) / this->_line_spacing;
- coord_t x0 = bounding_box.min.x + this->_line_spacing;
+ size_t n_vlines = (bounding_box.max.x - bounding_box.min.x + SCALED_EPSILON) / line_spacing;
+ coord_t x0 = bounding_box.min.x + line_spacing / 2;
#ifdef SLIC3R_DEBUG
static int iRun = 0;
@@ -847,7 +845,7 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillP
std::vector<SegmentedIntersectionLine> segs(n_vlines, SegmentedIntersectionLine());
for (size_t i = 0; i < n_vlines; ++ i) {
segs[i].idx = i;
- segs[i].pos = x0 + i * this->_line_spacing;
+ segs[i].pos = x0 + i * line_spacing;
}
for (size_t iContour = 0; iContour < poly_with_offset.n_contours; ++ iContour) {
const Points &contour = poly_with_offset.contour(iContour).points;
@@ -864,12 +862,12 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillP
if (l > r)
std::swap(l, r);
// il, ir are the left / right indices of vertical lines intersecting a segment
- int il = (l - x0) / this->_line_spacing;
- while (il * this->_line_spacing + x0 < l)
+ int il = (l - x0) / line_spacing;
+ while (il * line_spacing + x0 < l)
++ il;
il = std::max(int(0), il);
- int ir = (r - x0 + this->_line_spacing) / this->_line_spacing;
- while (ir * this->_line_spacing + x0 > r)
+ int ir = (r - x0 + line_spacing) / line_spacing;
+ while (ir * line_spacing + x0 > r)
-- ir;
ir = std::min(int(segs.size()) - 1, ir);
if (il > ir)
@@ -879,7 +877,7 @@ bool FillRectilinear2::fill_surface_by_lines(const Surface *surface, const FillP
myassert(ir >= 0 && ir < segs.size());
for (int i = il; i <= ir; ++ i) {
coord_t this_x = segs[i].pos;
- assert(this_x == i * this->_line_spacing + x0);
+ assert(this_x == i * line_spacing + x0);
SegmentIntersection is;
is.iContour = iContour;
is.iSegment = iSegment;
diff --git a/xs/src/libslic3r/Fill/FillRectilinear2.hpp b/xs/src/libslic3r/Fill/FillRectilinear2.hpp
index a82717bbe..d8afc76ad 100644
--- a/xs/src/libslic3r/Fill/FillRectilinear2.hpp
+++ b/xs/src/libslic3r/Fill/FillRectilinear2.hpp
@@ -17,11 +17,6 @@ public:
protected:
bool fill_surface_by_lines(const Surface *surface, const FillParams &params, float angleBase, float pattern_shift, Polylines &polylines_out);
-
- coord_t _min_spacing;
- coord_t _line_spacing;
- // distance threshold for allowing the horizontal infill lines to be connected into a continuous path
- coord_t _diagonal_distance;
};
class FillGrid2 : public FillRectilinear2
@@ -31,7 +26,7 @@ public:
virtual Polylines fill_surface(const Surface *surface, const FillParams &params);
protected:
- // The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill::Base.
+ // The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill.
virtual float _layer_angle(size_t idx) const { return 0.f; }
};
@@ -42,7 +37,7 @@ public:
virtual Polylines fill_surface(const Surface *surface, const FillParams &params);
protected:
- // The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill::Base.
+ // The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill.
virtual float _layer_angle(size_t idx) const { return 0.f; }
};
@@ -53,7 +48,7 @@ public:
virtual Polylines fill_surface(const Surface *surface, const FillParams &params);
protected:
- // The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill::Base.
+ // The grid fill will keep the angle constant between the layers, see the implementation of Slic3r::Fill.
virtual float _layer_angle(size_t idx) const { return 0.f; }
};