Merge branch 'master' of https://github.com/prusa3d/PrusaSlicer into et_preview_layout

This commit is contained in:
enricoturri1966 2021-12-08 08:15:51 +01:00
commit b45d56b5b8
146 changed files with 224791 additions and 127456 deletions

1
.gitignore vendored
View File

@ -17,3 +17,4 @@ local-lib
/.vscode/
build-linux/*
deps/build-linux/*
**/.DS_Store

View File

@ -478,13 +478,27 @@ find_package(cereal REQUIRED)
# l10n
set(L10N_DIR "${SLIC3R_RESOURCES_DIR}/localization")
add_custom_target(gettext_make_pot
COMMAND xgettext --keyword=L --keyword=_L --keyword=_u8L --keyword=L_CONTEXT:1,2c --keyword=_L_PLURAL:1,2 --add-comments=TRN --from-code=UTF-8 --debug
COMMAND xgettext --keyword=L --keyword=_L --keyword=_u8L --keyword=L_CONTEXT:1,2c --keyword=_L_PLURAL:1,2 --add-comments=TRN --from-code=UTF-8 --debug --boost
-f "${L10N_DIR}/list.txt"
-o "${L10N_DIR}/PrusaSlicer.pot"
COMMAND hintsToPot ${SLIC3R_RESOURCES_DIR} ${L10N_DIR}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Generate pot file from strings in the source tree"
)
add_custom_target(gettext_merge_po_with_pot
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Merge localization po with new generted pot file"
)
file(GLOB L10N_PO_FILES "${L10N_DIR}/*/PrusaSlicer*.po")
foreach(po_file ${L10N_PO_FILES})
GET_FILENAME_COMPONENT(po_dir "${po_file}" DIRECTORY)
SET(po_new_file "${po_dir}/PrusaSlicer_.po")
add_custom_command(
TARGET gettext_merge_po_with_pot PRE_BUILD
COMMAND msgmerge -N -o ${po_file} ${po_file} "${L10N_DIR}/PrusaSlicer.pot"
DEPENDS ${po_file}
)
endforeach()
add_custom_target(gettext_po_to_mo
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Generate localization po files (binary) from mo files (texts)"
@ -495,7 +509,8 @@ foreach(po_file ${L10N_PO_FILES})
SET(mo_file "${po_dir}/PrusaSlicer.mo")
add_custom_command(
TARGET gettext_po_to_mo PRE_BUILD
COMMAND msgfmt ARGS -o ${mo_file} ${po_file}
COMMAND msgfmt ARGS --check-format -o ${mo_file} ${po_file}
#COMMAND msgfmt ARGS --check-compatibility -o ${mo_file} ${po_file}
DEPENDS ${po_file}
)
endforeach()

View File

@ -6,7 +6,8 @@
@ECHO Performs initial build or rebuild of the app (build) and deps (build/deps).
@ECHO Default options are determined from build directories and system state.
@ECHO.
@ECHO Usage: build_win [-ARCH ^<arch^>] [-CONFIG ^<config^>] [-DESTDIR ^<directory^>]
@ECHO Usage: build_win [-ARCH ^<arch^>] [-CONFIG ^<config^>] [-VERSION ^<version^>]
@ECHO [-PRODUCT ^<product^>] [-DESTDIR ^<directory^>]
@ECHO [-STEPS ^<all^|all-dirty^|app^|app-dirty^|deps^|deps-dirty^>]
@ECHO [-RUN ^<console^|custom^|none^|viewer^|window^>]
@ECHO.
@ -14,6 +15,10 @@
@ECHO Default: %PS_ARCH_HOST%
@ECHO -c -CONFIG MSVC project config
@ECHO Default: %PS_CONFIG_DEFAULT%
@ECHO -v -VERSION Major version number of MSVC installation to use for build
@ECHO Default: %PS_VERSION_SUPPORTED%
@ECHO -p -PRODUCT Product ID of MSVC installation to use for build
@ECHO Default: %PS_PRODUCT_DEFAULT%
@ECHO -s -STEPS Performs only the specified build steps:
@ECHO all - clean and build deps and app
@ECHO all-dirty - build deps and app without cleaning
@ -55,6 +60,23 @@ SET PS_DEPS_PATH_FILE_NAME=.DEPS_PATH.txt
SET PS_DEPS_PATH_FILE=%~dp0deps\build\%PS_DEPS_PATH_FILE_NAME%
SET PS_CONFIG_LIST="Debug;MinSizeRel;Release;RelWithDebInfo"
REM The officially supported toolchain version is 16 (Visual Studio 2019)
REM TODO: Update versions after Boost gets rolled to 1.78 or later
SET PS_VERSION_SUPPORTED=16
SET PS_VERSION_EXCEEDED=17
SET VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe
IF NOT EXIST "%VSWHERE%" SET VSWHERE=%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe
FOR /F "tokens=4 USEBACKQ delims=." %%I IN (`"%VSWHERE%" -nologo -property productId`) DO SET PS_PRODUCT_DEFAULT=%%I
IF "%PS_PRODUCT_DEFAULT%" EQU "" (
SET EXIT_STATUS=-1
@ECHO ERROR: No Visual Studio installation found. 1>&2
GOTO :HELP
)
REM Default to the latest supported version if multiple are available
FOR /F "tokens=1 USEBACKQ delims=." %%I IN (
`^""%VSWHERE%" -version "[%PS_VERSION_SUPPORTED%,%PS_VERSION_EXCEEDED%)" -latest -nologo -property catalog_buildVersion^"`
) DO SET PS_VERSION_SUPPORTED=%%I
REM Probe build directories and system state for reasonable default arguments
pushd %~dp0
SET PS_CONFIG=RelWithDebInfo
@ -62,6 +84,8 @@ SET PS_ARCH=%PROCESSOR_ARCHITECTURE:amd64=x64%
CALL :TOLOWER PS_ARCH
SET PS_RUN=none
SET PS_DESTDIR=
SET PS_VERSION=
SET PS_PRODUCT=%PS_PRODUCT_DEFAULT%
CALL :RESOLVE_DESTDIR_CACHE
REM Set up parameters used by help menu
@ -75,7 +99,7 @@ SET EXIT_STATUS=1
SET PS_CURRENT_STEP=arguments
SET PARSER_STATE=
SET PARSER_FAIL=
FOR %%I in (%*) DO CALL :PARSE_OPTION "ARCH CONFIG DESTDIR STEPS RUN" PARSER_STATE "%%~I"
FOR %%I in (%*) DO CALL :PARSE_OPTION "ARCH CONFIG DESTDIR STEPS RUN VERSION PRODUCT" PARSER_STATE "%%~I"
IF "%PARSER_FAIL%" NEQ "" (
@ECHO ERROR: Invalid switch: %PARSER_FAIL% 1>&2
GOTO :HELP
@ -124,6 +148,15 @@ IF "%PS_RUN%" NEQ "none" IF "%PS_STEPS:~0,4%" EQU "deps" (
@ECHO ERROR: RUN=none is the only valid option for STEPS "deps" or "deps-dirty"
GOTO :HELP
)
IF DEFINED PS_VERSION (
SET /A PS_VERSION_EXCEEDED=%PS_VERSION% + 1
) ELSE SET PS_VERSION=%PS_VERSION_SUPPORTED%
SET MSVC_FILTER=-products Microsoft.VisualStudio.Product.%PS_PRODUCT% -version "[%PS_VERSION%,%PS_VERSION_EXCEEDED%)"
FOR /F "tokens=* USEBACKQ" %%I IN (`^""%VSWHERE%" %MSVC_FILTER% -nologo -property installationPath^"`) DO SET MSVC_DIR=%%I
IF NOT EXIST "%MSVC_DIR%" (
@ECHO ERROR: Compatible Visual Studio installation not found. 1>&2
GOTO :HELP
)
REM Give the user a chance to cancel if we found something odd.
IF "%PS_ASK_TO_CONTINUE%" EQU "" GOTO :BUILD_ENV
@ECHO.
@ -142,9 +175,6 @@ SET PS_CURRENT_STEP=environment
@ECHO ** Run App: %PS_RUN%
@ECHO ** Deps path: %PS_DESTDIR%
@ECHO ** Using Microsoft Visual Studio installation found at:
SET VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe
IF NOT EXIST "%VSWHERE%" SET VSWHERE=%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe
FOR /F "tokens=* USEBACKQ" %%I IN (`"%VSWHERE%" -nologo -property installationPath`) DO SET MSVC_DIR=%%I
@ECHO ** %MSVC_DIR%
CALL "%MSVC_DIR%\Common7\Tools\vsdevcmd.bat" -arch=%PS_ARCH% -host_arch=%PS_ARCH_HOST% -app_platform=Desktop
IF %ERRORLEVEL% NEQ 0 GOTO :END
@ -276,7 +306,7 @@ REM Functions and stubs start here.
SET PS_DEPS_PATH_FILE_FOR_CONFIG=%~dp0build\.vs\%PS_ARCH%\%PS_CONFIG%\%PS_DEPS_PATH_FILE_NAME%
mkdir "%~dp0build\.vs\%PS_ARCH%\%PS_CONFIG%" > nul 2> nul
REM Copy a legacy file if we don't have one in the proper location.
echo f|xcopy /D "%~dp0build\%PS_ARCH%\%PS_CONFIG%\%PS_DEPS_PATH_FILE_NAME%" "%PS_DEPS_PATH_FILE_FOR_CONFIG%"
echo f|xcopy /D "%~dp0build\%PS_ARCH%\%PS_CONFIG%\%PS_DEPS_PATH_FILE_NAME%" "%PS_DEPS_PATH_FILE_FOR_CONFIG%" > nul 2> nul
CALL :CANONICALIZE_PATH PS_DEPS_PATH_FILE_FOR_CONFIG
IF EXIST "%PS_DEPS_PATH_FILE_FOR_CONFIG%" (
FOR /F "tokens=* USEBACKQ" %%I IN ("%PS_DEPS_PATH_FILE_FOR_CONFIG%") DO (

View File

@ -13,7 +13,7 @@ prusaslicer_add_cmake_project(wxWidgets
# GIT_REPOSITORY "https://github.com/prusa3d/wxWidgets"
# GIT_TAG tm_cross_compile #${_wx_git_tag}
URL https://github.com/prusa3d/wxWidgets/archive/refs/heads/v3.1.4-patched.zip
URL_HASH SHA256=ed36a2159c781cce07b06378664e683ebd8cb2f51914aba9acd3bfca3d63d7d3
URL_HASH SHA256=78adc312e645d738945172d5ddcee16b1a55cca08e82b43379192262377a206a
DEPENDS ${PNG_PKG} ${ZLIB_PKG} ${EXPAT_PKG} dep_TIFF dep_JPEG
CMAKE_ARGS
-DwxBUILD_PRECOMP=ON

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 25.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 128 128" enable-background="new 0 0 128 128" xml:space="preserve">
<g id="paint_x5F_supports">
<path fill="#ED6B21" d="M88,38.93c-0.83,0-1.5,0.67-1.5,1.5V70.5h-5V45.14c0-0.83-0.67-1.5-1.5-1.5s-1.5,0.67-1.5,1.5V70.5h-5V49.8
c0-0.83-0.67-1.5-1.5-1.5s-1.5,0.67-1.5,1.5v20.7h-5V53.84c0-0.83-0.67-1.5-1.5-1.5s-1.5,0.67-1.5,1.5V70.5h-5V49.8
c0-0.83-0.67-1.5-1.5-1.5s-1.5,0.67-1.5,1.5v20.7h-5V45.14c0-0.83-0.67-1.5-1.5-1.5s-1.5,0.67-1.5,1.5V70.5h-5V40.43
c0-0.83-0.67-1.5-1.5-1.5s-1.5,0.67-1.5,1.5V72v10.99c0,3.59,2.92,6.51,6.51,6.51h2.98c0.67,0.01,6.51,0.24,6.51,6.5v16
c0,3.29,1.99,9.5,9.5,9.5s9.5-6.21,9.5-9.5V96c0-6.26,5.84-6.49,6.5-6.5h3c3.59,0,6.5-2.92,6.5-6.5V72V40.43
C89.5,39.6,88.83,38.93,88,38.93z M86.5,83c0,1.93-1.57,3.5-3.5,3.5h-3c-3.29,0-9.5,1.99-9.5,9.5v15.99
c-0.01,0.67-0.24,6.51-6.5,6.51s-6.49-5.84-6.5-6.5V96c0-7.51-6.21-9.5-9.5-9.5h-2.99c-1.94,0-3.51-1.57-3.51-3.51V73.5h45V83z"/>
<g>
<path fill="#808080" d="M64,48.03c-0.26,0-0.52-0.07-0.75-0.2l-48-27.69c-0.46-0.27-0.75-0.76-0.75-1.3V8c0-0.83,0.67-1.5,1.5-1.5
s1.5,0.67,1.5,1.5v9.98L64,44.8l46.5-26.83V8c0-0.83,0.67-1.5,1.5-1.5s1.5,0.67,1.5,1.5v10.84c0,0.54-0.29,1.03-0.75,1.3
l-48,27.69C64.52,47.97,64.26,48.03,64,48.03z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 25.4.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="128px" height="128px" viewBox="0 0 128 128" enable-background="new 0 0 128 128" xml:space="preserve">
<path fill="#808080" d="M52.87,108.38c-5.24,0-9.5-4.26-9.5-9.5s4.26-9.5,9.5-9.5s9.5,4.26,9.5,9.5S58.11,108.38,52.87,108.38z
M52.87,92.38c-3.58,0-6.5,2.92-6.5,6.5s2.92,6.5,6.5,6.5s6.5-2.92,6.5-6.5S56.46,92.38,52.87,92.38z M29.82,83.59
c-5.24,0-9.5-4.26-9.5-9.5s4.26-9.5,9.5-9.5s9.5,4.26,9.5,9.5S35.06,83.59,29.82,83.59z M29.82,67.59c-3.58,0-6.5,2.92-6.5,6.5
s2.92,6.5,6.5,6.5s6.5-2.92,6.5-6.5S33.4,67.59,29.82,67.59z M34,49.86c-5.24,0-9.5-4.26-9.5-9.5s4.26-9.5,9.5-9.5s9.5,4.26,9.5,9.5
S39.24,49.86,34,49.86z M34,33.86c-3.58,0-6.5,2.92-6.5,6.5s2.92,6.5,6.5,6.5s6.5-2.92,6.5-6.5S37.59,33.86,34,33.86z M64,35.21
c-5.24,0-9.5-4.26-9.5-9.5s4.26-9.5,9.5-9.5s9.5,4.26,9.5,9.5S69.24,35.21,64,35.21z M64,19.21c-3.58,0-6.5,2.92-6.5,6.5
s2.92,6.5,6.5,6.5s6.5-2.92,6.5-6.5S67.58,19.21,64,19.21z M96.1,52.24c-5.24,0-9.5-4.26-9.5-9.5s4.26-9.5,9.5-9.5s9.5,4.26,9.5,9.5
S101.34,52.24,96.1,52.24z M96.1,36.24c-3.58,0-6.5,2.92-6.5,6.5s2.92,6.5,6.5,6.5s6.5-2.92,6.5-6.5S99.69,36.24,96.1,36.24z
M72.54,120.87c2.6-0.39,4.78-2.06,5.81-4.46c1.06-2.47,0.77-5.29-0.8-7.52c-3.1-4.43-4.49-9.87-3.92-15.31
c0.26-2.47,0.94-4.89,2.03-7.17c0.36-0.75,0.04-1.64-0.71-2c-0.75-0.36-1.64-0.04-2,0.71c-1.23,2.6-2.01,5.34-2.3,8.15
c-0.64,6.16,0.94,12.32,4.45,17.34c0.96,1.38,1.15,3.11,0.5,4.62c-0.63,1.47-1.91,2.44-3.5,2.68c-3.29,0.49-6.66,0.68-10.01,0.57
c-28.61-0.99-51.7-24.18-52.56-52.79c-0.46-15.2,5.2-29.48,15.94-40.21S50.49,9.07,65.68,9.53c28.62,0.86,51.8,23.94,52.79,52.56
c0.11,3.25-0.06,6.51-0.52,9.69c-0.24,1.66-1.31,3.06-2.87,3.73c-1.52,0.66-3.16,0.5-4.49-0.42c-3.29-2.3-7.17-3.8-11.21-4.34
c-0.83-0.11-1.58,0.47-1.68,1.29c-0.11,0.82,0.47,1.58,1.29,1.68c3.57,0.47,6.99,1.79,9.89,3.82c2.17,1.52,4.94,1.78,7.4,0.72
c2.52-1.09,4.26-3.36,4.65-6.06c0.48-3.36,0.67-6.8,0.55-10.22c-1.04-30.19-25.5-54.55-55.7-55.45
c-16.02-0.48-31.1,5.49-42.42,16.81C12.02,34.66,6.05,49.73,6.53,65.77c0.9,30.19,25.26,54.66,55.45,55.7
c0.67,0.02,1.34,0.04,2.01,0.04C66.86,121.5,69.73,121.29,72.54,120.87z"/>
<path fill="#ED6B21" d="M115.41,105.01l-27.66-38.8c7.76-12.6-22.89-18.09-27.92-23.34c-2.48-2.6-0.44,35.31,15.58,32.26
l29.74,37.59c0.54,0.91,3.45,5.54,7.39,6.36c0.39,0.08,0.78,0.12,1.16,0.12c1.26,0,2.48-0.42,3.58-1.25
c1.36-1.02,2.14-2.41,2.27-4.01C119.87,109.95,116.14,105.79,115.41,105.01z M78.44,74.13c1.24-0.57,2.54-1.37,3.92-2.42
c1.39-1.05,2.53-2.06,3.45-3.04l6.94,9.73l-6.85,5.15L78.44,74.13z M116.56,113.69c-0.06,0.76-0.4,1.35-1.08,1.85
c-0.77,0.58-1.51,0.76-2.33,0.6c-2.38-0.49-4.75-3.78-5.46-5.01c-0.04-0.06-0.08-0.12-0.12-0.18L87.76,85.91l6.73-5.06l18.53,25.99
c0.04,0.06,0.09,0.12,0.14,0.17C114.11,107.98,116.75,111.3,116.56,113.69z"/>
</svg>

After

Width:  |  Height:  |  Size: 2.9 KiB

35
resources/icons/seam_.svg Normal file
View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.3.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 128 128" enable-background="new 0 0 128 128" xml:space="preserve">
<g id="paint_x5F_seams_2_">
<polyline fill="none" stroke="#808080" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="
120,32 64,8 8,32 8,96 64,120 "/>
<path fill="none" stroke="#808080" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
M120,96"/>
<polyline fill="none" stroke="#808080" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="
8,32 64,56 64,120 "/>
<line fill="none" stroke="#808080" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="64" y1="56" x2="120" y2="32"/>
<line fill="none" stroke="#808080" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="64" y1="120" x2="120" y2="96"/>
<line fill="none" stroke="#808080" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="120" y1="96" x2="120" y2="32"/>
<line fill="none" stroke="#ED6B21" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="88.05" y1="53.69" x2="95.96" y2="50.3"/>
<line fill="none" stroke="#ED6B21" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="95.96" y1="58.3" x2="103.99" y2="54.86"/>
<line fill="none" stroke="#ED6B21" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="88.05" y1="69.69" x2="95.96" y2="66.3"/>
<line fill="none" stroke="#ED6B21" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="80.05" y1="81.12" x2="88.05" y2="77.69"/>
<line fill="none" stroke="#ED6B21" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="71.94" y1="92.6" x2="80.05" y2="89.12"/>
<line fill="none" stroke="#ED6B21" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="80.05" y1="97.12" x2="88.05" y2="93.69"/>
<line fill="none" stroke="#ED6B21" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="88.05" y1="101.69" x2="96.13" y2="98.23"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 26.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="16px" height="16px" viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<g id="shape_x5F_gallery_x5F_2">
<path fill="#808080" d="M11,6.72c0.14,0,0.25,0.11,0.25,0.25V14c0,0.14-0.11,0.25-0.25,0.25H2c-0.14,0-0.25-0.11-0.25-0.25V6.97
c0-0.14,0.11-0.25,0.25-0.25H11 M11,5.97H2c-0.55,0-1,0.45-1,1V14c0,0.55,0.45,1,1,1h9c0.55,0,1-0.45,1-1V6.97
C12,6.42,11.55,5.97,11,5.97L11,5.97z"/>
<path fill="#808080" d="M14,2H5C4.45,2,4,2.45,4,3v1h0.75V3c0-0.14,0.11-0.25,0.25-0.25h9c0.14,0,0.25,0.11,0.25,0.25v8
c0,0.14-0.11,0.25-0.25,0.25h-0.5V12H14c0.55,0,1-0.45,1-1V3C15,2.45,14.55,2,14,2z"/>
<path fill="#808080" d="M12.5,4h-9c-0.55,0-1,0.45-1,1v0.97h0.75V5c0-0.14,0.11-0.25,0.25-0.25h9c0.14,0,0.25,0.11,0.25,0.25v7.5
c0,0.14-0.11,0.25-0.25,0.25H12v0.75h0.5c0.55,0,1-0.45,1-1V5C13.5,4.45,13.05,4,12.5,4z"/>
<path fill="#ED6B21" d="M9.07,11.7V9.3c0-0.18-0.1-0.34-0.25-0.43l-2.07-1.2c-0.15-0.09-0.35-0.09-0.5,0l-2.07,1.2
C4.02,8.96,3.93,9.13,3.93,9.3v2.39c0,0.18,0.1,0.34,0.25,0.43l2.07,1.2c0.15,0.09,0.35,0.09,0.5,0l2.07-1.2
C8.98,12.04,9.07,11.87,9.07,11.7z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 26.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="16px" height="16px" viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<g id="sinking">
<g>
<path fill="#808080" d="M15,10.5H1c-0.28,0-0.5-0.22-0.5-0.5S0.72,9.5,1,9.5h14c0.28,0,0.5,0.22,0.5,0.5S15.28,10.5,15,10.5z"/>
</g>
<g>
<path fill="#808080" d="M14.78,5.47L5.97,1.05C5.88,1.01,5.78,1,5.69,1.03c-0.09,0.03-0.17,0.1-0.22,0.19L2.15,7.83
C2.09,7.95,2.1,8.09,2.17,8.2c0.07,0.11,0.19,0.18,0.32,0.18h11.02c0.14,0,0.27-0.08,0.33-0.21l1.1-2.19
C15.04,5.79,14.97,5.56,14.78,5.47z"/>
<path fill="#ED6B21" d="M11.82,11.8c-0.07-0.11-0.19-0.18-0.32-0.18H4.99c-0.17,0-0.32,0.12-0.36,0.29
c-0.04,0.17,0.04,0.34,0.2,0.42l5.21,2.61c0.05,0.03,0.11,0.04,0.17,0.04c0.04,0,0.08-0.01,0.12-0.02
c0.09-0.03,0.17-0.1,0.22-0.19l1.31-2.61C11.9,12.05,11.89,11.91,11.82,11.8z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -89,6 +89,7 @@ src/libslic3r/Flow.cpp
src/libslic3r/Format/3mf.cpp
src/libslic3r/Format/AMF.cpp
src/libslic3r/miniz_extension.cpp
src/libslic3r/PostProcessor.cpp
src/libslic3r/Preset.cpp
src/libslic3r/Print.cpp
src/libslic3r/SLA/Pad.cpp

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,5 @@
min_slic3r_version = 2.4.0-beta2
1.4.0-beta3 Added material profiles for Prusament Resins.
1.4.0-beta2 Added SLA material colors. Updated BASF filament profiles.
min_slic3r_version = 2.4.0-beta0
1.4.0-beta1 Updated pad wall slope angle for SLA printers. Updated Filatech Filacarbon profile for Prusa MINI.
@ -17,6 +18,8 @@ min_slic3r_version = 2.4.0-alpha0
1.3.0-alpha1 Added Prusament PCCF. Increased travel acceleration for Prusa MINI. Updated start g-code for Prusa MINI. Added multiple add:north and Extrudr filament profiles. Updated Z travel speed values.
1.3.0-alpha0 Disabled thick bridges, updated support settings.
min_slic3r_version = 2.3.2-alpha0
1.3.5 Added material profiles for Prusament Resins.
1.3.4 Added material profiles for new Prusament Resins. Added profiles for multiple BASF filaments.
1.3.3 Added multiple profiles for Filatech filaments. Added material profiles for SL1S SPEED. Updated SLA print settings.
1.3.2 Added material profiles for Prusament Resin.
1.3.1 Added multiple add:north and Extrudr filament profiles. Updated support head settings (SL1S).

View File

@ -5,7 +5,7 @@
name = Prusa Research
# Configuration version of this file. Config file will only be installed, if the config_version differs.
# This means, the server may force the PrusaSlicer configuration to be downgraded.
config_version = 1.4.0-beta2
config_version = 1.4.0-beta3
# Where to get the updates from?
config_update_url = https://files.prusa3d.com/wp-content/uploads/repository/PrusaSlicer-settings-master/live/PrusaResearch/
changelog_url = https://files.prusa3d.com/?latest=slicer-profiles&lng=%1%
@ -2925,7 +2925,6 @@ bridge_fan_speed = 100
filament_type = PET
disable_fan_first_layers = 1
full_fan_speed_layer = 3
filament_notes = "BASF Forward AM Ultrafuse PET\nMaterial profile version 1.0\n\nMaterial Description\nUltrafuse PET is made from a premium PET and prints as easy as PLA, but is much stronger. The filament has a large operating window for printing (temperature vs. speed), so it can be used on every 3D-printer. PET will give you outstanding printing results: a good layer adhesion, a high resolution and it is easy to handle. Ultrafuse PET can be 100% recycled, is watertight and has great colors and finish.\n\nPrinting Recommendations:\nUltrafuse PET can be printed directly onto a clean build plate. For challenging prints, use 3dLac to improve adhesion.\n"
filament_retract_length = 2
filament_retract_speed = 40
@ -4835,7 +4834,47 @@ initial_exposure_time = 35
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #808080
[sla_material:Prusament Resin Tough Sandstone Model @0.025]
inherits = *common 0.025*
exposure_time = 4
initial_exposure_time = 35
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #F7D190
[sla_material:Prusament Resin Tough Terra Brown @0.025]
inherits = *common 0.025*
exposure_time = 4
initial_exposure_time = 35
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #7A5C45
[sla_material:Prusament Resin Tough Brick Red @0.025]
inherits = *common 0.025*
exposure_time = 4
initial_exposure_time = 35
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #B46056
[sla_material:Prusament Resin Tough Grass Green @0.025]
inherits = *common 0.025*
exposure_time = 4
initial_exposure_time = 35
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #37823F
[sla_material:Prusament Resin Tough Bright Yellow @0.025]
inherits = *common 0.025*
exposure_time = 4
initial_exposure_time = 35
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #F9DB4C
## Prusa 0.025
[sla_material:Prusa Orange Tough @0.025]
@ -5649,6 +5688,46 @@ material_type = Tough
material_vendor = Prusa Polymers
material_colour = #C0C0C0
[sla_material:Prusament Resin Tough Sandstone Model @0.05]
inherits = *common 0.05*
exposure_time = 6
initial_exposure_time = 35
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #F7D190
[sla_material:Prusament Resin Tough Terra Brown @0.05]
inherits = *common 0.05*
exposure_time = 6
initial_exposure_time = 35
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #7A5C45
[sla_material:Prusament Resin Tough Brick Red @0.05]
inherits = *common 0.05*
exposure_time = 6
initial_exposure_time = 35
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #B46056
[sla_material:Prusament Resin Tough Grass Green @0.05]
inherits = *common 0.05*
exposure_time = 6
initial_exposure_time = 35
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #37823F
[sla_material:Prusament Resin Tough Bright Yellow @0.05]
inherits = *common 0.05*
exposure_time = 6
initial_exposure_time = 35
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #F9DB4C
## Prusa 0.05
[sla_material:Prusa Beige Tough @0.05]
@ -5965,6 +6044,46 @@ material_type = Tough
material_vendor = Prusa Polymers
material_colour = #808080
[sla_material:Prusament Resin Tough Sandstone Model @0.1]
inherits = *common 0.1*
exposure_time = 13
initial_exposure_time = 45
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #F7D190
[sla_material:Prusament Resin Tough Terra Brown @0.1]
inherits = *common 0.1*
exposure_time = 13
initial_exposure_time = 45
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #7A5C45
[sla_material:Prusament Resin Tough Brick Red @0.1]
inherits = *common 0.1*
exposure_time = 13
initial_exposure_time = 45
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #B46056
[sla_material:Prusament Resin Tough Grass Green @0.1]
inherits = *common 0.1*
exposure_time = 13
initial_exposure_time = 45
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #37823F
[sla_material:Prusament Resin Tough Bright Yellow @0.1]
inherits = *common 0.1*
exposure_time = 13
initial_exposure_time = 45
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #F9DB4C
## Prusa 0.1
[sla_material:Prusa Orange Tough @0.1]
@ -6085,6 +6204,46 @@ material_type = Tough
material_vendor = Prusa Polymers
material_colour = #808080
[sla_material:Prusament Resin Tough Sandstone Model @0.025 SL1S]
inherits = *0.025_sl1s*
exposure_time = 2
initial_exposure_time = 25
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #F7D190
[sla_material:Prusament Resin Tough Terra Brown @0.025 SL1S]
inherits = *0.025_sl1s*
exposure_time = 1.8
initial_exposure_time = 25
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #7A5C45
[sla_material:Prusament Resin Tough Brick Red @0.025 SL1S]
inherits = *0.025_sl1s*
exposure_time = 1.8
initial_exposure_time = 25
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #B46056
[sla_material:Prusament Resin Tough Grass Green @0.025 SL1S]
inherits = *0.025_sl1s*
exposure_time = 1.8
initial_exposure_time = 25
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #37823F
[sla_material:Prusament Resin Tough Bright Yellow @0.025 SL1S]
inherits = *0.025_sl1s*
exposure_time = 1.8
initial_exposure_time = 25
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #F9DB4C
## Made for Prusa 0.025
[sla_material:Prusa Orange Tough @0.025 SL1S]
@ -6331,6 +6490,46 @@ material_type = Tough
material_vendor = Prusa Polymers
material_colour = #808080
[sla_material:Prusament Resin Tough Sandstone Model @0.05 SL1S]
inherits = *0.05_sl1s*
exposure_time = 2.4
initial_exposure_time = 25
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #F7D190
[sla_material:Prusament Resin Tough Terra Brown @0.05 SL1S]
inherits = *0.05_sl1s*
exposure_time = 2
initial_exposure_time = 25
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #7A5C45
[sla_material:Prusament Resin Tough Brick Red @0.05 SL1S]
inherits = *0.05_sl1s*
exposure_time = 2
initial_exposure_time = 25
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #B46056
[sla_material:Prusament Resin Tough Grass Green @0.05 SL1S]
inherits = *0.05_sl1s*
exposure_time = 2
initial_exposure_time = 25
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #37823F
[sla_material:Prusament Resin Tough Bright Yellow @0.05 SL1S]
inherits = *0.05_sl1s*
exposure_time = 2
initial_exposure_time = 25
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #F9DB4C
## Made for Prusa 0.05
[sla_material:Prusa Orange Tough @0.05 SL1S]
@ -6577,6 +6776,46 @@ material_type = Tough
material_vendor = Prusa Polymers
material_colour = #808080
[sla_material:Prusament Resin Tough Sandstone Model @0.1 SL1S]
inherits = *0.1_sl1s*
exposure_time = 3
initial_exposure_time = 25
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #F7D190
[sla_material:Prusament Resin Tough Terra Brown @0.1 SL1S]
inherits = *0.1_sl1s*
exposure_time = 2.6
initial_exposure_time = 25
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #7A5C45
[sla_material:Prusament Resin Tough Brick Red @0.1 SL1S]
inherits = *0.1_sl1s*
exposure_time = 2.6
initial_exposure_time = 25
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #B46056
[sla_material:Prusament Resin Tough Grass Green @0.1 SL1S]
inherits = *0.1_sl1s*
exposure_time = 2.6
initial_exposure_time = 25
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #37823F
[sla_material:Prusament Resin Tough Bright Yellow @0.1 SL1S]
inherits = *0.1_sl1s*
exposure_time = 2.6
initial_exposure_time = 25
material_type = Tough
material_vendor = Prusa Polymers
material_colour = #F9DB4C
## Made for Prusa 0.1
[sla_material:Prusa Orange Tough @0.1 SL1S]

View File

@ -1,26 +1,7 @@
#version 110
#define INTENSITY_CORRECTION 0.6
// normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
#define LIGHT_TOP_DIFFUSE (0.8 * INTENSITY_CORRECTION)
#define LIGHT_TOP_SPECULAR (0.125 * INTENSITY_CORRECTION)
#define LIGHT_TOP_SHININESS 20.0
// normalized values for (1./1.43, 0.2/1.43, 1./1.43)
const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
#define LIGHT_FRONT_DIFFUSE (0.3 * INTENSITY_CORRECTION)
#define INTENSITY_AMBIENT 0.3
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
const vec3 GREEN = vec3(0.0, 0.7, 0.0);
const vec3 YELLOW = vec3(0.5, 0.7, 0.0);
const vec3 RED = vec3(0.7, 0.0, 0.0);
const vec3 WHITE = vec3(1.0, 1.0, 1.0);
const float EPSILON = 0.0001;
const float BANDS_WIDTH = 10.0;
struct PrintVolumeDetection
{

View File

@ -595,6 +595,19 @@ int CLI::run(int argc, char **argv)
if (start_gui) {
#ifdef SLIC3R_GUI
#if !defined(_WIN32) && !defined(__APPLE__)
// likely some linux / unix system
const char *display = boost::nowide::getenv("DISPLAY");
// const char *wayland_display = boost::nowide::getenv("WAYLAND_DISPLAY");
//if (! ((display && *display) || (wayland_display && *wayland_display))) {
if (! (display && *display)) {
// DISPLAY not set.
boost::nowide::cerr << "DISPLAY not set, GUI mode not available." << std::endl << std::endl;
this->print_help(false);
// Indicate an error.
return 1;
}
#endif // some linux / unix system
Slic3r::GUI::GUI_InitParams params;
params.argc = argc;
params.argv = argv;

View File

@ -174,6 +174,9 @@ void AppConfig::set_defaults()
if (get("show_hints").empty())
set("show_hints", "1");
if (get("allow_ip_resolve").empty())
set("allow_ip_resolve", "1");
#ifdef _WIN32
if (get("use_legacy_3DConnexion").empty())
set("use_legacy_3DConnexion", "0");

View File

@ -126,7 +126,7 @@ static ConstPrintObjectPtrs get_top_level_objects_with_brim(const Print &print,
return top_level_objects_with_brim;
}
static Polygons top_level_outer_brim_islands(const ConstPrintObjectPtrs &top_level_objects_with_brim)
static Polygons top_level_outer_brim_islands(const ConstPrintObjectPtrs &top_level_objects_with_brim, const double scaled_resolution)
{
Polygons islands;
for (const PrintObject *object : top_level_objects_with_brim) {
@ -139,7 +139,7 @@ static Polygons top_level_outer_brim_islands(const ConstPrintObjectPtrs &top_lev
for (const ExPolygon &ex_poly : get_print_object_bottom_layer_expolygons(*object)) {
Polygons contour_offset = offset(ex_poly.contour, brim_separation, ClipperLib::jtSquare);
for (Polygon &poly : contour_offset)
poly.douglas_peucker(SCALED_RESOLUTION);
poly.douglas_peucker(scaled_resolution);
polygons_append(islands_object, std::move(contour_offset));
}
@ -359,13 +359,14 @@ static void make_inner_brim(const Print &print,
ExtrusionEntityCollection &brim)
{
assert(print.objects().size() == bottom_layers_expolygons.size());
const auto scaled_resolution = scaled<double>(print.config().gcode_resolution.value);
Flow flow = print.brim_flow();
ExPolygons islands_ex = inner_brim_area(print, top_level_objects_with_brim, bottom_layers_expolygons, float(flow.scaled_spacing()));
Polygons loops;
islands_ex = offset_ex(islands_ex, -0.5f * float(flow.scaled_spacing()), ClipperLib::jtSquare);
for (size_t i = 0; !islands_ex.empty(); ++i) {
for (ExPolygon &poly_ex : islands_ex)
poly_ex.douglas_peucker(SCALED_RESOLUTION);
poly_ex.douglas_peucker(scaled_resolution);
polygons_append(loops, to_polygons(islands_ex));
islands_ex = offset_ex(islands_ex, -float(flow.scaled_spacing()), ClipperLib::jtSquare);
}
@ -380,10 +381,11 @@ static void make_inner_brim(const Print &print,
// Collect islands_area to be merged into the final 1st layer convex hull.
ExtrusionEntityCollection make_brim(const Print &print, PrintTryCancel try_cancel, Polygons &islands_area)
{
const auto scaled_resolution = scaled<double>(print.config().gcode_resolution.value);
Flow flow = print.brim_flow();
std::vector<ExPolygons> bottom_layers_expolygons = get_print_bottom_layers_expolygons(print);
ConstPrintObjectPtrs top_level_objects_with_brim = get_top_level_objects_with_brim(print, bottom_layers_expolygons);
Polygons islands = top_level_outer_brim_islands(top_level_objects_with_brim);
Polygons islands = top_level_outer_brim_islands(top_level_objects_with_brim, scaled_resolution);
ExPolygons islands_area_ex = top_level_outer_brim_area(print, top_level_objects_with_brim, bottom_layers_expolygons, float(flow.scaled_spacing()));
islands_area = to_polygons(islands_area_ex);
@ -393,7 +395,7 @@ ExtrusionEntityCollection make_brim(const Print &print, PrintTryCancel try_cance
try_cancel();
islands = expand(islands, float(flow.scaled_spacing()), ClipperLib::jtSquare);
for (Polygon &poly : islands)
poly.douglas_peucker(SCALED_RESOLUTION);
poly.douglas_peucker(scaled_resolution);
polygons_append(loops, shrink(islands, 0.5f * float(flow.scaled_spacing())));
}
loops = union_pt_chained_outside_in(loops);

View File

@ -67,6 +67,16 @@ add_library(libslic3r STATIC
Fill/FillPlanePath.hpp
Fill/FillLine.cpp
Fill/FillLine.hpp
Fill/FillLightning.cpp
Fill/FillLightning.hpp
Fill/Lightning/DistanceField.cpp
Fill/Lightning/DistanceField.hpp
Fill/Lightning/Generator.cpp
Fill/Lightning/Generator.hpp
Fill/Lightning/Layer.cpp
Fill/Lightning/Layer.hpp
Fill/Lightning/TreeNode.cpp
Fill/Lightning/TreeNode.hpp
Fill/FillRectilinear.cpp
Fill/FillRectilinear.hpp
Flow.cpp
@ -288,7 +298,7 @@ set(CGAL_DO_NOT_WARN_ABOUT_CMAKE_BUILD_TYPE ON CACHE BOOL "" FORCE)
cmake_policy(PUSH)
cmake_policy(SET CMP0011 NEW)
find_package(CGAL 4.13 REQUIRED)
find_package(CGAL REQUIRED)
cmake_policy(POP)
add_library(libslic3r_cgal STATIC MeshBoolean.cpp MeshBoolean.hpp TryCatchSignal.hpp

View File

@ -329,7 +329,8 @@ void Layer::make_fills(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive:
#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */
std::vector<SurfaceFill> surface_fills = group_fills(*this);
const Slic3r::BoundingBox bbox = this->object()->bounding_box();
const Slic3r::BoundingBox bbox = this->object()->bounding_box();
const auto resolution = this->object()->print()->config().gcode_resolution.value;
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
{
@ -371,6 +372,7 @@ void Layer::make_fills(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive:
params.dont_adjust = false; // surface_fill.params.dont_adjust;
params.anchor_length = surface_fill.params.anchor_length;
params.anchor_length_max = surface_fill.params.anchor_length_max;
params.resolution = resolution;
for (ExPolygon &expoly : surface_fill.expolygons) {
// Spacing is modified by the filler to indicate adjustments. Reset it for each expolygon.
@ -537,7 +539,7 @@ void Layer::make_ironing()
fill_params.density = 1.;
fill_params.monotonic = true;
for (size_t i = 0; i < by_extruder.size(); ++ i) {
for (size_t i = 0; i < by_extruder.size();) {
// Find span of regions equivalent to the ironing operation.
IroningParams &ironing_params = by_extruder[i];
size_t j = i;
@ -587,14 +589,17 @@ void Layer::make_ironing()
polygons_append(infills, surface.expolygon);
}
}
if (! infills.empty() || j > i + 1) {
// Ironing over more than a single region or over solid internal infill.
if (! infills.empty())
// For IroningType::AllSolid only:
// Add solid infill areas for layers, that contain some non-ironable infil (sparse infill, bridge infill).
append(polys, std::move(infills));
polys = union_safety_offset(polys);
}
// Trim the top surfaces with half the nozzle diameter.
ironing_areas = intersection_ex(polys, offset(this->lslices, - float(scale_(0.5 * nozzle_dmr))));
if (! infills.empty()) {
// For IroningType::AllSolid only:
// Add solid infill areas for layers, that contain some non-ironable infil (sparse infill, bridge infill).
append(infills, to_polygons(std::move(ironing_areas)));
ironing_areas = union_safety_offset_ex(infills);
}
}
// Create the filler object.
@ -624,6 +629,9 @@ void Layer::make_ironing()
flow_mm3_per_mm, extrusion_width, float(extrusion_height));
}
}
// Regions up to j were processed.
i = j;
}
}

View File

@ -19,6 +19,7 @@
#include "FillLine.hpp"
#include "FillRectilinear.hpp"
#include "FillAdaptive.hpp"
#include "FillLightning.hpp"
// #define INFILL_DEBUG_OUTPUT
@ -45,6 +46,9 @@ Fill* Fill::new_from_type(const InfillPattern type)
case ipAdaptiveCubic: return new FillAdaptive::Filler();
case ipSupportCubic: return new FillAdaptive::Filler();
case ipSupportBase: return new FillSupportBase();
#if HAS_LIGHTNING_INFILL
case ipLightning: return new FillLightning::Filler();
#endif // HAS_LIGHTNING_INFILL
default: throw Slic3r::InvalidArgument("unknown type");
}
}

View File

@ -13,10 +13,10 @@
#include "../BoundingBox.hpp"
#include "../Exception.hpp"
#include "../Utils.hpp"
#include "../ExPolygon.hpp"
namespace Slic3r {
class ExPolygon;
class Surface;
enum InfillPattern : int;
@ -44,6 +44,9 @@ struct FillParams
float anchor_length { 1000.f };
float anchor_length_max { 1000.f };
// G-code resolution.
double resolution { 0.0125 };
// Don't adjust spacing to fill the space evenly.
bool dont_adjust { true };

View File

@ -0,0 +1,29 @@
#include "../Print.hpp"
#include "FillLightning.hpp"
#include "Lightning/Generator.hpp"
#include "../Surface.hpp"
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <numeric>
namespace Slic3r::FillLightning {
Polylines Filler::fill_surface(const Surface *surface, const FillParams &params)
{
const Layer &layer = generator->getTreesForLayer(this->layer_id);
return layer.convertToLines(to_polygons(surface->expolygon), generator->infilll_extrusion_width());
}
void GeneratorDeleter::operator()(Generator *p) {
delete p;
}
GeneratorPtr build_generator(const PrintObject &print_object)
{
return GeneratorPtr(new Generator(print_object));
}
} // namespace Slic3r::FillAdaptive

View File

@ -0,0 +1,36 @@
#ifndef slic3r_FillLightning_hpp_
#define slic3r_FillLightning_hpp_
#include "FillBase.hpp"
namespace Slic3r {
class PrintObject;
namespace FillLightning {
class Generator;
// To keep the definition of Octree opaque, we have to define a custom deleter.
struct GeneratorDeleter { void operator()(Generator *p); };
using GeneratorPtr = std::unique_ptr<Generator, GeneratorDeleter>;
GeneratorPtr build_generator(const PrintObject &print_object);
class Filler : public Slic3r::Fill
{
public:
~Filler() override = default;
Generator *generator { nullptr };
protected:
Fill* clone() const override { return new Filler(*this); }
// Perform the fill.
Polylines fill_surface(const Surface *surface, const FillParams &params) override;
// Let the G-code export reoder the infill lines.
bool no_sort() const override { return false; }
};
} // namespace FillAdaptive
} // namespace Slic3r
#endif // slic3r_FillLightning_hpp_

View File

@ -31,7 +31,8 @@ void FillPlanePath::_fill_surface_single(
coord_t(ceil(coordf_t(bounding_box.min.x()) / distance_between_lines)),
coord_t(ceil(coordf_t(bounding_box.min.y()) / distance_between_lines)),
coord_t(ceil(coordf_t(bounding_box.max.x()) / distance_between_lines)),
coord_t(ceil(coordf_t(bounding_box.max.y()) / distance_between_lines)));
coord_t(ceil(coordf_t(bounding_box.max.y()) / distance_between_lines)),
params.resolution);
if (pts.size() >= 2) {
// Convert points to a polyline, upscale.
@ -58,7 +59,7 @@ void FillPlanePath::_fill_surface_single(
}
// Follow an Archimedean spiral, in polar coordinates: r=a+b\theta
Pointfs FillArchimedeanChords::_generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y)
Pointfs FillArchimedeanChords::_generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double resolution)
{
// Radius to achieve.
coordf_t rmax = std::sqrt(coordf_t(max_x)*coordf_t(max_x)+coordf_t(max_y)*coordf_t(max_y)) * std::sqrt(2.) + 1.5;
@ -72,8 +73,8 @@ Pointfs FillArchimedeanChords::_generate(coord_t min_x, coord_t min_y, coord_t m
out.emplace_back(0, 0);
out.emplace_back(1, 0);
while (r < rmax) {
// Discretization angle to achieve a discretization error lower than RESOLUTION.
theta += 2. * acos(1. - RESOLUTION / r);
// Discretization angle to achieve a discretization error lower than resolution.
theta += 2. * acos(1. - resolution / r);
r = a + b * theta;
out.emplace_back(r * cos(theta), r * sin(theta));
}
@ -125,7 +126,7 @@ static inline Point hilbert_n_to_xy(const size_t n)
return Point(x, y);
}
Pointfs FillHilbertCurve::_generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y)
Pointfs FillHilbertCurve::_generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double /* resolution */)
{
// Minimum power of two square to fit the domain.
size_t sz = 2;
@ -148,7 +149,7 @@ Pointfs FillHilbertCurve::_generate(coord_t min_x, coord_t min_y, coord_t max_x,
return line;
}
Pointfs FillOctagramSpiral::_generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y)
Pointfs FillOctagramSpiral::_generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double /* resolution */)
{
// Radius to achieve.
coordf_t rmax = std::sqrt(coordf_t(max_x)*coordf_t(max_x)+coordf_t(max_y)*coordf_t(max_y)) * std::sqrt(2.) + 1.5;

View File

@ -28,7 +28,7 @@ protected:
float _layer_angle(size_t idx) const override { return 0.f; }
virtual bool _centered() const = 0;
virtual Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y) = 0;
virtual Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double resolution) = 0;
};
class FillArchimedeanChords : public FillPlanePath
@ -39,7 +39,7 @@ public:
protected:
bool _centered() const override { return true; }
Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y) override;
Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double resolution) override;
};
class FillHilbertCurve : public FillPlanePath
@ -50,7 +50,7 @@ public:
protected:
bool _centered() const override { return false; }
Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y) override;
Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double resolution) override;
};
class FillOctagramSpiral : public FillPlanePath
@ -61,7 +61,7 @@ public:
protected:
bool _centered() const override { return true; }
Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y) override;
Pointfs _generate(coord_t min_x, coord_t min_y, coord_t max_x, coord_t max_y, const double resolution) override;
};
} // namespace Slic3r

