NEW: FlipLines infill

jira:6701

New infill pattern that combine block lines infill and switching layers for smooth transition.

Change-Id: I2608a2d39b14efcdfe9d39a9437280da350b94c0
(cherry picked from commit 8d0a09c8b763dfc924cbba9913c241e6afadbc7f)
This commit is contained in:
jianjia.ma 2024-04-03 17:08:39 +08:00 committed by Lane.Wei
parent 1957f3ed1e
commit 1389862ad8
7 changed files with 843 additions and 2 deletions

View File

@ -0,0 +1,570 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="10"
height="10"
viewBox="0 0 10 10"
fill="none"
version="1.1"
id="svg19"
sodipodi:docname="param_flippingline.svg"
inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview19"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="64"
inkscape:cx="4.9921875"
inkscape:cy="5.8203125"
inkscape:window-width="1920"
inkscape:window-height="1017"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="svg19" />
<defs
id="defs19">
<clipPath
id="clip0_8962_33456">
<rect
width="10"
height="10"
fill="white"
id="rect19" />
</clipPath>
<mask
id="mask9_7_73"
maskUnits="userSpaceOnUse"
x="0"
y="0"
width="10"
height="10">
<path
d="M 10,0 H 0 v 10 h 10 z"
fill="#ffffff"
id="path27" />
</mask>
<mask
id="mask8_7_73"
maskUnits="userSpaceOnUse"
x="0"
y="0"
width="10"
height="10">
<path
d="M 10,0 H 0 v 10 h 10 z"
fill="#ffffff"
id="path24" />
</mask>
<mask
id="mask7_7_73"
maskUnits="userSpaceOnUse"
x="0"
y="0"
width="10"
height="10">
<path
d="M 10,0 H 0 v 10 h 10 z"
fill="#ffffff"
id="path21" />
</mask>
<mask
id="mask6_7_73"
maskUnits="userSpaceOnUse"
x="0"
y="0"
width="10"
height="10">
<path
d="M 10,0 H 0 v 10 h 10 z"
fill="#ffffff"
id="path18" />
</mask>
<mask
id="mask5_7_73"
maskUnits="userSpaceOnUse"
x="0"
y="0"
width="10"
height="10">
<path
d="M 10,0 H 0 v 10 h 10 z"
fill="#ffffff"
id="path15" />
</mask>
<mask
id="mask4_7_73"
maskUnits="userSpaceOnUse"
x="0"
y="0"
width="10"
height="10">
<path
d="M 10,0 H 0 v 10 h 10 z"
fill="#ffffff"
id="path12" />
</mask>
<mask
id="mask3_7_73"
maskUnits="userSpaceOnUse"
x="0"
y="0"
width="10"
height="10">
<path
d="M 10,0 H 0 v 10 h 10 z"
fill="#ffffff"
id="path9" />
</mask>
<mask
id="mask2_7_73"
maskUnits="userSpaceOnUse"
x="0"
y="0"
width="10"
height="10">
<path
d="M 10,0 H 0 v 10 h 10 z"
fill="#ffffff"
id="path6" />
</mask>
<mask
id="mask1_7_73"
maskUnits="userSpaceOnUse"
x="0"
y="0"
width="10"
height="10">
<path
d="M 10,0 H 0 v 10 h 10 z"
fill="#ffffff"
id="path3" />
</mask>
<mask
id="mask0_7_73"
maskUnits="userSpaceOnUse"
x="0"
y="0"
width="10"
height="10">
<path
d="M 10,0 H 0 v 10 h 10 z"
fill="#ffffff"
id="path1" />
</mask>
</defs>
<g
mask="url(#mask1_7_73)"
id="g5"
transform="translate(-0.13363557,-0.18774744)"
inkscape:highlight-color="#c8c8c8"
style="stroke-width:0.3;stroke-dasharray:none">
<path
d="M 2.64639,4.15868 4.27272,2.53235 2.64639,0.906019 1.02006,2.53235 Z"
stroke="#262e30"
stroke-width="0.4207"
id="path4"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 2.6464,3.3954519 0.84852,-0.84852 -0.84852,-0.84852 -0.84852,0.84852 z"
stroke="#262e30"
stroke-width="0.4359"
id="path5"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="M 2.64639,4.15868 4.27272,2.53235 2.64639,0.906019 1.02006,2.53235 Z"
stroke="#262e30"
stroke-width="0.4207"
id="path31"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 2.6464,3.3954519 0.84852,-0.84852 -0.84852,-0.84852 -0.84852,0.84852 z"
stroke="#262e30"
stroke-width="0.4359"
id="path32"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="M 2.64639,4.15868 4.27272,2.53235 2.64639,0.906019 1.02006,2.53235 Z"
stroke="#262e30"
stroke-width="0.4207"
id="path50"
style="stroke:#b5bfc2;stroke-opacity:1;stroke-width:0.3;stroke-dasharray:none" />
<path
d="m 2.6464,3.3954519 0.84852,-0.84852 -0.84852,-0.84852 -0.84852,0.84852 z"
stroke="#262e30"
stroke-width="0.4359"
id="path51"
style="stroke:#b5bfc2;stroke-opacity:1;stroke-width:0.3;stroke-dasharray:none" />
</g>
<g
mask="url(#mask2_7_73)"
id="g8"
transform="translate(-0.13363557,-0.18774744)"
style="stroke-width:0.3;stroke-dasharray:none">
<path
d="M 5.96315,4.1516 7.58948,2.52527 5.96315,0.898939 4.33682,2.52527 Z"
stroke="#262e30"
stroke-width="0.4207"
id="path7"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 5.9655316,3.3616097 0.84852,-0.84852 -0.84852,-0.84852 -0.84852,0.84852 z"
stroke="#262e30"
stroke-width="0.4359"
id="path8"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="M 5.96315,4.1516 7.58948,2.52527 5.96315,0.898939 4.33682,2.52527 Z"
stroke="#262e30"
stroke-width="0.4207"
id="path33"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 5.9655316,3.3616097 0.84852,-0.84852 -0.84852,-0.84852 -0.84852,0.84852 z"
stroke="#262e30"
stroke-width="0.4359"
id="path34"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="M 5.96315,4.1516 7.58948,2.52527 5.96315,0.898939 4.33682,2.52527 Z"
stroke="#262e30"
stroke-width="0.4207"
id="path52"
style="stroke:#b5bfc2;stroke-opacity:1;stroke-width:0.3;stroke-dasharray:none" />
<path
d="m 5.9655316,3.3616097 0.84852,-0.84852 -0.84852,-0.84852 -0.84852,0.84852 z"
stroke="#262e30"
stroke-width="0.4359"
id="path53"
style="stroke:#b5bfc2;stroke-opacity:1;stroke-width:0.3;stroke-dasharray:none" />
</g>
<g
mask="url(#mask3_7_73)"
id="g11"
transform="translate(-0.13363557,-0.18774744)"
style="stroke-width:0.3;stroke-dasharray:none">
<path
d="m 9.20001,4.10005 -1.6,-1.6 1.6,-1.700001"
stroke="#262e30"
stroke-width="0.4207"
id="path10"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 9.20001,3.30007 -0.8,-0.8 0.8,-0.8"
stroke="#262e30"
stroke-width="0.4359"
id="path11"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 9.20001,4.10005 -1.6,-1.6 1.6,-1.700001"
stroke="#262e30"
stroke-width="0.4207"
id="path35"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 9.20001,3.30007 -0.8,-0.8 0.8,-0.8"
stroke="#262e30"
stroke-width="0.4359"
id="path36"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 9.20001,4.10005 -1.6,-1.6 1.6,-1.700001"
stroke="#262e30"
stroke-width="0.4207"
id="path54"
style="stroke:#b5bfc2;stroke-opacity:1;stroke-width:0.3;stroke-dasharray:none" />
<path
d="m 9.20001,3.30007 -0.8,-0.8 0.8,-0.8"
stroke="#262e30"
stroke-width="0.4359"
id="path55"
style="stroke:#b5bfc2;stroke-opacity:1;stroke-width:0.3;stroke-dasharray:none" />
</g>
<g
mask="url(#mask4_7_73)"
id="g14"
transform="translate(-0.13363557,-0.18774744)"
style="stroke-width:0.3;stroke-dasharray:none">
<path
d="M 2.66075,7.4934 4.28708,5.86707 2.66075,4.24074 1.03442,5.86707 Z"
stroke="#262e30"
stroke-width="0.4207"
id="path13"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 2.6485797,6.7301719 0.84852,-0.84852 -0.84852,-0.84852 -0.84852,0.84852 z"
stroke="#262e30"
stroke-width="0.4359"
id="path14"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="M 2.66075,7.4934 4.28708,5.86707 2.66075,4.24074 1.03442,5.86707 Z"
stroke="#262e30"
stroke-width="0.4207"
id="path37"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 2.6485797,6.7301719 0.84852,-0.84852 -0.84852,-0.84852 -0.84852,0.84852 z"
stroke="#262e30"
stroke-width="0.4359"
id="path38"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="M 2.66075,7.4934 4.28708,5.86707 2.66075,4.24074 1.03442,5.86707 Z"
stroke="#262e30"
stroke-width="0.4207"
id="path56"
style="stroke:#b5bfc2;stroke-opacity:1;stroke-width:0.3;stroke-dasharray:none" />
<path
d="m 2.6485797,6.7301719 0.84852,-0.84852 -0.84852,-0.84852 -0.84852,0.84852 z"
stroke="#262e30"
stroke-width="0.4359"
id="path57"
style="stroke:#b5bfc2;stroke-opacity:1;stroke-width:0.3;stroke-dasharray:none" />
</g>
<g
mask="url(#mask5_7_73)"
id="g17"
transform="translate(-0.13363557,-0.18774744)"
style="stroke-width:0.3;stroke-dasharray:none">
<path
d="M 5.97763,7.48632 7.60396,5.85999 5.97763,4.23366 4.3513,5.85999 Z"
stroke="#262e30"
stroke-width="0.4207"
id="path16"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 5.9800116,6.70851 0.84852,-0.84852 -0.84852,-0.84852 -0.84852,0.84852 z"
stroke="#262e30"
stroke-width="0.4359"
id="path17"
style="opacity:1;stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1"
inkscape:highlight-color="#a8a8a8" />
<path
d="M 5.97763,7.48632 7.60396,5.85999 5.97763,4.23366 4.3513,5.85999 Z"
stroke="#262e30"
stroke-width="0.4207"
id="path39"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 5.9800116,6.70851 0.84852,-0.84852 -0.84852,-0.84852 -0.84852,0.84852 z"
stroke="#262e30"
stroke-width="0.4359"
id="path40"
style="opacity:1;stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1"
inkscape:highlight-color="#a8a8a8" />
<path
d="M 5.97763,7.48632 7.60396,5.85999 5.97763,4.23366 4.3513,5.85999 Z"
stroke="#262e30"
stroke-width="0.4207"
id="path58"
style="stroke:#b5bfc2;stroke-opacity:1;stroke-width:0.3;stroke-dasharray:none" />
<path
d="m 5.9800116,6.70851 0.84852,-0.84852 -0.84852,-0.84852 -0.84852,0.84852 z"
stroke="#262e30"
stroke-width="0.4359"
id="path59"
style="opacity:1;stroke:#b5bfc2;stroke-opacity:1;stroke-width:0.3;stroke-dasharray:none"
inkscape:highlight-color="#a8a8a8" />
</g>
<g
mask="url(#mask6_7_73)"
id="g20"
transform="translate(-0.13363557,-0.18774744)"
style="stroke-width:0.3;stroke-dasharray:none">
<path
d="m 9.20001,7.49995 -1.6,-1.7 1.6,-1.6"
stroke="#262e30"
stroke-width="0.4207"
id="path19"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 9.20001,6.6 -0.8,-0.8 0.8,-0.8"
stroke="#262e30"
stroke-width="0.4359"
id="path20"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 9.20001,7.49995 -1.6,-1.7 1.6,-1.6"
stroke="#262e30"
stroke-width="0.4207"
id="path41"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 9.20001,6.6 -0.8,-0.8 0.8,-0.8"
stroke="#262e30"
stroke-width="0.4359"
id="path42"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 9.20001,7.49995 -1.6,-1.7 1.6,-1.6"
stroke="#262e30"
stroke-width="0.4207"
id="path60"
style="stroke:#b5bfc2;stroke-opacity:1;stroke-width:0.3;stroke-dasharray:none" />
<path
d="m 9.20001,6.6 -0.8,-0.8 0.8,-0.8"
stroke="#262e30"
stroke-width="0.4359"
id="path61"
style="stroke:#b5bfc2;stroke-opacity:1;stroke-width:0.3;stroke-dasharray:none" />
</g>
<g
mask="url(#mask7_7_73)"
id="g23"
transform="translate(-0.13363557,-0.18774744)"
style="stroke-width:0.3;stroke-dasharray:none">
<path
d="m 0.899994,9.2 1.699996,-1.7 1.7,1.7"
stroke="#262e30"
stroke-width="0.4207"
id="path22"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 1.79999,9.20005 0.8,-0.9 0.8,0.9"
stroke="#262e30"
stroke-width="0.4359"
id="path23"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 0.899994,9.2 1.699996,-1.7 1.7,1.7"
stroke="#262e30"
stroke-width="0.4207"
id="path43"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 1.79999,9.20005 0.8,-0.9 0.8,0.9"
stroke="#262e30"
stroke-width="0.4359"
id="path44"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 0.899994,9.2 1.699996,-1.7 1.7,1.7"
stroke="#262e30"
stroke-width="0.4207"
id="path62"
style="stroke:#b5bfc2;stroke-opacity:1;stroke-width:0.3;stroke-dasharray:none" />
<path
d="m 1.79999,9.20005 0.8,-0.9 0.8,0.9"
stroke="#262e30"
stroke-width="0.4359"
id="path63"
style="stroke:#b5bfc2;stroke-opacity:1;stroke-width:0.3;stroke-dasharray:none" />
</g>
<g
mask="url(#mask8_7_73)"
id="g26"
transform="translate(-0.06473357,-0.11884544)"
style="stroke-width:0.3;stroke-dasharray:none">
<path
d="M 4.3,9.2 5.9,7.5 7.6,9.2"
stroke="#262e30"
stroke-width="0.4207"
id="path25"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 5.10001,9.20005 0.8,-0.9 0.8,0.9"
stroke="#262e30"
stroke-width="0.4359"
id="path26"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="M 4.3,9.2 5.9,7.5 7.6,9.2"
stroke="#262e30"
stroke-width="0.4207"
id="path45"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 5.10001,9.20005 0.8,-0.9 0.8,0.9"
stroke="#262e30"
stroke-width="0.4359"
id="path46"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="M 4.3,9.2 5.9,7.5 7.6,9.2"
stroke="#262e30"
stroke-width="0.4207"
id="path64"
style="stroke:#b5bfc2;stroke-width:0.3;stroke-dasharray:none;stroke-opacity:1" />
<path
d="m 5.10001,9.20005 0.8,-0.9 0.8,0.9"
stroke="#262e30"
stroke-width="0.4359"
id="path65"
style="stroke:#b5bfc2;stroke-width:0.3;stroke-dasharray:none;stroke-opacity:1" />
</g>
<g
mask="url(#mask9_7_73)"
id="g29"
transform="translate(-0.13363557,-0.18774744)"
style="stroke-width:0.3;stroke-dasharray:none">
<path
d="M 7.5,9.2 9.2,7.5"
stroke="#262e30"
stroke-width="0.4207"
id="path28"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 8.39999,9.20005 0.8,-0.9"
stroke="#262e30"
stroke-width="0.4359"
id="path29"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="M 7.5,9.2 9.2,7.5"
stroke="#262e30"
stroke-width="0.4207"
id="path47"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="m 8.39999,9.20005 0.8,-0.9"
stroke="#262e30"
stroke-width="0.4359"
id="path48"
style="stroke-width:0.3;stroke-dasharray:none;stroke:#b5bfc2;stroke-opacity:1" />
<path
d="M 7.5,9.2 9.2,7.5"
stroke="#262e30"
stroke-width="0.4207"
id="path66"
style="stroke:#b5bfc2;stroke-opacity:1;stroke-width:0.3;stroke-dasharray:none" />
<path
d="m 8.39999,9.20005 0.8,-0.9"
stroke="#262e30"
stroke-width="0.4359"
id="path67"
style="stroke:#b5bfc2;stroke-opacity:1;stroke-width:0.3;stroke-dasharray:none" />
</g>
<path
style="fill:#d38d5f;stroke:#242b2c;stroke-width:0.478;stroke-opacity:1;stroke-dasharray:none"
d="M 2.3610996,0.53829537 9.2877131,7.4647963"
id="path68" />
<path
style="fill:#d38d5f;stroke:#242b2c;stroke-width:0.499732;stroke-dasharray:none;stroke-opacity:1"
d="M 0.71099005,2.1609755 7.4945031,9.1745657"
id="path68-8" />
<path
style="fill:#d38d5f;stroke:#242b2c;stroke-width:0.478;stroke-opacity:1;stroke-dasharray:none"
d="M 0.67215306,5.4266372 4.2775124,9.1659794"
id="path69" />
<path
style="fill:#d38d5f;stroke:#242b2c;stroke-width:0.504841;stroke-dasharray:none;stroke-opacity:1"
d="M 5.7241868,0.5762967 9.2982017,4.0646825"
id="path70" />
<rect
style="fill:none;stroke:#1e2425;stroke-width:0.406;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:3.9;stroke-dasharray:none;stroke-opacity:1;paint-order:normal"
id="rect1"
width="8.683177"
height="8.6487265"
x="0.63658094"
y="0.53322792"
ry="0.86468774" />
</svg>

