ENH: Improve CrossHatch transation layers

jira: 6701

Change name from Flippingline to CrossHatch.

Reduce noise, improve speed by 6.5%. Improve transation layers by
gradually increasing rotation angle and overshoot the transation
layer while direction changed.

Change-Id: I17fcc45b409074d121bf5bb5702e15553d925b51
This commit is contained in:
jianjia.ma 2024-04-18 16:34:26 +08:00 committed by Lane.Wei
parent 1bd02c6aa6
commit 6540855ff7
8 changed files with 29 additions and 37 deletions

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -84,8 +84,8 @@ set(lisbslic3r_sources
Fill/FillConcentric.hpp Fill/FillConcentric.hpp
Fill/FillConcentricInternal.cpp Fill/FillConcentricInternal.cpp
Fill/FillConcentricInternal.hpp Fill/FillConcentricInternal.hpp
Fill/FillFlippingLine.cpp Fill/FillCrossHatch.cpp
Fill/FillFlippingLine.hpp Fill/FillCrossHatch.hpp
Fill/FillHoneycomb.cpp Fill/FillHoneycomb.cpp
Fill/FillHoneycomb.hpp Fill/FillHoneycomb.hpp
Fill/FillGyroid.cpp Fill/FillGyroid.cpp

View File

@ -23,7 +23,7 @@
#include "FillLightning.hpp" #include "FillLightning.hpp"
// BBS: new infill pattern header // BBS: new infill pattern header
#include "FillConcentricInternal.hpp" #include "FillConcentricInternal.hpp"
#include "FillFlippingLine.hpp" #include "FillCrossHatch.hpp"
// #define INFILL_DEBUG_OUTPUT // #define INFILL_DEBUG_OUTPUT
@ -38,7 +38,7 @@ Fill* Fill::new_from_type(const InfillPattern type)
case ipGyroid: return new FillGyroid(); case ipGyroid: return new FillGyroid();
case ipRectilinear: return new FillRectilinear(); case ipRectilinear: return new FillRectilinear();
case ipAlignedRectilinear: return new FillAlignedRectilinear(); case ipAlignedRectilinear: return new FillAlignedRectilinear();
case ipFlippingLine: return new FillFlippingLine(); case ipCrossHatch: return new FillCrossHatch();
case ipMonotonic: return new FillMonotonic(); case ipMonotonic: return new FillMonotonic();
case ipLine: return new FillLine(); case ipLine: return new FillLine();
case ipGrid: return new FillGrid(); case ipGrid: return new FillGrid();

View File

@ -2,14 +2,14 @@
#include "../ShortestPath.hpp" #include "../ShortestPath.hpp"
#include "../Surface.hpp" #include "../Surface.hpp"
#include "FillFlippingLine.hpp" #include "FillCrossHatch.hpp"
namespace Slic3r { namespace Slic3r {
// FlipLines Infill: Enhances 3D Printing Speed & Reduces Noise // CrossHatch Infill: Enhances 3D Printing Speed & Reduces Noise
// FlipLines, as its name hints, alternates line direction by 90 degrees every few layers to improve adhesion. // CrossHatch, as its name hints, alternates line direction by 90 degrees every few layers to improve adhesion.
// It introduces transform layers between direction shifts for better line cohesion, which fixes the weakness of line infill. // It introduces transform layers between direction shifts for better line cohesion, which fixes the weakness of line infill.
// The transform technique is inspired by David Eccles, improved 3D honeycomb but also a more flexible implementation. // The transform technique is inspired by David Eccles, improved 3D honeycomb but we made a more flexible implementation.
// This method notably increases printing speed, meeting the demands of modern high-speed 3D printers, and reduces noise for most layers. // This method notably increases printing speed, meeting the demands of modern high-speed 3D printers, and reduces noise for most layers.
// By Bambu Lab // By Bambu Lab
@ -22,15 +22,6 @@ namespace Slic3r {
* \ / * \ /
* o---o * o---o
* p1 p2 p3 p4 * p1 p2 p3 p4
*
* // X1 = progress * (1/8) * period
* // X2 = ( (1/2 - progress) * (1/8) ) * period
* // X3 = X1 + (1/2) * period
* // X4 = ( (1 - progress) * (1/8) ) * period
* // Y1 = X1
* // Y2 = X1
* // Y3 = -X1
* // Y4 = -X1
*/ */
static Pointfs generate_one_cycle(double progress, coordf_t period) static Pointfs generate_one_cycle(double progress, coordf_t period)
@ -38,10 +29,10 @@ static Pointfs generate_one_cycle(double progress, coordf_t period)
Pointfs out; Pointfs out;
double offset = progress * 1. / 8. * period; double offset = progress * 1. / 8. * period;
out.reserve(4); out.reserve(4);
out.push_back(Vec2d(offset, offset)); out.push_back(Vec2d(0.25 * period - offset, offset));
out.push_back(Vec2d(0.5 * period - offset, offset)); out.push_back(Vec2d(0.25 * period + offset, offset));
out.push_back(Vec2d(0.5 * period + offset, -offset)); out.push_back(Vec2d(0.75 * period - offset, -offset));
out.push_back(Vec2d(1. * period - offset, -offset)); out.push_back(Vec2d(0.75 * period + offset, -offset));
return out; return out;
} }
@ -154,8 +145,9 @@ static Polylines generate_repeat_pattern(int direction, coordf_t grid_size, coor
static Polylines generate_infill_layers(coordf_t z_height, double repeat_ratio, coordf_t grid_size, coordf_t width, coordf_t height) static Polylines generate_infill_layers(coordf_t z_height, double repeat_ratio, coordf_t grid_size, coordf_t width, coordf_t height)
{ {
Polylines result; Polylines result;
coordf_t trans_layer_size = grid_size * 0.3; // upper. coordf_t trans_layer_size = grid_size * 0.4; // upper.
coordf_t repeat_layer_size = grid_size * repeat_ratio; // lower. coordf_t repeat_layer_size = grid_size * repeat_ratio; // lower.
z_height += repeat_layer_size / 2; // offset to improve first few layer strength
coordf_t period = trans_layer_size + repeat_layer_size; coordf_t period = trans_layer_size + repeat_layer_size;
coordf_t remains = z_height - std::floor(z_height / period) * period; coordf_t remains = z_height - std::floor(z_height / period) * period;
coordf_t trans_z = remains - repeat_layer_size; // put repeat layer first. coordf_t trans_z = remains - repeat_layer_size; // put repeat layer first.
@ -174,15 +166,15 @@ static Polylines generate_infill_layers(coordf_t z_height, double repeat_ratio,
// split the progress to forward and backward, with a opposite direction. // split the progress to forward and backward, with a opposite direction.
if (progress < 0.5) if (progress < 0.5)
result = generate_transform_pattern(progress * 2, direction, grid_size, width, height); result = generate_transform_pattern((progress + 0.1) * 2, direction, grid_size, width, height); // increase overlapping.
else else
result = generate_transform_pattern((1 - progress) * 2, -1 * direction, grid_size, width, height); result = generate_transform_pattern((1.1 - progress) * 2, -1 * direction, grid_size, width, height);
} }
return result; return result;
} }
void FillFlippingLine ::_fill_surface_single( void FillCrossHatch ::_fill_surface_single(
const FillParams &params, unsigned int thickness_layers, const std::pair<float, Point> &direction, ExPolygon expolygon, Polylines &polylines_out) const FillParams &params, unsigned int thickness_layers, const std::pair<float, Point> &direction, ExPolygon expolygon, Polylines &polylines_out)
{ {
// rotate angle // rotate angle

View File

@ -1,5 +1,5 @@
#ifndef slic3r_FillFlippingLines_hpp_ #ifndef slic3r_FillCrossHatch_hpp_
#define slic3r_FillFlippingLines_hpp_ #define slic3r_FillCrossHatch_hpp_
#include <map> #include <map>
@ -9,11 +9,11 @@
namespace Slic3r { namespace Slic3r {
class FillFlippingLine : public Fill class FillCrossHatch : public Fill
{ {
public: public:
Fill *clone() const override { return new FillFlippingLine(*this); }; Fill *clone() const override { return new FillCrossHatch(*this); };
~FillFlippingLine() override {} ~FillCrossHatch() override {}
protected: protected:
void _fill_surface_single( void _fill_surface_single(
@ -26,4 +26,4 @@ protected:
} // namespace Slic3r } // namespace Slic3r
#endif // slic3r_FillFlippingLines_hpp_ #endif // slic3r_FillCrossHatch_hpp_

View File

@ -135,7 +135,7 @@ static t_config_enum_values s_keys_map_InfillPattern {
{ "octagramspiral", ipOctagramSpiral }, { "octagramspiral", ipOctagramSpiral },
{ "supportcubic", ipSupportCubic }, { "supportcubic", ipSupportCubic },
{ "lightning", ipLightning }, { "lightning", ipLightning },
{ "flippingline", ipFlippingLine} { "crosshatch", ipCrossHatch}
}; };
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(InfillPattern) CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(InfillPattern)
@ -1603,7 +1603,7 @@ void PrintConfigDef::init_fff_params()
def->enum_values.push_back("octagramspiral"); def->enum_values.push_back("octagramspiral");
def->enum_values.push_back("supportcubic"); def->enum_values.push_back("supportcubic");
def->enum_values.push_back("lightning"); def->enum_values.push_back("lightning");
def->enum_values.push_back("flippingline"); def->enum_values.push_back("crosshatch");
def->enum_labels.push_back(L("Concentric")); def->enum_labels.push_back(L("Concentric"));
def->enum_labels.push_back(L("Rectilinear")); def->enum_labels.push_back(L("Rectilinear"));
def->enum_labels.push_back(L("Grid")); def->enum_labels.push_back(L("Grid"));
@ -1621,7 +1621,7 @@ void PrintConfigDef::init_fff_params()
def->enum_labels.push_back(L("Octagram Spiral")); def->enum_labels.push_back(L("Octagram Spiral"));
def->enum_labels.push_back(L("Support Cubic")); def->enum_labels.push_back(L("Support Cubic"));
def->enum_labels.push_back(L("Lightning")); def->enum_labels.push_back(L("Lightning"));
def->enum_labels.push_back(L("Flipping Line")); def->enum_labels.push_back(L("Cross Hatch"));
def->set_default_value(new ConfigOptionEnum<InfillPattern>(ipCubic)); def->set_default_value(new ConfigOptionEnum<InfillPattern>(ipCubic));
def = this->add("top_surface_acceleration", coFloat); def = this->add("top_surface_acceleration", coFloat);

View File

@ -54,8 +54,8 @@ enum AuthorizationType {
enum InfillPattern : int { enum InfillPattern : int {
ipConcentric, ipRectilinear, ipGrid, ipLine, ipCubic, ipTriangles, ipStars, ipGyroid, ipHoneycomb, ipAdaptiveCubic, ipMonotonic, ipMonotonicLine, ipAlignedRectilinear, ip3DHoneycomb, ipConcentric, ipRectilinear, ipGrid, ipLine, ipCubic, ipTriangles, ipStars, ipGyroid, ipHoneycomb, ipAdaptiveCubic, ipMonotonic, ipMonotonicLine, ipAlignedRectilinear, ip3DHoneycomb,
ipHilbertCurve, ipArchimedeanChords, ipOctagramSpiral, ipSupportCubic, ipSupportBase, ipConcentricInternal, ipHilbertCurve, ipArchimedeanChords, ipOctagramSpiral, ipSupportCubic, ipSupportBase, ipConcentricInternal,
ipLightning, ipFlippingLine, ipLightning, ipCrossHatch,
ipCount, ipCount,
}; };
enum class IroningType { enum class IroningType {

View File

@ -2217,7 +2217,7 @@ void PrintObject::bridge_over_infill()
// Check it the infill that require a fixed infill angle. // Check it the infill that require a fixed infill angle.
switch (dominant_pattern) { switch (dominant_pattern) {
case ip3DHoneycomb: case ip3DHoneycomb:
case ipFlippingLine: case ipCrossHatch:
return (infill_direction + 45.0) * 2.0 * M_PI / 360.; return (infill_direction + 45.0) * 2.0 * M_PI / 360.;
default: break; default: break;
} }