View File

@ -3041,5 +3041,40 @@ Polylines FillSupportBase::fill_surface(const Surface *surface, const FillParams
return polylines_out;
}
} // namespace Slic3r
Points sample_grid_pattern(const ExPolygon &expolygon, coord_t spacing)
{
ExPolygonWithOffset poly_with_offset(expolygon, 0, 0, 0);
BoundingBox bounding_box = poly_with_offset.bounding_box_src();
std::vector<SegmentedIntersectionLine> segs = slice_region_by_vertical_lines(
poly_with_offset,
(bounding_box.max.x() - bounding_box.min.x() + spacing - 1) / spacing,
bounding_box.min.x(),
spacing);
Points out;
for (const SegmentedIntersectionLine &sil : segs) {
for (size_t i = 0; i < sil.intersections.size(); i += 2) {
coord_t a = sil.intersections[i].pos();
coord_t b = sil.intersections[i + 1].pos();
for (coord_t y = a - (a % spacing) - spacing; y < b; y += spacing)
if (y > a)
out.emplace_back(sil.pos, y);
}
}
return out;
}
Points sample_grid_pattern(const ExPolygons &expolygons, coord_t spacing)
{
Points out;
for (const ExPolygon &expoly : expolygons)
append(out, sample_grid_pattern(expoly, spacing));
return out;
}
Points sample_grid_pattern(const Polygons &polygons, coord_t spacing)
{
return sample_grid_pattern(union_ex(polygons), spacing);
}
} // namespace Slic3r

