Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Nov 18, 2021
2 parents a9a7f1b + 0d25f9b commit 8e14a10
Show file tree
Hide file tree
Showing 29 changed files with 344 additions and 208 deletions.
4 changes: 2 additions & 2 deletions doc/How to build - Windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ cmake .. -G "Visual Studio 16 2019" -A x64
msbuild /m ALL_BUILD.vcxproj
```

and then build Slic3r (in ./build):
and then build and install Slic3r (in ./build as an elevated Command Prompt - 'Run As Administrator'):
```
cmake .. -G "Visual Studio 16 2019" -A x64 -DCMAKE_PREFIX_PATH="PATH_TO_Slic3r\deps\build\destdir\usr\local"
msbuild /m /P:Configuration=Release INSTALL.vcxproj
```
You can also build it in visual studio, for that open the .sln.
Note that you need to have `libgmp-10.dll` and `libmpfr-4.dll` next to your built Slic3r. You can get them from any Slic3r release.
Note that you need to have `libgmp-10.dll` and `libmpfr-4.dll` next to your built Slic3r. You can get them from any Slic3r release: So copy these two dlls from your deps-build dir (default: "\deps\build\destdir\usr\local\bin") into the target installation dir of Slic3r (default: "C:\Program Files (x86)\Slic3r")

If you want to create the zipped release, you can follow this [script](https://github.com/supermerill/Slic3r/blob/master/.github/workflows/ccpp_win.yml).

Expand Down
28 changes: 14 additions & 14 deletions resources/localization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ If you found an odd translation and want to change it, go to section B)
Useful tools:

* windows:
* [python](https://www.python.org/)
* [gettext](http://gnuwin32.sourceforge.net/downlinks/gettext.php)
* [python](https://www.python.org/)
* [gettext](http://gnuwin32.sourceforge.net/downlinks/gettext.php)
* linux:
* python: make sure you can execute python3, install it if it isn't here.
* gettext: if you can't execute msgfmt, install the package 'gettext'
* macos: maybe like linux?

### 1) initialisation
open the settings.ini
for each file that can contain useful translation, create/edit a "data" line to point to the said file.
The 'input' property must be the Slic3r.pot path
The 'output' must be the Slic3r.po
The 'todo' contains the path of the po file to complete.
Open the settings.ini
* For each file that can contain useful translation, create/edit a "data" line to point to the said file.
* The 'input' property must be the Slic3r.pot path
* The 'output' must be the Slic3r.po
* The 'todo' contains the path of the po file to complete.

note that the first data line has the priority over the other ones (the first translation encountered is the one used)

In this example, we are going to update the Spanish translation.
We are going to use your old translation file and the current PrusaSlicer one.
To decompile the .mo of Prusaslicer, use the command `msgunfmt PrusaSlicer.mo -o PrusaSlicer.po`.
In this example, we are going to update the Spanish translation.
We are going to use your old translation file and the current PrusaSlicer one.
To decompile the .mo of Prusaslicer, use the command `msgunfmt PrusaSlicer.mo -o PrusaSlicer.po`.
So the settings.ini contains these lines :

```
Expand All @@ -59,13 +59,13 @@ output = es/Slic3r.po
```

Notes:
* thee 'todo' and 'output' files will be erased, so be sure nothing important has this name (or write another name)
* the file at 'database_out' will receive all the database created from the data files. That way, it will keep your new & old unused translations just in case the wording revert back to it, or to be used as reference for the helper.
* the 'todo' and 'output' files will be erased, so be sure you didn't use this file name (or copy it elsewhere). Note that often, Slic3r.po is used as input & output, as it's the "updated" file.
* the file at 'database_out' will receive all the translations created from the data files. That way, it will keep your new & old unused translations just in case the wording revert back to it, or to be used as reference for the helper.
* ui_dir should be the path to the slic3r/resources/ui_layout directory. If you're in slic3r/resources/localization, this value is good.
* allow_msgctxt is a bool to allow to keep the msgctxt tags. You need a recent version of gettext to use that.
* ignore_case is a bool that will let the tool to ignore the case when comparing msgid if no translation is found.
* remove_comment is a bool taht will remove all comment in the output file. It's to avoid unecessary changes in the git commit.
* percent_error_similar is a number between 0 and 1. This will activate the helper that will write help comment in the TODO file. These will present similar string that are already translated, to let you pick chunk that are already translated to avoid redoing all the work. It's the percentage of difference allowed (0 = identical, 1 = everything, 0.5 = not more than half of the string is different), using (levenshtein distance / msgid length).
* remove_comment is a bool that will remove all comments in the output file. It's to avoid unecessary changes in the git commit. Don't submit pull request for '.po' file with comments. (Note that the translations are ordered by alphabetic order)
* percent_error_similar is a number between 0 and 1. This will activate the helper that will write help comment in the TODO file. These will present similar string that are already translated, to let you pick chunk that are already translated to avoid redoing all the work. It's the percentage of difference allowed (0 = identical, 1 = everything, 0.5 = not more than half of the string is different), using (levenshtein distance / msgid length). You have to install the levenshtein lib in python to use it.
* max_similar: max number of help translation per item
* language and language_code: text to include in the header.

Expand Down
5 changes: 4 additions & 1 deletion resources/ui_layout/print.ui
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,11 @@ group:Overlap
setting:label$External:external_perimeter_overlap
setting:label$Gap Fill:gap_fill_overlap
end_line
line:Bridge lines density
setting:bridge_overlap_min
setting:bridge_overlap
end_line
setting:sidetext_width$7:infill_overlap
setting:bridge_overlap
group:Flow
line:Flow ratio
setting:bridge_flow_ratio
Expand Down
7 changes: 4 additions & 3 deletions src/libslic3r/ClipperUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,10 @@ ClipperLib::PolyTree _clipper_do_pl(const ClipperLib::ClipType clipType, const P
// read input
ClipperLib::Paths input_subject = Slic3rMultiPoints_to_ClipperPaths(subject);
ClipperLib::Paths input_clip = Slic3rMultiPoints_to_ClipperPaths(clip);

// perform safety offset (before scaling because it scale & unscale)
if (safety_offset_) safety_offset(&input_clip);

//scale to have some more precision to do some Y-bugfix
scaleClipperPolygons(input_subject);
scaleClipperPolygons(input_clip);
Expand All @@ -614,9 +618,6 @@ ClipperLib::PolyTree _clipper_do_pl(const ClipperLib::ClipType clipType, const P
lasty = pt.Y;
}
}

// perform safety offset
if (safety_offset_) safety_offset(&input_clip);

// init Clipper
ClipperLib::Clipper clipper;
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ double ConfigBase::get_computed_value(const t_config_option_key &opt_key, int ex
//FIXME there are some ratio_over chains, which end with empty ratio_with.
// For example, XXX_extrusion_width parameters are not handled by get_abs_value correctly.
if (!opt_def->ratio_over.empty() && opt_def->ratio_over != "depends")
return cast_opt->get_abs_value(this->get_computed_value(opt_def->ratio_over));
return cast_opt->get_abs_value(this->get_computed_value(opt_def->ratio_over, extruder_id));

std::stringstream ss; ss << "ConfigBase::get_abs_value(): " << opt_key << " has no valid ratio_over to compute of";
throw ConfigurationError(ss.str());
Expand Down
69 changes: 62 additions & 7 deletions src/libslic3r/Fill/Fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ struct SurfaceFillParams : FillParams

// FillBase
// in unscaled coordinates
coordf_t spacing = 0.;
double spacing = 0.;
// infill / perimeter overlap, in unscaled coordinates
coordf_t overlap = 0.;
double overlap = 0.;
// Angle as provided by the region config, in radians.
float angle = 0.f;
// Non-negative for a bridge.
Expand Down Expand Up @@ -435,6 +435,7 @@ void Layer::make_fills(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive:
store_fill(current_region_id);
}
current_region_id = surface_fill.region_id;
const LayerRegion* layerm = this->m_regions[surface_fill.region_id];

// Create the filler object.
std::unique_ptr<Fill> f = std::unique_ptr<Fill>(Fill::new_from_type(surface_fill.params.pattern));
Expand All @@ -446,6 +447,8 @@ void Layer::make_fills(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive:

// calculate flow spacing for infill pattern generation
bool using_internal_flow = ! surface_fill.surface.has_fill_solid() && ! surface_fill.params.flow.bridge;
//init spacing, it may also use & modify a bit the surface_fill.params, so most of these should be set before.
// note that the bridge overlap is applied here via the rectilinear init_spacing.
f->init_spacing(surface_fill.params.spacing, surface_fill.params);
double link_max_length = 0.;
if (! surface_fill.params.flow.bridge) {
Expand All @@ -463,7 +466,6 @@ void Layer::make_fills(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive:

//give the overlap size to let the infill do his overlap
//add overlap if at least one perimeter
const LayerRegion* layerm = this->m_regions[surface_fill.region_id];
const float perimeter_spacing = layerm->flow(frPerimeter).spacing();

// Used by the concentric infill pattern to clip the loops to create extrusion paths.
Expand All @@ -485,10 +487,6 @@ void Layer::make_fills(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive:
surface_fill.params.flow = Flow::new_from_spacing((float)f->get_spacing(), surface_fill.params.flow.nozzle_diameter, (float)surface_fill.params.flow.height, overlap, surface_fill.params.flow.bridge);
}

//apply bridge_overlap if needed
if (surface_fill.params.flow.bridge && surface_fill.params.density > 0.99 && layerm->region()->config().bridge_overlap.get_abs_value(1) != 1) {
surface_fill.params.density *= float(layerm->region()->config().bridge_overlap.get_abs_value(1));
}

for (ExPolygon &expoly : surface_fill.expolygons) {
//set overlap polygons
Expand All @@ -509,6 +507,63 @@ void Layer::make_fills(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive:
if (!expoly.contour.empty()) {
surface_fill.surface.expolygon = std::move(expoly);

//adjust the bridge density
if (surface_fill.params.flow.bridge && surface_fill.params.density > 0.99 /*&& layerm->region()->config().bridge_overlap.get_abs_value(1) != 1*/) {
////varies the overlap to have teh best coverage for the bridge
//surface_fill.params.density *= float(layerm->region()->config().bridge_overlap.get_abs_value(1));
double min_spacing = 0.999 * surface_fill.params.spacing / surface_fill.params.config->bridge_overlap.get_abs_value(surface_fill.params.density);
double max_spacing = 1.001 * surface_fill.params.spacing / surface_fill.params.config->bridge_overlap_min.get_abs_value(surface_fill.params.density);
double factor = 1.00001;
if (min_spacing < max_spacing * 1.01) {
// create a bouding box of the rotated surface
coord_t bounding_box_size_x = 0;
Polygon poly = surface_fill.surface.expolygon.contour;
coord_t bounding_box_min_x = 0;
poly.rotate(PI / 2 - (surface_fill.params.bridge_angle < 0 ? surface_fill.params.angle : surface_fill.params.bridge_angle));
ExPolygons expolys;
if (surface_fill.params.bridge_angle > 0 && !f->no_overlap_expolygons.empty()) {
//take only the no-overlap area
expolys = offset_ex(intersection_ex(ExPolygons{ ExPolygon{surface_fill.surface.expolygon.contour} }, f->no_overlap_expolygons), -scale_t(surface_fill.params.spacing) / 2 - 10);
} else {
expolys = offset_ex(ExPolygon{surface_fill.surface.expolygon.contour}, -scale_t(surface_fill.params.spacing) / 2 - 10);
}
BoundingBox bb;
bool first = true;
for (ExPolygon& expoly : expolys) {
expoly.holes.clear();
expoly.rotate(PI / 2 - (surface_fill.params.bridge_angle < 0 ? surface_fill.params.angle : surface_fill.params.bridge_angle));
if (first) {
bb = expoly.contour.bounding_box();
first = false;
} else {
bb.merge(expoly.contour.points);
}
}
bounding_box_size_x = bb.size().x();
bounding_box_min_x = bb.min.x();

//compute the dist
double new_spacing = unscaled(f->_adjust_solid_spacing(bounding_box_size_x, scale_t(min_spacing), 2));
if (new_spacing <= max_spacing) {
surface_fill.params.density = factor * surface_fill.params.spacing / new_spacing;
} else {
double new_spacing2 = unscaled(f->_adjust_solid_spacing(bounding_box_size_x, scale_t(min_spacing * 1.999 - new_spacing), 2));
if (new_spacing2 < min_spacing) {
if (min_spacing - new_spacing2 < new_spacing - max_spacing) {
surface_fill.params.density = surface_fill.params.config->bridge_overlap.get_abs_value(surface_fill.params.density);
} else {
surface_fill.params.density = surface_fill.params.config->bridge_overlap_min.get_abs_value(surface_fill.params.density);
}
} else {
//use the highest density
surface_fill.params.density = surface_fill.params.config->bridge_overlap.get_abs_value(surface_fill.params.density);
}
}
surface_fill.params.dont_adjust = true;
surface_fill.params.bridge_offset = std::abs(poly.bounding_box().min.x() - bounding_box_min_x);
}
}

//make fill
while ((size_t)surface_fill.params.priority >= fills_by_priority.size())
fills_by_priority.push_back(new ExtrusionEntityCollection());
Expand Down
7 changes: 3 additions & 4 deletions src/libslic3r/Fill/FillBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Polylines Fill::fill_surface(const Surface *surface, const FillParams &params) c
// This function possibly increases the spacing, never decreases,
// 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 Fill::_adjust_solid_spacing(const coord_t width, const coord_t distance, const double factor_max)
{
assert(width >= 0);
assert(distance > 0);
Expand All @@ -93,10 +93,9 @@ coord_t Fill::_adjust_solid_spacing(const coord_t width, const coord_t distance)
coord_t distance_new = (number_of_intervals == 0) ?
distance :
(coord_t)(((width - EPSILON) / number_of_intervals));
const coordf_t factor = coordf_t(distance_new) / coordf_t(distance);
const double 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;
Expand Down Expand Up @@ -228,7 +227,7 @@ void Fill::fill_surface_extrusion(const Surface *surface, const FillParams &para

coord_t Fill::_line_spacing_for_density(float density) const
{
return scale_(this->get_spacing() / density);
return scale_t(this->get_spacing() / density);
}

//FIXME: add recent improvmeent from perimetergenerator: avoid thick gapfill
Expand Down
11 changes: 7 additions & 4 deletions src/libslic3r/Fill/FillBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ struct FillParams
// Fill density, fraction in <0, 1>
float density { 0.f };

// bridge offset from the centerline.
coord_t bridge_offset = -1;

// Fill extruding flow multiplier, fraction in <0, 1>. Used by "over bridge compensation"
float flow_mult { 1.0f };

Expand Down Expand Up @@ -108,7 +111,7 @@ class Fill
FillAdaptive::Octree* adapt_fill_octree = nullptr;
protected:
// in unscaled coordinates, please use init (after settings all others settings) as some algos want to modify the value
coordf_t spacing_priv;
double spacing_priv;

public:
virtual ~Fill() {}
Expand All @@ -118,8 +121,8 @@ class Fill
static Fill* new_from_type(const std::string &type);

void set_bounding_box(const Slic3r::BoundingBox &bbox) { bounding_box = bbox; }
virtual void init_spacing(coordf_t spacing, const FillParams &params) { this->spacing_priv = spacing; }
coordf_t get_spacing() const { return spacing_priv; }
virtual void init_spacing(double spacing, const FillParams &params) { this->spacing_priv = spacing; }
double get_spacing() const { return spacing_priv; }

// Do not sort the fill lines to optimize the print head path?
virtual bool no_sort() const { return false; }
Expand Down Expand Up @@ -181,7 +184,7 @@ class Fill
//for rectilinear
static void connect_infill(Polylines&& infill_ordered, const ExPolygon& boundary, const Polygons& polygons_src, Polylines& polylines_out, const double spacing, const FillParams& params);

static coord_t _adjust_solid_spacing(const coord_t width, const coord_t distance);
static coord_t _adjust_solid_spacing(const coord_t width, const coord_t distance, const double factor_max = 1.2);

// Align a coordinate to a grid. The coordinate may be negative,
// the aligned value will never be bigger than the original one.
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Fill/FillConcentric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ FillConcentric::init_spacing(coordf_t spacing, const FillParams &params)
{
Fill::init_spacing(spacing, params);
if (params.density > 0.9999f && !params.dont_adjust) {
this->spacing_priv = unscale<double>(this->_adjust_solid_spacing(bounding_box.size()(0), _line_spacing_for_density(params.density)));
this->spacing_priv = unscaled(this->_adjust_solid_spacing(bounding_box.size()(0), _line_spacing_for_density(params.density)));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Fill/FillConcentric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class FillConcentric : public Fill

protected:
Fill* clone() const override { return new FillConcentric(*this); };
void init_spacing(coordf_t spacing, const FillParams &params) override;
void init_spacing(double spacing, const FillParams &params) override;
void _fill_surface_single(
const FillParams &params,
unsigned int thickness_layers,
Expand Down
4 changes: 2 additions & 2 deletions src/libslic3r/Fill/FillLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

namespace Slic3r {

void FillLine::init_spacing(coordf_t spacing, const FillParams& params) {
void FillLine::init_spacing(double spacing, const FillParams& params) {

this->_min_spacing = scale_(spacing);
this->_min_spacing = scale_t(spacing);
assert(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;
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Fill/FillLine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FillLine : public Fill
Fill* clone() const override { return new FillLine(*this); };
~FillLine() override = default;

void init_spacing(coordf_t spacing, const FillParams& params) override;
void init_spacing(double spacing, const FillParams& params) override;
protected:
void _fill_surface_single(
const FillParams &params,
Expand Down
Loading

0 comments on commit 8e14a10

Please sign in to comment.