After

Width:  |  Height:  |  Size: 18 KiB

View File

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

View File

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

View File

@ -0,0 +1,235 @@
#include "../ClipperUtils.hpp"
#include "../ShortestPath.hpp"
#include "../Surface.hpp"
#include "FillFlippingLine.hpp"
namespace Slic3r {
// FlipLines Infill: Enhances 3D Printing Speed & Reduces Noise
// FlipLines, 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.
// The transform technique is inspired by David Eccles, improved 3D honeycomb but also 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.
// By Bambu Lab
// graph credits: David Eccles (gringer).
// But we made a different definition for points.
/* o---o
* / \
* / \
* \ /
* \ /
* o---o
* 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)
{
Pointfs out;
double offset = progress * 1. / 8. * period;
out.reserve(4);
out.push_back(Vec2d(offset, offset));
out.push_back(Vec2d(0.5 * period - offset, offset));
out.push_back(Vec2d(0.5 * period + offset, -offset));
out.push_back(Vec2d(1. * period - offset, -offset));
return out;
}
static Polylines generate_transform_pattern(double inprogress, int direction, coordf_t ingrid_size, coordf_t inwidth, coordf_t inheight)
{
coordf_t width = inwidth;
coordf_t height = inheight;
coordf_t grid_size = ingrid_size * 2; // we due with odd and even saparately.
double progress = inprogress;
Polylines out_polylines;
// generate template patterns;
Pointfs one_cycle_points = generate_one_cycle(progress, grid_size);
Polyline one_cycle;
one_cycle.points.reserve(one_cycle_points.size());
for (size_t i = 0; i < one_cycle_points.size(); i++) one_cycle.points.push_back(Point(one_cycle_points[i]));
// swap if vertical
if (direction < 0) {
width = height;
height = inwidth;
}
// replicate polylines;
Polylines odd_polylines;
Polyline odd_poly;
int num_of_cycle = width / grid_size + 2;
odd_poly.points.reserve(num_of_cycle * one_cycle.size());
// replicate to odd line
Point translate = Point(0, 0);
for (size_t i = 0; i < num_of_cycle; i++) {
Polyline odd_points;
odd_points = Polyline(one_cycle);
odd_points.translate(Point(i * grid_size, 0.0));
odd_poly.points.insert(odd_poly.points.end(), odd_points.begin(), odd_points.end());
}
// fill the height
int num_of_lines = height / grid_size + 2;
odd_polylines.reserve(num_of_lines * odd_poly.size());
for (size_t i = 0; i < num_of_lines; i++) {
Polyline poly = odd_poly;
poly.translate(Point(0.0, grid_size * i));
odd_polylines.push_back(poly);
}
// save to output
out_polylines.insert(out_polylines.end(), odd_polylines.begin(), odd_polylines.end());
// replicate to even lines
Polylines even_polylines;
even_polylines.reserve(odd_polylines.size());
for (size_t i = 0; i < odd_polylines.size(); i++) {
Polyline even = odd_poly;
even.translate(Point(-0.5 * grid_size, (i + 0.5) * grid_size));
even_polylines.push_back(even);
}
// save for output
out_polylines.insert(out_polylines.end(), even_polylines.begin(), even_polylines.end());
// change to vertical if need
if (direction < 0) {
// swap xy, see if we need better performance method
for (Polyline &poly : out_polylines) {
for (Point &p : poly) { std::swap(p.x(), p.y()); }
}
}
return out_polylines;
}
static Polylines generate_repeat_pattern(int direction, coordf_t grid_size, coordf_t inwidth, coordf_t inheight)
{
coordf_t width = inwidth;
coordf_t height = inheight;
Polylines out_polylines;
// swap if vertical
if (direction < 0) {
width = height;
height = inwidth;
}
int num_of_lines = height / grid_size + 1;
out_polylines.reserve(num_of_lines);
for (int i = 0; i < num_of_lines; i++) {
Polyline poly;
poly.points.reserve(2);
poly.append(Point(coordf_t(0), coordf_t(grid_size * i)));
poly.append(Point(width, coordf_t(grid_size * i)));
out_polylines.push_back(poly);
}
// change to vertical if needed
if (direction < 0) {
// swap xy
for (Polyline &poly : out_polylines) {
for (Point &p : poly) { std::swap(p.x(), p.y()); }
}
}
return out_polylines;
}
// it makes the real patterns that overlap the bounding box
// repeat_ratio define the ratio between the height of repeat pattern and grid
static Polylines generate_infill_layers(coordf_t z_height, double repeat_ratio, coordf_t grid_size, coordf_t width, coordf_t height)
{
Polylines result;
coordf_t trans_layer_size = grid_size * 0.3; // upper.
coordf_t repeat_layer_size = grid_size * repeat_ratio; // lower.
coordf_t period = trans_layer_size + repeat_layer_size;
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 repeat_z = remains;
int phase = fmod(z_height, period * 2) - (period - 1); // add epsilon
int direction = phase <= 0 ? -1 : 1;
// this is a repeat layer
if (trans_z < 0) {
result = generate_repeat_pattern(direction, grid_size, width, height);
}
// this is a transform layer
else {
double progress = fmod(trans_z, trans_layer_size) / trans_layer_size;
// split the progress to forward and backward, with a opposite direction.
if (progress < 0.5)
result = generate_transform_pattern(progress * 2, direction, grid_size, width, height);
else
result = generate_transform_pattern((1 - progress) * 2, -1 * direction, grid_size, width, height);
}
return result;
}
void FillFlippingLine ::_fill_surface_single(
const FillParams &params, unsigned int thickness_layers, const std::pair<float, Point> &direction, ExPolygon expolygon, Polylines &polylines_out)
{
// rotate angle
auto infill_angle = float(this->angle);
if (std::abs(infill_angle) >= EPSILON) expolygon.rotate(-infill_angle);
// get the rotated bounding box
BoundingBox bb = expolygon.contour.bounding_box();
// linespace modifier
coord_t line_spacing = coord_t(scale_(this->spacing) / params.density);
// reduce density
if (params.density < 0.999) line_spacing *= 1.5;
bb.merge(align_to_grid(bb.min, Point(line_spacing * 4, line_spacing * 4)));
// generate pattern
Polylines polylines = generate_infill_layers(scale_(this->z), 1, line_spacing, bb.size()(0), bb.size()(1));
// shift the pattern to the actual space
for (Polyline &pl : polylines) { pl.translate(bb.min); }
polylines = intersection_pl(polylines, to_polygons(expolygon));
// --- remove small remains from gyroid infill
if (!polylines.empty()) {
// Remove very small bits, but be careful to not remove infill lines connecting thin walls!
// The infill perimeter lines should be separated by around a single infill line width.
const double minlength = scale_(0.8 * this->spacing);
polylines.erase(std::remove_if(polylines.begin(), polylines.end(), [minlength](const Polyline &pl)
{ return pl.length() < minlength; }), polylines.end());
}
if (!polylines.empty()) {
int infill_start_idx = polylines_out.size(); // only rotate what belongs to us.
// connect lines
if (params.dont_connect() || polylines.size() <= 1)
append(polylines_out, chain_polylines(std::move(polylines)));
else
this->connect_infill(std::move(polylines), expolygon, polylines_out, this->spacing, params);
// rotate back
if (std::abs(infill_angle) >= EPSILON) {
for (auto it = polylines_out.begin() + infill_start_idx; it != polylines_out.end(); ++it) it->rotate(infill_angle);
}
}
}
} // namespace Slic3r

View File

@ -0,0 +1,29 @@
#ifndef slic3r_FillFlippingLines_hpp_
#define slic3r_FillFlippingLines_hpp_
#include <map>
#include "../libslic3r.h"
#include "FillBase.hpp"
namespace Slic3r {
class FillFlippingLine : public Fill
{
public:
Fill *clone() const override { return new FillFlippingLine(*this); };
~FillFlippingLine() override {}
protected:
void _fill_surface_single(
const FillParams &params,
unsigned int thickness_layers,
const std::pair<float, Point> &direction,
ExPolygon expolygon,
Polylines &polylines_out) override;
};
} // namespace Slic3r
#endif // slic3r_FillFlippingLines_hpp_

View File

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

View File

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