View File

@ -109,6 +109,10 @@ protected:
float _layer_angle(size_t idx) const override { return 0.f; }
};
Points sample_grid_pattern(const ExPolygon &expolygon, coord_t spacing);
Points sample_grid_pattern(const ExPolygons &expolygons, coord_t spacing);
Points sample_grid_pattern(const Polygons &polygons, coord_t spacing);
} // namespace Slic3r
#endif // slic3r_FillRectilinear_hpp_

View File

@ -0,0 +1,99 @@
//Copyright (c) 2021 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
#include "DistanceField.hpp" //Class we're implementing.
#include "../FillRectilinear.hpp"
#include "../../ClipperUtils.hpp"
namespace Slic3r::FillLightning
{
constexpr coord_t radius_per_cell_size = 6; // The cell-size should be small compared to the radius, but not so small as to be inefficient.
DistanceField::DistanceField(const coord_t& radius, const Polygons& current_outline, const Polygons& current_overhang) :
m_cell_size(radius / radius_per_cell_size),
m_supporting_radius(radius)
{
m_supporting_radius2 = double(radius) * double(radius);
// Sample source polygons with a regular grid sampling pattern.
for (const ExPolygon &expoly : union_ex(current_outline)) {
for (const Point &p : sample_grid_pattern(expoly, m_cell_size)) {
// Find a squared distance to the source expolygon boundary.
double d2 = std::numeric_limits<double>::max();
for (size_t icontour = 0; icontour <= expoly.holes.size(); ++ icontour) {
const Polygon &contour = icontour == 0 ? expoly.contour : expoly.holes[icontour - 1];
if (contour.size() > 2) {
Point prev = contour.points.back();
for (const Point &p2 : contour.points) {
d2 = std::min(d2, Line::distance_to_squared(p, prev, p2));
prev = p2;
}
}
}
m_unsupported_points.emplace_back(p, sqrt(d2));
}
}
m_unsupported_points.sort([&radius](const UnsupportedCell &a, const UnsupportedCell &b) {
constexpr coord_t prime_for_hash = 191;
return std::abs(b.dist_to_boundary - a.dist_to_boundary) > radius ?
a.dist_to_boundary < b.dist_to_boundary :
(PointHash{}(a.loc) % prime_for_hash) < (PointHash{}(b.loc) % prime_for_hash);
});
for (auto it = m_unsupported_points.begin(); it != m_unsupported_points.end(); ++it) {
UnsupportedCell& cell = *it;
m_unsupported_points_grid.emplace(Point{ cell.loc.x() / m_cell_size, cell.loc.y() / m_cell_size }, it);
}
}
void DistanceField::update(const Point& to_node, const Point& added_leaf)
{
Vec2d v = (added_leaf - to_node).cast<double>();
auto l2 = v.squaredNorm();
Vec2d extent = Vec2d(-v.y(), v.x()) * m_supporting_radius / sqrt(l2);
BoundingBox grid;
{
Point diagonal(m_supporting_radius, m_supporting_radius);
Point iextent(extent.cast<coord_t>());
grid = BoundingBox(added_leaf - diagonal, added_leaf + diagonal);
grid.merge(to_node - iextent);
grid.merge(to_node + iextent);
grid.merge(added_leaf - iextent);
grid.merge(added_leaf + iextent);
grid.min /= m_cell_size;
grid.max /= m_cell_size;
}
Point grid_loc;
for (coord_t row = grid.min.y(); row <= grid.max.y(); ++ row) {
grid_loc.y() = row * m_cell_size;
for (coord_t col = grid.min.x(); col <= grid.max.y(); ++ col) {
grid_loc.x() = col * m_cell_size;
// Test inside a circle at the new leaf.
if ((grid_loc - added_leaf).cast<double>().squaredNorm() > m_supporting_radius2) {
// Not inside a circle at the end of the new leaf.
// Test inside a rotated rectangle.
Vec2d vx = (grid_loc - to_node).cast<double>();
double d = v.dot(vx);
if (d >= 0 && d <= l2) {
d = extent.dot(vx);
if (d < -1. || d > 1.)
// Not inside a rotated rectangle.
continue;
}
}
// Inside a circle at the end of the new leaf, or inside a rotated rectangle.
// Remove unsupported leafs at this grid location.
if (auto it = m_unsupported_points_grid.find(grid_loc); it != m_unsupported_points_grid.end()) {
std::list<UnsupportedCell>::iterator& list_it = it->second;
UnsupportedCell& cell = *list_it;
if ((cell.loc - added_leaf).cast<double>().squaredNorm() <= m_supporting_radius2) {
m_unsupported_points.erase(list_it);
m_unsupported_points_grid.erase(it);
}
}
}
}
}
} // namespace Slic3r::FillLightning

View File

@ -0,0 +1,100 @@
//Copyright (c) 2021 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
#ifndef LIGHTNING_DISTANCE_FIELD_H
#define LIGHTNING_DISTANCE_FIELD_H
#include "../../Point.hpp"
#include "../../Polygon.hpp"
namespace Slic3r::FillLightning
{
/*!
* 2D field that maintains locations which need to be supported for Lightning
* Infill.
*
* This field contains a set of "cells", spaced out in a grid. Each cell
* maintains how far it is removed from the edge, which is used to determine
* how it gets supported by Lightning Infill.
*/
class DistanceField
{
public:
/*!
* Construct a new field to calculate Lightning Infill with.
* \param radius The radius of influence that an infill line is expected to
* support in the layer above.
* \param current_outline The total infill area on this layer.
* \param current_overhang The overhang that needs to be supported on this
* layer.
*/
DistanceField(const coord_t& radius, const Polygons& current_outline, const Polygons& current_overhang);
/*!
* Gets the next unsupported location to be supported by a new branch.
* \param p Output variable for the next point to support.
* \return ``true`` if successful, or ``false`` if there are no more points
* to consider.
*/
bool tryGetNextPoint(Point* p) const {
if (m_unsupported_points.empty())
return false;
*p = m_unsupported_points.front().loc;
return true;
}
/*!
* Update the distance field with a newly added branch.
*
* The branch is a line extending from \p to_node to \p added_leaf . This
* function updates the grid cells so that the distance field knows how far
* off it is from being supported by the current pattern. Grid points are
* updated with sampling points spaced out by the supporting radius along
* the line.
* \param to_node The node endpoint of the newly added branch.
* \param added_leaf The location of the leaf of the newly added branch,
* drawing a straight line to the node.
*/
void update(const Point& to_node, const Point& added_leaf);
protected:
/*!
* Spacing between grid points to consider supporting.
*/
coord_t m_cell_size;
/*!
* The radius of the area of the layer above supported by a point on a
* branch of a tree.
*/
coord_t m_supporting_radius;
double m_supporting_radius2;
/*!
* Represents a small discrete area of infill that needs to be supported.
*/
struct UnsupportedCell
{
UnsupportedCell(Point loc, coord_t dist_to_boundary) : loc(loc), dist_to_boundary(dist_to_boundary) {}
// The position of the center of this cell.
Point loc;
// How far this cell is removed from the ``current_outline`` polygon, the edge of the infill area.
coord_t dist_to_boundary;
};
/*!
* Cells which still need to be supported at some point.
*/
std::list<UnsupportedCell> m_unsupported_points;
/*!
* Links the unsupported points to a grid point, so that we can quickly look
* up the cell belonging to a certain position in the grid.
*/
std::unordered_map<Point, std::list<UnsupportedCell>::iterator, PointHash> m_unsupported_points_grid;
};
} // namespace Slic3r::FillLightning
#endif //LIGHTNING_DISTANCE_FIELD_H

View File

@ -0,0 +1,127 @@
//Copyright (c) 2021 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
#include "Generator.hpp"
#include "TreeNode.hpp"
#include "../../ClipperUtils.hpp"
#include "../../Layer.hpp"
#include "../../Print.hpp"
#include "../../Surface.hpp"
/* Possible future tasks/optimizations,etc.:
* - Improve connecting heuristic to favor connecting to shorter trees
* - Change which node of a tree is the root when that would be better in reconnectRoots.
* - (For implementation in Infill classes & elsewhere): Outline offset, infill-overlap & perimeter gaps.
* - Allow for polylines, i.e. merge Tims PR about polyline fixes
* - Unit Tests?
* - Optimization: let the square grid store the closest point on boundary
* - Optimization: only compute the closest dist to / point on boundary for the outer cells and flood-fill the rest
* - Make a pass with Arachne over the output. Somehow.
* - Generate all to-be-supported points at once instead of sequentially: See branch interlocking_gen PolygonUtils::spreadDots (Or work with sparse grids.)
* - Lots of magic values ... to many to parameterize. But are they the best?
* - Move more complex computations from Generator constructor to elsewhere.
*/
namespace Slic3r::FillLightning {
Generator::Generator(const PrintObject &print_object)
{
const PrintConfig &print_config = print_object.print()->config();
const PrintObjectConfig &object_config = print_object.config();
const PrintRegionConfig &region_config = print_object.shared_regions()->all_regions.front()->config();
const std::vector<double> &nozzle_diameters = print_config.nozzle_diameter.values;
double max_nozzle_diameter = *std::max_element(nozzle_diameters.begin(), nozzle_diameters.end());
// const int infill_extruder = region_config.infill_extruder.value;
const double default_infill_extrusion_width = Flow::auto_extrusion_width(FlowRole::frInfill, float(max_nozzle_diameter));
// Note: There's not going to be a layer below the first one, so the 'initial layer height' doesn't have to be taken into account.
const double layer_thickness = object_config.layer_height;
m_infill_extrusion_width = scaled<float>(region_config.infill_extrusion_width.percent ? default_infill_extrusion_width * 0.01 * region_config.infill_extrusion_width : region_config.infill_extrusion_width);
m_supporting_radius = scaled<coord_t>(m_infill_extrusion_width * 0.001 / region_config.fill_density);
const double lightning_infill_overhang_angle = M_PI / 4; // 45 degrees
const double lightning_infill_prune_angle = M_PI / 4; // 45 degrees
const double lightning_infill_straightening_angle = M_PI / 4; // 45 degrees
m_wall_supporting_radius = layer_thickness * std::tan(lightning_infill_overhang_angle);
m_prune_length = layer_thickness * std::tan(lightning_infill_prune_angle);
m_straightening_max_distance = layer_thickness * std::tan(lightning_infill_straightening_angle);
generateInitialInternalOverhangs(print_object);
generateTrees(print_object);
}
void Generator::generateInitialInternalOverhangs(const PrintObject &print_object)
{
m_overhang_per_layer.resize(print_object.layers().size());
const float infill_wall_offset = - m_infill_extrusion_width;
Polygons infill_area_above;
//Iterate from top to bottom, to subtract the overhang areas above from the overhang areas on the layer below, to get only overhang in the top layer where it is overhanging.
for (int layer_nr = print_object.layers().size() - 1; layer_nr >= 0; layer_nr--) {
Polygons infill_area_here;
for (const LayerRegion* layerm : print_object.get_layer(layer_nr)->regions())
for (const Surface& surface : layerm->fill_surfaces.surfaces)
if (surface.surface_type == stInternal)
append(infill_area_here, offset(surface.expolygon, infill_wall_offset));
//Remove the part of the infill area that is already supported by the walls.
Polygons overhang = diff(offset(infill_area_here, -m_wall_supporting_radius), infill_area_above);
m_overhang_per_layer[layer_nr] = overhang;
infill_area_above = std::move(infill_area_here);
}
}
const Layer& Generator::getTreesForLayer(const size_t& layer_id) const
{
assert(layer_id < m_lightning_layers.size());
return m_lightning_layers[layer_id];
}
void Generator::generateTrees(const PrintObject &print_object)
{
m_lightning_layers.resize(print_object.layers().size());
const coord_t infill_wall_offset = - m_infill_extrusion_width;
std::vector<Polygons> infill_outlines(print_object.layers().size(), Polygons());
// For-each layer from top to bottom:
for (int layer_id = print_object.layers().size() - 1; layer_id >= 0; layer_id--)
for (const LayerRegion *layerm : print_object.get_layer(layer_id)->regions())
for (const Surface &surface : layerm->fill_surfaces.surfaces)
if (surface.surface_type == stInternal)
append(infill_outlines[layer_id], offset(surface.expolygon, infill_wall_offset));
// For various operations its beneficial to quickly locate nearby features on the polygon:
const size_t top_layer_id = print_object.layers().size() - 1;
EdgeGrid::Grid outlines_locator(get_extents(infill_outlines[top_layer_id]).inflated(SCALED_EPSILON));
outlines_locator.create(infill_outlines[top_layer_id], locator_cell_size);
// For-each layer from top to bottom:
for (int layer_id = top_layer_id; layer_id >= 0; layer_id--)
{
Layer& current_lightning_layer = m_lightning_layers[layer_id];
Polygons& current_outlines = infill_outlines[layer_id];
// register all trees propagated from the previous layer as to-be-reconnected
std::vector<NodeSPtr> to_be_reconnected_tree_roots = current_lightning_layer.tree_roots;
current_lightning_layer.generateNewTrees(m_overhang_per_layer[layer_id], current_outlines, outlines_locator, m_supporting_radius, m_wall_supporting_radius);
current_lightning_layer.reconnectRoots(to_be_reconnected_tree_roots, current_outlines, outlines_locator, m_supporting_radius, m_wall_supporting_radius);
// Initialize trees for next lower layer from the current one.
if (layer_id == 0)
return;
const Polygons& below_outlines = infill_outlines[layer_id - 1];
outlines_locator.set_bbox(get_extents(below_outlines).inflated(SCALED_EPSILON));
outlines_locator.create(below_outlines, locator_cell_size);
std::vector<NodeSPtr>& lower_trees = m_lightning_layers[layer_id - 1].tree_roots;
for (auto& tree : current_lightning_layer.tree_roots)
tree->propagateToNextLayer(lower_trees, below_outlines, outlines_locator, m_prune_length, m_straightening_max_distance, locator_cell_size / 2);
}
}
} // namespace Slic3r::FillLightning

View File

@ -0,0 +1,132 @@
//Copyright (c) 2021 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
#ifndef LIGHTNING_GENERATOR_H
#define LIGHTNING_GENERATOR_H
#include "Layer.hpp"
#include <functional>
#include <memory>
#include <vector>
namespace Slic3r
{
class PrintObject;
namespace FillLightning
{
/*!
* Generates the Lightning Infill pattern.
*
* The lightning infill pattern is designed to use a minimal amount of material
* to support the top skin of the print, while still printing with reasonably
* consistently flowing lines. It sacrifices strength completely in favour of
* top surface quality and reduced print time / material usage.
*
* Lightning Infill is so named because the patterns it creates resemble a
* forked path with one main path and many small lines on the side. These paths
* grow out from the sides of the model just below where the top surface needs
* to be supported from the inside, so that minimal material is needed.
*
* This pattern is based on a paper called "Ribbed Support Vaults for 3D
* Printing of Hollowed Objects" by Tricard, Claux and Lefebvre:
* https://www.researchgate.net/publication/333808588_Ribbed_Support_Vaults_for_3D_Printing_of_Hollowed_Objects
*/
class Generator // "Just like Nicola used to make!"
{
public:
/*!
* Create a generator to fill a certain mesh with infill.
*
* This generator will pre-compute things in preparation of generating
* Lightning Infill for the infill areas in that mesh. The infill areas must
* already be calculated at this point.
* \param mesh The mesh to generate infill for.
*/
Generator(const PrintObject &print_object);
/*!
* Get a tree of paths generated for a certain layer of the mesh.
*
* This tree represents the paths that must be traced to print the infill.
* \param layer_id The layer number to get the path tree for. This is within
* the range of layers of the mesh (not the global layer numbers).
* \return A tree structure representing paths to print to create the
* Lightning Infill pattern.
*/
const Layer& getTreesForLayer(const size_t& layer_id) const;
float infilll_extrusion_width() const { return m_infill_extrusion_width; }
protected:
/*!
* Calculate the overhangs above the infill areas that need to be supported
* by infill.
*
* Normally, overhangs are only generated for the outside of the model and
* only when support is generated. For this pattern, we also need to
* generate overhang areas for the inside of the model.
*/
void generateInitialInternalOverhangs(const PrintObject &print_object);
/*!
* Calculate the tree structure of all layers.
*/
void generateTrees(const PrintObject &print_object);
float m_infill_extrusion_width;
/*!
* How far each piece of infill can support skin in the layer above.
*/
coord_t m_supporting_radius;
/*!
* How far a wall can support the wall above it. If a wall completely
* supports the wall above it, no infill needs to support that.
*
* This is similar to the overhang distance calculated for support. It is
* determined by the lightning_infill_overhang_angle setting.
*/
coord_t m_wall_supporting_radius;
/*!
* How far each piece of infill can support other infill in the layer above.
*
* This may be different than \ref supporting_radius, because the infill is
* printed with one end floating in mid-air. This endpoint will sag more, so
* an infill line may need to be supported more than a skin line.
*/
coord_t m_prune_length;
/*!
* How far a line may be shifted in order to straighten the line out.
*
* Straightening the line reduces material and time usage and reduces
* accelerations needed to print the pattern. However it makes the infill
* weak if lines are partially suspended next to the line on the previous
* layer.
*/
coord_t m_straightening_max_distance;
/*!
* For each layer, the overhang that needs to be supported by the pattern.
*
* This is generated by \ref generateInitialInternalOverhangs.
*/
std::vector<Polygons> m_overhang_per_layer;
/*!
* For each layer, the generated lightning paths.
*
* This is generated by \ref generateTrees.
*/
std::vector<Layer> m_lightning_layers;
};
} // namespace FillLightning
} // namespace Slic3r
#endif // LIGHTNING_GENERATOR_H

View File

