Compare commits
141 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4f6c80a43 | ||
|
|
ee237cfc16 | ||
|
|
a9889b297e | ||
|
|
508ba0444c | ||
|
|
090eebdabc | ||
|
|
5368acee65 | ||
|
|
c2b5393b82 | ||
|
|
4404fdc03c | ||
|
|
8c0b581581 | ||
|
|
96b64539e2 | ||
|
|
e768b990a8 | ||
|
|
a2ddbe8eb4 | ||
|
|
a3e0809506 | ||
|
|
b13c47456b | ||
|
|
6121002516 | ||
|
|
8fa61058d4 | ||
|
|
0053429d72 | ||
|
|
da44f549e1 | ||
|
|
04ad174e91 | ||
|
|
9c52fb3733 | ||
|
|
128a023c41 | ||
|
|
b9452a91a2 | ||
|
|
cc68470ac8 | ||
|
|
0de9767ff0 | ||
|
|
3217389d20 | ||
|
|
05d820c13d | ||
|
|
68553eba55 | ||
|
|
6e4ada127d | ||
|
|
4d2d510050 | ||
|
|
825c980cef | ||
|
|
2a46a2f415 | ||
|
|
ea3407798b | ||
|
|
9917cfeb69 | ||
|
|
d06a7dfa89 | ||
|
|
ecde3d5864 | ||
|
|
446c2c4e75 | ||
|
|
2466489049 | ||
|
|
b9997e7ee2 | ||
|
|
b6d7c8a367 | ||
|
|
05e2b540ab | ||
|
|
0491f84149 | ||
|
|
88c9efa548 | ||
|
|
e6a64eb5cb | ||
|
|
a630648563 | ||
|
|
d884ef371d | ||
|
|
2f86351eab | ||
|
|
eeeb2a5437 | ||
|
|
8153dcc1b1 | ||
|
|
65a85dae84 | ||
|
|
2b269ea194 | ||
|
|
63f899f4a5 | ||
|
|
4d6feb71b9 | ||
|
|
d783651751 | ||
|
|
9b04886c3a | ||
|
|
3a99562743 | ||
|
|
5183107d79 | ||
|
|
8c672c53c7 | ||
|
|
3039c76417 | ||
|
|
f33a08f704 | ||
|
|
5ccb55ff98 | ||
|
|
764ce01063 | ||
|
|
58e2343a2e | ||
|
|
6485825ad8 | ||
|
|
2387bc9cdb | ||
|
|
63daf0c087 | ||
|
|
516d3a3313 | ||
|
|
470b3a19ed | ||
|
|
759c6732b8 | ||
|
|
c31585e5ba | ||
|
|
8cca851e84 | ||
|
|
00718edfa7 | ||
|
|
f82a8a4ca1 | ||
|
|
4407c9eb62 | ||
|
|
74f7fce027 | ||
|
|
354224679e | ||
|
|
92119cf9f5 | ||
|
|
0401c46f99 | ||
|
|
9d43e47a54 | ||
|
|
354ae2e282 | ||
|
|
4ffa594874 | ||
|
|
e795f88c09 | ||
|
|
e7028531e0 | ||
|
|
0d1dd29341 | ||
|
|
c56cfdb727 | ||
|
|
bfc036deae | ||
|
|
87ab8bd8dd | ||
|
|
ce3ad490b7 | ||
|
|
74d0317dd0 | ||
|
|
1c9ce7ec05 | ||
|
|
2a8cdc3414 | ||
|
|
cea37f9f7d | ||
|
|
48ed13e6f1 | ||
|
|
7a7fb7da00 | ||
|
|
02857e3fd8 | ||
|
|
8cb30a7329 | ||
|
|
1fc08d237c | ||
|
|
ee616bbbb6 | ||
|
|
30e9b00baf | ||
|
|
172b1893e2 | ||
|
|
04b1c22cc6 | ||
|
|
2046b2f21f | ||
|
|
1eb7e979b0 | ||
|
|
82f75eb146 | ||
|
|
7c6e614b3b | ||
|
|
76aaf50055 | ||
|
|
d76b009f40 | ||
|
|
ca4f336d62 | ||
|
|
9856ad7031 | ||
|
|
f6271b0c90 | ||
|
|
bc68a07f47 | ||
|
|
ec446edb36 | ||
|
|
4c3e3eea6d | ||
|
|
4bdbc32044 | ||
|
|
4888f01b47 | ||
|
|
428388b804 | ||
|
|
576389430c | ||
|
|
2b0652398d | ||
|
|
aa6efa280d | ||
|
|
8c016acf83 | ||
|
|
4983297dee | ||
|
|
e0dd4753c0 | ||
|
|
bb3884101f | ||
|
|
f155e1c167 | ||
|
|
a50473f8a9 | ||
|
|
b6f5986a9a | ||
|
|
821eb8ebe9 | ||
|
|
2eecb1ce8a | ||
|
|
12da7dac6a | ||
|
|
83c42c3d4f | ||
|
|
bf9dbfae79 | ||
|
|
5bba8ccb1b | ||
|
|
8de170e272 | ||
|
|
ec37905b75 | ||
|
|
c564e62549 | ||
|
|
eba6ab9ac1 | ||
|
|
abbe9d06df | ||
|
|
0b6f75c9dc | ||
|
|
2f7a8a7568 | ||
|
|
b7625edc45 | ||
|
|
6a26320804 | ||
|
|
8f7e2169c4 |
1
.gitignore
vendored
@@ -12,7 +12,6 @@ xs/MANIFEST.bak
|
||||
xs/assertlib*
|
||||
.init_bundle.ini
|
||||
.vs/*
|
||||
local-lib
|
||||
/src/TAGS
|
||||
/.vscode/
|
||||
build-linux/*
|
||||
|
||||
132
Build.PL
@@ -1,132 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
print "This script is currently used for installing Perl dependenices for running\n";
|
||||
print "the libslic3r unit / integration tests through Perl prove.\n";
|
||||
print "If you don't plan to run the unit / integration tests, you don't need to\n";
|
||||
print "install these dependencies to build and run QIDISlicer.\n";
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Config;
|
||||
use File::Spec;
|
||||
|
||||
my %prereqs = qw(
|
||||
Devel::CheckLib 0
|
||||
ExtUtils::MakeMaker 6.80
|
||||
ExtUtils::ParseXS 3.22
|
||||
ExtUtils::XSpp 0
|
||||
ExtUtils::XSpp::Cmd 0
|
||||
ExtUtils::CppGuess 0
|
||||
ExtUtils::Typemaps 0
|
||||
ExtUtils::Typemaps::Basic 0
|
||||
File::Basename 0
|
||||
File::Spec 0
|
||||
Getopt::Long 0
|
||||
Module::Build::WithXSpp 0.14
|
||||
Moo 1.003001
|
||||
POSIX 0
|
||||
Scalar::Util 0
|
||||
Test::More 0
|
||||
IO::Scalar 0
|
||||
Time::HiRes 0
|
||||
);
|
||||
my %recommends = qw(
|
||||
Class::XSAccessor 0
|
||||
Test::Harness 0
|
||||
);
|
||||
|
||||
my $sudo = grep { $_ eq '--sudo' } @ARGV;
|
||||
my $nolocal = grep { $_ eq '--nolocal' } @ARGV;
|
||||
|
||||
my @missing_prereqs = ();
|
||||
if ($ENV{SLIC3R_NO_AUTO}) {
|
||||
foreach my $module (sort keys %prereqs) {
|
||||
my $version = $prereqs{$module};
|
||||
next if eval "use $module $version; 1";
|
||||
push @missing_prereqs, $module if exists $prereqs{$module};
|
||||
print "Missing prerequisite $module $version\n";
|
||||
}
|
||||
foreach my $module (sort keys %recommends) {
|
||||
my $version = $recommends{$module};
|
||||
next if eval "use $module $version; 1";
|
||||
print "Missing optional $module $version\n";
|
||||
}
|
||||
} else {
|
||||
my @try = (
|
||||
$ENV{CPANM} // (),
|
||||
File::Spec->catfile($Config{sitebin}, 'cpanm'),
|
||||
File::Spec->catfile($Config{installscript}, 'cpanm'),
|
||||
);
|
||||
|
||||
my $cpanm;
|
||||
foreach my $path (@try) {
|
||||
if (-e $path) { # don't use -x because it fails on Windows
|
||||
$cpanm = $path;
|
||||
last;
|
||||
}
|
||||
}
|
||||
if (!$cpanm) {
|
||||
if ($^O =~ /^(?:darwin|linux)$/ && system(qw(which cpanm)) == 0) {
|
||||
$cpanm = 'cpanm';
|
||||
}
|
||||
}
|
||||
die <<'EOF'
|
||||
cpanm was not found. Please install it before running this script.
|
||||
|
||||
There are several ways to install cpanm, try one of these:
|
||||
|
||||
apt-get install cpanminus
|
||||
curl -L http://cpanmin.us | perl - --sudo App::cpanminus
|
||||
cpan App::cpanminus
|
||||
|
||||
If it is installed in a non-standard location you can do:
|
||||
|
||||
CPANM=/path/to/cpanm perl Build.PL
|
||||
|
||||
EOF
|
||||
if !$cpanm;
|
||||
my @cpanm_args = ();
|
||||
push @cpanm_args, "--sudo" if $sudo;
|
||||
|
||||
# install local::lib without --local-lib otherwise it's not usable afterwards
|
||||
if (!eval "use local::lib qw(local-lib); 1") {
|
||||
my $res = system $cpanm, @cpanm_args, 'local::lib';
|
||||
warn "Warning: local::lib is required. You might need to run the `cpanm --sudo local::lib` command in order to install it.\n"
|
||||
if $res != 0;
|
||||
}
|
||||
|
||||
push @cpanm_args, ('--local-lib', 'local-lib') if ! $nolocal;
|
||||
|
||||
# make sure our cpanm is updated (old ones don't support the ~ syntax)
|
||||
system $cpanm, @cpanm_args, 'App::cpanminus';
|
||||
|
||||
my %modules = (%prereqs, %recommends);
|
||||
foreach my $module (sort keys %modules) {
|
||||
my $version = $modules{$module};
|
||||
my @cmd = ($cpanm, @cpanm_args);
|
||||
|
||||
# temporary workaround for upstream bug in test
|
||||
push @cmd, '--notest'
|
||||
if $module =~ /^(?:OpenGL|Test::Harness)$/;
|
||||
|
||||
push @cmd, "$module~$version";
|
||||
|
||||
my $res = system @cmd;
|
||||
if ($res != 0) {
|
||||
if (exists $prereqs{$module}) {
|
||||
push @missing_prereqs, $module;
|
||||
} else {
|
||||
printf "Don't worry, this module is optional.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "\n";
|
||||
print "In the next step, you need to build the QIDISlicer C++ library.\n";
|
||||
print "1) Create a build directory and change to it\n";
|
||||
print "2) run cmake .. -DCMAKE_BUILD_TYPE=Release\n";
|
||||
print "3) run make\n";
|
||||
print "4) to execute the automatic tests, run ctest --verbose\n";
|
||||
__END__
|
||||
@@ -29,7 +29,6 @@ option(SLIC3R_FHS "Assume QIDISlicer is to be installed in a FHS d
|
||||
option(SLIC3R_PCH "Use precompiled headers" 1)
|
||||
option(SLIC3R_MSVC_COMPILE_PARALLEL "Compile on Visual Studio in parallel" 1)
|
||||
option(SLIC3R_MSVC_PDB "Generate PDB files on MSVC in Release mode" 1)
|
||||
option(SLIC3R_PERL_XS "Compile XS Perl module and enable Perl unit and integration tests" 0)
|
||||
option(SLIC3R_ASAN "Enable ASan on Clang and GCC" 0)
|
||||
option(SLIC3R_UBSAN "Enable UBSan on Clang and GCC" 0)
|
||||
option(SLIC3R_ENABLE_FORMAT_STEP "Enable compilation of STEP file support" ON)
|
||||
@@ -72,7 +71,6 @@ option(SLIC3R_BUILD_TESTS "Build unit tests" ON)
|
||||
|
||||
if (IS_CROSS_COMPILE)
|
||||
message("Detected cross compilation setup. Tests and encoding checks will be forcedly disabled!")
|
||||
set(SLIC3R_PERL_XS OFF CACHE BOOL "" FORCE)
|
||||
set(SLIC3R_BUILD_TESTS OFF CACHE BOOL "" FORCE)
|
||||
endif ()
|
||||
|
||||
@@ -165,9 +163,6 @@ if(NOT WIN32)
|
||||
add_compile_options("$<$<CONFIG:DEBUG>:-DDEBUG>")
|
||||
endif()
|
||||
|
||||
# To be able to link libslic3r with the Perl XS module.
|
||||
# Once we get rid of Perl and libslic3r is linked statically, we can get rid of -fPIC
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
# WIN10SDK_PATH is used to point CMake to the WIN10 SDK installation directory.
|
||||
# We pick it from environment if it is not defined in another way
|
||||
@@ -608,12 +603,6 @@ set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Q
|
||||
|
||||
add_dependencies(gettext_make_pot hintsToPot)
|
||||
|
||||
# Perl bindings, currently only used for the unit / integration tests of libslic3r.
|
||||
# Also runs the unit / integration tests.
|
||||
#FIXME Port the tests into C++ to finally get rid of the Perl!
|
||||
if (SLIC3R_PERL_XS)
|
||||
add_subdirectory(xs)
|
||||
endif ()
|
||||
|
||||
if(SLIC3R_BUILD_SANDBOXES)
|
||||
add_subdirectory(sandboxes)
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
{
|
||||
"build_systems":
|
||||
[
|
||||
{
|
||||
"name": "List",
|
||||
//"file_regex": " at ([^-\\s]*) line ([0-9]*)",
|
||||
// "file_regex": " at (D\\:\\/src\\/Slic3r\\/.*?) line ([0-9]*)",
|
||||
"shell_cmd": "ls -l"
|
||||
},
|
||||
{
|
||||
"name": "Run",
|
||||
"working_dir": "$project_path",
|
||||
"file_regex": " at (.*?) line ([0-9]*)",
|
||||
// "shell_cmd": "chdir & perl slic3r.pl --DataDir \"C:\\Users\\Public\\Documents\\QIDI3D\\Slic3r settings MK2\" --gui \"..\\Slic3r-tests\\gap fill torture 20 -rt.stl\""
|
||||
"shell_cmd": "chdir & perl slic3r.pl"
|
||||
},
|
||||
{
|
||||
"name": "full",
|
||||
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
|
||||
"shell_cmd": "chdir & perl Build.pl"
|
||||
},
|
||||
{
|
||||
"name": "xs",
|
||||
"working_dir": "$project_path/build",
|
||||
// for Visual Studio:
|
||||
"file_regex": "^(..[^:]*)\\(([0-9]+)\\)(.*)$",
|
||||
// For GCC:
|
||||
// "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
|
||||
"shell_cmd": "chdir & ninja -j 6 -v",
|
||||
"env": {
|
||||
// "PATH": "C:\\Program Files (x86)\\MSBuild\\12.0\\bin\\amd64;C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\BIN\\amd64;C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE;C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\Tools;%PATH%;c:\\wperl64d\\site\\bin;c:\\wperl64d\\bin",
|
||||
// "PERL_CPANM_HOME": "c:\\wperl64d\\cpanm",
|
||||
// "WXDIR": "D:\\src-perl\\wxWidgets-3.0.3-beta1",
|
||||
// "BOOST_DIR": "D:\\src-perl\\boost_1_61_0",
|
||||
// "BOOST_INCLUDEDIR": "D:\\src-perl\\boost_1_61_0",
|
||||
// "BOOST_LIBRARYDIR": "D:\\src-perl\\boost_1_61_0\\stage\\x64\\lib",
|
||||
// "SLIC3R_STATIC": "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "xs & run",
|
||||
"working_dir": "$project_path/build",
|
||||
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
|
||||
"shell_cmd": "chdir & ninja -j 6 & cd .. & perl slic3r.pl --gui \"..\\Slic3r-tests\\star3-big2.stl\""
|
||||
},
|
||||
{
|
||||
"name": "Slic3r - clean",
|
||||
"working_dir": "$project_path/build",
|
||||
"file_regex": "^(..[^:]*)(?::|\\()([0-9]+)(?::|\\))(?:([0-9]+):)?\\s*(.*)",
|
||||
"shell_cmd": ["chdir & ninja clean"]
|
||||
},
|
||||
{
|
||||
"name": "run tests",
|
||||
"working_dir": "$project_path/build",
|
||||
// for Visual Studio:
|
||||
"file_regex": "^(..[^:]*)\\(([0-9]+)\\)(.*)$",
|
||||
"shell_cmd": "chdir & ctest --verbose"
|
||||
},
|
||||
{
|
||||
"name": "Clean & Configure",
|
||||
"working_dir": "$project_path",
|
||||
// for Visual Studio:
|
||||
"file_regex": "^(..[^:]*)(?::|\\()([0-9]+)(?::|\\))(?:([0-9]+):)?\\s*(.*)",
|
||||
"shell_cmd": "chdir & rmdir /S /Q build & mkdir build & cd build & cmake -G Ninja .. -DCMAKE_COLOR_MAKEFILE=OFF -DCMAKE_RULE_PROGRESS=OFF -DCMAKE_RULE_MESSAGES=OFF -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo"
|
||||
},
|
||||
{
|
||||
"name": "Configure",
|
||||
"working_dir": "$project_path/build",
|
||||
// for Visual Studio:
|
||||
"file_regex": "^(..[^:]*)(?::|\\()([0-9]+)(?::|\\))(?:([0-9]+):)?\\s*(.*)",
|
||||
"shell_cmd": "cmake -G Ninja .. -DCMAKE_COLOR_MAKEFILE=OFF -DCMAKE_RULE_PROGRESS=OFF -DCMAKE_RULE_MESSAGES=OFF -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo"
|
||||
}
|
||||
],
|
||||
"folders":
|
||||
[
|
||||
{
|
||||
"path": ".",
|
||||
// "folder_exclude_patterns": [".svn", "._d", ".metadata", ".settings"],
|
||||
"file_exclude_patterns": ["XS.c", "*.pch", "*.ilk", "*.js" ]
|
||||
}
|
||||
],
|
||||
|
||||
"settings":
|
||||
{
|
||||
"sublimegdb_workingdir": "${folder:${project_path:run}}",
|
||||
// NOTE: You MUST provide --interpreter=mi for the plugin to work
|
||||
// "sublimegdb_commandline": "D:\\Qt\\Tools\\mingw492_32\\bin\\gdb.exe --interpreter=mi -ex 'target localhost:2345'",
|
||||
// "sublimegdb_commandline": "D:\\Qt\\Tools\\mingw492_32\\bin\\gdb.exe --interpreter=mi perl --args perl slic3r.pl",
|
||||
// "sublimegdb_commandline": "D:\\Qt\\Tools\\mingw492_32\\bin\\gdb.exe --interpreter=mi perl --args slic3r.pl ",
|
||||
// "sublimegdb_commandline": "D:\\Qt\\Tools\\mingw492_32\\bin\\gdb.exe --interpreter=mi -e C:\\Strawberry\\perl\\bin\\perl.exe -s C:\\Strawberry\\perl\\site\\lib\\auto\\Slic3r\\XS\\XS.xs.dll --args perl slic3r.pl -j 1 --gui D:\\src\\Slic3r-tests\\star3-big.stl",
|
||||
"sublimegdb_commandline": "D:\\Qt\\Tools\\mingw492_32\\bin\\gdb.exe --interpreter=mi perl.exe --args perl slic3r.pl -j 1 --gui", // D:\\src\\Slic3r-tests\\star3-big.stl",
|
||||
// "sublimegdb_commandline": "D:\\Qt\\Tools\\mingw492_32\\bin\\gdb.exe --interpreter=mi -x slic3r.gdb",
|
||||
// "arguments": "slic3r -j 1 --gui ../Slic3r-tests/star3-big.stl",
|
||||
// "arguments": "../slic3r.pl -j 1 --gui",
|
||||
// "sublimegdb_exec_cmd": "-exec-continue",
|
||||
|
||||
// Add "pending breakpoints" for symbols that are dynamically loaded from
|
||||
// external shared libraries
|
||||
"debug_ext" : true,
|
||||
"run_after_init": false,
|
||||
"close_views": false
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@ See the [QIDI's homepage](https://qidi3d.com) for more information.
|
||||
|
||||
You can find the printer's firmware here:
|
||||
|
||||
[Q1 Pro](https://github.com/QIDITECH/QIDI_Q1_Pro)
|
||||
|
||||
[X-MAX 3](https://github.com/QIDITECH/QIDI_MAX3)
|
||||
|
||||
[X-Plus 3](https://github.com/QIDITECH/QIDI_PLUS3)
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
# Find the wxWidgets module based on the information provided by the Perl Alien::wxWidgets module.
|
||||
|
||||
# Check for the Perl & PerlLib modules
|
||||
include(LibFindMacros)
|
||||
libfind_package(AlienWx Perl)
|
||||
libfind_package(AlienWx PerlLibs)
|
||||
|
||||
if (AlienWx_DEBUG)
|
||||
message(STATUS " AlienWx_FIND_COMPONENTS=${AlienWx_FIND_COMPONENTS}")
|
||||
endif()
|
||||
|
||||
# Execute an Alien::Wx module to find the relevant information regarding
|
||||
# the wxWidgets used by the Perl interpreter.
|
||||
# Perl specific stuff
|
||||
set(AlienWx_TEMP_INCLUDE ${CMAKE_CURRENT_BINARY_DIR}/AlienWx_TEMP_INCLUDE.txt)
|
||||
execute_process(
|
||||
COMMAND ${PERL_EXECUTABLE} -e "
|
||||
# Import Perl modules.
|
||||
use strict;
|
||||
use warnings;
|
||||
use Text::ParseWords;
|
||||
|
||||
BEGIN {
|
||||
# CMake sets the environment variables CC and CXX to the detected C compiler.
|
||||
# There is an issue with the Perl ExtUtils::CBuilder, which does not handle whitespaces
|
||||
# in the paths correctly on Windows, so we rather drop the CMake auto-detected paths.
|
||||
delete \$ENV{CC};
|
||||
delete \$ENV{CXX};
|
||||
}
|
||||
|
||||
use Alien::wxWidgets;
|
||||
use ExtUtils::CppGuess;
|
||||
|
||||
# Test for a Visual Studio compiler
|
||||
my \$cpp_guess = ExtUtils::CppGuess->new;
|
||||
my \$mswin = \$^O eq 'MSWin32';
|
||||
my \$msvc = \$cpp_guess->is_msvc;
|
||||
|
||||
# List of wxWidgets components to be used.
|
||||
my @components = split /;/, '${AlienWx_FIND_COMPONENTS}';
|
||||
|
||||
# Query the available data from Alien::wxWidgets.
|
||||
my \$version = Alien::wxWidgets->version;
|
||||
my \$config = Alien::wxWidgets->config;
|
||||
my \$compiler = Alien::wxWidgets->compiler;
|
||||
my \$linker = Alien::wxWidgets->linker;
|
||||
my \$include_path = ' ' . Alien::wxWidgets->include_path;
|
||||
my \$defines = ' ' . Alien::wxWidgets->defines;
|
||||
my \$cflags = Alien::wxWidgets->c_flags;
|
||||
my \$linkflags = Alien::wxWidgets->link_flags;
|
||||
my \$libraries = ' ' . Alien::wxWidgets->libraries(@components);
|
||||
my \$gui_toolkit = Alien::wxWidgets->config->{toolkit};
|
||||
#my @libraries = Alien::wxWidgets->link_libraries(@components);
|
||||
#my @implib = Alien::wxWidgets->import_libraries(@components);
|
||||
#my @shrlib = Alien::wxWidgets->shared_libraries(@components);
|
||||
#my @keys = Alien::wxWidgets->library_keys; # 'gl', 'adv', ...
|
||||
#my \$library_path = Alien::wxWidgets->shared_library_path;
|
||||
#my \$key = Alien::wxWidgets->key;
|
||||
#my \$prefix = Alien::wxWidgets->prefix;
|
||||
|
||||
my \$filename = '${AlienWx_TEMP_INCLUDE}';
|
||||
open(my $fh, '>', \$filename) or die \"Could not open file '\$filename' \$!\";
|
||||
|
||||
# Convert a space separated lists to CMake semicolon separated lists,
|
||||
# escape the backslashes,
|
||||
# export the resulting list to a temp file.
|
||||
sub cmake_set_var {
|
||||
my (\$varname, \$content) = @_;
|
||||
# Remove line separators.
|
||||
\$content =~ s/\\r|\\n//g;
|
||||
# Escape the path separators.
|
||||
\$content =~ s/\\\\/\\\\\\\\\\\\\\\\/g;
|
||||
my @words = shellwords(\$content);
|
||||
print \$fh \"set(AlienWx_\$varname \\\"\" . join(';', @words) . \"\\\")\\n\";
|
||||
}
|
||||
cmake_set_var('VERSION', \$version);
|
||||
\$include_path =~ s/ -I/ /g;
|
||||
cmake_set_var('INCLUDE_DIRS', \$include_path);
|
||||
\$libraries =~ s/ -L/ -LIBPATH:/g if \$msvc;
|
||||
cmake_set_var('LIBRARIES', \$libraries);
|
||||
#cmake_set_var('LIBRARY_DIRS', );
|
||||
#\$defines =~ s/ -D/ /g;
|
||||
cmake_set_var('DEFINITIONS', \$defines);
|
||||
#cmake_set_var('DEFINITIONS_DEBUG', );
|
||||
cmake_set_var('CXX_FLAGS', \$cflags);
|
||||
cmake_set_var('GUI_TOOLKIT', \$gui_toolkit);
|
||||
close \$fh;
|
||||
")
|
||||
include(${AlienWx_TEMP_INCLUDE})
|
||||
file(REMOVE ${AlienWx_TEMP_INCLUDE})
|
||||
unset(AlienWx_TEMP_INCLUDE)
|
||||
|
||||
if (AlienWx_DEBUG)
|
||||
message(STATUS " AlienWx_VERSION = ${AlienWx_VERSION}")
|
||||
message(STATUS " AlienWx_INCLUDE_DIRS = ${AlienWx_INCLUDE_DIRS}")
|
||||
message(STATUS " AlienWx_LIBRARIES = ${AlienWx_LIBRARIES}")
|
||||
message(STATUS " AlienWx_LIBRARY_DIRS = ${AlienWx_LIBRARY_DIRS}")
|
||||
message(STATUS " AlienWx_DEFINITIONS = ${AlienWx_DEFINITIONS}")
|
||||
message(STATUS " AlienWx_DEFINITIONS_DEBUG = ${AlienWx_DEFINITIONS_DEBUG}")
|
||||
message(STATUS " AlienWx_CXX_FLAGS = ${AlienWx_CXX_FLAGS}")
|
||||
message(STATUS " AlienWx_GUI_TOOLKIT = ${AlienWx_GUI_TOOLKIT}")
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(AlienWx
|
||||
REQUIRED_VARS AlienWx_INCLUDE_DIRS AlienWx_LIBRARIES
|
||||
# HANDLE_COMPONENTS
|
||||
VERSION_VAR AlienWx_VERSION)
|
||||
@@ -1,88 +0,0 @@
|
||||
# Find the dependencies for linking with the Perl runtime library.
|
||||
|
||||
# Check for the Perl & PerlLib modules
|
||||
include(LibFindMacros)
|
||||
libfind_package(PerlEmbed Perl)
|
||||
libfind_package(PerlEmbed PerlLibs)
|
||||
|
||||
# Execute an Alien::Wx module to find the relevant information regarding
|
||||
# the wxWidgets used by the Perl interpreter.
|
||||
# Perl specific stuff
|
||||
set(PerlEmbed_TEMP_INCLUDE ${CMAKE_CURRENT_BINARY_DIR}/PerlEmbed_TEMP_INCLUDE.txt)
|
||||
execute_process(
|
||||
COMMAND ${PERL_EXECUTABLE} -MExtUtils::Embed -e "
|
||||
# Import Perl modules.
|
||||
use strict;
|
||||
use warnings;
|
||||
use Config;
|
||||
use Text::ParseWords;
|
||||
use ExtUtils::CppGuess;
|
||||
|
||||
# Test for a Visual Studio compiler
|
||||
my \$cpp_guess = ExtUtils::CppGuess->new;
|
||||
my \$mswin = \$^O eq 'MSWin32';
|
||||
my \$msvc = \$cpp_guess->is_msvc;
|
||||
|
||||
# Query the available data from Alien::wxWidgets.
|
||||
my \$ccflags;
|
||||
my \$ldflags;
|
||||
{ local *STDOUT; open STDOUT, '>', \\\$ccflags; ccflags; }
|
||||
{ local *STDOUT; open STDOUT, '>', \\\$ldflags; ldopts; }
|
||||
\$ccflags = ' ' . \$ccflags;
|
||||
\$ldflags = ' ' . \$ldflags;
|
||||
|
||||
my \$filename = '${PerlEmbed_TEMP_INCLUDE}';
|
||||
open(my $fh, '>', \$filename) or die \"Could not open file '\$filename' \$!\";
|
||||
|
||||
# Convert a space separated lists to CMake semicolon separated lists,
|
||||
# escape the backslashes,
|
||||
# export the resulting list to a temp file.
|
||||
sub cmake_set_var {
|
||||
my (\$varname, \$content) = @_;
|
||||
# Remove line separators.
|
||||
\$content =~ s/\\r|\\n//g;
|
||||
# Escape the path separators.
|
||||
\$content =~ s/\\\\/\\\\\\\\\\\\\\\\/g;
|
||||
my @words = shellwords(\$content);
|
||||
print \$fh \"set(PerlEmbed_\$varname \\\"\" . join(';', @words) . \"\\\")\\n\";
|
||||
}
|
||||
cmake_set_var('ARCHNAME', \$Config{archname});
|
||||
cmake_set_var('CCFLAGS', \$ccflags);
|
||||
\$ldflags =~ s/ -L/ -LIBPATH:/g if \$msvc;
|
||||
cmake_set_var('LD', \$Config{ld});
|
||||
cmake_set_var('LDFLAGS', \$ldflags);
|
||||
cmake_set_var('CCCDLFLAGS', \$Config{cccdlflags});
|
||||
cmake_set_var('LDDLFLAGS', \$Config{lddlflags});
|
||||
cmake_set_var('DLEXT', \$Config{dlext});
|
||||
close \$fh;
|
||||
")
|
||||
include(${PerlEmbed_TEMP_INCLUDE})
|
||||
file(REMOVE ${PerlEmbed_TEMP_INCLUDE})
|
||||
unset(PerlEmbed_TEMP_INCLUDE)
|
||||
|
||||
if (PerlEmbed_DEBUG)
|
||||
# First show the configuration extracted by FindPerl & FindPerlLibs:
|
||||
message(STATUS " PERL_INCLUDE_PATH = ${PERL_INCLUDE_PATH}")
|
||||
message(STATUS " PERL_LIBRARY = ${PERL_LIBRARY}")
|
||||
message(STATUS " PERL_EXECUTABLE = ${PERL_EXECUTABLE}")
|
||||
message(STATUS " PERL_SITESEARCH = ${PERL_SITESEARCH}")
|
||||
message(STATUS " PERL_SITELIB = ${PERL_SITELIB}")
|
||||
message(STATUS " PERL_VENDORARCH = ${PERL_VENDORARCH}")
|
||||
message(STATUS " PERL_VENDORLIB = ${PERL_VENDORLIB}")
|
||||
message(STATUS " PERL_ARCHLIB = ${PERL_ARCHLIB}")
|
||||
message(STATUS " PERL_PRIVLIB = ${PERL_PRIVLIB}")
|
||||
message(STATUS " PERL_EXTRA_C_FLAGS = ${PERL_EXTRA_C_FLAGS}")
|
||||
# Second show the configuration extracted by this module (FindPerlEmbed):
|
||||
message(STATUS " PerlEmbed_ARCHNAME = ${PerlEmbed_ARCHNAME}")
|
||||
message(STATUS " PerlEmbed_CCFLAGS = ${PerlEmbed_CCFLAGS}")
|
||||
message(STATUS " PerlEmbed_CCCDLFLAGS = ${PerlEmbed_CCCDLFLAGS}")
|
||||
message(STATUS " LD = ${PerlEmbed_LD}")
|
||||
message(STATUS " PerlEmbed_LDFLAGS = ${PerlEmbed_LDFLAGS}")
|
||||
message(STATUS " PerlEmbed_LDDLFLAGS = ${PerlEmbed_LDDLFLAGS}")
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(PerlEmbed
|
||||
REQUIRED_VARS PerlEmbed_CCFLAGS PerlEmbed_LDFLAGS
|
||||
VERSION_VAR PERL_VERSION)
|
||||
5
deps/+LibBGCode/LibBGCode.cmake
vendored
@@ -1,9 +1,8 @@
|
||||
set(LibBGCode_SOURCE_DIR "" CACHE PATH "Optionally specify local LibBGCode source directory")
|
||||
|
||||
set(_source_dir_line
|
||||
URL https://github.com/prusa3d/libbgcode/archive/bc390aab4427589a6402b4c7f65cf4d0a8f987ec.zip
|
||||
URL_HASH SHA256=0c86cb67232089728233014f937e2a07d133a61e31dd8811a9c905e563a49f24
|
||||
)
|
||||
URL https://github.com/prusa3d/libbgcode/archive/6f43cb004ef3d3bda37dde49f6235e24d2717629.zip
|
||||
URL_HASH SHA256=eb5198caecb6a693a294af6a56c37b0adb1eb159a34a9c3116970b80659ee9f9)
|
||||
|
||||
if (LibBGCode_SOURCE_DIR)
|
||||
set(_source_dir_line "SOURCE_DIR;${LibBGCode_SOURCE_DIR};BUILD_ALWAYS;ON")
|
||||
|
||||
2
deps/+OpenVDB/OpenVDB.cmake
vendored
@@ -15,7 +15,7 @@ endif ()
|
||||
|
||||
add_cmake_project(OpenVDB
|
||||
# 8.2 patched
|
||||
URL https://github.com/tamasmeszaros/openvdb/archive/a68fd58d0e2b85f01adeb8b13d7555183ab10aa5.zip
|
||||
URL https://github.com/prusa3d/openvdb/archive/a68fd58d0e2b85f01adeb8b13d7555183ab10aa5.zip
|
||||
URL_HASH SHA256=f353e7b99bd0cbfc27ac9082de51acf32a8bc0b3e21ff9661ecca6f205ec1d81
|
||||
CMAKE_ARGS
|
||||
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
# This package loads all the non-GUI Slic3r perl packages.
|
||||
|
||||
package Slic3r;
|
||||
|
||||
# Copyright holder: Alessandro Ranellucci
|
||||
# This application is licensed under the GNU Affero General Public License, version 3
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Config;
|
||||
require v5.10;
|
||||
|
||||
our $VERSION = VERSION();
|
||||
our $BUILD = BUILD();
|
||||
our $FORK_NAME = FORK_NAME();
|
||||
|
||||
our $debug = 0;
|
||||
sub debugf {
|
||||
printf @_ if $debug;
|
||||
}
|
||||
|
||||
our $loglevel = 0;
|
||||
|
||||
BEGIN {
|
||||
$debug = 1 if (defined($ENV{'SLIC3R_DEBUGOUT'}) && $ENV{'SLIC3R_DEBUGOUT'} == 1);
|
||||
print "Debugging output enabled\n" if $debug;
|
||||
}
|
||||
|
||||
use FindBin;
|
||||
|
||||
use Moo 1.003001;
|
||||
|
||||
use Slic3r::XS; # import all symbols (constants etc.) before they get parsed
|
||||
use Slic3r::Config;
|
||||
use Slic3r::GCode::Reader;
|
||||
use Slic3r::Line;
|
||||
use Slic3r::Model;
|
||||
use Slic3r::Point;
|
||||
use Slic3r::Polygon;
|
||||
use Slic3r::Polyline;
|
||||
our $build = eval "use Slic3r::Build; 1";
|
||||
|
||||
# Scaling between the float and integer coordinates.
|
||||
# Floats are in mm.
|
||||
use constant SCALING_FACTOR => 0.000001;
|
||||
|
||||
# Set the logging level at the Slic3r XS module.
|
||||
$Slic3r::loglevel = (defined($ENV{'SLIC3R_LOGLEVEL'}) && $ENV{'SLIC3R_LOGLEVEL'} =~ /^[1-9]/) ? $ENV{'SLIC3R_LOGLEVEL'} : 0;
|
||||
set_logging_level($Slic3r::loglevel);
|
||||
|
||||
1;
|
||||
@@ -1,32 +0,0 @@
|
||||
# Extends C++ class Slic3r::DynamicPrintConfig
|
||||
# This perl class does not keep any perl class variables,
|
||||
# all the storage is handled by the underlying C++ code.
|
||||
package Slic3r::Config;
|
||||
use strict;
|
||||
use warnings;
|
||||
use utf8;
|
||||
|
||||
use List::Util qw(first max);
|
||||
|
||||
# C++ Slic3r::PrintConfigDef exported as a Perl hash of hashes.
|
||||
# The C++ counterpart is a constant singleton.
|
||||
our $Options = print_config_def();
|
||||
|
||||
# Generate accessors.
|
||||
{
|
||||
no strict 'refs';
|
||||
for my $opt_key (keys %$Options) {
|
||||
*{$opt_key} = sub {
|
||||
#print "Slic3r::Config::accessor $opt_key\n";
|
||||
$_[0]->get($opt_key)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
package Slic3r::Config::Static;
|
||||
use parent 'Slic3r::Config';
|
||||
|
||||
sub Slic3r::Config::GCode::new { Slic3r::Config::Static::new_GCodeConfig }
|
||||
sub Slic3r::Config::Print::new { Slic3r::Config::Static::new_PrintConfig }
|
||||
|
||||
1;
|
||||
@@ -1,90 +0,0 @@
|
||||
# Helper module to parse and interpret a G-code file,
|
||||
# invoking a callback for each move extracted from the G-code.
|
||||
# Currently used by the automatic tests only.
|
||||
package Slic3r::GCode::Reader;
|
||||
use Moo;
|
||||
|
||||
has 'config' => (is => 'ro', default => sub { Slic3r::Config::GCode->new });
|
||||
has 'X' => (is => 'rw', default => sub {0});
|
||||
has 'Y' => (is => 'rw', default => sub {0});
|
||||
has 'Z' => (is => 'rw', default => sub {0});
|
||||
has 'E' => (is => 'rw', default => sub {0});
|
||||
has 'F' => (is => 'rw', default => sub {0});
|
||||
has '_extrusion_axis' => (is => 'rw', default => sub {"E"});
|
||||
|
||||
our $Verbose = 0;
|
||||
my @AXES = qw(X Y Z E);
|
||||
|
||||
sub apply_print_config {
|
||||
my ($self, $print_config) = @_;
|
||||
|
||||
$self->config->apply_static($print_config);
|
||||
$self->_extrusion_axis($self->config->get_extrusion_axis);
|
||||
}
|
||||
|
||||
sub clone {
|
||||
my $self = shift;
|
||||
return (ref $self)->new(
|
||||
map { $_ => $self->$_ } (@AXES, 'F', '_extrusion_axis', 'config'),
|
||||
);
|
||||
}
|
||||
|
||||
sub parse {
|
||||
my $self = shift;
|
||||
my ($gcode, $cb) = @_;
|
||||
|
||||
foreach my $raw_line (split /\R+/, $gcode) {
|
||||
print "$raw_line\n" if $Verbose || $ENV{SLIC3R_TESTS_GCODE};
|
||||
my $line = $raw_line;
|
||||
$line =~ s/\s*;(.*)//; # strip comment
|
||||
my %info = (comment => $1, raw => $raw_line);
|
||||
|
||||
# parse command
|
||||
my ($command, @args) = split /\s+/, $line;
|
||||
$command //= '';
|
||||
my %args = map { /([A-Z])(.*)/; ($1 => $2) } @args;
|
||||
|
||||
# convert extrusion axis
|
||||
if (exists $args{ $self->_extrusion_axis }) {
|
||||
$args{E} = $args{ $self->_extrusion_axis };
|
||||
}
|
||||
|
||||
# check motion
|
||||
if ($command =~ /^G[01]$/) {
|
||||
foreach my $axis (@AXES) {
|
||||
if (exists $args{$axis}) {
|
||||
$self->$axis(0) if $axis eq 'E' && $self->config->use_relative_e_distances;
|
||||
$info{"dist_$axis"} = $args{$axis} - $self->$axis;
|
||||
$info{"new_$axis"} = $args{$axis};
|
||||
} else {
|
||||
$info{"dist_$axis"} = 0;
|
||||
$info{"new_$axis"} = $self->$axis;
|
||||
}
|
||||
}
|
||||
$info{dist_XY} = sqrt(($info{dist_X}**2) + ($info{dist_Y}**2));
|
||||
if (exists $args{E}) {
|
||||
if ($info{dist_E} > 0) {
|
||||
$info{extruding} = 1;
|
||||
} elsif ($info{dist_E} < 0) {
|
||||
$info{retracting} = 1
|
||||
}
|
||||
} else {
|
||||
$info{travel} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
# run callback
|
||||
$cb->($self, $command, \%args, \%info);
|
||||
|
||||
# update coordinates
|
||||
if ($command =~ /^(?:G[01]|G92)$/) {
|
||||
for my $axis (@AXES, 'F') {
|
||||
$self->$axis($args{$axis}) if exists $args{$axis};
|
||||
}
|
||||
}
|
||||
|
||||
# TODO: update temperatures
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -1,36 +0,0 @@
|
||||
package Slic3r::Geometry;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
require Exporter;
|
||||
our @ISA = qw(Exporter);
|
||||
|
||||
# Exported by this module. The last section starting with convex_hull is exported by Geometry.xsp
|
||||
our @EXPORT_OK = qw(
|
||||
PI epsilon
|
||||
|
||||
scale
|
||||
unscale
|
||||
scaled_epsilon
|
||||
|
||||
X Y Z
|
||||
convex_hull
|
||||
deg2rad
|
||||
rad2deg
|
||||
);
|
||||
|
||||
use constant PI => 4 * atan2(1, 1);
|
||||
use constant A => 0;
|
||||
use constant B => 1;
|
||||
use constant X1 => 0;
|
||||
use constant Y1 => 1;
|
||||
use constant X2 => 2;
|
||||
use constant Y2 => 3;
|
||||
|
||||
sub epsilon () { 1E-4 }
|
||||
sub scaled_epsilon () { epsilon / &Slic3r::SCALING_FACTOR }
|
||||
|
||||
sub scale ($) { $_[0] / &Slic3r::SCALING_FACTOR }
|
||||
sub unscale ($) { $_[0] * &Slic3r::SCALING_FACTOR }
|
||||
|
||||
1;
|
||||
@@ -1,8 +0,0 @@
|
||||
package Slic3r::Line;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# a line is a two-points line
|
||||
use parent 'Slic3r::Polyline';
|
||||
|
||||
1;
|
||||
@@ -1,136 +0,0 @@
|
||||
# extends C++ class Slic3r::Model
|
||||
package Slic3r::Model;
|
||||
|
||||
use List::Util qw(first max any);
|
||||
|
||||
sub merge {
|
||||
my $class = shift;
|
||||
my @models = @_;
|
||||
|
||||
my $new_model = ref($class)
|
||||
? $class
|
||||
: $class->new;
|
||||
|
||||
$new_model->add_object($_) for map @{$_->objects}, @models;
|
||||
return $new_model;
|
||||
}
|
||||
|
||||
sub add_object {
|
||||
my $self = shift;
|
||||
|
||||
if (@_ == 1) {
|
||||
# we have a Model::Object
|
||||
my ($object) = @_;
|
||||
return $self->_add_object_clone($object);
|
||||
} else {
|
||||
my (%args) = @_;
|
||||
|
||||
my $new_object = $self->_add_object;
|
||||
|
||||
$new_object->set_name($args{name})
|
||||
if defined $args{name};
|
||||
$new_object->set_input_file($args{input_file})
|
||||
if defined $args{input_file};
|
||||
$new_object->config->apply($args{config})
|
||||
if defined $args{config};
|
||||
$new_object->set_layer_height_ranges($args{layer_height_ranges})
|
||||
if defined $args{layer_height_ranges};
|
||||
$new_object->set_origin_translation($args{origin_translation})
|
||||
if defined $args{origin_translation};
|
||||
|
||||
return $new_object;
|
||||
}
|
||||
}
|
||||
|
||||
sub set_material {
|
||||
my $self = shift;
|
||||
my ($material_id, $attributes) = @_;
|
||||
|
||||
my $material = $self->add_material($material_id);
|
||||
$material->apply($attributes // {});
|
||||
return $material;
|
||||
}
|
||||
|
||||
# Extends C++ class Slic3r::ModelMaterial
|
||||
package Slic3r::Model::Material;
|
||||
|
||||
sub apply {
|
||||
my ($self, $attributes) = @_;
|
||||
$self->set_attribute($_, $attributes{$_}) for keys %$attributes;
|
||||
}
|
||||
|
||||
# Extends C++ class Slic3r::ModelObject
|
||||
package Slic3r::Model::Object;
|
||||
|
||||
use List::Util qw(first sum);
|
||||
|
||||
sub add_volume {
|
||||
my $self = shift;
|
||||
|
||||
my $new_volume;
|
||||
if (@_ == 1) {
|
||||
# we have a Model::Volume
|
||||
my ($volume) = @_;
|
||||
|
||||
$new_volume = $self->_add_volume_clone($volume);
|
||||
|
||||
if ($volume->material_id ne '') {
|
||||
# merge material attributes and config (should we rename materials in case of duplicates?)
|
||||
if (my $material = $volume->object->model->get_material($volume->material_id)) {
|
||||
my %attributes = %{ $material->attributes };
|
||||
if ($self->model->has_material($volume->material_id)) {
|
||||
%attributes = (%attributes, %{ $self->model->get_material($volume->material_id)->attributes })
|
||||
}
|
||||
my $new_material = $self->model->set_material($volume->material_id, {%attributes});
|
||||
$new_material->config->apply($material->config);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
my %args = @_;
|
||||
|
||||
$new_volume = $self->_add_volume($args{mesh});
|
||||
|
||||
$new_volume->set_name($args{name})
|
||||
if defined $args{name};
|
||||
$new_volume->set_material_id($args{material_id})
|
||||
if defined $args{material_id};
|
||||
$new_volume->set_modifier($args{modifier})
|
||||
if defined $args{modifier};
|
||||
$new_volume->config->apply($args{config})
|
||||
if defined $args{config};
|
||||
}
|
||||
|
||||
if ($new_volume->material_id ne '' && !defined $self->model->get_material($new_volume->material_id)) {
|
||||
# TODO: this should be a trigger on Volume::material_id
|
||||
$self->model->set_material($new_volume->material_id);
|
||||
}
|
||||
|
||||
$self->invalidate_bounding_box;
|
||||
|
||||
return $new_volume;
|
||||
}
|
||||
|
||||
sub add_instance {
|
||||
my $self = shift;
|
||||
|
||||
if (@_ == 1) {
|
||||
# we have a Model::Instance
|
||||
my ($instance) = @_;
|
||||
return $self->_add_instance_clone($instance);
|
||||
} else {
|
||||
my (%args) = @_;
|
||||
|
||||
my $new_instance = $self->_add_instance;
|
||||
|
||||
$new_instance->set_rotations($args{rotation})
|
||||
if defined $args{rotation};
|
||||
$new_instance->set_scaling_factors($args{scaling_factor})
|
||||
if defined $args{scaling_factor};
|
||||
$new_instance->set_offset($args{offset})
|
||||
if defined $args{offset};
|
||||
|
||||
return $new_instance;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -1,28 +0,0 @@
|
||||
package Slic3r::Point;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new_scale {
|
||||
my $class = shift;
|
||||
return $class->new(map Slic3r::Geometry::scale($_), @_);
|
||||
}
|
||||
|
||||
package Slic3r::Pointf;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new_unscale {
|
||||
my $class = shift;
|
||||
return $class->new(map Slic3r::Geometry::unscale($_), @_);
|
||||
}
|
||||
|
||||
package Slic3r::Pointf3;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
sub new_unscale {
|
||||
my $class = shift;
|
||||
return $class->new(map Slic3r::Geometry::unscale($_), @_);
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -1,8 +0,0 @@
|
||||
package Slic3r::Polygon;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# a polygon is a closed polyline.
|
||||
use parent 'Slic3r::Polyline';
|
||||
|
||||
1;
|
||||
@@ -1,13 +0,0 @@
|
||||
package Slic3r::Polyline;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Slic3r::Geometry qw(X Y);
|
||||
|
||||
sub new_scale {
|
||||
my $class = shift;
|
||||
my @points = map { ref($_) eq 'Slic3r::Point' ? $_->pp : $_ } @_;
|
||||
return $class->new(map [ Slic3r::Geometry::scale($_->[X]), Slic3r::Geometry::scale($_->[Y]) ], @points);
|
||||
}
|
||||
|
||||
1;
|
||||
BIN
resources/calib/VolumetricSpeed/volumetric_speed.stl
Normal file
BIN
resources/icons/Q1 Pro_thumbnail.png
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
17
resources/icons/cost_weight.svg
Normal file
@@ -0,0 +1,17 @@
|
||||
<?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.1" id="图层_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">
|
||||
<path fill="#4479FB" d="M14.6,13.1l-1.4-7.3c-0.1-0.6-0.7-1.1-1.4-1.1H9.5C9.9,4.3,10,3.9,10,3.4c0-1.1-0.9-2-2-2s-2,0.9-2,2
|
||||
c0,0.5,0.2,1,0.5,1.3H4.1c-0.7,0-1.2,0.5-1.4,1.1l-1.4,7.3c-0.2,0.8,0.5,1.6,1.4,1.6h10.5C14.1,14.7,14.8,13.9,14.6,13.1z M8,2.3
|
||||
c0.6,0,1,0.5,1,1s-0.5,1-1,1s-1-0.5-1-1S7.4,2.3,8,2.3z M13.6,13.5c0,0-0.1,0.1-0.3,0.1H2.7c-0.2,0-0.3-0.1-0.3-0.1
|
||||
c0-0.1-0.1-0.1-0.1-0.2L3.8,6c0-0.2,0.2-0.3,0.4-0.3h7.7c0.2,0,0.4,0.1,0.4,0.3l1.4,7.3C13.7,13.4,13.6,13.5,13.6,13.5z"/>
|
||||
<g>
|
||||
<path fill="#4479FB" d="M6.9,12c-0.2-0.4-0.4-0.7-0.6-0.9c-0.2-0.2-0.4-0.4-0.6-0.6H5.4v1.6H4.5V8.2h0.9v1.6h0.2l1.1-1.6h1
|
||||
l-1.3,1.9c0.3,0.3,0.6,0.6,0.8,0.8c0.2,0.3,0.5,0.7,0.7,1.1H6.9z"/>
|
||||
<path fill="#4479FB" d="M11.5,11.9C11.3,12,11.1,12,11,12.1c-0.2,0-0.4,0.1-0.7,0.1c-0.4,0-0.8-0.1-1.1-0.2
|
||||
c-0.3-0.2-0.6-0.4-0.8-0.7c-0.2-0.3-0.3-0.6-0.3-1c0-0.4,0.1-0.8,0.3-1.1c0.2-0.3,0.4-0.6,0.8-0.7c0.3-0.2,0.7-0.3,1.1-0.3
|
||||
c0.2,0,0.4,0,0.6,0.1c0.2,0,0.4,0.1,0.5,0.1V9c-0.4-0.1-0.7-0.2-1-0.2c-0.4,0-0.7,0.1-1,0.3C9.1,9.4,9,9.7,9,10.2
|
||||
c0,0.3,0.1,0.5,0.2,0.7c0.1,0.2,0.3,0.3,0.5,0.4c0.2,0.1,0.4,0.1,0.7,0.1c0.2,0,0.3,0,0.4,0v-0.9h-0.4V9.8h1.2V11.9z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -1,10 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 24.0.3, 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 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
|
||||
<g id="hex_x5F_green">
|
||||
<!-- Generator: Adobe Illustrator 25.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="图层_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="hex_x5F_green_2_">
|
||||
<g>
|
||||
<polygon fill="#ED6B21" points="8,1 2,5 2,7 2,11 8,15 14,11 14,7 14,5 "/>
|
||||
<polygon fill="#4479FB" points="8,1 2,5 2,7 2,11 8,15 14,11 14,7 14,5 "/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 462 B After Width: | Height: | Size: 493 B |
155
resources/icons/param_cross hatch.svg
Normal file
@@ -0,0 +1,155 @@
|
||||
<?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.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="10px" height="10px" viewBox="0 0 10 10" enable-background="new 0 0 10 10" xml:space="preserve">
|
||||
<defs>
|
||||
<filter id="Adobe_OpacityMaskFilter" filterUnits="userSpaceOnUse" x="0.7" y="0.6" width="3.7" height="3.7">
|
||||
<feColorMatrix type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<mask maskUnits="userSpaceOnUse" x="0.7" y="0.6" width="3.7" height="3.7" id="mask1_7_73_2_">
|
||||
<path id="path3_2_" fill="#FFFFFF" filter="url(#Adobe_OpacityMaskFilter)" d="M10,0.1H0v10h10V0.1z"/>
|
||||
</mask>
|
||||
<g id="g5" transform="translate(-0.13363557,-0.18774744)" mask="url(#mask1_7_73_2_)">
|
||||
<path id="path4" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M2.7,4.3l1.6-1.6L2.7,1L1,2.7L2.7,4.3z"/>
|
||||
<path id="path5" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M2.7,3.5l0.8-0.8L2.7,1.8L1.8,2.7L2.7,3.5z"/>
|
||||
<path id="path31" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M2.7,4.3l1.6-1.6L2.7,1L1,2.7L2.7,4.3z"/>
|
||||
<path id="path32" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M2.7,3.5l0.8-0.8L2.7,1.8L1.8,2.7L2.7,3.5z"/>
|
||||
<path id="path50" fill="none" stroke="#999999" stroke-width="0.3" d="M2.7,4.3l1.6-1.6L2.7,1L1,2.7L2.7,4.3z"/>
|
||||
<path id="path51" fill="none" stroke="#999999" stroke-width="0.3" d="M2.7,3.5l0.8-0.8L2.7,1.8L1.8,2.7L2.7,3.5z"/>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="Adobe_OpacityMaskFilter_1_" filterUnits="userSpaceOnUse" x="4" y="0.6" width="3.7" height="3.7">
|
||||
<feColorMatrix type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<mask maskUnits="userSpaceOnUse" x="4" y="0.6" width="3.7" height="3.7" id="mask2_7_73_2_">
|
||||
<path id="path6_2_" fill="#FFFFFF" filter="url(#Adobe_OpacityMaskFilter_1_)" d="M10,0.1H0v10h10V0.1z"/>
|
||||
</mask>
|
||||
<g id="g8" transform="translate(-0.13363557,-0.18774744)" mask="url(#mask2_7_73_2_)">
|
||||
<path id="path7" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M6,4.3l1.6-1.6L6,1L4.4,2.7L6,4.3z"/>
|
||||
<path id="path8" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M6,3.5l0.8-0.8L6,1.8L5.1,2.7L6,3.5z"/>
|
||||
<path id="path33" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M6,4.3l1.6-1.6L6,1L4.4,2.7L6,4.3z"/>
|
||||
<path id="path34" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M6,3.5l0.8-0.8L6,1.8L5.1,2.7L6,3.5z"/>
|
||||
<path id="path52" fill="none" stroke="#999999" stroke-width="0.3" d="M6,4.3l1.6-1.6L6,1L4.4,2.7L6,4.3z"/>
|
||||
<path id="path53" fill="none" stroke="#999999" stroke-width="0.3" d="M6,3.5l0.8-0.8L6,1.8L5.1,2.7L6,3.5z"/>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="Adobe_OpacityMaskFilter_2_" filterUnits="userSpaceOnUse" x="7.3" y="0.7" width="2.1" height="3.5">
|
||||
<feColorMatrix type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<mask maskUnits="userSpaceOnUse" x="7.3" y="0.7" width="2.1" height="3.5" id="mask3_7_73_2_">
|
||||
<path id="path9_2_" fill="#FFFFFF" filter="url(#Adobe_OpacityMaskFilter_2_)" d="M10,0.1H0v10h10V0.1z"/>
|
||||
</mask>
|
||||
<g id="g11" transform="translate(-0.13363557,-0.18774744)" mask="url(#mask3_7_73_2_)">
|
||||
<path id="path10" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M9.2,4.2L7.6,2.6l1.6-1.7"/>
|
||||
<path id="path11" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M9.2,3.4L8.4,2.6l0.8-0.8"/>
|
||||
<path id="path35" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M9.2,4.2L7.6,2.6l1.6-1.7"/>
|
||||
<path id="path36" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M9.2,3.4L8.4,2.6l0.8-0.8"/>
|
||||
<path id="path54" fill="none" stroke="#999999" stroke-width="0.3" d="M9.2,4.2L7.6,2.6l1.6-1.7"/>
|
||||
<path id="path55" fill="none" stroke="#999999" stroke-width="0.3" d="M9.5,3.7l-1-1l1-1"/>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="Adobe_OpacityMaskFilter_3_" filterUnits="userSpaceOnUse" x="0.7" y="4" width="3.7" height="3.7">
|
||||
<feColorMatrix type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<mask maskUnits="userSpaceOnUse" x="0.7" y="4" width="3.7" height="3.7" id="mask4_7_73_2_">
|
||||
<path id="path12_2_" fill="#FFFFFF" filter="url(#Adobe_OpacityMaskFilter_3_)" d="M10,0.1H0v10h10V0.1z"/>
|
||||
</mask>
|
||||
<g id="g14" transform="translate(-0.13363557,-0.18774744)" mask="url(#mask4_7_73_2_)">
|
||||
<path id="path13" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M2.7,7.6L4.3,6L2.7,4.4L1.1,6L2.7,7.6z"/>
|
||||
<path id="path14" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M2.7,6.9L3.5,6L2.7,5.2L1.8,6L2.7,6.9z"/>
|
||||
<path id="path37" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M2.7,7.6L4.3,6L2.7,4.4L1.1,6L2.7,7.6z"/>
|
||||
<path id="path38" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M2.7,6.9L3.5,6L2.7,5.2L1.8,6L2.7,6.9z"/>
|
||||
<path id="path56" fill="none" stroke="#999999" stroke-width="0.3" d="M2.7,7.6L4.3,6L2.7,4.4L1.1,6L2.7,7.6z"/>
|
||||
<path id="path57" fill="none" stroke="#999999" stroke-width="0.3" d="M2.7,6.9L3.5,6L2.7,5.2L1.8,6L2.7,6.9z"/>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="Adobe_OpacityMaskFilter_4_" filterUnits="userSpaceOnUse" x="4" y="4" width="3.7" height="3.7">
|
||||
<feColorMatrix type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<mask maskUnits="userSpaceOnUse" x="4" y="4" width="3.7" height="3.7" id="mask5_7_73_2_">
|
||||
<path id="path15_2_" fill="#FFFFFF" filter="url(#Adobe_OpacityMaskFilter_4_)" d="M10,0.1H0v10h10V0.1z"/>
|
||||
</mask>
|
||||
<g id="g17" transform="translate(-0.13363557,-0.18774744)" mask="url(#mask5_7_73_2_)">
|
||||
<path id="path16" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M6,7.6L7.6,6L6,4.4L4.4,6L6,7.6z"/>
|
||||
<path id="path17" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M6,6.9L6.9,6L6,5.2L5.2,6L6,6.9z"/>
|
||||
<path id="path39" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M6,7.6L7.6,6L6,4.4L4.4,6L6,7.6z"/>
|
||||
<path id="path40" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M6,6.9L6.9,6L6,5.2L5.2,6L6,6.9z"/>
|
||||
<path id="path58" fill="none" stroke="#999999" stroke-width="0.3" d="M6,7.6L7.6,6L6,4.4L4.4,6L6,7.6z"/>
|
||||
<path id="path59" fill="none" stroke="#999999" stroke-width="0.3" d="M6,6.9L6.9,6L6,5.2L5.2,6L6,6.9z"/>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="Adobe_OpacityMaskFilter_5_" filterUnits="userSpaceOnUse" x="7.3" y="4" width="2.1" height="3.5">
|
||||
<feColorMatrix type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<mask maskUnits="userSpaceOnUse" x="7.3" y="4" width="2.1" height="3.5" id="mask6_7_73_2_">
|
||||
<path id="path18_2_" fill="#FFFFFF" filter="url(#Adobe_OpacityMaskFilter_5_)" d="M10,0.1H0v10h10V0.1z"/>
|
||||
</mask>
|
||||
<g id="g20" transform="translate(-0.13363557,-0.18774744)" mask="url(#mask6_7_73_2_)">
|
||||
<path id="path19" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M9.2,7.6L7.6,5.9l1.6-1.6"/>
|
||||
<path id="path20" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M9.2,6.7L8.4,5.9l0.8-0.8"/>
|
||||
<path id="path41" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M9.2,7.6L7.6,5.9l1.6-1.6"/>
|
||||
<path id="path42" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M9.2,6.7L8.4,5.9l0.8-0.8"/>
|
||||
<path id="path60" fill="none" stroke="#999999" stroke-width="0.3" d="M9.2,7.6L7.6,5.9l1.6-1.6"/>
|
||||
<path id="path61" fill="none" stroke="#999999" stroke-width="0.3" d="M9.4,7l-1-1l1-1"/>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="Adobe_OpacityMaskFilter_6_" filterUnits="userSpaceOnUse" x="0.7" y="7.2" width="3.6" height="2.2">
|
||||
<feColorMatrix type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<mask maskUnits="userSpaceOnUse" x="0.7" y="7.2" width="3.6" height="2.2" id="mask7_7_73_2_">
|
||||
<path id="path21_2_" fill="#FFFFFF" filter="url(#Adobe_OpacityMaskFilter_6_)" d="M10,0.1H0v10h10V0.1z"/>
|
||||
</mask>
|
||||
<g id="g23" transform="translate(-0.13363557,-0.18774744)" mask="url(#mask7_7_73_2_)">
|
||||
<path id="path22" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M0.9,9.3l1.7-1.7l1.7,1.7"/>
|
||||
<path id="path23" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M1.8,9.3l0.8-0.9l0.8,0.9"/>
|
||||
<path id="path43" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M0.9,9.3l1.7-1.7l1.7,1.7"/>
|
||||
<path id="path44" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M1.8,9.3l0.8-0.9l0.8,0.9"/>
|
||||
<path id="path62" fill="none" stroke="#999999" stroke-width="0.3" d="M0.9,9.3l1.7-1.7l1.7,1.7"/>
|
||||
<path id="path63" fill="none" stroke="#999999" stroke-width="0.3" d="M1.8,9.4l0.9-1l0.9,1.1"/>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="Adobe_OpacityMaskFilter_7_" filterUnits="userSpaceOnUse" x="4.1" y="7.3" width="3.5" height="2">
|
||||
<feColorMatrix type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<mask maskUnits="userSpaceOnUse" x="4.1" y="7.3" width="3.5" height="2" id="mask8_7_73_2_">
|
||||
<path id="path24_2_" fill="#FFFFFF" filter="url(#Adobe_OpacityMaskFilter_7_)" d="M10,0.1H0v10h10V0.1z"/>
|
||||
</mask>
|
||||
<g id="g26" transform="translate(-0.06473357,-0.11884544)" mask="url(#mask8_7_73_2_)">
|
||||
<path id="path25" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M4.3,9.3l1.6-1.7l1.7,1.7"/>
|
||||
<path id="path26" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M5.1,9.3l0.8-0.9l0.8,0.9"/>
|
||||
<path id="path45" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M4.3,9.3l1.6-1.7l1.7,1.7"/>
|
||||
<path id="path46" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M5.1,9.3l0.8-0.9l0.8,0.9"/>
|
||||
<path id="path64" fill="none" stroke="#999999" stroke-width="0.3" d="M4.3,9.3l1.6-1.7l1.7,1.7"/>
|
||||
<path id="path65" fill="none" stroke="#999999" stroke-width="0.3" d="M5.1,9.3l0.8-0.9l0.8,0.9"/>
|
||||
</g>
|
||||
<defs>
|
||||
<filter id="Adobe_OpacityMaskFilter_8_" filterUnits="userSpaceOnUse" x="7.3" y="7.3" width="2.1" height="2">
|
||||
<feColorMatrix type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<mask maskUnits="userSpaceOnUse" x="7.3" y="7.3" width="2.1" height="2" id="mask9_7_73_2_">
|
||||
<path id="path27_2_" fill="#FFFFFF" filter="url(#Adobe_OpacityMaskFilter_8_)" d="M10,0.1H0v10h10V0.1z"/>
|
||||
</mask>
|
||||
<g id="g29" transform="translate(-0.13363557,-0.18774744)" mask="url(#mask9_7_73_2_)">
|
||||
<path id="path28" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M7.5,9.3l1.7-1.7"/>
|
||||
<path id="path29" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M8.4,9.3l0.8-0.9"/>
|
||||
<path id="path47" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M7.5,9.3l1.7-1.7"/>
|
||||
<path id="path48" fill="none" stroke="#B5BFC2" stroke-width="0.3" d="M8.4,9.3l0.8-0.9"/>
|
||||
<path id="path66" fill="none" stroke="#999999" stroke-width="0.3" d="M7.5,9.3l1.7-1.7"/>
|
||||
<path id="path67" fill="none" stroke="#999999" stroke-width="0.3" d="M8.3,9.5l1.1-1.3"/>
|
||||
</g>
|
||||
<path id="path68" fill="none" stroke="#4479FB" stroke-width="0.478" d="M2.4,0.7l6.9,6.9"/>
|
||||
<path id="path68-8" fill="none" stroke="#4479FB" stroke-width="0.4997" d="M0.7,2.2l6.9,7.1"/>
|
||||
<path id="path69" fill="none" stroke="#4479FB" stroke-width="0.478" d="M0.7,5.6l3.6,3.7"/>
|
||||
<path id="path70" fill="none" stroke="#4479FB" stroke-width="0.5048" d="M5.7,0.7l3.6,3.5"/>
|
||||
<path id="rect1" fill="none" stroke="#4479FB" stroke-width="0.406" stroke-linejoin="round" stroke-miterlimit="3.9" d="M1.5,0.7h7
|
||||
c0.5,0,0.9,0.4,0.9,0.9v6.9c0,0.5-0.4,0.9-0.9,0.9h-7C1,9.3,0.7,8.9,0.7,8.5V1.5C0.7,1.1,1,0.7,1.5,0.7z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 11 KiB |
13
resources/icons/print_time.svg
Normal file
@@ -0,0 +1,13 @@
|
||||
<?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.1" id="图层_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">
|
||||
<path fill="#4479FB" d="M8.5,9.2L8.3,9.1c-0.2,0-0.4,0-0.5,0L7.5,9.2c-1.3,0.4-2.3,1.6-2.3,3v0.5h5.5v-0.5
|
||||
C10.8,10.8,9.8,9.6,8.5,9.2z"/>
|
||||
<path fill="#4479FB" d="M7.9,6.8l-2-1.4c0,0,0-0.1,0-0.1h4.2c0,0,0.1,0.1,0,0.1l-2,1.4C8,6.9,7.9,6.9,7.9,6.8z"/>
|
||||
<path fill="#4479FB" d="M13.3,14h-0.4v-1.8c0-1.7-0.9-3.3-2.3-4.2c1.4-0.9,2.3-2.5,2.3-4.2V2h0.4C13.7,2,14,1.7,14,1.4
|
||||
s-0.3-0.7-0.6-0.7H2.7C2.3,0.7,2,1,2,1.4S2.3,2,2.7,2h0.4v1.8c0,1.7,0.9,3.3,2.3,4.2c-1.4,0.9-2.3,2.5-2.3,4.2V14H2.7
|
||||
C2.3,14,2,14.3,2,14.6c0,0.4,0.3,0.7,0.6,0.7h10.7c0.4,0,0.6-0.3,0.6-0.7C14,14.3,13.7,14,13.3,14z M4.1,12.2c0-1.4,0.8-2.7,2-3.4
|
||||
C6.3,8.6,6.5,8.3,6.5,8c0-0.3-0.2-0.6-0.4-0.7c-1.2-0.7-2-2-2-3.4V2h7.9v1.8c0,1.4-0.8,2.7-2,3.4C9.6,7.4,9.5,7.7,9.5,8
|
||||
c0,0.3,0.2,0.6,0.4,0.7c1.2,0.7,2,2,2,3.4V14H4.1V12.2z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -1,3 +1,11 @@
|
||||
min_slic3r_version = 1.1.4
|
||||
1.1.4 Optimize parameters
|
||||
min_slic3r_version = 1.1.3
|
||||
1.1.3 Optimize parameters
|
||||
min_slic3r_version = 1.1.2
|
||||
1.1.2 Optimize parameters
|
||||
min_slic3r_version = 1.1.1
|
||||
1.1.1 Optimize parameters
|
||||
min_slic3r_version = 1.1.0
|
||||
1.1.0 Optimize parameters
|
||||
min_slic3r_version = 1.0.9
|
||||
|
||||
60
resources/profiles/QIDITechnology/Q1 Pro.svg
Normal file
@@ -0,0 +1,60 @@
|
||||
<?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.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="694.5px" height="694.5px" viewBox="0 0 694.5 694.5" enable-background="new 0 0 694.5 694.5" xml:space="preserve">
|
||||
<rect fill="#FFFFFF" width="1.4" height="694.5"/>
|
||||
<rect x="693.1" y="15.7" fill="#FFFFFF" width="1.4" height="678.8"/>
|
||||
<rect x="0" y="693.1" fill="#FFFFFF" width="694.5" height="1.4"/>
|
||||
<rect x="559.1" fill="#FFFFFF" width="1.4" height="694.5"/>
|
||||
<rect x="417.4" fill="#FFFFFF" width="1.4" height="694.5"/>
|
||||
<rect x="275.7" y="15.7" fill="#FFFFFF" width="1.4" height="678.8"/>
|
||||
<rect x="133.9" y="14.2" fill="#FFFFFF" width="1.4" height="680.3"/>
|
||||
<rect x="21.1" y="0" fill="#FFFFFF" width="0.4" height="694.5"/>
|
||||
<rect x="49.4" y="0" fill="#FFFFFF" width="0.4" height="694.5"/>
|
||||
<rect x="77.8" y="14.2" fill="#FFFFFF" width="0.4" height="680.3"/>
|
||||
<rect x="106.1" y="14.2" fill="#FFFFFF" width="0.4" height="680.3"/>
|
||||
<rect x="162.8" y="15.7" fill="#FFFFFF" width="0.4" height="678.8"/>
|
||||
<rect x="191.1" y="15.7" fill="#FFFFFF" width="0.4" height="678.8"/>
|
||||
<rect x="219.5" y="15.7" fill="#FFFFFF" width="0.4" height="678.8"/>
|
||||
<rect x="247.8" y="15.7" fill="#FFFFFF" width="0.4" height="678.8"/>
|
||||
<rect x="304.5" y="15.7" fill="#FFFFFF" width="0.4" height="678.8"/>
|
||||
<rect x="332.9" y="0" fill="#FFFFFF" width="0.4" height="694.5"/>
|
||||
<rect x="361.2" y="0" fill="#FFFFFF" width="0.4" height="694.5"/>
|
||||
<rect x="389.6" y="0" fill="#FFFFFF" width="0.4" height="694.5"/>
|
||||
<rect x="446.3" y="0" fill="#FFFFFF" width="0.4" height="694.5"/>
|
||||
<rect x="474.6" y="0" fill="#FFFFFF" width="0.4" height="694.5"/>
|
||||
<rect x="502.9" y="0" fill="#FFFFFF" width="0.4" height="694.5"/>
|
||||
<rect x="531.3" y="0" fill="#FFFFFF" width="0.4" height="694.5"/>
|
||||
<rect x="588" y="0" fill="#FFFFFF" width="0.4" height="694.5"/>
|
||||
<rect x="616.3" y="15.7" fill="#FFFFFF" width="0.4" height="678.8"/>
|
||||
<rect x="644.7" y="15.7" fill="#FFFFFF" width="0.4" height="678.8"/>
|
||||
<rect x="673" y="15.7" fill="#FFFFFF" width="0.4" height="678.8"/>
|
||||
<rect x="0" y="559.1" fill="#FFFFFF" width="694.5" height="1.4"/>
|
||||
<rect x="0" y="417.4" fill="#FFFFFF" width="694.5" height="1.4"/>
|
||||
<rect x="0" y="275.7" fill="#FFFFFF" width="694.5" height="1.4"/>
|
||||
<rect x="0" y="133.9" fill="#FFFFFF" width="694.5" height="1.4"/>
|
||||
<rect x="0" y="21.1" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="49.4" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="77.8" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="106.1" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="162.8" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="191.1" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="219.5" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="247.8" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="304.5" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="332.9" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="361.2" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="389.6" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="446.3" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="474.6" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="502.9" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="531.3" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="588" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="616.3" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="644.7" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<rect x="0" y="673" fill="#FFFFFF" width="694.5" height="0.4"/>
|
||||
<polygon fill="#FFFFFF" points="694.5,15.7 588.1,15.7 588.1,0 589.6,0 589.6,14 694.5,14 "/>
|
||||
<polygon fill="#FFFFFF" points="327.5,15.7 69.4,15.7 69.4,0 70.9,0 70.9,14 326,14 326,0 327.5,0 "/>
|
||||
<rect x="327.5" y="0" fill="#FFFFFF" width="260.9" height="1.4"/>
|
||||
<rect x="0" y="0" fill="#FFFFFF" width="69.4" height="1.4"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
BIN
resources/profiles/QIDITechnology/Q1 Pro_bed.STL
Normal file
BIN
resources/profiles/QIDITechnology/Q1 Pro_thumbnail.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
@@ -18,6 +18,7 @@ var LangText={
|
||||
"t16": "Calibration",
|
||||
"t17": "Pressure Advance",
|
||||
"t18": "Exclude Objects",
|
||||
"t19": "Max Volumetric Speed",
|
||||
|
||||
"l0": "Learn more:",
|
||||
"l1": "You can download the 3D model from the following link.",
|
||||
@@ -62,6 +63,9 @@ var LangText={
|
||||
"l41": "4.PA calibration does not work with PETG.",
|
||||
"l42": "When multiple models are printed at the same time, you can stop printing a model in the middle of printing.",
|
||||
"l43": "Note: Models with the same file name are treated as the same object.",
|
||||
"l44": "Different filaments have different maximum volume speed.",
|
||||
"l45": "Nozzle material, caliber, printing temperature, etc., will affect the maximum volume speed.",
|
||||
"l46": "During the test, the printing speed will increase layer by layer. When there is a hole or missing wire on the surface of the model, it indicates that the layer has reached the maximum volume speed, and the maximum volume speed is calculated according to the ratio of height.",
|
||||
},
|
||||
"zh_CN": {
|
||||
"t1": "用户指南",
|
||||
@@ -82,6 +86,7 @@ var LangText={
|
||||
"t16": "校准",
|
||||
"t17": "压力提前",
|
||||
"t18": "排除对象",
|
||||
"t19": "最大体积速度",
|
||||
|
||||
"l0": "了解更多:",
|
||||
"l1": "您可以从以下链接下载3D模型。",
|
||||
@@ -126,6 +131,9 @@ var LangText={
|
||||
"l41": "4.PA校准不适用于PETG。",
|
||||
"l42": "当多个模型同时打印时,你可以在打印中途停止某个模型的打印。",
|
||||
"l43": "注:相同文件名的模型会被视为同一对象。",
|
||||
"l44": "不同线材的最大体积速度各不相同。",
|
||||
"l45": "喷嘴材质、口径、打印温度、等都会影响最大体积速度。",
|
||||
"l46": "测试时打印速度会逐层增加,当模型表面出现空洞或缺丝时,说明该层已达到最大体积速度,根据高度比例算出最大体积速度。",
|
||||
},
|
||||
"ja": {
|
||||
"t1": "ユーザーガイド",
|
||||
@@ -146,6 +154,7 @@ var LangText={
|
||||
"t16": "較正",
|
||||
"t17": "圧力前進",
|
||||
"t18": "対象をはずします",
|
||||
"t19": "最大体積速度です",
|
||||
|
||||
"l0": "もっと詳しく知る:",
|
||||
"l1": "3Dモデルは以下のWebサイトからダウンロードできます。",
|
||||
@@ -190,6 +199,9 @@ var LangText={
|
||||
"l41": "4.PA キャリブレーションは PETG では機能しません。",
|
||||
"l42": "複数のモデルが同時に印刷されている場合は、あるモデルの印刷を途中でやめることができます。",
|
||||
"l43": "注:同じファイル名のモデルは、同じ対象として扱われます。",
|
||||
"l44": "最大体積速度は線材によって異なります。",
|
||||
"l45": "ノズルの材質、口径、印刷温度などが最大体積速度に影響します。",
|
||||
"l46": "テスト時の印刷速度は層ごとに増加します。模型の表面に穴ができたり、糸が欠けたりした場合、その層が最大体積速度に達したことを示し、高さの割合から最大体積速度を算出します。",
|
||||
},
|
||||
"fr": {
|
||||
"t1": "Guide de l'utilisateur",
|
||||
@@ -210,6 +222,7 @@ var LangText={
|
||||
"t16": "Étalonnage",
|
||||
"t17": "Avance de pression",
|
||||
"t18": "Exclure des objets",
|
||||
"t19": "Vitesse volumétrique Max",
|
||||
|
||||
"l0": "Apprendre encore plus:",
|
||||
"l1": "Vous pouvez télécharger des modèles 3D à partir des sites Web suivants.",
|
||||
@@ -254,6 +267,9 @@ var LangText={
|
||||
"l41": "4.L'étalonnage PA ne fonctionne pas avec le PETG.",
|
||||
"l42": "Lorsque plusieurs modèles sont imprimés en même temps, vous pouvez arrêter l’impression d’un modèle au milieu de l’impression.",
|
||||
"l43": "Note: les modèles avec le même nom de fichier sont traités comme le même objet.",
|
||||
"l44": "Différents filaments ont une vitesse de volume maximale différente.",
|
||||
"l45": "Le matériau de la buse, le calibre, la température d’impression, etc., affecteront la vitesse de volume maximum.",
|
||||
"l46": "Pendant l’essai, la vitesse d’impression augmentera couche par couche. Quand il y a un trou ou un fil manquant sur la surface du modèle, cela indique que la couche a atteint la vitesse volumique maximale, et la vitesse volumique maximale est calculée selon le rapport de la hauteur.",
|
||||
},
|
||||
"de": {
|
||||
"t1": "Benutzerhandbuch",
|
||||
@@ -274,6 +290,7 @@ var LangText={
|
||||
"t16": "Kalibrierung",
|
||||
"t17": "Druckvorschub",
|
||||
"t18": "Subjekt wird eliminiert",
|
||||
"t19": "Maximale geschwindigkeit",
|
||||
|
||||
"l0": "Erfahren Sie mehr:",
|
||||
"l1": "Sie können 3D-Modelle von den folgenden Websites herunterladen.",
|
||||
@@ -318,6 +335,9 @@ var LangText={
|
||||
"l41": "4.Die PA-Kalibrierung funktioniert nicht mit PETG.",
|
||||
"l42": "Wenn sie mehrere modelle gleichzeitig drucken, können sie den druckvorgang beenden.",
|
||||
"l43": "Anmerkung: ein modell mit dem gleichen namen wird als gleiches objekt betrachtet.",
|
||||
"l44": "Es gibt eine vielzahl Von lichtern mit maximale geschwindigkeit.",
|
||||
"l45": "Die düsen, der durchmesser, die drucktemperatur all das beeinflusst die maximale geschwindigkeit.",
|
||||
"l46": "Bei den tests wird die druckgeschwindigkeit etage für etage erhöht Wenn eine öffnung Oder keine linie in der oberfläche eines modells angezeigt wird, zeigt sie an, dass sie die höchstgeschwindigkeit erreicht hat und dass die höchste geschwindigkeit nach höhe angegeben wird.",
|
||||
},
|
||||
"be": {
|
||||
"t1": "Кіраўніцтва карыстальніка",
|
||||
@@ -338,6 +358,7 @@ var LangText={
|
||||
"t16": "Каліброўка",
|
||||
"t17": "Увеличение давления",
|
||||
"t18": "Исключить объекты из списка",
|
||||
"t19": "Максимальная объемная частота вращения",
|
||||
|
||||
"l0": "даведацца больш:",
|
||||
"l1": "Вы можаце загрузіць 3D-мадэлі з наступных сайтаў.",
|
||||
@@ -382,6 +403,9 @@ var LangText={
|
||||
"l41": "4.Калибровка PA не работает с PETG.",
|
||||
"l42": "Когда одновременно печатаются несколько моделей, можно прекратить печатание модели в процессе печати.",
|
||||
"l43": "Примечание: модели с одним и тем же именем файла рассматриваются как Один и тот же объект.",
|
||||
"l44": "Различные нити накала имеют разную максимальную объемную скорость.",
|
||||
"l45": "Материал сопла, калибр, температура печати и т.д., повлияет на максимальную объемную скорость.",
|
||||
"l46": "Во время теста скорость печати будет увеличиваться слой за слоем. Если на поверхности модели имеется отверстие или недостающая проволока, это указывает на то, что слой достиг максимальной объемной скорости, а максимальная объемная скорость рассчитывается в соответствии с отношением высоты.",
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
BIN
resources/web/guide/img/MaxVolumetricSpeed.gif
Normal file
|
After Width: | Height: | Size: 2.3 MiB |
@@ -1 +1,12 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1687832492956" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10887" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M972.146238 0.005962h-3.629346c-15.683959 0.907336-246.277047 15.683959-374.341111 93.714898-27.479334 16.850535-36.16384 49.12579-41.867098 104.602935a94.362995 94.362995 0 0 0-67.920617-31.627158 85.16001 85.16001 0 0 0-52.625517 18.924447c-47.051878 37.330416-207.391197 171.356977-277.256107 332.862872C68.698334 717.320267 82.826859 863.66068 83.474957 869.752797c0 1.555434 0.907336 2.981248 1.166575 4.536682-47.959214 61.439642-77.123602 104.732555-80.364089 109.398857a25.9239 25.9239 0 0 0 7.129073 35.515743A25.9239 25.9239 0 0 0 25.9239 1024a25.9239 25.9239 0 0 0 21.387217-11.406516c0-1.036956 27.479334-40.830142 72.716539-98.899677h1.685053A250.295251 250.295251 0 0 0 181.467298 920.304401c99.547775 0 305.902016-38.88585 570.325793-296.958271C987.570958 393.012282 1019.716594 99.294498 1023.086701 58.723595A47.829595 47.829595 0 0 0 1023.994038 51.853762a51.070082 51.070082 0 0 0-51.8478-51.8478zM716.406968 586.404573C461.575034 835.533249 267.405025 868.456602 181.467298 868.456602c-10.499179 0-18.794827 0-25.9239-1.166576 87.363542-107.195325 220.353147-251.202588 368.378615-349.972645a25.9239 25.9239 0 0 0-28.51629-42.644815c-145.173838 97.214624-272.200947 232.148522-361.89764 338.825369a795.215623 795.215623 0 0 1 67.531759-274.274859c64.809749-151.136335 221.001245-280.626214 262.220245-312.901469a33.182592 33.182592 0 0 1 20.998359-8.166029c45.237205 0 81.401045 108.750759 100.195872 108.75076h1.944293c16.202437-7.517931 9.591843-173.560508 34.349167-188.72599C741.034672 64.815712 972.146238 51.853762 972.146238 51.853762s-19.054066 303.180007-255.73927 534.550811z" fill="#4479FB" p-id="10888"></path></svg>
|
||||
<?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.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="20px" height="20px" viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve">
|
||||
<path fill="#4479FB" d="M19,0L19,0c-0.4,0-4.9,0.3-7.4,1.8c-0.5,0.3-0.7,1-0.8,2C10.4,3.5,10,3.3,9.5,3.3c-0.4,0-0.7,0.1-1,0.4
|
||||
C7.5,4.4,4.4,7,3,10.1C1.3,14,1.6,16.9,1.6,17c0,0,0,0.1,0,0.1c-0.9,1.2-1.5,2-1.6,2.1c-0.1,0.2-0.1,0.5,0.1,0.7
|
||||
C0.3,20,0.4,20,0.5,20c0.2,0,0.3-0.1,0.4-0.2c0,0,0.5-0.8,1.4-1.9h0C2.8,17.9,3.2,18,3.5,18c1.9,0,6-0.8,11.1-5.8
|
||||
c4.6-4.5,5.2-10.2,5.3-11c0,0,0-0.1,0-0.1C20,0.5,19.6,0,19,0C19,0,19,0,19,0z M14,11.5C9,16.3,5.2,17,3.5,17c-0.2,0-0.4,0-0.5,0
|
||||
c1.7-2.1,4.3-4.9,7.2-6.8c0.2-0.2,0.2-0.5,0-0.7c-0.1-0.2-0.4-0.2-0.6-0.1c-2.8,1.9-5.3,4.5-7.1,6.6c0.1-1.9,0.6-3.7,1.3-5.4
|
||||
c1.3-3,4.3-5.5,5.1-6.1c0.1-0.1,0.3-0.2,0.4-0.2c0.9,0,1.6,2.1,2,2.1h0c0.3-0.1,0.2-3.4,0.7-3.7C14.5,1.3,19,1,19,1
|
||||
S18.6,6.9,14,11.5L14,11.5z"/>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.1 KiB |
BIN
resources/web/guide/img/Q1 Pro.png
Normal file
|
After Width: | Height: | Size: 83 KiB |
BIN
resources/web/guide/img/Q1 ProPoster.png
Normal file
|
After Width: | Height: | Size: 517 KiB |
|
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 2.0 KiB |
@@ -83,6 +83,10 @@
|
||||
<div class="MenuBtnIcon"><img src="img/MenuBtnIcon.svg"/></div>
|
||||
<div class="trans" tid="t17"></div>
|
||||
</li>
|
||||
<li menu="MaxVolumetricSpeed" class="MenuBtn" onClick="GotoMenu('MaxVolumetricSpeed')">
|
||||
<div class="MenuBtnIcon"><img src="img/MenuBtnIcon.svg"/></div>
|
||||
<div class="trans" tid="t19"></div>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
|
||||
@@ -93,6 +97,10 @@
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</label>
|
||||
<ol>
|
||||
<li menu="Q1 Pro" class="MenuBtn" onClick="GotoMenu('Q1 Pro')">
|
||||
<div class="MenuBtnIcon"><img src="img/MenuBtnIcon.svg"/></div>
|
||||
<div>Q1 Pro</div>
|
||||
</li>
|
||||
<li menu="X-MAX 3" class="MenuBtn" onClick="GotoMenu('X-MAX 3')">
|
||||
<div class="MenuBtnIcon"><img src="img/MenuBtnIcon.svg"/></div>
|
||||
<div>X-MAX 3</div>
|
||||
@@ -174,6 +182,10 @@
|
||||
<div class="AutozoomImage"><img src="img/PressureAdvance.gif"/></div>
|
||||
<div class="ThumbnailTitle trans" tid="t17"></div>
|
||||
</div>
|
||||
<div class="Thumbnail" onClick="GotoMenu('MaxVolumetricSpeed')">
|
||||
<div class="AutozoomImage"><img src="img/MaxVolumetricSpeed.gif"/></div>
|
||||
<div class="ThumbnailTitle trans" tid="t19"></div>
|
||||
</div>
|
||||
<div class="Thumbnail" onClick="GotoMenu('IssueReport')">
|
||||
<div class="AutozoomImage"><img src="img/IssueReport.png"/></div>
|
||||
<div class="ThumbnailTitle trans" tid="t6"></div>
|
||||
@@ -294,6 +306,20 @@
|
||||
<div class="CenterImage"><img src="img/PressureAdvanceTower.png"/></div>
|
||||
</div>
|
||||
|
||||
<div class="IntroduceBoard" board="MaxVolumetricSpeed">
|
||||
<div class="IntroduceTitle trans" tid="t19"></div>
|
||||
<div class="IntroduceText trans" tid="l44"></div>
|
||||
<div class="IntroduceText trans" tid="l45"></div>
|
||||
<div class="AutozoomImage"><img src="img/MaxVolumetricSpeed.gif"/></div>
|
||||
<div class="IntroduceText trans" tid="l46"></div>
|
||||
</div>
|
||||
|
||||
<div class="IntroduceBoard" board="Q1 Pro">
|
||||
<div class="AutozoomImage"><img src="img/Q1 ProPoster.png"/></div>
|
||||
<div class="IntroduceTextBold trans" tid="l0"></div>
|
||||
<div class="IntroduceText">https://qidi3d.com</div>
|
||||
</div>
|
||||
|
||||
<div class="IntroduceBoard" board="X-MAX 3">
|
||||
<div class="AutozoomImage"><img src="img/X-MAX3Poster.png"/></div>
|
||||
<div class="IntroduceTextBold trans" tid="l0"></div>
|
||||
@@ -526,6 +552,22 @@
|
||||
<td>2200 ± 200</td>
|
||||
<td>7.5 ± 1.5</td>
|
||||
</tr>
|
||||
<tr v-for="(item, index) in 1" :key="index">
|
||||
<td>PLA-CF</td>
|
||||
<td>≤30%</td>
|
||||
<td>/</td>
|
||||
<td>+</td>
|
||||
<td>+</td>
|
||||
<td>++</td>
|
||||
<td>55.2℃</td>
|
||||
<td>52.6℃</td>
|
||||
<td>54.92 ± 0.22</td>
|
||||
<td>4020.55 ± 99.11</td>
|
||||
<td>4.90 ± 0.97</td>
|
||||
<td>91.57 ± 0.31</td>
|
||||
<td>4197.66 ± 279.96</td>
|
||||
<td>6.65 ± 0.38</td>
|
||||
</tr>
|
||||
<tr v-for="(item, index) in 1" :key="index">
|
||||
<td>UltraPA</td>
|
||||
<td>≤15%</td>
|
||||
@@ -554,6 +596,14 @@
|
||||
<div class="IntroduceText trans" tid="l2"></div>
|
||||
<div class="IntroduceText trans" tid="l3"></div>
|
||||
<div class="EmailBlock">
|
||||
<div class="PrinterBlock">
|
||||
<div class="CenterImage"><img src="img/Q1 Pro.png"/></div>
|
||||
<div class="ThumbnailTitle">Q1 Pro</div>
|
||||
<div class="IntroduceText">
|
||||
<b>E-mail:</b><br/>Q1support@qidi3d.com<br>Q1AMS@qidi3d.com<br/><br>
|
||||
<b>Skype:</b><br/>Q1support@qidi3d.com
|
||||
</div>
|
||||
</div>
|
||||
<div class="PrinterBlock">
|
||||
<div class="CenterImage"><img src="img/X-MAX 3.png"/></div>
|
||||
<div class="ThumbnailTitle">X-MAX 3</div>
|
||||
|
||||
70
src/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"typeinfo": "cpp",
|
||||
"any": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"bitset": "cpp",
|
||||
"cctype": "cpp",
|
||||
"cfenv": "cpp",
|
||||
"charconv": "cpp",
|
||||
"chrono": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"codecvt": "cpp",
|
||||
"complex": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"csignal": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cstring": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"deque": "cpp",
|
||||
"forward_list": "cpp",
|
||||
"list": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"unordered_set": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"map": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"random": "cpp",
|
||||
"ratio": "cpp",
|
||||
"regex": "cpp",
|
||||
"set": "cpp",
|
||||
"string": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"fstream": "cpp",
|
||||
"future": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"mutex": "cpp",
|
||||
"new": "cpp",
|
||||
"ostream": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"thread": "cpp"
|
||||
}
|
||||
}
|
||||
@@ -130,12 +130,6 @@ int CLI::run(int argc, char **argv)
|
||||
// On Unix systems, the qidi-slicer binary may be symlinked to give the application a different meaning.
|
||||
boost::algorithm::iends_with(boost::filesystem::path(argv[0]).filename().string(), "gcodeviewer");
|
||||
#endif // _WIN32
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
std::pair<int, int> opengl_version = { 0, 0 };
|
||||
#if ENABLE_OPENGL_DEBUG_OPTION
|
||||
bool opengl_debug = false;
|
||||
#endif // ENABLE_OPENGL_DEBUG_OPTION
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
|
||||
const std::vector<std::string> &load_configs = m_config.option<ConfigOptionStrings>("load", true)->values;
|
||||
const ForwardCompatibilitySubstitutionRule config_substitution_rule = m_config.option<ConfigOptionEnum<ForwardCompatibilitySubstitutionRule>>("config_compatibility", true)->value;
|
||||
@@ -174,7 +168,11 @@ int CLI::run(int argc, char **argv)
|
||||
m_print_config.apply(config);
|
||||
}
|
||||
|
||||
#ifdef SLIC3R_GUI
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
std::pair<int, int> opengl_version = { 0, 0 };
|
||||
bool opengl_debug = false;
|
||||
bool opengl_compatibility_profile = false;
|
||||
// search for special keys into command line parameters
|
||||
auto it = std::find(m_actions.begin(), m_actions.end(), "gcodeviewer");
|
||||
if (it != m_actions.end()) {
|
||||
@@ -185,30 +183,37 @@ int CLI::run(int argc, char **argv)
|
||||
|
||||
it = std::find(m_actions.begin(), m_actions.end(), "opengl-version");
|
||||
if (it != m_actions.end()) {
|
||||
std::string opengl_version_str = m_config.opt_string("opengl-version");
|
||||
if (std::find(Slic3r::GUI::OpenGLVersions::core_str.begin(), Slic3r::GUI::OpenGLVersions::core_str.end(), opengl_version_str) == Slic3r::GUI::OpenGLVersions::core_str.end()) {
|
||||
if (std::find(Slic3r::GUI::OpenGLVersions::precore_str.begin(), Slic3r::GUI::OpenGLVersions::precore_str.end(), opengl_version_str) == Slic3r::GUI::OpenGLVersions::precore_str.end()) {
|
||||
boost::nowide::cerr << "Found invalid OpenGL version: " << opengl_version_str << std::endl;
|
||||
opengl_version_str.clear();
|
||||
const Semver opengl_minimum = Semver(3,2,0);
|
||||
const std::string opengl_version_str = m_config.opt_string("opengl-version");
|
||||
boost::optional<Semver> semver = Semver::parse(opengl_version_str);
|
||||
if (semver.has_value() && (*semver) >= opengl_minimum ) {
|
||||
opengl_version.first = semver->maj();
|
||||
opengl_version.second = semver->min();
|
||||
if (std::find(Slic3r::GUI::OpenGLVersions::core.begin(), Slic3r::GUI::OpenGLVersions::core.end(), std::make_pair(opengl_version.first, opengl_version.second)) == Slic3r::GUI::OpenGLVersions::core.end()) {
|
||||
opengl_version = { 0, 0 };
|
||||
boost::nowide::cerr << "Required OpenGL version " << opengl_version_str << " not recognized.\n Option 'opengl-version' ignored." << std::endl;
|
||||
}
|
||||
} else
|
||||
boost::nowide::cerr << "Required OpenGL version " << opengl_version_str << " is invalid. Must be greater than or equal to " <<
|
||||
opengl_minimum.to_string() << "\n Option 'opengl-version' ignored." << std::endl;
|
||||
start_gui = true;
|
||||
m_actions.erase(it);
|
||||
}
|
||||
|
||||
if (!opengl_version_str.empty()) {
|
||||
std::vector<std::string> tokens;
|
||||
boost::split(tokens, opengl_version_str, boost::is_any_of("."), boost::token_compress_on);
|
||||
opengl_version.first = std::stoi(tokens[0].c_str());
|
||||
opengl_version.second = std::stoi(tokens[1].c_str());
|
||||
}
|
||||
it = std::find(m_actions.begin(), m_actions.end(), "opengl-compatibility");
|
||||
if (it != m_actions.end()) {
|
||||
start_gui = true;
|
||||
opengl_compatibility_profile = true;
|
||||
// reset version as compatibility profile always take the highest version
|
||||
// supported by the graphic card
|
||||
opengl_version = std::make_pair(0, 0);
|
||||
m_actions.erase(it);
|
||||
}
|
||||
|
||||
it = std::find(m_actions.begin(), m_actions.end(), "opengl-debug");
|
||||
if (it != m_actions.end()) {
|
||||
start_gui = true;
|
||||
#if ENABLE_OPENGL_DEBUG_OPTION
|
||||
opengl_debug = true;
|
||||
#endif // ENABLE_OPENGL_DEBUG_OPTION
|
||||
m_actions.erase(it);
|
||||
}
|
||||
#else
|
||||
@@ -222,6 +227,16 @@ int CLI::run(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
#else // SLIC3R_GUI
|
||||
// If there is no GUI, we shall ignore the parameters. Remove them from the list.
|
||||
for (const std::string& s : { "opengl-version", "opengl-compatibility", "opengl-debug", "gcodeviewer" }) {
|
||||
auto it = std::find(m_actions.cbegin(), m_actions.cend(), s);
|
||||
if (it != m_actions.end()) {
|
||||
boost::nowide::cerr << "Parameter '" << s << "' is ignored, this PrusaSlicer build is CLI only." << std::endl;
|
||||
m_actions.erase(it);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Read input file(s) if any.
|
||||
for (const std::string& file : m_input_files)
|
||||
@@ -702,10 +717,9 @@ int CLI::run(int argc, char **argv)
|
||||
params.download_url = download_url;
|
||||
params.delete_after_load = delete_after_load;
|
||||
#if ENABLE_GL_CORE_PROFILE
|
||||
#if ENABLE_OPENGL_DEBUG_OPTION
|
||||
params.opengl_version = opengl_version;
|
||||
params.opengl_debug = opengl_debug;
|
||||
#endif // ENABLE_OPENGL_DEBUG_OPTION
|
||||
params.opengl_compatibiity_profile = opengl_compatibility_profile;
|
||||
#endif // ENABLE_GL_CORE_PROFILE
|
||||
return Slic3r::GUI::GUI_Run(params);
|
||||
#else // SLIC3R_GUI
|
||||
@@ -781,6 +795,7 @@ bool CLI::setup(int argc, char **argv)
|
||||
set_var_dir((path_resources / "icons").string());
|
||||
set_local_dir((path_resources / "localization").string());
|
||||
set_sys_shapes_dir((path_resources / "shapes").string());
|
||||
set_custom_gcodes_dir((path_resources / "custom_gcodes").string());
|
||||
|
||||
// Parse all command line options into a DynamicConfig.
|
||||
// If any option is unsupported, print usage and abort immediately.
|
||||
@@ -805,6 +820,11 @@ bool CLI::setup(int argc, char **argv)
|
||||
set_logging_level(opt_loglevel->value);
|
||||
}
|
||||
|
||||
{
|
||||
const ConfigOptionInt *opt_threads = m_config.opt<ConfigOptionInt>("threads");
|
||||
if (opt_threads != nullptr)
|
||||
thread_count = opt_threads->value;
|
||||
}
|
||||
//FIXME Validating at this stage most likely does not make sense, as the config is not fully initialized yet.
|
||||
std::string validity = m_config.validate();
|
||||
|
||||
|
||||
@@ -268,7 +268,7 @@ int wmain(int argc, wchar_t **argv)
|
||||
// In that case, use Mesa.
|
||||
(::GetSystemMetrics(SM_REMOTESESSION) && !force_hw) ||
|
||||
// Try to load the default OpenGL driver and test its context version.
|
||||
! opengl_version_check.load_opengl_dll() || ! opengl_version_check.is_version_greater_or_equal_to(2, 0);
|
||||
! opengl_version_check.load_opengl_dll() || ! opengl_version_check.is_version_greater_or_equal_to(3, 2);
|
||||
#endif /* SLIC3R_GUI */
|
||||
|
||||
wchar_t path_to_exe[MAX_PATH + 1] = { 0 };
|
||||
|
||||
@@ -153,7 +153,7 @@ void AppConfig::set_defaults()
|
||||
set("default_action_on_new_project", "none"); // , "keep(transfer)", "discard" or "save"
|
||||
|
||||
if (get("color_mapinulation_panel").empty())
|
||||
set("color_mapinulation_panel", "0");
|
||||
set("color_mapinulation_panel", "1");
|
||||
|
||||
if (get("order_volumes").empty())
|
||||
set("order_volumes", "1");
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <functional>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#include "utils/VoronoiUtils.hpp"
|
||||
|
||||
#include "utils/linearAlg2D.hpp"
|
||||
#include "Utils.hpp"
|
||||
@@ -19,26 +18,9 @@
|
||||
#include "Geometry/VoronoiUtilsCgal.hpp"
|
||||
#include "../EdgeGrid.hpp"
|
||||
|
||||
#include "Geometry/VoronoiUtils.hpp"
|
||||
#define SKELETAL_TRAPEZOIDATION_BEAD_SEARCH_MAX 1000 //A limit to how long it'll keep searching for adjacent beads. Increasing will re-use beadings more often (saving performance), but search longer for beading (costing performance).
|
||||
|
||||
namespace boost::polygon {
|
||||
|
||||
template<> struct geometry_concept<Slic3r::Arachne::PolygonsSegmentIndex>
|
||||
{
|
||||
typedef segment_concept type;
|
||||
};
|
||||
|
||||
template<> struct segment_traits<Slic3r::Arachne::PolygonsSegmentIndex>
|
||||
{
|
||||
typedef coord_t coordinate_type;
|
||||
typedef Slic3r::Point point_type;
|
||||
static inline point_type get(const Slic3r::Arachne::PolygonsSegmentIndex &CSegment, direction_1d dir)
|
||||
{
|
||||
return dir.to_int() ? CSegment.p() : CSegment.next().p();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace boost::polygon
|
||||
|
||||
namespace Slic3r::Arachne
|
||||
{
|
||||
@@ -108,8 +90,7 @@ static void export_graph_to_svg(const std::string
|
||||
}
|
||||
#endif
|
||||
|
||||
SkeletalTrapezoidation::node_t& SkeletalTrapezoidation::makeNode(vd_t::vertex_type& vd_node, Point p)
|
||||
{
|
||||
SkeletalTrapezoidation::node_t &SkeletalTrapezoidation::makeNode(const VD::vertex_type &vd_node, Point p) {
|
||||
auto he_node_it = vd_node_to_he_node.find(&vd_node);
|
||||
if (he_node_it == vd_node_to_he_node.end())
|
||||
{
|
||||
@@ -124,8 +105,7 @@ SkeletalTrapezoidation::node_t& SkeletalTrapezoidation::makeNode(vd_t::vertex_ty
|
||||
}
|
||||
}
|
||||
|
||||
void SkeletalTrapezoidation::transferEdge(Point from, Point to, vd_t::edge_type& vd_edge, edge_t*& prev_edge, Point& start_source_point, Point& end_source_point, const std::vector<Segment>& segments)
|
||||
{
|
||||
void SkeletalTrapezoidation::transferEdge(Point from, Point to, const VD::edge_type &vd_edge, edge_t *&prev_edge, Point &start_source_point, Point &end_source_point, const std::vector<Segment> &segments) {
|
||||
auto he_edge_it = vd_edge_to_he_edge.find(vd_edge.twin());
|
||||
if (he_edge_it != vd_edge_to_he_edge.end())
|
||||
{ // Twin segment(s) have already been made
|
||||
@@ -235,22 +215,18 @@ void SkeletalTrapezoidation::transferEdge(Point from, Point to, vd_t::edge_type&
|
||||
}
|
||||
}
|
||||
|
||||
Points SkeletalTrapezoidation::discretize(const vd_t::edge_type& vd_edge, const std::vector<Segment>& segments)
|
||||
Points SkeletalTrapezoidation::discretize(const VD::edge_type& vd_edge, const std::vector<Segment>& segments)
|
||||
{
|
||||
assert(Geometry::VoronoiUtils::is_in_range<coord_t>(vd_edge));
|
||||
/*Terminology in this function assumes that the edge moves horizontally from
|
||||
left to right. This is not necessarily the case; the edge can go in any
|
||||
direction, but it helps to picture it in a certain direction in your head.*/
|
||||
|
||||
const vd_t::cell_type* left_cell = vd_edge.cell();
|
||||
const vd_t::cell_type* right_cell = vd_edge.twin()->cell();
|
||||
const VD::cell_type *left_cell = vd_edge.cell();
|
||||
const VD::cell_type *right_cell = vd_edge.twin()->cell();
|
||||
|
||||
assert(VoronoiUtils::p(vd_edge.vertex0()).x() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(vd_edge.vertex0()).x() >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(VoronoiUtils::p(vd_edge.vertex0()).y() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(vd_edge.vertex0()).y() >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(VoronoiUtils::p(vd_edge.vertex1()).x() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(vd_edge.vertex1()).x() >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(VoronoiUtils::p(vd_edge.vertex1()).y() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(vd_edge.vertex1()).y() >= std::numeric_limits<coord_t>::lowest());
|
||||
|
||||
Point start = VoronoiUtils::p(vd_edge.vertex0()).cast<coord_t>();
|
||||
Point end = VoronoiUtils::p(vd_edge.vertex1()).cast<coord_t>();
|
||||
Point start = Geometry::VoronoiUtils::to_point(vd_edge.vertex0()).cast<coord_t>();
|
||||
Point end = Geometry::VoronoiUtils::to_point(vd_edge.vertex1()).cast<coord_t>();
|
||||
|
||||
bool point_left = left_cell->contains_point();
|
||||
bool point_right = right_cell->contains_point();
|
||||
@@ -260,17 +236,17 @@ Points SkeletalTrapezoidation::discretize(const vd_t::edge_type& vd_edge, const
|
||||
}
|
||||
else if (point_left != point_right) //This is a parabolic edge between a point and a line.
|
||||
{
|
||||
Point p = VoronoiUtils::getSourcePoint(*(point_left ? left_cell : right_cell), segments);
|
||||
const Segment& s = VoronoiUtils::getSourceSegment(*(point_left ? right_cell : left_cell), segments);
|
||||
return VoronoiUtils::discretizeParabola(p, s, start, end, discretization_step_size, transitioning_angle);
|
||||
Point p = Geometry::VoronoiUtils::get_source_point(*(point_left ? left_cell : right_cell), segments.begin(), segments.end());
|
||||
const Segment& s = Geometry::VoronoiUtils::get_source_segment(*(point_left ? right_cell : left_cell), segments.begin(), segments.end());
|
||||
return Geometry::VoronoiUtils::discretize_parabola(p, s, start, end, discretization_step_size, transitioning_angle);
|
||||
}
|
||||
else //This is a straight edge between two points.
|
||||
{
|
||||
/*While the edge is straight, it is still discretized since the part
|
||||
becomes narrower between the two points. As such it may need different
|
||||
beadings along the way.*/
|
||||
Point left_point = VoronoiUtils::getSourcePoint(*left_cell, segments);
|
||||
Point right_point = VoronoiUtils::getSourcePoint(*right_cell, segments);
|
||||
Point left_point = Geometry::VoronoiUtils::get_source_point(*left_cell, segments.begin(), segments.end());
|
||||
Point right_point = Geometry::VoronoiUtils::get_source_point(*right_cell, segments.begin(), segments.end());
|
||||
coord_t d = (right_point - left_point).cast<int64_t>().norm();
|
||||
Point middle = (left_point + right_point) / 2;
|
||||
Point x_axis_dir = perp(Point(right_point - left_point));
|
||||
@@ -350,8 +326,7 @@ Points SkeletalTrapezoidation::discretize(const vd_t::edge_type& vd_edge, const
|
||||
}
|
||||
}
|
||||
|
||||
bool SkeletalTrapezoidation::computePointCellRange(vd_t::cell_type& cell, Point& start_source_point, Point& end_source_point, vd_t::edge_type*& starting_vd_edge, vd_t::edge_type*& ending_vd_edge, const std::vector<Segment>& segments)
|
||||
{
|
||||
bool SkeletalTrapezoidation::computePointCellRange(const VD::cell_type &cell, Point &start_source_point, Point &end_source_point, const VD::edge_type *&starting_vd_edge, const VD::edge_type *&ending_vd_edge, const std::vector<Segment> &segments) {
|
||||
if (cell.incident_edge()->is_infinite())
|
||||
return false; //Infinite edges only occur outside of the polygon. Don't copy any part of this cell.
|
||||
|
||||
@@ -359,16 +334,16 @@ bool SkeletalTrapezoidation::computePointCellRange(vd_t::cell_type& cell, Point&
|
||||
// Copy whole cell into graph or not at all
|
||||
|
||||
// If the cell.incident_edge()->vertex0() is far away so much that it doesn't even fit into Vec2i64, then there is no way that it will be inside the input polygon.
|
||||
if (const vd_t::vertex_type &vert = *cell.incident_edge()->vertex0();
|
||||
if (const VD::vertex_type &vert = *cell.incident_edge()->vertex0();
|
||||
vert.x() >= double(std::numeric_limits<int64_t>::max()) || vert.x() <= double(std::numeric_limits<int64_t>::lowest()) ||
|
||||
vert.y() >= double(std::numeric_limits<int64_t>::max()) || vert.y() <= double(std::numeric_limits<int64_t>::lowest()))
|
||||
return false; // Don't copy any part of this cell
|
||||
|
||||
const Point source_point = VoronoiUtils::getSourcePoint(cell, segments);
|
||||
const PolygonsPointIndex source_point_index = VoronoiUtils::getSourcePointIndex(cell, segments);
|
||||
Vec2i64 some_point = VoronoiUtils::p(cell.incident_edge()->vertex0());
|
||||
const Point source_point = Geometry::VoronoiUtils::get_source_point(cell, segments.begin(), segments.end());
|
||||
const PolygonsPointIndex source_point_index = Geometry::VoronoiUtils::get_source_point_index(cell, segments.begin(), segments.end());
|
||||
Vec2i64 some_point = Geometry::VoronoiUtils::to_point(cell.incident_edge()->vertex0());
|
||||
if (some_point == source_point.cast<int64_t>())
|
||||
some_point = VoronoiUtils::p(cell.incident_edge()->vertex1());
|
||||
some_point = Geometry::VoronoiUtils::to_point(cell.incident_edge()->vertex1());
|
||||
|
||||
//Test if the some_point is even inside the polygon.
|
||||
//The edge leading out of a polygon must have an endpoint that's not in the corner following the contour of the polygon at that vertex.
|
||||
@@ -377,16 +352,16 @@ bool SkeletalTrapezoidation::computePointCellRange(vd_t::cell_type& cell, Point&
|
||||
if (!LinearAlg2D::isInsideCorner(source_point_index.prev().p(), source_point_index.p(), source_point_index.next().p(), some_point))
|
||||
return false; // Don't copy any part of this cell
|
||||
|
||||
vd_t::edge_type* vd_edge = cell.incident_edge();
|
||||
const VD::edge_type* vd_edge = cell.incident_edge();
|
||||
do {
|
||||
assert(vd_edge->is_finite());
|
||||
if (Vec2i64 p1 = VoronoiUtils::p(vd_edge->vertex1()); p1 == source_point.cast<int64_t>()) {
|
||||
if (Vec2i64 p1 = Geometry::VoronoiUtils::to_point(vd_edge->vertex1()); p1 == source_point.cast<int64_t>()) {
|
||||
start_source_point = source_point;
|
||||
end_source_point = source_point;
|
||||
starting_vd_edge = vd_edge->next();
|
||||
ending_vd_edge = vd_edge;
|
||||
} else {
|
||||
assert((VoronoiUtils::p(vd_edge->vertex0()) == source_point.cast<int64_t>() || !vd_edge->is_secondary()) && "point cells must end in the point! They cannot cross the point with an edge, because collinear edges are not allowed in the input.");
|
||||
assert((Geometry::VoronoiUtils::to_point(vd_edge->vertex0()) == source_point.cast<int64_t>() || !vd_edge->is_secondary()) && "point cells must end in the point! They cannot cross the point with an edge, because collinear edges are not allowed in the input.");
|
||||
}
|
||||
}
|
||||
while (vd_edge = vd_edge->next(), vd_edge != cell.incident_edge());
|
||||
@@ -395,46 +370,6 @@ bool SkeletalTrapezoidation::computePointCellRange(vd_t::cell_type& cell, Point&
|
||||
return true;
|
||||
}
|
||||
|
||||
void SkeletalTrapezoidation::computeSegmentCellRange(vd_t::cell_type& cell, Point& start_source_point, Point& end_source_point, vd_t::edge_type*& starting_vd_edge, vd_t::edge_type*& ending_vd_edge, const std::vector<Segment>& segments)
|
||||
{
|
||||
const Segment &source_segment = VoronoiUtils::getSourceSegment(cell, segments);
|
||||
const Point from = source_segment.from();
|
||||
const Point to = source_segment.to();
|
||||
|
||||
// Find starting edge
|
||||
// Find end edge
|
||||
bool seen_possible_start = false;
|
||||
bool after_start = false;
|
||||
bool ending_edge_is_set_before_start = false;
|
||||
vd_t::edge_type* edge = cell.incident_edge();
|
||||
do {
|
||||
if (edge->is_infinite())
|
||||
continue;
|
||||
|
||||
Vec2i64 v0 = VoronoiUtils::p(edge->vertex0());
|
||||
Vec2i64 v1 = VoronoiUtils::p(edge->vertex1());
|
||||
|
||||
assert(!(v0 == to.cast<int64_t>() && v1 == from.cast<int64_t>() ));
|
||||
if (v0 == to.cast<int64_t>() && !after_start) { // Use the last edge which starts in source_segment.to
|
||||
starting_vd_edge = edge;
|
||||
seen_possible_start = true;
|
||||
}
|
||||
else if (seen_possible_start) {
|
||||
after_start = true;
|
||||
}
|
||||
|
||||
if (v1 == from.cast<int64_t>() && (!ending_vd_edge || ending_edge_is_set_before_start)) {
|
||||
ending_edge_is_set_before_start = !after_start;
|
||||
ending_vd_edge = edge;
|
||||
}
|
||||
} while (edge = edge->next(), edge != cell.incident_edge());
|
||||
|
||||
assert(starting_vd_edge && ending_vd_edge);
|
||||
assert(starting_vd_edge != ending_vd_edge);
|
||||
|
||||
start_source_point = source_segment.to();
|
||||
end_source_point = source_segment.from();
|
||||
}
|
||||
|
||||
SkeletalTrapezoidation::SkeletalTrapezoidation(const Polygons& polys, const BeadingStrategy& beading_strategy,
|
||||
double transitioning_angle, coord_t discretization_step_size,
|
||||
@@ -450,194 +385,6 @@ SkeletalTrapezoidation::SkeletalTrapezoidation(const Polygons& polys, const Bead
|
||||
constructFromPolygons(polys);
|
||||
}
|
||||
|
||||
static bool has_finite_edge_with_non_finite_vertex(const Geometry::VoronoiDiagram &voronoi_diagram)
|
||||
{
|
||||
for (const VoronoiUtils::vd_t::edge_type &edge : voronoi_diagram.edges()) {
|
||||
if (edge.is_finite()) {
|
||||
assert(edge.vertex0() != nullptr && edge.vertex1() != nullptr);
|
||||
if (edge.vertex0() == nullptr || edge.vertex1() == nullptr || !VoronoiUtils::is_finite(*edge.vertex0()) ||
|
||||
!VoronoiUtils::is_finite(*edge.vertex1()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool detect_missing_voronoi_vertex(const Geometry::VoronoiDiagram &voronoi_diagram, const std::vector<SkeletalTrapezoidation::Segment> &segments) {
|
||||
if (has_finite_edge_with_non_finite_vertex(voronoi_diagram))
|
||||
return true;
|
||||
|
||||
for (VoronoiUtils::vd_t::cell_type cell : voronoi_diagram.cells()) {
|
||||
if (!cell.incident_edge())
|
||||
continue; // There is no spoon
|
||||
|
||||
if (cell.contains_segment()) {
|
||||
const SkeletalTrapezoidation::Segment &source_segment = VoronoiUtils::getSourceSegment(cell, segments);
|
||||
const Point from = source_segment.from();
|
||||
const Point to = source_segment.to();
|
||||
|
||||
// Find starting edge
|
||||
// Find end edge
|
||||
bool seen_possible_start = false;
|
||||
bool after_start = false;
|
||||
bool ending_edge_is_set_before_start = false;
|
||||
VoronoiUtils::vd_t::edge_type *starting_vd_edge = nullptr;
|
||||
VoronoiUtils::vd_t::edge_type *ending_vd_edge = nullptr;
|
||||
VoronoiUtils::vd_t::edge_type *edge = cell.incident_edge();
|
||||
do {
|
||||
if (edge->is_infinite() || edge->vertex0() == nullptr || edge->vertex1() == nullptr || !VoronoiUtils::is_finite(*edge->vertex0()) || !VoronoiUtils::is_finite(*edge->vertex1()))
|
||||
continue;
|
||||
|
||||
Vec2i64 v0 = VoronoiUtils::p(edge->vertex0());
|
||||
Vec2i64 v1 = VoronoiUtils::p(edge->vertex1());
|
||||
|
||||
assert(!(v0 == to.cast<int64_t>() && v1 == from.cast<int64_t>()));
|
||||
if (v0 == to.cast<int64_t>() && !after_start) { // Use the last edge which starts in source_segment.to
|
||||
starting_vd_edge = edge;
|
||||
seen_possible_start = true;
|
||||
} else if (seen_possible_start) {
|
||||
after_start = true;
|
||||
}
|
||||
|
||||
if (v1 == from.cast<int64_t>() && (!ending_vd_edge || ending_edge_is_set_before_start)) {
|
||||
ending_edge_is_set_before_start = !after_start;
|
||||
ending_vd_edge = edge;
|
||||
}
|
||||
} while (edge = edge->next(), edge != cell.incident_edge());
|
||||
|
||||
if (!starting_vd_edge || !ending_vd_edge || starting_vd_edge == ending_vd_edge)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool has_missing_twin_edge(const SkeletalTrapezoidationGraph &graph)
|
||||
{
|
||||
for (const auto &edge : graph.edges)
|
||||
if (edge.twin == nullptr)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
using PointMap = SkeletalTrapezoidation::PointMap;
|
||||
|
||||
inline static void rotate_back_skeletal_trapezoidation_graph_after_fix(SkeletalTrapezoidationGraph &graph,
|
||||
const double fix_angle,
|
||||
const PointMap &vertex_mapping)
|
||||
{
|
||||
for (STHalfEdgeNode &node : graph.nodes) {
|
||||
// If a mapping exists between a rotated point and an original point, use this mapping. Otherwise, rotate a point in the opposite direction.
|
||||
if (auto node_it = vertex_mapping.find(node.p); node_it != vertex_mapping.end())
|
||||
node.p = node_it->second;
|
||||
else
|
||||
node.p.rotate(-fix_angle);
|
||||
}
|
||||
}
|
||||
|
||||
bool detect_voronoi_edge_intersecting_input_segment(const Geometry::VoronoiDiagram &voronoi_diagram, const std::vector<VoronoiUtils::Segment> &segments)
|
||||
{
|
||||
for (VoronoiUtils::vd_t::cell_type cell : voronoi_diagram.cells()) {
|
||||
if (!cell.incident_edge())
|
||||
continue; // Degenerated cell, there is no spoon
|
||||
|
||||
if (!cell.contains_segment())
|
||||
continue; // Skip cells that don't contain segments.
|
||||
|
||||
const VoronoiUtils::Segment &source_segment = VoronoiUtils::getSourceSegment(cell, segments);
|
||||
const Vec2d source_segment_from = source_segment.from().cast<double>();
|
||||
const Vec2d source_segment_vec = source_segment.to().cast<double>() - source_segment_from;
|
||||
|
||||
Point start_source_point, end_source_point;
|
||||
VoronoiUtils::vd_t::edge_type *begin_voronoi_edge = nullptr, *end_voronoi_edge = nullptr;
|
||||
SkeletalTrapezoidation::computeSegmentCellRange(cell, start_source_point, end_source_point, begin_voronoi_edge, end_voronoi_edge, segments);
|
||||
// All Voronoi vertices must be on left side of the source segment, otherwise Voronoi diagram is invalid.
|
||||
// FIXME Lukas H.: Be aware that begin_voronoi_edge and end_voronoi_edge could be nullptr in some specific cases.
|
||||
// It mostly happens when there is some missing Voronoi, for example, in GH issue #8846 (IssuesWithMysteriousPerimeters.3mf).
|
||||
if (begin_voronoi_edge != nullptr && end_voronoi_edge != nullptr)
|
||||
for (VoronoiUtils::vd_t::edge_type *edge = begin_voronoi_edge; edge != end_voronoi_edge; edge = edge->next())
|
||||
if (const Vec2d edge_v1(edge->vertex1()->x(), edge->vertex1()->y()); Slic3r::cross2(source_segment_vec, edge_v1 - source_segment_from) < 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
enum class VoronoiDiagramStatus {
|
||||
NO_ISSUE_DETECTED,
|
||||
MISSING_VORONOI_VERTEX,
|
||||
NON_PLANAR_VORONOI_DIAGRAM,
|
||||
VORONOI_EDGE_INTERSECTING_INPUT_SEGMENT,
|
||||
OTHER_TYPE_OF_VORONOI_DIAGRAM_DEGENERATION
|
||||
};
|
||||
|
||||
// Try to detect cases when some Voronoi vertex is missing, when the Voronoi diagram
|
||||
// is not planar or some Voronoi edge is intersecting input segment.
|
||||
VoronoiDiagramStatus detect_voronoi_diagram_known_issues(const Geometry::VoronoiDiagram &voronoi_diagram,
|
||||
const std::vector<SkeletalTrapezoidation::Segment> &segments)
|
||||
{
|
||||
if (const bool has_missing_voronoi_vertex = detect_missing_voronoi_vertex(voronoi_diagram, segments); has_missing_voronoi_vertex) {
|
||||
return VoronoiDiagramStatus::MISSING_VORONOI_VERTEX;
|
||||
} else if (const bool has_voronoi_edge_intersecting_input_segment = detect_voronoi_edge_intersecting_input_segment(voronoi_diagram, segments); has_voronoi_edge_intersecting_input_segment) {
|
||||
// Detection if Voronoi edge is intersecting input segment detects at least one model in GH issue #8446.
|
||||
return VoronoiDiagramStatus::VORONOI_EDGE_INTERSECTING_INPUT_SEGMENT;
|
||||
} else if (const bool is_voronoi_diagram_planar = Geometry::VoronoiUtilsCgal::is_voronoi_diagram_planar_angle(voronoi_diagram, segments); !is_voronoi_diagram_planar) {
|
||||
// Detection of non-planar Voronoi diagram detects at least GH issues #8474, #8514 and #8446.
|
||||
return VoronoiDiagramStatus::NON_PLANAR_VORONOI_DIAGRAM;
|
||||
}
|
||||
return VoronoiDiagramStatus::NO_ISSUE_DETECTED;
|
||||
}
|
||||
|
||||
inline static std::pair<PointMap, double> try_to_fix_degenerated_voronoi_diagram_by_rotation(
|
||||
Geometry::VoronoiDiagram &voronoi_diagram,
|
||||
const Polygons &polys,
|
||||
Polygons &polys_rotated,
|
||||
std::vector<SkeletalTrapezoidation::Segment> &segments,
|
||||
const std::vector<double> &fix_angles)
|
||||
{
|
||||
const Polygons polys_rotated_original = polys_rotated;
|
||||
double fixed_by_angle = fix_angles.front();
|
||||
PointMap vertex_mapping;
|
||||
|
||||
for (const double &fix_angle : fix_angles) {
|
||||
vertex_mapping.clear();
|
||||
polys_rotated = polys_rotated_original;
|
||||
fixed_by_angle = fix_angle;
|
||||
|
||||
for (Polygon &poly : polys_rotated)
|
||||
poly.rotate(fix_angle);
|
||||
|
||||
assert(polys_rotated.size() == polys.size());
|
||||
for (size_t poly_idx = 0; poly_idx < polys.size(); ++poly_idx) {
|
||||
assert(polys_rotated[poly_idx].size() == polys[poly_idx].size());
|
||||
for (size_t point_idx = 0; point_idx < polys[poly_idx].size(); ++point_idx)
|
||||
vertex_mapping.insert({polys_rotated[poly_idx][point_idx], polys[poly_idx][point_idx]});
|
||||
}
|
||||
|
||||
segments.clear();
|
||||
for (size_t poly_idx = 0; poly_idx < polys_rotated.size(); poly_idx++)
|
||||
for (size_t point_idx = 0; point_idx < polys_rotated[poly_idx].size(); point_idx++)
|
||||
segments.emplace_back(&polys_rotated, poly_idx, point_idx);
|
||||
|
||||
voronoi_diagram.clear();
|
||||
construct_voronoi(segments.begin(), segments.end(), &voronoi_diagram);
|
||||
|
||||
#ifdef ARACHNE_DEBUG_VORONOI
|
||||
{
|
||||
static int iRun = 0;
|
||||
dump_voronoi_to_svg(debug_out_path("arachne_voronoi-diagram-rotated-%d.svg", iRun++).c_str(), voronoi_diagram, to_points(polys), to_lines(polys));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (detect_voronoi_diagram_known_issues(voronoi_diagram, segments) == VoronoiDiagramStatus::NO_ISSUE_DETECTED)
|
||||
break;
|
||||
}
|
||||
|
||||
assert(Geometry::VoronoiUtilsCgal::is_voronoi_diagram_planar_intersection(voronoi_diagram));
|
||||
|
||||
return {vertex_mapping, fixed_by_angle};
|
||||
}
|
||||
|
||||
void SkeletalTrapezoidation::constructFromPolygons(const Polygons& polys)
|
||||
{
|
||||
@@ -670,8 +417,8 @@ void SkeletalTrapezoidation::constructFromPolygons(const Polygons& polys)
|
||||
}
|
||||
#endif
|
||||
|
||||
Geometry::VoronoiDiagram voronoi_diagram;
|
||||
construct_voronoi(segments.begin(), segments.end(), &voronoi_diagram);
|
||||
VD voronoi_diagram;
|
||||
voronoi_diagram.construct_voronoi(segments.cbegin(), segments.cend());
|
||||
|
||||
#ifdef ARACHNE_DEBUG_VORONOI
|
||||
{
|
||||
@@ -680,45 +427,15 @@ void SkeletalTrapezoidation::constructFromPolygons(const Polygons& polys)
|
||||
}
|
||||
#endif
|
||||
|
||||
// When any Voronoi vertex is missing, the Voronoi diagram is not planar, or some voronoi edge is
|
||||
// intersecting input segment, rotate the input polygon and try again.
|
||||
VoronoiDiagramStatus status = detect_voronoi_diagram_known_issues(voronoi_diagram, segments);
|
||||
const std::vector<double> fix_angles = {PI / 6, PI / 5, PI / 7, PI / 11};
|
||||
double fixed_by_angle = fix_angles.front();
|
||||
|
||||
PointMap vertex_mapping;
|
||||
// polys_copy is referenced through items stored in the std::vector segments.
|
||||
Polygons polys_copy = polys;
|
||||
if (status != VoronoiDiagramStatus::NO_ISSUE_DETECTED) {
|
||||
if (status == VoronoiDiagramStatus::MISSING_VORONOI_VERTEX)
|
||||
BOOST_LOG_TRIVIAL(warning) << "Detected missing Voronoi vertex, input polygons will be rotated back and forth.";
|
||||
else if (status == VoronoiDiagramStatus::NON_PLANAR_VORONOI_DIAGRAM)
|
||||
BOOST_LOG_TRIVIAL(warning) << "Detected non-planar Voronoi diagram, input polygons will be rotated back and forth.";
|
||||
else if (status == VoronoiDiagramStatus::VORONOI_EDGE_INTERSECTING_INPUT_SEGMENT)
|
||||
BOOST_LOG_TRIVIAL(warning) << "Detected Voronoi edge intersecting input segment, input polygons will be rotated back and forth.";
|
||||
|
||||
std::tie(vertex_mapping, fixed_by_angle) = try_to_fix_degenerated_voronoi_diagram_by_rotation(voronoi_diagram, polys, polys_copy, segments, fix_angles);
|
||||
|
||||
VoronoiDiagramStatus status_after_fix = detect_voronoi_diagram_known_issues(voronoi_diagram, segments);
|
||||
assert(status_after_fix == VoronoiDiagramStatus::NO_ISSUE_DETECTED);
|
||||
if (status_after_fix == VoronoiDiagramStatus::MISSING_VORONOI_VERTEX)
|
||||
BOOST_LOG_TRIVIAL(error) << "Detected missing Voronoi vertex even after the rotation of input.";
|
||||
else if (status_after_fix == VoronoiDiagramStatus::NON_PLANAR_VORONOI_DIAGRAM)
|
||||
BOOST_LOG_TRIVIAL(error) << "Detected non-planar Voronoi diagram even after the rotation of input.";
|
||||
else if (status_after_fix == VoronoiDiagramStatus::VORONOI_EDGE_INTERSECTING_INPUT_SEGMENT)
|
||||
BOOST_LOG_TRIVIAL(error) << "Detected Voronoi edge intersecting input segment even after the rotation of input.";
|
||||
}
|
||||
|
||||
process_voronoi_diagram:
|
||||
assert(this->graph.edges.empty() && this->graph.nodes.empty() && this->vd_edge_to_he_edge.empty() && this->vd_node_to_he_node.empty());
|
||||
for (vd_t::cell_type cell : voronoi_diagram.cells()) {
|
||||
for (const VD::cell_type &cell : voronoi_diagram.cells()) {
|
||||
if (!cell.incident_edge())
|
||||
continue; // There is no spoon
|
||||
|
||||
Point start_source_point;
|
||||
Point end_source_point;
|
||||
vd_t::edge_type* starting_voronoi_edge = nullptr;
|
||||
vd_t::edge_type* ending_voronoi_edge = nullptr;
|
||||
const VD::edge_type *starting_voronoi_edge = nullptr;
|
||||
const VD::edge_type *ending_voronoi_edge = nullptr;
|
||||
// Compute and store result in above variables
|
||||
|
||||
if (cell.contains_point()) {
|
||||
@@ -727,7 +444,12 @@ process_voronoi_diagram:
|
||||
continue;
|
||||
} else {
|
||||
assert(cell.contains_segment());
|
||||
computeSegmentCellRange(cell, start_source_point, end_source_point, starting_voronoi_edge, ending_voronoi_edge, segments);
|
||||
Geometry::SegmentCellRange<Point> cell_range = Geometry::VoronoiUtils::compute_segment_cell_range(cell, segments.cbegin(), segments.cend());
|
||||
assert(cell_range.is_valid());
|
||||
start_source_point = cell_range.segment_start_point;
|
||||
end_source_point = cell_range.segment_end_point;
|
||||
starting_voronoi_edge = cell_range.edge_begin;
|
||||
ending_voronoi_edge = cell_range.edge_end;
|
||||
}
|
||||
|
||||
if (!starting_voronoi_edge || !ending_voronoi_edge) {
|
||||
@@ -736,68 +458,30 @@ process_voronoi_diagram:
|
||||
}
|
||||
|
||||
// Copy start to end edge to graph
|
||||
assert(Geometry::VoronoiUtils::is_in_range<coord_t>(*starting_voronoi_edge));
|
||||
edge_t* prev_edge = nullptr;
|
||||
assert(VoronoiUtils::p(starting_voronoi_edge->vertex1()).x() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(starting_voronoi_edge->vertex1()).x() >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(VoronoiUtils::p(starting_voronoi_edge->vertex1()).y() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(starting_voronoi_edge->vertex1()).y() >= std::numeric_limits<coord_t>::lowest());
|
||||
transferEdge(start_source_point, VoronoiUtils::p(starting_voronoi_edge->vertex1()).cast<coord_t>(), *starting_voronoi_edge, prev_edge, start_source_point, end_source_point, segments);
|
||||
transferEdge(start_source_point, Geometry::VoronoiUtils::to_point(starting_voronoi_edge->vertex1()).cast<coord_t>(), *starting_voronoi_edge, prev_edge, start_source_point, end_source_point, segments);
|
||||
node_t* starting_node = vd_node_to_he_node[starting_voronoi_edge->vertex0()];
|
||||
starting_node->data.distance_to_boundary = 0;
|
||||
|
||||
constexpr bool is_next_to_start_or_end = true;
|
||||
graph.makeRib(prev_edge, start_source_point, end_source_point, is_next_to_start_or_end);
|
||||
for (vd_t::edge_type* vd_edge = starting_voronoi_edge->next(); vd_edge != ending_voronoi_edge; vd_edge = vd_edge->next()) {
|
||||
for (const VD::edge_type* vd_edge = starting_voronoi_edge->next(); vd_edge != ending_voronoi_edge; vd_edge = vd_edge->next()) {
|
||||
assert(vd_edge->is_finite());
|
||||
|
||||
assert(VoronoiUtils::p(vd_edge->vertex0()).x() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(vd_edge->vertex0()).x() >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(VoronoiUtils::p(vd_edge->vertex0()).y() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(vd_edge->vertex0()).y() >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(VoronoiUtils::p(vd_edge->vertex1()).x() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(vd_edge->vertex1()).x() >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(VoronoiUtils::p(vd_edge->vertex1()).y() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(vd_edge->vertex1()).y() >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(Geometry::VoronoiUtils::is_in_range<coord_t>(*vd_edge));
|
||||
|
||||
Point v1 = VoronoiUtils::p(vd_edge->vertex0()).cast<coord_t>();
|
||||
Point v2 = VoronoiUtils::p(vd_edge->vertex1()).cast<coord_t>();
|
||||
Point v1 = Geometry::VoronoiUtils::to_point(vd_edge->vertex0()).cast<coord_t>();
|
||||
Point v2 = Geometry::VoronoiUtils::to_point(vd_edge->vertex1()).cast<coord_t>();
|
||||
transferEdge(v1, v2, *vd_edge, prev_edge, start_source_point, end_source_point, segments);
|
||||
|
||||
graph.makeRib(prev_edge, start_source_point, end_source_point, vd_edge->next() == ending_voronoi_edge);
|
||||
}
|
||||
|
||||
assert(VoronoiUtils::p(starting_voronoi_edge->vertex0()).x() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(starting_voronoi_edge->vertex0()).x() >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(VoronoiUtils::p(starting_voronoi_edge->vertex0()).y() <= std::numeric_limits<coord_t>::max() && VoronoiUtils::p(starting_voronoi_edge->vertex0()).y() >= std::numeric_limits<coord_t>::lowest());
|
||||
transferEdge(VoronoiUtils::p(ending_voronoi_edge->vertex0()).cast<coord_t>(), end_source_point, *ending_voronoi_edge, prev_edge, start_source_point, end_source_point, segments);
|
||||
transferEdge(Geometry::VoronoiUtils::to_point(ending_voronoi_edge->vertex0()).cast<coord_t>(), end_source_point, *ending_voronoi_edge, prev_edge, start_source_point, end_source_point, segments);
|
||||
prev_edge->to->data.distance_to_boundary = 0;
|
||||
}
|
||||
|
||||
// For some input polygons, as in GH issues #8474 and #8514 resulting Voronoi diagram is degenerated because it is not planar.
|
||||
// When this degenerated Voronoi diagram is processed, the resulting half-edge structure contains some edges that don't have
|
||||
// a twin edge. Based on this, we created a fast mechanism that detects those causes and tries to recompute the Voronoi
|
||||
// diagram on slightly rotated input polygons that usually make the Voronoi generator generate a non-degenerated Voronoi diagram.
|
||||
if (status == VoronoiDiagramStatus::NO_ISSUE_DETECTED && has_missing_twin_edge(this->graph)) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "Detected degenerated Voronoi diagram, input polygons will be rotated back and forth.";
|
||||
status = VoronoiDiagramStatus::OTHER_TYPE_OF_VORONOI_DIAGRAM_DEGENERATION;
|
||||
std::tie(vertex_mapping, fixed_by_angle) = try_to_fix_degenerated_voronoi_diagram_by_rotation(voronoi_diagram, polys, polys_copy, segments, fix_angles);
|
||||
|
||||
assert(!detect_missing_voronoi_vertex(voronoi_diagram, segments));
|
||||
if (detect_missing_voronoi_vertex(voronoi_diagram, segments))
|
||||
BOOST_LOG_TRIVIAL(error) << "Detected missing Voronoi vertex after the rotation of input.";
|
||||
|
||||
assert(Geometry::VoronoiUtilsCgal::is_voronoi_diagram_planar_intersection(voronoi_diagram));
|
||||
|
||||
this->graph.edges.clear();
|
||||
this->graph.nodes.clear();
|
||||
this->vd_edge_to_he_edge.clear();
|
||||
this->vd_node_to_he_node.clear();
|
||||
|
||||
goto process_voronoi_diagram;
|
||||
}
|
||||
|
||||
if (status != VoronoiDiagramStatus::NO_ISSUE_DETECTED) {
|
||||
assert(!has_missing_twin_edge(this->graph));
|
||||
|
||||
if (has_missing_twin_edge(this->graph))
|
||||
BOOST_LOG_TRIVIAL(error) << "Detected degenerated Voronoi diagram even after the rotation of input.";
|
||||
}
|
||||
|
||||
if (status != VoronoiDiagramStatus::NO_ISSUE_DETECTED)
|
||||
rotate_back_skeletal_trapezoidation_graph_after_fix(this->graph, fixed_by_angle, vertex_mapping);
|
||||
|
||||
#ifdef ARACHNE_DEBUG
|
||||
assert(Geometry::VoronoiUtilsCgal::is_voronoi_diagram_planar_intersection(voronoi_diagram));
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include <ankerl/unordered_dense.h>
|
||||
|
||||
#include <Arachne/utils/VoronoiUtils.hpp>
|
||||
|
||||
#include "utils/HalfEdgeGraph.hpp"
|
||||
#include "utils/PolygonsSegmentIndex.hpp"
|
||||
@@ -26,8 +25,9 @@
|
||||
//#define ARACHNE_DEBUG
|
||||
//#define ARACHNE_DEBUG_VORONOI
|
||||
|
||||
namespace Slic3r::Arachne
|
||||
{
|
||||
namespace Slic3r::Arachne {
|
||||
|
||||
using VD = Slic3r::Geometry::VoronoiDiagram;
|
||||
|
||||
/*!
|
||||
* Main class of the dynamic beading strategies.
|
||||
@@ -50,8 +50,6 @@ deposition modeling" by Kuipers et al.
|
||||
*/
|
||||
class SkeletalTrapezoidation
|
||||
{
|
||||
using pos_t = double;
|
||||
using vd_t = boost::polygon::voronoi_diagram<pos_t>;
|
||||
using graph_t = SkeletalTrapezoidationGraph;
|
||||
using edge_t = STHalfEdge;
|
||||
using node_t = STHalfEdgeNode;
|
||||
@@ -83,7 +81,6 @@ class SkeletalTrapezoidation
|
||||
|
||||
public:
|
||||
using Segment = PolygonsSegmentIndex;
|
||||
using PointMap = ankerl::unordered_dense::map<Point, Point, PointHash>;
|
||||
using NodeSet = ankerl::unordered_dense::set<node_t*>;
|
||||
|
||||
/*!
|
||||
@@ -168,9 +165,9 @@ protected:
|
||||
* mapping each voronoi VD edge to the corresponding halfedge HE edge
|
||||
* In case the result segment is discretized, we map the VD edge to the *last* HE edge
|
||||
*/
|
||||
ankerl::unordered_dense::map<vd_t::edge_type*, edge_t*> vd_edge_to_he_edge;
|
||||
ankerl::unordered_dense::map<vd_t::vertex_type*, node_t*> vd_node_to_he_node;
|
||||
node_t& makeNode(vd_t::vertex_type& vd_node, Point p); //!< Get the node which the VD node maps to, or create a new mapping if there wasn't any yet.
|
||||
ankerl::unordered_dense::map<const VD::edge_type *, edge_t *> vd_edge_to_he_edge;
|
||||
ankerl::unordered_dense::map<const VD::vertex_type *, node_t *> vd_node_to_he_node;
|
||||
node_t &makeNode(const VD::vertex_type &vd_node, Point p); //!< Get the node which the VD node maps to, or create a new mapping if there wasn't any yet.
|
||||
|
||||
/*!
|
||||
* (Eventual) returned 'polylines per index' result (from generateToolpaths):
|
||||
@@ -181,7 +178,7 @@ protected:
|
||||
* Transfer an edge from the VD to the HE and perform discretization of parabolic edges (and vertex-vertex edges)
|
||||
* \p prev_edge serves as input and output. May be null as input.
|
||||
*/
|
||||
void transferEdge(Point from, Point to, vd_t::edge_type& vd_edge, edge_t*& prev_edge, Point& start_source_point, Point& end_source_point, const std::vector<Segment>& segments);
|
||||
void transferEdge(Point from, Point to, const VD::edge_type &vd_edge, edge_t *&prev_edge, Point &start_source_point, Point &end_source_point, const std::vector<Segment> &segments);
|
||||
|
||||
/*!
|
||||
* Discretize a Voronoi edge that represents the medial axis of a vertex-
|
||||
@@ -208,7 +205,7 @@ protected:
|
||||
* \return A number of coordinates along the edge where the edge is broken
|
||||
* up into discrete pieces.
|
||||
*/
|
||||
Points discretize(const vd_t::edge_type& segment, const std::vector<Segment>& segments);
|
||||
Points discretize(const VD::edge_type& segment, const std::vector<Segment>& segments);
|
||||
|
||||
/*!
|
||||
* Compute the range of line segments that surround a cell of the skeletal
|
||||
@@ -234,33 +231,7 @@ protected:
|
||||
* /return Whether the cell is inside of the polygon. If it's outside of the
|
||||
* polygon we should skip processing it altogether.
|
||||
*/
|
||||
static bool computePointCellRange(vd_t::cell_type& cell, Point& start_source_point, Point& end_source_point, vd_t::edge_type*& starting_vd_edge, vd_t::edge_type*& ending_vd_edge, const std::vector<Segment>& segments);
|
||||
|
||||
/*!
|
||||
* Compute the range of line segments that surround a cell of the skeletal
|
||||
* graph that belongs to a line segment of the medial axis.
|
||||
*
|
||||
* This should only be used on cells that belong to a central line segment
|
||||
* of the skeletal graph, e.g. trapezoid cells, not triangular cells.
|
||||
*
|
||||
* The resulting line segments is just the first and the last segment. They
|
||||
* are linked to the neighboring segments, so you can iterate over the
|
||||
* segments until you reach the last segment.
|
||||
* \param cell The cell to compute the range of line segments for.
|
||||
* \param[out] start_source_point The start point of the source segment of
|
||||
* this cell.
|
||||
* \param[out] end_source_point The end point of the source segment of this
|
||||
* cell.
|
||||
* \param[out] starting_vd_edge The edge of the Voronoi diagram where the
|
||||
* loop around the cell starts.
|
||||
* \param[out] ending_vd_edge The edge of the Voronoi diagram where the loop
|
||||
* around the cell ends.
|
||||
* \param points All vertices of the input Polygons.
|
||||
* \param segments All edges of the input Polygons.
|
||||
* /return Whether the cell is inside of the polygon. If it's outside of the
|
||||
* polygon we should skip processing it altogether.
|
||||
*/
|
||||
static void computeSegmentCellRange(vd_t::cell_type& cell, Point& start_source_point, Point& end_source_point, vd_t::edge_type*& starting_vd_edge, vd_t::edge_type*& ending_vd_edge, const std::vector<Segment>& segments);
|
||||
static bool computePointCellRange(const VD::cell_type &cell, Point &start_source_point, Point &end_source_point, const VD::edge_type *&starting_vd_edge, const VD::edge_type *&ending_vd_edge, const std::vector<Segment> &segments);
|
||||
|
||||
/*!
|
||||
* For VD cells associated with an input polygon vertex, we need to separate the node at the end and start of the cell into two
|
||||
@@ -603,7 +574,7 @@ protected:
|
||||
*/
|
||||
void generateLocalMaximaSingleBeads();
|
||||
|
||||
friend bool detect_voronoi_edge_intersecting_input_segment(const Geometry::VoronoiDiagram &voronoi_diagram, const std::vector<VoronoiUtils::Segment> &segments);
|
||||
friend bool detect_voronoi_edge_intersecting_input_segment(const VD &voronoi_diagram, const std::vector<Segment> &segments);
|
||||
};
|
||||
|
||||
} // namespace Slic3r::Arachne
|
||||
|
||||
@@ -156,7 +156,6 @@ struct PathsPointIndexLocator
|
||||
}
|
||||
};
|
||||
|
||||
using PolygonsPointIndexLocator = PathsPointIndexLocator<Polygons>;
|
||||
|
||||
}//namespace Slic3r::Arachne
|
||||
|
||||
|
||||
@@ -27,5 +27,24 @@ public:
|
||||
|
||||
} // namespace Slic3r::Arachne
|
||||
|
||||
namespace boost::polygon {
|
||||
|
||||
template<> struct geometry_concept<Slic3r::Arachne::PolygonsSegmentIndex>
|
||||
{
|
||||
typedef segment_concept type;
|
||||
};
|
||||
|
||||
template<> struct segment_traits<Slic3r::Arachne::PolygonsSegmentIndex>
|
||||
{
|
||||
typedef coord_t coordinate_type;
|
||||
typedef Slic3r::Point point_type;
|
||||
|
||||
static inline point_type get(const Slic3r::Arachne::PolygonsSegmentIndex &CSegment, direction_1d dir)
|
||||
{
|
||||
return dir.to_int() ? CSegment.to() : CSegment.from();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace boost::polygon
|
||||
|
||||
#endif//UTILS_POLYGONS_SEGMENT_INDEX_H
|
||||
|
||||
@@ -1,251 +0,0 @@
|
||||
//Copyright (c) 2021 Ultimaker B.V.
|
||||
//CuraEngine is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
#include <stack>
|
||||
#include <optional>
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
#include "linearAlg2D.hpp"
|
||||
#include "VoronoiUtils.hpp"
|
||||
|
||||
namespace Slic3r::Arachne
|
||||
{
|
||||
|
||||
Vec2i64 VoronoiUtils::p(const vd_t::vertex_type *node)
|
||||
{
|
||||
const double x = node->x();
|
||||
const double y = node->y();
|
||||
assert(std::isfinite(x) && std::isfinite(y));
|
||||
assert(x <= double(std::numeric_limits<int64_t>::max()) && x >= std::numeric_limits<int64_t>::lowest());
|
||||
assert(y <= double(std::numeric_limits<int64_t>::max()) && y >= std::numeric_limits<int64_t>::lowest());
|
||||
return {int64_t(x + 0.5 - (x < 0)), int64_t(y + 0.5 - (y < 0))}; // Round to the nearest integer coordinates.
|
||||
}
|
||||
|
||||
Point VoronoiUtils::getSourcePoint(const vd_t::cell_type& cell, const std::vector<Segment>& segments)
|
||||
{
|
||||
assert(cell.contains_point());
|
||||
if(!cell.contains_point())
|
||||
BOOST_LOG_TRIVIAL(debug) << "Voronoi cell doesn't contain a source point!";
|
||||
|
||||
switch (cell.source_category()) {
|
||||
case boost::polygon::SOURCE_CATEGORY_SINGLE_POINT:
|
||||
assert(false && "Voronoi diagram is always constructed using segments, so cell.source_category() shouldn't be SOURCE_CATEGORY_SINGLE_POINT!\n");
|
||||
BOOST_LOG_TRIVIAL(error) << "Voronoi diagram is always constructed using segments, so cell.source_category() shouldn't be SOURCE_CATEGORY_SINGLE_POINT!";
|
||||
break;
|
||||
case boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT:
|
||||
assert(cell.source_index() < segments.size());
|
||||
return segments[cell.source_index()].to();
|
||||
break;
|
||||
case boost::polygon::SOURCE_CATEGORY_SEGMENT_END_POINT:
|
||||
assert(cell.source_index() < segments.size());
|
||||
return segments[cell.source_index()].from();
|
||||
break;
|
||||
default:
|
||||
assert(false && "getSourcePoint should only be called on point cells!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
assert(false && "cell.source_category() is equal to an invalid value!\n");
|
||||
BOOST_LOG_TRIVIAL(error) << "cell.source_category() is equal to an invalid value!";
|
||||
return {};
|
||||
}
|
||||
|
||||
PolygonsPointIndex VoronoiUtils::getSourcePointIndex(const vd_t::cell_type& cell, const std::vector<Segment>& segments)
|
||||
{
|
||||
assert(cell.contains_point());
|
||||
if(!cell.contains_point())
|
||||
BOOST_LOG_TRIVIAL(debug) << "Voronoi cell doesn't contain a source point!";
|
||||
|
||||
assert(cell.source_category() != boost::polygon::SOURCE_CATEGORY_SINGLE_POINT);
|
||||
switch (cell.source_category()) {
|
||||
case boost::polygon::SOURCE_CATEGORY_SEGMENT_START_POINT: {
|
||||
assert(cell.source_index() < segments.size());
|
||||
PolygonsPointIndex ret = segments[cell.source_index()];
|
||||
++ret;
|
||||
return ret;
|
||||
break;
|
||||
}
|
||||
case boost::polygon::SOURCE_CATEGORY_SEGMENT_END_POINT: {
|
||||
assert(cell.source_index() < segments.size());
|
||||
return segments[cell.source_index()];
|
||||
break;
|
||||
}
|
||||
default:
|
||||
assert(false && "getSourcePoint should only be called on point cells!\n");
|
||||
break;
|
||||
}
|
||||
PolygonsPointIndex ret = segments[cell.source_index()];
|
||||
return ++ret;
|
||||
}
|
||||
|
||||
const VoronoiUtils::Segment &VoronoiUtils::getSourceSegment(const vd_t::cell_type &cell, const std::vector<Segment> &segments)
|
||||
{
|
||||
assert(cell.contains_segment());
|
||||
if (!cell.contains_segment())
|
||||
BOOST_LOG_TRIVIAL(debug) << "Voronoi cell doesn't contain a source segment!";
|
||||
|
||||
return segments[cell.source_index()];
|
||||
}
|
||||
|
||||
class PointMatrix
|
||||
{
|
||||
public:
|
||||
double matrix[4];
|
||||
|
||||
PointMatrix()
|
||||
{
|
||||
matrix[0] = 1;
|
||||
matrix[1] = 0;
|
||||
matrix[2] = 0;
|
||||
matrix[3] = 1;
|
||||
}
|
||||
|
||||
PointMatrix(double rotation)
|
||||
{
|
||||
rotation = rotation / 180 * M_PI;
|
||||
matrix[0] = cos(rotation);
|
||||
matrix[1] = -sin(rotation);
|
||||
matrix[2] = -matrix[1];
|
||||
matrix[3] = matrix[0];
|
||||
}
|
||||
|
||||
PointMatrix(const Point p)
|
||||
{
|
||||
matrix[0] = p.x();
|
||||
matrix[1] = p.y();
|
||||
double f = sqrt((matrix[0] * matrix[0]) + (matrix[1] * matrix[1]));
|
||||
matrix[0] /= f;
|
||||
matrix[1] /= f;
|
||||
matrix[2] = -matrix[1];
|
||||
matrix[3] = matrix[0];
|
||||
}
|
||||
|
||||
static PointMatrix scale(double s)
|
||||
{
|
||||
PointMatrix ret;
|
||||
ret.matrix[0] = s;
|
||||
ret.matrix[3] = s;
|
||||
return ret;
|
||||
}
|
||||
|
||||
Point apply(const Point p) const
|
||||
{
|
||||
return Point(coord_t(p.x() * matrix[0] + p.y() * matrix[1]), coord_t(p.x() * matrix[2] + p.y() * matrix[3]));
|
||||
}
|
||||
|
||||
Point unapply(const Point p) const
|
||||
{
|
||||
return Point(coord_t(p.x() * matrix[0] + p.y() * matrix[2]), coord_t(p.x() * matrix[1] + p.y() * matrix[3]));
|
||||
}
|
||||
};
|
||||
Points VoronoiUtils::discretizeParabola(const Point& p, const Segment& segment, Point s, Point e, coord_t approximate_step_size, float transitioning_angle)
|
||||
{
|
||||
Points discretized;
|
||||
// x is distance of point projected on the segment ab
|
||||
// xx is point projected on the segment ab
|
||||
const Point a = segment.from();
|
||||
const Point b = segment.to();
|
||||
const Point ab = b - a;
|
||||
const Point as = s - a;
|
||||
const Point ae = e - a;
|
||||
const coord_t ab_size = ab.cast<int64_t>().norm();
|
||||
const coord_t sx = as.cast<int64_t>().dot(ab.cast<int64_t>()) / ab_size;
|
||||
const coord_t ex = ae.cast<int64_t>().dot(ab.cast<int64_t>()) / ab_size;
|
||||
const coord_t sxex = ex - sx;
|
||||
|
||||
assert((as.cast<int64_t>().dot(ab.cast<int64_t>()) / int64_t(ab_size)) <= std::numeric_limits<coord_t>::max());
|
||||
assert((ae.cast<int64_t>().dot(ab.cast<int64_t>()) / int64_t(ab_size)) <= std::numeric_limits<coord_t>::max());
|
||||
|
||||
const Point ap = p - a;
|
||||
const coord_t px = ap.cast<int64_t>().dot(ab.cast<int64_t>()) / ab_size;
|
||||
|
||||
assert((ap.cast<int64_t>().dot(ab.cast<int64_t>()) / int64_t(ab_size)) <= std::numeric_limits<coord_t>::max());
|
||||
|
||||
Point pxx;
|
||||
Line(a, b).distance_to_infinite_squared(p, &pxx);
|
||||
const Point ppxx = pxx - p;
|
||||
const coord_t d = ppxx.cast<int64_t>().norm();
|
||||
const PointMatrix rot = PointMatrix(perp(ppxx));
|
||||
|
||||
if (d == 0)
|
||||
{
|
||||
discretized.emplace_back(s);
|
||||
discretized.emplace_back(e);
|
||||
return discretized;
|
||||
}
|
||||
|
||||
const float marking_bound = atan(transitioning_angle * 0.5);
|
||||
int64_t msx = - marking_bound * int64_t(d); // projected marking_start
|
||||
int64_t mex = marking_bound * int64_t(d); // projected marking_end
|
||||
|
||||
assert(msx <= std::numeric_limits<coord_t>::max());
|
||||
assert(double(msx) * double(msx) <= double(std::numeric_limits<int64_t>::max()));
|
||||
assert(mex <= std::numeric_limits<coord_t>::max());
|
||||
assert(double(msx) * double(msx) / double(2 * d) + double(d / 2) <= std::numeric_limits<coord_t>::max());
|
||||
|
||||
const coord_t marking_start_end_h = msx * msx / (2 * d) + d / 2;
|
||||
Point marking_start = rot.unapply(Point(coord_t(msx), marking_start_end_h)) + pxx;
|
||||
Point marking_end = rot.unapply(Point(coord_t(mex), marking_start_end_h)) + pxx;
|
||||
const int dir = (sx > ex) ? -1 : 1;
|
||||
if (dir < 0)
|
||||
{
|
||||
std::swap(marking_start, marking_end);
|
||||
std::swap(msx, mex);
|
||||
}
|
||||
|
||||
bool add_marking_start = msx * int64_t(dir) > int64_t(sx - px) * int64_t(dir) && msx * int64_t(dir) < int64_t(ex - px) * int64_t(dir);
|
||||
bool add_marking_end = mex * int64_t(dir) > int64_t(sx - px) * int64_t(dir) && mex * int64_t(dir) < int64_t(ex - px) * int64_t(dir);
|
||||
|
||||
const Point apex = rot.unapply(Point(0, d / 2)) + pxx;
|
||||
bool add_apex = int64_t(sx - px) * int64_t(dir) < 0 && int64_t(ex - px) * int64_t(dir) > 0;
|
||||
|
||||
assert(!(add_marking_start && add_marking_end) || add_apex);
|
||||
if(add_marking_start && add_marking_end && !add_apex)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(warning) << "Failing to discretize parabola! Must add an apex or one of the endpoints.";
|
||||
}
|
||||
|
||||
const coord_t step_count = static_cast<coord_t>(static_cast<float>(std::abs(ex - sx)) / approximate_step_size + 0.5);
|
||||
|
||||
discretized.emplace_back(s);
|
||||
for (coord_t step = 1; step < step_count; step++)
|
||||
{
|
||||
assert(double(sxex) * double(step) <= double(std::numeric_limits<int64_t>::max()));
|
||||
const int64_t x = int64_t(sx) + int64_t(sxex) * int64_t(step) / int64_t(step_count) - int64_t(px);
|
||||
assert(double(x) * double(x) <= double(std::numeric_limits<int64_t>::max()));
|
||||
assert(double(x) * double(x) / double(2 * d) + double(d / 2) <= double(std::numeric_limits<int64_t>::max()));
|
||||
const int64_t y = int64_t(x) * int64_t(x) / int64_t(2 * d) + int64_t(d / 2);
|
||||
|
||||
if (add_marking_start && msx * int64_t(dir) < int64_t(x) * int64_t(dir))
|
||||
{
|
||||
discretized.emplace_back(marking_start);
|
||||
add_marking_start = false;
|
||||
}
|
||||
if (add_apex && int64_t(x) * int64_t(dir) > 0)
|
||||
{
|
||||
discretized.emplace_back(apex);
|
||||
add_apex = false; // only add the apex just before the
|
||||
}
|
||||
if (add_marking_end && mex * int64_t(dir) < int64_t(x) * int64_t(dir))
|
||||
{
|
||||
discretized.emplace_back(marking_end);
|
||||
add_marking_end = false;
|
||||
}
|
||||
assert(x <= std::numeric_limits<coord_t>::max() && x >= std::numeric_limits<coord_t>::lowest());
|
||||
assert(y <= std::numeric_limits<coord_t>::max() && y >= std::numeric_limits<coord_t>::lowest());
|
||||
const Point result = rot.unapply(Point(x, y)) + pxx;
|
||||
discretized.emplace_back(result);
|
||||
}
|
||||
if (add_apex)
|
||||
{
|
||||
discretized.emplace_back(apex);
|
||||
}
|
||||
if (add_marking_end)
|
||||
{
|
||||
discretized.emplace_back(marking_end);
|
||||
}
|
||||
discretized.emplace_back(e);
|
||||
return discretized;
|
||||
}
|
||||
|
||||
}//namespace Slic3r::Arachne
|
||||
@@ -1,47 +0,0 @@
|
||||
//Copyright (c) 2020 Ultimaker B.V.
|
||||
//CuraEngine is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
|
||||
#ifndef UTILS_VORONOI_UTILS_H
|
||||
#define UTILS_VORONOI_UTILS_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
#include <boost/polygon/voronoi.hpp>
|
||||
|
||||
#include "PolygonsSegmentIndex.hpp"
|
||||
|
||||
namespace Slic3r::Arachne
|
||||
{
|
||||
|
||||
/*!
|
||||
*/
|
||||
class VoronoiUtils
|
||||
{
|
||||
public:
|
||||
using Segment = PolygonsSegmentIndex;
|
||||
using voronoi_data_t = double;
|
||||
using vd_t = boost::polygon::voronoi_diagram<voronoi_data_t>;
|
||||
|
||||
static Point getSourcePoint(const vd_t::cell_type &cell, const std::vector<Segment> &segments);
|
||||
static const Segment &getSourceSegment(const vd_t::cell_type &cell, const std::vector<Segment> &segments);
|
||||
static PolygonsPointIndex getSourcePointIndex(const vd_t::cell_type &cell, const std::vector<Segment> &segments);
|
||||
|
||||
static Vec2i64 p(const vd_t::vertex_type *node);
|
||||
|
||||
/*!
|
||||
* Discretize a parabola based on (approximate) step size.
|
||||
* The \p approximate_step_size is measured parallel to the \p source_segment, not along the parabola.
|
||||
*/
|
||||
static Points discretizeParabola(const Point &source_point, const Segment &source_segment, Point start, Point end, coord_t approximate_step_size, float transitioning_angle);
|
||||
|
||||
static inline bool is_finite(const VoronoiUtils::vd_t::vertex_type &vertex)
|
||||
{
|
||||
return std::isfinite(vertex.x()) && std::isfinite(vertex.y());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Slic3r::Arachne
|
||||
|
||||
#endif // UTILS_VORONOI_UTILS_H
|
||||
@@ -58,7 +58,7 @@ class DefaultArrangerCtl : public Arranger<ArrItem>::Ctl {
|
||||
public:
|
||||
DefaultArrangerCtl() = default;
|
||||
|
||||
explicit DefaultArrangerCtl(ArrangeTaskBase::Ctl &ctl) : taskctl{&ctl} {}
|
||||
explicit DefaultArrangerCtl(ArrangeTaskCtl &ctl) : taskctl{&ctl} {}
|
||||
|
||||
void update_status(int st) override
|
||||
{
|
||||
|
||||
@@ -325,7 +325,7 @@ class DefaultArranger: public Arranger<ArrItem> {
|
||||
// a pure RectangleBed with inner-fit polygon calculation.
|
||||
if (!with_wipe_tower &&
|
||||
m_settings.get_arrange_strategy() == ArrangeSettingsView::asAuto &&
|
||||
std::is_convertible_v<Bed, RectangleBed>) {
|
||||
IsRectangular<Bed>) {
|
||||
PackStrategyNFP base_strategy{std::move(kernel), ep, Accuracy, stop_cond};
|
||||
|
||||
RectangleOverfitPackingStrategy final_strategy{std::move(base_strategy)};
|
||||
|
||||
@@ -181,6 +181,11 @@ inline ExPolygons to_expolygons(const ArrangeBed &bed)
|
||||
|
||||
ArrangeBed to_arrange_bed(const Points &bedpts);
|
||||
|
||||
template<class Bed, class En = void> struct IsRectangular_ : public std::false_type {};
|
||||
template<> struct IsRectangular_<RectangleBed>: public std::true_type {};
|
||||
template<> struct IsRectangular_<BoundingBox>: public std::true_type {};
|
||||
|
||||
template<class Bed> static constexpr bool IsRectangular = IsRectangular_<Bed>::value;
|
||||
} // namespace arr2
|
||||
|
||||
inline BoundingBox &bounding_box(BoundingBox &bb) { return bb; }
|
||||
|
||||
@@ -51,9 +51,9 @@ protected:
|
||||
public:
|
||||
TMArrangeKernel() = default;
|
||||
TMArrangeKernel(Vec2crd gravity_center, size_t itm_cnt, double bedarea = NaNd)
|
||||
: sink{gravity_center}
|
||||
, m_bin_area(bedarea)
|
||||
: m_bin_area(bedarea)
|
||||
, m_item_cnt{itm_cnt}
|
||||
, sink{gravity_center}
|
||||
{}
|
||||
|
||||
TMArrangeKernel(size_t itm_cnt, double bedarea = NaNd)
|
||||
@@ -87,8 +87,6 @@ public:
|
||||
// Will hold the resulting score
|
||||
double score = 0;
|
||||
|
||||
// Density is the pack density: how big is the arranged pile
|
||||
double density = 0;
|
||||
|
||||
// Distinction of cases for the arrangement scene
|
||||
enum e_cases {
|
||||
@@ -96,8 +94,6 @@ public:
|
||||
// OR for all items in a small-only scene.
|
||||
BIG_ITEM,
|
||||
|
||||
// This branch is for the last big item in a mixed scene
|
||||
LAST_BIG_ITEM,
|
||||
|
||||
// For small items in a mixed scene.
|
||||
SMALL_ITEM,
|
||||
@@ -109,10 +105,8 @@ public:
|
||||
bool bigitems = is_big(envelope_area(item)) || m_rtree.empty();
|
||||
if (is_wt)
|
||||
compute_case = WIPE_TOWER;
|
||||
else if (bigitems && m_rem_cnt > 0)
|
||||
else if (bigitems)
|
||||
compute_case = BIG_ITEM;
|
||||
else if (bigitems && m_rem_cnt == 0)
|
||||
compute_case = LAST_BIG_ITEM;
|
||||
else
|
||||
compute_case = SMALL_ITEM;
|
||||
|
||||
@@ -129,20 +123,8 @@ public:
|
||||
Point top_left{minc.x(), maxc.y()};
|
||||
Point bottom_right{maxc.x(), minc.y()};
|
||||
|
||||
// Now the distance of the gravity center will be calculated to the
|
||||
// five anchor points and the smallest will be chosen.
|
||||
std::array<double, 5> dists;
|
||||
auto cc = fullbb.center(); // The gravity center
|
||||
dists[0] = (minc - cc).cast<double>().norm();
|
||||
dists[1] = (maxc - cc).cast<double>().norm();
|
||||
dists[2] = (itmcntr - cc).template cast<double>().norm();
|
||||
dists[3] = (top_left - cc).cast<double>().norm();
|
||||
dists[4] = (bottom_right - cc).cast<double>().norm();
|
||||
|
||||
// The smalles distance from the arranged pile center:
|
||||
double dist = norm(*(std::min_element(dists.begin(), dists.end())));
|
||||
double bindist = norm((ibb.center() - active_sink).template cast<double>().norm());
|
||||
dist = 0.8 * dist + 0.2 * bindist;
|
||||
// The smallest distance from the arranged pile center:
|
||||
double dist = norm((itmcntr - m_pilebb.center()).template cast<double>().norm());
|
||||
|
||||
// Prepare a variable for the alignment score.
|
||||
// This will indicate: how well is the candidate item
|
||||
@@ -150,7 +132,7 @@ public:
|
||||
// with all neighbors and return the score for the best
|
||||
// alignment. So it is enough for the candidate to be
|
||||
// aligned with only one item.
|
||||
auto alignment_score = 1.0;
|
||||
auto alignment_score = 1.;
|
||||
|
||||
auto query = bgi::intersects(ibb);
|
||||
auto& index = is_big(envelope_area(item)) ? m_rtree : m_smallsrtree;
|
||||
@@ -170,33 +152,24 @@ public:
|
||||
auto bb = p.bb;
|
||||
bb.merge(ibb);
|
||||
auto bbarea = area(bb);
|
||||
auto ascore = 1.0 - (fixed_area(item) + parea) / bbarea;
|
||||
auto ascore = 1.0 - (area(fixed_bounding_box(item)) + area(p.bb)) / bbarea;
|
||||
|
||||
if(ascore < alignment_score)
|
||||
alignment_score = ascore;
|
||||
}
|
||||
}
|
||||
|
||||
auto fullbbsz = fullbb.size();
|
||||
density = std::sqrt(norm(fullbbsz.x()) * norm(fullbbsz.y()));
|
||||
double R = double(m_rem_cnt) / (m_item_cnt);
|
||||
R = std::pow(R, 1./3.);
|
||||
|
||||
// The final mix of the score is the balance between the
|
||||
// distance from the full pile center, the pack density and
|
||||
// the alignment with the neighbors
|
||||
if (result.empty())
|
||||
score = 0.50 * dist + 0.50 * density;
|
||||
else
|
||||
// Let the density matter more when fewer objects remain
|
||||
score = 0.50 * dist + (1.0 - R) * 0.20 * density +
|
||||
0.30 * alignment_score;
|
||||
score = 0.6 * dist + 0.1 * alignment_score + (1.0 - R) * (0.3 * dist) + R * 0.3 * alignment_score;
|
||||
|
||||
break;
|
||||
}
|
||||
case LAST_BIG_ITEM: {
|
||||
score = norm((itmcntr - m_pilebb.center()).template cast<double>().norm());
|
||||
break;
|
||||
}
|
||||
case SMALL_ITEM: {
|
||||
// Here there are the small items that should be placed around the
|
||||
// already processed bigger items.
|
||||
@@ -236,8 +209,11 @@ public:
|
||||
if (m_item_cnt == 0)
|
||||
m_item_cnt = m_rem_cnt + fixed.size() + 1;
|
||||
|
||||
if (std::isnan(m_bin_area))
|
||||
m_bin_area = area(bed);
|
||||
if (std::isnan(m_bin_area)) {
|
||||
auto sz = bounding_box(bed).size();
|
||||
|
||||
m_bin_area = scaled<double>(unscaled(sz.x()) * unscaled(sz.y()));
|
||||
}
|
||||
|
||||
m_norm = std::sqrt(m_bin_area);
|
||||
|
||||
@@ -245,7 +221,7 @@ public:
|
||||
m_itemstats.reserve(fixed.size());
|
||||
m_rtree.clear();
|
||||
m_smallsrtree.clear();
|
||||
m_pilebb = {};
|
||||
m_pilebb = {active_sink, active_sink};
|
||||
unsigned idx = 0;
|
||||
for (auto &fixitem : fixed) {
|
||||
auto fixitmbb = fixed_bounding_box(fixitem);
|
||||
|
||||
@@ -101,6 +101,9 @@ ExPolygons to_expolygons(const SegmentedRectangleBed<Args...> &bed)
|
||||
return to_expolygons(RectangleBed{bed.bb});
|
||||
}
|
||||
|
||||
template<class SegB>
|
||||
struct IsRectangular_<SegB, std::enable_if_t<IsSegmentedBed<SegB>, void>> : public std::true_type
|
||||
{};
|
||||
}} // namespace Slic3r::arr2
|
||||
|
||||
#endif // SEGMENTEDRECTANGLEBED_HPP
|
||||
|
||||
@@ -115,21 +115,13 @@ ArrangeTask<ArrItem>::process_native(Ctl &ctl)
|
||||
|
||||
} subctl{ctl, *this};
|
||||
|
||||
auto fixed_items = printable.unselected;
|
||||
|
||||
// static (unselected) unprintable objects should not be overlapped by
|
||||
// movable and printable objects
|
||||
std::copy(unprintable.unselected.begin(),
|
||||
unprintable.unselected.end(),
|
||||
std::back_inserter(fixed_items));
|
||||
|
||||
arranger->arrange(printable.selected, fixed_items, bed, subctl);
|
||||
arranger->arrange(printable.selected, printable.unselected, bed, subctl);
|
||||
|
||||
std::vector<int> printable_bed_indices =
|
||||
get_bed_indices(crange(printable.selected), crange(printable.unselected));
|
||||
|
||||
// If there are no printables, leave the physical bed empty
|
||||
constexpr int SearchFrom = 1;
|
||||
static constexpr int SearchFrom = 1;
|
||||
|
||||
// Unprintable items should go to the first logical (!) bed not containing
|
||||
// any printable items
|
||||
|
||||
@@ -31,7 +31,29 @@ public:
|
||||
: BoundingBoxBase(points.begin(), points.end())
|
||||
{}
|
||||
|
||||
void reset() { this->defined = false; this->min = PointType::Zero(); this->max = PointType::Zero(); }
|
||||
void reset()
|
||||
{
|
||||
this->defined = false;
|
||||
this->min = PointType::Zero();
|
||||
this->max = PointType::Zero();
|
||||
}
|
||||
// B66
|
||||
Polygon polygon(bool is_scaled = false) const
|
||||
{
|
||||
Polygon polygon;
|
||||
polygon.points.clear();
|
||||
polygon.points.resize(4);
|
||||
double scale_factor = 1 / (is_scaled ? SCALING_FACTOR : 1);
|
||||
polygon.points[0](0) = this->min(0) * scale_factor;
|
||||
polygon.points[0](1) = this->min(1) * scale_factor;
|
||||
polygon.points[1](0) = this->max(0) * scale_factor;
|
||||
polygon.points[1](1) = this->min(1) * scale_factor;
|
||||
polygon.points[2](0) = this->max(0) * scale_factor;
|
||||
polygon.points[2](1) = this->max(1) * scale_factor;
|
||||
polygon.points[3](0) = this->min(0) * scale_factor;
|
||||
polygon.points[3](1) = this->max(1) * scale_factor;
|
||||
return polygon;
|
||||
};
|
||||
void merge(const PointType &point);
|
||||
void merge(const PointsType &points);
|
||||
void merge(const BoundingBoxBase<PointType, PointsType> &bb);
|
||||
@@ -142,6 +164,15 @@ public:
|
||||
return this->min.x() < other.max.x() && this->max.x() > other.min.x() && this->min.y() < other.max.y() && this->max.y() > other.min.y() &&
|
||||
this->min.z() < other.max.z() && this->max.z() > other.min.z();
|
||||
}
|
||||
// Shares some boundary.
|
||||
bool shares_boundary(const BoundingBox3Base<PointType>& other) const {
|
||||
return is_approx(this->min.x(), other.max.x()) ||
|
||||
is_approx(this->max.x(), other.min.x()) ||
|
||||
is_approx(this->min.y(), other.max.y()) ||
|
||||
is_approx(this->max.y(), other.min.y()) ||
|
||||
is_approx(this->min.z(), other.max.z()) ||
|
||||
is_approx(this->max.z(), other.min.z());
|
||||
}
|
||||
};
|
||||
|
||||
// Will prevent warnings caused by non existing definition of template in hpp
|
||||
|
||||
@@ -8,7 +8,9 @@
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
BuildVolume::BuildVolume(const std::vector<Vec2d> &bed_shape, const double max_print_height) : m_bed_shape(bed_shape), m_max_print_height(max_print_height)
|
||||
//B52
|
||||
BuildVolume::BuildVolume(const std::vector<Vec2d> &bed_shape, const double max_print_height, const std::vector<Vec2d> &exclude_bed_shape)
|
||||
: m_bed_shape(bed_shape), m_max_print_height(max_print_height),m_exclude_bed_shape(exclude_bed_shape)
|
||||
{
|
||||
assert(max_print_height >= 0);
|
||||
|
||||
@@ -22,11 +24,16 @@ BuildVolume::BuildVolume(const std::vector<Vec2d> &bed_shape, const double max_p
|
||||
BoundingBoxf bboxf = get_extents(bed_shape);
|
||||
m_bboxf = BoundingBoxf3{ to_3d(bboxf.min, 0.), to_3d(bboxf.max, max_print_height) };
|
||||
|
||||
//B52
|
||||
if (bed_shape.size() >= 4 && std::abs((m_area - double(m_bbox.size().x()) * double(m_bbox.size().y()))) < sqr(SCALED_EPSILON)) {
|
||||
// Square print bed, use the bounding box for collision detection.
|
||||
m_type = Type::Rectangle;
|
||||
m_circle.center = 0.5 * (m_bbox.min.cast<double>() + m_bbox.max.cast<double>());
|
||||
m_circle.radius = 0.5 * m_bbox.size().cast<double>().norm();
|
||||
} else if (exclude_bed_shape.size()>3) {
|
||||
m_type = Type::Rectangle;
|
||||
m_circle.center = 0.5 * (m_bbox.min.cast<double>() + m_bbox.max.cast<double>());
|
||||
m_circle.radius = 0.5 * m_bbox.size().cast<double>().norm();
|
||||
} else if (bed_shape.size() > 3) {
|
||||
// Circle was discretized, formatted into text with limited accuracy, thus the circle was deformed.
|
||||
// RANSAC is slightly more accurate than the iterative Taubin / Newton method with such an input.
|
||||
@@ -304,19 +311,50 @@ BuildVolume::ObjectState BuildVolume::object_state(const indexed_triangle_set& i
|
||||
}
|
||||
}
|
||||
|
||||
//B52
|
||||
BuildVolume::ObjectState BuildVolume::volume_state_bbox(const BoundingBoxf3& volume_bbox, bool ignore_bottom) const
|
||||
{
|
||||
assert(m_type == Type::Rectangle);
|
||||
BoundingBox3Base<Vec3d> build_volume = this->bounding_volume().inflated(SceneEpsilon);
|
||||
std::vector<BoundingBox3Base<Vec3d>> exclude_build_volume;
|
||||
for (int i = 1; i < m_exclude_bed_shape.size(); i += 7) {
|
||||
std::vector<Vec2d> tem_exclude_bed_shap;
|
||||
for (int j = 1; j < 6; j++)
|
||||
tem_exclude_bed_shap.push_back(m_exclude_bed_shape[i + j]);
|
||||
BoundingBoxf tem_bboxf = get_extents(tem_exclude_bed_shap);
|
||||
auto tem_exclude_bboxf = BoundingBoxf3{to_3d(tem_bboxf.min, 0.), to_3d(tem_bboxf.max, m_max_print_height)};
|
||||
BoundingBox3Base<Vec3d> tem_build_volume = tem_exclude_bboxf.inflated(SceneEpsilon);
|
||||
exclude_build_volume.push_back(tem_build_volume);
|
||||
}
|
||||
|
||||
bool is_contain = false;
|
||||
bool is_intersect = false;
|
||||
|
||||
for (const auto &tem_build_volume : exclude_build_volume) {
|
||||
if (tem_build_volume.contains(volume_bbox)) {
|
||||
is_contain=true;
|
||||
is_intersect = false;
|
||||
break;
|
||||
}
|
||||
else if (tem_build_volume.intersects(volume_bbox)) {
|
||||
is_contain = false;
|
||||
is_intersect = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (m_max_print_height == 0.0)
|
||||
build_volume.max.z() = std::numeric_limits<double>::max();
|
||||
if (ignore_bottom)
|
||||
build_volume.min.z() = -std::numeric_limits<double>::max();
|
||||
return build_volume.max.z() <= - SceneEpsilon ? ObjectState::Below :
|
||||
is_contain ? ObjectState::Outside :
|
||||
is_intersect ? ObjectState::Outside :
|
||||
build_volume.contains(volume_bbox) ? ObjectState::Inside :
|
||||
build_volume.intersects(volume_bbox) ? ObjectState::Colliding : ObjectState::Outside;
|
||||
build_volume.intersects(volume_bbox) ? ObjectState::Colliding :
|
||||
ObjectState::Outside;
|
||||
}
|
||||
|
||||
//B52
|
||||
bool BuildVolume::all_paths_inside(const GCodeProcessorResult& paths, const BoundingBoxf3& paths_bbox, bool ignore_bottom) const
|
||||
{
|
||||
auto move_valid = [](const GCodeProcessorResult::MoveVertex &move) {
|
||||
@@ -332,6 +370,32 @@ bool BuildVolume::all_paths_inside(const GCodeProcessorResult& paths, const Boun
|
||||
build_volume.max.z() = std::numeric_limits<double>::max();
|
||||
if (ignore_bottom)
|
||||
build_volume.min.z() = -std::numeric_limits<double>::max();
|
||||
// B66
|
||||
Points pts;
|
||||
for (const GCodeProcessorResult::MoveVertex &move : paths.moves) {
|
||||
if (move.type == EMoveType::Extrude && move.extrusion_role != GCodeExtrusionRole::Custom && move.width != 0.0f &&
|
||||
move.height != 0.0f)
|
||||
pts.emplace_back(Point(scale_(move.position.x()), scale_(move.position.y())));
|
||||
}
|
||||
|
||||
if ((build_volume.contains(paths_bbox))) {
|
||||
if (m_exclude_bed_shape.size() > 0) {
|
||||
Slic3r::Polygon convex_hull_2d = Slic3r::Geometry::convex_hull(std::move(pts));
|
||||
for (int i = 1; i < m_exclude_bed_shape.size(); i += 7) {
|
||||
std::vector<Vec2d> tem_exclude_bed_shap;
|
||||
for (int j = 1; j < 6; j++)
|
||||
tem_exclude_bed_shap.push_back(m_exclude_bed_shape[i + j]);
|
||||
BoundingBoxf tem_bboxf = get_extents(tem_exclude_bed_shap);
|
||||
auto tem_exclude_bboxf = BoundingBoxf3{to_3d(tem_bboxf.min, 0.), to_3d(tem_bboxf.max, m_max_print_height)};
|
||||
Slic3r::Polygon p = tem_exclude_bboxf.polygon(true); // instance convex hull is scaled, so we need to scale here
|
||||
if (intersection({p}, {convex_hull_2d}).empty() == false) {
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return build_volume.contains(paths_bbox);
|
||||
}
|
||||
case Type::Circle:
|
||||
|
||||
@@ -34,10 +34,13 @@ public:
|
||||
// Initialized to empty, all zeros, Invalid.
|
||||
BuildVolume() {}
|
||||
// Initialize from PrintConfig::bed_shape and PrintConfig::max_print_height
|
||||
BuildVolume(const std::vector<Vec2d> &bed_shape, const double max_print_height);
|
||||
//B52
|
||||
BuildVolume(const std::vector<Vec2d> &bed_shape, const double max_print_height, const std::vector<Vec2d> &exclude_bed_shape);
|
||||
|
||||
// Source data, unscaled coordinates.
|
||||
const std::vector<Vec2d>& bed_shape() const { return m_bed_shape; }
|
||||
//B52
|
||||
const std::vector<Vec2d>& exclude_bed_shape() const { return m_exclude_bed_shape; }
|
||||
double max_print_height() const { return m_max_print_height; }
|
||||
|
||||
// Derived data
|
||||
@@ -101,6 +104,8 @@ public:
|
||||
private:
|
||||
// Source definition of the print bed geometry (PrintConfig::bed_shape)
|
||||
std::vector<Vec2d> m_bed_shape;
|
||||
//B52
|
||||
std::vector<Vec2d> m_exclude_bed_shape;
|
||||
// Source definition of the print volume height (PrintConfig::max_print_height)
|
||||
double m_max_print_height;
|
||||
|
||||
|
||||
@@ -80,7 +80,6 @@ set(SLIC3R_SOURCES
|
||||
ExtrusionSimulator.hpp
|
||||
FileParserError.hpp
|
||||
Fill/Fill.cpp
|
||||
Fill/Fill.hpp
|
||||
Fill/Fill3DHoneycomb.cpp
|
||||
Fill/Fill3DHoneycomb.hpp
|
||||
Fill/FillAdaptive.cpp
|
||||
@@ -89,6 +88,10 @@ set(SLIC3R_SOURCES
|
||||
Fill/FillBase.hpp
|
||||
Fill/FillConcentric.cpp
|
||||
Fill/FillConcentric.hpp
|
||||
Fill/FillConcentricInternal.cpp
|
||||
Fill/FillConcentricInternal.hpp
|
||||
Fill/FillCrossHatch.cpp
|
||||
Fill/FillCrossHatch.hpp
|
||||
Fill/FillEnsuring.cpp
|
||||
Fill/FillEnsuring.hpp
|
||||
Fill/FillHoneycomb.cpp
|
||||
@@ -184,6 +187,8 @@ set(SLIC3R_SOURCES
|
||||
GCode/GCodeProcessor.hpp
|
||||
GCode/AvoidCrossingPerimeters.cpp
|
||||
GCode/AvoidCrossingPerimeters.hpp
|
||||
GCode/Travels.cpp
|
||||
GCode/Travels.hpp
|
||||
GCode.cpp
|
||||
GCode.hpp
|
||||
GCodeReader.cpp
|
||||
@@ -205,6 +210,8 @@ set(SLIC3R_SOURCES
|
||||
Geometry/Voronoi.hpp
|
||||
Geometry/VoronoiOffset.cpp
|
||||
Geometry/VoronoiOffset.hpp
|
||||
Geometry/VoronoiUtils.hpp
|
||||
Geometry/VoronoiUtils.cpp
|
||||
Geometry/VoronoiVisualUtils.hpp
|
||||
Int128.hpp
|
||||
JumpPointSearch.cpp
|
||||
@@ -212,6 +219,7 @@ set(SLIC3R_SOURCES
|
||||
KDTreeIndirect.hpp
|
||||
Layer.cpp
|
||||
Layer.hpp
|
||||
LayerRegion.hpp
|
||||
LayerRegion.cpp
|
||||
libslic3r.h
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libslic3r_version.h"
|
||||
@@ -486,8 +494,9 @@ set(SLIC3R_SOURCES
|
||||
Arachne/utils/PolygonsSegmentIndex.hpp
|
||||
Arachne/utils/PolylineStitcher.hpp
|
||||
Arachne/utils/PolylineStitcher.cpp
|
||||
Arachne/utils/VoronoiUtils.hpp
|
||||
Arachne/utils/VoronoiUtils.cpp
|
||||
Geometry/Voronoi.cpp
|
||||
Geometry/VoronoiUtils.hpp
|
||||
Geometry/VoronoiUtils.cpp
|
||||
Arachne/SkeletalTrapezoidation.hpp
|
||||
Arachne/SkeletalTrapezoidation.cpp
|
||||
Arachne/SkeletalTrapezoidationEdge.hpp
|
||||
|
||||
@@ -793,6 +793,7 @@ Slic3r::ExPolygons union_ex(const Slic3r::ExPolygons &subject, const Slic3r::Pol
|
||||
Slic3r::ExPolygons union_ex(const Slic3r::Surfaces &subject)
|
||||
{ return PolyTreeToExPolygons(clipper_do_polytree(ClipperLib::ctUnion, ClipperUtils::SurfacesProvider(subject), ClipperUtils::EmptyPathsProvider(), ClipperLib::pftNonZero)); }
|
||||
|
||||
|
||||
template<typename PathsProvider1, typename PathsProvider2>
|
||||
Polylines _clipper_pl_open(ClipperLib::ClipType clipType, PathsProvider1 &&subject, PathsProvider2 &&clip)
|
||||
{
|
||||
|
||||
@@ -447,6 +447,7 @@ Slic3r::Polylines diff_pl(const Slic3r::Polylines &subject, const Slic3r::ExPol
|
||||
Slic3r::Polylines diff_pl(const Slic3r::Polylines &subject, const Slic3r::ExPolygons &clip);
|
||||
Slic3r::Polylines diff_pl(const Slic3r::Polygons &subject, const Slic3r::Polygons &clip);
|
||||
|
||||
|
||||
inline Slic3r::Lines diff_ln(const Slic3r::Lines &subject, const Slic3r::Polygons &clip)
|
||||
{
|
||||
return _clipper_ln(ClipperLib::ctDifference, subject, clip);
|
||||
@@ -473,6 +474,7 @@ Slic3r::ExPolygons intersection_ex(const Slic3r::Surfaces &subject, const Slic3r
|
||||
Slic3r::ExPolygons intersection_ex(const Slic3r::Surfaces &subject, const Slic3r::ExPolygons &clip, ApplySafetyOffset do_safety_offset = ApplySafetyOffset::No);
|
||||
Slic3r::ExPolygons intersection_ex(const Slic3r::Surfaces &subject, const Slic3r::Surfaces &clip, ApplySafetyOffset do_safety_offset = ApplySafetyOffset::No);
|
||||
Slic3r::ExPolygons intersection_ex(const Slic3r::SurfacesPtr &subject, const Slic3r::ExPolygons &clip, ApplySafetyOffset do_safety_offset = ApplySafetyOffset::No);
|
||||
|
||||
Slic3r::Polylines intersection_pl(const Slic3r::Polylines &subject, const Slic3r::Polygon &clip);
|
||||
Slic3r::Polylines intersection_pl(const Slic3r::Polyline &subject, const Slic3r::ExPolygon &clip);
|
||||
Slic3r::Polylines intersection_pl(const Slic3r::Polylines &subject, const Slic3r::ExPolygon &clip);
|
||||
|
||||
@@ -245,6 +245,8 @@ ConfigOption* ConfigOptionDef::create_empty_option() const
|
||||
{
|
||||
if (this->nullable) {
|
||||
switch (this->type) {
|
||||
case coFloat: return new ConfigOptionFloatNullable();
|
||||
case coInt: return new ConfigOptionIntNullable();
|
||||
case coFloats: return new ConfigOptionFloatsNullable();
|
||||
case coInts: return new ConfigOptionIntsNullable();
|
||||
case coPercents: return new ConfigOptionPercentsNullable();
|
||||
@@ -883,6 +885,8 @@ size_t ConfigBase::load_from_gcode_string_legacy(ConfigBase& config, const char*
|
||||
end = start;
|
||||
}
|
||||
|
||||
// Do legacy conversion on a completely loaded dictionary.
|
||||
// Perform composite conversions, for example merging multiple keys into one key.
|
||||
config.handle_legacy_composite();
|
||||
return num_key_value_pairs;
|
||||
}
|
||||
@@ -1410,6 +1414,9 @@ CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionSingle<std::string>)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionSingle<Slic3r::Vec2d>)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionSingle<Slic3r::Vec3d>)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionSingle<bool>)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionSingleNullable<double>)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionSingleNullable<int>)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionSingleNullable<bool>)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionVectorBase)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionVector<double>)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionVector<int>)
|
||||
@@ -1417,9 +1424,11 @@ CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionVector<std::string>)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionVector<Slic3r::Vec2d>)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionVector<unsigned char>)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionFloat)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionFloatNullable)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionFloats)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionFloatsNullable)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionInt)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionIntNullable)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionInts)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionIntsNullable)
|
||||
CEREAL_REGISTER_TYPE(Slic3r::ConfigOptionString)
|
||||
@@ -1446,6 +1455,9 @@ CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOption, Slic3r::ConfigOptionS
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOption, Slic3r::ConfigOptionSingle<Slic3r::Vec2d>)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOption, Slic3r::ConfigOptionSingle<Slic3r::Vec3d>)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOption, Slic3r::ConfigOptionSingle<bool>)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOption, Slic3r::ConfigOptionSingleNullable<double>)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOption, Slic3r::ConfigOptionSingleNullable<int>)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOption, Slic3r::ConfigOptionSingleNullable<bool>)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOption, Slic3r::ConfigOptionVectorBase)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOptionVectorBase, Slic3r::ConfigOptionVector<double>)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOptionVectorBase, Slic3r::ConfigOptionVector<int>)
|
||||
@@ -1453,9 +1465,11 @@ CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOptionVectorBase, Slic3r::Con
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOptionVectorBase, Slic3r::ConfigOptionVector<Slic3r::Vec2d>)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOptionVectorBase, Slic3r::ConfigOptionVector<unsigned char>)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOptionSingle<double>, Slic3r::ConfigOptionFloat)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOptionSingleNullable<double>, Slic3r::ConfigOptionFloatNullable)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOptionVector<double>, Slic3r::ConfigOptionFloats)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOptionVector<double>, Slic3r::ConfigOptionFloatsNullable)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOptionSingle<int>, Slic3r::ConfigOptionInt)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOptionSingleNullable<int>, Slic3r::ConfigOptionIntNullable)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOptionVector<int>, Slic3r::ConfigOptionInts)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOptionVector<int>, Slic3r::ConfigOptionIntsNullable)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(Slic3r::ConfigOptionSingle<std::string>, Slic3r::ConfigOptionString)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <assert.h>
|
||||
#include <map>
|
||||
#include <climits>
|
||||
#include <limits>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <functional>
|
||||
@@ -39,9 +40,9 @@ namespace Slic3r {
|
||||
template<class Archive> void serialize(Archive& ar) { ar(this->value); ar(this->percent); }
|
||||
};
|
||||
|
||||
inline bool operator==(const FloatOrPercent& l, const FloatOrPercent& r) throw() { return l.value == r.value && l.percent == r.percent; }
|
||||
inline bool operator!=(const FloatOrPercent& l, const FloatOrPercent& r) throw() { return !(l == r); }
|
||||
inline bool operator< (const FloatOrPercent& l, const FloatOrPercent& r) throw() { return l.value < r.value || (l.value == r.value && int(l.percent) < int(r.percent)); }
|
||||
inline bool operator==(const FloatOrPercent& l, const FloatOrPercent& r) noexcept { return l.value == r.value && l.percent == r.percent; }
|
||||
inline bool operator!=(const FloatOrPercent& l, const FloatOrPercent& r) noexcept { return !(l == r); }
|
||||
inline bool operator< (const FloatOrPercent& l, const FloatOrPercent& r) noexcept { return l.value < r.value || (l.value == r.value && int(l.percent) < int(r.percent)); }
|
||||
}
|
||||
|
||||
namespace std {
|
||||
@@ -298,8 +299,55 @@ public:
|
||||
typedef ConfigOption* ConfigOptionPtr;
|
||||
typedef const ConfigOption* ConfigOptionConstPtr;
|
||||
|
||||
// Nill value will be defined in specializations
|
||||
template<class T, class En = void> struct NilValueTempl
|
||||
{
|
||||
using NilType = T;
|
||||
static_assert(always_false<T>::value, "Type has no well defined nil value");
|
||||
};
|
||||
|
||||
template<class T> struct NilValueTempl<T, std::enable_if_t<std::is_integral_v<T>, void>> {
|
||||
using NilType = T;
|
||||
static constexpr auto value = std::numeric_limits<T>::max();
|
||||
};
|
||||
|
||||
template<> struct NilValueTempl<bool> : public NilValueTempl<int>{};
|
||||
|
||||
// For enums the nil is the max value of the underlying type.
|
||||
template<class T>
|
||||
struct NilValueTempl<T, std::enable_if_t<std::is_enum_v<T>, void>>
|
||||
{
|
||||
using NilType = T;
|
||||
static constexpr auto value = static_cast<T>(std::numeric_limits<std::underlying_type_t<T>>::max());
|
||||
};
|
||||
|
||||
template<class T> struct NilValueTempl<T, std::enable_if_t<std::is_floating_point_v<T>, void>> {
|
||||
using NilType = T;
|
||||
static constexpr auto value = std::numeric_limits<T>::quiet_NaN();
|
||||
};
|
||||
|
||||
template<>
|
||||
struct NilValueTempl<FloatOrPercent> : public NilValueTempl<double> {};
|
||||
|
||||
template<> struct NilValueTempl<std::string> {
|
||||
using NilType = const char *;
|
||||
|
||||
static constexpr const char* value = "";
|
||||
};
|
||||
|
||||
template<int N, class T> struct NilValueTempl<Vec<N, T>> {
|
||||
using NilType = Vec<N, T>;
|
||||
// No constexpr for Vec<N, T>
|
||||
static inline const Vec<N, T> value = Vec<N, T>::Ones() * NilValueTempl<remove_cvref_t<T>>::value;
|
||||
};
|
||||
|
||||
template<class T> using NilType = typename NilValueTempl<remove_cvref_t<T>>::NilType;
|
||||
|
||||
// Define shortcut as a function instead of a static const var so that it can be constexpr
|
||||
// even if the NilValueTempl::value is not constexpr.
|
||||
template<class T> static constexpr NilType<T> NilValue() noexcept { return NilValueTempl<remove_cvref_t<T>>::value; }
|
||||
// Value of a single valued option (bool, int, float, string, point, enum)
|
||||
template <class T>
|
||||
template <class T, bool NULLABLE = false>
|
||||
class ConfigOptionSingle : public ConfigOption {
|
||||
public:
|
||||
T value;
|
||||
@@ -310,16 +358,18 @@ public:
|
||||
{
|
||||
if (rhs->type() != this->type())
|
||||
throw ConfigurationError("ConfigOptionSingle: Assigning an incompatible type");
|
||||
assert(dynamic_cast<const ConfigOptionSingle<T>*>(rhs));
|
||||
this->value = static_cast<const ConfigOptionSingle<T>*>(rhs)->value;
|
||||
assert(dynamic_cast<const ConfigOptionSingle*>(rhs));
|
||||
this->value = static_cast<const ConfigOptionSingle*>(rhs)->value;
|
||||
}
|
||||
|
||||
bool operator==(const ConfigOption &rhs) const override
|
||||
{
|
||||
if (rhs.type() != this->type())
|
||||
throw ConfigurationError("ConfigOptionSingle: Comparing incompatible types");
|
||||
assert(dynamic_cast<const ConfigOptionSingle<T>*>(&rhs));
|
||||
return this->value == static_cast<const ConfigOptionSingle<T>*>(&rhs)->value;
|
||||
assert(dynamic_cast<const ConfigOptionSingle*>(&rhs));
|
||||
if (this->is_nil() && rhs.is_nil())
|
||||
return true;
|
||||
return this->value == static_cast<const ConfigOptionSingle*>(&rhs)->value;
|
||||
}
|
||||
|
||||
bool operator==(const T &rhs) const throw() { return this->value == rhs; }
|
||||
@@ -328,11 +378,65 @@ public:
|
||||
|
||||
size_t hash() const throw() override { return std::hash<T>{}(this->value); }
|
||||
|
||||
// Is this option overridden by another option?
|
||||
// An option overrides another option if it is not nil and not equal.
|
||||
bool overriden_by(const ConfigOption *rhs) const override {
|
||||
if (this->nullable())
|
||||
throw ConfigurationError("Cannot override a nullable ConfigOption.");
|
||||
if (rhs->type() != this->type())
|
||||
throw ConfigurationError("ConfigOptionVector.overriden_by() applied to different types.");
|
||||
auto rhs_co = static_cast<const ConfigOptionSingle*>(rhs);
|
||||
if (! rhs->nullable())
|
||||
// Overridding a non-nullable object with another non-nullable object.
|
||||
return this->value != rhs_co->value;
|
||||
|
||||
return !rhs_co->is_nil() && rhs_co->value != this->value;
|
||||
}
|
||||
// Apply an override option, possibly a nullable one.
|
||||
bool apply_override(const ConfigOption *rhs) override {
|
||||
if (this->nullable())
|
||||
throw ConfigurationError("Cannot override a nullable ConfigOption.");
|
||||
if (rhs->type() != this->type())
|
||||
throw ConfigurationError("ConfigOptionVector.apply_override() applied to different types.");
|
||||
auto rhs_co = static_cast<const ConfigOptionSingle*>(rhs);
|
||||
if (! rhs->nullable()) {
|
||||
// Overridding a non-nullable object with another non-nullable object.
|
||||
if (this->value != rhs_co->value) {
|
||||
this->value = rhs_co->value;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!rhs_co->is_nil() && rhs_co->value != this->value) {
|
||||
this->value = rhs_co->value;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool nullable() const override { return NULLABLE; }
|
||||
|
||||
static constexpr NilType<T> nil_value() { return NilValue<T>(); }
|
||||
|
||||
// A scalar is nil, or all values of a vector are nil.
|
||||
bool is_nil() const override
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
if constexpr (NULLABLE)
|
||||
ret = this->value == nil_value();
|
||||
|
||||
return ret;
|
||||
}
|
||||
private:
|
||||
friend class cereal::access;
|
||||
template<class Archive> void serialize(Archive & ar) { ar(this->value); }
|
||||
};
|
||||
|
||||
template<class T>
|
||||
using ConfigOptionSingleNullable = ConfigOptionSingle<T, true>;
|
||||
// Value of a vector valued option (bools, ints, floats, strings, points)
|
||||
class ConfigOptionVectorBase : public ConfigOption {
|
||||
public:
|
||||
@@ -551,23 +655,34 @@ private:
|
||||
template<class Archive> void serialize(Archive & ar) { ar(this->values); }
|
||||
};
|
||||
|
||||
class ConfigOptionFloat : public ConfigOptionSingle<double>
|
||||
template<bool NULLABLE = false>
|
||||
class ConfigOptionFloatTempl : public ConfigOptionSingle<double, NULLABLE>
|
||||
{
|
||||
public:
|
||||
ConfigOptionFloat() : ConfigOptionSingle<double>(0) {}
|
||||
explicit ConfigOptionFloat(double _value) : ConfigOptionSingle<double>(_value) {}
|
||||
ConfigOptionFloatTempl() : ConfigOptionSingle<double, NULLABLE>(0) {}
|
||||
explicit ConfigOptionFloatTempl(double _value) : ConfigOptionSingle<double, NULLABLE>(_value) {}
|
||||
|
||||
static ConfigOptionType static_type() { return coFloat; }
|
||||
ConfigOptionType type() const override { return static_type(); }
|
||||
double getFloat() const override { return this->value; }
|
||||
ConfigOption* clone() const override { return new ConfigOptionFloat(*this); }
|
||||
bool operator==(const ConfigOptionFloat &rhs) const throw() { return this->value == rhs.value; }
|
||||
bool operator< (const ConfigOptionFloat &rhs) const throw() { return this->value < rhs.value; }
|
||||
ConfigOption* clone() const override { return new ConfigOptionFloatTempl(*this); }
|
||||
bool operator==(const ConfigOptionFloatTempl &rhs) const throw() { return this->value == rhs.value; }
|
||||
bool operator< (const ConfigOptionFloatTempl &rhs) const throw() { return this->value < rhs.value; }
|
||||
|
||||
std::string serialize() const override
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << this->value;
|
||||
double v = this->value;
|
||||
|
||||
if (std::isfinite(v))
|
||||
ss << v;
|
||||
else if (std::isnan(v)) {
|
||||
if (NULLABLE)
|
||||
ss << "nil";
|
||||
else
|
||||
throw ConfigurationError("Serializing NaN");
|
||||
} else
|
||||
throw ConfigurationError("Serializing invalid number");
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
@@ -575,19 +690,30 @@ public:
|
||||
{
|
||||
UNUSED(append);
|
||||
std::istringstream iss(str);
|
||||
if (str == "nil") {
|
||||
if (NULLABLE)
|
||||
this->value = this->nil_value();
|
||||
else
|
||||
throw ConfigurationError("Deserializing nil into a non-nullable object");
|
||||
} else {
|
||||
iss >> this->value;
|
||||
}
|
||||
return !iss.fail();
|
||||
}
|
||||
|
||||
ConfigOptionFloat& operator=(const ConfigOption *opt)
|
||||
ConfigOptionFloatTempl& operator=(const ConfigOption *opt)
|
||||
{
|
||||
this->set(opt);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool is_nil() const override
|
||||
{
|
||||
return std::isnan(this->value);
|
||||
}
|
||||
private:
|
||||
friend class cereal::access;
|
||||
template<class Archive> void serialize(Archive &ar) { ar(cereal::base_class<ConfigOptionSingle<double>>(this)); }
|
||||
template<class Archive> void serialize(Archive &ar) { ar(cereal::base_class<ConfigOptionSingle<double, NULLABLE>>(this)); }
|
||||
};
|
||||
|
||||
template<bool NULLABLE>
|
||||
@@ -713,26 +839,35 @@ private:
|
||||
template<class Archive> void serialize(Archive &ar) { ar(cereal::base_class<ConfigOptionVector<double>>(this)); }
|
||||
};
|
||||
|
||||
using ConfigOptionFloat = ConfigOptionFloatTempl<false>;
|
||||
using ConfigOptionFloatNullable = ConfigOptionFloatTempl<true>;
|
||||
using ConfigOptionFloats = ConfigOptionFloatsTempl<false>;
|
||||
using ConfigOptionFloatsNullable = ConfigOptionFloatsTempl<true>;
|
||||
|
||||
class ConfigOptionInt : public ConfigOptionSingle<int>
|
||||
template<bool NULLABLE = false>
|
||||
class ConfigOptionIntTempl : public ConfigOptionSingle<int, NULLABLE>
|
||||
{
|
||||
public:
|
||||
ConfigOptionInt() : ConfigOptionSingle<int>(0) {}
|
||||
explicit ConfigOptionInt(int value) : ConfigOptionSingle<int>(value) {}
|
||||
explicit ConfigOptionInt(double _value) : ConfigOptionSingle<int>(int(floor(_value + 0.5))) {}
|
||||
ConfigOptionIntTempl() : ConfigOptionSingle<int, NULLABLE>(0) {}
|
||||
explicit ConfigOptionIntTempl(int value) : ConfigOptionSingle<int, NULLABLE>(value) {}
|
||||
explicit ConfigOptionIntTempl(double _value) : ConfigOptionSingle<int, NULLABLE>(int(floor(_value + 0.5))) {}
|
||||
|
||||
static ConfigOptionType static_type() { return coInt; }
|
||||
ConfigOptionType type() const override { return static_type(); }
|
||||
int getInt() const override { return this->value; }
|
||||
void setInt(int val) override { this->value = val; }
|
||||
ConfigOption* clone() const override { return new ConfigOptionInt(*this); }
|
||||
bool operator==(const ConfigOptionInt &rhs) const throw() { return this->value == rhs.value; }
|
||||
ConfigOption* clone() const override { return new ConfigOptionIntTempl(*this); }
|
||||
bool operator==(const ConfigOptionIntTempl &rhs) const throw() { return this->value == rhs.value; }
|
||||
|
||||
std::string serialize() const override
|
||||
{
|
||||
std::ostringstream ss;
|
||||
if (this->value == this->nil_value()) {
|
||||
if (NULLABLE)
|
||||
ss << "nil";
|
||||
else
|
||||
throw ConfigurationError("Serializing NaN");
|
||||
} else
|
||||
ss << this->value;
|
||||
return ss.str();
|
||||
}
|
||||
@@ -741,11 +876,18 @@ public:
|
||||
{
|
||||
UNUSED(append);
|
||||
std::istringstream iss(str);
|
||||
if (str == "nil") {
|
||||
if (NULLABLE)
|
||||
this->value = this->nil_value();
|
||||
else
|
||||
throw ConfigurationError("Deserializing nil into a non-nullable object");
|
||||
} else {
|
||||
iss >> this->value;
|
||||
}
|
||||
return !iss.fail();
|
||||
}
|
||||
|
||||
ConfigOptionInt& operator=(const ConfigOption *opt)
|
||||
ConfigOptionIntTempl& operator=(const ConfigOption *opt)
|
||||
{
|
||||
this->set(opt);
|
||||
return *this;
|
||||
@@ -753,9 +895,11 @@ public:
|
||||
|
||||
private:
|
||||
friend class cereal::access;
|
||||
template<class Archive> void serialize(Archive &ar) { ar(cereal::base_class<ConfigOptionSingle<int>>(this)); }
|
||||
template<class Archive> void serialize(Archive &ar) { ar(cereal::base_class<ConfigOptionSingle<int, NULLABLE>>(this)); }
|
||||
};
|
||||
|
||||
using ConfigOptionInt = ConfigOptionIntTempl<false>;
|
||||
using ConfigOptionIntNullable = ConfigOptionIntTempl<true>;
|
||||
template<bool NULLABLE>
|
||||
class ConfigOptionIntsTempl : public ConfigOptionVector<int>
|
||||
{
|
||||
@@ -1838,6 +1982,8 @@ public:
|
||||
template<class Archive> ConfigOption* load_option_from_archive(Archive &archive) const {
|
||||
if (this->nullable) {
|
||||
switch (this->type) {
|
||||
case coFloat: { auto opt = new ConfigOptionFloatNullable(); archive(*opt); return opt; }
|
||||
case coInt: { auto opt = new ConfigOptionIntNullable(); archive(*opt); return opt; }
|
||||
case coFloats: { auto opt = new ConfigOptionFloatsNullable(); archive(*opt); return opt; }
|
||||
case coInts: { auto opt = new ConfigOptionIntsNullable(); archive(*opt); return opt; }
|
||||
case coPercents: { auto opt = new ConfigOptionPercentsNullable();archive(*opt); return opt; }
|
||||
@@ -1870,6 +2016,8 @@ public:
|
||||
template<class Archive> ConfigOption* save_option_to_archive(Archive &archive, const ConfigOption *opt) const {
|
||||
if (this->nullable) {
|
||||
switch (this->type) {
|
||||
case coFloat: archive(*static_cast<const ConfigOptionFloatNullable*>(opt)); break;
|
||||
case coInt: archive(*static_cast<const ConfigOptionIntNullable*>(opt)); break;
|
||||
case coFloats: archive(*static_cast<const ConfigOptionFloatsNullable*>(opt)); break;
|
||||
case coInts: archive(*static_cast<const ConfigOptionIntsNullable*>(opt)); break;
|
||||
case coPercents: archive(*static_cast<const ConfigOptionPercentsNullable*>(opt));break;
|
||||
|
||||
@@ -68,6 +68,21 @@ std::vector<std::pair<double, unsigned int>> custom_tool_changes(const Info& cus
|
||||
return custom_tool_changes;
|
||||
}
|
||||
|
||||
// Return pairs of <print_z, 1-based extruder ID> sorted by increasing print_z from custom_gcode_per_print_z.
|
||||
// Where print_z corresponds to the layer on which we perform a color change for the specified extruder.
|
||||
std::vector<std::pair<double, unsigned int>> custom_color_changes(const Info& custom_gcode_per_print_z, size_t num_extruders)
|
||||
{
|
||||
std::vector<std::pair<double, unsigned int>> custom_color_changes;
|
||||
for (const Item& custom_gcode : custom_gcode_per_print_z.gcodes)
|
||||
if (custom_gcode.type == ColorChange) {
|
||||
// If extruder count in PrinterSettings was changed, ignore custom g-codes for extruder ids bigger than num_extruders.
|
||||
assert(custom_gcode.extruder >= 0);
|
||||
if (size_t(custom_gcode.extruder) <= num_extruders) {
|
||||
custom_color_changes.emplace_back(custom_gcode.print_z, static_cast<unsigned int>(custom_gcode.extruder));
|
||||
}
|
||||
}
|
||||
return custom_color_changes;
|
||||
}
|
||||
} // namespace CustomGCode
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
@@ -87,6 +87,9 @@ extern void check_mode_for_custom_gcode_per_print_z(Info& info);
|
||||
// print_z corresponds to the first layer printed with the new extruder.
|
||||
std::vector<std::pair<double, unsigned int>> custom_tool_changes(const Info& custom_gcode_per_print_z, size_t num_extruders);
|
||||
|
||||
// Return pairs of <print_z, 1-based extruder ID> sorted by increasing print_z from custom_gcode_per_print_z.
|
||||
// Where print_z corresponds to the layer on which we perform a color change for the specified extruder.
|
||||
std::vector<std::pair<double, unsigned int>> custom_color_changes(const Info& custom_gcode_per_print_z, size_t num_extruders);
|
||||
} // namespace CustomGCode
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
@@ -105,7 +105,7 @@ struct EmbossShape
|
||||
// Note: image is only cache it is not neccessary to store
|
||||
|
||||
// Store file data as plain string
|
||||
assert(file_data != nullptr);
|
||||
// For Embossed text file_data are nullptr
|
||||
ar(path, path_in_3mf, (file_data != nullptr) ? *file_data : std::string(""));
|
||||
}
|
||||
template<class Archive> void load(Archive &ar) {
|
||||
|
||||
@@ -434,7 +434,7 @@ inline void expolygons_rotate(ExPolygons &expolys, double angle)
|
||||
expoly.rotate(angle);
|
||||
}
|
||||
|
||||
inline bool expolygons_contain(ExPolygons &expolys, const Point &pt, bool border_result = true)
|
||||
inline bool expolygons_contain(const ExPolygons &expolys, const Point &pt, bool border_result = true)
|
||||
{
|
||||
for (const ExPolygon &expoly : expolys)
|
||||
if (expoly.contains(pt, border_result))
|
||||
@@ -465,6 +465,7 @@ std::vector<BoundingBox> get_extents_vector(const ExPolygons &polygons);
|
||||
bool has_duplicate_points(const ExPolygon &expoly);
|
||||
bool has_duplicate_points(const ExPolygons &expolys);
|
||||
|
||||
// Return True when erase some otherwise False.
|
||||
bool remove_same_neighbor(ExPolygons &expolys);
|
||||
bool remove_sticks(ExPolygon &poly);
|
||||
void keep_largest_contour_only(ExPolygons &polygons);
|
||||
|
||||
@@ -184,6 +184,10 @@ public:
|
||||
void collect_polylines(Polylines &dst) const override { if (! this->polyline.empty()) dst.emplace_back(this->polyline); }
|
||||
void collect_points(Points &dst) const override { append(dst, this->polyline.points); }
|
||||
double total_volume() const override { return m_attributes.mm3_per_mm * unscale<double>(length()); }
|
||||
//w21
|
||||
void set_width(float set_val) { m_attributes.width = set_val; }
|
||||
void set_height(float set_val) { m_attributes.height = set_val; }
|
||||
void set_mm3_per_mm(float set_val) { m_attributes.mm3_per_mm = set_val; }
|
||||
|
||||
private:
|
||||
void _inflate_collection(const Polylines &polylines, ExtrusionEntityCollection* collection) const;
|
||||
@@ -372,6 +376,8 @@ inline void extrusion_entities_append_paths(ExtrusionEntitiesPtr &dst, Polylines
|
||||
polylines.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline void extrusion_entities_append_loops(ExtrusionEntitiesPtr &dst, Polygons &&loops, const ExtrusionAttributes &attributes)
|
||||
{
|
||||
dst.reserve(dst.size() + loops.size());
|
||||
|
||||
@@ -697,11 +697,12 @@ void gcode_spread_points(
|
||||
*/
|
||||
float area_total = 0;
|
||||
float volume_total = 0;
|
||||
size_t n_cells = 0;
|
||||
|
||||
#if 0
|
||||
float volume_excess = 0;
|
||||
float volume_deficit = 0;
|
||||
size_t n_cells = 0;
|
||||
float area_circle_total = 0;
|
||||
#if 0
|
||||
// The intermediate lines.
|
||||
for (int j = row_first; j < row_last; ++ j) {
|
||||
const std::pair<float, float> &span1 = spans[j];
|
||||
@@ -755,7 +756,9 @@ void gcode_spread_points(
|
||||
cell.volume = acc[j][i];
|
||||
cell.area = mask[j][i];
|
||||
assert(cell.area >= 0.f && cell.area <= 1.000001f);
|
||||
#if 0
|
||||
area_circle_total += area;
|
||||
#endif
|
||||
if (cell.area < area)
|
||||
cell.area = area;
|
||||
cell.fraction_covered = std::clamp((cell.area > 0) ? (area / cell.area) : 0, 0.f, 1.f);
|
||||
@@ -765,10 +768,13 @@ void gcode_spread_points(
|
||||
}
|
||||
float cell_height = cell.volume / cell.area;
|
||||
cell.excess_height = cell_height - height_target;
|
||||
#if 0
|
||||
area_circle_total += area;
|
||||
if (cell.excess_height > 0.f)
|
||||
volume_excess += cell.excess_height * cell.area * cell.fraction_covered;
|
||||
else
|
||||
volume_deficit -= cell.excess_height * cell.area * cell.fraction_covered;
|
||||
#endif
|
||||
volume_total += cell.volume * cell.fraction_covered;
|
||||
area_total += cell.area * cell.fraction_covered;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,16 @@
|
||||
#include "FillConcentric.hpp"
|
||||
#include "FillEnsuring.hpp"
|
||||
#include "Polygon.hpp"
|
||||
//w21
|
||||
#include "../ShortestPath.hpp"
|
||||
//w11
|
||||
//w29
|
||||
#include "FillConcentricInternal.hpp"
|
||||
|
||||
#include "LayerRegion.hpp"
|
||||
|
||||
#define NARROW_INFILL_AREA_THRESHOLD 3
|
||||
#define NARROW_INFILL_AREA_THRESHOLD_MIN 0.5
|
||||
namespace Slic3r {
|
||||
|
||||
//static constexpr const float NarrowInfillAreaThresholdMM = 3.f;
|
||||
@@ -112,12 +120,17 @@ struct SurfaceFill {
|
||||
Surface surface;
|
||||
ExPolygons expolygons;
|
||||
SurfaceFillParams params;
|
||||
//w21
|
||||
std::vector<size_t> region_id_group;
|
||||
ExPolygons no_overlap_expolygons;
|
||||
};
|
||||
//w11
|
||||
static bool is_narrow_infill_area(const ExPolygon &expolygon)
|
||||
{
|
||||
//w29
|
||||
ExPolygons offsets = offset_ex(expolygon, -scale_(NARROW_INFILL_AREA_THRESHOLD));
|
||||
if (offsets.empty())
|
||||
//ExPolygons offsets_min = offset_ex(expolygon, -scale_(NARROW_INFILL_AREA_THRESHOLD_MIN));
|
||||
if (offsets.empty() )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -219,8 +232,20 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
|
||||
fill.region_id = region_id;
|
||||
fill.surface = surface;
|
||||
fill.expolygons.emplace_back(std::move(fill.surface.expolygon));
|
||||
} else
|
||||
fill.expolygons.emplace_back(surface.expolygon);
|
||||
//w21
|
||||
fill.region_id_group.push_back(region_id);
|
||||
//w21
|
||||
fill.no_overlap_expolygons = layerm.fill_no_overlap_expolygons;
|
||||
} else {
|
||||
//w21
|
||||
fill.expolygons.emplace_back(surface.expolygon);
|
||||
auto t = find(fill.region_id_group.begin(), fill.region_id_group.end(), region_id);
|
||||
if (t == fill.region_id_group.end()) {
|
||||
fill.region_id_group.push_back(region_id);
|
||||
//w21
|
||||
fill.no_overlap_expolygons = union_ex(fill.no_overlap_expolygons, layerm.fill_no_overlap_expolygons);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -316,19 +341,13 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
|
||||
}
|
||||
|
||||
// Use ipEnsuring pattern for all internal Solids.
|
||||
{
|
||||
for (size_t surface_fill_id = 0; surface_fill_id < surface_fills.size(); ++surface_fill_id)
|
||||
if (SurfaceFill &fill = surface_fills[surface_fill_id]; fill.surface.surface_type == stInternalSolid) {
|
||||
fill.params.pattern = ipEnsuring;
|
||||
}
|
||||
}
|
||||
//w11
|
||||
if (layer.object()->config().detect_narrow_internal_solid_infill) {
|
||||
size_t surface_fills_size = surface_fills.size();
|
||||
for (size_t i = 0; i < surface_fills_size; i++) {
|
||||
if (surface_fills[i].surface.surface_type != stInternalSolid)
|
||||
continue;
|
||||
|
||||
//w29
|
||||
size_t expolygons_size = surface_fills[i].expolygons.size();
|
||||
std::vector<size_t> narrow_expolygons_index;
|
||||
narrow_expolygons_index.reserve(expolygons_size);
|
||||
@@ -339,16 +358,16 @@ std::vector<SurfaceFill> group_fills(const Layer &layer)
|
||||
if (narrow_expolygons_index.size() == 0) {
|
||||
continue;
|
||||
} else if (narrow_expolygons_index.size() == expolygons_size) {
|
||||
// w11
|
||||
// w14
|
||||
surface_fills[i].params.pattern = ipConcentricInternal;
|
||||
surface_fills[i].params.pattern = ipConcentric;
|
||||
} else {
|
||||
params = surface_fills[i].params;
|
||||
params.pattern = ipConcentricInternal;
|
||||
params.pattern = ipConcentric;
|
||||
surface_fills.emplace_back(params);
|
||||
surface_fills.back().region_id = surface_fills[i].region_id;
|
||||
surface_fills.back().surface.surface_type = stInternalSolid;
|
||||
surface_fills.back().surface.thickness = surface_fills[i].surface.thickness;
|
||||
surface_fills.back().region_id = surface_fills[i].region_id;
|
||||
surface_fills.back().surface.surface_type = stInternalSolid;
|
||||
surface_fills.back().surface.thickness = surface_fills[i].surface.thickness;
|
||||
surface_fills.back().region_id_group = surface_fills[i].region_id_group;
|
||||
surface_fills.back().no_overlap_expolygons = surface_fills[i].no_overlap_expolygons;
|
||||
for (size_t j = 0; j < narrow_expolygons_index.size(); j++) {
|
||||
surface_fills.back().expolygons.emplace_back(std::move(surface_fills[i].expolygons[narrow_expolygons_index[j]]));
|
||||
}
|
||||
@@ -489,6 +508,8 @@ void Layer::make_fills(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive:
|
||||
const Slic3r::BoundingBox bbox = this->object()->bounding_box();
|
||||
const auto resolution = this->object()->print()->config().gcode_resolution.value;
|
||||
const auto perimeter_generator = this->object()->config().perimeter_generator;
|
||||
//w21
|
||||
float filter_gap_infill_value = this->object()->config().filter_top_gap_infill;
|
||||
|
||||
#ifdef SLIC3R_DEBUG_SLICE_PROCESSING
|
||||
{
|
||||
@@ -512,14 +533,19 @@ void Layer::make_fills(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive:
|
||||
f->print_config = &this->object()->print()->config();
|
||||
f->print_object_config = &this->object()->config();
|
||||
|
||||
if (surface_fill.params.pattern == ipLightning)
|
||||
dynamic_cast<FillLightning::Filler*>(f.get())->generator = lightning_generator;
|
||||
|
||||
if (surface_fill.params.pattern == ipEnsuring) {
|
||||
auto *fill_ensuring = dynamic_cast<FillEnsuring *>(f.get());
|
||||
assert(fill_ensuring != nullptr);
|
||||
fill_ensuring->print_region_config = &m_regions[surface_fill.region_id]->region().config();
|
||||
}
|
||||
//w29
|
||||
if (surface_fill.params.pattern == ipConcentricInternal) {
|
||||
FillConcentricInternal *fill_concentric = dynamic_cast<FillConcentricInternal *>(f.get());
|
||||
assert(fill_concentric != nullptr);
|
||||
fill_concentric->print_config = &this->object()->print()->config();
|
||||
fill_concentric->print_object_config = &this->object()->config();
|
||||
} else if (surface_fill.params.pattern == ipConcentric) {
|
||||
FillConcentric *fill_concentric = dynamic_cast<FillConcentric *>(f.get());
|
||||
assert(fill_concentric != nullptr);
|
||||
fill_concentric->print_config = &this->object()->print()->config();
|
||||
fill_concentric->print_object_config = &this->object()->config();
|
||||
} else if (surface_fill.params.pattern == ipLightning)
|
||||
dynamic_cast<FillLightning::Filler *>(f.get())->generator = lightning_generator;
|
||||
|
||||
// calculate flow spacing for infill pattern generation
|
||||
bool using_internal_flow = ! surface_fill.surface.is_solid() && ! surface_fill.params.bridge;
|
||||
@@ -549,65 +575,59 @@ void Layer::make_fills(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive:
|
||||
params.anchor_length_max = surface_fill.params.anchor_length_max;
|
||||
params.resolution = resolution;
|
||||
//w14
|
||||
params.use_arachne = (perimeter_generator == PerimeterGeneratorType::Arachne && surface_fill.params.pattern == ipConcentricInternal) || surface_fill.params.pattern == ipEnsuring;
|
||||
params.use_arachne = (perimeter_generator == PerimeterGeneratorType::Arachne && surface_fill.params.pattern == ipConcentric) || surface_fill.params.pattern == ipEnsuring || surface_fill.params.pattern == ipConcentric;
|
||||
params.layer_height = layerm.layer()->height;
|
||||
//w29
|
||||
params.flow = surface_fill.params.flow;
|
||||
params.extrusion_role = surface_fill.params.extrusion_role;
|
||||
params.using_internal_flow = !surface_fill.surface.is_solid() && !surface_fill.params.bridge;
|
||||
|
||||
for (ExPolygon &expoly : surface_fill.expolygons) {
|
||||
// Spacing is modified by the filler to indicate adjustments. Reset it for each expolygon.
|
||||
f->spacing = surface_fill.params.spacing;
|
||||
surface_fill.surface.expolygon = std::move(expoly);
|
||||
// Spacing is modified by the filler to indicate adjustments. Reset it for each expolygon.
|
||||
f->spacing = surface_fill.params.spacing;
|
||||
// w21
|
||||
f->no_overlap_expolygons = intersection_ex(surface_fill.no_overlap_expolygons, ExPolygons() = {expoly}, ApplySafetyOffset::Yes);
|
||||
surface_fill.surface.expolygon = std::move(expoly);
|
||||
Polylines polylines;
|
||||
ThickPolylines thick_polylines;
|
||||
try {
|
||||
if (params.use_arachne) {
|
||||
//w14
|
||||
if (surface_fill.params.pattern == ipConcentricInternal) {
|
||||
layerm.region().config().infill_overlap.percent ?
|
||||
f->overlap = layerm.region().config().perimeter_extrusion_width * layerm.region().config().infill_overlap.value / 100 *(-1):
|
||||
f->overlap = float(layerm.region().config().infill_overlap.value);
|
||||
|
||||
} else
|
||||
f->overlap = 0;
|
||||
thick_polylines = f->fill_surface_arachne(&surface_fill.surface, params);
|
||||
}
|
||||
//w14
|
||||
else {
|
||||
if (surface_fill.params.pattern == ipConcentricInternal) {
|
||||
layerm.region().config().infill_overlap.percent ?
|
||||
f->overlap = layerm.region().config().perimeter_extrusion_width *
|
||||
layerm.region().config().infill_overlap.value / 100 * (-1) :
|
||||
f->overlap = float(layerm.region().config().infill_overlap.value);
|
||||
|
||||
} else
|
||||
f->overlap = 0;
|
||||
polylines = f->fill_surface(&surface_fill.surface, params);
|
||||
}
|
||||
} catch (InfillFailedException &) {
|
||||
}
|
||||
// w14
|
||||
//w29
|
||||
/* if (this->object()->config().detect_narrow_internal_solid_infill &&
|
||||
(surface_fill.params.pattern == ipConcentricInternal || surface_fill.params.pattern == ipEnsuring)) {
|
||||
layerm.region().config().infill_overlap.percent ? f->overlap = layerm.region().config().perimeter_extrusion_width *
|
||||
layerm.region().config().infill_overlap.value / 100 * (-1) :
|
||||
f->overlap = float(layerm.region().config().infill_overlap.value);
|
||||
} else
|
||||
f->overlap = 0;*/
|
||||
//w29
|
||||
f->fill_surface_extrusion(&surface_fill.surface, params, polylines, thick_polylines);
|
||||
if (!polylines.empty() || !thick_polylines.empty()) {
|
||||
// calculate actual flow from spacing (which might have been adjusted by the infill
|
||||
// pattern generator)
|
||||
double flow_mm3_per_mm = surface_fill.params.flow.mm3_per_mm();
|
||||
double flow_width = surface_fill.params.flow.width();
|
||||
if (using_internal_flow) {
|
||||
// if we used the internal flow we're not doing a solid infill
|
||||
// so we can safely ignore the slight variation that might have
|
||||
// been applied to f->spacing
|
||||
} else {
|
||||
Flow new_flow = surface_fill.params.flow.with_spacing(float(f->spacing));
|
||||
flow_mm3_per_mm = new_flow.mm3_per_mm();
|
||||
flow_width = new_flow.width();
|
||||
}
|
||||
// Save into layer.
|
||||
// pattern generator)
|
||||
double flow_mm3_per_mm = surface_fill.params.flow.mm3_per_mm();
|
||||
double flow_width = surface_fill.params.flow.width();
|
||||
if (using_internal_flow) {
|
||||
// if we used the internal flow we're not doing a solid infill
|
||||
// so we can safely ignore the slight variation that might have
|
||||
// been applied to f->spacing
|
||||
} else {
|
||||
Flow new_flow = surface_fill.params.flow.with_spacing(float(f->spacing));
|
||||
flow_mm3_per_mm = new_flow.mm3_per_mm();
|
||||
flow_width = new_flow.width();
|
||||
}
|
||||
// Save into layer.
|
||||
ExtrusionEntityCollection *eec = new ExtrusionEntityCollection();
|
||||
auto fill_begin = uint32_t(layerm.fills().size());
|
||||
// Only concentric fills are not sorted.
|
||||
eec->no_sort = f->no_sort();
|
||||
auto fill_begin = uint32_t(layerm.fills().size());
|
||||
// Only concentric fills are not sorted.
|
||||
eec->no_sort = f->no_sort();
|
||||
if (params.use_arachne) {
|
||||
for (const ThickPolyline &thick_polyline : thick_polylines) {
|
||||
Flow new_flow = surface_fill.params.flow.with_spacing(float(f->spacing));
|
||||
|
||||
ExtrusionMultiPath multi_path = PerimeterGenerator::thick_polyline_to_multi_path(thick_polyline, surface_fill.params.extrusion_role, new_flow, scaled<float>(0.05), float(SCALED_EPSILON));
|
||||
ExtrusionMultiPath multi_path = PerimeterGenerator::thick_polyline_to_multi_path(thick_polyline,
|
||||
surface_fill.params.extrusion_role,
|
||||
new_flow, scaled<float>(0.05),
|
||||
float(SCALED_EPSILON));
|
||||
// Append paths to collection.
|
||||
if (!multi_path.empty()) {
|
||||
if (multi_path.paths.front().first_point() == multi_path.paths.back().last_point())
|
||||
@@ -623,56 +643,248 @@ void Layer::make_fills(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive:
|
||||
delete eec;
|
||||
thick_polylines.clear();
|
||||
} else {
|
||||
extrusion_entities_append_paths(
|
||||
eec->entities, std::move(polylines),
|
||||
ExtrusionAttributes{ surface_fill.params.extrusion_role,
|
||||
ExtrusionFlow{ flow_mm3_per_mm, float(flow_width), surface_fill.params.flow.height() }
|
||||
});
|
||||
extrusion_entities_append_paths(eec->entities, std::move(polylines),
|
||||
ExtrusionAttributes{surface_fill.params.extrusion_role,
|
||||
ExtrusionFlow{flow_mm3_per_mm, float(flow_width),
|
||||
surface_fill.params.flow.height()}});
|
||||
// w21
|
||||
if (surface_fill.params.pattern == ipMonotonicLines && surface_fill.surface.surface_type == stTop) {
|
||||
ExPolygons unextruded_areas = diff_ex(f->no_overlap_expolygons, union_ex(eec->polygons_covered_by_spacing(10)));
|
||||
ExPolygons gapfill_areas = union_ex(unextruded_areas);
|
||||
if (!f->no_overlap_expolygons.empty())
|
||||
gapfill_areas = intersection_ex(gapfill_areas, f->no_overlap_expolygons);
|
||||
if (gapfill_areas.size() > 0 && params.density >= 1) {
|
||||
Flow new_flow = surface_fill.params.flow.with_spacing(float(f->spacing));
|
||||
double min = 0.2 * new_flow.scaled_spacing() * (1 - INSET_OVERLAP_TOLERANCE);
|
||||
double max = 2. * new_flow.scaled_spacing();
|
||||
ExPolygons gaps_ex = diff_ex(opening_ex(gapfill_areas, float(min / 2.)),
|
||||
offset2_ex(gapfill_areas, -float(max / 2.), float(max / 2. + ClipperSafetyOffset)));
|
||||
Points ordering_points;
|
||||
ordering_points.reserve(gaps_ex.size());
|
||||
ExPolygons gaps_ex_sorted;
|
||||
gaps_ex_sorted.reserve(gaps_ex.size());
|
||||
for (const ExPolygon &ex : gaps_ex)
|
||||
ordering_points.push_back(ex.contour.first_point());
|
||||
std::vector<Points::size_type> order = chain_points(ordering_points);
|
||||
for (size_t i : order)
|
||||
gaps_ex_sorted.emplace_back(std::move(gaps_ex[i]));
|
||||
|
||||
ThickPolylines polylines;
|
||||
for (ExPolygon &ex : gaps_ex_sorted) {
|
||||
ex.douglas_peucker(0.0125 / 0.000001 * 0.1);
|
||||
ex.medial_axis(min, max, &polylines);
|
||||
}
|
||||
|
||||
if (!polylines.empty() && !surface_fill.params.extrusion_role.is_bridge()) {
|
||||
ExtrusionEntityCollection gap_fill;
|
||||
polylines.erase(std::remove_if(polylines.begin(), polylines.end(),
|
||||
[&](const ThickPolyline &p) {
|
||||
return p.length() < 0; // scale_(params.filter_out_gap_fill);
|
||||
}),
|
||||
polylines.end());
|
||||
|
||||
variable_width_gap(polylines, ExtrusionRole::GapFill, surface_fill.params.flow, gap_fill.entities,
|
||||
filter_gap_infill_value);
|
||||
|
||||
eec->append(std::move(gap_fill.entities));
|
||||
}
|
||||
}
|
||||
}
|
||||
layerm.m_fills.entities.push_back(eec);
|
||||
}
|
||||
insert_fills_into_islands(*this, uint32_t(surface_fill.region_id), fill_begin, uint32_t(layerm.fills().size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (LayerSlice &lslice : this->lslices_ex)
|
||||
for (LayerIsland &island : lslice.islands) {
|
||||
if (! island.thin_fills.empty()) {
|
||||
// Copy thin fills into fills packed as a collection.
|
||||
// Fills are always stored as collections, the rest of the pipeline (wipe into infill, G-code generator) relies on it.
|
||||
LayerRegion &layerm = *this->get_region(island.perimeters.region());
|
||||
ExtrusionEntityCollection &collection = *(new ExtrusionEntityCollection());
|
||||
layerm.m_fills.entities.push_back(&collection);
|
||||
collection.entities.reserve(island.thin_fills.size());
|
||||
for (uint32_t fill_id : island.thin_fills)
|
||||
collection.entities.push_back(layerm.thin_fills().entities[fill_id]->clone());
|
||||
island.add_fill_range({ island.perimeters.region(), { uint32_t(layerm.m_fills.entities.size() - 1), uint32_t(layerm.m_fills.entities.size()) } });
|
||||
}
|
||||
// Sort the fills by region ID.
|
||||
std::sort(island.fills.begin(), island.fills.end(), [](auto &l, auto &r){ return l.region() < r.region() || (l.region() == r.region() && *l.begin() < *r.begin()); });
|
||||
// Compress continuous fill ranges of the same region.
|
||||
{
|
||||
size_t k = 0;
|
||||
for (size_t i = 0; i < island.fills.size();) {
|
||||
uint32_t region_id = island.fills[i].region();
|
||||
uint32_t begin = *island.fills[i].begin();
|
||||
uint32_t end = *island.fills[i].end();
|
||||
size_t j = i + 1;
|
||||
for (; j < island.fills.size() && island.fills[j].region() == region_id && *island.fills[j].begin() == end; ++ j)
|
||||
end = *island.fills[j].end();
|
||||
island.fills[k ++] = { region_id, { begin, end } };
|
||||
i = j;
|
||||
}
|
||||
island.fills.erase(island.fills.begin() + k, island.fills.end());
|
||||
}
|
||||
}
|
||||
for (LayerIsland &island : lslice.islands) {
|
||||
if (!island.thin_fills.empty()) {
|
||||
// Copy thin fills into fills packed as a collection.
|
||||
// Fills are always stored as collections, the rest of the pipeline (wipe into infill, G-code generator) relies on it.
|
||||
LayerRegion & layerm = *this->get_region(island.perimeters.region());
|
||||
ExtrusionEntityCollection &collection = *(new ExtrusionEntityCollection());
|
||||
layerm.m_fills.entities.push_back(&collection);
|
||||
collection.entities.reserve(island.thin_fills.size());
|
||||
for (uint32_t fill_id : island.thin_fills)
|
||||
collection.entities.push_back(layerm.thin_fills().entities[fill_id]->clone());
|
||||
island.add_fill_range(
|
||||
{island.perimeters.region(), {uint32_t(layerm.m_fills.entities.size() - 1), uint32_t(layerm.m_fills.entities.size())}});
|
||||
}
|
||||
// Sort the fills by region ID.
|
||||
std::sort(island.fills.begin(), island.fills.end(),
|
||||
[](auto &l, auto &r) { return l.region() < r.region() || (l.region() == r.region() && *l.begin() < *r.begin()); });
|
||||
// Compress continuous fill ranges of the same region.
|
||||
{
|
||||
size_t k = 0;
|
||||
for (size_t i = 0; i < island.fills.size();) {
|
||||
uint32_t region_id = island.fills[i].region();
|
||||
uint32_t begin = *island.fills[i].begin();
|
||||
uint32_t end = *island.fills[i].end();
|
||||
size_t j = i + 1;
|
||||
for (; j < island.fills.size() && island.fills[j].region() == region_id && *island.fills[j].begin() == end; ++j)
|
||||
end = *island.fills[j].end();
|
||||
island.fills[k++] = {region_id, {begin, end}};
|
||||
i = j;
|
||||
}
|
||||
island.fills.erase(island.fills.begin() + k, island.fills.end());
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
for (LayerRegion *layerm : m_regions)
|
||||
for (const ExtrusionEntity *e : layerm->fills())
|
||||
assert(dynamic_cast<const ExtrusionEntityCollection*>(e) != nullptr);
|
||||
for (LayerRegion *layerm : m_regions)
|
||||
for (const ExtrusionEntity *e : layerm->fills())
|
||||
assert(dynamic_cast<const ExtrusionEntityCollection *>(e) != nullptr);
|
||||
#endif
|
||||
}
|
||||
//w21
|
||||
void Layer::variable_width_gap(const ThickPolylines &polylines, ExtrusionRole role, const Flow &flow, std::vector<ExtrusionEntity *> &out,const float filter_gap_infill_value)
|
||||
{
|
||||
const float tolerance = float(scale_(0.05));
|
||||
for (const ThickPolyline &p : polylines) {
|
||||
ExtrusionPaths paths = thick_polyline_to_extrusion_paths(p, role, flow, tolerance);
|
||||
if (!paths.empty()) {
|
||||
if (paths.front().first_point() == paths.back().last_point()) {
|
||||
out.emplace_back(new ExtrusionLoop(std::move(paths)));
|
||||
}
|
||||
else {
|
||||
for (ExtrusionPath &path : paths) {
|
||||
if (filter_gap_infill_value != 0) {
|
||||
if (path.length() >= scale_(filter_gap_infill_value) || path.width() >= scale_(filter_gap_infill_value))
|
||||
out.emplace_back(new ExtrusionPath(std::move(path)));
|
||||
}
|
||||
else
|
||||
out.emplace_back(new ExtrusionPath(std::move(path)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//w21
|
||||
ExtrusionPaths Layer::thick_polyline_to_extrusion_paths(const ThickPolyline &thick_polyline,
|
||||
ExtrusionRole role,
|
||||
const Flow & flow,
|
||||
const float tolerance)
|
||||
{
|
||||
ExtrusionPaths paths;
|
||||
ExtrusionPath path(role);
|
||||
ThickLines lines = thick_polyline.thicklines();
|
||||
|
||||
size_t start_index = 0;
|
||||
double max_width, min_width;
|
||||
|
||||
for (int i = 0; i < (int) lines.size(); ++i) {
|
||||
const ThickLine &line = lines[i];
|
||||
|
||||
if (i == 0) {
|
||||
max_width = line.a_width;
|
||||
min_width = line.a_width;
|
||||
}
|
||||
|
||||
const coordf_t line_len = line.length();
|
||||
if (line_len < SCALED_EPSILON)
|
||||
continue;
|
||||
|
||||
double thickness_delta = std::max(fabs(max_width - line.b_width), fabs(min_width - line.b_width));
|
||||
if (thickness_delta > tolerance) {
|
||||
if (start_index != i) {
|
||||
path = ExtrusionPath(role);
|
||||
double length = lines[start_index].length();
|
||||
double sum = lines[start_index].length() * 0.5 * (lines[start_index].a_width + lines[start_index].b_width);
|
||||
path.polyline.append(lines[start_index].a);
|
||||
for (int idx = start_index + 1; idx < i; idx++) {
|
||||
length += lines[idx].length();
|
||||
sum += lines[idx].length() * 0.5 * (lines[idx].a_width + lines[idx].b_width);
|
||||
path.polyline.append(lines[idx].a);
|
||||
}
|
||||
path.polyline.append(lines[i].a);
|
||||
if (length > SCALED_EPSILON) {
|
||||
double w = sum / length;
|
||||
Flow new_flow = flow.with_width(unscale<float>(w) + flow.height() * float(1. - 0.25 * PI));
|
||||
|
||||
//path.mm3_per_mm = new_flow.mm3_per_mm();
|
||||
path.set_mm3_per_mm(new_flow.mm3_per_mm());
|
||||
//path.width = new_flow.width();
|
||||
path.set_width(new_flow.width());
|
||||
//path.height = new_flow.height();
|
||||
path.set_height(new_flow.height());
|
||||
paths.emplace_back(std::move(path));
|
||||
}
|
||||
}
|
||||
|
||||
start_index = i;
|
||||
max_width = line.a_width;
|
||||
min_width = line.a_width;
|
||||
thickness_delta = fabs(line.a_width - line.b_width);
|
||||
if (thickness_delta > tolerance) {
|
||||
const unsigned int segments = (unsigned int) ceil(thickness_delta / tolerance);
|
||||
const coordf_t seg_len = line_len / segments;
|
||||
Points pp;
|
||||
std::vector<coordf_t> width;
|
||||
{
|
||||
pp.push_back(line.a);
|
||||
width.push_back(line.a_width);
|
||||
for (size_t j = 1; j < segments; ++j) {
|
||||
pp.push_back(
|
||||
(line.a.cast<double>() + (line.b - line.a).cast<double>().normalized() * (j * seg_len)).cast<coord_t>());
|
||||
|
||||
coordf_t w = line.a_width + (j * seg_len) * (line.b_width - line.a_width) / line_len;
|
||||
width.push_back(w);
|
||||
width.push_back(w);
|
||||
}
|
||||
pp.push_back(line.b);
|
||||
width.push_back(line.b_width);
|
||||
|
||||
assert(pp.size() == segments + 1u);
|
||||
assert(width.size() == segments * 2);
|
||||
}
|
||||
|
||||
lines.erase(lines.begin() + i);
|
||||
for (size_t j = 0; j < segments; ++j) {
|
||||
ThickLine new_line(pp[j], pp[j + 1]);
|
||||
new_line.a_width = width[2 * j];
|
||||
new_line.b_width = width[2 * j + 1];
|
||||
lines.insert(lines.begin() + i + j, new_line);
|
||||
}
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
max_width = std::max(max_width, std::max(line.a_width, line.b_width));
|
||||
min_width = std::min(min_width, std::min(line.a_width, line.b_width));
|
||||
}
|
||||
}
|
||||
size_t final_size = lines.size();
|
||||
if (start_index < final_size) {
|
||||
path = ExtrusionPath(role);
|
||||
double length = lines[start_index].length();
|
||||
double sum = lines[start_index].length() * lines[start_index].a_width;
|
||||
path.polyline.append(lines[start_index].a);
|
||||
for (int idx = start_index + 1; idx < final_size; idx++) {
|
||||
length += lines[idx].length();
|
||||
sum += lines[idx].length() * lines[idx].a_width;
|
||||
path.polyline.append(lines[idx].a);
|
||||
}
|
||||
path.polyline.append(lines[final_size - 1].b);
|
||||
if (length > SCALED_EPSILON) {
|
||||
double w = sum / length;
|
||||
Flow new_flow = flow.with_width(unscale<float>(w) + flow.height() * float(1. - 0.25 * PI));
|
||||
//path.mm3_per_mm = new_flow.mm3_per_mm();
|
||||
path.set_mm3_per_mm(new_flow.mm3_per_mm());
|
||||
//path.width = new_flow.width();
|
||||
path.set_width(new_flow.width());
|
||||
//path.height = new_flow.height();
|
||||
path.set_height(new_flow.height());
|
||||
paths.emplace_back(std::move(path));
|
||||
}
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Polylines Layer::generate_sparse_infill_polylines_for_anchoring(FillAdaptive::Octree* adaptive_fill_octree, FillAdaptive::Octree* support_fill_octree, FillLightning::Generator* lightning_generator) const
|
||||
{
|
||||
@@ -779,6 +991,8 @@ void Layer::make_ironing()
|
||||
|
||||
// First classify regions based on the extruder used.
|
||||
struct IroningParams {
|
||||
//w33
|
||||
InfillPattern pattern;
|
||||
int extruder = -1;
|
||||
bool just_infill = false;
|
||||
// Spacing of the ironing lines, also to calculate the extrusion flow from.
|
||||
@@ -819,7 +1033,9 @@ void Layer::make_ironing()
|
||||
bool operator==(const IroningParams &rhs) const {
|
||||
return this->extruder == rhs.extruder && this->just_infill == rhs.just_infill &&
|
||||
this->line_spacing == rhs.line_spacing && this->height == rhs.height && this->speed == rhs.speed &&
|
||||
this->angle == rhs.angle;
|
||||
this->angle == rhs.angle
|
||||
//w33
|
||||
&& this->pattern == rhs.pattern;
|
||||
}
|
||||
|
||||
LayerRegion *layerm;
|
||||
@@ -869,27 +1085,46 @@ void Layer::make_ironing()
|
||||
ironing_params.angle = config.fill_angle * M_PI / 180.;
|
||||
ironing_params.layerm = layerm;
|
||||
ironing_params.region_id = region_id;
|
||||
//w33
|
||||
ironing_params.pattern = config.ironing_pattern;
|
||||
by_extruder.emplace_back(ironing_params);
|
||||
}
|
||||
}
|
||||
std::sort(by_extruder.begin(), by_extruder.end());
|
||||
|
||||
FillRectilinear fill;
|
||||
//w33
|
||||
//FillRectilinear fill;
|
||||
FillParams fill_params;
|
||||
fill.set_bounding_box(this->object()->bounding_box());
|
||||
//fill.set_bounding_box(this->object()->bounding_box());
|
||||
// Layer ID is used for orienting the infill in alternating directions.
|
||||
// Layer::id() returns layer ID including raft layers, subtract them to make the infill direction independent
|
||||
// from raft.
|
||||
//FIXME ironing does not take fill angle into account. Shall it? Does it matter?
|
||||
fill.layer_id = this->id() - this->object()->get_layer(0)->id();
|
||||
fill.z = this->print_z;
|
||||
fill.overlap = 0;
|
||||
//fill.layer_id = this->id() - this->object()->get_layer(0)->id();
|
||||
//fill.z = this->print_z;
|
||||
//fill.overlap = 0;
|
||||
fill_params.density = 1.;
|
||||
fill_params.monotonic = true;
|
||||
InfillPattern f_pattern = ipRectilinear;
|
||||
std::unique_ptr<Fill> f = std::unique_ptr<Fill>(Fill::new_from_type(f_pattern));
|
||||
f->set_bounding_box(this->object()->bounding_box());
|
||||
f->layer_id = this->id();
|
||||
f->z = this->print_z;
|
||||
f->overlap = 0;
|
||||
|
||||
for (size_t i = 0; i < by_extruder.size();) {
|
||||
// Find span of regions equivalent to the ironing operation.
|
||||
IroningParams &ironing_params = by_extruder[i];
|
||||
//w33
|
||||
if (f_pattern != ironing_params.pattern) {
|
||||
f_pattern = ironing_params.pattern;
|
||||
f = std::unique_ptr<Fill>(Fill::new_from_type(f_pattern));
|
||||
f->set_bounding_box(this->object()->bounding_box());
|
||||
f->layer_id = this->id();
|
||||
f->z = this->print_z;
|
||||
f->overlap = 0;
|
||||
}
|
||||
|
||||
size_t j = i;
|
||||
for (++ j; j < by_extruder.size() && ironing_params == by_extruder[j]; ++ j) ;
|
||||
|
||||
@@ -951,10 +1186,15 @@ void Layer::make_ironing()
|
||||
}
|
||||
|
||||
// Create the filler object.
|
||||
fill.spacing = ironing_params.line_spacing;
|
||||
fill.angle = float(ironing_params.angle + 0.25 * M_PI);
|
||||
fill.link_max_length = (coord_t)scale_(3. * fill.spacing);
|
||||
double extrusion_height = ironing_params.height * fill.spacing / nozzle_dmr;
|
||||
//w33
|
||||
//fill.spacing = ironing_params.line_spacing;
|
||||
//fill.angle = float(ironing_params.angle + 0.25 * M_PI);
|
||||
//fill.link_max_length = (coord_t)scale_(3. * fill.spacing);
|
||||
//double extrusion_height = ironing_params.height * fill.spacing / nozzle_dmr;
|
||||
f->spacing = ironing_params.line_spacing;
|
||||
f->angle = float(ironing_params.angle + 0.25 * M_PI);
|
||||
f->link_max_length = (coord_t) scale_(3. * f->spacing);
|
||||
double extrusion_height = ironing_params.height * f->spacing / nozzle_dmr;
|
||||
float extrusion_width = Flow::rounded_rectangle_extrusion_width_from_spacing(float(nozzle_dmr), float(extrusion_height));
|
||||
double flow_mm3_per_mm = nozzle_dmr * extrusion_height;
|
||||
Surface surface_fill(stTop, ExPolygon());
|
||||
@@ -963,7 +1203,9 @@ void Layer::make_ironing()
|
||||
Polylines polylines;
|
||||
try {
|
||||
assert(!fill_params.use_arachne);
|
||||
polylines = fill.fill_surface(&surface_fill, fill_params);
|
||||
//w33
|
||||
//polylines = fill.fill_surface(&surface_fill, fill_params);
|
||||
polylines = f->fill_surface(&surface_fill, fill_params);
|
||||
} catch (InfillFailedException &) {
|
||||
}
|
||||
if (! polylines.empty()) {
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
#ifndef slic3r_Fill_hpp_
|
||||
#define slic3r_Fill_hpp_
|
||||
|
||||
#include <memory.h>
|
||||
#include <float.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "../libslic3r.h"
|
||||
#include "../PrintConfig.hpp"
|
||||
|
||||
#include "FillBase.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class ExtrusionEntityCollection;
|
||||
class LayerRegion;
|
||||
|
||||
// An interface class to Perl, aggregating an instance of a Fill and a FillData.
|
||||
class Filler
|
||||
{
|
||||
public:
|
||||
Filler() : fill(nullptr) {}
|
||||
~Filler() {
|
||||
delete fill;
|
||||
fill = nullptr;
|
||||
}
|
||||
Fill *fill;
|
||||
FillParams params;
|
||||
};
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // slic3r_Fill_hpp_
|
||||
@@ -6,6 +6,36 @@
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
template <typename T> int sgn(T val) {
|
||||
return (T(0) < val) - (val < T(0));
|
||||
}
|
||||
static coordf_t triWave(coordf_t pos, coordf_t gridSize)
|
||||
{
|
||||
float t = (pos / (gridSize * 2.)) + 0.25;
|
||||
t = t - (int)t;
|
||||
return((1. - abs(t * 8. - 4.)) * (gridSize / 4.) + (gridSize / 4.));
|
||||
}
|
||||
static coordf_t troctWave(coordf_t pos, coordf_t gridSize, coordf_t Zpos)
|
||||
{
|
||||
coordf_t Zcycle = triWave(Zpos, gridSize);
|
||||
coordf_t perpOffset = Zcycle / 2;
|
||||
coordf_t y = triWave(pos, gridSize);
|
||||
return ((abs(y) > abs(perpOffset)) ? (sgn(y) * perpOffset) : (y * sgn(perpOffset)));
|
||||
}
|
||||
static std::vector<coordf_t> getCriticalPoints(coordf_t Zpos, coordf_t gridSize)
|
||||
{
|
||||
std::vector<coordf_t> res = {0.};
|
||||
coordf_t perpOffset = abs(triWave(Zpos, gridSize) / 2.);
|
||||
|
||||
coordf_t normalisedOffset = perpOffset / gridSize;
|
||||
if (normalisedOffset > 0) {
|
||||
res.push_back(gridSize * (0. + normalisedOffset));
|
||||
res.push_back(gridSize * (1. - normalisedOffset));
|
||||
res.push_back(gridSize * (1. + normalisedOffset));
|
||||
res.push_back(gridSize * (2. - normalisedOffset));
|
||||
}
|
||||
return (res);
|
||||
}
|
||||
/*
|
||||
Creates a contiguous sequence of points at a specified height that make
|
||||
up a horizontal slice of the edges of a space filling truncated
|
||||
@@ -20,33 +50,39 @@ Credits: David Eccles (gringer).
|
||||
// basic printing line (i.e. Y points for columns, X points for rows)
|
||||
// Note: a negative offset only causes a change in the perpendicular
|
||||
// direction
|
||||
static std::vector<coordf_t> colinearPoints(const coordf_t offset, const size_t baseLocation, size_t gridLength)
|
||||
static std::vector<coordf_t> colinearPoints(const coordf_t Zpos, coordf_t gridSize, std::vector<coordf_t> critPoints,
|
||||
const size_t baseLocation, size_t gridLength)
|
||||
{
|
||||
const coordf_t offset2 = std::abs(offset / coordf_t(2.));
|
||||
std::vector<coordf_t> points;
|
||||
points.push_back(baseLocation - offset2);
|
||||
for (size_t i = 0; i < gridLength; ++i) {
|
||||
points.push_back(baseLocation + i + offset2);
|
||||
points.push_back(baseLocation + i + 1 - offset2);
|
||||
points.push_back(baseLocation);
|
||||
for (coordf_t cLoc = baseLocation; cLoc < gridLength; cLoc += (gridSize * 2)) {
|
||||
for (size_t pi = 0; pi < critPoints.size(); pi++) {
|
||||
points.push_back(baseLocation + cLoc + critPoints[pi]);
|
||||
}
|
||||
}
|
||||
points.push_back(baseLocation + gridLength + offset2);
|
||||
points.push_back(gridLength);
|
||||
return points;
|
||||
}
|
||||
|
||||
// Generate an array of points for the dimension that is perpendicular to
|
||||
// the basic printing line (i.e. X points for columns, Y points for rows)
|
||||
static std::vector<coordf_t> perpendPoints(const coordf_t offset, const size_t baseLocation, size_t gridLength)
|
||||
static std::vector<coordf_t> perpendPoints(const coordf_t Zpos,
|
||||
coordf_t gridSize,
|
||||
std::vector<coordf_t> critPoints,
|
||||
size_t baseLocation,
|
||||
size_t gridLength,
|
||||
size_t offsetBase,
|
||||
coordf_t perpDir)
|
||||
{
|
||||
coordf_t offset2 = offset / coordf_t(2.);
|
||||
coord_t side = 2 * (baseLocation & 1) - 1;
|
||||
std::vector<coordf_t> points;
|
||||
points.push_back(baseLocation - offset2 * side);
|
||||
for (size_t i = 0; i < gridLength; ++i) {
|
||||
side = 2*((i+baseLocation) & 1) - 1;
|
||||
points.push_back(baseLocation + offset2 * side);
|
||||
points.push_back(baseLocation + offset2 * side);
|
||||
points.push_back(offsetBase);
|
||||
for (coordf_t cLoc = baseLocation; cLoc < gridLength; cLoc += gridSize * 2) {
|
||||
for (size_t pi = 0; pi < critPoints.size(); pi++) {
|
||||
coordf_t offset = troctWave(critPoints[pi], gridSize, Zpos);
|
||||
points.push_back(offsetBase + (offset * perpDir));
|
||||
}
|
||||
}
|
||||
points.push_back(baseLocation - offset2 * side);
|
||||
points.push_back(offsetBase);
|
||||
return points;
|
||||
}
|
||||
|
||||
@@ -74,40 +110,30 @@ static inline Pointfs zip(const std::vector<coordf_t> &x, const std::vector<coor
|
||||
// horizontal slice of a truncated regular octahedron with edge length 1.
|
||||
// curveType specifies which lines to print, 1 for vertical lines
|
||||
// (columns), 2 for horizontal lines (rows), and 3 for both.
|
||||
static std::vector<Pointfs> makeNormalisedGrid(coordf_t z, size_t gridWidth, size_t gridHeight, size_t curveType)
|
||||
static std::vector<Pointfs> makeActualGrid(coordf_t Zpos, coordf_t gridSize, size_t boundsX, size_t boundsY)
|
||||
{
|
||||
// offset required to create a regular octagram
|
||||
coordf_t octagramGap = coordf_t(0.5);
|
||||
|
||||
// sawtooth wave function for range f($z) = [-$octagramGap .. $octagramGap]
|
||||
coordf_t a = std::sqrt(coordf_t(2.)); // period
|
||||
coordf_t wave = fabs(fmod(z, a) - a/2.)/a*4. - 1.;
|
||||
coordf_t offset = wave * octagramGap;
|
||||
|
||||
std::vector<Pointfs> points;
|
||||
if ((curveType & 1) != 0) {
|
||||
for (size_t x = 0; x <= gridWidth; ++x) {
|
||||
std::vector<Pointfs> points;
|
||||
std::vector<coordf_t> critPoints = getCriticalPoints(Zpos, gridSize);
|
||||
coordf_t zCycle = fmod(Zpos + gridSize / 2, gridSize * 2.) / (gridSize * 2.);
|
||||
bool printVert = zCycle < 0.5;
|
||||
if (printVert) {
|
||||
int perpDir = -1;
|
||||
for (coordf_t x = 0; x <= (boundsX); x += gridSize, perpDir *= -1) {
|
||||
points.push_back(Pointfs());
|
||||
Pointfs &newPoints = points.back();
|
||||
newPoints = zip(
|
||||
perpendPoints(offset, x, gridHeight),
|
||||
colinearPoints(offset, 0, gridHeight));
|
||||
// trim points to grid edges
|
||||
trim(newPoints, coordf_t(0.), coordf_t(0.), coordf_t(gridWidth), coordf_t(gridHeight));
|
||||
if (x & 1)
|
||||
newPoints = zip(perpendPoints(Zpos, gridSize, critPoints, 0, boundsY, x, perpDir),
|
||||
colinearPoints(Zpos, gridSize, critPoints, 0, boundsY));
|
||||
if (perpDir == 1)
|
||||
std::reverse(newPoints.begin(), newPoints.end());
|
||||
}
|
||||
}
|
||||
if ((curveType & 2) != 0) {
|
||||
for (size_t y = 0; y <= gridHeight; ++y) {
|
||||
} else {
|
||||
int perpDir = 1;
|
||||
for (coordf_t y = gridSize; y <= (boundsY); y += gridSize, perpDir *= -1) {
|
||||
points.push_back(Pointfs());
|
||||
Pointfs &newPoints = points.back();
|
||||
newPoints = zip(
|
||||
colinearPoints(offset, 0, gridWidth),
|
||||
perpendPoints(offset, y, gridWidth));
|
||||
// trim points to grid edges
|
||||
trim(newPoints, coordf_t(0.), coordf_t(0.), coordf_t(gridWidth), coordf_t(gridHeight));
|
||||
if (y & 1)
|
||||
newPoints = zip(colinearPoints(Zpos, gridSize, critPoints, 0, boundsX),
|
||||
perpendPoints(Zpos, gridSize, critPoints, 0, boundsX, y, perpDir));
|
||||
if (perpDir == -1)
|
||||
std::reverse(newPoints.begin(), newPoints.end());
|
||||
}
|
||||
}
|
||||
@@ -117,18 +143,16 @@ static std::vector<Pointfs> makeNormalisedGrid(coordf_t z, size_t gridWidth, siz
|
||||
// Generate a set of curves (array of array of 2d points) that describe a
|
||||
// horizontal slice of a truncated regular octahedron with a specified
|
||||
// grid square size.
|
||||
static Polylines makeGrid(coord_t z, coord_t gridSize, size_t gridWidth, size_t gridHeight, size_t curveType)
|
||||
static Polylines makeGrid(coordf_t z, coordf_t gridSize, coordf_t boundWidth, coordf_t boundHeight, bool fillEvenly)
|
||||
{
|
||||
coord_t scaleFactor = gridSize;
|
||||
coordf_t normalisedZ = coordf_t(z) / coordf_t(scaleFactor);
|
||||
std::vector<Pointfs> polylines = makeNormalisedGrid(normalisedZ, gridWidth, gridHeight, curveType);
|
||||
Polylines result;
|
||||
std::vector<Pointfs> polylines = makeActualGrid(z, gridSize, boundWidth, boundHeight);
|
||||
Polylines result;
|
||||
result.reserve(polylines.size());
|
||||
for (std::vector<Pointfs>::const_iterator it_polylines = polylines.begin(); it_polylines != polylines.end(); ++ it_polylines) {
|
||||
for (std::vector<Pointfs>::const_iterator it_polylines = polylines.begin(); it_polylines != polylines.end(); ++it_polylines) {
|
||||
result.push_back(Polyline());
|
||||
Polyline &polyline = result.back();
|
||||
for (Pointfs::const_iterator it = it_polylines->begin(); it != it_polylines->end(); ++ it)
|
||||
polyline.points.push_back(Point(coord_t((*it)(0) * scaleFactor), coord_t((*it)(1) * scaleFactor)));
|
||||
for (Pointfs::const_iterator it = it_polylines->begin(); it != it_polylines->end(); ++it)
|
||||
polyline.points.push_back(Point(coord_t((*it)(0)), coord_t((*it)(1))));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -141,34 +165,64 @@ void Fill3DHoneycomb::_fill_surface_single(
|
||||
Polylines &polylines_out)
|
||||
{
|
||||
// no rotation is supported for this infill pattern
|
||||
auto infill_angle = float(this->angle);
|
||||
if (std::abs(infill_angle) >= EPSILON)
|
||||
expolygon.rotate(-infill_angle);
|
||||
BoundingBox bb = expolygon.contour.bounding_box();
|
||||
coord_t distance = coord_t(scale_(this->spacing) / params.density);
|
||||
|
||||
// align bounding box to a multiple of our honeycomb grid module
|
||||
// (a module is 2*$distance since one $distance half-module is
|
||||
// (a module is 2*$distance since one $distance half-module is
|
||||
// growing while the other $distance half-module is shrinking)
|
||||
bb.merge(align_to_grid(bb.min, Point(2*distance, 2*distance)));
|
||||
|
||||
// generate pattern
|
||||
Polylines polylines = makeGrid(
|
||||
scale_(this->z),
|
||||
distance,
|
||||
ceil(bb.size()(0) / distance) + 1,
|
||||
ceil(bb.size()(1) / distance) + 1,
|
||||
((this->layer_id/thickness_layers) % 2) + 1);
|
||||
coordf_t zScale = sqrt(2);
|
||||
coordf_t gridSize = (scale_(this->spacing) * ((zScale + 1.) / 2.) / params.density);
|
||||
|
||||
|
||||
coordf_t layerHeight = scale_(thickness_layers);
|
||||
|
||||
coordf_t layersPerModule = floor((gridSize * 2) / (zScale * layerHeight) + 0.05);
|
||||
if (params.density > 0.42) {
|
||||
layersPerModule = 2;
|
||||
gridSize = (scale_(this->spacing) * 1.1 / params.density);
|
||||
zScale = (gridSize * 2) / (layersPerModule * layerHeight);
|
||||
} else {
|
||||
if (layersPerModule < 2) {
|
||||
layersPerModule = 2;
|
||||
}
|
||||
zScale = (gridSize * 2) / (layersPerModule * layerHeight);
|
||||
gridSize = (scale_(this->spacing) * ((zScale + 1.) / 2.) / params.density);
|
||||
layersPerModule = floor((gridSize * 2) / (zScale * layerHeight) + 0.05);
|
||||
if (layersPerModule < 2) {
|
||||
layersPerModule = 2;
|
||||
}
|
||||
zScale = (gridSize * 2) / (layersPerModule * layerHeight);
|
||||
}
|
||||
|
||||
bb.merge(align_to_grid(bb.min, Point(gridSize * 4, gridSize * 4)));
|
||||
|
||||
Polylines polylines =
|
||||
makeGrid(
|
||||
scale_(this->z) * zScale,
|
||||
gridSize,
|
||||
bb.size()(0),
|
||||
bb.size()(1),
|
||||
!params.dont_adjust);
|
||||
// move pattern in place
|
||||
for (Polyline &pl : polylines)
|
||||
pl.translate(bb.min);
|
||||
|
||||
for (Polyline &pl : polylines) {
|
||||
pl.translate(bb.min);
|
||||
}
|
||||
// clip pattern to boundaries, chain the clipped polylines
|
||||
polylines = intersection_pl(polylines, expolygon);
|
||||
polylines = intersection_pl(polylines, to_polygons(expolygon));
|
||||
if (!polylines.empty()) {
|
||||
int infill_start_idx = polylines_out.size();
|
||||
if (params.dont_connect() || polylines.size() <= 1)
|
||||
append(polylines_out, chain_polylines(std::move(polylines)));
|
||||
else
|
||||
this->connect_infill(std::move(polylines), expolygon, polylines_out, this->spacing, params);
|
||||
|
||||
// connect lines if needed
|
||||
if (params.dont_connect() || polylines.size() <= 1)
|
||||
append(polylines_out, chain_polylines(std::move(polylines)));
|
||||
else
|
||||
this->connect_infill(std::move(polylines), expolygon, polylines_out, this->spacing, params);
|
||||
if (std::abs(infill_angle) >= EPSILON) {
|
||||
for (auto it = polylines_out.begin() + infill_start_idx; it != polylines_out.end(); ++it)
|
||||
it->rotate(infill_angle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
~Fill3DHoneycomb() override {}
|
||||
|
||||
// require bridge flow since most of this pattern hangs in air
|
||||
bool use_bridge_flow() const override { return true; }
|
||||
|
||||
|
||||
protected:
|
||||
void _fill_surface_single(
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
#include "FillAdaptive.hpp"
|
||||
#include "FillLightning.hpp"
|
||||
#include "FillEnsuring.hpp"
|
||||
//w29
|
||||
#include "FillConcentricInternal.hpp"
|
||||
//w32
|
||||
#include "FillCrossHatch.hpp"
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
@@ -53,7 +57,10 @@ Fill* Fill::new_from_type(const InfillPattern type)
|
||||
case ipLightning: return new FillLightning::Filler();
|
||||
case ipEnsuring: return new FillEnsuring();
|
||||
//w14
|
||||
case ipConcentricInternal: return new FillConcentric();
|
||||
//w29
|
||||
case ipConcentricInternal: return new FillConcentricInternal();
|
||||
//w32
|
||||
case ipCrossHatch: return new FillCrossHatch();
|
||||
default: throw Slic3r::InvalidArgument("unknown type");
|
||||
}
|
||||
}
|
||||
@@ -105,6 +112,156 @@ ThickPolylines Fill::fill_surface_arachne(const Surface *surface, const FillPara
|
||||
return thick_polylines_out;
|
||||
}
|
||||
|
||||
//w29
|
||||
void Fill::fill_surface_extrusion(const Surface *surface, const FillParams ¶ms, Polylines &polylines, ThickPolylines &thick_polylines)
|
||||
{
|
||||
|
||||
try {
|
||||
if (params.use_arachne)
|
||||
thick_polylines = this->fill_surface_arachne(surface, params);
|
||||
else
|
||||
polylines = this->fill_surface(surface, params);
|
||||
} catch (InfillFailedException &) {}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Fill::variable_width(const ThickPolylines &polylines, ExtrusionRole role, const Flow &flow, std::vector<ExtrusionEntity *> &out)
|
||||
{
|
||||
const float tolerance = float(scale_(0.05));
|
||||
for (const ThickPolyline &p : polylines) {
|
||||
ExtrusionPaths paths = thick_polyline_to_extrusion_paths_2(p, role, flow, tolerance);
|
||||
if (!paths.empty()) {
|
||||
if (paths.front().first_point() == paths.back().last_point())
|
||||
out.emplace_back(new ExtrusionLoop(std::move(paths)));
|
||||
else {
|
||||
for (ExtrusionPath &path : paths)
|
||||
out.emplace_back(new ExtrusionPath(std::move(path)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ExtrusionPaths Fill::thick_polyline_to_extrusion_paths_2(const ThickPolyline &thick_polyline,
|
||||
ExtrusionRole role,
|
||||
const Flow & flow,
|
||||
const float tolerance)
|
||||
{
|
||||
ExtrusionPaths paths;
|
||||
ExtrusionPath path(role);
|
||||
ThickLines lines = thick_polyline.thicklines();
|
||||
|
||||
size_t start_index = 0;
|
||||
double max_width, min_width;
|
||||
|
||||
for (int i = 0; i < (int) lines.size(); ++i) {
|
||||
const ThickLine &line = lines[i];
|
||||
|
||||
if (i == 0) {
|
||||
max_width = line.a_width;
|
||||
min_width = line.a_width;
|
||||
}
|
||||
|
||||
const coordf_t line_len = line.length();
|
||||
if (line_len < SCALED_EPSILON)
|
||||
continue;
|
||||
|
||||
double thickness_delta = std::max(fabs(max_width - line.b_width), fabs(min_width - line.b_width));
|
||||
if (thickness_delta > tolerance) {
|
||||
if (start_index != i) {
|
||||
path = ExtrusionPath(role);
|
||||
double length = lines[start_index].length();
|
||||
double sum = lines[start_index].length() * 0.5 * (lines[start_index].a_width + lines[start_index].b_width);
|
||||
path.polyline.append(lines[start_index].a);
|
||||
for (int idx = start_index + 1; idx < i; idx++) {
|
||||
length += lines[idx].length();
|
||||
sum += lines[idx].length() * 0.5 * (lines[idx].a_width + lines[idx].b_width);
|
||||
path.polyline.append(lines[idx].a);
|
||||
}
|
||||
path.polyline.append(lines[i].a);
|
||||
if (length > SCALED_EPSILON) {
|
||||
double w = sum / length;
|
||||
Flow new_flow = flow.with_width(unscale<float>(w) + flow.height() * float(1. - 0.25 * PI));
|
||||
|
||||
// path.mm3_per_mm = new_flow.mm3_per_mm();
|
||||
path.set_mm3_per_mm(new_flow.mm3_per_mm());
|
||||
// path.width = new_flow.width();
|
||||
path.set_width(new_flow.width());
|
||||
// path.height = new_flow.height();
|
||||
path.set_height(new_flow.height());
|
||||
paths.emplace_back(std::move(path));
|
||||
}
|
||||
}
|
||||
|
||||
start_index = i;
|
||||
max_width = line.a_width;
|
||||
min_width = line.a_width;
|
||||
thickness_delta = fabs(line.a_width - line.b_width);
|
||||
if (thickness_delta > tolerance) {
|
||||
const unsigned int segments = (unsigned int) ceil(thickness_delta / tolerance);
|
||||
const coordf_t seg_len = line_len / segments;
|
||||
Points pp;
|
||||
std::vector<coordf_t> width;
|
||||
{
|
||||
pp.push_back(line.a);
|
||||
width.push_back(line.a_width);
|
||||
for (size_t j = 1; j < segments; ++j) {
|
||||
pp.push_back(
|
||||
(line.a.cast<double>() + (line.b - line.a).cast<double>().normalized() * (j * seg_len)).cast<coord_t>());
|
||||
|
||||
coordf_t w = line.a_width + (j * seg_len) * (line.b_width - line.a_width) / line_len;
|
||||
width.push_back(w);
|
||||
width.push_back(w);
|
||||
}
|
||||
pp.push_back(line.b);
|
||||
width.push_back(line.b_width);
|
||||
|
||||
assert(pp.size() == segments + 1u);
|
||||
assert(width.size() == segments * 2);
|
||||
}
|
||||
|
||||
lines.erase(lines.begin() + i);
|
||||
for (size_t j = 0; j < segments; ++j) {
|
||||
ThickLine new_line(pp[j], pp[j + 1]);
|
||||
new_line.a_width = width[2 * j];
|
||||
new_line.b_width = width[2 * j + 1];
|
||||
lines.insert(lines.begin() + i + j, new_line);
|
||||
}
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
max_width = std::max(max_width, std::max(line.a_width, line.b_width));
|
||||
min_width = std::min(min_width, std::min(line.a_width, line.b_width));
|
||||
}
|
||||
}
|
||||
size_t final_size = lines.size();
|
||||
if (start_index < final_size) {
|
||||
path = ExtrusionPath(role);
|
||||
double length = lines[start_index].length();
|
||||
double sum = lines[start_index].length() * lines[start_index].a_width;
|
||||
path.polyline.append(lines[start_index].a);
|
||||
for (int idx = start_index + 1; idx < final_size; idx++) {
|
||||
length += lines[idx].length();
|
||||
sum += lines[idx].length() * lines[idx].a_width;
|
||||
path.polyline.append(lines[idx].a);
|
||||
}
|
||||
path.polyline.append(lines[final_size - 1].b);
|
||||
if (length > SCALED_EPSILON) {
|
||||
double w = sum / length;
|
||||
Flow new_flow = flow.with_width(unscale<float>(w) + flow.height() * float(1. - 0.25 * PI));
|
||||
// path.mm3_per_mm = new_flow.mm3_per_mm();
|
||||
path.set_mm3_per_mm(new_flow.mm3_per_mm());
|
||||
// path.width = new_flow.width();
|
||||
path.set_width(new_flow.width());
|
||||
// path.height = new_flow.height();
|
||||
path.set_height(new_flow.height());
|
||||
paths.emplace_back(std::move(path));
|
||||
}
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
// Calculate a new spacing to fill width with possibly integer number of lines,
|
||||
// the first and last line being centered at the interval ends.
|
||||
// This function possibly increases the spacing, never decreases,
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
#include "../Utils.hpp"
|
||||
#include "../ExPolygon.hpp"
|
||||
#include "../PrintConfig.hpp"
|
||||
//w29
|
||||
#include "../ExtrusionEntity.hpp"
|
||||
#include "../ExtrusionEntityCollection.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
@@ -63,6 +66,11 @@ struct FillParams
|
||||
bool use_arachne { false };
|
||||
// Layer height for Concentric infill with Arachne.
|
||||
coordf_t layer_height { 0.f };
|
||||
//w29
|
||||
Flow flow;
|
||||
ExtrusionRole extrusion_role{ExtrusionRole::None};
|
||||
bool using_internal_flow{false};
|
||||
//bool can_reverse{true};
|
||||
};
|
||||
static_assert(IsTriviallyCopyable<FillParams>::value, "FillParams class is not POD (and it should be - see constructor).");
|
||||
|
||||
@@ -94,6 +102,8 @@ public:
|
||||
// PrintConfig and PrintObjectConfig are used by infills that use Arachne (Concentric and FillEnsuring).
|
||||
const PrintConfig *print_config = nullptr;
|
||||
const PrintObjectConfig *print_object_config = nullptr;
|
||||
//w21
|
||||
ExPolygons no_overlap_expolygons;
|
||||
|
||||
public:
|
||||
virtual ~Fill() {}
|
||||
@@ -114,6 +124,13 @@ public:
|
||||
// Perform the fill.
|
||||
virtual Polylines fill_surface(const Surface *surface, const FillParams ¶ms);
|
||||
virtual ThickPolylines fill_surface_arachne(const Surface *surface, const FillParams ¶ms);
|
||||
//w29
|
||||
virtual void fill_surface_extrusion(const Surface *surface, const FillParams ¶ms, Polylines &polylines,ThickPolylines &thick_polylines);
|
||||
void variable_width(const ThickPolylines &polylines, ExtrusionRole role, const Flow &flow, std::vector<ExtrusionEntity *> &out);
|
||||
ExtrusionPaths thick_polyline_to_extrusion_paths_2(const ThickPolyline &thick_polyline,
|
||||
ExtrusionRole role,
|
||||
const Flow & flow,
|
||||
const float tolerance);
|
||||
|
||||
protected:
|
||||
Fill() :
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "FillConcentric.hpp"
|
||||
|
||||
#include <libslic3r/ShortestPath.hpp>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
void FillConcentric::_fill_surface_single(
|
||||
@@ -116,6 +118,7 @@ void FillConcentric::_fill_surface_single(const FillParams ¶ms,
|
||||
}
|
||||
if (j < thick_polylines_out.size())
|
||||
thick_polylines_out.erase(thick_polylines_out.begin() + int(j), thick_polylines_out.end());
|
||||
//reorder_by_shortest_traverse(thick_polylines_out);
|
||||
} else {
|
||||
Polylines polylines;
|
||||
this->_fill_surface_single(params, thickness_layers, direction, expolygon, polylines);
|
||||
|
||||
74
src/libslic3r/Fill/FillConcentricInternal.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
#include "../ClipperUtils.hpp"
|
||||
#include "../ExPolygon.hpp"
|
||||
#include "../Surface.hpp"
|
||||
#include "Arachne/WallToolPaths.hpp"
|
||||
|
||||
#include "FillConcentricInternal.hpp"
|
||||
|
||||
#include <libslic3r/ShortestPath.hpp>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
void FillConcentricInternal::fill_surface_extrusion(const Surface * surface,
|
||||
const FillParams ¶ms,
|
||||
Polylines & polylines,
|
||||
ThickPolylines & thick_polylines_out)
|
||||
{
|
||||
assert(this->print_config != nullptr && this->print_object_config != nullptr);
|
||||
|
||||
for (size_t i = 0; i < this->no_overlap_expolygons.size(); ++i) {
|
||||
ExPolygon &expolygon = this->no_overlap_expolygons[i];
|
||||
Point bbox_size = expolygon.contour.bounding_box().size();
|
||||
coord_t min_spacing = params.flow.scaled_spacing();
|
||||
|
||||
coord_t loops_count = std::max(bbox_size.x(), bbox_size.y()) / min_spacing + 1;
|
||||
Polygons polygons = to_polygons(expolygon);
|
||||
|
||||
Arachne::WallToolPaths wallToolPaths(polygons, min_spacing, min_spacing, loops_count, 0, params.layer_height,
|
||||
*this->print_object_config, *this->print_config);
|
||||
|
||||
std::vector<Arachne::VariableWidthLines> loops = wallToolPaths.getToolPaths();
|
||||
std::vector<const Arachne::ExtrusionLine *> all_extrusions;
|
||||
for (Arachne::VariableWidthLines &loop : loops) {
|
||||
if (loop.empty())
|
||||
continue;
|
||||
for (const Arachne::ExtrusionLine &wall : loop)
|
||||
all_extrusions.emplace_back(&wall);
|
||||
}
|
||||
|
||||
size_t firts_poly_idx = thick_polylines_out.size();
|
||||
Point last_pos(0, 0);
|
||||
for (const Arachne::ExtrusionLine *extrusion : all_extrusions) {
|
||||
if (extrusion->empty())
|
||||
continue;
|
||||
|
||||
ThickPolyline thick_polyline = Arachne::to_thick_polyline(*extrusion);
|
||||
if (extrusion->is_closed && thick_polyline.points.front() == thick_polyline.points.back() &&
|
||||
thick_polyline.width.front() == thick_polyline.width.back()) {
|
||||
thick_polyline.points.pop_back();
|
||||
assert(thick_polyline.points.size() * 2 == thick_polyline.width.size());
|
||||
int nearest_idx = last_pos.nearest_point_index(thick_polyline.points);
|
||||
std::rotate(thick_polyline.points.begin(), thick_polyline.points.begin() + nearest_idx, thick_polyline.points.end());
|
||||
std::rotate(thick_polyline.width.begin(), thick_polyline.width.begin() + 2 * nearest_idx, thick_polyline.width.end());
|
||||
thick_polyline.points.emplace_back(thick_polyline.points.front());
|
||||
}
|
||||
thick_polylines_out.emplace_back(std::move(thick_polyline));
|
||||
}
|
||||
|
||||
size_t j = firts_poly_idx;
|
||||
for (size_t i = firts_poly_idx; i < thick_polylines_out.size(); ++i) {
|
||||
thick_polylines_out[i].clip_end(this->loop_clipping);
|
||||
if (thick_polylines_out[i].is_valid()) {
|
||||
if (j < i)
|
||||
thick_polylines_out[j] = std::move(thick_polylines_out[i]);
|
||||
++j;
|
||||
}
|
||||
}
|
||||
if (j < thick_polylines_out.size())
|
||||
thick_polylines_out.erase(thick_polylines_out.begin() + int(j), thick_polylines_out.end());
|
||||
|
||||
reorder_by_shortest_traverse(thick_polylines_out);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
165
src/libslic3r/Fill/FillConcentricInternal.hpp
Normal file
@@ -0,0 +1,165 @@
|
||||
#ifndef slic3r_FillConcentricInternal_hpp_
|
||||
#define slic3r_FillConcentricInternal_hpp_
|
||||
|
||||
#include "FillBase.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class FillConcentricInternal : public Fill
|
||||
{
|
||||
public:
|
||||
~FillConcentricInternal() override = default;
|
||||
void fill_surface_extrusion(const Surface * surface,
|
||||
const FillParams ¶ms,
|
||||
Polylines & polylines,
|
||||
ThickPolylines & thick_polylines) override;
|
||||
void variable_width(const ThickPolylines &polylines, ExtrusionRole role, const Flow &flow, std::vector<ExtrusionEntity *> &out)
|
||||
{
|
||||
const float tolerance = float(scale_(0.05));
|
||||
for (const ThickPolyline &p : polylines) {
|
||||
ExtrusionPaths paths = thick_polyline_to_extrusion_paths_2(p, role, flow, tolerance);
|
||||
// Append paths to collection.
|
||||
if (!paths.empty()) {
|
||||
if (paths.front().first_point() == paths.back().last_point())
|
||||
out.emplace_back(new ExtrusionLoop(std::move(paths)));
|
||||
else {
|
||||
for (ExtrusionPath &path : paths)
|
||||
out.emplace_back(new ExtrusionPath(std::move(path)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ExtrusionPaths thick_polyline_to_extrusion_paths_2(const ThickPolyline &thick_polyline,
|
||||
ExtrusionRole role,
|
||||
const Flow & flow,
|
||||
const float tolerance)
|
||||
{
|
||||
ExtrusionPaths paths;
|
||||
ExtrusionPath path(role);
|
||||
ThickLines lines = thick_polyline.thicklines();
|
||||
|
||||
size_t start_index = 0;
|
||||
double max_width, min_width;
|
||||
|
||||
for (int i = 0; i < (int) lines.size(); ++i) {
|
||||
const ThickLine &line = lines[i];
|
||||
|
||||
if (i == 0) {
|
||||
max_width = line.a_width;
|
||||
min_width = line.a_width;
|
||||
}
|
||||
|
||||
const coordf_t line_len = line.length();
|
||||
if (line_len < SCALED_EPSILON)
|
||||
continue;
|
||||
|
||||
double thickness_delta = std::max(fabs(max_width - line.b_width), fabs(min_width - line.b_width));
|
||||
if (thickness_delta > tolerance) {
|
||||
if (start_index != i) {
|
||||
path = ExtrusionPath(role);
|
||||
double length = lines[start_index].length();
|
||||
double sum = lines[start_index].length() * 0.5 * (lines[start_index].a_width + lines[start_index].b_width);
|
||||
path.polyline.append(lines[start_index].a);
|
||||
for (int idx = start_index + 1; idx < i; idx++) {
|
||||
length += lines[idx].length();
|
||||
sum += lines[idx].length() * 0.5 * (lines[idx].a_width + lines[idx].b_width);
|
||||
path.polyline.append(lines[idx].a);
|
||||
}
|
||||
path.polyline.append(lines[i].a);
|
||||
if (length > SCALED_EPSILON) {
|
||||
double w = sum / length;
|
||||
Flow new_flow = flow.with_width(unscale<float>(w) + flow.height() * float(1. - 0.25 * PI));
|
||||
|
||||
// path.mm3_per_mm = new_flow.mm3_per_mm();
|
||||
path.set_mm3_per_mm(new_flow.mm3_per_mm());
|
||||
// path.width = new_flow.width();
|
||||
path.set_width(new_flow.width());
|
||||
// path.height = new_flow.height();
|
||||
path.set_height(new_flow.height());
|
||||
paths.emplace_back(std::move(path));
|
||||
}
|
||||
}
|
||||
|
||||
start_index = i;
|
||||
max_width = line.a_width;
|
||||
min_width = line.a_width;
|
||||
thickness_delta = fabs(line.a_width - line.b_width);
|
||||
if (thickness_delta > tolerance) {
|
||||
const unsigned int segments = (unsigned int) ceil(thickness_delta / tolerance);
|
||||
const coordf_t seg_len = line_len / segments;
|
||||
Points pp;
|
||||
std::vector<coordf_t> width;
|
||||
{
|
||||
pp.push_back(line.a);
|
||||
width.push_back(line.a_width);
|
||||
for (size_t j = 1; j < segments; ++j) {
|
||||
pp.push_back(
|
||||
(line.a.cast<double>() + (line.b - line.a).cast<double>().normalized() * (j * seg_len)).cast<coord_t>());
|
||||
|
||||
coordf_t w = line.a_width + (j * seg_len) * (line.b_width - line.a_width) / line_len;
|
||||
width.push_back(w);
|
||||
width.push_back(w);
|
||||
}
|
||||
pp.push_back(line.b);
|
||||
width.push_back(line.b_width);
|
||||
|
||||
assert(pp.size() == segments + 1u);
|
||||
assert(width.size() == segments * 2);
|
||||
}
|
||||
|
||||
lines.erase(lines.begin() + i);
|
||||
for (size_t j = 0; j < segments; ++j) {
|
||||
ThickLine new_line(pp[j], pp[j + 1]);
|
||||
new_line.a_width = width[2 * j];
|
||||
new_line.b_width = width[2 * j + 1];
|
||||
lines.insert(lines.begin() + i + j, new_line);
|
||||
}
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
max_width = std::max(max_width, std::max(line.a_width, line.b_width));
|
||||
min_width = std::min(min_width, std::min(line.a_width, line.b_width));
|
||||
}
|
||||
}
|
||||
size_t final_size = lines.size();
|
||||
if (start_index < final_size) {
|
||||
path = ExtrusionPath(role);
|
||||
double length = lines[start_index].length();
|
||||
double sum = lines[start_index].length() * lines[start_index].a_width;
|
||||
path.polyline.append(lines[start_index].a);
|
||||
for (int idx = start_index + 1; idx < final_size; idx++) {
|
||||
length += lines[idx].length();
|
||||
sum += lines[idx].length() * lines[idx].a_width;
|
||||
path.polyline.append(lines[idx].a);
|
||||
}
|
||||
path.polyline.append(lines[final_size - 1].b);
|
||||
if (length > SCALED_EPSILON) {
|
||||
double w = sum / length;
|
||||
Flow new_flow = flow.with_width(unscale<float>(w) + flow.height() * float(1. - 0.25 * PI));
|
||||
// path.mm3_per_mm = new_flow.mm3_per_mm();
|
||||
path.set_mm3_per_mm(new_flow.mm3_per_mm());
|
||||
// path.width = new_flow.width();
|
||||
path.set_width(new_flow.width());
|
||||
// path.height = new_flow.height();
|
||||
path.set_height(new_flow.height());
|
||||
paths.emplace_back(std::move(path));
|
||||
}
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
protected:
|
||||
Fill *clone() const override { return new FillConcentricInternal(*this); };
|
||||
bool no_sort() const override { return true; }
|
||||
|
||||
const PrintConfig * print_config = nullptr;
|
||||
const PrintObjectConfig *print_object_config = nullptr;
|
||||
|
||||
friend class Layer;
|
||||
};
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // slic3r_FillConcentricInternal_hpp_
|
||||
236
src/libslic3r/Fill/FillCrossHatch.cpp
Normal file
@@ -0,0 +1,236 @@
|
||||
#include "../ClipperUtils.hpp"
|
||||
#include "../ShortestPath.hpp"
|
||||
#include "../Surface.hpp"
|
||||
|
||||
#include "FillCrossHatch.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
// CrossHatch Infill: Enhances 3D Printing Speed & Reduces Noise
|
||||
// CrossHatch, as its name hints, alternates line direction by 90 degrees every few layers to improve adhesion.
|
||||
// It introduces transform layers between direction shifts for better line cohesion, which fixes the weakness of line infill.
|
||||
// The transform technique is inspired by David Eccles, improved 3D honeycomb but also a more flexible implementation.
|
||||
// This method notably increases printing speed, meeting the demands of modern high-speed 3D printers, and reduces noise for most layers.
|
||||
// By Bambu Lab
|
||||
|
||||
// graph credits: David Eccles (gringer).
|
||||
// But we made a different definition for points.
|
||||
/* o---o
|
||||
* / \
|
||||
* / \
|
||||
* \ /
|
||||
* \ /
|
||||
* o---o
|
||||
* p1 p2 p3 p4
|
||||
*
|
||||
* // X1 = progress * (1/8) * period
|
||||
* // X2 = ( (1/2 - progress) * (1/8) ) * period
|
||||
* // X3 = X1 + (1/2) * period
|
||||
* // X4 = ( (1 - progress) * (1/8) ) * period
|
||||
* // Y1 = X1
|
||||
* // Y2 = X1
|
||||
* // Y3 = -X1
|
||||
* // Y4 = -X1
|
||||
*/
|
||||
|
||||
static Pointfs generate_one_cycle(double progress, coordf_t period)
|
||||
{
|
||||
Pointfs out;
|
||||
double offset = progress * 1. / 8. * period;
|
||||
out.reserve(4);
|
||||
out.push_back(Vec2d(0.25 * period - offset, offset));
|
||||
out.push_back(Vec2d(0.25 * period + offset, offset));
|
||||
out.push_back(Vec2d(0.75 * period - offset, -offset));
|
||||
out.push_back(Vec2d(0.75 * period + offset, -offset));
|
||||
return out;
|
||||
}
|
||||
|
||||
static Polylines generate_transform_pattern(double inprogress, int direction, coordf_t ingrid_size, coordf_t inwidth, coordf_t inheight)
|
||||
{
|
||||
coordf_t width = inwidth;
|
||||
coordf_t height = inheight;
|
||||
coordf_t grid_size = ingrid_size * 2; // we due with odd and even saparately.
|
||||
double progress = inprogress;
|
||||
Polylines out_polylines;
|
||||
|
||||
// generate template patterns;
|
||||
Pointfs one_cycle_points = generate_one_cycle(progress, grid_size);
|
||||
|
||||
Polyline one_cycle;
|
||||
one_cycle.points.reserve(one_cycle_points.size());
|
||||
for (size_t i = 0; i < one_cycle_points.size(); i++) one_cycle.points.push_back(Point(one_cycle_points[i]));
|
||||
|
||||
// swap if vertical
|
||||
if (direction < 0) {
|
||||
width = height;
|
||||
height = inwidth;
|
||||
}
|
||||
|
||||
// replicate polylines;
|
||||
Polylines odd_polylines;
|
||||
Polyline odd_poly;
|
||||
int num_of_cycle = width / grid_size + 2;
|
||||
odd_poly.points.reserve(num_of_cycle * one_cycle.size());
|
||||
|
||||
// replicate to odd line
|
||||
Point translate = Point(0, 0);
|
||||
for (size_t i = 0; i < num_of_cycle; i++) {
|
||||
Polyline odd_points;
|
||||
odd_points = Polyline(one_cycle);
|
||||
odd_points.translate(Point(i * grid_size, 0.0));
|
||||
odd_poly.points.insert(odd_poly.points.end(), odd_points.begin(), odd_points.end());
|
||||
}
|
||||
|
||||
// fill the height
|
||||
int num_of_lines = height / grid_size + 2;
|
||||
odd_polylines.reserve(num_of_lines * odd_poly.size());
|
||||
for (size_t i = 0; i < num_of_lines; i++) {
|
||||
Polyline poly = odd_poly;
|
||||
poly.translate(Point(0.0, grid_size * i));
|
||||
odd_polylines.push_back(poly);
|
||||
}
|
||||
// save to output
|
||||
out_polylines.insert(out_polylines.end(), odd_polylines.begin(), odd_polylines.end());
|
||||
|
||||
// replicate to even lines
|
||||
Polylines even_polylines;
|
||||
even_polylines.reserve(odd_polylines.size());
|
||||
for (size_t i = 0; i < odd_polylines.size(); i++) {
|
||||
Polyline even = odd_poly;
|
||||
even.translate(Point(-0.5 * grid_size, (i + 0.5) * grid_size));
|
||||
even_polylines.push_back(even);
|
||||
}
|
||||
|
||||
// save for output
|
||||
out_polylines.insert(out_polylines.end(), even_polylines.begin(), even_polylines.end());
|
||||
|
||||
// change to vertical if need
|
||||
if (direction < 0) {
|
||||
// swap xy, see if we need better performance method
|
||||
for (Polyline& poly : out_polylines) {
|
||||
for (Point& p : poly) { std::swap(p.x(), p.y()); }
|
||||
}
|
||||
}
|
||||
|
||||
return out_polylines;
|
||||
}
|
||||
|
||||
static Polylines generate_repeat_pattern(int direction, coordf_t grid_size, coordf_t inwidth, coordf_t inheight)
|
||||
{
|
||||
coordf_t width = inwidth;
|
||||
coordf_t height = inheight;
|
||||
Polylines out_polylines;
|
||||
|
||||
// swap if vertical
|
||||
if (direction < 0) {
|
||||
width = height;
|
||||
height = inwidth;
|
||||
}
|
||||
|
||||
int num_of_lines = height / grid_size + 1;
|
||||
out_polylines.reserve(num_of_lines);
|
||||
|
||||
for (int i = 0; i < num_of_lines; i++) {
|
||||
Polyline poly;
|
||||
poly.points.reserve(2);
|
||||
poly.append(Point(coordf_t(0), coordf_t(grid_size * i)));
|
||||
poly.append(Point(width, coordf_t(grid_size * i)));
|
||||
out_polylines.push_back(poly);
|
||||
}
|
||||
|
||||
// change to vertical if needed
|
||||
if (direction < 0) {
|
||||
// swap xy
|
||||
for (Polyline& poly : out_polylines) {
|
||||
for (Point& p : poly) { std::swap(p.x(), p.y()); }
|
||||
}
|
||||
}
|
||||
|
||||
return out_polylines;
|
||||
}
|
||||
|
||||
// it makes the real patterns that overlap the bounding box
|
||||
// repeat_ratio define the ratio between the height of repeat pattern and grid
|
||||
static Polylines generate_infill_layers(coordf_t z_height, double repeat_ratio, coordf_t grid_size, coordf_t width, coordf_t height)
|
||||
{
|
||||
Polylines result;
|
||||
coordf_t trans_layer_size = grid_size * 0.4; // upper.
|
||||
coordf_t repeat_layer_size = grid_size * repeat_ratio; // lower.
|
||||
z_height += repeat_layer_size / 2; // offset to improve first few layer strength
|
||||
coordf_t period = trans_layer_size + repeat_layer_size;
|
||||
coordf_t remains = z_height - std::floor(z_height / period) * period;
|
||||
coordf_t trans_z = remains - repeat_layer_size; // put repeat layer first.
|
||||
coordf_t repeat_z = remains;
|
||||
|
||||
int phase = fmod(z_height, period * 2) - (period - 1); // add epsilon
|
||||
int direction = phase <= 0 ? -1 : 1;
|
||||
|
||||
// this is a repeat layer
|
||||
if (trans_z < 0) {
|
||||
result = generate_repeat_pattern(direction, grid_size, width, height);
|
||||
}
|
||||
// this is a transform layer
|
||||
else {
|
||||
double progress = fmod(trans_z, trans_layer_size) / trans_layer_size;
|
||||
|
||||
// split the progress to forward and backward, with a opposite direction.
|
||||
if (progress < 0.5)
|
||||
result = generate_transform_pattern((progress + 0.1) * 2, direction, grid_size, width, height); // increase overlapping.
|
||||
else
|
||||
result = generate_transform_pattern((1.1 - progress) * 2, -1 * direction, grid_size, width, height);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void FillCrossHatch::_fill_surface_single(
|
||||
const FillParams& params, unsigned int thickness_layers, const std::pair<float, Point>& direction, ExPolygon expolygon, Polylines& polylines_out)
|
||||
{
|
||||
// rotate angle
|
||||
auto infill_angle = float(this->angle);
|
||||
if (std::abs(infill_angle) >= EPSILON) expolygon.rotate(-infill_angle);
|
||||
|
||||
// get the rotated bounding box
|
||||
BoundingBox bb = expolygon.contour.bounding_box();
|
||||
|
||||
// linespace modifier
|
||||
coord_t line_spacing = coord_t(scale_(this->spacing) / params.density);
|
||||
|
||||
// reduce density
|
||||
if (params.density < 0.999) line_spacing *= 1.5;
|
||||
|
||||
bb.merge(align_to_grid(bb.min, Point(line_spacing * 4, line_spacing * 4)));
|
||||
|
||||
// generate pattern
|
||||
Polylines polylines = generate_infill_layers(scale_(this->z), 1, line_spacing, bb.size()(0), bb.size()(1));
|
||||
|
||||
// shift the pattern to the actual space
|
||||
for (Polyline& pl : polylines) { pl.translate(bb.min); }
|
||||
|
||||
polylines = intersection_pl(polylines, to_polygons(expolygon));
|
||||
|
||||
// --- remove small remains from gyroid infill
|
||||
if (!polylines.empty()) {
|
||||
// Remove very small bits, but be careful to not remove infill lines connecting thin walls!
|
||||
// The infill perimeter lines should be separated by around a single infill line width.
|
||||
const double minlength = scale_(0.8 * this->spacing);
|
||||
polylines.erase(std::remove_if(polylines.begin(), polylines.end(), [minlength](const Polyline& pl)
|
||||
{ return pl.length() < minlength; }), polylines.end());
|
||||
}
|
||||
|
||||
if (!polylines.empty()) {
|
||||
int infill_start_idx = polylines_out.size(); // only rotate what belongs to us.
|
||||
// connect lines
|
||||
if (params.dont_connect() || polylines.size() <= 1)
|
||||
append(polylines_out, chain_polylines(std::move(polylines)));
|
||||
else
|
||||
this->connect_infill(std::move(polylines), expolygon, polylines_out, this->spacing, params);
|
||||
|
||||
// rotate back
|
||||
if (std::abs(infill_angle) >= EPSILON) {
|
||||
for (auto it = polylines_out.begin() + infill_start_idx; it != polylines_out.end(); ++it) it->rotate(infill_angle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
28
src/libslic3r/Fill/FillCrossHatch.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef slic3r_FillCrossHatch_hpp_
|
||||
#define slic3r_FillCrossHatch_hpp_
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "../libslic3r.h"
|
||||
|
||||
#include "FillBase.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
class FillCrossHatch : public Fill
|
||||
{
|
||||
public:
|
||||
Fill *clone() const override { return new FillCrossHatch(*this); };
|
||||
~FillCrossHatch() override {}
|
||||
|
||||
protected:
|
||||
void _fill_surface_single(const FillParams & params,
|
||||
unsigned int thickness_layers,
|
||||
const std::pair<float, Point> &direction,
|
||||
ExPolygon expolygon,
|
||||
Polylines & polylines_out) override;
|
||||
};
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // slic3r_FillCrossHatch_hpp_
|
||||
@@ -86,6 +86,11 @@ const std::string SLA_DRAIN_HOLES_FILE = "Metadata/Slic3r_PE_sla_drain_holes.txt
|
||||
const std::string CUSTOM_GCODE_PER_PRINT_Z_FILE = "Metadata/QIDI_Slicer_custom_gcode_per_print_z.xml";
|
||||
const std::string CUT_INFORMATION_FILE = "Metadata/QIDI_Slicer_cut_information.xml";
|
||||
|
||||
static constexpr const char *RELATIONSHIP_TAG = "Relationship";
|
||||
|
||||
static constexpr const char* TARGET_ATTR = "Target";
|
||||
static constexpr const char* RELS_TYPE_ATTR = "Type";
|
||||
|
||||
static constexpr const char* MODEL_TAG = "model";
|
||||
static constexpr const char* RESOURCES_TAG = "resources";
|
||||
static constexpr const char* OBJECT_TAG = "object";
|
||||
@@ -113,13 +118,14 @@ static constexpr const char* Z_ATTR = "z";
|
||||
static constexpr const char* V1_ATTR = "v1";
|
||||
static constexpr const char* V2_ATTR = "v2";
|
||||
static constexpr const char* V3_ATTR = "v3";
|
||||
static constexpr const char* PPATH_ATTR = "p:path";
|
||||
static constexpr const char* OBJECTID_ATTR = "objectid";
|
||||
static constexpr const char* TRANSFORM_ATTR = "transform";
|
||||
static constexpr const char* PRINTABLE_ATTR = "printable";
|
||||
static constexpr const char* INSTANCESCOUNT_ATTR = "instances_count";
|
||||
static constexpr const char* CUSTOM_SUPPORTS_ATTR = "slic3rpe:custom_supports";
|
||||
static constexpr const char* CUSTOM_SEAM_ATTR = "slic3rpe:custom_seam";
|
||||
static constexpr const char* MMU_SEGMENTATION_ATTR = "slic3rpe:mmu_segmentation";
|
||||
static constexpr const char* MM_SEGMENTATION_ATTR = "slic3rpe:mmu_segmentation";
|
||||
|
||||
static constexpr const char* KEY_ATTR = "key";
|
||||
static constexpr const char* VALUE_ATTR = "value";
|
||||
@@ -173,6 +179,7 @@ static constexpr const char *FONT_FACE_NAME_ATTR = "face_name";
|
||||
static constexpr const char *FONT_STYLE_ATTR = "style";
|
||||
static constexpr const char *FONT_WEIGHT_ATTR = "weight";
|
||||
|
||||
// Store / load of EmbossShape
|
||||
static constexpr const char *SHAPE_TAG = "slic3rpe:shape";
|
||||
static constexpr const char *SHAPE_SCALE_ATTR = "scale";
|
||||
static constexpr const char *UNHEALED_ATTR = "unhealed";
|
||||
@@ -182,6 +189,9 @@ static constexpr const char *SVG_FILE_PATH_IN_3MF_ATTR = "filepath3mf";
|
||||
// EmbossProjection
|
||||
static constexpr const char *DEPTH_ATTR = "depth";
|
||||
static constexpr const char *USE_SURFACE_ATTR = "use_surface";
|
||||
// static constexpr const char *FIX_TRANSFORMATION_ATTR = "transform";
|
||||
|
||||
|
||||
const unsigned int VALID_OBJECT_TYPES_COUNT = 1;
|
||||
const char* VALID_OBJECT_TYPES[] =
|
||||
{
|
||||
@@ -327,18 +337,21 @@ namespace Slic3r {
|
||||
|
||||
class _3MF_Importer : public _3MF_Base
|
||||
{
|
||||
typedef std::pair<std::string, int> PathId;
|
||||
|
||||
struct Component
|
||||
{
|
||||
int object_id;
|
||||
PathId object_id;
|
||||
std::string path;
|
||||
Transform3d transform;
|
||||
|
||||
explicit Component(int object_id)
|
||||
explicit Component(PathId object_id)
|
||||
: object_id(object_id)
|
||||
, transform(Transform3d::Identity())
|
||||
{
|
||||
}
|
||||
|
||||
Component(int object_id, const Transform3d& transform)
|
||||
Component(PathId object_id, const Transform3d &transform)
|
||||
: object_id(object_id)
|
||||
, transform(transform)
|
||||
{
|
||||
@@ -353,7 +366,7 @@ namespace Slic3r {
|
||||
std::vector<Vec3i> triangles;
|
||||
std::vector<std::string> custom_supports;
|
||||
std::vector<std::string> custom_seam;
|
||||
std::vector<std::string> mmu_segmentation;
|
||||
std::vector<std::string> mm_segmentation;
|
||||
|
||||
bool empty() { return vertices.empty() || triangles.empty(); }
|
||||
|
||||
@@ -362,7 +375,7 @@ namespace Slic3r {
|
||||
triangles.clear();
|
||||
custom_supports.clear();
|
||||
custom_seam.clear();
|
||||
mmu_segmentation.clear();
|
||||
mm_segmentation.clear();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -456,17 +469,16 @@ namespace Slic3r {
|
||||
};
|
||||
|
||||
// Map from a 1 based 3MF object ID to a 0 based ModelObject index inside m_model->objects.
|
||||
typedef std::map<int, int> IdToModelObjectMap;
|
||||
typedef std::map<int, ComponentsList> IdToAliasesMap;
|
||||
typedef std::map<PathId, int> IdToModelObjectMap;
|
||||
typedef std::map<PathId, ComponentsList> IdToAliasesMap;
|
||||
typedef std::vector<Instance> InstancesList;
|
||||
typedef std::map<int, ObjectMetadata> IdToMetadataMap;
|
||||
typedef std::map<int, Geometry> IdToGeometryMap;
|
||||
typedef std::map<PathId, Geometry> IdToGeometryMap;
|
||||
typedef std::map<int, std::vector<coordf_t>> IdToLayerHeightsProfileMap;
|
||||
typedef std::map<int, t_layer_config_ranges> IdToLayerConfigRangesMap;
|
||||
typedef std::map<int, CutObjectInfo> IdToCutObjectInfoMap;
|
||||
typedef std::map<int, std::vector<sla::SupportPoint>> IdToSlaSupportPointsMap;
|
||||
typedef std::map<int, std::vector<sla::DrainHole>> IdToSlaDrainHolesMap;
|
||||
|
||||
using PathToEmbossShapeFileMap = std::map<std::string, std::shared_ptr<std::string>>;
|
||||
// Version of the 3mf file
|
||||
unsigned int m_version;
|
||||
@@ -501,6 +513,8 @@ namespace Slic3r {
|
||||
std::string m_curr_metadata_name;
|
||||
std::string m_curr_characters;
|
||||
std::string m_name;
|
||||
std::string m_start_part_path;
|
||||
std::string m_model_path;
|
||||
|
||||
public:
|
||||
_3MF_Importer();
|
||||
@@ -524,8 +538,9 @@ namespace Slic3r {
|
||||
}
|
||||
|
||||
bool _load_model_from_file(const std::string& filename, Model& model, DynamicPrintConfig& config, ConfigSubstitutionContext& config_substitutions);
|
||||
bool _extract_relationships_from_archive(mz_zip_archive &archive, const mz_zip_archive_file_stat &stat);
|
||||
bool _extract_model_from_archive(mz_zip_archive &archive, const mz_zip_archive_file_stat &stat);
|
||||
bool _is_svg_shape_file(const std::string &filename) const;
|
||||
bool _extract_model_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat);
|
||||
void _extract_cut_information_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat, ConfigSubstitutionContext& config_substitutions);
|
||||
void _extract_layer_heights_profile_config_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat);
|
||||
void _extract_layer_config_ranges_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat, ConfigSubstitutionContext& config_substitutions);
|
||||
@@ -538,6 +553,10 @@ namespace Slic3r {
|
||||
bool _extract_model_config_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat, Model& model);
|
||||
void _extract_embossed_svg_shape_file(const std::string &filename, mz_zip_archive &archive, const mz_zip_archive_file_stat &stat);
|
||||
|
||||
// handlers to parse the .rels file
|
||||
void _handle_start_relationships_element(const char* name, const char** attributes);
|
||||
bool _handle_start_relationship(const char **attributes, unsigned int num_attributes);
|
||||
|
||||
// handlers to parse the .model file
|
||||
void _handle_start_model_xml_element(const char* name, const char** attributes);
|
||||
void _handle_end_model_xml_element(const char* name);
|
||||
@@ -589,7 +608,7 @@ namespace Slic3r {
|
||||
bool _handle_start_text_configuration(const char** attributes, unsigned int num_attributes);
|
||||
bool _handle_start_shape_configuration(const char **attributes, unsigned int num_attributes);
|
||||
|
||||
bool _create_object_instance(int object_id, const Transform3d& transform, const bool printable, unsigned int recur_counter);
|
||||
bool _create_object_instance(PathId object_id, const Transform3d& transform, const bool printable, unsigned int recur_counter);
|
||||
|
||||
void _apply_transform(ModelInstance& instance, const Transform3d& transform);
|
||||
|
||||
@@ -609,6 +628,9 @@ namespace Slic3r {
|
||||
|
||||
bool _generate_volumes(ModelObject& object, const Geometry& geometry, const ObjectMetadata::VolumeMetadataList& volumes, ConfigSubstitutionContext& config_substitutions);
|
||||
|
||||
// callbacks to parse the .rels file
|
||||
static void XMLCALL _handle_start_relationships_element(void *userData, const char *name, const char **attributes);
|
||||
|
||||
// callbacks to parse the .model file
|
||||
static void XMLCALL _handle_start_model_xml_element(void* userData, const char* name, const char** attributes);
|
||||
static void XMLCALL _handle_end_model_xml_element(void* userData, const char* name);
|
||||
@@ -658,6 +680,7 @@ namespace Slic3r {
|
||||
m_sla_support_points.clear();
|
||||
m_curr_metadata_name.clear();
|
||||
m_curr_characters.clear();
|
||||
m_start_part_path = MODEL_FILE; // set default value for invalid .rel file
|
||||
clear_errors();
|
||||
|
||||
return _load_model_from_file(filename, model, config, config_substitutions);
|
||||
@@ -697,16 +720,29 @@ namespace Slic3r {
|
||||
|
||||
m_name = boost::filesystem::path(filename).stem().string();
|
||||
|
||||
// we first loop the entries to read from the archive the .model file only, in order to extract the version from it
|
||||
int index = mz_zip_reader_locate_file(&archive, RELATIONSHIPS_FILE.c_str(), nullptr, 0);
|
||||
if (index < 0 || !mz_zip_reader_file_stat(&archive, index, &stat))
|
||||
return false;
|
||||
|
||||
mz_zip_archive_file_stat start_part_stat{std::numeric_limits<mz_uint32>::max()};
|
||||
m_model_path = MODEL_FILE;
|
||||
_extract_relationships_from_archive(archive, stat);
|
||||
bool found_model = false;
|
||||
|
||||
// we first loop the entries to read from the .model files which are not root
|
||||
for (mz_uint i = 0; i < num_entries; ++i) {
|
||||
if (mz_zip_reader_file_stat(&archive, i, &stat)) {
|
||||
std::string name(stat.m_filename);
|
||||
std::replace(name.begin(), name.end(), '\\', '/');
|
||||
|
||||
if (boost::algorithm::istarts_with(name, MODEL_FOLDER) && boost::algorithm::iends_with(name, MODEL_EXTENSION)) {
|
||||
try
|
||||
{
|
||||
// valid model name -> extract model
|
||||
if (boost::algorithm::iends_with(name, MODEL_EXTENSION)) {
|
||||
// valid model name -> extract model
|
||||
m_model_path = "/" + name;
|
||||
if (m_model_path == m_start_part_path) {
|
||||
start_part_stat = stat;
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
if (!_extract_model_from_archive(archive, stat)) {
|
||||
close_zip_reader(&archive);
|
||||
add_error("Archive does not contain a valid model");
|
||||
@@ -719,10 +755,33 @@ namespace Slic3r {
|
||||
close_zip_reader(&archive);
|
||||
throw Slic3r::FileIOError(e.what());
|
||||
}
|
||||
found_model = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Read root model file
|
||||
if (start_part_stat.m_file_index < num_entries) {
|
||||
try {
|
||||
m_model_path.clear();
|
||||
if (!_extract_model_from_archive(archive, start_part_stat)) {
|
||||
close_zip_reader(&archive);
|
||||
add_error("Archive does not contain a valid model");
|
||||
return false;
|
||||
}
|
||||
} catch (const std::exception &e) {
|
||||
// ensure the zip archive is closed and rethrow the exception
|
||||
close_zip_reader(&archive);
|
||||
throw Slic3r::FileIOError(e.what());
|
||||
}
|
||||
found_model = true;
|
||||
}
|
||||
if (!found_model) {
|
||||
close_zip_reader(&archive);
|
||||
add_error("Not valid 3mf. There is missing .model file.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// we then loop again the entries to read other files stored in the archive
|
||||
for (mz_uint i = 0; i < num_entries; ++i) {
|
||||
if (mz_zip_reader_file_stat(&archive, i, &stat)) {
|
||||
@@ -855,7 +914,7 @@ namespace Slic3r {
|
||||
ObjectMetadata::VolumeMetadataList volumes;
|
||||
ObjectMetadata::VolumeMetadataList* volumes_ptr = nullptr;
|
||||
|
||||
IdToMetadataMap::iterator obj_metadata = m_objects_metadata.find(object.first);
|
||||
IdToMetadataMap::iterator obj_metadata = m_objects_metadata.find(object.first.second);
|
||||
if (obj_metadata != m_objects_metadata.end()) {
|
||||
// config data has been found, this model was saved using slic3r pe
|
||||
|
||||
@@ -936,8 +995,55 @@ namespace Slic3r {
|
||||
}
|
||||
}
|
||||
|
||||
// // fixes the min z of the model if negative
|
||||
// model.adjust_min_z();
|
||||
// We support our 3mf contains only configuration without mesh,
|
||||
// others MUST contain mesh (triangles and vertices).
|
||||
if (!m_qidislicer_generator_version.has_value() && model.objects.empty()) {
|
||||
const std::string msg = (boost::format(_u8L("The 3MF file does not contain a valid mesh.\n\n\"%1%\"")) % filename).str();
|
||||
throw Slic3r::RuntimeError(msg);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _3MF_Importer::_extract_relationships_from_archive(mz_zip_archive &archive, const mz_zip_archive_file_stat &stat)
|
||||
{
|
||||
if (stat.m_uncomp_size == 0 ||
|
||||
stat.m_uncomp_size > 10000000 // Prevent overloading by big Relations file(>10MB). there is no reason to be soo big
|
||||
) {
|
||||
add_error("Found invalid size");
|
||||
return false;
|
||||
}
|
||||
|
||||
_destroy_xml_parser();
|
||||
|
||||
m_xml_parser = XML_ParserCreate(nullptr);
|
||||
if (m_xml_parser == nullptr) {
|
||||
add_error("Unable to create parser");
|
||||
return false;
|
||||
}
|
||||
|
||||
XML_SetUserData(m_xml_parser, (void *) this);
|
||||
XML_SetStartElementHandler(m_xml_parser, _handle_start_relationships_element);
|
||||
|
||||
void *parser_buffer = XML_GetBuffer(m_xml_parser, (int) stat.m_uncomp_size);
|
||||
if (parser_buffer == nullptr) {
|
||||
add_error("Unable to create buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
mz_bool res = mz_zip_reader_extract_file_to_mem(&archive, stat.m_filename, parser_buffer, (size_t) stat.m_uncomp_size, 0);
|
||||
if (res == 0) {
|
||||
add_error("Error while reading config data to buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!XML_ParseBuffer(m_xml_parser, (int) stat.m_uncomp_size, 1)) {
|
||||
char error_buf[1024];
|
||||
::sprintf(error_buf, "Error (%s) while parsing xml file at line %d", XML_ErrorString(XML_GetErrorCode(m_xml_parser)),
|
||||
(int) XML_GetCurrentLineNumber(m_xml_parser));
|
||||
add_error(error_buf);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -945,6 +1051,7 @@ namespace Slic3r {
|
||||
bool _3MF_Importer::_is_svg_shape_file(const std::string &name) const {
|
||||
return boost::starts_with(name, MODEL_FOLDER) && boost::ends_with(name, ".svg");
|
||||
}
|
||||
|
||||
bool _3MF_Importer::_extract_model_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat)
|
||||
{
|
||||
if (stat.m_uncomp_size == 0) {
|
||||
@@ -1402,6 +1509,7 @@ namespace Slic3r {
|
||||
svg->file_data = m_path_to_emboss_shape_files[filename];
|
||||
}
|
||||
}
|
||||
|
||||
bool _3MF_Importer::_extract_model_config_from_archive(mz_zip_archive& archive, const mz_zip_archive_file_stat& stat, Model& model)
|
||||
{
|
||||
if (stat.m_uncomp_size == 0) {
|
||||
@@ -1501,7 +1609,41 @@ namespace Slic3r {
|
||||
}
|
||||
}
|
||||
|
||||
void _3MF_Importer::_handle_start_model_xml_element(const char* name, const char** attributes)
|
||||
void XMLCALL _3MF_Importer::_handle_start_relationships_element(void *userData, const char *name, const char **attributes)
|
||||
{
|
||||
_3MF_Importer *importer = (_3MF_Importer *) userData;
|
||||
if (importer != nullptr)
|
||||
importer->_handle_start_relationships_element(name, attributes);
|
||||
}
|
||||
|
||||
void _3MF_Importer::_handle_start_relationships_element(const char *name, const char **attributes)
|
||||
{
|
||||
if (m_xml_parser == nullptr)
|
||||
return;
|
||||
|
||||
bool res = true;
|
||||
unsigned int num_attributes = (unsigned int) XML_GetSpecifiedAttributeCount(m_xml_parser);
|
||||
|
||||
if (::strcmp(RELATIONSHIP_TAG, name) == 0)
|
||||
res = _handle_start_relationship(attributes, num_attributes);
|
||||
|
||||
m_curr_characters.clear();
|
||||
if (!res)
|
||||
_stop_xml_parser();
|
||||
}
|
||||
|
||||
bool _3MF_Importer::_handle_start_relationship(const char **attributes, unsigned int num_attributes)
|
||||
{
|
||||
std::string type = get_attribute_value_string(attributes, num_attributes, RELS_TYPE_ATTR);
|
||||
// only exactly that string type mean root model file
|
||||
if (type == "http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel") {
|
||||
std::string path = get_attribute_value_string(attributes, num_attributes, TARGET_ATTR);
|
||||
m_start_part_path = path;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void _3MF_Importer::_handle_start_model_xml_element(const char *name, const char **attributes)
|
||||
{
|
||||
if (m_xml_parser == nullptr)
|
||||
return;
|
||||
@@ -1640,6 +1782,9 @@ namespace Slic3r {
|
||||
|
||||
bool _3MF_Importer::_handle_end_model()
|
||||
{
|
||||
if (!m_model_path.empty())
|
||||
return true;
|
||||
|
||||
// deletes all non-built or non-instanced objects
|
||||
for (const IdToModelObjectMap::value_type& object : m_objects) {
|
||||
if (object.second >= int(m_model->objects.size())) {
|
||||
@@ -1708,6 +1853,7 @@ namespace Slic3r {
|
||||
bool _3MF_Importer::_handle_end_object()
|
||||
{
|
||||
if (m_curr_object.object != nullptr) {
|
||||
PathId object_id{m_model_path, m_curr_object.id};
|
||||
if (m_curr_object.geometry.empty()) {
|
||||
// no geometry defined
|
||||
// remove the object from the model
|
||||
@@ -1715,26 +1861,26 @@ namespace Slic3r {
|
||||
|
||||
if (m_curr_object.components.empty()) {
|
||||
// no components defined -> invalid object, delete it
|
||||
IdToModelObjectMap::iterator object_item = m_objects.find(m_curr_object.id);
|
||||
IdToModelObjectMap::iterator object_item = m_objects.find(object_id);
|
||||
if (object_item != m_objects.end())
|
||||
m_objects.erase(object_item);
|
||||
|
||||
IdToAliasesMap::iterator alias_item = m_objects_aliases.find(m_curr_object.id);
|
||||
IdToAliasesMap::iterator alias_item = m_objects_aliases.find(object_id);
|
||||
if (alias_item != m_objects_aliases.end())
|
||||
m_objects_aliases.erase(alias_item);
|
||||
}
|
||||
else
|
||||
// adds components to aliases
|
||||
m_objects_aliases.insert({ m_curr_object.id, m_curr_object.components });
|
||||
m_objects_aliases.insert({ object_id, m_curr_object.components });
|
||||
}
|
||||
else {
|
||||
// geometry defined, store it for later use
|
||||
m_geometries.insert({ m_curr_object.id, std::move(m_curr_object.geometry) });
|
||||
m_geometries.insert({ object_id, std::move(m_curr_object.geometry) });
|
||||
|
||||
// stores the object for later use
|
||||
if (m_objects.find(m_curr_object.id) == m_objects.end()) {
|
||||
m_objects.insert({ m_curr_object.id, m_curr_object.model_object_idx });
|
||||
m_objects_aliases.insert({ m_curr_object.id, { 1, Component(m_curr_object.id) } }); // aliases itself
|
||||
if (m_objects.find(object_id) == m_objects.end()) {
|
||||
m_objects.insert({ object_id, m_curr_object.model_object_idx });
|
||||
m_objects_aliases.insert({object_id, {1, Component(object_id)}}); // aliases itself
|
||||
}
|
||||
else {
|
||||
add_error("Found object with duplicate id");
|
||||
@@ -1820,7 +1966,11 @@ namespace Slic3r {
|
||||
|
||||
m_curr_object.geometry.custom_supports.push_back(get_attribute_value_string(attributes, num_attributes, CUSTOM_SUPPORTS_ATTR));
|
||||
m_curr_object.geometry.custom_seam.push_back(get_attribute_value_string(attributes, num_attributes, CUSTOM_SEAM_ATTR));
|
||||
m_curr_object.geometry.mmu_segmentation.push_back(get_attribute_value_string(attributes, num_attributes, MMU_SEGMENTATION_ATTR));
|
||||
std::string mm_segmentation_serialized = get_attribute_value_string(attributes, num_attributes, MM_SEGMENTATION_ATTR);
|
||||
if (mm_segmentation_serialized.empty())
|
||||
mm_segmentation_serialized = get_attribute_value_string(attributes, num_attributes, "paint_color");
|
||||
m_curr_object.geometry.mm_segmentation.push_back(mm_segmentation_serialized);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1845,19 +1995,23 @@ namespace Slic3r {
|
||||
|
||||
bool _3MF_Importer::_handle_start_component(const char** attributes, unsigned int num_attributes)
|
||||
{
|
||||
int object_id = get_attribute_value_int(attributes, num_attributes, OBJECTID_ATTR);
|
||||
std::string path = get_attribute_value_string(attributes, num_attributes, PPATH_ATTR);
|
||||
if (path.empty()) path = m_model_path;
|
||||
|
||||
int object_id = get_attribute_value_int(attributes, num_attributes, OBJECTID_ATTR);
|
||||
Transform3d transform = get_transform_from_3mf_specs_string(get_attribute_value_string(attributes, num_attributes, TRANSFORM_ATTR));
|
||||
|
||||
IdToModelObjectMap::iterator object_item = m_objects.find(object_id);
|
||||
|
||||
PathId path_id { path, object_id };
|
||||
IdToModelObjectMap::iterator object_item = m_objects.find(path_id);
|
||||
if (object_item == m_objects.end()) {
|
||||
IdToAliasesMap::iterator alias_item = m_objects_aliases.find(object_id);
|
||||
IdToAliasesMap::iterator alias_item = m_objects_aliases.find(path_id);
|
||||
if (alias_item == m_objects_aliases.end()) {
|
||||
add_error("Found component with invalid object id");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
m_curr_object.components.emplace_back(object_id, transform);
|
||||
m_curr_object.components.emplace_back(path_id, transform);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1891,9 +2045,11 @@ namespace Slic3r {
|
||||
|
||||
int object_id = get_attribute_value_int(attributes, num_attributes, OBJECTID_ATTR);
|
||||
Transform3d transform = get_transform_from_3mf_specs_string(get_attribute_value_string(attributes, num_attributes, TRANSFORM_ATTR));
|
||||
std::string path = get_attribute_value_string(attributes, num_attributes, PPATH_ATTR);
|
||||
if (path.empty()) path = m_model_path;
|
||||
int printable = get_attribute_value_bool(attributes, num_attributes, PRINTABLE_ATTR);
|
||||
|
||||
return _create_object_instance(object_id, transform, printable, 1);
|
||||
return _create_object_instance({path, object_id}, transform, printable, 1);
|
||||
}
|
||||
|
||||
bool _3MF_Importer::_handle_end_item()
|
||||
@@ -1955,7 +2111,7 @@ namespace Slic3r {
|
||||
{
|
||||
public:
|
||||
TextConfigurationSerialization() = delete;
|
||||
|
||||
|
||||
using TypeToName = boost::bimap<EmbossStyle::Type, std::string_view>;
|
||||
static const TypeToName type_to_name;
|
||||
|
||||
@@ -1990,11 +2146,11 @@ namespace Slic3r {
|
||||
{
|
||||
IdToMetadataMap::iterator object = m_objects_metadata.find(m_curr_config.object_id);
|
||||
if (object == m_objects_metadata.end()) {
|
||||
add_error("Cannot assign volume mesh to a valid object");
|
||||
add_error("Can not assign volume mesh to a valid object");
|
||||
return false;
|
||||
}
|
||||
if (object->second.volumes.empty()) {
|
||||
add_error("Cannot assign mesh to a valid volume");
|
||||
add_error("Can not assign mesh to a valid volume");
|
||||
return false;
|
||||
}
|
||||
ObjectMetadata::VolumeMetadata& volume = object->second.volumes.back();
|
||||
@@ -2049,7 +2205,7 @@ namespace Slic3r {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _3MF_Importer::_create_object_instance(int object_id, const Transform3d& transform, const bool printable, unsigned int recur_counter)
|
||||
bool _3MF_Importer::_create_object_instance(PathId object_id, const Transform3d& transform, const bool printable, unsigned int recur_counter)
|
||||
{
|
||||
static const unsigned int MAX_RECURSIONS = 10;
|
||||
|
||||
@@ -2310,41 +2466,30 @@ namespace Slic3r {
|
||||
if (has_transform)
|
||||
volume->source.transform = Slic3r::Geometry::Transformation(volume_matrix_to_object);
|
||||
|
||||
// recreate custom supports, seam and mmu segmentation from previously loaded attribute
|
||||
// recreate custom supports, seam and mm segmentation from previously loaded attribute
|
||||
volume->supported_facets.reserve(triangles_count);
|
||||
volume->seam_facets.reserve(triangles_count);
|
||||
volume->mmu_segmentation_facets.reserve(triangles_count);
|
||||
volume->mm_segmentation_facets.reserve(triangles_count);
|
||||
for (size_t i=0; i<triangles_count; ++i) {
|
||||
size_t index = volume_data.first_triangle_id + i;
|
||||
assert(index < geometry.custom_supports.size());
|
||||
assert(index < geometry.custom_seam.size());
|
||||
assert(index < geometry.mmu_segmentation.size());
|
||||
assert(index < geometry.mm_segmentation.size());
|
||||
if (! geometry.custom_supports[index].empty())
|
||||
volume->supported_facets.set_triangle_from_string(i, geometry.custom_supports[index]);
|
||||
if (! geometry.custom_seam[index].empty())
|
||||
volume->seam_facets.set_triangle_from_string(i, geometry.custom_seam[index]);
|
||||
if (! geometry.mmu_segmentation[index].empty())
|
||||
volume->mmu_segmentation_facets.set_triangle_from_string(i, geometry.mmu_segmentation[index]);
|
||||
if (! geometry.mm_segmentation[index].empty())
|
||||
volume->mm_segmentation_facets.set_triangle_from_string(i, geometry.mm_segmentation[index]);
|
||||
}
|
||||
volume->supported_facets.shrink_to_fit();
|
||||
volume->seam_facets.shrink_to_fit();
|
||||
volume->mmu_segmentation_facets.shrink_to_fit();
|
||||
volume->mm_segmentation_facets.shrink_to_fit();
|
||||
|
||||
if (auto &es = volume_data.shape_configuration; es.has_value())
|
||||
volume->emboss_shape = std::move(es);
|
||||
if (auto &tc = volume_data.text_configuration; tc.has_value())
|
||||
volume->text_configuration = std::move(tc);
|
||||
|
||||
//// Transformation before store to 3mf
|
||||
//const Transform3d &pre_trmat = *tc->fix_3mf_tr;
|
||||
//// Cannot use source tranformation
|
||||
//// When store transformed againg to 3mf it is not modified !!!
|
||||
//// const Transform3d &pre_trmat = volume->source.transform.get_matrix();
|
||||
|
||||
//// create fix transformation
|
||||
//assert(tc->fix_3mf_tr.has_value());
|
||||
//volume->text_configuration->fix_3mf_tr =
|
||||
// pre_trmat.inverse() *
|
||||
// volume->get_transformation().get_matrix();
|
||||
|
||||
// apply the remaining volume's metadata
|
||||
for (const Metadata& metadata : volume_data.metadata) {
|
||||
@@ -3003,12 +3148,12 @@ namespace Slic3r {
|
||||
output_buffer += "\"";
|
||||
}
|
||||
|
||||
std::string mmu_painting_data_string = volume->mmu_segmentation_facets.get_triangle_as_string(i);
|
||||
if (! mmu_painting_data_string.empty()) {
|
||||
std::string mm_painting_data_string = volume->mm_segmentation_facets.get_triangle_as_string(i);
|
||||
if (! mm_painting_data_string.empty()) {
|
||||
output_buffer += " ";
|
||||
output_buffer += MMU_SEGMENTATION_ATTR;
|
||||
output_buffer += MM_SEGMENTATION_ATTR;
|
||||
output_buffer += "=\"";
|
||||
output_buffer += mmu_painting_data_string;
|
||||
output_buffer += mm_painting_data_string;
|
||||
output_buffer += "\"";
|
||||
}
|
||||
|
||||
@@ -3420,11 +3565,11 @@ namespace Slic3r {
|
||||
for (const std::string& key : volume->config.keys()) {
|
||||
stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << VOLUME_TYPE << "\" " << KEY_ATTR << "=\"" << key << "\" " << VALUE_ATTR << "=\"" << volume->config.opt_serialize(key) << "\"/>\n";
|
||||
}
|
||||
|
||||
|
||||
if (const std::optional<EmbossShape> &es = volume->emboss_shape;
|
||||
es.has_value())
|
||||
to_xml(stream, *es, *volume, archive);
|
||||
// stores volume's text data
|
||||
|
||||
if (const std::optional<TextConfiguration> &tc = volume->text_configuration;
|
||||
tc.has_value())
|
||||
TextConfigurationSerialization::to_xml(stream, *tc);
|
||||
@@ -3575,11 +3720,11 @@ bool load_3mf(const char* path, DynamicPrintConfig& config, ConfigSubstitutionCo
|
||||
// All import should use "C" locales for number formatting.
|
||||
CNumericLocalesSetter locales_setter;
|
||||
_3MF_Importer importer;
|
||||
importer.load_model_from_file(path, *model, config, config_substitutions, check_version);
|
||||
bool res = importer.load_model_from_file(path, *model, config, config_substitutions, check_version);
|
||||
importer.log_errors();
|
||||
handle_legacy_project_loaded(importer.version(), config, importer.qidislicer_generator_version());
|
||||
|
||||
return !model->objects.empty() || !config.empty();
|
||||
return res;
|
||||
}
|
||||
|
||||
bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config, bool fullpath_sources, const ThumbnailData* thumbnail_data, bool zip64)
|
||||
@@ -3630,11 +3775,12 @@ S bimap_cvt(const boost::bimap<F, S> &bmap, F f, const S &def_value)
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
/// <summary>
|
||||
/// TextConfiguration serialization
|
||||
/// </summary>
|
||||
const TextConfigurationSerialization::TypeToName TextConfigurationSerialization::type_to_name =
|
||||
boost::assign::list_of<TypeToName::relation>
|
||||
boost::assign::list_of<TypeToName::relation>
|
||||
(EmbossStyle::Type::file_path, "file_name")
|
||||
(EmbossStyle::Type::wx_win_font_descr, "wxFontDescriptor_Windows")
|
||||
(EmbossStyle::Type::wx_lin_font_descr, "wxFontDescriptor_Linux")
|
||||
@@ -3651,6 +3797,8 @@ const TextConfigurationSerialization::VerticalAlignToName TextConfigurationSeria
|
||||
(FontProp::VerticalAlign::top, "top")
|
||||
(FontProp::VerticalAlign::center, "middle")
|
||||
(FontProp::VerticalAlign::bottom, "bottom");
|
||||
|
||||
|
||||
void TextConfigurationSerialization::to_xml(std::stringstream &stream, const TextConfiguration &tc)
|
||||
{
|
||||
stream << " <" << TEXT_TAG << " ";
|
||||
@@ -3698,25 +3846,29 @@ namespace {
|
||||
|
||||
FontProp::HorizontalAlign read_horizontal_align(const char **attributes, unsigned int num_attributes, const TextConfigurationSerialization::HorizontalAlignToName& horizontal_align_to_name){
|
||||
std::string horizontal_align_str = get_attribute_value_string(attributes, num_attributes, HORIZONTAL_ALIGN_ATTR);
|
||||
// FIX of baked transformation
|
||||
|
||||
// Back compatibility
|
||||
// PS 2.6.0 do not have align
|
||||
if (horizontal_align_str.empty())
|
||||
return FontProp::HorizontalAlign::center;
|
||||
|
||||
// Back compatibility
|
||||
// PS 2.6.1 store indices(0|1|2) instead of text for align
|
||||
if (horizontal_align_str.length() == 1) {
|
||||
int horizontal_align_int = 0;
|
||||
if(boost::spirit::qi::parse(horizontal_align_str.c_str(), horizontal_align_str.c_str() + 1, boost::spirit::qi::int_, horizontal_align_int))
|
||||
return static_cast<FontProp::HorizontalAlign>(horizontal_align_int);
|
||||
}
|
||||
|
||||
return bimap_cvt(horizontal_align_to_name, std::string_view(horizontal_align_str), FontProp::HorizontalAlign::center);
|
||||
}
|
||||
|
||||
// IMPROVE: check if volume was modified (translated, rotated OR scaled)
|
||||
return bimap_cvt(horizontal_align_to_name, std::string_view(horizontal_align_str), FontProp::HorizontalAlign::center);
|
||||
}
|
||||
|
||||
|
||||
FontProp::VerticalAlign read_vertical_align(const char **attributes, unsigned int num_attributes, const TextConfigurationSerialization::VerticalAlignToName& vertical_align_to_name){
|
||||
std::string vertical_align_str = get_attribute_value_string(attributes, num_attributes, VERTICAL_ALIGN_ATTR);
|
||||
// when no change do not calculate transformation only store original fix matrix
|
||||
|
||||
// Create transformation used after load actual stored volume
|
||||
// Back compatibility
|
||||
// PS 2.6.0 do not have align
|
||||
if (vertical_align_str.empty())
|
||||
return FontProp::VerticalAlign::center;
|
||||
|
||||
@@ -3729,9 +3881,10 @@ FontProp::VerticalAlign read_vertical_align(const char **attributes, unsigned in
|
||||
}
|
||||
|
||||
return bimap_cvt(vertical_align_to_name, std::string_view(vertical_align_str), FontProp::VerticalAlign::center);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::optional<TextConfiguration> TextConfigurationSerialization::read(const char **attributes, unsigned int num_attributes)
|
||||
{
|
||||
FontProp fp;
|
||||
@@ -3751,6 +3904,7 @@ std::optional<TextConfiguration> TextConfigurationSerialization::read(const char
|
||||
fp.align = FontProp::Align(
|
||||
read_horizontal_align(attributes, num_attributes, horizontal_align_to_name),
|
||||
read_vertical_align(attributes, num_attributes, vertical_align_to_name));
|
||||
|
||||
int collection_number = get_attribute_value_int(attributes, num_attributes, COLLECTION_NUMBER_ATTR);
|
||||
if (collection_number > 0) fp.collection_number = static_cast<unsigned int>(collection_number);
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@ namespace {
|
||||
std::string to_ini(const ConfMap &m)
|
||||
{
|
||||
std::string ret;
|
||||
for (auto ¶m : m) ret += param.first + " = " + param.second + "\n";
|
||||
for (auto ¶m : m)
|
||||
ret += param.first + " = " + param.second + "\n";
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Original implementation of STEP format import created by Bambulab.
|
||||
// https://github.com/bambulab/BambuStudio
|
||||
// Forked off commit 1555904, modified by QIDI Research.
|
||||
|
||||
#ifndef slic3r_Format_STEP_hpp_
|
||||
#define slic3r_Format_STEP_hpp_
|
||||
|
||||
@@ -135,7 +135,7 @@ std::pair<DynamicPrintConfig, ConfigSubstitutions> extract_profile(
|
||||
// as output argument then replace it with the readed profile to report
|
||||
// that it was empty.
|
||||
profile_use = profile_in.empty() ? profile_out : profile_in;
|
||||
profile_out = profile_in;
|
||||
profile_out += std::move(profile_in);
|
||||
|
||||
return {profile_use, std::move(config_substitutions)};
|
||||
}
|
||||
|
||||
@@ -24,8 +24,9 @@
|
||||
#include "GCode/WipeTowerIntegration.hpp"
|
||||
#include "GCode/SeamPlacer.hpp"
|
||||
#include "GCode/GCodeProcessor.hpp"
|
||||
#include "EdgeGrid.hpp"
|
||||
#include "GCode/ThumbnailData.hpp"
|
||||
#include "GCode/Travels.hpp"
|
||||
#include "EdgeGrid.hpp"
|
||||
#include "tcbspan/span.hpp"
|
||||
|
||||
#include <memory>
|
||||
@@ -38,6 +39,7 @@ namespace Slic3r {
|
||||
|
||||
// Forward declarations.
|
||||
class GCodeGenerator;
|
||||
struct WipeTowerData;
|
||||
|
||||
namespace { struct Item; }
|
||||
struct PrintInstance;
|
||||
@@ -75,136 +77,33 @@ struct LayerResult {
|
||||
static LayerResult make_nop_layer_result() { return {"", std::numeric_limits<coord_t>::max(), false, false, true}; }
|
||||
};
|
||||
|
||||
namespace GCode::Impl {
|
||||
struct DistancedPoint {
|
||||
Point point;
|
||||
double distance_from_start;
|
||||
namespace GCode {
|
||||
// Object and support extrusions of the same PrintObject at the same print_z.
|
||||
// public, so that it could be accessed by free helper functions from GCode.cpp
|
||||
struct ObjectLayerToPrint
|
||||
{
|
||||
ObjectLayerToPrint() : object_layer(nullptr), support_layer(nullptr) {}
|
||||
const Layer* object_layer;
|
||||
const SupportLayer* support_layer;
|
||||
const Layer* layer() const { return (object_layer != nullptr) ? object_layer : support_layer; }
|
||||
const PrintObject* object() const { return (this->layer() != nullptr) ? this->layer()->object() : nullptr; }
|
||||
coordf_t print_z() const { return (object_layer != nullptr && support_layer != nullptr) ? 0.5 * (object_layer->print_z + support_layer->print_z) : this->layer()->print_z; }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Takes a path described as a list of points and adds points to it.
|
||||
*
|
||||
* @param xy_path A list of points describing a path in xy.
|
||||
* @param sorted_distances A sorted list of distances along the path.
|
||||
* @return Sliced path.
|
||||
*
|
||||
* The algorithm travels along the path segments and adds points to
|
||||
* the segments in such a way that the points have specified distances
|
||||
* from the xy_path start. **Any distances over the xy_path end will
|
||||
* be simply ignored.**
|
||||
*
|
||||
* Example usage - simplified for clarity:
|
||||
* @code
|
||||
* std::vector<double> distances{0.5, 1.5};
|
||||
* std::vector<Points> xy_path{{0, 0}, {1, 0}};
|
||||
* // produces
|
||||
* {{0, 0}, {0, 0.5}, {1, 0}}
|
||||
* // notice that 1.5 is omitted
|
||||
* @endcode
|
||||
*/
|
||||
std::vector<DistancedPoint> slice_xy_path(tcb::span<const Point> xy_path, tcb::span<const double> sorted_distances);
|
||||
struct PrintObjectInstance
|
||||
{
|
||||
const PrintObject *print_object = nullptr;
|
||||
int instance_idx = -1;
|
||||
|
||||
/**
|
||||
* @brief Take xy_path and genrate a travel acording to elevation.
|
||||
*
|
||||
* @param xy_path A list of points describing a path in xy.
|
||||
* @param ensure_points_at_distances See slice_xy_path sorted_distances.
|
||||
* @param elevation A function taking current distance in mm as input and returning elevation in mm as output.
|
||||
*
|
||||
* **Be aweare** that the elevation function operates in mm, while xy_path and returned travel are in
|
||||
* scaled coordinates.
|
||||
*/
|
||||
Points3 generate_elevated_travel(
|
||||
const tcb::span<const Point> xy_path,
|
||||
const std::vector<double>& ensure_points_at_distances,
|
||||
const double initial_elevation,
|
||||
const std::function<double(double)>& elevation
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Takes a list o polygons and builds a AABBTree over all unscaled lines.
|
||||
*
|
||||
* @param polygons A list of polygons.
|
||||
* @return AABB Tree over all lines of the polygons.
|
||||
*
|
||||
* Unscales the lines in the process!
|
||||
*/
|
||||
AABBTreeLines::LinesDistancer<Linef> get_expolygons_distancer(const ExPolygons& polygons);
|
||||
|
||||
/**
|
||||
* @brief Given a AABB tree over lines find intersection with xy_path closest to the xy_path start.
|
||||
*
|
||||
* @param xy_path A path in 2D.
|
||||
* @param distancer AABB Tree over lines.
|
||||
* @return Distance to the first intersection if there is one.
|
||||
*
|
||||
* **Ignores intersection with xy_path starting point.**
|
||||
*/
|
||||
std::optional<double> get_first_crossed_line_distance(
|
||||
tcb::span<const Line> xy_path,
|
||||
const AABBTreeLines::LinesDistancer<Linef>& distancer
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Generates a regular polygon - all angles are the same (e.g. typical hexagon).
|
||||
*
|
||||
* @param centroid Central point.
|
||||
* @param start_point The polygon point are ordered. This is the first point.
|
||||
* @param points_count Amount of nodes of the polygon (e.g. 6 for haxagon).
|
||||
*
|
||||
* Distance between centroid and start point sets the scale of the polygon.
|
||||
*/
|
||||
Polygon generate_regular_polygon(
|
||||
const Point& centroid,
|
||||
const Point& start_point,
|
||||
const unsigned points_count
|
||||
);
|
||||
|
||||
class Bed {
|
||||
private:
|
||||
Polygon inner_offset;
|
||||
static Polygon get_inner_offset(const std::vector<Vec2d>& shape, const double padding);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Bed shape with inner padding.
|
||||
*/
|
||||
Bed(const std::vector<Vec2d>& shape, const double padding);
|
||||
|
||||
Vec2d centroid;
|
||||
|
||||
/**
|
||||
* Returns true if the point is within the bed shape including inner padding.
|
||||
*/
|
||||
bool contains_within_padding(const Vec2d& point) const;
|
||||
bool operator==(const PrintObjectInstance &other) const {return print_object == other.print_object && instance_idx == other.instance_idx; }
|
||||
bool operator!=(const PrintObjectInstance &other) const { return !(*this == other); }
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace GCode
|
||||
|
||||
class GCodeGenerator {
|
||||
public:
|
||||
GCodeGenerator() :
|
||||
m_origin(Vec2d::Zero()),
|
||||
m_enable_loop_clipping(true),
|
||||
m_enable_cooling_markers(false),
|
||||
m_enable_extrusion_role_markers(false),
|
||||
m_last_processor_extrusion_role(GCodeExtrusionRole::None),
|
||||
m_layer_count(0),
|
||||
m_layer_index(-1),
|
||||
m_layer(nullptr),
|
||||
m_object_layer_over_raft(false),
|
||||
m_volumetric_speed(0),
|
||||
m_last_pos_defined(false),
|
||||
m_last_extrusion_role(GCodeExtrusionRole::None),
|
||||
m_last_width(0.0f),
|
||||
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||
m_last_mm3_per_mm(0.0),
|
||||
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||
m_brim_done(false),
|
||||
m_second_layer_things_done(false),
|
||||
m_silent_time_estimator_enabled(false),
|
||||
m_last_obj_copy(nullptr, Point(std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max()))
|
||||
{}
|
||||
GCodeGenerator(const Print* print = nullptr); // The default value is only used in unit tests.
|
||||
~GCodeGenerator() = default;
|
||||
|
||||
// throws std::runtime_exception on error,
|
||||
@@ -215,13 +114,25 @@ public:
|
||||
const Vec2d& origin() const { return m_origin; }
|
||||
void set_origin(const Vec2d &pointf);
|
||||
void set_origin(const coordf_t x, const coordf_t y) { this->set_origin(Vec2d(x, y)); }
|
||||
const Point& last_pos() const { return m_last_pos; }
|
||||
// Convert coordinates of the active object to G-code coordinates, possibly adjusted for extruder offset.
|
||||
template<typename Derived>
|
||||
Vec2d point_to_gcode(const Eigen::MatrixBase<Derived> &point) const {
|
||||
static_assert(Derived::IsVectorAtCompileTime && int(Derived::SizeAtCompileTime) == 2, "GCodeGenerator::point_to_gcode(): first parameter is not a 2D vector");
|
||||
Eigen::Matrix<double, Derived::SizeAtCompileTime, 1, Eigen::DontAlign> point_to_gcode(const Eigen::MatrixBase<Derived> &point) const {
|
||||
static_assert(
|
||||
Derived::IsVectorAtCompileTime,
|
||||
"GCodeGenerator::point_to_gcode(): first parameter is not a vector"
|
||||
);
|
||||
static_assert(
|
||||
int(Derived::SizeAtCompileTime) == 2 || int(Derived::SizeAtCompileTime) == 3,
|
||||
"GCodeGenerator::point_to_gcode(): first parameter is not a 2D or 3D vector"
|
||||
);
|
||||
|
||||
if constexpr (Derived::SizeAtCompileTime == 2) {
|
||||
return Vec2d(unscaled<double>(point.x()), unscaled<double>(point.y())) + m_origin
|
||||
- m_config.extruder_offset.get_at(m_writer.extruder()->id());
|
||||
} else {
|
||||
const Vec2d gcode_point_xy{this->point_to_gcode(point.template head<2>())};
|
||||
return to_3d(gcode_point_xy, unscaled(point.z()));
|
||||
}
|
||||
}
|
||||
// Convert coordinates of the active object to G-code coordinates, possibly adjusted for extruder offset and quantized to G-code resolution.
|
||||
template<typename Derived>
|
||||
@@ -242,8 +153,6 @@ public:
|
||||
std::string placeholder_parser_process(const std::string &name, const std::string &templ, unsigned int current_extruder_id, const DynamicConfig *config_override = nullptr);
|
||||
bool enable_cooling_markers() const { return m_enable_cooling_markers; }
|
||||
|
||||
// For Perl bindings, to be used exclusively by unit tests.
|
||||
unsigned int layer_count() const { return m_layer_count; }
|
||||
void set_layer_count(unsigned int value) { m_layer_count = value; }
|
||||
void apply_print_config(const PrintConfig &print_config);
|
||||
|
||||
@@ -252,18 +161,10 @@ public:
|
||||
// translate full config into a list of <key, value> items
|
||||
static void encode_full_config(const Print& print, std::vector<std::pair<std::string, std::string>>& config);
|
||||
|
||||
// Object and support extrusions of the same PrintObject at the same print_z.
|
||||
// public, so that it could be accessed by free helper functions from GCode.cpp
|
||||
struct ObjectLayerToPrint
|
||||
{
|
||||
ObjectLayerToPrint() : object_layer(nullptr), support_layer(nullptr) {}
|
||||
const Layer* object_layer;
|
||||
const SupportLayer* support_layer;
|
||||
const Layer* layer() const { return (object_layer != nullptr) ? object_layer : support_layer; }
|
||||
const PrintObject* object() const { return (this->layer() != nullptr) ? this->layer()->object() : nullptr; }
|
||||
coordf_t print_z() const { return (object_layer != nullptr && support_layer != nullptr) ? 0.5 * (object_layer->print_z + support_layer->print_z) : this->layer()->print_z; }
|
||||
};
|
||||
using ObjectsLayerToPrint = std::vector<ObjectLayerToPrint>;
|
||||
using ObjectLayerToPrint = GCode::ObjectLayerToPrint;
|
||||
using ObjectsLayerToPrint = std::vector<GCode::ObjectLayerToPrint>;
|
||||
|
||||
std::optional<Point> last_position;
|
||||
|
||||
private:
|
||||
class GCodeOutputStream {
|
||||
@@ -309,6 +210,15 @@ private:
|
||||
static ObjectsLayerToPrint collect_layers_to_print(const PrintObject &object);
|
||||
static std::vector<std::pair<coordf_t, ObjectsLayerToPrint>> collect_layers_to_print(const Print &print);
|
||||
|
||||
Polyline get_layer_change_xy_path(const Vec3d &from, const Vec3d &to);
|
||||
|
||||
std::string get_ramping_layer_change_gcode(const Vec3d &from, const Vec3d &to, const unsigned extruder_id);
|
||||
/** @brief Generates ramping travel gcode for layer change. */
|
||||
std::string generate_ramping_layer_change_gcode(
|
||||
const Polyline &xy_path,
|
||||
const double initial_elevation,
|
||||
const GCode::Impl::Travels::ElevatedTravelParams &elevation_params
|
||||
) const;
|
||||
LayerResult process_layer(
|
||||
const Print &print,
|
||||
// Set of object & print layers of the same PrintObject and with the same print_z.
|
||||
@@ -342,19 +252,12 @@ private:
|
||||
const GCode::SmoothPathCache &smooth_path_cache_global,
|
||||
GCodeOutputStream &output_stream);
|
||||
|
||||
void set_last_pos(const Point &pos) { m_last_pos = pos; m_last_pos_defined = true; }
|
||||
bool last_pos_defined() const { return m_last_pos_defined; }
|
||||
void set_extruders(const std::vector<unsigned int> &extruder_ids);
|
||||
std::string preamble();
|
||||
std::optional<std::string> get_helical_layer_change_gcode(
|
||||
const coordf_t previous_layer_z,
|
||||
const coordf_t print_z,
|
||||
const std::string& comment
|
||||
);
|
||||
std::string change_layer(
|
||||
coordf_t previous_layer_z,
|
||||
coordf_t print_z,
|
||||
const bool spiral_vase_enabled
|
||||
bool vase_mode
|
||||
);
|
||||
std::string extrude_entity(const ExtrusionEntityReference &entity, const GCode::SmoothPathCache &smooth_path_cache, const std::string_view description, double speed = -1.);
|
||||
std::string extrude_loop(const ExtrusionLoop &loop, const GCode::SmoothPathCache &smooth_path_cache, const std::string_view description, double speed = -1.);
|
||||
@@ -406,7 +309,8 @@ private:
|
||||
std::string extrude_support(const ExtrusionEntityReferences &support_fills, const GCode::SmoothPathCache &smooth_path_cache);
|
||||
std::string generate_travel_gcode(
|
||||
const Points3& travel,
|
||||
const std::string& comment
|
||||
const std::string& comment,
|
||||
const std::function<std::string()>& insert_gcode
|
||||
);
|
||||
Polyline generate_travel_xy_path(
|
||||
const Point& start,
|
||||
@@ -414,8 +318,15 @@ private:
|
||||
const bool needs_retraction,
|
||||
bool& could_be_wipe_disabled
|
||||
);
|
||||
std::string travel_to(
|
||||
const Point &start_point,
|
||||
const Point &end_point,
|
||||
ExtrusionRole role,
|
||||
const std::string &comment,
|
||||
const std::function<std::string()>& insert_gcode
|
||||
);
|
||||
|
||||
std::string travel_to(const Point &point, ExtrusionRole role, std::string comment);
|
||||
std::string travel_to_first_position(const Vec3crd& point, const double from_z, const ExtrusionRole role, const std::function<std::string()>& insert_gcode);
|
||||
bool needs_retraction(const Polyline &travel, ExtrusionRole role = ExtrusionRole::None);
|
||||
|
||||
//B41
|
||||
@@ -426,7 +337,7 @@ private:
|
||||
int unique_id;
|
||||
};
|
||||
std::unordered_map<const PrintInstance *, LabelData> m_label_data;
|
||||
std::string retract_and_wipe(bool toolchange = false);
|
||||
std::string retract_and_wipe(bool toolchange = false, bool reset_e = true);
|
||||
std::string unretract() { return m_writer.unretract(); }
|
||||
std::string set_extruder(unsigned int extruder_id, double print_z);
|
||||
bool line_distancer_is_required(const std::vector<unsigned int>& extruder_ids);
|
||||
@@ -446,7 +357,7 @@ private:
|
||||
struct PlaceholderParserIntegration {
|
||||
void reset();
|
||||
void init(const GCodeWriter &config);
|
||||
void update_from_gcodewriter(const GCodeWriter &writer);
|
||||
void update_from_gcodewriter(const GCodeWriter &writer, const WipeTowerData& wipe_tower_data);
|
||||
void validate_output_vector_variables();
|
||||
|
||||
PlaceholderParser parser;
|
||||
@@ -479,6 +390,7 @@ private:
|
||||
AvoidCrossingPerimeters m_avoid_crossing_perimeters;
|
||||
JPSPathFinder m_avoid_crossing_curled_overhangs;
|
||||
RetractWhenCrossingPerimeters m_retract_when_crossing_perimeters;
|
||||
GCode::TravelObstacleTracker m_travel_obstacle_tracker;
|
||||
bool m_enable_loop_clipping;
|
||||
// If enabled, the G-code generator will put following comments at the ends
|
||||
// of the G-code lines: _EXTRUDE_SET_SPEED, _WIPE, _BRIDGE_FAN_START, _BRIDGE_FAN_END
|
||||
@@ -498,7 +410,6 @@ private:
|
||||
// In non-sequential mode, all its copies will be printed.
|
||||
const Layer* m_layer;
|
||||
// m_layer is an object layer and it is being printed over raft surface.
|
||||
std::optional<AABBTreeLines::LinesDistancer<Linef>> m_previous_layer_distancer;
|
||||
bool m_object_layer_over_raft;
|
||||
double m_volumetric_speed;
|
||||
// Support for the extrusion role markers. Which marker is active?
|
||||
@@ -512,8 +423,15 @@ private:
|
||||
double m_last_mm3_per_mm;
|
||||
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
|
||||
|
||||
Point m_last_pos;
|
||||
bool m_last_pos_defined;
|
||||
std::optional<Vec3d> m_previous_layer_last_position;
|
||||
std::optional<Vec3d> m_previous_layer_last_position_before_wipe;
|
||||
// This needs to be populated during the layer processing!
|
||||
std::optional<Vec3d> m_current_layer_first_position;
|
||||
std::optional<unsigned> m_layer_change_extruder_id;
|
||||
bool m_layer_change_used_external_mp{false};
|
||||
const Layer* m_layer_change_layer{nullptr};
|
||||
std::optional<Vec2d> m_layer_change_origin;
|
||||
bool m_already_unretracted{false};
|
||||
|
||||
std::unique_ptr<CoolingBuffer> m_cooling_buffer;
|
||||
std::unique_ptr<SpiralVase> m_spiral_vase;
|
||||
@@ -527,22 +445,33 @@ private:
|
||||
bool m_brim_done;
|
||||
// Flag indicating whether the nozzle temperature changes from 1st to 2nd layer were performed.
|
||||
bool m_second_layer_things_done;
|
||||
// Index of a last object copy extruded.
|
||||
std::pair<const PrintObject*, Point> m_last_obj_copy;
|
||||
// G-code that is due to be written before the next extrusion
|
||||
std::string m_pending_pre_extrusion_gcode;
|
||||
// Pointer to currently exporting PrintObject and instance index.
|
||||
GCode::PrintObjectInstance m_current_instance;
|
||||
|
||||
bool m_silent_time_estimator_enabled;
|
||||
|
||||
// Processor
|
||||
GCodeProcessor m_processor;
|
||||
|
||||
// Back-pointer to Print (const).
|
||||
const Print* m_print;
|
||||
std::string _extrude(
|
||||
const ExtrusionAttributes &attribs, const Geometry::ArcWelder::Path &path, const std::string_view description, double speed = -1);
|
||||
void print_machine_envelope(GCodeOutputStream &file, Print &print);
|
||||
void _print_first_layer_bed_temperature(GCodeOutputStream &file, Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait);
|
||||
void _print_first_layer_extruder_temperatures(GCodeOutputStream &file, Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait);
|
||||
void print_machine_envelope(GCodeOutputStream &file, const Print &print);
|
||||
void _print_first_layer_bed_temperature(GCodeOutputStream &file, const Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait);
|
||||
void _print_first_layer_extruder_temperatures(GCodeOutputStream &file, const Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait);
|
||||
|
||||
// On the first printing layer. This flag triggers first layer speeds.
|
||||
bool on_first_layer() const { return m_layer != nullptr && m_layer->id() == 0; }
|
||||
//w25
|
||||
int layer_id() const
|
||||
{
|
||||
if (m_layer == nullptr)
|
||||
return -1;
|
||||
return m_layer->id();
|
||||
}
|
||||
// To control print speed of 1st object layer over raft interface.
|
||||
bool object_layer_over_raft() const { return m_object_layer_over_raft; }
|
||||
|
||||
|
||||
@@ -1171,9 +1171,9 @@ Polyline AvoidCrossingPerimeters::travel_to(const GCodeGenerator &gcodegen, cons
|
||||
{
|
||||
// If use_external, then perform the path planning in the world coordinate system (correcting for the gcodegen offset).
|
||||
// Otherwise perform the path planning in the coordinate system of the active object.
|
||||
bool use_external = m_use_external_mp || m_use_external_mp_once;
|
||||
bool use_external = m_use_external_mp || use_external_mp_once;
|
||||
Point scaled_origin = use_external ? Point::new_scale(gcodegen.origin()(0), gcodegen.origin()(1)) : Point(0, 0);
|
||||
const Point start = gcodegen.last_pos() + scaled_origin;
|
||||
const Point start = *gcodegen.last_position + scaled_origin;
|
||||
const Point end = point + scaled_origin;
|
||||
const Line travel(start, end);
|
||||
|
||||
@@ -1470,7 +1470,7 @@ static size_t avoid_perimeters(const AvoidCrossingPerimeters::Boundary &boundary
|
||||
}
|
||||
|
||||
// Plan travel, which avoids perimeter crossings by following the boundaries of the layer.
|
||||
Polyline AvoidCrossingPerimeters::travel_to(const GCode &gcodegen, const Point &point, bool *could_be_wipe_disabled)
|
||||
Polyline AvoidCrossingPerimeters::travel_to(const GCodeGenerator &gcodegen, const Point &point, bool *could_be_wipe_disabled)
|
||||
{
|
||||
// If use_external, then perform the path planning in the world coordinate system (correcting for the gcodegen offset).
|
||||
// Otherwise perform the path planning in the coordinate system of the active object.
|
||||
|
||||
@@ -17,11 +17,10 @@ class AvoidCrossingPerimeters
|
||||
public:
|
||||
// Routing around the objects vs. inside a single object.
|
||||
void use_external_mp(bool use = true) { m_use_external_mp = use; };
|
||||
void use_external_mp_once() { m_use_external_mp_once = true; }
|
||||
bool used_external_mp_once() { return m_use_external_mp_once; }
|
||||
bool used_external_mp_once() { return use_external_mp_once; }
|
||||
void disable_once() { m_disabled_once = true; }
|
||||
bool disabled_once() const { return m_disabled_once; }
|
||||
void reset_once_modifiers() { m_use_external_mp_once = false; m_disabled_once = false; }
|
||||
void reset_once_modifiers() { use_external_mp_once = false; m_disabled_once = false; }
|
||||
|
||||
void init_layer(const Layer &layer);
|
||||
|
||||
@@ -50,10 +49,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// just for the next travel move
|
||||
bool use_external_mp_once { false };
|
||||
private:
|
||||
bool m_use_external_mp { false };
|
||||
// just for the next travel move
|
||||
bool m_use_external_mp_once { false };
|
||||
// this flag disables avoid_crossing_perimeters just for the next travel move
|
||||
// we enable it by default for the first travel move in print
|
||||
bool m_disabled_once { true };
|
||||
|
||||
@@ -143,6 +143,14 @@ std::pair<float,float> calculate_overhang_speed(const ExtrusionAttributes &attri
|
||||
float external_perim_reference_speed,
|
||||
float default_speed)
|
||||
{
|
||||
//w19
|
||||
bool is_overhang = attributes.overhang_attributes->start_distance_from_prev_layer >= 0.25 * attributes.width &&
|
||||
attributes.overhang_attributes->end_distance_from_prev_layer >= 0.25 * attributes.width;//&&
|
||||
//attributes.overhang_attributes->proximity_to_curled_lines > 0.05 ;
|
||||
|
||||
if (!is_overhang) {
|
||||
return {default_speed, 0};
|
||||
}
|
||||
assert(attributes.overhang_attributes.has_value());
|
||||
std::vector<std::pair<int, ConfigOptionFloatOrPercent>> overhangs_with_speeds = {
|
||||
{100, ConfigOptionFloatOrPercent{default_speed, false}}};
|
||||
@@ -197,9 +205,11 @@ std::pair<float,float> calculate_overhang_speed(const ExtrusionAttributes &attri
|
||||
|
||||
float extrusion_speed = std::min(interpolate_speed(speed_sections, attributes.overhang_attributes->start_distance_from_prev_layer),
|
||||
interpolate_speed(speed_sections, attributes.overhang_attributes->end_distance_from_prev_layer));
|
||||
//w19
|
||||
float curled_base_speed = interpolate_speed(speed_sections,
|
||||
attributes.width * attributes.overhang_attributes->proximity_to_curled_lines);
|
||||
float final_speed = std::min(curled_base_speed, extrusion_speed);
|
||||
attributes.width * attributes.overhang_attributes->proximity_to_curled_lines/tan(67.5));
|
||||
float final_speed = std::min(curled_base_speed, extrusion_speed);
|
||||
|
||||
float fan_speed = std::min(interpolate_speed(fan_speed_sections, attributes.overhang_attributes->start_distance_from_prev_layer),
|
||||
interpolate_speed(fan_speed_sections, attributes.overhang_attributes->end_distance_from_prev_layer));
|
||||
|
||||
|
||||
@@ -54,6 +54,9 @@ const std::vector<std::string> GCodeProcessor::Reserved_Tags = {
|
||||
"HEIGHT:",
|
||||
"WIDTH:",
|
||||
"LAYER_CHANGE",
|
||||
"LAYER_CHANGE_TRAVEL",
|
||||
"LAYER_CHANGE_RETRACTION_START",
|
||||
"LAYER_CHANGE_RETRACTION_END",
|
||||
"COLOR_CHANGE",
|
||||
"PAUSE_PRINT",
|
||||
"CUSTOM_GCODE",
|
||||
@@ -3803,7 +3806,13 @@ void GCodeProcessor::post_process()
|
||||
struct LineData
|
||||
{
|
||||
std::string line;
|
||||
float time;
|
||||
std::array<float, static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count)> times{ 0.0f, 0.0f };
|
||||
};
|
||||
|
||||
enum ETimeMode
|
||||
{
|
||||
Normal = static_cast<int>(PrintEstimatedStatistics::ETimeMode::Normal),
|
||||
Stealth = static_cast<int>(PrintEstimatedStatistics::ETimeMode::Stealth)
|
||||
};
|
||||
|
||||
#ifndef NDEBUG
|
||||
@@ -3833,10 +3842,10 @@ void GCodeProcessor::post_process()
|
||||
#endif // NDEBUG
|
||||
|
||||
EWriteType m_write_type{ EWriteType::BySize };
|
||||
// Time machine containing g1 times cache
|
||||
TimeMachine& m_machine;
|
||||
// Time machines containing g1 times cache
|
||||
const std::array<TimeMachine, static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count)>& m_machines;
|
||||
// Current time
|
||||
float m_time{ 0.0f };
|
||||
std::array<float, static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count)> m_times{ 0.0f, 0.0f };
|
||||
// Current size in bytes
|
||||
size_t m_size{ 0 };
|
||||
|
||||
@@ -3852,11 +3861,12 @@ void GCodeProcessor::post_process()
|
||||
|
||||
bgcode::binarize::Binarizer& m_binarizer;
|
||||
public:
|
||||
ExportLines(bgcode::binarize::Binarizer& binarizer, EWriteType type, TimeMachine& machine)
|
||||
ExportLines(bgcode::binarize::Binarizer& binarizer, EWriteType type,
|
||||
const std::array<TimeMachine, static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count)>& machines)
|
||||
#ifndef NDEBUG
|
||||
: m_statistics(*this), m_binarizer(binarizer), m_write_type(type), m_machine(machine) {}
|
||||
: m_statistics(*this), m_binarizer(binarizer), m_write_type(type), m_machines(machines) {}
|
||||
#else
|
||||
: m_binarizer(binarizer), m_write_type(type), m_machine(machine) {}
|
||||
: m_binarizer(binarizer), m_write_type(type), m_machines(machines) {}
|
||||
#endif // NDEBUG
|
||||
|
||||
// return: number of internal G1 lines (from G2/G3 splitting) processed
|
||||
@@ -3873,9 +3883,9 @@ void GCodeProcessor::post_process()
|
||||
else
|
||||
return ret;
|
||||
|
||||
auto init_it = m_machine.g1_times_cache.begin() + m_times_cache_id;
|
||||
auto init_it = m_machines[Normal].g1_times_cache.begin() + m_times_cache_id;
|
||||
auto it = init_it;
|
||||
while (it != m_machine.g1_times_cache.end() && it->id < g1_lines_counter) {
|
||||
while (it != m_machines[Normal].g1_times_cache.end() && it->id < g1_lines_counter) {
|
||||
++it;
|
||||
++m_times_cache_id;
|
||||
}
|
||||
@@ -3885,7 +3895,7 @@ void GCodeProcessor::post_process()
|
||||
|
||||
// search for internal G1 lines
|
||||
if (GCodeReader::GCodeLine::cmd_is(line, "G2") || GCodeReader::GCodeLine::cmd_is(line, "G3")) {
|
||||
while (it != m_machine.g1_times_cache.end() && it->remaining_internal_g1_lines > 0) {
|
||||
while (it != m_machines[Normal].g1_times_cache.end() && it->remaining_internal_g1_lines > 0) {
|
||||
++it;
|
||||
++m_times_cache_id;
|
||||
++g1_lines_counter;
|
||||
@@ -3893,14 +3903,17 @@ void GCodeProcessor::post_process()
|
||||
}
|
||||
}
|
||||
|
||||
if (it != m_machine.g1_times_cache.end() && it->id == g1_lines_counter)
|
||||
m_time = it->elapsed_time;
|
||||
if (it != m_machines[Normal].g1_times_cache.end() && it->id == g1_lines_counter) {
|
||||
m_times[Normal] = it->elapsed_time;
|
||||
if (!m_machines[Stealth].g1_times_cache.empty())
|
||||
m_times[Stealth] = (m_machines[Stealth].g1_times_cache.begin() + std::distance(m_machines[Normal].g1_times_cache.begin(), it))->elapsed_time;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// add the given gcode line to the cache
|
||||
void append_line(const std::string& line) {
|
||||
m_lines.push_back({ line, m_time });
|
||||
m_lines.push_back({ line, m_times });
|
||||
#ifndef NDEBUG
|
||||
m_statistics.add_line(line.length());
|
||||
#endif // NDEBUG
|
||||
@@ -3911,7 +3924,8 @@ void GCodeProcessor::post_process()
|
||||
}
|
||||
|
||||
// Insert the gcode lines required by the command cmd by backtracing into the cache
|
||||
void insert_lines(const Backtrace& backtrace, const std::string& cmd, std::function<std::string(unsigned int, float, float)> line_inserter,
|
||||
void insert_lines(const Backtrace& backtrace, const std::string& cmd,
|
||||
std::function<std::string(unsigned int, const std::vector<float>&)> line_inserter,
|
||||
std::function<std::string(const std::string&)> line_replacer) {
|
||||
assert(!m_lines.empty());
|
||||
const float time_step = backtrace.time_step();
|
||||
@@ -3919,13 +3933,13 @@ void GCodeProcessor::post_process()
|
||||
float last_time_insertion = 0.0f; // used to avoid inserting two lines at the same time
|
||||
for (unsigned int i = 0; i < backtrace.steps; ++i) {
|
||||
const float backtrace_time_i = (i + 1) * time_step;
|
||||
const float time_threshold_i = m_time - backtrace_time_i;
|
||||
const float time_threshold_i = m_times[Normal] - backtrace_time_i;
|
||||
auto rev_it = m_lines.rbegin() + rev_it_dist;
|
||||
auto start_rev_it = rev_it;
|
||||
|
||||
std::string curr_cmd = GCodeReader::GCodeLine::extract_cmd(rev_it->line);
|
||||
// backtrace into the cache to find the place where to insert the line
|
||||
while (rev_it != m_lines.rend() && rev_it->time > time_threshold_i && curr_cmd != cmd && curr_cmd != "G28" && curr_cmd != "G29") {
|
||||
while (rev_it != m_lines.rend() && rev_it->times[Normal] > time_threshold_i && curr_cmd != cmd && curr_cmd != "G28" && curr_cmd != "G29") {
|
||||
rev_it->line = line_replacer(rev_it->line);
|
||||
++rev_it;
|
||||
if (rev_it != m_lines.rend())
|
||||
@@ -3937,11 +3951,15 @@ void GCodeProcessor::post_process()
|
||||
break;
|
||||
|
||||
// insert the line for the current step
|
||||
if (rev_it != m_lines.rend() && rev_it != start_rev_it && rev_it->time != last_time_insertion) {
|
||||
last_time_insertion = rev_it->time;
|
||||
const std::string out_line = line_inserter(i + 1, last_time_insertion, m_time - last_time_insertion);
|
||||
if (rev_it != m_lines.rend() && rev_it != start_rev_it && rev_it->times[Normal] != last_time_insertion) {
|
||||
last_time_insertion = rev_it->times[Normal];
|
||||
std::vector<float> time_diffs;
|
||||
time_diffs.push_back(m_times[Normal] - last_time_insertion);
|
||||
if (!m_machines[Stealth].g1_times_cache.empty())
|
||||
time_diffs.push_back(m_times[Stealth] - rev_it->times[Stealth]);
|
||||
const std::string out_line = line_inserter(i + 1, time_diffs);
|
||||
rev_it_dist = std::distance(m_lines.rbegin(), rev_it) + 1;
|
||||
m_lines.insert(rev_it.base(), { out_line, rev_it->time });
|
||||
m_lines.insert(rev_it.base(), { out_line, rev_it->times });
|
||||
#ifndef NDEBUG
|
||||
m_statistics.add_line(out_line.length());
|
||||
#endif // NDEBUG
|
||||
@@ -3967,7 +3985,7 @@ void GCodeProcessor::post_process()
|
||||
std::string out_string;
|
||||
if (!m_lines.empty()) {
|
||||
if (m_write_type == EWriteType::ByTime) {
|
||||
while (m_lines.front().time < m_time - backtrace_time) {
|
||||
while (m_lines.front().times[Normal] < m_times[Normal] - backtrace_time) {
|
||||
const LineData& data = m_lines.front();
|
||||
out_string += data.line;
|
||||
m_size -= data.line.length();
|
||||
@@ -4052,7 +4070,8 @@ void GCodeProcessor::post_process()
|
||||
}
|
||||
};
|
||||
|
||||
ExportLines export_lines(m_binarizer, m_result.backtrace_enabled ? ExportLines::EWriteType::ByTime : ExportLines::EWriteType::BySize, m_time_processor.machines[0]);
|
||||
ExportLines export_lines(m_binarizer, m_result.backtrace_enabled ? ExportLines::EWriteType::ByTime : ExportLines::EWriteType::BySize,
|
||||
m_time_processor.machines);
|
||||
|
||||
// replace placeholder lines with the proper final value
|
||||
// gcode_line is in/out parameter, to reduce expensive memory allocation
|
||||
@@ -4256,9 +4275,14 @@ void GCodeProcessor::post_process()
|
||||
}
|
||||
export_lines.insert_lines(backtrace, cmd,
|
||||
// line inserter
|
||||
[tool_number, this](unsigned int id, float time, float time_diff) {
|
||||
int temperature = int( m_layer_id != 1 ? m_extruder_temps_config[tool_number] : m_extruder_temps_first_layer_config[tool_number]);
|
||||
const std::string out = "M104 T" + std::to_string(tool_number) + " P" + std::to_string(int(std::round(time_diff))) + " S" + std::to_string(temperature) + "\n";
|
||||
[tool_number, this](unsigned int id, const std::vector<float>& time_diffs) {
|
||||
const int temperature = int(m_layer_id != 1 ? m_extruder_temps_config[tool_number] : m_extruder_temps_first_layer_config[tool_number]);
|
||||
std::string out = "M104.1 T" + std::to_string(tool_number);
|
||||
if (time_diffs.size() > 0)
|
||||
out += " P" + std::to_string(int(std::round(time_diffs[0])));
|
||||
if (time_diffs.size() > 1)
|
||||
out += " Q" + std::to_string(int(std::round(time_diffs[1])));
|
||||
out += " S" + std::to_string(temperature) + "\n";
|
||||
return out;
|
||||
},
|
||||
// line replacer
|
||||
|
||||
@@ -185,6 +185,9 @@ namespace Slic3r {
|
||||
Height,
|
||||
Width,
|
||||
Layer_Change,
|
||||
Layer_Change_Travel,
|
||||
Layer_Change_Retraction_Start,
|
||||
Layer_Change_Retraction_End,
|
||||
Color_Change,
|
||||
Pause_Print,
|
||||
Custom_Code,
|
||||
|
||||
@@ -316,9 +316,8 @@ std::string GCodeWriter::set_speed(double F, const std::string_view comment, con
|
||||
return w.string();
|
||||
}
|
||||
|
||||
std::string GCodeWriter::travel_to_xy(const Vec2d &point, const std::string_view comment)
|
||||
std::string GCodeWriter::get_travel_to_xy_gcode(const Vec2d &point, const std::string_view comment) const
|
||||
{
|
||||
m_pos.head<2>() = point.head<2>();
|
||||
|
||||
GCodeG1Formatter w;
|
||||
w.emit_xy(point);
|
||||
@@ -330,6 +329,11 @@ std::string GCodeWriter::travel_to_xy(const Vec2d &point, const std::string_view
|
||||
return w.string();
|
||||
}
|
||||
|
||||
std::string GCodeWriter::travel_to_xy(const Vec2d &point, const std::string_view comment)
|
||||
{
|
||||
m_pos.head<2>() = point.head<2>();
|
||||
return this->get_travel_to_xy_gcode(point, comment);
|
||||
}
|
||||
std::string GCodeWriter::travel_to_xy_G2G3IJ(const Vec2d &point, const Vec2d &ij, const bool ccw, const std::string_view comment)
|
||||
{
|
||||
assert(std::abs(point.x()) < 1200.);
|
||||
@@ -347,33 +351,53 @@ std::string GCodeWriter::travel_to_xy_G2G3IJ(const Vec2d &point, const Vec2d &ij
|
||||
return w.string();
|
||||
}
|
||||
|
||||
std::string GCodeWriter::travel_to_xyz(const Vec3d &point, const std::string_view comment)
|
||||
std::string GCodeWriter::travel_to_xyz(const Vec3d& from, const Vec3d &to, const std::string_view comment)
|
||||
{
|
||||
if (std::abs(point.x() - m_pos.x()) < EPSILON && std::abs(point.y() - m_pos.y()) < EPSILON) {
|
||||
return this->travel_to_z(point.z(), comment);
|
||||
} else if (std::abs(point.z() - m_pos.z()) < EPSILON) {
|
||||
return this->travel_to_xy(point.head<2>(), comment);
|
||||
if (std::abs(to.x() - m_pos.x()) < EPSILON && std::abs(to.y() - m_pos.y()) < EPSILON) {
|
||||
return this->travel_to_z(to.z(), comment);
|
||||
} else if (std::abs(to.z() - m_pos.z()) < EPSILON) {
|
||||
return this->travel_to_xy(to.head<2>(), comment);
|
||||
} else {
|
||||
m_pos = point;
|
||||
m_pos = to;
|
||||
return this->get_travel_to_xyz_gcode(from, to, comment);
|
||||
}
|
||||
}
|
||||
|
||||
std::string GCodeWriter::get_travel_to_xyz_gcode(const Vec3d &from, const Vec3d &to, const std::string_view comment) const {
|
||||
GCodeG1Formatter w;
|
||||
w.emit_xyz(point);
|
||||
Vec2f speed {this->config.travel_speed_z.value, this->config.travel_speed.value};
|
||||
w.emit_f(speed.norm() * 60.0);
|
||||
w.emit_xyz(to);
|
||||
|
||||
double speed_z = this->config.travel_speed_z.value;
|
||||
if (speed_z == 0.)
|
||||
speed_z = this->config.travel_speed.value;
|
||||
|
||||
const double distance_xy{(to.head<2>() - from.head<2>()).norm()};
|
||||
const double distnace_z{std::abs(to.z() - from.z())};
|
||||
const double time_z = distnace_z / speed_z;
|
||||
const double time_xy = distance_xy / this->config.travel_speed.value;
|
||||
const double factor = time_z > 0 ? time_xy / time_z : 1;
|
||||
if (factor < 1) {
|
||||
w.emit_f((this->config.travel_speed.value * factor + (1 - factor) * speed_z) * 60.0);
|
||||
} else {
|
||||
w.emit_f(this->config.travel_speed.value * 60.0);
|
||||
}
|
||||
w.emit_comment(this->config.gcode_comments, comment);
|
||||
return w.string();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string GCodeWriter::travel_to_z(double z, const std::string_view comment)
|
||||
{
|
||||
return std::abs(m_pos.z() - z) < EPSILON ? "" : this->get_travel_to_z_gcode(z, comment);
|
||||
if (std::abs(m_pos.z() - z) < EPSILON) {
|
||||
return "";
|
||||
} else {
|
||||
m_pos.z() = z;
|
||||
return this->get_travel_to_z_gcode(z, comment);
|
||||
}
|
||||
}
|
||||
|
||||
std::string GCodeWriter::get_travel_to_z_gcode(double z, const std::string_view comment)
|
||||
std::string GCodeWriter::get_travel_to_z_gcode(double z, const std::string_view comment) const
|
||||
{
|
||||
m_pos.z() = z;
|
||||
|
||||
double speed = this->config.travel_speed_z.value;
|
||||
if (speed == 0.)
|
||||
|
||||
@@ -66,10 +66,21 @@ public:
|
||||
std::string toolchange_prefix() const;
|
||||
std::string toolchange(unsigned int extruder_id);
|
||||
std::string set_speed(double F, const std::string_view comment = {}, const std::string_view cooling_marker = {}) const;
|
||||
std::string get_travel_to_xy_gcode(const Vec2d &point, const std::string_view comment) const;
|
||||
std::string travel_to_xy(const Vec2d &point, const std::string_view comment = {});
|
||||
std::string travel_to_xy_G2G3IJ(const Vec2d &point, const Vec2d &ij, const bool ccw, const std::string_view comment = {});
|
||||
std::string travel_to_xyz(const Vec3d &point, const std::string_view comment = {});
|
||||
std::string get_travel_to_z_gcode(double z, const std::string_view comment);
|
||||
/**
|
||||
* @brief Return gcode with all three axis defined. Optionally adds feedrate.
|
||||
*
|
||||
* Feedrate is added the starting point "from" is specified.
|
||||
*
|
||||
* @param from Optional starting point of the travel.
|
||||
* @param to Where to travel to.
|
||||
* @param comment Description of the travel purpose.
|
||||
*/
|
||||
std::string get_travel_to_xyz_gcode(const Vec3d &from, const Vec3d &to, const std::string_view comment) const;
|
||||
std::string travel_to_xyz(const Vec3d &from, const Vec3d &to, const std::string_view comment = {});
|
||||
std::string get_travel_to_z_gcode(double z, const std::string_view comment) const;
|
||||
std::string travel_to_z(double z, const std::string_view comment = {});
|
||||
std::string extrude_to_xy(const Vec2d &point, double dE, const std::string_view comment = {});
|
||||
std::string extrude_to_xy_G2G3IJ(const Vec2d &point, const Vec2d &ij, const bool ccw, double dE, const std::string_view comment);
|
||||
@@ -187,6 +198,8 @@ public:
|
||||
{ return { quantize(pt.x(), XYZF_EXPORT_DIGITS), quantize(pt.y(), XYZF_EXPORT_DIGITS) }; }
|
||||
static Vec3d quantize(const Vec3d &pt)
|
||||
{ return { quantize(pt.x(), XYZF_EXPORT_DIGITS), quantize(pt.y(), XYZF_EXPORT_DIGITS), quantize(pt.z(), XYZF_EXPORT_DIGITS) }; }
|
||||
static Vec2d quantize(const Vec2f &pt)
|
||||
{ return { quantize(double(pt.x()), XYZF_EXPORT_DIGITS), quantize(double(pt.y()), XYZF_EXPORT_DIGITS) }; }
|
||||
|
||||
void emit_axis(const char axis, const double v, size_t digits);
|
||||
|
||||
@@ -224,7 +237,8 @@ public:
|
||||
}
|
||||
|
||||
void emit_string(const std::string_view s) {
|
||||
strncpy(ptr_err.ptr, s.data(), s.size());
|
||||
// Be aware that std::string_view::data() returns a pointer to a buffer that is not necessarily null-terminated.
|
||||
memcpy(ptr_err.ptr, s.data(), s.size());
|
||||
ptr_err.ptr += s.size();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
#include "LabelObjects.hpp"
|
||||
|
||||
#include "ClipperUtils.hpp"
|
||||
#include "GCode/GCodeWriter.hpp"
|
||||
#include "Model.hpp"
|
||||
#include "Print.hpp"
|
||||
#include "TriangleMeshSlicer.hpp"
|
||||
|
||||
#include "boost/algorithm/string/replace.hpp"
|
||||
|
||||
namespace Slic3r::GCode {
|
||||
|
||||
@@ -39,10 +41,10 @@ Polygon instance_outline(const PrintInstance* pi)
|
||||
}; // anonymous namespace
|
||||
|
||||
|
||||
void LabelObjects::init(const Print& print)
|
||||
void LabelObjects::init(const SpanOfConstPtrs<PrintObject>& objects, LabelObjectsStyle label_object_style, GCodeFlavor gcode_flavor)
|
||||
{
|
||||
m_label_objects_style = print.config().gcode_label_objects;
|
||||
m_flavor = print.config().gcode_flavor;
|
||||
m_label_objects_style = label_object_style;
|
||||
m_flavor = gcode_flavor;
|
||||
|
||||
if (m_label_objects_style == LabelObjectsStyle::Disabled)
|
||||
return;
|
||||
@@ -51,7 +53,7 @@ void LabelObjects::init(const Print& print)
|
||||
|
||||
// Iterate over all PrintObjects and their PrintInstances, collect PrintInstances which
|
||||
// belong to the same ModelObject.
|
||||
for (const PrintObject* po : print.objects())
|
||||
for (const PrintObject* po : objects)
|
||||
for (const PrintInstance& pi : po->instances())
|
||||
model_object_to_print_instances[pi.model_instance->get_object()].emplace_back(&pi);
|
||||
|
||||
@@ -81,18 +83,75 @@ void LabelObjects::init(const Print& print)
|
||||
if (object_has_more_instances)
|
||||
name += " (Instance " + std::to_string(instance_id) + ")";
|
||||
if (m_flavor == gcfKlipper) {
|
||||
const std::string banned = "-. \r\n\v\t\f";
|
||||
// Disallow Klipper special chars, common illegal filename chars, etc.
|
||||
const std::string banned = "\b\t\n\v\f\r \"#%&\'*-./:;<>\\";
|
||||
std::replace_if(name.begin(), name.end(), [&banned](char c) { return banned.find(c) != std::string::npos; }, '_');
|
||||
}
|
||||
}
|
||||
|
||||
m_label_data.emplace(pi, LabelData{name, unique_id});
|
||||
// Now calculate the polygon and center for Cancel Object (this is not always used).
|
||||
Polygon outline = instance_outline(pi);
|
||||
assert(! outline.empty());
|
||||
outline.douglas_peucker(50000.f);
|
||||
Point center = outline.centroid();
|
||||
char buffer[64];
|
||||
std::snprintf(buffer, sizeof(buffer) - 1, "%.3f,%.3f", unscale<float>(center[0]), unscale<float>(center[1]));
|
||||
std::string center_str(buffer);
|
||||
std::string polygon_str = std::string("[");
|
||||
for (const Point& point : outline) {
|
||||
std::snprintf(buffer, sizeof(buffer) - 1, "[%.3f,%.3f],", unscale<float>(point[0]), unscale<float>(point[1]));
|
||||
polygon_str += buffer;
|
||||
}
|
||||
polygon_str.pop_back();
|
||||
polygon_str += "]";
|
||||
|
||||
m_label_data.emplace_back(LabelData{pi, name, center_str, polygon_str, unique_id});
|
||||
++unique_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool LabelObjects::update(const PrintInstance *instance) {
|
||||
if (this->last_operation_instance == instance) {
|
||||
return false;
|
||||
}
|
||||
this->last_operation_instance = instance;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string LabelObjects::maybe_start_instance(GCodeWriter& writer) {
|
||||
if (current_instance == nullptr && last_operation_instance != nullptr) {
|
||||
current_instance = last_operation_instance;
|
||||
|
||||
std::string result{this->start_object(*current_instance, LabelObjects::IncludeName::No)};
|
||||
result += writer.reset_e(true);
|
||||
return result;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string LabelObjects::maybe_stop_instance() {
|
||||
if (current_instance != nullptr) {
|
||||
const std::string result{this->stop_object(*current_instance)};
|
||||
current_instance = nullptr;
|
||||
return result;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string LabelObjects::maybe_change_instance(GCodeWriter& writer) {
|
||||
if (last_operation_instance != current_instance) {
|
||||
const std::string stop_instance_gcode{this->maybe_stop_instance()};
|
||||
// Be carefull with refactoring: this->maybe_stop_instance() + this->maybe_start_instance()
|
||||
// may not be evaluated in order. The order is indeed undefined!
|
||||
return stop_instance_gcode + this->maybe_start_instance(writer);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
bool LabelObjects::has_active_instance() {
|
||||
return this->current_instance != nullptr;
|
||||
}
|
||||
|
||||
std::string LabelObjects::all_objects_header() const
|
||||
{
|
||||
@@ -101,38 +160,34 @@ std::string LabelObjects::all_objects_header() const
|
||||
|
||||
std::string out;
|
||||
|
||||
// Let's sort the values according to unique_id so they are in the same order in which they were added.
|
||||
std::vector<std::pair<const PrintInstance*, LabelData>> label_data_sorted;
|
||||
for (const auto& pi_and_label : m_label_data)
|
||||
label_data_sorted.emplace_back(pi_and_label);
|
||||
std::sort(label_data_sorted.begin(), label_data_sorted.end(), [](const auto& ld1, const auto& ld2) { return ld1.second.unique_id < ld2.second.unique_id; });
|
||||
|
||||
out += "\n";
|
||||
for (const auto& [print_instance, label] : label_data_sorted) {
|
||||
if (m_label_objects_style == LabelObjectsStyle::Firmware && m_flavor == gcfKlipper) {
|
||||
char buffer[64];
|
||||
out += "EXCLUDE_OBJECT_DEFINE NAME=" + label.name;
|
||||
Polygon outline = instance_outline(print_instance);
|
||||
assert(! outline.empty());
|
||||
outline.douglas_peucker(50000.f);
|
||||
Point center = outline.centroid();
|
||||
std::snprintf(buffer, sizeof(buffer) - 1, " CENTER=%.3f,%.3f", unscale<float>(center[0]), unscale<float>(center[1]));
|
||||
out += buffer + std::string(" POLYGON=[");
|
||||
for (const Point& point : outline) {
|
||||
std::snprintf(buffer, sizeof(buffer) - 1, "[%.3f,%.3f],", unscale<float>(point[0]), unscale<float>(point[1]));
|
||||
out += buffer;
|
||||
}
|
||||
out.pop_back();
|
||||
out += "]\n";
|
||||
} else {
|
||||
out += start_object(*print_instance, IncludeName::Yes);
|
||||
out += stop_object(*print_instance);
|
||||
for (const LabelData& label : m_label_data) {
|
||||
if (m_label_objects_style == LabelObjectsStyle::Firmware && m_flavor == gcfKlipper)
|
||||
out += "EXCLUDE_OBJECT_DEFINE NAME='" + label.name + "' CENTER=" + label.center + " POLYGON=" + label.polygon + "\n";
|
||||
else {
|
||||
out += start_object(*label.pi, IncludeName::Yes);
|
||||
out += stop_object(*label.pi);
|
||||
}
|
||||
}
|
||||
out += "\n";
|
||||
return out;
|
||||
}
|
||||
|
||||
std::string LabelObjects::all_objects_header_singleline_json() const
|
||||
{
|
||||
std::string out;
|
||||
out = "{\"objects\":[";
|
||||
for (size_t i=0; i<m_label_data.size(); ++i) {
|
||||
const LabelData& label = m_label_data[i];
|
||||
out += std::string("{\"name\":\"") + label.name + "\",";
|
||||
out += "\"polygon\":" + label.polygon + "}";
|
||||
if (i != m_label_data.size() - 1)
|
||||
out += ",";
|
||||
}
|
||||
out += "]}";
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
std::string LabelObjects::start_object(const PrintInstance& print_instance, IncludeName include_name) const
|
||||
@@ -140,7 +195,7 @@ std::string LabelObjects::start_object(const PrintInstance& print_instance, Incl
|
||||
if (m_label_objects_style == LabelObjectsStyle::Disabled)
|
||||
return std::string();
|
||||
|
||||
const LabelData& label = m_label_data.at(&print_instance);
|
||||
const LabelData& label = *std::find_if(m_label_data.begin(), m_label_data.end(), [&print_instance](const LabelData& ld) { return ld.pi == &print_instance; });
|
||||
|
||||
std::string out;
|
||||
if (m_label_objects_style == LabelObjectsStyle::Octoprint)
|
||||
@@ -154,7 +209,7 @@ std::string LabelObjects::start_object(const PrintInstance& print_instance, Incl
|
||||
}
|
||||
out += "\n";
|
||||
} else if (m_flavor == gcfKlipper)
|
||||
out += "EXCLUDE_OBJECT_START NAME=" + label.name + "\n";
|
||||
out += "EXCLUDE_OBJECT_START NAME='" + label.name + "'\n";
|
||||
else {
|
||||
// Not supported by / implemented for the other firmware flavors.
|
||||
}
|
||||
@@ -169,7 +224,7 @@ std::string LabelObjects::stop_object(const PrintInstance& print_instance) const
|
||||
if (m_label_objects_style == LabelObjectsStyle::Disabled)
|
||||
return std::string();
|
||||
|
||||
const LabelData& label = m_label_data.at(&print_instance);
|
||||
const LabelData& label = *std::find_if(m_label_data.begin(), m_label_data.end(), [&print_instance](const LabelData& ld) { return ld.pi == &print_instance; });
|
||||
|
||||
std::string out;
|
||||
if (m_label_objects_style == LabelObjectsStyle::Octoprint)
|
||||
@@ -178,7 +233,7 @@ std::string LabelObjects::stop_object(const PrintInstance& print_instance) const
|
||||
if (m_flavor == GCodeFlavor::gcfMarlinFirmware || m_flavor == GCodeFlavor::gcfMarlinLegacy || m_flavor == GCodeFlavor::gcfRepRapFirmware)
|
||||
out += std::string("M486 S-1\n");
|
||||
else if (m_flavor ==gcfKlipper)
|
||||
out += "EXCLUDE_OBJECT_END NAME=" + label.name + "\n";
|
||||
out += "EXCLUDE_OBJECT_END NAME='" + label.name + "'\n";
|
||||
else {
|
||||
// Not supported by / implemented for the other firmware flavors.
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
#define slic3r_GCode_LabelObjects_hpp_
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "libslic3r/Print.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
@@ -11,30 +13,49 @@ enum class LabelObjectsStyle;
|
||||
struct PrintInstance;
|
||||
class Print;
|
||||
|
||||
class GCodeWriter;
|
||||
|
||||
namespace GCode {
|
||||
|
||||
|
||||
class LabelObjects {
|
||||
class LabelObjects
|
||||
{
|
||||
public:
|
||||
void init(const SpanOfConstPtrs<PrintObject>& objects, LabelObjectsStyle label_object_style, GCodeFlavor gcode_flavor);
|
||||
std::string all_objects_header() const;
|
||||
std::string all_objects_header_singleline_json() const;
|
||||
|
||||
bool update(const PrintInstance *instance);
|
||||
|
||||
std::string maybe_start_instance(GCodeWriter& writer);
|
||||
|
||||
std::string maybe_stop_instance();
|
||||
|
||||
std::string maybe_change_instance(GCodeWriter& writer);
|
||||
|
||||
bool has_active_instance();
|
||||
|
||||
private:
|
||||
struct LabelData
|
||||
{
|
||||
const PrintInstance* pi;
|
||||
std::string name;
|
||||
std::string center;
|
||||
std::string polygon;
|
||||
int unique_id;
|
||||
};
|
||||
enum class IncludeName {
|
||||
No,
|
||||
Yes
|
||||
};
|
||||
void init(const Print& print);
|
||||
std::string all_objects_header() const;
|
||||
std::string start_object(const PrintInstance& print_instance, IncludeName include_name) const;
|
||||
std::string stop_object(const PrintInstance& print_instance) const;
|
||||
|
||||
private:
|
||||
struct LabelData {
|
||||
std::string name;
|
||||
int unique_id;
|
||||
};
|
||||
const PrintInstance* current_instance{nullptr};
|
||||
const PrintInstance* last_operation_instance{nullptr};
|
||||
|
||||
LabelObjectsStyle m_label_objects_style;
|
||||
GCodeFlavor m_flavor;
|
||||
std::unordered_map<const PrintInstance*, LabelData> m_label_data;
|
||||
std::vector<LabelData> m_label_data;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <memory.h>
|
||||
#include <cstring>
|
||||
#include <cfloat>
|
||||
#include <algorithm>
|
||||
|
||||
#include "../libslic3r.h"
|
||||
#include "../PrintConfig.hpp"
|
||||
@@ -27,6 +28,11 @@ static constexpr float max_segment_length = 5.f;
|
||||
// affect how distant will be propagated a flow rate adjustment.
|
||||
static constexpr int max_look_back_limit = 128;
|
||||
|
||||
// Max non-extruding XY distance (travel move) in mm between two continuous extrusions where we pretend
|
||||
// it's all one continuous extrusion line. Above this distance, we assume extruder pressure hits 0
|
||||
// This exists because often there are tiny travel moves between stuff like infill.
|
||||
// Lines where some extruder pressure will remain (so we should equalize between these small travels).
|
||||
static constexpr double max_ignored_gap_between_extruding_segments = 3.;
|
||||
PressureEqualizer::PressureEqualizer(const Slic3r::GCodeConfig &config) : m_use_relative_e_distances(config.use_relative_e_distances.value)
|
||||
{
|
||||
// Preallocate some data, so that output_buffer.data() will return an empty string.
|
||||
@@ -59,8 +65,8 @@ PressureEqualizer::PressureEqualizer(const Slic3r::GCodeConfig &config) : m_use_
|
||||
extrusion_rate_slope.positive = m_max_volumetric_extrusion_rate_slope_positive;
|
||||
}
|
||||
|
||||
// Don't regulate the pressure before and after gap-fill and ironing.
|
||||
for (const GCodeExtrusionRole er : {GCodeExtrusionRole::GapFill, GCodeExtrusionRole::Ironing}) {
|
||||
// Don't regulate the pressure before and after ironing.
|
||||
for (const GCodeExtrusionRole er : {GCodeExtrusionRole::Ironing}) {
|
||||
m_max_volumetric_extrusion_rate_slopes[size_t(er)].negative = 0;
|
||||
m_max_volumetric_extrusion_rate_slopes[size_t(er)].positive = 0;
|
||||
}
|
||||
@@ -97,6 +103,72 @@ void PressureEqualizer::process_layer(const std::string &gcode)
|
||||
}
|
||||
assert(!this->opened_extrude_set_speed_block);
|
||||
}
|
||||
// At this point, we have an entire layer of gcode lines loaded into m_gcode_lines.
|
||||
// Now, we will split the mix of travels and extrusions into segments of continuous extrusions and process them.
|
||||
// We skip over large travels, and pretend that small ones are part of a continuous extrusion segment.
|
||||
for (auto current_extrusion_end_it = m_gcode_lines.cbegin(); current_extrusion_end_it != m_gcode_lines.cend();) {
|
||||
// Find beginning of next extrusion segment from current position.
|
||||
const auto current_extrusion_begin_it = std::find_if(current_extrusion_end_it, m_gcode_lines.cend(), [](const GCodeLine &line) {
|
||||
return line.extruding();
|
||||
});
|
||||
|
||||
// We start with extrusion length of zero.
|
||||
current_extrusion_end_it = current_extrusion_begin_it;
|
||||
|
||||
// Inner loop extends the extrusion segment over small travel moves.
|
||||
while (current_extrusion_end_it != m_gcode_lines.cend()) {
|
||||
// Find the end of the current extrusion segment.
|
||||
const auto travel_begin_it = std::find_if(std::next(current_extrusion_end_it), m_gcode_lines.cend(), [](const GCodeLine &line) {
|
||||
return !line.extruding();
|
||||
});
|
||||
|
||||
current_extrusion_end_it = std::prev(travel_begin_it);
|
||||
|
||||
const auto next_extrusion_segment_it = advance_segment_beyond_small_gap(current_extrusion_end_it);
|
||||
if (std::distance(current_extrusion_end_it, next_extrusion_segment_it) > 0) {
|
||||
// Extend the continuous line over the small gap.
|
||||
current_extrusion_end_it = next_extrusion_segment_it;
|
||||
continue; // Keep going, loop again to find the new end of extrusion segment.
|
||||
} else {
|
||||
break; // Gap to next extrude is too big, stop looking forward. We've found the end of this segment.
|
||||
}
|
||||
}
|
||||
|
||||
// Now, run the pressure equalizer across the segment like a streamroller.
|
||||
// It operates on a sliding window that moves forward across gcode line by line.
|
||||
const std::ptrdiff_t current_extrusion_begin_idx = std::distance(m_gcode_lines.cbegin(), current_extrusion_begin_it);
|
||||
for (auto current_line_it = current_extrusion_begin_it; current_line_it != current_extrusion_end_it; ++current_line_it) {
|
||||
const std::ptrdiff_t current_line_idx = std::distance(m_gcode_lines.cbegin(), current_line_it);
|
||||
|
||||
// Feed pressure equalizer past lines, going back to max_look_back_limit (or start of segment).
|
||||
const size_t start_idx = size_t(std::max<std::ptrdiff_t>(current_extrusion_begin_idx, current_line_idx - max_look_back_limit));
|
||||
adjust_volumetric_rate(start_idx, size_t(current_line_idx));
|
||||
}
|
||||
|
||||
// Current extrusion is all done processing so advance beyond it for the next loop.
|
||||
if (current_extrusion_end_it != m_gcode_lines.cend())
|
||||
++current_extrusion_end_it;
|
||||
}
|
||||
}
|
||||
|
||||
PressureEqualizer::GCodeLinesConstIt PressureEqualizer::advance_segment_beyond_small_gap(const GCodeLinesConstIt &last_extruding_line_it) const {
|
||||
// This should only be run on the last extruding line before a gap.
|
||||
assert(last_extruding_line_it != m_gcode_lines.cend() && last_extruding_line_it->extruding());
|
||||
double travel_distance = 0.;
|
||||
// Start at the beginning of a gap, advance till extrusion found or gap too big.
|
||||
for (auto current_line_it = std::next(last_extruding_line_it); current_line_it != m_gcode_lines.cend(); ++current_line_it) {
|
||||
// Started extruding again! Return segment extension.
|
||||
if (current_line_it->extruding())
|
||||
return current_line_it;
|
||||
|
||||
travel_distance += current_line_it->dist_xy();
|
||||
// Gap too big, don't extend segment.
|
||||
if (travel_distance > max_ignored_gap_between_extruding_segments)
|
||||
return last_extruding_line_it;
|
||||
}
|
||||
|
||||
// Looped until the end of the layer and couldn't extend extrusion.
|
||||
return last_extruding_line_it;
|
||||
}
|
||||
|
||||
LayerResult PressureEqualizer::process_layer(LayerResult &&input)
|
||||
@@ -391,7 +463,6 @@ bool PressureEqualizer::process_line(const char *line, const char *line_end, GCo
|
||||
buf.extruder_id = m_current_extruder;
|
||||
memcpy(buf.pos_end, m_current_pos, sizeof(float)*5);
|
||||
|
||||
adjust_volumetric_rate();
|
||||
#ifdef PRESSURE_EQUALIZER_DEBUG
|
||||
++line_idx;
|
||||
#endif
|
||||
@@ -506,16 +577,14 @@ void PressureEqualizer::output_gcode_line(const size_t line_idx)
|
||||
}
|
||||
}
|
||||
|
||||
void PressureEqualizer::adjust_volumetric_rate()
|
||||
void PressureEqualizer::adjust_volumetric_rate(const size_t first_line_idx, const size_t last_line_idx)
|
||||
{
|
||||
if (m_gcode_lines.size() < 2)
|
||||
// Don't bother adjusting volumetric rate if there's no gcode to adjust.
|
||||
if (last_line_idx <= first_line_idx || last_line_idx - first_line_idx < 2)
|
||||
return;
|
||||
|
||||
// Go back from the current circular_buffer_pos and lower the feedtrate to decrease the slope of the extrusion rate changes.
|
||||
size_t fist_line_idx = size_t(std::max<int>(0, int(m_gcode_lines.size()) - max_look_back_limit));
|
||||
const size_t last_line_idx = m_gcode_lines.size() - 1;
|
||||
size_t line_idx = last_line_idx;
|
||||
if (line_idx == fist_line_idx || !m_gcode_lines[line_idx].extruding())
|
||||
if (line_idx == first_line_idx || !m_gcode_lines[line_idx].extruding())
|
||||
// Nothing to do, the last move is not extruding.
|
||||
return;
|
||||
|
||||
@@ -523,13 +592,13 @@ void PressureEqualizer::adjust_volumetric_rate()
|
||||
feedrate_per_extrusion_role.fill(std::numeric_limits<float>::max());
|
||||
feedrate_per_extrusion_role[int(m_gcode_lines[line_idx].extrusion_role)] = m_gcode_lines[line_idx].volumetric_extrusion_rate_start;
|
||||
|
||||
while (line_idx != fist_line_idx) {
|
||||
while (line_idx != first_line_idx) {
|
||||
size_t idx_prev = line_idx - 1;
|
||||
for (; !m_gcode_lines[idx_prev].extruding() && idx_prev != fist_line_idx; --idx_prev);
|
||||
for (; !m_gcode_lines[idx_prev].extruding() && idx_prev != first_line_idx; --idx_prev);
|
||||
if (!m_gcode_lines[idx_prev].extruding())
|
||||
break;
|
||||
// Don't decelerate before ironing and gap-fill.
|
||||
if (m_gcode_lines[line_idx].extrusion_role == GCodeExtrusionRole::Ironing || m_gcode_lines[line_idx].extrusion_role == GCodeExtrusionRole::GapFill) {
|
||||
// Don't decelerate before ironing.
|
||||
if (m_gcode_lines[line_idx].extrusion_role == GCodeExtrusionRole::Ironing) {
|
||||
line_idx = idx_prev;
|
||||
continue;
|
||||
}
|
||||
@@ -549,7 +618,8 @@ void PressureEqualizer::adjust_volumetric_rate()
|
||||
// Limit by the succeeding volumetric flow rate.
|
||||
rate_end = rate_succ;
|
||||
|
||||
if (!line.adjustable_flow || line.extrusion_role == GCodeExtrusionRole::ExternalPerimeter || line.extrusion_role == GCodeExtrusionRole::GapFill || line.extrusion_role == GCodeExtrusionRole::BridgeInfill || line.extrusion_role == GCodeExtrusionRole::Ironing) {
|
||||
// Don't alter the flow rate for these extrusion types.
|
||||
if (!line.adjustable_flow || line.extrusion_role == GCodeExtrusionRole::BridgeInfill || line.extrusion_role == GCodeExtrusionRole::Ironing) {
|
||||
rate_end = line.volumetric_extrusion_rate_end;
|
||||
} else if (line.volumetric_extrusion_rate_end > rate_end) {
|
||||
line.volumetric_extrusion_rate_end = rate_end;
|
||||
@@ -571,9 +641,8 @@ void PressureEqualizer::adjust_volumetric_rate()
|
||||
line.modified = true;
|
||||
}
|
||||
}
|
||||
// feedrate_per_extrusion_role[iRole] = (iRole == line.extrusion_role) ? line.volumetric_extrusion_rate_start : rate_start;
|
||||
// Don't store feed rate for ironing and gap-fill.
|
||||
if (line.extrusion_role != GCodeExtrusionRole::Ironing && line.extrusion_role != GCodeExtrusionRole::GapFill)
|
||||
// Don't store feed rate for ironing.
|
||||
if (line.extrusion_role != GCodeExtrusionRole::Ironing)
|
||||
feedrate_per_extrusion_role[iRole] = line.volumetric_extrusion_rate_start;
|
||||
}
|
||||
}
|
||||
@@ -587,8 +656,8 @@ void PressureEqualizer::adjust_volumetric_rate()
|
||||
for (; !m_gcode_lines[idx_next].extruding() && idx_next != last_line_idx; ++idx_next);
|
||||
if (!m_gcode_lines[idx_next].extruding())
|
||||
break;
|
||||
// Don't accelerate after ironing and gap-fill.
|
||||
if (m_gcode_lines[line_idx].extrusion_role == GCodeExtrusionRole::Ironing || m_gcode_lines[line_idx].extrusion_role == GCodeExtrusionRole::GapFill) {
|
||||
// Don't accelerate after ironing.
|
||||
if (m_gcode_lines[line_idx].extrusion_role == GCodeExtrusionRole::Ironing) {
|
||||
line_idx = idx_next;
|
||||
continue;
|
||||
}
|
||||
@@ -603,7 +672,8 @@ void PressureEqualizer::adjust_volumetric_rate()
|
||||
continue; // The positive rate is unlimited or the rate for GCodeExtrusionRole iRole is unlimited.
|
||||
|
||||
float rate_start = feedrate_per_extrusion_role[iRole];
|
||||
if (!line.adjustable_flow || line.extrusion_role == GCodeExtrusionRole::ExternalPerimeter || line.extrusion_role == GCodeExtrusionRole::GapFill || line.extrusion_role == GCodeExtrusionRole::BridgeInfill || line.extrusion_role == GCodeExtrusionRole::Ironing) {
|
||||
// Don't alter the flow rate for these extrusion types.
|
||||
if (!line.adjustable_flow || line.extrusion_role == GCodeExtrusionRole::BridgeInfill || line.extrusion_role == GCodeExtrusionRole::Ironing) {
|
||||
rate_start = line.volumetric_extrusion_rate_start;
|
||||
} else if (iRole == size_t(line.extrusion_role) && rate_prec < rate_start)
|
||||
rate_start = rate_prec;
|
||||
@@ -627,9 +697,8 @@ void PressureEqualizer::adjust_volumetric_rate()
|
||||
line.modified = true;
|
||||
}
|
||||
}
|
||||
// feedrate_per_extrusion_role[iRole] = (iRole == line.extrusion_role) ? line.volumetric_extrusion_rate_end : rate_end;
|
||||
// Don't store feed rate for ironing and gap-fill.
|
||||
if (line.extrusion_role != GCodeExtrusionRole::Ironing && line.extrusion_role != GCodeExtrusionRole::GapFill)
|
||||
// Don't store feed rate for ironing
|
||||
if (line.extrusion_role != GCodeExtrusionRole::Ironing)
|
||||
feedrate_per_extrusion_role[iRole] = line.volumetric_extrusion_rate_end;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,6 +169,8 @@ private:
|
||||
bool extrude_end_tag = false;
|
||||
};
|
||||
|
||||
using GCodeLines = std::vector<GCodeLine>;
|
||||
using GCodeLinesConstIt = GCodeLines::const_iterator;
|
||||
// Output buffer will only grow. It will not be reallocated over and over.
|
||||
std::vector<char> output_buffer;
|
||||
size_t output_buffer_length;
|
||||
@@ -182,9 +184,10 @@ private:
|
||||
bool process_line(const char *line, const char *line_end, GCodeLine &buf);
|
||||
void output_gcode_line(size_t line_idx);
|
||||
|
||||
GCodeLinesConstIt advance_segment_beyond_small_gap(const GCodeLinesConstIt &last_extruding_line_it) const;
|
||||
// Go back from the current circular_buffer_pos and lower the feedtrate to decrease the slope of the extrusion rate changes.
|
||||
// Then go forward and adjust the feedrate to decrease the slope of the extrusion rate changes.
|
||||
void adjust_volumetric_rate();
|
||||
void adjust_volumetric_rate(size_t first_line_idx, size_t last_line_idx);
|
||||
|
||||
// Push the text to the end of the output_buffer.
|
||||
inline void push_to_output(GCodeG1Formatter &formatter);
|
||||
|
||||