@ -0,0 +1,410 @@
//Copyright (c) 2021 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
#include "Layer.hpp" //The class we're implementing.
#include <iterator> // advance
#include "DistanceField.hpp"
#include "TreeNode.hpp"
#include "../../Geometry.hpp"
namespace Slic3r::FillLightning {
coord_t Layer::getWeightedDistance(const Point& boundary_loc, const Point& unsupported_location)
{
return coord_t((boundary_loc - unsupported_location).cast<double>().norm());
}
Point GroundingLocation::p() const
{
assert(tree_node || boundary_location);
return tree_node ? tree_node->getLocation() : *boundary_location;
}
void Layer::fillLocator(SparseNodeGrid &tree_node_locator)
{
std::function<void(NodeSPtr)> add_node_to_locator_func = [&tree_node_locator](NodeSPtr node) {
tree_node_locator.insert(std::make_pair(Point(node->getLocation().x() / locator_cell_size, node->getLocation().y() / locator_cell_size), node));
};
for (auto& tree : tree_roots)
tree->visitNodes(add_node_to_locator_func);
}
void Layer::generateNewTrees
(
const Polygons& current_overhang,
const Polygons& current_outlines,
const EdgeGrid::Grid& outlines_locator,
const coord_t supporting_radius,
const coord_t wall_supporting_radius
)
{
DistanceField distance_field(supporting_radius, current_outlines, current_overhang);
SparseNodeGrid tree_node_locator;
fillLocator(tree_node_locator);
// Until no more points need to be added to support all:
// Determine next point from tree/outline areas via distance-field
Point unsupported_location;
while (distance_field.tryGetNextPoint(&unsupported_location)) {
GroundingLocation grounding_loc = getBestGroundingLocation(
unsupported_location, current_outlines, outlines_locator, supporting_radius, wall_supporting_radius, tree_node_locator);
NodeSPtr new_parent;
NodeSPtr new_child;
this->attach(unsupported_location, grounding_loc, new_child, new_parent);
tree_node_locator.insert(std::make_pair(Point(new_child->getLocation().x() / locator_cell_size, new_child->getLocation().y() / locator_cell_size), new_child));
if (new_parent)
tree_node_locator.insert(std::make_pair(Point(new_parent->getLocation().x() / locator_cell_size, new_parent->getLocation().y() / locator_cell_size), new_parent));
// update distance field
distance_field.update(grounding_loc.p(), unsupported_location);
}
}
static bool polygonCollidesWithLineSegment(const Point from, const Point to, const EdgeGrid::Grid &loc_to_line)
{
struct Visitor {
explicit Visitor(const EdgeGrid::Grid &grid) : grid(grid) {}
bool operator()(coord_t iy, coord_t ix) {
// Called with a row and colum of the grid cell, which is intersected by a line.
auto cell_data_range = grid.cell_data_range(iy, ix);
for (auto it_contour_and_segment = cell_data_range.first; it_contour_and_segment != cell_data_range.second; ++ it_contour_and_segment) {
// End points of the line segment and their vector.
auto segment = grid.segment(*it_contour_and_segment);
if (Geometry::segments_intersect(segment.first, segment.second, line.a, line.b)) {
this->intersect = true;
return false;
}
}
// Continue traversing the grid along the edge.
return true;
}
const EdgeGrid::Grid& grid;
Line line;
bool intersect = false;
} visitor(loc_to_line);
loc_to_line.visit_cells_intersecting_line(from, to, visitor);
return visitor.intersect;
}
GroundingLocation Layer::getBestGroundingLocation
(
const Point& unsupported_location,
const Polygons& current_outlines,
const EdgeGrid::Grid& outline_locator,
const coord_t supporting_radius,
const coord_t wall_supporting_radius,
const SparseNodeGrid& tree_node_locator,
const NodeSPtr& exclude_tree
)
{
// Closest point on current_outlines to unsupported_location:
Point node_location;
{
double d2 = std::numeric_limits<double>::max();
for (const Polygon &contour : current_outlines)
if (contour.size() > 2) {
Point prev = contour.points.back();
for (const Point &p2 : contour.points) {
if (double d = Line::distance_to_squared(unsupported_location, prev, p2); d < d2) {
d2 = d;
node_location = Geometry::foot_pt({ prev, p2 }, unsupported_location).cast<coord_t>();
}
prev = p2;
}
}
}
const auto within_dist = coord_t((node_location - unsupported_location).cast<double>().norm());
NodeSPtr sub_tree{ nullptr };
coord_t current_dist = getWeightedDistance(node_location, unsupported_location);
if (current_dist >= wall_supporting_radius) { // Only reconnect tree roots to other trees if they are not already close to the outlines.
const coord_t search_radius = std::min(current_dist, within_dist);
BoundingBox region(unsupported_location - Point(search_radius, search_radius), unsupported_location + Point(search_radius + locator_cell_size, search_radius + locator_cell_size));
region.min /= locator_cell_size;
region.max /= locator_cell_size;
Point grid_addr;
for (grid_addr.y() = region.min.y(); grid_addr.y() < region.max.y(); ++ grid_addr.y())
for (grid_addr.x() = region.min.x(); grid_addr.x() < region.max.x(); ++ grid_addr.x()) {
auto it_range = tree_node_locator.equal_range(grid_addr);
for (auto it = it_range.first; it != it_range.second; ++ it) {
auto candidate_sub_tree = it->second.lock();
if ((candidate_sub_tree && candidate_sub_tree != exclude_tree) &&
!(exclude_tree && exclude_tree->hasOffspring(candidate_sub_tree)) &&
!polygonCollidesWithLineSegment(unsupported_location, candidate_sub_tree->getLocation(), outline_locator)) {
const coord_t candidate_dist = candidate_sub_tree->getWeightedDistance(unsupported_location, supporting_radius);
if (candidate_dist < current_dist) {
current_dist = candidate_dist;
sub_tree = candidate_sub_tree;
}
}
}
}
}
return ! sub_tree ?
GroundingLocation{ nullptr, node_location } :
GroundingLocation{ sub_tree, std::optional<Point>() };
}
bool Layer::attach(
const Point& unsupported_location,
const GroundingLocation& grounding_loc,
NodeSPtr& new_child,
NodeSPtr& new_root)
{
// Update trees & distance fields.
if (grounding_loc.boundary_location) {
new_root = Node::create(grounding_loc.p(), std::make_optional(grounding_loc.p()));
new_child = new_root->addChild(unsupported_location);
tree_roots.push_back(new_root);
return true;
} else {
new_child = grounding_loc.tree_node->addChild(unsupported_location);
return false;
}
}
void Layer::reconnectRoots
(
std::vector<NodeSPtr>& to_be_reconnected_tree_roots,
const Polygons& current_outlines,
const EdgeGrid::Grid& outline_locator,
const coord_t supporting_radius,
const coord_t wall_supporting_radius
)
{
constexpr coord_t tree_connecting_ignore_offset = 100;
SparseNodeGrid tree_node_locator;
fillLocator(tree_node_locator);
const coord_t within_max_dist = outline_locator.resolution() * 2;
for (auto root_ptr : to_be_reconnected_tree_roots)
{
auto old_root_it = std::find(tree_roots.begin(), tree_roots.end(), root_ptr);
if (root_ptr->getLastGroundingLocation())
{
const Point& ground_loc = *root_ptr->getLastGroundingLocation();
if (ground_loc != root_ptr->getLocation())
{
Point new_root_pt;
// Find an intersection of the line segment from root_ptr->getLocation() to ground_loc, at within_max_dist from ground_loc.
if (lineSegmentPolygonsIntersection(root_ptr->getLocation(), ground_loc, outline_locator, new_root_pt, within_max_dist)) {
auto new_root = Node::create(new_root_pt, new_root_pt);
root_ptr->addChild(new_root);
new_root->reroot();
tree_node_locator.insert(std::make_pair(Point(new_root->getLocation().x() / locator_cell_size, new_root->getLocation().y() / locator_cell_size), new_root));
*old_root_it = std::move(new_root); // replace old root with new root
continue;
}
}
}
const coord_t tree_connecting_ignore_width = wall_supporting_radius - tree_connecting_ignore_offset; // Ideally, the boundary size in which the valence rule is ignored would be configurable.
GroundingLocation ground =
getBestGroundingLocation
(
root_ptr->getLocation(),
current_outlines,
outline_locator,
supporting_radius,
tree_connecting_ignore_width,
tree_node_locator,
root_ptr
);
if (ground.boundary_location)
{
if (*ground.boundary_location == root_ptr->getLocation())
continue; // Already on the boundary.
auto new_root = Node::create(ground.p(), ground.p());
auto attach_ptr = root_ptr->closestNode(new_root->getLocation());
attach_ptr->reroot();
new_root->addChild(attach_ptr);
tree_node_locator.insert(std::make_pair(new_root->getLocation(), new_root));
*old_root_it = std::move(new_root); // replace old root with new root
}
else
{
assert(ground.tree_node);
assert(ground.tree_node != root_ptr);
assert(!root_ptr->hasOffspring(ground.tree_node));
assert(!ground.tree_node->hasOffspring(root_ptr));
auto attach_ptr = root_ptr->closestNode(ground.tree_node->getLocation());
attach_ptr->reroot();
ground.tree_node->addChild(attach_ptr);
// remove old root
*old_root_it = std::move(tree_roots.back());
tree_roots.pop_back();
}
}
}
/*
* Implementation assumes moving inside, but moving outside should just as well be possible.
*/
static unsigned int moveInside(const Polygons& polygons, Point& from, int distance, int64_t maxDist2)
{
Point ret = from;
int64_t bestDist2 = std::numeric_limits<int64_t>::max();
unsigned int bestPoly = static_cast<unsigned int>(-1);
bool is_already_on_correct_side_of_boundary = false; // whether [from] is already on the right side of the boundary
for (unsigned int poly_idx = 0; poly_idx < polygons.size(); poly_idx++)
{
const Polygon &poly = polygons[poly_idx];
if (poly.size() < 2)
continue;
Point p0 = poly[poly.size() - 2];
Point p1 = poly.back();
// because we compare with vSize2 here (no division by zero), we also need to compare by vSize2 inside the loop
// to avoid integer rounding edge cases
bool projected_p_beyond_prev_segment = (p1 - p0).cast<int64_t>().dot((from - p0).cast<int64_t>()) >= (p1 - p0).cast<int64_t>().squaredNorm();
for (const Point& p2 : poly)
{
// X = A + Normal(B-A) * (((B-A) dot (P-A)) / VSize(B-A));
// = A + (B-A) * ((B-A) dot (P-A)) / VSize2(B-A);
// X = P projected on AB
const Point& a = p1;
const Point& b = p2;
const Point& p = from;
Point ab = b - a;
Point ap = p - a;
int64_t ab_length2 = ab.cast<int64_t>().squaredNorm();
if (ab_length2 <= 0) //A = B, i.e. the input polygon had two adjacent points on top of each other.
{
p1 = p2; //Skip only one of the points.
continue;
}
int64_t dot_prod = ab.cast<int64_t>().dot(ap.cast<int64_t>());
if (dot_prod <= 0) // x is projected to before ab
{
if (projected_p_beyond_prev_segment)
{ // case which looks like: > .
projected_p_beyond_prev_segment = false;
Point& x = p1;
int64_t dist2 = (x - p).cast<int64_t>().squaredNorm();
if (dist2 < bestDist2)
{
bestDist2 = dist2;
bestPoly = poly_idx;
if (distance == 0) {
ret = x;
} else {
// inward direction irrespective of sign of [distance]
Point inward_dir = perp((ab.cast<double>().normalized() * scaled<double>(10.0) + (p1 - p0).cast<double>().normalized() * scaled<double>(10.0)).eval()).cast<coord_t>();
// MM2INT(10.0) to retain precision for the eventual normalization
ret = x + (inward_dir.cast<double>().normalized() * distance).cast<coord_t>();
is_already_on_correct_side_of_boundary = inward_dir.cast<int64_t>().dot((p - x).cast<int64_t>()) * distance >= 0;
}
}
}
else
{
projected_p_beyond_prev_segment = false;
p0 = p1;
p1 = p2;
continue;
}
}
else if (dot_prod >= ab_length2) // x is projected to beyond ab
{
projected_p_beyond_prev_segment = true;
p0 = p1;
p1 = p2;
continue;
}
else
{ // x is projected to a point properly on the line segment (not onto a vertex). The case which looks like | .
projected_p_beyond_prev_segment = false;
Point x = a + ab * dot_prod / ab_length2;
int64_t dist2 = (p - x).cast<int64_t>().squaredNorm();
if (dist2 < bestDist2)
{
bestDist2 = dist2;
bestPoly = poly_idx;
if (distance == 0) { ret = x; }
else
{
// inward or outward depending on the sign of [distance]
Vec2d inward_dir = perp((ab.cast<double>().normalized() * distance).eval());
ret = x + inward_dir.cast<coord_t>();
is_already_on_correct_side_of_boundary = inward_dir.dot((p - x).cast<double>()) >= 0;
}
}
}
p0 = p1;
p1 = p2;
}
}
if (is_already_on_correct_side_of_boundary) // when the best point is already inside and we're moving inside, or when the best point is already outside and we're moving outside
{
if (bestDist2 < distance * distance)
{
from = ret;
}
else
{
// from = from; // original point stays unaltered. It is already inside by enough distance
}
return bestPoly;
}
else if (bestDist2 < maxDist2)
{
from = ret;
return bestPoly;
}
return static_cast<unsigned int>(-1);
}
// Returns 'added someting'.
Polylines Layer::convertToLines(const Polygons& limit_to_outline, const coord_t line_width) const
{
if (tree_roots.empty())
return {};
Polygons result_lines;
for (const auto& tree : tree_roots) {
// If even the furthest location in the tree is inside the polygon, the entire tree must be inside of the polygon.
// (Don't take the root as that may be on the edge and cause rounding errors to register as 'outside'.)
constexpr coord_t epsilon = 5;
Point should_be_inside = tree->getLocation();
moveInside(limit_to_outline, should_be_inside, epsilon, epsilon * epsilon);
if (inside(limit_to_outline, should_be_inside))
tree->convertToPolylines(result_lines, line_width);
}
// TODO: allow for polylines!
Polylines split_lines;
for (Polygon &line : result_lines) {
if (line.size() <= 1)
continue;
Point last = line[0];
for (size_t point_idx = 1; point_idx < line.size(); point_idx++) {
Point here = line[point_idx];
split_lines.push_back({ last, here });
last = here;
}
}
return split_lines;
}
} // namespace Slic3r::Lightning

View File

@ -0,0 +1,88 @@
//Copyright (c) 2021 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
#ifndef LIGHTNING_LAYER_H
#define LIGHTNING_LAYER_H
#include "../../EdgeGrid.hpp"
#include "../../Polygon.hpp"
#include <memory>
#include <vector>
#include <list>
#include <unordered_map>
#include <optional>
namespace Slic3r::FillLightning
{
class Node;
using NodeSPtr = std::shared_ptr<Node>;
using SparseNodeGrid = std::unordered_multimap<Point, std::weak_ptr<Node>, PointHash>;
struct GroundingLocation
{
NodeSPtr tree_node; //!< not null if the gounding location is on a tree
std::optional<Point> boundary_location; //!< in case the gounding location is on the boundary
Point p() const;
};
/*!
* A layer of the lightning fill.
*
* Contains the trees to be printed and propagated to the next layer below.
*/
class Layer
{
public:
std::vector<NodeSPtr> tree_roots;
void generateNewTrees
(
const Polygons& current_overhang,
const Polygons& current_outlines,
const EdgeGrid::Grid& outline_locator,
const coord_t supporting_radius,
const coord_t wall_supporting_radius
);
/*! Determine & connect to connection point in tree/outline.
* \param min_dist_from_boundary_for_tree If the unsupported point is closer to the boundary than this then don't consider connecting it to a tree
*/
GroundingLocation getBestGroundingLocation
(
const Point& unsupported_location,
const Polygons& current_outlines,
const EdgeGrid::Grid& outline_locator,
const coord_t supporting_radius,
const coord_t wall_supporting_radius,
const SparseNodeGrid& tree_node_locator,
const NodeSPtr& exclude_tree = nullptr
);
/*!
* \param[out] new_child The new child node introduced
* \param[out] new_root The new root node if one had been made
* \return Whether a new root was added
*/
bool attach(const Point& unsupported_location, const GroundingLocation& ground, NodeSPtr& new_child, NodeSPtr& new_root);
void reconnectRoots
(
std::vector<NodeSPtr>& to_be_reconnected_tree_roots,
const Polygons& current_outlines,
const EdgeGrid::Grid& outline_locator,
const coord_t supporting_radius,
const coord_t wall_supporting_radius
);
Polylines convertToLines(const Polygons& limit_to_outline, const coord_t line_width) const;
coord_t getWeightedDistance(const Point& boundary_loc, const Point& unsupported_location);
void fillLocator(SparseNodeGrid& tree_node_locator);
};
} // namespace Slic3r::FillLightning
#endif // LIGHTNING_LAYER_H

View File

@ -0,0 +1,411 @@
//Copyright (c) 2021 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
#include "TreeNode.hpp"
#include "../../Geometry.hpp"
#include "../../ClipperUtils.hpp"
namespace Slic3r::FillLightning {
coord_t Node::getWeightedDistance(const Point& unsupported_location, const coord_t& supporting_radius) const
{
constexpr coord_t min_valence_for_boost = 0;
constexpr coord_t max_valence_for_boost = 4;
constexpr coord_t valence_boost_multiplier = 4;
const size_t valence = (!m_is_root) + m_children.size();
const coord_t valence_boost = (min_valence_for_boost < valence && valence < max_valence_for_boost) ? valence_boost_multiplier * supporting_radius : 0;
const auto dist_here = coord_t((getLocation() - unsupported_location).cast<double>().norm());
return dist_here - valence_boost;
}
bool Node::hasOffspring(const NodeSPtr& to_be_checked) const
{
if (to_be_checked == shared_from_this())
return true;
for (auto& child_ptr : m_children)
if (child_ptr->hasOffspring(to_be_checked))
return true;
return false;
}
NodeSPtr Node::addChild(const Point& child_loc)
{
assert(m_p != child_loc);
NodeSPtr child = Node::create(child_loc);
return addChild(child);
}
NodeSPtr Node::addChild(NodeSPtr& new_child)
{
assert(new_child != shared_from_this());
//assert(p != new_child->p); // NOTE: No problem for now. Issue to solve later. Maybe even afetr final. Low prio.
m_children.push_back(new_child);
new_child->m_parent = shared_from_this();
new_child->m_is_root = false;
return new_child;
}
void Node::propagateToNextLayer(
std::vector<NodeSPtr>& next_trees,
const Polygons& next_outlines,
const EdgeGrid::Grid& outline_locator,
const coord_t prune_distance,
const coord_t smooth_magnitude,
const coord_t max_remove_colinear_dist) const
{
auto tree_below = deepCopy();
tree_below->prune(prune_distance);
tree_below->straighten(smooth_magnitude, max_remove_colinear_dist);
if (tree_below->realign(next_outlines, outline_locator, next_trees))
next_trees.push_back(tree_below);
}
// NOTE: Depth-first, as currently implemented.
// Skips the root (because that has no root itself), but all initial nodes will have the root point anyway.
void Node::visitBranches(const std::function<void(const Point&, const Point&)>& visitor) const
{
for (const auto& node : m_children) {
assert(node->m_parent.lock() == shared_from_this());
visitor(m_p, node->m_p);
node->visitBranches(visitor);
}
}
// NOTE: Depth-first, as currently implemented.
void Node::visitNodes(const std::function<void(NodeSPtr)>& visitor)
{
visitor(shared_from_this());
for (const auto& node : m_children) {
assert(node->m_parent.lock() == shared_from_this());
node->visitNodes(visitor);
}
}
Node::Node(const Point& p, const std::optional<Point>& last_grounding_location /*= std::nullopt*/) :
m_is_root(true), m_p(p), m_last_grounding_location(last_grounding_location)
{}
NodeSPtr Node::deepCopy() const
{
NodeSPtr local_root = Node::create(m_p);
local_root->m_is_root = m_is_root;
if (m_is_root)
{
local_root->m_last_grounding_location = m_last_grounding_location.value_or(m_p);
}
local_root->m_children.reserve(m_children.size());
for (const auto& node : m_children)
{
NodeSPtr child = node->deepCopy();
child->m_parent = local_root;
local_root->m_children.push_back(child);
}
return local_root;
}
void Node::reroot(NodeSPtr new_parent /*= nullptr*/)
{
if (! m_is_root) {
auto old_parent = m_parent.lock();
old_parent->reroot(shared_from_this());
m_children.push_back(old_parent);
}
if (new_parent) {
m_children.erase(std::remove(m_children.begin(), m_children.end(), new_parent), m_children.end());
m_is_root = false;
m_parent = new_parent;
} else {
m_is_root = true;
m_parent.reset();
}
}
NodeSPtr Node::closestNode(const Point& loc)
{
NodeSPtr result = shared_from_this();
auto closest_dist2 = coord_t((m_p - loc).cast<double>().norm());
for (const auto& child : m_children) {
NodeSPtr candidate_node = child->closestNode(loc);
const auto child_dist2 = coord_t((candidate_node->m_p - loc).cast<double>().norm());
if (child_dist2 < closest_dist2) {
closest_dist2 = child_dist2;
result = candidate_node;
}
}
return result;
}
bool inside(const Polygons &polygons, const Point p)
{
int poly_count_inside = 0;
for (const Polygon &poly : polygons) {
const int is_inside_this_poly = ClipperLib::PointInPolygon(p, poly.points);
if (is_inside_this_poly == -1)
return true;
poly_count_inside += is_inside_this_poly;
}
return (poly_count_inside % 2) == 1;
}
bool lineSegmentPolygonsIntersection(const Point& a, const Point& b, const EdgeGrid::Grid& outline_locator, Point& result, const coord_t within_max_dist)
{
struct Visitor {
bool operator()(coord_t iy, coord_t ix) {
// Called with a row and colum of the grid cell, which is intersected by a line.
auto cell_data_range = grid.cell_data_range(iy, ix);
for (auto it_contour_and_segment = cell_data_range.first; it_contour_and_segment != cell_data_range.second; ++it_contour_and_segment) {
// End points of the line segment and their vector.
auto segment = grid.segment(*it_contour_and_segment);
if (Vec2d ip; Geometry::segment_segment_intersection(segment.first.cast<double>(), segment.second.cast<double>(), this->line_a, this->line_b, ip))
if (double d = (this->intersection_pt - this->line_b).squaredNorm(); d < d2min) {
this->d2min = d;
this->intersection_pt = ip;
}
}
// Continue traversing the grid along the edge.
return true;
}
const EdgeGrid::Grid& grid;
Vec2d line_a;
Vec2d line_b;
Vec2d intersection_pt;
double d2min { std::numeric_limits<double>::max() };
} visitor { outline_locator, a.cast<double>(), b.cast<double>() };
outline_locator.visit_cells_intersecting_line(a, b, visitor);
return visitor.d2min < within_max_dist * within_max_dist;
}
bool Node::realign(const Polygons& outlines, const EdgeGrid::Grid& outline_locator, std::vector<NodeSPtr>& rerooted_parts)
{
if (outlines.empty())
return false;
if (inside(outlines, m_p)) {
// Only keep children that have an unbroken connection to here, realign will put the rest in rerooted parts due to recursion:
Point coll;
bool reground_me = false;
m_children.erase(std::remove_if(m_children.begin(), m_children.end(), [&](const NodeSPtr &child) {
bool connect_branch = child->realign(outlines, outline_locator, rerooted_parts);
// Find an intersection of the line segment from p to child->p, at maximum outline_locator.resolution() * 2 distance from p.
if (connect_branch && lineSegmentPolygonsIntersection(child->m_p, m_p, outline_locator, coll, outline_locator.resolution() * 2)) {
child->m_last_grounding_location.reset();
child->m_parent.reset();
child->m_is_root = true;
rerooted_parts.push_back(child);
reground_me = true;
connect_branch = false;
}
return ! connect_branch;
}), m_children.end());
if (reground_me)
m_last_grounding_location.reset();
return true;
}
// 'Lift' any decendants out of this tree:
for (auto& child : m_children)
if (child->realign(outlines, outline_locator, rerooted_parts)) {
child->m_last_grounding_location = m_p;
child->m_parent.reset();
child->m_is_root = true;
rerooted_parts.push_back(child);
}
m_children.clear();
return false;
}
void Node::straighten(const coord_t magnitude, const coord_t max_remove_colinear_dist)
{
straighten(magnitude, m_p, 0, max_remove_colinear_dist * max_remove_colinear_dist);
}
Node::RectilinearJunction Node::straighten(
const coord_t magnitude,
const Point& junction_above,
const coord_t accumulated_dist,
const coord_t max_remove_colinear_dist2)
{
constexpr coord_t junction_magnitude_factor_numerator = 3;
constexpr coord_t junction_magnitude_factor_denominator = 4;
const coord_t junction_magnitude = magnitude * junction_magnitude_factor_numerator / junction_magnitude_factor_denominator;
if (m_children.size() == 1)
{
auto child_p = m_children.front();
auto child_dist = coord_t((m_p - child_p->m_p).cast<double>().norm());
RectilinearJunction junction_below = child_p->straighten(magnitude, junction_above, accumulated_dist + child_dist, max_remove_colinear_dist2);
coord_t total_dist_to_junction_below = junction_below.total_recti_dist;
Point a = junction_above;
Point b = junction_below.junction_loc;
if (a != b) // should always be true!
{
Point ab = b - a;
Point destination = a + ab * accumulated_dist / std::max(coord_t(1), total_dist_to_junction_below);
if ((destination - m_p).cast<double>().squaredNorm() <= magnitude * magnitude)
m_p = destination;
else
m_p += ((destination - m_p).cast<double>().normalized() * magnitude).cast<coord_t>();
}
{ // remove nodes on linear segments
constexpr coord_t close_enough = 10;
child_p = m_children.front(); //recursive call to straighten might have removed the child
const NodeSPtr& parent_node = m_parent.lock();
if (parent_node &&
(child_p->m_p - parent_node->m_p).cast<double>().squaredNorm() < max_remove_colinear_dist2 &&
Line::distance_to_squared(m_p, parent_node->m_p, child_p->m_p) < close_enough * close_enough) {
child_p->m_parent = m_parent;
for (auto& sibling : parent_node->m_children)
{ // find this node among siblings
if (sibling == shared_from_this())
{
sibling = child_p; // replace this node by child
break;
}
}
}
}
return junction_below;
}
else
{
constexpr coord_t weight = 1000;
Point junction_moving_dir = ((junction_above - m_p).cast<double>().normalized() * weight).cast<coord_t>();
bool prevent_junction_moving = false;
for (auto& child_p : m_children)
{
const auto child_dist = coord_t((m_p - child_p->m_p).cast<double>().norm());
RectilinearJunction below = child_p->straighten(magnitude, m_p, child_dist, max_remove_colinear_dist2);
junction_moving_dir += ((below.junction_loc - m_p).cast<double>().normalized() * weight).cast<coord_t>();
if (below.total_recti_dist < magnitude) // TODO: make configurable?
{
prevent_junction_moving = true; // prevent flipflopping in branches due to straightening and junctoin moving clashing
}
}
if (junction_moving_dir != Point(0, 0) && ! m_children.empty() && ! m_is_root && ! prevent_junction_moving)
{
auto junction_moving_dir_len = coord_t(junction_moving_dir.norm());
if (junction_moving_dir_len > junction_magnitude)
{
junction_moving_dir = junction_moving_dir * junction_magnitude / junction_moving_dir_len;
}
m_p += junction_moving_dir;
}
return RectilinearJunction{ accumulated_dist, m_p };
}
}
// Prune the tree from the extremeties (leaf-nodes) until the pruning distance is reached.
coord_t Node::prune(const coord_t& pruning_distance)
{
if (pruning_distance <= 0)
return 0;
coord_t max_distance_pruned = 0;
for (auto child_it = m_children.begin(); child_it != m_children.end(); ) {
auto& child = *child_it;
coord_t dist_pruned_child = child->prune(pruning_distance);
if (dist_pruned_child >= pruning_distance)
{ // pruning is finished for child; dont modify further
max_distance_pruned = std::max(max_distance_pruned, dist_pruned_child);
++child_it;
} else {
const Point a = getLocation();
const Point b = child->getLocation();
const Point ba = a - b;
const auto ab_len = coord_t(ba.cast<double>().norm());
if (dist_pruned_child + ab_len <= pruning_distance) {
// we're still in the process of pruning
assert(child->m_children.empty() && "when pruning away a node all it's children must already have been pruned away");
max_distance_pruned = std::max(max_distance_pruned, dist_pruned_child + ab_len);
child_it = m_children.erase(child_it);
} else {
// pruning stops in between this node and the child
const Point n = b + (ba.cast<double>().normalized() * (pruning_distance - dist_pruned_child)).cast<coord_t>();
assert(std::abs((n - b).cast<double>().norm() + dist_pruned_child - pruning_distance) < 10 && "total pruned distance must be equal to the pruning_distance");
max_distance_pruned = std::max(max_distance_pruned, pruning_distance);
child->setLocation(n);
++child_it;
}
}
}
return max_distance_pruned;
}
void Node::convertToPolylines(Polygons& output, const coord_t line_width) const
{
Polygons result;
output.emplace_back();
convertToPolylines(0, result);
removeJunctionOverlap(result, line_width);
append(output, std::move(result));
}
void Node::convertToPolylines(size_t long_line_idx, Polygons& output) const
{
if (m_children.empty()) {
output[long_line_idx].points.push_back(m_p);
return;
}
size_t first_child_idx = rand() % m_children.size();
m_children[first_child_idx]->convertToPolylines(long_line_idx, output);
output[long_line_idx].points.push_back(m_p);
for (size_t idx_offset = 1; idx_offset < m_children.size(); idx_offset++) {
size_t child_idx = (first_child_idx + idx_offset) % m_children.size();
const Node& child = *m_children[child_idx];
output.emplace_back();
size_t child_line_idx = output.size() - 1;
child.convertToPolylines(child_line_idx, output);
output[child_line_idx].points.emplace_back(m_p);
}
}
void Node::removeJunctionOverlap(Polygons& result_lines, const coord_t line_width) const
{
const coord_t reduction = line_width / 2; // TODO make configurable?
for (auto poly_it = result_lines.begin(); poly_it != result_lines.end(); ) {
Polygon &polyline = *poly_it;
if (polyline.size() <= 1) {
polyline = std::move(result_lines.back());
result_lines.pop_back();
continue;
}
coord_t to_be_reduced = reduction;
Point a = polyline.back();
for (int point_idx = polyline.size() - 2; point_idx >= 0; point_idx--) {
const Point b = polyline[point_idx];
const Point ab = b - a;
const auto ab_len = coord_t(ab.cast<double>().norm());
if (ab_len >= to_be_reduced) {
polyline.points.back() = a + (ab.cast<double>() * (double(to_be_reduced) / ab_len)).cast<coord_t>();
break;
} else {
to_be_reduced -= ab_len;
polyline.points.pop_back();
}
a = b;
}
if (polyline.size() <= 1) {
polyline = std::move(result_lines.back());
result_lines.pop_back();
} else
++ poly_it;
}
}
} // namespace Slic3r::FillLightning

View File

@ -0,0 +1,275 @@
//Copyright (c) 2021 Ultimaker B.V.
//CuraEngine is released under the terms of the AGPLv3 or higher.
#ifndef LIGHTNING_TREE_NODE_H
#define LIGHTNING_TREE_NODE_H
#include <functional>
#include <memory>
#include <optional>
#include <vector>
#include "../../EdgeGrid.hpp"
#include "../../Polygon.hpp"
namespace Slic3r::FillLightning
{
constexpr auto locator_cell_size = scaled<coord_t>(4.);
class Node;
using NodeSPtr = std::shared_ptr<Node>;
// NOTE: As written, this struct will only be valid for a single layer, will have to be updated for the next.
// NOTE: Reasons for implementing this with some separate closures:
// - keep clear deliniation during development
// - possibility of multiple distance field strategies
/*!
* A single vertex of a Lightning Tree, the structure that determines the paths
* to be printed to form Lightning Infill.
*
* In essence these vertices are just a position linked to other positions in
* 2D. The nodes have a hierarchical structure of parents and children, forming
* a tree. The class also has some helper functions specific to Lightning Infill
* e.g. to straighten the paths around this node.
*/
class Node : public std::enable_shared_from_this<Node>
{
public:
// Workaround for private/protected constructors and 'make_shared': https://stackoverflow.com/a/27832765
template<typename ...Arg> NodeSPtr static create(Arg&&...arg)
{
struct EnableMakeShared : public Node
{
EnableMakeShared(Arg&&...arg) : Node(std::forward<Arg>(arg)...) {}
};
return std::make_shared<EnableMakeShared>(std::forward<Arg>(arg)...);
}
/*!
* Get the position on this layer that this node represents, a vertex of the
* path to print.
* \return The position that this node represents.
*/
const Point& getLocation() const { return m_p; }
/*!
* Change the position on this layer that the node represents.
* \param p The position that the node needs to represent.
*/
void setLocation(const Point& p) { m_p = p; }
/*!
* Construct a new ``Node`` instance and add it as a child of
* this node.
* \param p The location of the new node.
* \return A shared pointer to the new node.
*/
NodeSPtr addChild(const Point& p);
/*!
* Add an existing ``Node`` as a child of this node.
* \param new_child The node that must be added as a child.
* \return Always returns \p new_child.
*/
NodeSPtr addChild(NodeSPtr& new_child);
/*!
* Propagate this node's sub-tree to the next layer.
*
* Creates a copy of this tree, realign it to the new layer boundaries
* \p next_outlines and reduce (i.e. prune and straighten) it. A copy of
* this node and all of its descendant nodes will be added to the
* \p next_trees vector.
* \param next_trees A collection of tree nodes to use for the next layer.
* \param next_outlines The shape of the layer below, to make sure that the
* tree stays within the bounds of the infill area.
* \param prune_distance The maximum distance that a leaf node may be moved
* such that it still supports the current node.
* \param smooth_magnitude The maximum distance that a line may be shifted
* to straighten the tree's paths, such that it still supports the current
* paths.
* \param max_remove_colinear_dist The maximum distance of a line-segment
* from which straightening may remove a colinear point.
*/
void propagateToNextLayer
(
std::vector<NodeSPtr>& next_trees,
const Polygons& next_outlines,
const EdgeGrid::Grid& outline_locator,
const coord_t prune_distance,
const coord_t smooth_magnitude,
const coord_t max_remove_colinear_dist
) const;
/*!
* Executes a given function for every line segment in this node's sub-tree.
*
* The function takes two `Point` arguments. These arguments will be filled
* in with the higher-order node (closer to the root) first, and the
* downtree node (closer to the leaves) as the second argument. The segment
* from this node's parent to this node itself is not included.
* The order in which the segments are visited is depth-first.
* \param visitor A function to execute for every branch in the node's sub-
* tree.
*/
void visitBranches(const std::function<void(const Point&, const Point&)>& visitor) const;
/*!
* Execute a given function for every node in this node's sub-tree.
*
* The visitor function takes a node as input. This node is not const, so
* this can be used to change the tree.
* Nodes are visited in depth-first order. This node itself is visited as
* well (pre-order).
* \param visitor A function to execute for every node in this node's sub-
* tree.
*/
void visitNodes(const std::function<void(NodeSPtr)>& visitor);
/*!
* Get a weighted distance from an unsupported point to this node (given the current supporting radius).
*
* When attaching a unsupported location to a node, not all nodes have the same priority.
* (Eucludian) closer nodes are prioritised, but that's not the whole story.
* For instance, we give some nodes a 'valence boost' depending on the nr. of branches.
* \param unsupported_location The (unsuppported) location of which the weighted distance needs to be calculated.
* \param supporting_radius The maximum distance which can be bridged without (infill) supporting it.
* \return The weighted distance.
*/
coord_t getWeightedDistance(const Point& unsupported_location, const coord_t& supporting_radius) const;
/*!
* Returns whether this node is the root of a lightning tree. It is the root
* if it has no parents.
* \return ``true`` if this node is the root (no parents) or ``false`` if it
* is a child node of some other node.
*/
bool isRoot() const { return m_is_root; }
/*!
* Reverse the parent-child relationship all the way to the root, from this node onward.
* This has the effect of 're-rooting' the tree at the current node if no immediate parent is given as argument.
* That is, the current node will become the root, it's (former) parent if any, will become one of it's children.
* This is then recursively bubbled up until it reaches the (former) root, which then will become a leaf.
* \param new_parent The (new) parent-node of the root, useful for recursing or immediately attaching the node to another tree.
*/
void reroot(NodeSPtr new_parent = nullptr);
/*!
* Retrieves the closest node to the specified location.
* \param loc The specified location.
* \result The branch that starts at the position closest to the location within this tree.
*/
NodeSPtr closestNode(const Point& loc);
/*!
* Returns whether the given tree node is a descendant of this node.
*
* If this node itself is given, it is also considered to be a descendant.
* \param to_be_checked A node to find out whether it is a descendant of
* this node.
* \return ``true`` if the given node is a descendant or this node itself,
* or ``false`` if it is not in the sub-tree.
*/
bool hasOffspring(const NodeSPtr& to_be_checked) const;
protected:
Node() = delete; // Don't allow empty contruction
/*!
* Construct a new node, either for insertion in a tree or as root.
* \param p The physical location in the 2D layer that this node represents.
* Connecting other nodes to this node indicates that a line segment should
* be drawn between those two physical positions.
*/
Node(const Point& p, const std::optional<Point>& last_grounding_location = std::nullopt);
/*!
* Copy this node and its entire sub-tree.
* \return The equivalent of this node in the copy (the root of the new sub-
* tree).
*/
NodeSPtr deepCopy() const;
/*! Reconnect trees from the layer above to the new outlines of the lower layer.
* \return Wether or not the root is kept (false is no, true is yes).
*/
bool realign(const Polygons& outlines, const EdgeGrid::Grid& outline_locator, std::vector<NodeSPtr>& rerooted_parts);
struct RectilinearJunction
{
coord_t total_recti_dist; //!< rectilinear distance along the tree from the last junction above to the junction below
Point junction_loc; //!< junction location below
};
/*!
* Smoothen the tree to make it a bit more printable, while still supporting
* the trees above.
* \param magnitude The maximum allowed distance to move the node.
* \param max_remove_colinear_dist Maximum distance of the (compound) line-segment from which a co-linear point may be removed.
*/
void straighten(const coord_t magnitude, const coord_t max_remove_colinear_dist);
/*! Recursive part of \ref straighten(.)
* \param junction_above The last seen junction with multiple children above
* \param accumulated_dist The distance along the tree from the last seen junction to this node
* \param max_remove_colinear_dist2 Maximum distance _squared_ of the (compound) line-segment from which a co-linear point may be removed.
* \return the total distance along the tree from the last junction above to the first next junction below and the location of the next junction below
*/
RectilinearJunction straighten(const coord_t magnitude, const Point& junction_above, const coord_t accumulated_dist, const coord_t max_remove_colinear_dist2);
/*! Prune the tree from the extremeties (leaf-nodes) until the pruning distance is reached.
* \return The distance that has been pruned. If less than \p distance, then the whole tree was puned away.
*/
coord_t prune(const coord_t& distance);
public:
/*!
* Convert the tree into polylines
*
* At each junction one line is chosen at random to continue
*
* The lines start at a leaf and end in a junction
*
* \param output all branches in this tree connected into polylines
*/
void convertToPolylines(Polygons& output, const coord_t line_width) const;
/*! If this was ever a direct child of the root, it'll have a previous grounding location.
*
* This needs to be known when roots are reconnected, so that the last (higher) layer is supported by the next one.
*/
const std::optional<Point>& getLastGroundingLocation() const { return m_last_grounding_location; }
protected:
/*!
* Convert the tree into polylines
*
* At each junction one line is chosen at random to continue
*
* The lines start at a leaf and end in a junction
*
* \param long_line a reference to a polyline in \p output which to continue building on in the recursion
* \param output all branches in this tree connected into polylines
*/
void convertToPolylines(size_t long_line_idx, Polygons& output) const;
void removeJunctionOverlap(Polygons& polylines, const coord_t line_width) const;
bool m_is_root;
Point m_p;
std::weak_ptr<Node> m_parent;
std::vector<NodeSPtr> m_children;
std::optional<Point> m_last_grounding_location; //<! The last known grounding location, see 'getLastGroundingLocation()'.
};
bool inside(const Polygons &polygons, const Point p);
bool lineSegmentPolygonsIntersection(const Point& a, const Point& b, const EdgeGrid::Grid& outline_locator, Point& result, const coord_t within_max_dist);
} // namespace Slic3r::FillLightning
#endif // LIGHTNING_TREE_NODE_H

View File

@ -1998,13 +1998,19 @@ GCode::LayerResult GCode::process_layer(
// Either printing all copies of all objects, or just a single copy of a single object.
assert(single_object_instance_idx == size_t(-1) || layers.size() == 1);
// First object, support and raft layer, if available.
const Layer *object_layer = nullptr;
const SupportLayer *support_layer = nullptr;
const SupportLayer *raft_layer = nullptr;
for (const LayerToPrint &l : layers) {
if (l.object_layer != nullptr && object_layer == nullptr)
if (l.object_layer && ! object_layer)
object_layer = l.object_layer;
if (l.support_layer != nullptr && support_layer == nullptr)
support_layer = l.support_layer;
if (l.support_layer) {
if (! support_layer)
support_layer = l.support_layer;
if (! raft_layer && support_layer->id() < support_layer->object()->slicing_parameters().raft_layers())
raft_layer = support_layer;
}
}
const Layer &layer = (object_layer != nullptr) ? *object_layer : *support_layer;
GCode::LayerResult result { {}, layer.id(), false, last_layer };
@ -2406,7 +2412,7 @@ GCode::LayerResult GCode::process_layer(
log_memory_info();
result.gcode = std::move(gcode);
result.cooling_buffer_flush = object_layer || last_layer;
result.cooling_buffer_flush = object_layer || raft_layer || last_layer;
return result;
}
@ -2414,6 +2420,7 @@ void GCode::apply_print_config(const PrintConfig &print_config)
{
m_writer.apply_print_config(print_config);
m_config.apply(print_config);
m_scaled_resolution = scaled<double>(print_config.gcode_resolution.value);
}
void GCode::append_full_config(const Print &print, std::string &str)
@ -2565,7 +2572,7 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou
for (ExtrusionPaths::iterator path = paths.begin(); path != paths.end(); ++path) {
// description += ExtrusionLoop::role_to_string(loop.loop_role());
// description += ExtrusionEntity::role_to_string(path->role);
path->simplify(SCALED_RESOLUTION);
path->simplify(m_scaled_resolution);
gcode += this->_extrude(*path, description, speed);
}
@ -2619,7 +2626,7 @@ std::string GCode::extrude_multi_path(ExtrusionMultiPath multipath, std::string
for (ExtrusionPath path : multipath.paths) {
// description += ExtrusionLoop::role_to_string(loop.loop_role());
// description += ExtrusionEntity::role_to_string(path->role);
path.simplify(SCALED_RESOLUTION);
path.simplify(m_scaled_resolution);
gcode += this->_extrude(path, description, speed);
}
if (m_wipe.enable) {
@ -2647,7 +2654,7 @@ std::string GCode::extrude_entity(const ExtrusionEntity &entity, std::string des
std::string GCode::extrude_path(ExtrusionPath path, std::string description, double speed)
{
// description += ExtrusionEntity::role_to_string(path.role());
path.simplify(SCALED_RESOLUTION);
path.simplify(m_scaled_resolution);
std::string gcode = this->_extrude(path, description, speed);
if (m_wipe.enable) {
m_wipe.path = std::move(path.polyline);

View File

@ -345,6 +345,8 @@ private:
methods. */
Vec2d m_origin;
FullPrintConfig m_config;
// scaled G-code resolution
double m_scaled_resolution;
GCodeWriter m_writer;
PlaceholderParser m_placeholder_parser;
// For random number generator etc.

View File

@ -254,7 +254,7 @@ static std::vector<Intersection> extend_for_closest_lines(const std::vector<Inte
};
std::vector<Intersection> new_intersections = intersections;
if (!intersections.empty() && !start_lines.empty()) {
if (!new_intersections.empty() && !start_lines.empty()) {
size_t cl_start_idx = get_closer(start_lines, new_intersections.front(), start);
if (cl_start_idx != std::numeric_limits<size_t>::max()) {
// If there is any ClosestLine around the start point closer to the Intersection, then replace this Intersection with ClosestLine.
@ -265,11 +265,13 @@ static std::vector<Intersection> extend_for_closest_lines(const std::vector<Inte
// vector of intersections. This allows in some cases when it is more than one around ClosestLine start point chose that one which
// minimizes the number of contours (also length of the detour) in result detour. If there doesn't exist any ClosestLine like this, then
// use the first one, which is the closest one to the start point.
size_t start_closest_lines_idx = find_closest_line_with_same_boundary_idx(start_lines, intersections, true);
size_t start_closest_lines_idx = find_closest_line_with_same_boundary_idx(start_lines, new_intersections, true);
const ClosestLine &cl_start = (start_closest_lines_idx != std::numeric_limits<size_t>::max()) ? start_lines[start_closest_lines_idx] : start_lines.front();
new_intersections.insert(new_intersections.begin(),{cl_start.border_idx, cl_start.line_idx, cl_start.point, compute_distance(cl_start)});
}
} else if (!intersections.empty() && !end_lines.empty()) {
}
if (!new_intersections.empty() && !end_lines.empty()) {
size_t cl_end_idx = get_closer(end_lines, new_intersections.back(), end);
if (cl_end_idx != std::numeric_limits<size_t>::max()) {
// If there is any ClosestLine around the end point closer to the Intersection, then replace this Intersection with ClosestLine.
@ -280,7 +282,7 @@ static std::vector<Intersection> extend_for_closest_lines(const std::vector<Inte
// vector of intersections. This allows in some cases when it is more than one around ClosestLine end point chose that one which
// minimizes the number of contours (also length of the detour) in result detour. If there doesn't exist any ClosestLine like this, then
// use the first one, which is the closest one to the end point.
size_t end_closest_lines_idx = find_closest_line_with_same_boundary_idx(end_lines, intersections, false);
size_t end_closest_lines_idx = find_closest_line_with_same_boundary_idx(end_lines, new_intersections, false);
const ClosestLine &cl_end = (end_closest_lines_idx != std::numeric_limits<size_t>::max()) ? end_lines[end_closest_lines_idx] : end_lines.front();
new_intersections.push_back({cl_end.border_idx, cl_end.line_idx, cl_end.point, compute_distance(cl_end)});
}

View File

@ -2,6 +2,7 @@
#include "libslic3r/Utils.hpp"
#include "libslic3r/format.hpp"
#include "libslic3r/I18N.hpp"
#include <boost/algorithm/string.hpp>
#include <boost/log/trivial.hpp>
@ -184,6 +185,11 @@ static int run_script(const std::string &script, const std::string &gcode, std::
namespace Slic3r {
//! macro used to mark string used at localization,
//! return same string
#define L(s) (s)
#define _(s) Slic3r::I18N::translate(s)
// Run post processing script / scripts if defined.
// Returns true if a post-processing script was executed.
// Returns false if no post-processing script was defined.
@ -278,6 +284,15 @@ bool run_post_process_scripts(std::string &src_path, bool make_copy, const std::
delete_copy();
throw Slic3r::RuntimeError(msg);
}
if (! boost::filesystem::exists(gcode_file)) {
const std::string msg = (boost::format(_(L(
"Post-processing script %1% failed.\n\n"
"The post-processing script is expected to change the G-code file %2% in place, but the G-code file was deleted and likely saved under a new name.\n"
"Please adjust the post-processing script to change the G-code in place and consult the manual on how to optionally rename the post-processed G-code file.\n")))
% script % path).str();
BOOST_LOG_TRIVIAL(error) << msg;
throw Slic3r::RuntimeError(msg);
}
}
}
if (boost::filesystem::exists(path_output_name)) {

View File

@ -45,7 +45,7 @@ void Layer::make_slices()
Polygons slices_p;
for (LayerRegion *layerm : m_regions)
polygons_append(slices_p, to_polygons(layerm->slices.surfaces));
slices = union_ex(slices_p);
slices = union_safety_offset_ex(slices_p);
}
this->lslices.clear();

View File

@ -148,7 +148,8 @@ public:
return false;
}
void make_perimeters();
void make_fills() { this->make_fills(nullptr, nullptr); };
// Phony version of make_fills() without parameters for Perl integration only.
void make_fills() { this->make_fills(nullptr, nullptr); }
void make_fills(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive::Octree* support_fill_octree);
void make_ironing();

View File

@ -322,7 +322,7 @@ void PerimeterGenerator::process()
for (const Surface &surface : this->slices->surfaces) {
// detect how many perimeters must be generated for this island
int loop_number = this->config->perimeters + surface.extra_perimeters - 1; // 0-indexed loops
ExPolygons last = union_ex(surface.expolygon.simplify_p(SCALED_RESOLUTION));
ExPolygons last = union_ex(surface.expolygon.simplify_p(m_scaled_resolution));
ExPolygons gaps;
if (loop_number >= 0) {
// In case no perimeters are to be generated, loop_number will equal to -1.
@ -533,7 +533,7 @@ void PerimeterGenerator::process()
// simplify infill contours according to resolution
Polygons pp;
for (ExPolygon &ex : last)
ex.simplify_p(SCALED_RESOLUTION, &pp);
ex.simplify_p(m_scaled_resolution, &pp);
// collapse too narrow infill areas
coord_t min_perimeter_infill_spacing = coord_t(solid_infill_spacing * (1. - INSET_OVERLAP_TOLERANCE));
// append infill areas to fill_surfaces

View File

@ -50,6 +50,7 @@ public:
overhang_flow(flow), solid_infill_flow(flow),
config(config), object_config(object_config), print_config(print_config),
m_spiral_vase(spiral_vase),
m_scaled_resolution(scaled<double>(print_config->gcode_resolution.value)),
loops(loops), gap_fill(gap_fill), fill_surfaces(fill_surfaces),
m_ext_mm3_per_mm(-1), m_mm3_per_mm(-1), m_mm3_per_mm_overhang(-1)
{}
@ -63,6 +64,7 @@ public:
private:
bool m_spiral_vase;
double m_scaled_resolution;
double m_ext_mm3_per_mm;
double m_mm3_per_mm;
double m_mm3_per_mm_overhang;

View File

@ -255,7 +255,7 @@ namespace int128 {
// To be used by std::unordered_map, std::unordered_multimap and friends.
struct PointHash {
size_t operator()(const Vec2crd &pt) const {
return std::hash<coord_t>()(pt.x()) ^ std::hash<coord_t>()(pt.y());
return coord_t((89 * 31 + int64_t(pt.x())) * 31 + pt.y());
}
};

View File

@ -444,7 +444,7 @@ static std::vector<std::string> s_Preset_print_options {
"ooze_prevention", "standby_temperature_delta", "interface_shells", "extrusion_width", "first_layer_extrusion_width",
"perimeter_extrusion_width", "external_perimeter_extrusion_width", "infill_extrusion_width", "solid_infill_extrusion_width",
"top_infill_extrusion_width", "support_material_extrusion_width", "infill_overlap", "infill_anchor", "infill_anchor_max", "bridge_flow_ratio", "clip_multipart_objects",
"elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "wipe_tower", "wipe_tower_x", "wipe_tower_y",
"elefant_foot_compensation", "xy_size_compensation", "threads", "resolution", "gcode_resolution", "wipe_tower", "wipe_tower_x", "wipe_tower_y",
"wipe_tower_width", "wipe_tower_rotation_angle", "wipe_tower_brim_width", "wipe_tower_bridging", "single_extruder_multi_material_priming", "mmu_segmented_region_max_width",
"wipe_tower_no_sparse_layers", "compatible_printers", "compatible_printers_condition", "inherits"
};

View File

@ -214,7 +214,8 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
} else if (
opt_key == "first_layer_extrusion_width"
|| opt_key == "min_layer_height"
|| opt_key == "max_layer_height") {
|| opt_key == "max_layer_height"
|| opt_key == "gcode_resolution") {
osteps.emplace_back(posPerimeters);
osteps.emplace_back(posInfill);
osteps.emplace_back(posSupportMaterial);

View File

@ -107,7 +107,10 @@ static t_config_enum_values s_keys_map_InfillPattern {
{ "archimedeanchords", ipArchimedeanChords },
{ "octagramspiral", ipOctagramSpiral },
{ "adaptivecubic", ipAdaptiveCubic },
{ "supportcubic", ipSupportCubic }
{ "supportcubic", ipSupportCubic },
#if HAS_LIGHTNING_INFILL
{ "lightning", ipLightning }
#endif // HAS_LIGHTNING_INFILL
};
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(InfillPattern)
@ -1135,6 +1138,9 @@ void PrintConfigDef::init_fff_params()
def->enum_values.push_back("octagramspiral");
def->enum_values.push_back("adaptivecubic");
def->enum_values.push_back("supportcubic");
#if HAS_LIGHTNING_INFILL
def->enum_values.push_back("lightning");
#endif // HAS_LIGHTNING_INFILL
def->enum_labels.push_back(L("Rectilinear"));
def->enum_labels.push_back(L("Aligned Rectilinear"));
def->enum_labels.push_back(L("Grid"));
@ -1151,6 +1157,9 @@ void PrintConfigDef::init_fff_params()
def->enum_labels.push_back(L("Octagram Spiral"));
def->enum_labels.push_back(L("Adaptive Cubic"));
def->enum_labels.push_back(L("Support Cubic"));
#if HAS_LIGHTNING_INFILL
def->enum_labels.push_back(L("Lightning"));
#endif // HAS_LIGHTNING_INFILL
def->set_default_value(new ConfigOptionEnum<InfillPattern>(ipStars));
def = this->add("first_layer_acceleration", coFloat);
@ -1201,6 +1210,7 @@ void PrintConfigDef::init_fff_params()
def->tooltip = L("When printing with very low layer heights, you might still want to print a thicker "
"bottom layer to improve adhesion and tolerance for non perfect build plates.");
def->sidetext = L("mm");
def->min = 0;
def->ratio_over = "layer_height";
def->set_default_value(new ConfigOptionFloatOrPercent(0.35, false));
@ -2072,7 +2082,7 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionInt(0));
def = this->add("resolution", coFloat);
def->label = L("Resolution");
def->label = L("Slice resolution");
def->tooltip = L("Minimum detail resolution, used to simplify the input file for speeding up "
"the slicing job and reducing memory usage. High-resolution models often carry "
"more detail than printers can render. Set to zero to disable any simplification "
@ -2082,6 +2092,18 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(0));
def = this->add("gcode_resolution", coFloat);
def->label = L("G-code resolution");
def->tooltip = L("Maximum deviation of exported G-code paths from their full resolution counterparts. "
"Very high resolution G-code requires huge amount of RAM to slice and preview, "
"also a 3D printer may stutter not being able to process a high resolution G-code in a timely manner. "
"On the other hand, a low resolution G-code will produce a low poly effect and because "
"the G-code reduction is performed at each layer independently, visible artifacts may be produced.");
def->sidetext = L("mm");
def->min = 0;
def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(0.0125));
def = this->add("retract_before_travel", coFloats);
def->label = L("Minimum travel after retraction");
def->tooltip = L("Retraction is not triggered when travel moves are shorter than this length.");
@ -3167,7 +3189,7 @@ void PrintConfigDef::init_sla_params()
def = this->add("relative_correction_y", coFloat);
def->label = L("Printer scaling correction in Y axis");
def->full_label = L("Printer scaling X axis correction");
def->full_label = L("Printer scaling Y axis correction");
def->tooltip = L("Printer scaling correction in Y axis");
def->min = 0;
def->mode = comExpert;
@ -3175,7 +3197,7 @@ void PrintConfigDef::init_sla_params()
def = this->add("relative_correction_z", coFloat);
def->label = L("Printer scaling correction in Z axis");
def->full_label = L("Printer scaling X axis correction");
def->full_label = L("Printer scaling Z axis correction");
def->tooltip = L("Printer scaling correction in Z axis");
def->min = 0;
def->mode = comExpert;
@ -3940,6 +3962,10 @@ void DynamicPrintConfig::normalize_fdm()
this->opt<ConfigOptionPercent>("fill_density", true)->value = 0;
}
}
if (auto *opt_gcode_resolution = this->opt<ConfigOptionFloat>("gcode_resolution", false); opt_gcode_resolution)
// Resolution will be above 1um.
opt_gcode_resolution->value = std::max(opt_gcode_resolution->value, 0.001);
}
void handle_legacy_sla(DynamicPrintConfig &config)

View File

@ -57,9 +57,15 @@ enum class FuzzySkinType {
All,
};
#define HAS_LIGHTNING_INFILL 0
enum InfillPattern : int {
ipRectilinear, ipMonotonic, ipAlignedRectilinear, ipGrid, ipTriangles, ipStars, ipCubic, ipLine, ipConcentric, ipHoneycomb, ip3DHoneycomb,
ipGyroid, ipHilbertCurve, ipArchimedeanChords, ipOctagramSpiral, ipAdaptiveCubic, ipSupportCubic, ipSupportBase, ipCount,
ipGyroid, ipHilbertCurve, ipArchimedeanChords, ipOctagramSpiral, ipAdaptiveCubic, ipSupportCubic, ipSupportBase,
#if HAS_LIGHTNING_INFILL
ipLightning,
#endif // HAS_LIGHTNING_INFILL
ipCount,
};
enum class IroningType {
@ -734,6 +740,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
((ConfigOptionString, printer_model))
((ConfigOptionString, printer_notes))
((ConfigOptionFloat, resolution))
((ConfigOptionFloat, gcode_resolution))
((ConfigOptionFloats, retract_before_travel))
((ConfigOptionBools, retract_layer_change))
((ConfigOptionFloat, skirt_distance))

View File

@ -6,6 +6,7 @@
#include "Geometry.hpp"
#include "I18N.hpp"
#include "Layer.hpp"
#include "MutablePolygon.hpp"
#include "SupportMaterial.hpp"
#include "Surface.hpp"
#include "Slicing.hpp"
@ -1709,9 +1710,6 @@ void PrintObject::clip_fill_surfaces()
Layer *layer = m_layers[layer_id];
Layer *lower_layer = m_layers[layer_id - 1];
// Detect things that we need to support.
// Cummulative slices.
Polygons slices;
polygons_append(slices, layer->lslices);
// Cummulative fill surfaces.
Polygons fill_surfaces;
// Solid surfaces to be supported.
@ -1736,7 +1734,7 @@ void PrintObject::clip_fill_surfaces()
{
// Get perimeters area as the difference between slices and fill_surfaces
// Only consider the area that is not supported by lower perimeters
Polygons perimeters = intersection(diff(slices, fill_surfaces), lower_layer_fill_surfaces);
Polygons perimeters = intersection(diff(layer->lslices, fill_surfaces), lower_layer_fill_surfaces);
// Only consider perimeter areas that are at least one extrusion width thick.
//FIXME Offset2 eats out from both sides, while the perimeters are create outside in.
//Should the pw not be half of the current value?
@ -1746,9 +1744,15 @@ void PrintObject::clip_fill_surfaces()
// Append such thick perimeters to the areas that need support
polygons_append(overhangs, opening(perimeters, pw));
}
// Find new internal infill.
polygons_append(overhangs, std::move(upper_internal));
upper_internal = intersection(overhangs, lower_layer_internal_surfaces);
// Merge the new overhangs, find new internal infill.
polygons_append(upper_internal, std::move(overhangs));
static constexpr const auto closing_radius = scaled<float>(2.f);
upper_internal = intersection(
// Regularize the overhang regions, so that the infill areas will not become excessively jagged.
smooth_outward(
closing(upper_internal, closing_radius, ClipperLib::jtSquare, 0.),
scaled<coord_t>(0.1)),
lower_layer_internal_surfaces);
// Apply new internal infill to regions.
for (LayerRegion *layerm : lower_layer->m_regions) {
if (layerm->region().config().fill_density.value == 0)

View File

@ -1480,7 +1480,7 @@ static inline std::tuple<Polygons, Polygons, Polygons, float> detect_overhangs(
overhang_polygons = to_polygons(layer.lslices);
#endif
// Expand for better stability.
contact_polygons = expand(overhang_polygons, scaled<float>(object_config.raft_expansion.value));
contact_polygons = object_config.raft_expansion.value > 0 ? expand(overhang_polygons, scaled<float>(object_config.raft_expansion.value)) : overhang_polygons;
}
else if (! layer.regions().empty())
{

View File

@ -9,6 +9,112 @@
namespace Slic3r {
// Check if the line is whole inside the sphere, or it is partially inside (intersecting) the sphere.
// Inspired by Christer Ericson's Real-Time Collision Detection, pp. 177-179.
static bool test_line_inside_sphere(const Vec3f &line_a, const Vec3f &line_b, const Vec3f &sphere_p, const float sphere_radius)
{
const float sphere_radius_sqr = Slic3r::sqr(sphere_radius);
const Vec3f line_dir = line_b - line_a; // n
const Vec3f origins_diff = line_a - sphere_p; // m
const float m_dot_m = origins_diff.dot(origins_diff);
// Check if any of the end-points of the line is inside the sphere.
if (m_dot_m <= sphere_radius_sqr || (line_b - sphere_p).squaredNorm() <= sphere_radius_sqr)
return true;
// Check if the infinite line is going through the sphere.
const float n_dot_n = line_dir.dot(line_dir);
const float m_dot_n = origins_diff.dot(line_dir);
const float eq_a = n_dot_n;
const float eq_b = m_dot_n;
const float eq_c = m_dot_m - sphere_radius_sqr;
const float discr = eq_b * eq_b - eq_a * eq_c;
// A negative discriminant corresponds to the infinite line infinite not going through the sphere.
if (discr < 0.f)
return false;
// Check if the finite line is going through the sphere.
const float discr_sqrt = std::sqrt(discr);
const float t1 = (-eq_b - discr_sqrt) / eq_a;
if (0.f <= t1 && t1 <= 1.f)
return true;
const float t2 = (-eq_b + discr_sqrt) / eq_a;
if (0.f <= t2 && t2 <= 1.f && discr_sqrt > 0.f)
return true;
return false;
}
// Check if the line is whole inside the finite cylinder, or it is partially inside (intersecting) the finite cylinder.
// Inspired by Christer Ericson's Real-Time Collision Detection, pp. 194-198.
static bool test_line_inside_cylinder(const Vec3f &line_a, const Vec3f &line_b, const Vec3f &cylinder_P, const Vec3f &cylinder_Q, const float cylinder_radius)
{
assert(cylinder_P != cylinder_Q);
const Vec3f cylinder_dir = cylinder_Q - cylinder_P; // d
auto is_point_inside_finite_cylinder = [&cylinder_P, &cylinder_Q, &cylinder_radius, &cylinder_dir](const Vec3f &pt) {
const Vec3f first_center_diff = cylinder_P - pt;
const Vec3f second_center_diff = cylinder_Q - pt;
// First, check if the point pt is laying between planes defined by cylinder_p and cylinder_q.
// Then check if it is inside the cylinder between cylinder_p and cylinder_q.
return first_center_diff.dot(cylinder_dir) <= 0 && second_center_diff.dot(cylinder_dir) >= 0 &&
(first_center_diff.cross(cylinder_dir).norm() / cylinder_dir.norm()) <= cylinder_radius;
};
// Check if any of the end-points of the line is inside the cylinder.
if (is_point_inside_finite_cylinder(line_a) || is_point_inside_finite_cylinder(line_b))
return true;
// Check if the line is going through the cylinder.
const Vec3f origins_diff = line_a - cylinder_P; // m
const Vec3f line_dir = line_b - line_a; // n
const float m_dot_d = origins_diff.dot(cylinder_dir);
const float n_dot_d = line_dir.dot(cylinder_dir);
const float d_dot_d = cylinder_dir.dot(cylinder_dir);
const float n_dot_n = line_dir.dot(line_dir);
const float m_dot_n = origins_diff.dot(line_dir);
const float m_dot_m = origins_diff.dot(origins_diff);
const float eq_a = d_dot_d * n_dot_n - n_dot_d * n_dot_d;
const float eq_b = d_dot_d * m_dot_n - n_dot_d * m_dot_d;
const float eq_c = d_dot_d * (m_dot_m - Slic3r::sqr(cylinder_radius)) - m_dot_d * m_dot_d;
const float discr = eq_b * eq_b - eq_a * eq_c;
// A negative discriminant corresponds to the infinite line not going through the infinite cylinder.
if (discr < 0.0f)
return false;
// Check if the finite line is going through the finite cylinder.
const float discr_sqrt = std::sqrt(discr);
const float t1 = (-eq_b - discr_sqrt) / eq_a;
if (0.f <= t1 && t1 <= 1.f)
if (const float cylinder_endcap_t1 = m_dot_d + t1 * n_dot_d; 0.f <= cylinder_endcap_t1 && cylinder_endcap_t1 <= d_dot_d)
return true;
const float t2 = (-eq_b + discr_sqrt) / eq_a;
if (0.f <= t2 && t2 <= 1.f)
if (const float cylinder_endcap_t2 = (m_dot_d + t2 * n_dot_d); 0.f <= cylinder_endcap_t2 && cylinder_endcap_t2 <= d_dot_d)
return true;
return false;
}
// Check if the line is whole inside the capsule, or it is partially inside (intersecting) the capsule.
static bool test_line_inside_capsule(const Vec3f &line_a, const Vec3f &line_b, const Vec3f &capsule_p, const Vec3f &capsule_q, const float capsule_radius) {
assert(capsule_p != capsule_q);
// Check if the line intersect any of the spheres forming the capsule.
if (test_line_inside_sphere(line_a, line_b, capsule_p, capsule_radius) || test_line_inside_sphere(line_a, line_b, capsule_q, capsule_radius))
return true;
// Check if the line intersects the cylinder between the centers of the spheres.
return test_line_inside_cylinder(line_a, line_b, capsule_p, capsule_q, capsule_radius);
}
#ifndef NDEBUG
bool TriangleSelector::verify_triangle_midpoints(const Triangle &tr) const
{
@ -124,24 +230,20 @@ int TriangleSelector::select_unsplit_triangle(const Vec3f &hit, int facet_idx) c
return this->select_unsplit_triangle(hit, facet_idx, neighbors);
}
void TriangleSelector::select_patch(const Vec3f& hit, int facet_start,
const Vec3f& source, float radius,
CursorType cursor_type, EnforcerBlockerType new_state,
const Transform3d& trafo, const Transform3d& trafo_no_translate,
bool triangle_splitting, const ClippingPlane &clp, float highlight_by_angle_deg)
void TriangleSelector::select_patch(int facet_start, std::unique_ptr<Cursor> &&cursor, EnforcerBlockerType new_state, const Transform3d& trafo_no_translate, bool triangle_splitting, float highlight_by_angle_deg)
{
assert(facet_start < m_orig_size_indices);
// Save current cursor center, squared radius and camera direction, so we don't
// have to pass it around.
m_cursor = Cursor(hit, source, radius, cursor_type, trafo, clp);
m_cursor = std::move(cursor);
// In case user changed cursor size since last time, update triangle edge limit.
// It is necessary to compare the internal radius in m_cursor! radius is in
// world coords and does not change after scaling.
if (m_old_cursor_radius_sqr != m_cursor.radius_sqr) {
set_edge_limit(std::sqrt(m_cursor.radius_sqr) / 5.f);
m_old_cursor_radius_sqr = m_cursor.radius_sqr;
if (m_old_cursor_radius_sqr != m_cursor->radius_sqr) {
set_edge_limit(std::sqrt(m_cursor->radius_sqr) / 5.f);
m_old_cursor_radius_sqr = m_cursor->radius_sqr;
}
const float highlight_angle_limit = cos(Geometry::deg2rad(highlight_by_angle_deg));
@ -163,7 +265,7 @@ void TriangleSelector::select_patch(const Vec3f& hit, int facet_start,
if (select_triangle(facet, new_state, triangle_splitting)) {
// add neighboring facets to list to be processed later
for (int neighbor_idx : m_neighbors[facet])
if (neighbor_idx >= 0 && (m_cursor.type == SPHERE || faces_camera(neighbor_idx)))
if (neighbor_idx >= 0 && m_cursor->is_facet_visible(neighbor_idx, m_face_normals))
facets_to_check.push_back(neighbor_idx);
}
}
@ -256,8 +358,9 @@ void TriangleSelector::precompute_all_neighbors_recursive(const int facet_idx, c
assert(tr->children[i] < int(m_triangles.size()));
// Recursion, deep first search over the children of this triangle.
// All children of this triangle were created by splitting a single source triangle of the original mesh.
this->precompute_all_neighbors_recursive(tr->children[i], this->child_neighbors(*tr, neighbors, i),
this->child_neighbors_propagated(*tr, neighbors_propagated, i), neighbors_out,
const Vec3i child_neighbors = this->child_neighbors(*tr, neighbors, i);
this->precompute_all_neighbors_recursive(tr->children[i], child_neighbors,
this->child_neighbors_propagated(*tr, neighbors_propagated, i, child_neighbors), neighbors_out,
neighbors_propagated_out);
}
}
@ -682,33 +785,29 @@ Vec3i TriangleSelector::child_neighbors(const Triangle &tr, const Vec3i &neighbo
// Return neighbors of the ith child of a triangle given neighbors of the triangle.
// If such a neighbor doesn't exist, return the neighbor from the previous depth.
Vec3i TriangleSelector::child_neighbors_propagated(const Triangle &tr, const Vec3i &neighbors, int child_idx) const
Vec3i TriangleSelector::child_neighbors_propagated(const Triangle &tr, const Vec3i &neighbors_propagated, int child_idx, const Vec3i &child_neighbors) const
{
int i = tr.special_side();
int j = next_idx_modulo(i, 3);
int k = next_idx_modulo(j, 3);
Vec3i out;
auto replace_if_not_exists = [&out](int index_to_replace, int neighbor) {
Vec3i out = child_neighbors;
auto replace_if_not_exists = [&out, &neighbors_propagated](int index_to_replace, int neighbor_idx) {
if (out(index_to_replace) == -1)
out(index_to_replace) = neighbor;
out(index_to_replace) = neighbors_propagated(neighbor_idx);
};
switch (tr.number_of_split_sides()) {
case 1:
switch (child_idx) {
case 0:
out(0) = neighbors(i);
out(1) = this->neighbor_child(neighbors(j), tr.verts_idxs[k], tr.verts_idxs[j], Partition::Second);
replace_if_not_exists(1, neighbors(j));
out(2) = tr.children[1];
replace_if_not_exists(0, i);
replace_if_not_exists(1, j);
break;
default:
assert(child_idx == 1);
out(0) = this->neighbor_child(neighbors(j), tr.verts_idxs[k], tr.verts_idxs[j], Partition::First);
replace_if_not_exists(0, neighbors(j));
out(1) = neighbors(k);
out(2) = tr.children[0];
replace_if_not_exists(0, j);
replace_if_not_exists(1, k);
break;
}
break;
@ -716,25 +815,17 @@ Vec3i TriangleSelector::child_neighbors_propagated(const Triangle &tr, const Vec
case 2:
switch (child_idx) {
case 0:
out(0) = this->neighbor_child(neighbors(i), tr.verts_idxs[j], tr.verts_idxs[i], Partition::Second);
replace_if_not_exists(0, neighbors(i));
out(1) = tr.children[1];
out(2) = this->neighbor_child(neighbors(k), tr.verts_idxs[i], tr.verts_idxs[k], Partition::First);
replace_if_not_exists(2, neighbors(k));
replace_if_not_exists(0, i);
replace_if_not_exists(2, k);
break;
case 1:
assert(child_idx == 1);
out(0) = this->neighbor_child(neighbors(i), tr.verts_idxs[j], tr.verts_idxs[i], Partition::First);
replace_if_not_exists(0, neighbors(i));
out(1) = tr.children[2];
out(2) = tr.children[0];
replace_if_not_exists(0, i);
break;
default:
assert(child_idx == 2);
out(0) = neighbors(j);
out(1) = this->neighbor_child(neighbors(k), tr.verts_idxs[i], tr.verts_idxs[k], Partition::Second);
replace_if_not_exists(1, neighbors(k));
out(2) = tr.children[1];
replace_if_not_exists(0, j);
replace_if_not_exists(1, k);
break;
}
break;
@ -743,31 +834,19 @@ Vec3i TriangleSelector::child_neighbors_propagated(const Triangle &tr, const Vec
assert(tr.special_side() == 0);
switch (child_idx) {
case 0:
out(0) = this->neighbor_child(neighbors(0), tr.verts_idxs[1], tr.verts_idxs[0], Partition::Second);
replace_if_not_exists(0, neighbors(0));
out(1) = tr.children[3];
out(2) = this->neighbor_child(neighbors(2), tr.verts_idxs[0], tr.verts_idxs[2], Partition::First);
replace_if_not_exists(2, neighbors(2));
replace_if_not_exists(0, 0);
replace_if_not_exists(2, 2);
break;
case 1:
out(0) = this->neighbor_child(neighbors(0), tr.verts_idxs[1], tr.verts_idxs[0], Partition::First);
replace_if_not_exists(0, neighbors(0));
out(1) = this->neighbor_child(neighbors(1), tr.verts_idxs[2], tr.verts_idxs[1], Partition::Second);
replace_if_not_exists(1, neighbors(1));
out(2) = tr.children[3];
replace_if_not_exists(0, 0);
replace_if_not_exists(1, 1);
break;
case 2:
out(0) = this->neighbor_child(neighbors(1), tr.verts_idxs[2], tr.verts_idxs[1], Partition::First);
replace_if_not_exists(0, neighbors(1));
out(1) = this->neighbor_child(neighbors(2), tr.verts_idxs[0], tr.verts_idxs[2], Partition::Second);
replace_if_not_exists(1, neighbors(2));
out(2) = tr.children[3];
replace_if_not_exists(0, 1);
replace_if_not_exists(1, 2);
break;
default:
assert(child_idx == 3);
out(0) = tr.children[1];
out(1) = tr.children[2];
out(2) = tr.children[0];
break;
}
break;
@ -788,11 +867,11 @@ bool TriangleSelector::select_triangle_recursive(int facet_idx, const Vec3i &nei
assert(this->verify_triangle_neighbors(*tr, neighbors));
int num_of_inside_vertices = vertices_inside(facet_idx);
int num_of_inside_vertices = m_cursor->vertices_inside(*tr, m_vertices);
if (num_of_inside_vertices == 0
&& ! is_pointer_in_triangle(facet_idx)
&& ! is_edge_inside_cursor(facet_idx))
&& ! m_cursor->is_pointer_in_triangle(*tr, m_vertices)
&& ! m_cursor->is_edge_inside_cursor(*tr, m_vertices))
return false;
if (num_of_inside_vertices == 3) {
@ -840,7 +919,7 @@ void TriangleSelector::set_facet(int facet_idx, EnforcerBlockerType state)
}
// called by select_patch()->select_triangle()...select_triangle()
// to decide which sides of the traingle to split and to actually split it calling set_division() and perform_split().
// to decide which sides of the triangle to split and to actually split it calling set_division() and perform_split().
void TriangleSelector::split_triangle(int facet_idx, const Vec3i &neighbors)
{
if (m_triangles[facet_idx].is_split()) {
@ -864,9 +943,9 @@ void TriangleSelector::split_triangle(int facet_idx, const Vec3i &neighbors)
// In case the object is non-uniformly scaled, transform the
// points to world coords.
if (! m_cursor.uniform_scaling) {
if (! m_cursor->uniform_scaling) {
for (size_t i=0; i<pts.size(); ++i) {
pts_transformed[i] = m_cursor.trafo * (*pts[i]);
pts_transformed[i] = m_cursor->trafo * (*pts[i]);
pts[i] = &pts_transformed[i];
}
}
@ -897,71 +976,80 @@ void TriangleSelector::split_triangle(int facet_idx, const Vec3i &neighbors)
perform_split(facet_idx, neighbors, old_type);
}
// Is pointer in a triangle?
bool TriangleSelector::is_pointer_in_triangle(int facet_idx) const
{
const Vec3f& p1 = m_vertices[m_triangles[facet_idx].verts_idxs[0]].v;
const Vec3f& p2 = m_vertices[m_triangles[facet_idx].verts_idxs[1]].v;
const Vec3f& p3 = m_vertices[m_triangles[facet_idx].verts_idxs[2]].v;
return m_cursor.is_pointer_in_triangle(p1, p2, p3);
bool TriangleSelector::Cursor::is_pointer_in_triangle(const Triangle &tr, const std::vector<Vertex> &vertices) const {
const Vec3f& p1 = vertices[tr.verts_idxs[0]].v;
const Vec3f& p2 = vertices[tr.verts_idxs[1]].v;
const Vec3f& p3 = vertices[tr.verts_idxs[2]].v;
return this->is_pointer_in_triangle(p1, p2, p3);
}
// Determine whether this facet is potentially visible (still can be obscured).
bool TriangleSelector::faces_camera(int facet) const
bool TriangleSelector::Cursor::is_facet_visible(const Cursor &cursor, int facet_idx, const std::vector<Vec3f> &face_normals)
{
assert(facet < m_orig_size_indices);
Vec3f n = m_face_normals[facet];
if (! m_cursor.uniform_scaling)
n = m_cursor.trafo_normal * n;
return n.dot(m_cursor.dir) < 0.;
assert(facet_idx < int(face_normals.size()));
Vec3f n = face_normals[facet_idx];
if (!cursor.uniform_scaling)
n = cursor.trafo_normal * n;
return n.dot(cursor.dir) < 0.f;
}
// How many vertices of a triangle are inside the circle?
int TriangleSelector::vertices_inside(int facet_idx) const
int TriangleSelector::Cursor::vertices_inside(const Triangle &tr, const std::vector<Vertex> &vertices) const
{
int inside = 0;
for (size_t i=0; i<3; ++i) {
if (m_cursor.is_mesh_point_inside(m_vertices[m_triangles[facet_idx].verts_idxs[i]].v))
for (size_t i = 0; i < 3; ++i)
if (this->is_mesh_point_inside(vertices[tr.verts_idxs[i]].v))
++inside;
}
return inside;
}
// Is edge inside cursor?
bool TriangleSelector::is_edge_inside_cursor(int facet_idx) const
// Is any edge inside Sphere cursor?
bool TriangleSelector::Sphere::is_edge_inside_cursor(const Triangle &tr, const std::vector<Vertex> &vertices) const
{
std::array<Vec3f, 3> pts;
for (int i=0; i<3; ++i) {
pts[i] = m_vertices[m_triangles[facet_idx].verts_idxs[i]].v;
if (! m_cursor.uniform_scaling)
pts[i] = m_cursor.trafo * pts[i];
for (int i = 0; i < 3; ++i) {
pts[i] = vertices[tr.verts_idxs[i]].v;
if (!this->uniform_scaling)
pts[i] = this->trafo * pts[i];
}
const Vec3f& p = m_cursor.center;
for (int side = 0; side < 3; ++side) {
const Vec3f& a = pts[side];
const Vec3f& b = pts[side<2 ? side+1 : 0];
Vec3f s = (b-a).normalized();
float t = (p-a).dot(s);
Vec3f vector = a+t*s - p;
// vector is 3D vector from center to the intersection. What we want to
// measure is length of its projection onto plane perpendicular to dir.
float dist_sqr = vector.squaredNorm() - std::pow(vector.dot(m_cursor.dir), 2.f);
if (dist_sqr < m_cursor.radius_sqr && t>=0.f && t<=(b-a).norm())
const Vec3f &edge_a = pts[side];
const Vec3f &edge_b = pts[side < 2 ? side + 1 : 0];
if (test_line_inside_sphere(edge_a, edge_b, this->center, this->radius))
return true;
}
return false;
}
// Is edge inside cursor?
bool TriangleSelector::Circle::is_edge_inside_cursor(const Triangle &tr, const std::vector<Vertex> &vertices) const
{
std::array<Vec3f, 3> pts;
for (int i = 0; i < 3; ++i) {
pts[i] = vertices[tr.verts_idxs[i]].v;
if (!this->uniform_scaling)
pts[i] = this->trafo * pts[i];
}
const Vec3f &p = this->center;
for (int side = 0; side < 3; ++side) {
const Vec3f &a = pts[side];
const Vec3f &b = pts[side < 2 ? side + 1 : 0];
Vec3f s = (b - a).normalized();
float t = (p - a).dot(s);
Vec3f vector = a + t * s - p;
// vector is 3D vector from center to the intersection. What we want to
// measure is length of its projection onto plane perpendicular to dir.
float dist_sqr = vector.squaredNorm() - std::pow(vector.dot(this->dir), 2.f);
if (dist_sqr < this->radius_sqr && t >= 0.f && t <= (b - a).norm())
return true;
}
return false;
}
// Recursively remove all subtriangles.
void TriangleSelector::undivide_triangle(int facet_idx)
@ -1002,7 +1090,6 @@ void TriangleSelector::undivide_triangle(int facet_idx)
}
}
void TriangleSelector::remove_useless_children(int facet_idx)
{
// Check that all children are leafs of the same type. If not, try to
@ -1041,8 +1128,6 @@ void TriangleSelector::remove_useless_children(int facet_idx)
tr.set_state(first_child_type);
}
void TriangleSelector::garbage_collect()
{
// First make a map from old to new triangle indices.
@ -1103,7 +1188,6 @@ TriangleSelector::TriangleSelector(const TriangleMesh& mesh)
reset();
}
void TriangleSelector::reset()
{
m_vertices.clear();
@ -1124,17 +1208,11 @@ void TriangleSelector::reset()
}
void TriangleSelector::set_edge_limit(float edge_limit)
{
m_edge_limit_sqr = std::pow(edge_limit, 2.f);
}
int TriangleSelector::push_triangle(int a, int b, int c, int source_triangle, const EnforcerBlockerType state)
{
for (int i : {a, b, c}) {
@ -1426,7 +1504,9 @@ void TriangleSelector::get_seed_fill_contour_recursive(const int facet_idx, cons
assert(tr->children[i] < int(m_triangles.size()));
// Recursion, deep first search over the children of this triangle.
// All children of this triangle were created by splitting a single source triangle of the original mesh.
this->get_seed_fill_contour_recursive(tr->children[i], this->child_neighbors(*tr, neighbors, i), this->child_neighbors_propagated(*tr, neighbors_propagated, i), edges_out);
const Vec3i child_neighbors = this->child_neighbors(*tr, neighbors, i);
this->get_seed_fill_contour_recursive(tr->children[i], child_neighbors,
this->child_neighbors_propagated(*tr, neighbors_propagated, i, child_neighbors), edges_out);
}
}
} else if (tr->is_selected_by_seed_fill()) {
@ -1693,54 +1773,132 @@ void TriangleSelector::seed_fill_apply_on_triangles(EnforcerBlockerType new_stat
}
}
TriangleSelector::Cursor::Cursor(
const Vec3f& center_, const Vec3f& source_, float radius_world,
CursorType type_, const Transform3d& trafo_, const ClippingPlane &clipping_plane_)
: center{center_},
source{source_},
type{type_},
trafo{trafo_.cast<float>()},
clipping_plane(clipping_plane_)
TriangleSelector::Cursor::Cursor(const Vec3f &source_, float radius_world, const Transform3d &trafo_, const ClippingPlane &clipping_plane_)
: source{source_}, trafo{trafo_.cast<float>()}, clipping_plane{clipping_plane_}
{
Vec3d sf = Geometry::Transformation(trafo_).get_scaling_factor();
if (is_approx(sf(0), sf(1)) && is_approx(sf(1), sf(2))) {
radius_sqr = float(std::pow(radius_world / sf(0), 2));
radius = float(radius_world / sf(0));
radius_sqr = float(Slic3r::sqr(radius_world / sf(0)));
uniform_scaling = true;
}
else {
} else {
// In case that the transformation is non-uniform, all checks whether
// something is inside the cursor should be done in world coords.
// First transform center, source and dir in world coords and remember
// that we did this.
center = trafo * center;
source = trafo * source;
// First transform source in world coords and remember that we did this.
source = trafo * source;
uniform_scaling = false;
radius_sqr = radius_world * radius_world;
trafo_normal = trafo.linear().inverse().transpose();
radius = radius_world;
radius_sqr = Slic3r::sqr(radius_world);
trafo_normal = trafo.linear().inverse().transpose();
}
}
TriangleSelector::SinglePointCursor::SinglePointCursor(const Vec3f& center_, const Vec3f& source_, float radius_world, const Transform3d& trafo_, const ClippingPlane &clipping_plane_)
: center{center_}, Cursor(source_, radius_world, trafo_, clipping_plane_)
{
// In case that the transformation is non-uniform, all checks whether
// something is inside the cursor should be done in world coords.
// Because of the center is transformed.
if (!uniform_scaling)
center = trafo * center;
// Calculate dir, in whatever coords is appropriate.
dir = (center - source).normalized();
}
// Is a point (in mesh coords) inside a cursor?
bool TriangleSelector::Cursor::is_mesh_point_inside(const Vec3f &point) const
TriangleSelector::DoublePointCursor::DoublePointCursor(const Vec3f &first_center_, const Vec3f &second_center_, const Vec3f &source_, float radius_world, const Transform3d &trafo_, const ClippingPlane &clipping_plane_)
: first_center{first_center_}, second_center{second_center_}, Cursor(source_, radius_world, trafo_, clipping_plane_)
{
if (!uniform_scaling) {
first_center = trafo * first_center_;
second_center = trafo * second_center_;
}
// Calculate dir, in whatever coords is appropriate.
dir = (first_center - source).normalized();
}
// Returns true if clipping plane is not active or if the point not clipped by clipping plane.
inline static bool is_mesh_point_not_clipped(const Vec3f &point, const TriangleSelector::ClippingPlane &clipping_plane)
{
return !clipping_plane.is_active() || !clipping_plane.is_mesh_point_clipped(point);
}
// Is a point (in mesh coords) inside a Sphere cursor?
bool TriangleSelector::Sphere::is_mesh_point_inside(const Vec3f &point) const
{
const Vec3f transformed_point = uniform_scaling ? point : Vec3f(trafo * point);
if ((center - transformed_point).squaredNorm() < radius_sqr)
return is_mesh_point_not_clipped(point, clipping_plane);
return false;
}
// Is a point (in mesh coords) inside a Circle cursor?
bool TriangleSelector::Circle::is_mesh_point_inside(const Vec3f &point) const
{
const Vec3f transformed_point = uniform_scaling ? point : Vec3f(trafo * point);
const Vec3f diff = center - transformed_point;
const bool is_point_inside = (type == CIRCLE ? (diff - diff.dot(dir) * dir).squaredNorm() : diff.squaredNorm()) < radius_sqr;
if (is_point_inside && clipping_plane.is_active())
return !clipping_plane.is_mesh_point_clipped(point);
if ((diff - diff.dot(dir) * dir).squaredNorm() < radius_sqr)
return is_mesh_point_not_clipped(point, clipping_plane);
return is_point_inside;
return false;
}
// Is a point (in mesh coords) inside a Capsule3D cursor?
bool TriangleSelector::Capsule3D::is_mesh_point_inside(const Vec3f &point) const
{
const Vec3f transformed_point = uniform_scaling ? point : Vec3f(trafo * point);
const Vec3f first_center_diff = this->first_center - transformed_point;
const Vec3f second_center_diff = this->second_center - transformed_point;
if (first_center_diff.squaredNorm() < this->radius_sqr || second_center_diff.squaredNorm() < this->radius_sqr)
return is_mesh_point_not_clipped(point, clipping_plane);
// First, check if the point pt is laying between planes defined by first_center and second_center.
// Then check if it is inside the cylinder between first_center and second_center.
const Vec3f centers_diff = this->second_center - this->first_center;
if (first_center_diff.dot(centers_diff) <= 0.f && second_center_diff.dot(centers_diff) >= 0.f && (first_center_diff.cross(centers_diff).norm() / centers_diff.norm()) <= this->radius)
return is_mesh_point_not_clipped(point, clipping_plane);
return false;
}
// Is a point (in mesh coords) inside a Capsule2D cursor?
bool TriangleSelector::Capsule2D::is_mesh_point_inside(const Vec3f &point) const
{
const Vec3f transformed_point = uniform_scaling ? point : Vec3f(trafo * point);
const Vec3f first_center_diff = this->first_center - transformed_point;
const Vec3f first_center_diff_projected = first_center_diff - first_center_diff.dot(this->dir) * this->dir;
if (first_center_diff_projected.squaredNorm() < this->radius_sqr)
return is_mesh_point_not_clipped(point, clipping_plane);
const Vec3f second_center_diff = this->second_center - transformed_point;
const Vec3f second_center_diff_projected = second_center_diff - second_center_diff.dot(this->dir) * this->dir;
if (second_center_diff_projected.squaredNorm() < this->radius_sqr)
return is_mesh_point_not_clipped(point, clipping_plane);
const Vec3f centers_diff = this->second_center - this->first_center;
const Vec3f centers_diff_projected = centers_diff - centers_diff.dot(this->dir) * this->dir;
// First, check if the point is laying between first_center and second_center.
if (first_center_diff_projected.dot(centers_diff_projected) <= 0.f && second_center_diff_projected.dot(centers_diff_projected) >= 0.f) {
// Vector in the direction of line |AD| of the rectangle that intersects the circle with the center in first_center.
const Vec3f rectangle_da_dir = centers_diff.cross(this->dir);
// Vector pointing from first_center to the point 'A' of the rectangle.
const Vec3f first_center_rectangle_a_diff = rectangle_da_dir.normalized() * this->radius;
const Vec3f rectangle_a = this->first_center - first_center_rectangle_a_diff;
const Vec3f rectangle_d = this->first_center + first_center_rectangle_a_diff;
// Now check if the point is laying inside the rectangle between circles with centers in first_center and second_center.
if ((rectangle_a - transformed_point).dot(rectangle_da_dir) <= 0.f && (rectangle_d - transformed_point).dot(rectangle_da_dir) >= 0.f)
return is_mesh_point_not_clipped(point, clipping_plane);
}
return false;
}
// p1, p2, p3 are in mesh coords!
bool TriangleSelector::Cursor::is_pointer_in_triangle(const Vec3f& p1_,
const Vec3f& p2_,
const Vec3f& p3_) const
{
static bool is_circle_pointer_inside_triangle(const Vec3f &p1_, const Vec3f &p2_, const Vec3f &p3_, const Vec3f &center, const Vec3f &dir, const bool uniform_scaling, const Transform3f &trafo) {
const Vec3f& q1 = center + dir;
const Vec3f& q2 = center - dir;
@ -1761,4 +1919,108 @@ bool TriangleSelector::Cursor::is_pointer_in_triangle(const Vec3f& p1_,
return signed_volume_sign(q1,q2,p2,p3) == pos && signed_volume_sign(q1,q2,p3,p1) == pos;
}
// p1, p2, p3 are in mesh coords!
bool TriangleSelector::SinglePointCursor::is_pointer_in_triangle(const Vec3f &p1_, const Vec3f &p2_, const Vec3f &p3_) const
{
return is_circle_pointer_inside_triangle(p1_, p2_, p3_, center, dir, uniform_scaling, trafo);
}
// p1, p2, p3 are in mesh coords!
bool TriangleSelector::DoublePointCursor::is_pointer_in_triangle(const Vec3f &p1_, const Vec3f &p2_, const Vec3f &p3_) const
{
return is_circle_pointer_inside_triangle(p1_, p2_, p3_, first_center, dir, uniform_scaling, trafo) ||
is_circle_pointer_inside_triangle(p1_, p2_, p3_, second_center, dir, uniform_scaling, trafo);
}
bool line_plane_intersection(const Vec3f &line_a, const Vec3f &line_b, const Vec3f &plane_origin, const Vec3f &plane_normal, Vec3f &out_intersection)
{
Vec3f line_dir = line_b - line_a;
float t_denominator = plane_normal.dot(line_dir);
if (t_denominator == 0.f)
return false;
// Compute 'd' in plane equation by using some point (origin) on the plane
float plane_d = plane_normal.dot(plane_origin);
if (float t = (plane_d - plane_normal.dot(line_a)) / t_denominator; t >= 0.f && t <= 1.f) {
out_intersection = line_a + t * line_dir;
return true;
}
return false;
}
bool TriangleSelector::Capsule3D::is_edge_inside_cursor(const Triangle &tr, const std::vector<Vertex> &vertices) const
{
std::array<Vec3f, 3> pts;
for (int i = 0; i < 3; ++i) {
pts[i] = vertices[tr.verts_idxs[i]].v;
if (!this->uniform_scaling)
pts[i] = this->trafo * pts[i];
}
for (int side = 0; side < 3; ++side) {
const Vec3f &edge_a = pts[side];
const Vec3f &edge_b = pts[side < 2 ? side + 1 : 0];
if (test_line_inside_capsule(edge_a, edge_b, this->first_center, this->second_center, this->radius))
return true;
}
return false;
}
// Is edge inside cursor?
bool TriangleSelector::Capsule2D::is_edge_inside_cursor(const Triangle &tr, const std::vector<Vertex> &vertices) const
{
std::array<Vec3f, 3> pts;
for (int i = 0; i < 3; ++i) {
pts[i] = vertices[tr.verts_idxs[i]].v;
if (!this->uniform_scaling)
pts[i] = this->trafo * pts[i];
}
const Vec3f centers_diff = this->second_center - this->first_center;
// Vector in the direction of line |AD| of the rectangle that intersects the circle with the center in first_center.
const Vec3f rectangle_da_dir = centers_diff.cross(this->dir);
// Vector pointing from first_center to the point 'A' of the rectangle.
const Vec3f first_center_rectangle_a_diff = rectangle_da_dir.normalized() * this->radius;
const Vec3f rectangle_a = this->first_center - first_center_rectangle_a_diff;
const Vec3f rectangle_d = this->first_center + first_center_rectangle_a_diff;
auto edge_inside_rectangle = [&self = std::as_const(*this), &centers_diff](const Vec3f &edge_a, const Vec3f &edge_b, const Vec3f &plane_origin, const Vec3f &plane_normal) -> bool {
Vec3f intersection(-1.f, -1.f, -1.f);
if (line_plane_intersection(edge_a, edge_b, plane_origin, plane_normal, intersection)) {
// Now check if the intersection point is inside the rectangle. That means it is between 'first_center' and 'second_center', resp. between 'A' and 'B'.
if (self.first_center.dot(centers_diff) <= intersection.dot(centers_diff) && intersection.dot(centers_diff) <= self.second_center.dot(centers_diff))
return true;
}
return false;
};
for (int side = 0; side < 3; ++side) {
const Vec3f &edge_a = pts[side];
const Vec3f &edge_b = pts[side < 2 ? side + 1 : 0];
const Vec3f edge_dir = edge_b - edge_a;
const Vec3f edge_dir_n = edge_dir.normalized();
float t1 = (this->first_center - edge_a).dot(edge_dir_n);
float t2 = (this->second_center - edge_a).dot(edge_dir_n);
Vec3f vector1 = edge_a + t1 * edge_dir_n - this->first_center;
Vec3f vector2 = edge_a + t2 * edge_dir_n - this->second_center;
// Vectors vector1 and vector2 are 3D vector from centers to the intersections. What we want to
// measure is length of its projection onto plane perpendicular to dir.
if (float dist = vector1.squaredNorm() - std::pow(vector1.dot(this->dir), 2.f); dist < this->radius_sqr && t1 >= 0.f && t1 <= edge_dir.norm())
return true;
if (float dist = vector2.squaredNorm() - std::pow(vector2.dot(this->dir), 2.f); dist < this->radius_sqr && t2 >= 0.f && t2 <= edge_dir.norm())
return true;
// Check if the edge is passing through the rectangle between first_center and second_center.
if (edge_inside_rectangle(edge_a, edge_b, rectangle_a, (rectangle_d - rectangle_a)) || edge_inside_rectangle(edge_a, edge_b, rectangle_d, (rectangle_a - rectangle_d)))
return true;
}
return false;
}
} // namespace Slic3r

View File

@ -15,7 +15,12 @@ enum class EnforcerBlockerType : int8_t;
// Following class holds information about selected triangles. It also has power
// to recursively subdivide the triangles and make the selection finer.
class TriangleSelector {
class TriangleSelector
{
protected:
class Triangle;
struct Vertex;
public:
enum CursorType {
CIRCLE,
@ -35,6 +40,146 @@ public:
bool is_mesh_point_clipped(const Vec3f &point) const { return normal.dot(point) - offset > 0.f; }
};
class Cursor
{
public:
Cursor() = delete;
virtual ~Cursor() = default;
bool is_pointer_in_triangle(const Triangle &tr, const std::vector<Vertex> &vertices) const;
virtual bool is_mesh_point_inside(const Vec3f &point) const = 0;
virtual bool is_pointer_in_triangle(const Vec3f &p1, const Vec3f &p2, const Vec3f &p3) const = 0;
virtual int vertices_inside(const Triangle &tr, const std::vector<Vertex> &vertices) const;
virtual bool is_edge_inside_cursor(const Triangle &tr, const std::vector<Vertex> &vertices) const = 0;
virtual bool is_facet_visible(int facet_idx, const std::vector<Vec3f> &face_normals) const = 0;
static bool is_facet_visible(const Cursor &cursor, int facet_idx, const std::vector<Vec3f> &face_normals);
protected:
explicit Cursor(const Vec3f &source_, float radius_world, const Transform3d &trafo_, const ClippingPlane &clipping_plane_);
Transform3f trafo;
Vec3f source;
bool uniform_scaling;
Transform3f trafo_normal;
float radius;
float radius_sqr;
Vec3f dir = Vec3f(0.f, 0.f, 0.f);
ClippingPlane clipping_plane; // Clipping plane to limit painting to not clipped facets only
friend TriangleSelector;
};
class SinglePointCursor : public Cursor
{
public:
SinglePointCursor() = delete;
~SinglePointCursor() override = default;
bool is_pointer_in_triangle(const Vec3f &p1, const Vec3f &p2, const Vec3f &p3) const override;
static std::unique_ptr<Cursor> cursor_factory(const Vec3f &center, const Vec3f &camera_pos, const float cursor_radius, const CursorType cursor_type, const Transform3d &trafo_matrix, const ClippingPlane &clipping_plane)
{
assert(cursor_type == TriangleSelector::CursorType::CIRCLE || cursor_type == TriangleSelector::CursorType::SPHERE);
if (cursor_type == TriangleSelector::CursorType::SPHERE)
return std::make_unique<TriangleSelector::Sphere>(center, camera_pos, cursor_radius, trafo_matrix, clipping_plane);
else
return std::make_unique<TriangleSelector::Circle>(center, camera_pos, cursor_radius, trafo_matrix, clipping_plane);
}
protected:
explicit SinglePointCursor(const Vec3f &center_, const Vec3f &source_, float radius_world, const Transform3d &trafo_, const ClippingPlane &clipping_plane_);
Vec3f center;
};
class DoublePointCursor : public Cursor
{
public:
DoublePointCursor() = delete;
~DoublePointCursor() override = default;
bool is_pointer_in_triangle(const Vec3f &p1, const Vec3f &p2, const Vec3f &p3) const override;
static std::unique_ptr<Cursor> cursor_factory(const Vec3f &first_center, const Vec3f &second_center, const Vec3f &camera_pos, const float cursor_radius, const CursorType cursor_type, const Transform3d &trafo_matrix, const ClippingPlane &clipping_plane)
{
assert(cursor_type == TriangleSelector::CursorType::CIRCLE || cursor_type == TriangleSelector::CursorType::SPHERE);
if (cursor_type == TriangleSelector::CursorType::SPHERE)
return std::make_unique<TriangleSelector::Capsule3D>(first_center, second_center, camera_pos, cursor_radius, trafo_matrix, clipping_plane);
else
return std::make_unique<TriangleSelector::Capsule2D>(first_center, second_center, camera_pos, cursor_radius, trafo_matrix, clipping_plane);
}
protected:
explicit DoublePointCursor(const Vec3f &first_center_, const Vec3f &second_center_, const Vec3f &source_, float radius_world, const Transform3d &trafo_, const ClippingPlane &clipping_plane_);
Vec3f first_center;
Vec3f second_center;
};
class Sphere : public SinglePointCursor
{
public:
Sphere() = delete;
explicit Sphere(const Vec3f &center_, const Vec3f &source_, float radius_world, const Transform3d &trafo_, const ClippingPlane &clipping_plane_)
: SinglePointCursor(center_, source_, radius_world, trafo_, clipping_plane_){};
~Sphere() override = default;
bool is_mesh_point_inside(const Vec3f &point) const override;
bool is_edge_inside_cursor(const Triangle &tr, const std::vector<Vertex> &vertices) const override;
bool is_facet_visible(int facet_idx, const std::vector<Vec3f> &face_normals) const override { return true; }
};
class Circle : public SinglePointCursor
{
public:
Circle() = delete;
explicit Circle(const Vec3f &center_, const Vec3f &source_, float radius_world, const Transform3d &trafo_, const ClippingPlane &clipping_plane_)
: SinglePointCursor(center_, source_, radius_world, trafo_, clipping_plane_){};
~Circle() override = default;
bool is_mesh_point_inside(const Vec3f &point) const override;
bool is_edge_inside_cursor(const Triangle &tr, const std::vector<Vertex> &vertices) const override;
bool is_facet_visible(int facet_idx, const std::vector<Vec3f> &face_normals) const override
{
return TriangleSelector::Cursor::is_facet_visible(*this, facet_idx, face_normals);
}
};
class Capsule3D : public DoublePointCursor
{
public:
Capsule3D() = delete;
explicit Capsule3D(const Vec3f &first_center_, const Vec3f &second_center_, const Vec3f &source_, float radius_world, const Transform3d &trafo_, const ClippingPlane &clipping_plane_)
: TriangleSelector::DoublePointCursor(first_center_, second_center_, source_, radius_world, trafo_, clipping_plane_)
{}
~Capsule3D() override = default;
bool is_mesh_point_inside(const Vec3f &point) const override;
bool is_edge_inside_cursor(const Triangle &tr, const std::vector<Vertex> &vertices) const override;
bool is_facet_visible(int facet_idx, const std::vector<Vec3f> &face_normals) const override { return true; }
};
class Capsule2D : public DoublePointCursor
{
public:
Capsule2D() = delete;
explicit Capsule2D(const Vec3f &first_center_, const Vec3f &second_center_, const Vec3f &source_, float radius_world, const Transform3d &trafo_, const ClippingPlane &clipping_plane_)
: TriangleSelector::DoublePointCursor(first_center_, second_center_, source_, radius_world, trafo_, clipping_plane_)
{}
~Capsule2D() override = default;
bool is_mesh_point_inside(const Vec3f &point) const override;
bool is_edge_inside_cursor(const Triangle &tr, const std::vector<Vertex> &vertices) const override;
bool is_facet_visible(int facet_idx, const std::vector<Vec3f> &face_normals) const override
{
return TriangleSelector::Cursor::is_facet_visible(*this, facet_idx, face_normals);
}
};
std::pair<std::vector<Vec3i>, std::vector<Vec3i>> precompute_all_neighbors() const;
void precompute_all_neighbors_recursive(int facet_idx, const Vec3i &neighbors, const Vec3i &neighbors_propagated, std::vector<Vec3i> &neighbors_out, std::vector<Vec3i> &neighbors_normal_out) const;
@ -51,17 +196,12 @@ public:
[[nodiscard]] int select_unsplit_triangle(const Vec3f &hit, int facet_idx, const Vec3i &neighbors) const;
// Select all triangles fully inside the circle, subdivide where needed.
void select_patch(const Vec3f &hit, // point where to start
int facet_start, // facet of the original mesh (unsplit) that the hit point belongs to
const Vec3f &source, // camera position (mesh coords)
float radius, // radius of the cursor
CursorType type, // current type of cursor
EnforcerBlockerType new_state, // enforcer or blocker?
const Transform3d &trafo, // matrix to get from mesh to world
const Transform3d &trafo_no_translate, // matrix to get from mesh to world without translation
bool triangle_splitting, // If triangles will be split base on the cursor or not
const ClippingPlane &clp, // Clipping plane to limit painting to not clipped facets only
float highlight_by_angle_deg = 0.f); // The maximal angle of overhang. If it is set to a non-zero value, it is possible to paint only the triangles of overhang defined by this angle in degrees.
void select_patch(int facet_start, // facet of the original mesh (unsplit) that the hit point belongs to
std::unique_ptr<Cursor> &&cursor, // Cursor containing information about the point where to start, camera position (mesh coords), matrix to get from mesh to world, and its shape and type.
EnforcerBlockerType new_state, // enforcer or blocker?
const Transform3d &trafo_no_translate, // matrix to get from mesh to world without translation
bool triangle_splitting, // If triangles will be split base on the cursor or not
float highlight_by_angle_deg = 0.f); // The maximal angle of overhang. If it is set to a non-zero value, it is possible to paint only the triangles of overhang defined by this angle in degrees.
void seed_fill_select_triangles(const Vec3f &hit, // point where to start
int facet_start, // facet of the original mesh (unsplit) that the hit point belongs to
@ -195,44 +335,21 @@ protected:
int m_orig_size_vertices = 0;
int m_orig_size_indices = 0;
// Cache for cursor position, radius and direction.
struct Cursor {
Cursor() = default;
Cursor(const Vec3f& center_, const Vec3f& source_, float radius_world,
CursorType type_, const Transform3d& trafo_, const ClippingPlane &clipping_plane_);
bool is_mesh_point_inside(const Vec3f &pt) const;
bool is_pointer_in_triangle(const Vec3f& p1, const Vec3f& p2, const Vec3f& p3) const;
Vec3f center;
Vec3f source;
Vec3f dir;
float radius_sqr;
CursorType type;
Transform3f trafo;
Transform3f trafo_normal;
bool uniform_scaling;
ClippingPlane clipping_plane;
};
Cursor m_cursor;
std::unique_ptr<Cursor> m_cursor;
float m_old_cursor_radius_sqr;
// Private functions:
private:
bool select_triangle(int facet_idx, EnforcerBlockerType type, bool triangle_splitting);
bool select_triangle_recursive(int facet_idx, const Vec3i &neighbors, EnforcerBlockerType type, bool triangle_splitting);
int vertices_inside(int facet_idx) const;
bool faces_camera(int facet) const;
void undivide_triangle(int facet_idx);
void split_triangle(int facet_idx, const Vec3i &neighbors);
void remove_useless_children(int facet_idx); // No hidden meaning. Triangles are meant.
bool is_pointer_in_triangle(int facet_idx) const;
bool is_edge_inside_cursor(int facet_idx) const;
bool is_facet_clipped(int facet_idx, const ClippingPlane &clp) const;
int push_triangle(int a, int b, int c, int source_triangle, EnforcerBlockerType state = EnforcerBlockerType{0});
void perform_split(int facet_idx, const Vec3i &neighbors, EnforcerBlockerType old_state);
Vec3i child_neighbors(const Triangle &tr, const Vec3i &neighbors, int child_idx) const;
Vec3i child_neighbors_propagated(const Triangle &tr, const Vec3i &neighbors, int child_idx) const;
Vec3i child_neighbors_propagated(const Triangle &tr, const Vec3i &neighbors_propagated, int child_idx, const Vec3i &child_neighbors) const;
// Return child of itriangle at a CCW oriented side (vertexi, vertexj), either first or 2nd part.
// If itriangle == -1 or if the side sharing (vertexi, vertexj) is not split, return -1.
enum class Partition {

View File

@ -47,9 +47,6 @@ static constexpr double EPSILON = 1e-4;
// int32_t fits an interval of (-2147.48mm, +2147.48mm)
// with int64_t we don't have to worry anymore about the size of the int.
static constexpr double SCALING_FACTOR = 0.000001;
// RESOLUTION, SCALED_RESOLUTION: Used as an error threshold for a Douglas-Peucker polyline simplification algorithm.
static constexpr double RESOLUTION = 0.0125;
#define SCALED_RESOLUTION (RESOLUTION / SCALING_FACTOR)
static constexpr double PI = 3.141592653589793238;
// When extruding a closed loop, the loop is interrupted and shortened a bit to reduce the seam.
static constexpr double LOOP_CLIPPING_LENGTH_OVER_NOZZLE_DIAMETER = 0.15;

View File

@ -139,7 +139,7 @@ Code flags --
REALfloat = 1 all numbers are 'float' type
= 0 all numbers are 'double' type
*/
#define REALfloat 1
#define REALfloat 0
#if (REALfloat == 1)
#define realT float

View File

@ -72,15 +72,10 @@ namespace Slic3r {
#if ENABLE_SMOOTH_NORMALS
static void smooth_normals_corner(TriangleMesh& mesh, std::vector<stl_normal>& normals)
{
mesh.repair();
using MapMatrixXfUnaligned = Eigen::Map<const Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor | Eigen::DontAlign>>;
using MapMatrixXiUnaligned = Eigen::Map<const Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor | Eigen::DontAlign>>;
std::vector<stl_normal> face_normals(mesh.stl.stats.number_of_facets);
for (uint32_t i = 0; i < mesh.stl.stats.number_of_facets; ++i) {
face_normals[i] = mesh.stl.facet_start[i].normal;
}
std::vector<Vec3f> face_normals = its_face_normals(mesh.its);
Eigen::MatrixXd vertices = MapMatrixXfUnaligned(mesh.its.vertices.front().data(),
Eigen::Index(mesh.its.vertices.size()), 3).cast<double>();
@ -102,8 +97,6 @@ static void smooth_normals_corner(TriangleMesh& mesh, std::vector<stl_normal>& n
static void smooth_normals_vertex(TriangleMesh& mesh, std::vector<stl_normal>& normals)
{
mesh.repair();
using MapMatrixXfUnaligned = Eigen::Map<const Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor | Eigen::DontAlign>>;
using MapMatrixXiUnaligned = Eigen::Map<const Eigen::Matrix<int, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor | Eigen::DontAlign>>;

View File

@ -167,7 +167,12 @@ int BitmapComboBox::Append(const wxString& item)
//3. Set this empty bitmap to the at list one item and BitmapCombobox will be recreated correct
wxBitmap bitmap(1, int(1.6 * wxGetApp().em_unit() + 1));
bitmap.SetWidth(0);
{
// bitmap.SetWidth(0); is depricated now
// so, use next code
bitmap.UnShare();// AllocExclusive();
bitmap.GetGDIImageData()->m_width = 0;
}
OnAddBitmap(bitmap);
const int n = wxComboBox::Append(item);

View File

@ -47,8 +47,7 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
if (config->opt_float("layer_height") < EPSILON)
{
const wxString msg_text = _(L("Layer height is not valid.\n\nThe layer height will be reset to 0.01."));
//wxMessageDialog dialog(nullptr, msg_text, _(L("Layer height")), wxICON_WARNING | wxOK);
MessageDialog dialog(nullptr, msg_text, _(L("Layer height")), wxICON_WARNING | wxOK);
MessageDialog dialog(m_msg_dlg_parent, msg_text, _(L("Layer height")), wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
dialog.ShowModal();
@ -60,8 +59,7 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
if (config->option<ConfigOptionFloatOrPercent>("first_layer_height")->value < EPSILON)
{
const wxString msg_text = _(L("First layer height is not valid.\n\nThe first layer height will be reset to 0.01."));
//wxMessageDialog dialog(nullptr, msg_text, _(L("First layer height")), wxICON_WARNING | wxOK);
MessageDialog dialog(nullptr, msg_text, _(L("First layer height")), wxICON_WARNING | wxOK);
MessageDialog dialog(m_msg_dlg_parent, msg_text, _(L("First layer height")), wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
is_msg_dlg_already_exist = true;
dialog.ShowModal();
@ -90,8 +88,7 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
"- Detect thin walls disabled"));
if (is_global_config)
msg_text += "\n\n" + _(L("Shall I adjust those settings in order to enable Spiral Vase?"));
//wxMessageDialog dialog(nullptr, msg_text, _(L("Spiral Vase")),
MessageDialog dialog(nullptr, msg_text, _(L("Spiral Vase")),
MessageDialog dialog(m_msg_dlg_parent, msg_text, _(L("Spiral Vase")),
wxICON_WARNING | (is_global_config ? wxYES | wxNO : wxOK));
DynamicPrintConfig new_conf = *config;
auto answer = dialog.ShowModal();
@ -126,8 +123,7 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
"(both support_material_extruder and support_material_interface_extruder need to be set to 0)."));
if (is_global_config)
msg_text += "\n\n" + _(L("Shall I adjust those settings in order to enable the Wipe Tower?"));
//wxMessageDialog dialog (nullptr, msg_text, _(L("Wipe Tower")),
MessageDialog dialog (nullptr, msg_text, _(L("Wipe Tower")),
MessageDialog dialog (m_msg_dlg_parent, msg_text, _(L("Wipe Tower")),
wxICON_WARNING | (is_global_config ? wxYES | wxNO : wxOK));
DynamicPrintConfig new_conf = *config;
auto answer = dialog.ShowModal();
@ -147,8 +143,7 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
"need to be synchronized with the object layers."));
if (is_global_config)
msg_text += "\n\n" + _(L("Shall I synchronize support layers in order to enable the Wipe Tower?"));
//wxMessageDialog dialog(nullptr, msg_text, _(L("Wipe Tower")),
MessageDialog dialog(nullptr, msg_text, _(L("Wipe Tower")),
MessageDialog dialog(m_msg_dlg_parent, msg_text, _(L("Wipe Tower")),
wxICON_WARNING | (is_global_config ? wxYES | wxNO : wxOK));
DynamicPrintConfig new_conf = *config;
auto answer = dialog.ShowModal();
@ -169,7 +164,7 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
"- Detect bridging perimeters"));
if (is_global_config)
msg_text += "\n\n" + _(L("Shall I adjust those settings for supports?"));
MessageDialog dialog(nullptr, msg_text, _L("Support Generator"), wxICON_WARNING | (is_global_config ? wxYES | wxNO : wxOK));
MessageDialog dialog(m_msg_dlg_parent, msg_text, _L("Support Generator"), wxICON_WARNING | (is_global_config ? wxYES | wxNO : wxOK));
DynamicPrintConfig new_conf = *config;
auto answer = dialog.ShowModal();
if (!is_global_config || answer == wxID_YES) {
@ -200,8 +195,7 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
_(fill_pattern_def->enum_labels[it_pattern - fill_pattern_def->enum_values.begin()]));
if (is_global_config)
msg_text += "\n\n" + _L("Shall I switch to rectilinear fill pattern?");
//wxMessageDialog dialog(nullptr, msg_text, _L("Infill"),
MessageDialog dialog(nullptr, msg_text, _L("Infill"),
MessageDialog dialog(m_msg_dlg_parent, msg_text, _L("Infill"),
wxICON_WARNING | (is_global_config ? wxYES | wxNO : wxOK) );
DynamicPrintConfig new_conf = *config;
auto answer = dialog.ShowModal();
@ -331,8 +325,7 @@ void ConfigManipulation::update_print_sla_config(DynamicPrintConfig* config, con
if (head_penetration > head_width) {
wxString msg_text = _(L("Head penetration should not be greater than the head width."));
//wxMessageDialog dialog(nullptr, msg_text, _(L("Invalid Head penetration")), wxICON_WARNING | wxOK);
MessageDialog dialog(nullptr, msg_text, _(L("Invalid Head penetration")), wxICON_WARNING | wxOK);
MessageDialog dialog(m_msg_dlg_parent, msg_text, _(L("Invalid Head penetration")), wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
if (dialog.ShowModal() == wxID_OK) {
new_conf.set_key_value("support_head_penetration", new ConfigOptionFloat(head_width));
@ -345,8 +338,7 @@ void ConfigManipulation::update_print_sla_config(DynamicPrintConfig* config, con
if (pinhead_d > pillar_d) {
wxString msg_text = _(L("Pinhead diameter should be smaller than the pillar diameter."));
//wxMessageDialog dialog(nullptr, msg_text, _(L("Invalid pinhead diameter")), wxICON_WARNING | wxOK);
MessageDialog dialog(nullptr, msg_text, _(L("Invalid pinhead diameter")), wxICON_WARNING | wxOK);
MessageDialog dialog(m_msg_dlg_parent, msg_text, _(L("Invalid pinhead diameter")), wxICON_WARNING | wxOK);
DynamicPrintConfig new_conf = *config;
if (dialog.ShowModal() == wxID_OK) {

View File

@ -30,15 +30,18 @@ class ConfigManipulation
// callback to propagation of changed value, if needed
std::function<void(const std::string&, const boost::any&)> cb_value_change = nullptr;
ModelConfig* local_config = nullptr;
wxWindow* m_msg_dlg_parent {nullptr};
public:
ConfigManipulation(std::function<void()> load_config,
std::function<void(const std::string&, bool toggle, int opt_index)> cb_toggle_field,
std::function<void(const std::string&, const boost::any&)> cb_value_change,
ModelConfig* local_config = nullptr) :
ModelConfig* local_config = nullptr,
wxWindow* msg_dlg_parent = nullptr) :
load_config(load_config),
cb_toggle_field(cb_toggle_field),
cb_value_change(cb_value_change),
m_msg_dlg_parent(msg_dlg_parent),
local_config(local_config) {}
ConfigManipulation() {}

View File

@ -2713,7 +2713,9 @@ bool ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
// if unsaved changes was not cheched till this moment
if (!check_unsaved_preset_changes) {
if ((check_unsaved_preset_changes = !first_added_filament.empty() || !first_added_sla_material.empty())) {
header = format_wxstr(_L("A new %1% was installed and it will be activated."), !first_added_filament.empty() ? _L("Filament") : _L("SLA material"));
header = !first_added_filament.empty() ?
_L("A new filament was installed and it will be activated.") :
_L("A new SLA material was installed and it will be activated.");
if (!wxGetApp().check_and_keep_current_preset_changes(caption, header, act_btns, &apply_keeped_changes))
return false;
}
@ -2721,7 +2723,7 @@ bool ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese
bool is_filaments_changed = app_config->get_section(AppConfig::SECTION_FILAMENTS) != appconfig_new.get_section(AppConfig::SECTION_FILAMENTS);
bool is_sla_materials_changed = app_config->get_section(AppConfig::SECTION_MATERIALS) != appconfig_new.get_section(AppConfig::SECTION_MATERIALS);
if ((check_unsaved_preset_changes = is_filaments_changed || is_sla_materials_changed)) {
header = format_wxstr(_L("Some %1% were uninstalled."), is_filaments_changed ? _L("Filaments") : _L("SLA materials"));
header = is_filaments_changed ? _L("Some filaments were uninstalled.") : _L("Some SLA materials were uninstalled.");
if (!wxGetApp().check_and_keep_current_preset_changes(caption, header, act_btns, &apply_keeped_changes))
return false;
}

View File

@ -1407,8 +1407,8 @@ wxString Control::get_tooltip(int tick/*=-1*/)
if (tick_code_it == m_ticks.ticks.end() && m_focus == fiActionIcon) // tick doesn't exist
{
if (m_draw_mode == dmSequentialFffPrint)
return _L("The sequential print is on.\n"
"It's impossible to apply any custom G-code for objects printing sequentually.\n");
return (_L("The sequential print is on.\n"
"It's impossible to apply any custom G-code for objects printing sequentually.") + "\n");
// Show mode as a first string of tooltop
tooltip = " " + _L("Print mode") + ": ";

Some files were not shown because too many files have changed in this diff Show More