Fix JPEG texture imports and filament-matching crash (#16607)

Co-authored-by: RF47 <162915171+RF47@users.noreply.github.com>
This commit is contained in:
Robert J AudasandRF47 authored and GitHub committed 2026-10-19 20:30:03 -03:00
1 parent f64beb4379
commit 90a5a0b964
16 files changed
+1181 -3

No files matched your search

+5 -2
View File
@@ -26,6 +26,7 @@ orcaslicer_add_cmake_project(OpenCV
URL https://github.com/opencv/opencv/archive/refs/tags/4.6.0.tar.gz
URL_HASH SHA256=1ec1cba65f9f20fe5a41fda1586e01c70ea0c9a6d7b67c9e13edf0cfe2239277
PATCH_COMMAND git apply ${OpenCV_DIRECTORY_FLAG} --verbose --ignore-space-change --whitespace=fix ${CMAKE_CURRENT_LIST_DIR}/0001-vs.patch ${CMAKE_CURRENT_LIST_DIR}/0002-clang19-macos.patch
DEPENDS ${JPEG_PKG}
CMAKE_ARGS
-DBUILD_SHARED_LIBS=0
-DBUILD_PERE_TESTS=OFF
@@ -34,7 +35,8 @@ orcaslicer_add_cmake_project(OpenCV
-DBUILD_EXAMPLES=OFF
-DBUILD_JASPER=OFF
-DBUILD_JAVA=OFF
-DBUILD_JPEG=ON
# Share Orca's libjpeg to avoid conflicting codec symbols in the application.
-DBUILD_JPEG=OFF
-DBUILD_APPS_LIST=version
-DBUILD_opencv_apps=OFF
-DBUILD_opencv_java=OFF
@@ -67,7 +69,8 @@ orcaslicer_add_cmake_project(OpenCV
-DWITH_OPENJPEG=OFF
-DWITH_QUIRC=OFF
-DWITH_VTK=OFF
-DWITH_JPEG=OFF
# Textured GLB/OBJ imports decode embedded and external JPEGs with cv::imdecode.
-DWITH_JPEG=ON
-DWITH_WEBP=OFF
-DWITH_TIFF=OFF
-DBUILD_TIFF=OFF
+3
View File
@@ -666,6 +666,9 @@ endif ()
encoding_check(libslic3r)
target_compile_definitions(libslic3r PUBLIC -DUSE_TBB -DTBB_USE_CAPTURED_EXCEPTION=0)
# CGAL changes Kd_tree's member layout when TBB is enabled. Match libslic3r_cgal
# in every consumer so inline constructors/destructors cannot mix the two layouts.
target_compile_definitions(libslic3r PUBLIC CGAL_LINKED_WITH_TBB)
if (USE_SLIC3R_CONSOLE_LOG)
target_compile_definitions(libslic3r PRIVATE $<$<CONFIG:RelWithDebInfo>:SLIC3R_CONSOLE_LOG>)
endif()
+1 -1
View File
@@ -18677,7 +18677,7 @@ void ProjectDropDialog::on_dpi_changed(const wxRect& suggested_rect)
//BBS: remove GCodeViewer as seperate APP logic
bool Plater::load_files(const wxArrayString& filenames)
{
const std::regex pattern_drop(".*[.](stp|step|stl|oltp|obj|amf|3mf|svg|zip|drc)", std::regex::icase);
const std::regex pattern_drop(".*[.](stp|step|stl|oltp|obj|amf|3mf|svg|zip|drc|glb|gltf|fbx)", std::regex::icase);
const std::regex pattern_gcode_drop(".*[.](gcode|g)", std::regex::icase);
std::vector<fs::path> normal_paths;
+20
View File
@@ -0,0 +1,20 @@
`two_color_jpeg.glb` is a generated, closed tetrahedron with four faces, UVs, and
an embedded 8×8 red/blue JPEG base-color texture. Its coordinates span 20 mm.
The core tests load all three fixtures through `Model::read_from_file`, convert
textures or MTL colors to painting with boundary smoothing, and match red and blue
to filaments. They run in CI without a display. A separate layout check compares
the smoothing search-tree type seen by a core consumer with the same type compiled
inside `libslic3r_cgal`. The mismatch is checked directly because undefined behavior
can be masked by which inline template implementations the linker selects.
`two_color_sphere/test_two_color_sphere.obj` and its matching MTL are the original
red/blue material-color sphere supplied by RF47 in
[the PR discussion](https://github.com/OrcaSlicer/OrcaSlicer/pull/16607#issuecomment-6244475095).
They contain solid `Kd` colors and no texture images.
`test_two_color_sphere_textured.obj` is a derived version of that sphere. Its MTL
uses white `Kd` values and references `textures/two_color.jpg` by a relative path;
the two face groups sample different halves of that image through their UVs.
The JPEG is extracted unchanged from `two_color_jpeg.glb`. This case must retain
both colors from the external texture, rather than fall back to MTL colors.
Binary file not shown.
@@ -0,0 +1,11 @@
# test model for OrcaSlicer tex2color
newmtl Red
Ka 0.0000 0.0000 0.0000
Kd 0.7500 0.2500 0.2500
Ks 0.0000 0.0000 0.0000
d 1.0000
newmtl Blue
Ka 0.0000 0.0000 0.0000
Kd 0.0700 0.2100 0.7000
Ks 0.0000 0.0000 0.0000
d 1.0000
@@ -0,0 +1,457 @@
# test model for OrcaSlicer tex2color
mtllib test_two_color_sphere.mtl
v 0.000000 0.000000 20.000000
v 7.653669 0.000000 18.477591
v 7.071068 2.928932 18.477591
v 5.411961 5.411961 18.477591
v 2.928932 7.071068 18.477591
v 0.000000 7.653669 18.477591
v -2.928932 7.071068 18.477591
v -5.411961 5.411961 18.477591
v -7.071068 2.928932 18.477591
v -7.653669 0.000000 18.477591
v -7.071068 -2.928932 18.477591
v -5.411961 -5.411961 18.477591
v -2.928932 -7.071068 18.477591
v -0.000000 -7.653669 18.477591
v 2.928932 -7.071068 18.477591
v 5.411961 -5.411961 18.477591
v 7.071068 -2.928932 18.477591
v 14.142136 0.000000 14.142136
v 13.065630 5.411961 14.142136
v 10.000000 10.000000 14.142136
v 5.411961 13.065630 14.142136
v 0.000000 14.142136 14.142136
v -5.411961 13.065630 14.142136
v -10.000000 10.000000 14.142136
v -13.065630 5.411961 14.142136
v -14.142136 0.000000 14.142136
v -13.065630 -5.411961 14.142136
v -10.000000 -10.000000 14.142136
v -5.411961 -13.065630 14.142136
v -0.000000 -14.142136 14.142136
v 5.411961 -13.065630 14.142136
v 10.000000 -10.000000 14.142136
v 13.065630 -5.411961 14.142136
v 18.477591 0.000000 7.653669
v 17.071068 7.071068 7.653669
v 13.065630 13.065630 7.653669
v 7.071068 17.071068 7.653669
v 0.000000 18.477591 7.653669
v -7.071068 17.071068 7.653669
v -13.065630 13.065630 7.653669
v -17.071068 7.071068 7.653669
v -18.477591 0.000000 7.653669
v -17.071068 -7.071068 7.653669
v -13.065630 -13.065630 7.653669
v -7.071068 -17.071068 7.653669
v -0.000000 -18.477591 7.653669
v 7.071068 -17.071068 7.653669
v 13.065630 -13.065630 7.653669
v 17.071068 -7.071068 7.653669
v 20.000000 0.000000 0.000000
v 18.477591 7.653669 0.000000
v 14.142136 14.142136 0.000000
v 7.653669 18.477591 0.000000
v 0.000000 20.000000 0.000000
v -7.653669 18.477591 0.000000
v -14.142136 14.142136 0.000000
v -18.477591 7.653669 0.000000
v -20.000000 0.000000 0.000000
v -18.477591 -7.653669 0.000000
v -14.142136 -14.142136 0.000000
v -7.653669 -18.477591 0.000000
v -0.000000 -20.000000 0.000000
v 7.653669 -18.477591 0.000000
v 14.142136 -14.142136 0.000000
v 18.477591 -7.653669 0.000000
v 18.477591 0.000000 -7.653669
v 17.071068 7.071068 -7.653669
v 13.065630 13.065630 -7.653669
v 7.071068 17.071068 -7.653669
v 0.000000 18.477591 -7.653669
v -7.071068 17.071068 -7.653669
v -13.065630 13.065630 -7.653669
v -17.071068 7.071068 -7.653669
v -18.477591 0.000000 -7.653669
v -17.071068 -7.071068 -7.653669
v -13.065630 -13.065630 -7.653669
v -7.071068 -17.071068 -7.653669
v -0.000000 -18.477591 -7.653669
v 7.071068 -17.071068 -7.653669
v 13.065630 -13.065630 -7.653669
v 17.071068 -7.071068 -7.653669
v 14.142136 0.000000 -14.142136
v 13.065630 5.411961 -14.142136
v 10.000000 10.000000 -14.142136
v 5.411961 13.065630 -14.142136
v 0.000000 14.142136 -14.142136
v -5.411961 13.065630 -14.142136
v -10.000000 10.000000 -14.142136
v -13.065630 5.411961 -14.142136
v -14.142136 0.000000 -14.142136
v -13.065630 -5.411961 -14.142136
v -10.000000 -10.000000 -14.142136
v -5.411961 -13.065630 -14.142136
v -0.000000 -14.142136 -14.142136
v 5.411961 -13.065630 -14.142136
v 10.000000 -10.000000 -14.142136
v 13.065630 -5.411961 -14.142136
v 7.653669 0.000000 -18.477591
v 7.071068 2.928932 -18.477591
v 5.411961 5.411961 -18.477591
v 2.928932 7.071068 -18.477591
v 0.000000 7.653669 -18.477591
v -2.928932 7.071068 -18.477591
v -5.411961 5.411961 -18.477591
v -7.071068 2.928932 -18.477591
v -7.653669 0.000000 -18.477591
v -7.071068 -2.928932 -18.477591
v -5.411961 -5.411961 -18.477591
v -2.928932 -7.071068 -18.477591
v -0.000000 -7.653669 -18.477591
v 2.928932 -7.071068 -18.477591
v 5.411961 -5.411961 -18.477591
v 7.071068 -2.928932 -18.477591
v 0.000000 0.000000 -20.000000
vt 0 0
vn 0.000000 -0.000000 1.000000
vn 0.439605 0.035510 0.897489
vn 0.392553 0.201037 0.897489
vn 0.285739 0.335958 0.897489
vn 0.135423 0.419732 0.897489
vn -0.035510 0.439605 0.897489
vn -0.201037 0.392553 0.897489
vn -0.335958 0.285739 0.897489
vn -0.419732 0.135423 0.897489
vn -0.439605 -0.035510 0.897489
vn -0.392553 -0.201037 0.897489
vn -0.285739 -0.335958 0.897489
vn -0.135423 -0.419732 0.897489
vn 0.035510 -0.439605 0.897489
vn 0.201037 -0.392553 0.897489
vn 0.335958 -0.285739 0.897489
vn 0.419732 -0.135423 0.897489
vn 0.725001 0.027230 0.688209
vn 0.659393 0.302603 0.688209
vn 0.493399 0.531907 0.688209
vn 0.252289 0.680234 0.688209
vn -0.027230 0.725001 0.688209
vn -0.302603 0.659393 0.688209
vn -0.531907 0.493399 0.688209
vn -0.680234 0.252289 0.688209
vn -0.725001 -0.027230 0.688209
vn -0.659393 -0.302603 0.688209
vn -0.493399 -0.531907 0.688209
vn -0.252289 -0.680234 0.688209
vn 0.027230 -0.725001 0.688209
vn 0.302603 -0.659393 0.688209
vn 0.531907 -0.493399 0.688209
vn 0.680234 -0.252289 0.688209
vn 0.927851 0.014745 0.372658
vn 0.851580 0.368696 0.372658
vn 0.645664 0.666516 0.372658
vn 0.341451 0.862865 0.372658
vn -0.014745 0.927851 0.372658
vn -0.368696 0.851580 0.372658
vn -0.666516 0.645664 0.372658
vn -0.862865 0.341451 0.372658
vn -0.927851 -0.014745 0.372658
vn -0.851580 -0.368696 0.372658
vn -0.645664 -0.666516 0.372658
vn -0.341451 -0.862865 0.372658
vn 0.014745 -0.927851 0.372658
vn 0.368696 -0.851580 0.372658
vn 0.666516 -0.645664 0.372658
vn 0.862865 -0.341451 0.372658
vn 1.000000 -0.000000 -0.000000
vn 0.923880 0.382683 0.000000
vn 0.707107 0.707107 0.000000
vn 0.382683 0.923880 0.000000
vn 0.000000 1.000000 0.000000
vn -0.382683 0.923880 0.000000
vn -0.707107 0.707107 0.000000
vn -0.923880 0.382683 0.000000
vn -1.000000 0.000000 0.000000
vn -0.923880 -0.382683 -0.000000
vn -0.707107 -0.707107 0.000000
vn -0.382683 -0.923880 -0.000000
vn -0.000000 -1.000000 -0.000000
vn 0.382683 -0.923880 0.000000
vn 0.707107 -0.707107 0.000000
vn 0.923880 -0.382683 -0.000000
vn 0.927851 -0.014745 -0.372658
vn 0.862865 0.341451 -0.372658
vn 0.666516 0.645664 -0.372658
vn 0.368696 0.851580 -0.372658
vn 0.014745 0.927851 -0.372658
vn -0.341451 0.862865 -0.372658
vn -0.645664 0.666516 -0.372658
vn -0.851580 0.368696 -0.372658
vn -0.927851 0.014745 -0.372658
vn -0.862865 -0.341451 -0.372658
vn -0.666516 -0.645664 -0.372658
vn -0.368696 -0.851580 -0.372658
vn -0.014745 -0.927851 -0.372658
vn 0.341451 -0.862865 -0.372658
vn 0.645664 -0.666516 -0.372658
vn 0.851580 -0.368696 -0.372658
vn 0.725001 -0.027230 -0.688209
vn 0.680234 0.252289 -0.688209
vn 0.531907 0.493399 -0.688209
vn 0.302603 0.659393 -0.688209
vn 0.027230 0.725001 -0.688209
vn -0.252289 0.680234 -0.688209
vn -0.493399 0.531907 -0.688209
vn -0.659393 0.302603 -0.688209
vn -0.725001 0.027230 -0.688209
vn -0.680234 -0.252289 -0.688209
vn -0.531907 -0.493399 -0.688209
vn -0.302603 -0.659393 -0.688209
vn -0.027230 -0.725001 -0.688209
vn 0.252289 -0.680234 -0.688209
vn 0.493399 -0.531907 -0.688209
vn 0.659393 -0.302603 -0.688209
vn 0.439605 -0.035510 -0.897489
vn 0.419732 0.135423 -0.897489
vn 0.335958 0.285739 -0.897489
vn 0.201037 0.392553 -0.897489
vn 0.035510 0.439605 -0.897489
vn -0.135423 0.419732 -0.897489
vn -0.285739 0.335958 -0.897489
vn -0.392553 0.201037 -0.897489
vn -0.439605 0.035510 -0.897489
vn -0.419732 -0.135423 -0.897489
vn -0.335958 -0.285739 -0.897489
vn -0.201037 -0.392553 -0.897489
vn -0.035510 -0.439605 -0.897489
vn 0.135423 -0.419732 -0.897489
vn 0.285739 -0.335958 -0.897489
vn 0.392553 -0.201037 -0.897489
vn 0.000000 -0.000000 -1.000000
usemtl Red
f 1/1/1 2/1/2 3/1/3
f 1/1/1 3/1/3 4/1/4
f 1/1/1 4/1/4 5/1/5
f 1/1/1 5/1/5 6/1/6
f 1/1/1 6/1/6 7/1/7
f 1/1/1 7/1/7 8/1/8
f 1/1/1 8/1/8 9/1/9
f 1/1/1 9/1/9 10/1/10
f 1/1/1 10/1/10 11/1/11
f 1/1/1 11/1/11 12/1/12
f 1/1/1 12/1/12 13/1/13
f 1/1/1 13/1/13 14/1/14
f 1/1/1 14/1/14 15/1/15
f 1/1/1 15/1/15 16/1/16
f 1/1/1 16/1/16 17/1/17
f 1/1/1 17/1/17 2/1/2
f 2/1/2 18/1/18 19/1/19
f 2/1/2 19/1/19 3/1/3
f 3/1/3 19/1/19 20/1/20
f 3/1/3 20/1/20 4/1/4
f 4/1/4 20/1/20 21/1/21
f 4/1/4 21/1/21 5/1/5
f 5/1/5 21/1/21 22/1/22
f 5/1/5 22/1/22 6/1/6
f 6/1/6 22/1/22 23/1/23
f 6/1/6 23/1/23 7/1/7
f 7/1/7 23/1/23 24/1/24
f 7/1/7 24/1/24 8/1/8
f 8/1/8 24/1/24 25/1/25
f 8/1/8 25/1/25 9/1/9
f 9/1/9 25/1/25 26/1/26
f 9/1/9 26/1/26 10/1/10
f 10/1/10 26/1/26 27/1/27
f 10/1/10 27/1/27 11/1/11
f 11/1/11 27/1/27 28/1/28
f 11/1/11 28/1/28 12/1/12
f 12/1/12 28/1/28 29/1/29
f 12/1/12 29/1/29 13/1/13
f 13/1/13 29/1/29 30/1/30
f 13/1/13 30/1/30 14/1/14
f 14/1/14 30/1/30 31/1/31
f 14/1/14 31/1/31 15/1/15
f 15/1/15 31/1/31 32/1/32
f 15/1/15 32/1/32 16/1/16
f 16/1/16 32/1/32 33/1/33
f 16/1/16 33/1/33 17/1/17
f 17/1/17 33/1/33 18/1/18
f 17/1/17 18/1/18 2/1/2
f 18/1/18 34/1/34 35/1/35
f 18/1/18 35/1/35 19/1/19
f 19/1/19 35/1/35 36/1/36
f 19/1/19 36/1/36 20/1/20
f 20/1/20 36/1/36 37/1/37
f 20/1/20 37/1/37 21/1/21
f 21/1/21 37/1/37 38/1/38
f 21/1/21 38/1/38 22/1/22
f 22/1/22 38/1/38 39/1/39
f 22/1/22 39/1/39 23/1/23
f 23/1/23 39/1/39 40/1/40
f 23/1/23 40/1/40 24/1/24
f 24/1/24 40/1/40 41/1/41
f 24/1/24 41/1/41 25/1/25
f 25/1/25 41/1/41 42/1/42
f 25/1/25 42/1/42 26/1/26
f 26/1/26 42/1/42 43/1/43
f 26/1/26 43/1/43 27/1/27
f 27/1/27 43/1/43 44/1/44
f 27/1/27 44/1/44 28/1/28
f 28/1/28 44/1/44 45/1/45
f 28/1/28 45/1/45 29/1/29
f 29/1/29 45/1/45 46/1/46
f 29/1/29 46/1/46 30/1/30
f 30/1/30 46/1/46 47/1/47
f 30/1/30 47/1/47 31/1/31
f 31/1/31 47/1/47 48/1/48
f 31/1/31 48/1/48 32/1/32
f 32/1/32 48/1/48 49/1/49
f 32/1/32 49/1/49 33/1/33
f 33/1/33 49/1/49 34/1/34
f 33/1/33 34/1/34 18/1/18
f 34/1/34 50/1/50 51/1/51
f 34/1/34 51/1/51 35/1/35
f 35/1/35 51/1/51 52/1/52
f 35/1/35 52/1/52 36/1/36
f 36/1/36 52/1/52 53/1/53
f 36/1/36 53/1/53 37/1/37
f 37/1/37 53/1/53 54/1/54
f 37/1/37 54/1/54 38/1/38
f 38/1/38 54/1/54 55/1/55
f 38/1/38 55/1/55 39/1/39
f 39/1/39 55/1/55 56/1/56
f 39/1/39 56/1/56 40/1/40
f 40/1/40 56/1/56 57/1/57
f 40/1/40 57/1/57 41/1/41
f 41/1/41 57/1/57 58/1/58
f 41/1/41 58/1/58 42/1/42
f 42/1/42 58/1/58 59/1/59
f 42/1/42 59/1/59 43/1/43
f 43/1/43 59/1/59 60/1/60
f 43/1/43 60/1/60 44/1/44
f 44/1/44 60/1/60 61/1/61
f 44/1/44 61/1/61 45/1/45
f 45/1/45 61/1/61 62/1/62
f 45/1/45 62/1/62 46/1/46
f 46/1/46 62/1/62 63/1/63
f 46/1/46 63/1/63 47/1/47
f 47/1/47 63/1/63 64/1/64
f 47/1/47 64/1/64 48/1/48
f 48/1/48 64/1/64 65/1/65
f 48/1/48 65/1/65 49/1/49
f 49/1/49 65/1/65 50/1/50
f 49/1/49 50/1/50 34/1/34
usemtl Blue
f 50/1/50 66/1/66 67/1/67
f 50/1/50 67/1/67 51/1/51
f 51/1/51 67/1/67 68/1/68
f 51/1/51 68/1/68 52/1/52
f 52/1/52 68/1/68 69/1/69
f 52/1/52 69/1/69 53/1/53
f 53/1/53 69/1/69 70/1/70
f 53/1/53 70/1/70 54/1/54
f 54/1/54 70/1/70 71/1/71
f 54/1/54 71/1/71 55/1/55
f 55/1/55 71/1/71 72/1/72
f 55/1/55 72/1/72 56/1/56
f 56/1/56 72/1/72 73/1/73
f 56/1/56 73/1/73 57/1/57
f 57/1/57 73/1/73 74/1/74
f 57/1/57 74/1/74 58/1/58
f 58/1/58 74/1/74 75/1/75
f 58/1/58 75/1/75 59/1/59
f 59/1/59 75/1/75 76/1/76
f 59/1/59 76/1/76 60/1/60
f 60/1/60 76/1/76 77/1/77
f 60/1/60 77/1/77 61/1/61
f 61/1/61 77/1/77 78/1/78
f 61/1/61 78/1/78 62/1/62
f 62/1/62 78/1/78 79/1/79
f 62/1/62 79/1/79 63/1/63
f 63/1/63 79/1/79 80/1/80
f 63/1/63 80/1/80 64/1/64
f 64/1/64 80/1/80 81/1/81
f 64/1/64 81/1/81 65/1/65
f 65/1/65 81/1/81 66/1/66
f 65/1/65 66/1/66 50/1/50
f 66/1/66 82/1/82 83/1/83
f 66/1/66 83/1/83 67/1/67
f 67/1/67 83/1/83 84/1/84
f 67/1/67 84/1/84 68/1/68
f 68/1/68 84/1/84 85/1/85
f 68/1/68 85/1/85 69/1/69
f 69/1/69 85/1/85 86/1/86
f 69/1/69 86/1/86 70/1/70
f 70/1/70 86/1/86 87/1/87
f 70/1/70 87/1/87 71/1/71
f 71/1/71 87/1/87 88/1/88
f 71/1/71 88/1/88 72/1/72
f 72/1/72 88/1/88 89/1/89
f 72/1/72 89/1/89 73/1/73
f 73/1/73 89/1/89 90/1/90
f 73/1/73 90/1/90 74/1/74
f 74/1/74 90/1/90 91/1/91
f 74/1/74 91/1/91 75/1/75
f 75/1/75 91/1/91 92/1/92
f 75/1/75 92/1/92 76/1/76
f 76/1/76 92/1/92 93/1/93
f 76/1/76 93/1/93 77/1/77
f 77/1/77 93/1/93 94/1/94
f 77/1/77 94/1/94 78/1/78
f 78/1/78 94/1/94 95/1/95
f 78/1/78 95/1/95 79/1/79
f 79/1/79 95/1/95 96/1/96
f 79/1/79 96/1/96 80/1/80
f 80/1/80 96/1/96 97/1/97
f 80/1/80 97/1/97 81/1/81
f 81/1/81 97/1/97 82/1/82
f 81/1/81 82/1/82 66/1/66
f 82/1/82 98/1/98 99/1/99
f 82/1/82 99/1/99 83/1/83
f 83/1/83 99/1/99 100/1/100
f 83/1/83 100/1/100 84/1/84
f 84/1/84 100/1/100 101/1/101
f 84/1/84 101/1/101 85/1/85
f 85/1/85 101/1/101 102/1/102
f 85/1/85 102/1/102 86/1/86
f 86/1/86 102/1/102 103/1/103
f 86/1/86 103/1/103 87/1/87
f 87/1/87 103/1/103 104/1/104
f 87/1/87 104/1/104 88/1/88
f 88/1/88 104/1/104 105/1/105
f 88/1/88 105/1/105 89/1/89
f 89/1/89 105/1/105 106/1/106
f 89/1/89 106/1/106 90/1/90
f 90/1/90 106/1/106 107/1/107
f 90/1/90 107/1/107 91/1/91
f 91/1/91 107/1/107 108/1/108
f 91/1/91 108/1/108 92/1/92
f 92/1/92 108/1/108 109/1/109
f 92/1/92 109/1/109 93/1/93
f 93/1/93 109/1/109 110/1/110
f 93/1/93 110/1/110 94/1/94
f 94/1/94 110/1/110 111/1/111
f 94/1/94 111/1/111 95/1/95
f 95/1/95 111/1/111 112/1/112
f 95/1/95 112/1/112 96/1/96
f 96/1/96 112/1/112 113/1/113
f 96/1/96 113/1/113 97/1/97
f 97/1/97 113/1/113 98/1/98
f 97/1/97 98/1/98 82/1/82
f 114/1/114 99/1/99 98/1/98
f 114/1/114 100/1/100 99/1/99
f 114/1/114 101/1/101 100/1/100
f 114/1/114 102/1/102 101/1/101
f 114/1/114 103/1/103 102/1/102
f 114/1/114 104/1/104 103/1/103
f 114/1/114 105/1/105 104/1/104
f 114/1/114 106/1/106 105/1/105
f 114/1/114 107/1/107 106/1/106
f 114/1/114 108/1/108 107/1/107
f 114/1/114 109/1/109 108/1/108
f 114/1/114 110/1/110 109/1/109
f 114/1/114 111/1/111 110/1/110
f 114/1/114 112/1/112 111/1/111
f 114/1/114 113/1/113 112/1/112
f 114/1/114 98/1/98 113/1/113
@@ -0,0 +1,8 @@
# Derived texture-file regression: color comes from map_Kd, not Kd.
newmtl Red
Kd 1 1 1
map_Kd textures/two_color.jpg
newmtl Blue
Kd 1 1 1
map_Kd textures/two_color.jpg
@@ -0,0 +1,458 @@
# test model for OrcaSlicer tex2color
mtllib test_two_color_sphere_textured.mtl
v 0.000000 0.000000 20.000000
v 7.653669 0.000000 18.477591
v 7.071068 2.928932 18.477591
v 5.411961 5.411961 18.477591
v 2.928932 7.071068 18.477591
v 0.000000 7.653669 18.477591
v -2.928932 7.071068 18.477591
v -5.411961 5.411961 18.477591
v -7.071068 2.928932 18.477591
v -7.653669 0.000000 18.477591
v -7.071068 -2.928932 18.477591
v -5.411961 -5.411961 18.477591
v -2.928932 -7.071068 18.477591
v -0.000000 -7.653669 18.477591
v 2.928932 -7.071068 18.477591
v 5.411961 -5.411961 18.477591
v 7.071068 -2.928932 18.477591
v 14.142136 0.000000 14.142136
v 13.065630 5.411961 14.142136
v 10.000000 10.000000 14.142136
v 5.411961 13.065630 14.142136
v 0.000000 14.142136 14.142136
v -5.411961 13.065630 14.142136
v -10.000000 10.000000 14.142136
v -13.065630 5.411961 14.142136
v -14.142136 0.000000 14.142136
v -13.065630 -5.411961 14.142136
v -10.000000 -10.000000 14.142136
v -5.411961 -13.065630 14.142136
v -0.000000 -14.142136 14.142136
v 5.411961 -13.065630 14.142136
v 10.000000 -10.000000 14.142136
v 13.065630 -5.411961 14.142136
v 18.477591 0.000000 7.653669
v 17.071068 7.071068 7.653669
v 13.065630 13.065630 7.653669
v 7.071068 17.071068 7.653669
v 0.000000 18.477591 7.653669
v -7.071068 17.071068 7.653669
v -13.065630 13.065630 7.653669
v -17.071068 7.071068 7.653669
v -18.477591 0.000000 7.653669
v -17.071068 -7.071068 7.653669
v -13.065630 -13.065630 7.653669
v -7.071068 -17.071068 7.653669
v -0.000000 -18.477591 7.653669
v 7.071068 -17.071068 7.653669
v 13.065630 -13.065630 7.653669
v 17.071068 -7.071068 7.653669
v 20.000000 0.000000 0.000000
v 18.477591 7.653669 0.000000
v 14.142136 14.142136 0.000000
v 7.653669 18.477591 0.000000
v 0.000000 20.000000 0.000000
v -7.653669 18.477591 0.000000
v -14.142136 14.142136 0.000000
v -18.477591 7.653669 0.000000
v -20.000000 0.000000 0.000000
v -18.477591 -7.653669 0.000000
v -14.142136 -14.142136 0.000000
v -7.653669 -18.477591 0.000000
v -0.000000 -20.000000 0.000000
v 7.653669 -18.477591 0.000000
v 14.142136 -14.142136 0.000000
v 18.477591 -7.653669 0.000000
v 18.477591 0.000000 -7.653669
v 17.071068 7.071068 -7.653669
v 13.065630 13.065630 -7.653669
v 7.071068 17.071068 -7.653669
v 0.000000 18.477591 -7.653669
v -7.071068 17.071068 -7.653669
v -13.065630 13.065630 -7.653669
v -17.071068 7.071068 -7.653669
v -18.477591 0.000000 -7.653669
v -17.071068 -7.071068 -7.653669
v -13.065630 -13.065630 -7.653669
v -7.071068 -17.071068 -7.653669
v -0.000000 -18.477591 -7.653669
v 7.071068 -17.071068 -7.653669
v 13.065630 -13.065630 -7.653669
v 17.071068 -7.071068 -7.653669
v 14.142136 0.000000 -14.142136
v 13.065630 5.411961 -14.142136
v 10.000000 10.000000 -14.142136
v 5.411961 13.065630 -14.142136
v 0.000000 14.142136 -14.142136
v -5.411961 13.065630 -14.142136
v -10.000000 10.000000 -14.142136
v -13.065630 5.411961 -14.142136
v -14.142136 0.000000 -14.142136
v -13.065630 -5.411961 -14.142136
v -10.000000 -10.000000 -14.142136
v -5.411961 -13.065630 -14.142136
v -0.000000 -14.142136 -14.142136
v 5.411961 -13.065630 -14.142136
v 10.000000 -10.000000 -14.142136
v 13.065630 -5.411961 -14.142136
v 7.653669 0.000000 -18.477591
v 7.071068 2.928932 -18.477591
v 5.411961 5.411961 -18.477591
v 2.928932 7.071068 -18.477591
v 0.000000 7.653669 -18.477591
v -2.928932 7.071068 -18.477591
v -5.411961 5.411961 -18.477591
v -7.071068 2.928932 -18.477591
v -7.653669 0.000000 -18.477591
v -7.071068 -2.928932 -18.477591
v -5.411961 -5.411961 -18.477591
v -2.928932 -7.071068 -18.477591
v -0.000000 -7.653669 -18.477591
v 2.928932 -7.071068 -18.477591
v 5.411961 -5.411961 -18.477591
v 7.071068 -2.928932 -18.477591
v 0.000000 0.000000 -20.000000
vt 0.25 0.5
vt 0.75 0.5
vn 0.000000 -0.000000 1.000000
vn 0.439605 0.035510 0.897489
vn 0.392553 0.201037 0.897489
vn 0.285739 0.335958 0.897489
vn 0.135423 0.419732 0.897489
vn -0.035510 0.439605 0.897489
vn -0.201037 0.392553 0.897489
vn -0.335958 0.285739 0.897489
vn -0.419732 0.135423 0.897489
vn -0.439605 -0.035510 0.897489
vn -0.392553 -0.201037 0.897489
vn -0.285739 -0.335958 0.897489
vn -0.135423 -0.419732 0.897489
vn 0.035510 -0.439605 0.897489
vn 0.201037 -0.392553 0.897489
vn 0.335958 -0.285739 0.897489
vn 0.419732 -0.135423 0.897489
vn 0.725001 0.027230 0.688209
vn 0.659393 0.302603 0.688209
vn 0.493399 0.531907 0.688209
vn 0.252289 0.680234 0.688209
vn -0.027230 0.725001 0.688209
vn -0.302603 0.659393 0.688209
vn -0.531907 0.493399 0.688209
vn -0.680234 0.252289 0.688209
vn -0.725001 -0.027230 0.688209
vn -0.659393 -0.302603 0.688209
vn -0.493399 -0.531907 0.688209
vn -0.252289 -0.680234 0.688209
vn 0.027230 -0.725001 0.688209
vn 0.302603 -0.659393 0.688209
vn 0.531907 -0.493399 0.688209
vn 0.680234 -0.252289 0.688209
vn 0.927851 0.014745 0.372658
vn 0.851580 0.368696 0.372658
vn 0.645664 0.666516 0.372658
vn 0.341451 0.862865 0.372658
vn -0.014745 0.927851 0.372658
vn -0.368696 0.851580 0.372658
vn -0.666516 0.645664 0.372658
vn -0.862865 0.341451 0.372658
vn -0.927851 -0.014745 0.372658
vn -0.851580 -0.368696 0.372658
vn -0.645664 -0.666516 0.372658
vn -0.341451 -0.862865 0.372658
vn 0.014745 -0.927851 0.372658
vn 0.368696 -0.851580 0.372658
vn 0.666516 -0.645664 0.372658
vn 0.862865 -0.341451 0.372658
vn 1.000000 -0.000000 -0.000000
vn 0.923880 0.382683 0.000000
vn 0.707107 0.707107 0.000000
vn 0.382683 0.923880 0.000000
vn 0.000000 1.000000 0.000000
vn -0.382683 0.923880 0.000000
vn -0.707107 0.707107 0.000000
vn -0.923880 0.382683 0.000000
vn -1.000000 0.000000 0.000000
vn -0.923880 -0.382683 -0.000000
vn -0.707107 -0.707107 0.000000
vn -0.382683 -0.923880 -0.000000
vn -0.000000 -1.000000 -0.000000
vn 0.382683 -0.923880 0.000000
vn 0.707107 -0.707107 0.000000
vn 0.923880 -0.382683 -0.000000
vn 0.927851 -0.014745 -0.372658
vn 0.862865 0.341451 -0.372658
vn 0.666516 0.645664 -0.372658
vn 0.368696 0.851580 -0.372658
vn 0.014745 0.927851 -0.372658
vn -0.341451 0.862865 -0.372658
vn -0.645664 0.666516 -0.372658
vn -0.851580 0.368696 -0.372658
vn -0.927851 0.014745 -0.372658
vn -0.862865 -0.341451 -0.372658
vn -0.666516 -0.645664 -0.372658
vn -0.368696 -0.851580 -0.372658
vn -0.014745 -0.927851 -0.372658
vn 0.341451 -0.862865 -0.372658
vn 0.645664 -0.666516 -0.372658
vn 0.851580 -0.368696 -0.372658
vn 0.725001 -0.027230 -0.688209
vn 0.680234 0.252289 -0.688209
vn 0.531907 0.493399 -0.688209
vn 0.302603 0.659393 -0.688209
vn 0.027230 0.725001 -0.688209
vn -0.252289 0.680234 -0.688209
vn -0.493399 0.531907 -0.688209
vn -0.659393 0.302603 -0.688209
vn -0.725001 0.027230 -0.688209
vn -0.680234 -0.252289 -0.688209
vn -0.531907 -0.493399 -0.688209
vn -0.302603 -0.659393 -0.688209
vn -0.027230 -0.725001 -0.688209
vn 0.252289 -0.680234 -0.688209
vn 0.493399 -0.531907 -0.688209
vn 0.659393 -0.302603 -0.688209
vn 0.439605 -0.035510 -0.897489
vn 0.419732 0.135423 -0.897489
vn 0.335958 0.285739 -0.897489
vn 0.201037 0.392553 -0.897489
vn 0.035510 0.439605 -0.897489
vn -0.135423 0.419732 -0.897489
vn -0.285739 0.335958 -0.897489
vn -0.392553 0.201037 -0.897489
vn -0.439605 0.035510 -0.897489
vn -0.419732 -0.135423 -0.897489
vn -0.335958 -0.285739 -0.897489
vn -0.201037 -0.392553 -0.897489
vn -0.035510 -0.439605 -0.897489
vn 0.135423 -0.419732 -0.897489
vn 0.285739 -0.335958 -0.897489
vn 0.392553 -0.201037 -0.897489
vn 0.000000 -0.000000 -1.000000
usemtl Red
f 1/1/1 2/1/2 3/1/3
f 1/1/1 3/1/3 4/1/4
f 1/1/1 4/1/4 5/1/5
f 1/1/1 5/1/5 6/1/6
f 1/1/1 6/1/6 7/1/7
f 1/1/1 7/1/7 8/1/8
f 1/1/1 8/1/8 9/1/9
f 1/1/1 9/1/9 10/1/10
f 1/1/1 10/1/10 11/1/11
f 1/1/1 11/1/11 12/1/12
f 1/1/1 12/1/12 13/1/13
f 1/1/1 13/1/13 14/1/14
f 1/1/1 14/1/14 15/1/15
f 1/1/1 15/1/15 16/1/16
f 1/1/1 16/1/16 17/1/17
f 1/1/1 17/1/17 2/1/2
f 2/1/2 18/1/18 19/1/19
f 2/1/2 19/1/19 3/1/3
f 3/1/3 19/1/19 20/1/20
f 3/1/3 20/1/20 4/1/4
f 4/1/4 20/1/20 21/1/21
f 4/1/4 21/1/21 5/1/5
f 5/1/5 21/1/21 22/1/22
f 5/1/5 22/1/22 6/1/6
f 6/1/6 22/1/22 23/1/23
f 6/1/6 23/1/23 7/1/7
f 7/1/7 23/1/23 24/1/24
f 7/1/7 24/1/24 8/1/8
f 8/1/8 24/1/24 25/1/25
f 8/1/8 25/1/25 9/1/9
f 9/1/9 25/1/25 26/1/26
f 9/1/9 26/1/26 10/1/10
f 10/1/10 26/1/26 27/1/27
f 10/1/10 27/1/27 11/1/11
f 11/1/11 27/1/27 28/1/28
f 11/1/11 28/1/28 12/1/12
f 12/1/12 28/1/28 29/1/29
f 12/1/12 29/1/29 13/1/13
f 13/1/13 29/1/29 30/1/30
f 13/1/13 30/1/30 14/1/14
f 14/1/14 30/1/30 31/1/31
f 14/1/14 31/1/31 15/1/15
f 15/1/15 31/1/31 32/1/32
f 15/1/15 32/1/32 16/1/16
f 16/1/16 32/1/32 33/1/33
f 16/1/16 33/1/33 17/1/17
f 17/1/17 33/1/33 18/1/18
f 17/1/17 18/1/18 2/1/2
f 18/1/18 34/1/34 35/1/35
f 18/1/18 35/1/35 19/1/19
f 19/1/19 35/1/35 36/1/36
f 19/1/19 36/1/36 20/1/20
f 20/1/20 36/1/36 37/1/37
f 20/1/20 37/1/37 21/1/21
f 21/1/21 37/1/37 38/1/38
f 21/1/21 38/1/38 22/1/22
f 22/1/22 38/1/38 39/1/39
f 22/1/22 39/1/39 23/1/23
f 23/1/23 39/1/39 40/1/40
f 23/1/23 40/1/40 24/1/24
f 24/1/24 40/1/40 41/1/41
f 24/1/24 41/1/41 25/1/25
f 25/1/25 41/1/41 42/1/42
f 25/1/25 42/1/42 26/1/26
f 26/1/26 42/1/42 43/1/43
f 26/1/26 43/1/43 27/1/27
f 27/1/27 43/1/43 44/1/44
f 27/1/27 44/1/44 28/1/28
f 28/1/28 44/1/44 45/1/45
f 28/1/28 45/1/45 29/1/29
f 29/1/29 45/1/45 46/1/46
f 29/1/29 46/1/46 30/1/30
f 30/1/30 46/1/46 47/1/47
f 30/1/30 47/1/47 31/1/31
f 31/1/31 47/1/47 48/1/48
f 31/1/31 48/1/48 32/1/32
f 32/1/32 48/1/48 49/1/49
f 32/1/32 49/1/49 33/1/33
f 33/1/33 49/1/49 34/1/34
f 33/1/33 34/1/34 18/1/18
f 34/1/34 50/1/50 51/1/51
f 34/1/34 51/1/51 35/1/35
f 35/1/35 51/1/51 52/1/52
f 35/1/35 52/1/52 36/1/36
f 36/1/36 52/1/52 53/1/53
f 36/1/36 53/1/53 37/1/37
f 37/1/37 53/1/53 54/1/54
f 37/1/37 54/1/54 38/1/38
f 38/1/38 54/1/54 55/1/55
f 38/1/38 55/1/55 39/1/39
f 39/1/39 55/1/55 56/1/56
f 39/1/39 56/1/56 40/1/40
f 40/1/40 56/1/56 57/1/57
f 40/1/40 57/1/57 41/1/41
f 41/1/41 57/1/57 58/1/58
f 41/1/41 58/1/58 42/1/42
f 42/1/42 58/1/58 59/1/59
f 42/1/42 59/1/59 43/1/43
f 43/1/43 59/1/59 60/1/60
f 43/1/43 60/1/60 44/1/44
f 44/1/44 60/1/60 61/1/61
f 44/1/44 61/1/61 45/1/45
f 45/1/45 61/1/61 62/1/62
f 45/1/45 62/1/62 46/1/46
f 46/1/46 62/1/62 63/1/63
f 46/1/46 63/1/63 47/1/47
f 47/1/47 63/1/63 64/1/64
f 47/1/47 64/1/64 48/1/48
f 48/1/48 64/1/64 65/1/65
f 48/1/48 65/1/65 49/1/49
f 49/1/49 65/1/65 50/1/50
f 49/1/49 50/1/50 34/1/34
usemtl Blue
f 50/2/50 66/2/66 67/2/67
f 50/2/50 67/2/67 51/2/51
f 51/2/51 67/2/67 68/2/68
f 51/2/51 68/2/68 52/2/52
f 52/2/52 68/2/68 69/2/69
f 52/2/52 69/2/69 53/2/53
f 53/2/53 69/2/69 70/2/70
f 53/2/53 70/2/70 54/2/54
f 54/2/54 70/2/70 71/2/71
f 54/2/54 71/2/71 55/2/55
f 55/2/55 71/2/71 72/2/72
f 55/2/55 72/2/72 56/2/56
f 56/2/56 72/2/72 73/2/73
f 56/2/56 73/2/73 57/2/57
f 57/2/57 73/2/73 74/2/74
f 57/2/57 74/2/74 58/2/58
f 58/2/58 74/2/74 75/2/75
f 58/2/58 75/2/75 59/2/59
f 59/2/59 75/2/75 76/2/76
f 59/2/59 76/2/76 60/2/60
f 60/2/60 76/2/76 77/2/77
f 60/2/60 77/2/77 61/2/61
f 61/2/61 77/2/77 78/2/78
f 61/2/61 78/2/78 62/2/62
f 62/2/62 78/2/78 79/2/79
f 62/2/62 79/2/79 63/2/63
f 63/2/63 79/2/79 80/2/80
f 63/2/63 80/2/80 64/2/64
f 64/2/64 80/2/80 81/2/81
f 64/2/64 81/2/81 65/2/65
f 65/2/65 81/2/81 66/2/66
f 65/2/65 66/2/66 50/2/50
f 66/2/66 82/2/82 83/2/83
f 66/2/66 83/2/83 67/2/67
f 67/2/67 83/2/83 84/2/84
f 67/2/67 84/2/84 68/2/68
f 68/2/68 84/2/84 85/2/85
f 68/2/68 85/2/85 69/2/69
f 69/2/69 85/2/85 86/2/86
f 69/2/69 86/2/86 70/2/70
f 70/2/70 86/2/86 87/2/87
f 70/2/70 87/2/87 71/2/71
f 71/2/71 87/2/87 88/2/88
f 71/2/71 88/2/88 72/2/72
f 72/2/72 88/2/88 89/2/89
f 72/2/72 89/2/89 73/2/73
f 73/2/73 89/2/89 90/2/90
f 73/2/73 90/2/90 74/2/74
f 74/2/74 90/2/90 91/2/91
f 74/2/74 91/2/91 75/2/75
f 75/2/75 91/2/91 92/2/92
f 75/2/75 92/2/92 76/2/76
f 76/2/76 92/2/92 93/2/93
f 76/2/76 93/2/93 77/2/77
f 77/2/77 93/2/93 94/2/94
f 77/2/77 94/2/94 78/2/78
f 78/2/78 94/2/94 95/2/95
f 78/2/78 95/2/95 79/2/79
f 79/2/79 95/2/95 96/2/96
f 79/2/79 96/2/96 80/2/80
f 80/2/80 96/2/96 97/2/97
f 80/2/80 97/2/97 81/2/81
f 81/2/81 97/2/97 82/2/82
f 81/2/81 82/2/82 66/2/66
f 82/2/82 98/2/98 99/2/99
f 82/2/82 99/2/99 83/2/83
f 83/2/83 99/2/99 100/2/100
f 83/2/83 100/2/100 84/2/84
f 84/2/84 100/2/100 101/2/101
f 84/2/84 101/2/101 85/2/85
f 85/2/85 101/2/101 102/2/102
f 85/2/85 102/2/102 86/2/86
f 86/2/86 102/2/102 103/2/103
f 86/2/86 103/2/103 87/2/87
f 87/2/87 103/2/103 104/2/104
f 87/2/87 104/2/104 88/2/88
f 88/2/88 104/2/104 105/2/105
f 88/2/88 105/2/105 89/2/89
f 89/2/89 105/2/105 106/2/106
f 89/2/89 106/2/106 90/2/90
f 90/2/90 106/2/106 107/2/107
f 90/2/90 107/2/107 91/2/91
f 91/2/91 107/2/107 108/2/108
f 91/2/91 108/2/108 92/2/92
f 92/2/92 108/2/108 109/2/109
f 92/2/92 109/2/109 93/2/93
f 93/2/93 109/2/109 110/2/110
f 93/2/93 110/2/110 94/2/94
f 94/2/94 110/2/110 111/2/111
f 94/2/94 111/2/111 95/2/95
f 95/2/95 111/2/111 112/2/112
f 95/2/95 112/2/112 96/2/96
f 96/2/96 112/2/112 113/2/113
f 96/2/96 113/2/113 97/2/97
f 97/2/97 113/2/113 98/2/98
f 97/2/97 98/2/98 82/2/82
f 114/2/114 99/2/99 98/2/98
f 114/2/114 100/2/100 99/2/99
f 114/2/114 101/2/101 100/2/100
f 114/2/114 102/2/102 101/2/101
f 114/2/114 103/2/103 102/2/102
f 114/2/114 104/2/104 103/2/103
f 114/2/114 105/2/105 104/2/104
f 114/2/114 106/2/106 105/2/105
f 114/2/114 107/2/107 106/2/106
f 114/2/114 108/2/108 107/2/107
f 114/2/114 109/2/109 108/2/108
f 114/2/114 110/2/110 109/2/109
f 114/2/114 111/2/111 110/2/110
f 114/2/114 112/2/112 111/2/111
f 114/2/114 113/2/113 112/2/112
f 114/2/114 98/2/98 113/2/113
Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

+5
View File
@@ -1,5 +1,9 @@
get_filename_component(_TEST_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
# Observe the geometry backend's actual CGAL layout without duplicating its flags.
# This source is only added when the test suite is enabled.
target_sources(libslic3r_cgal PRIVATE texture_import_cgal.cpp)
add_executable(${_TEST_NAME}_tests
${_TEST_NAME}_tests.cpp
test_3mf.cpp
@@ -72,6 +76,7 @@ add_executable(${_TEST_NAME}_tests
test_indexed_triangle_set.cpp
test_connected_bodies.cpp
test_texture_displacement.cpp
test_texture_import.cpp
test_instance_lock.cpp
../libnest2d/printer_parts.cpp
)
+76
View File
@@ -0,0 +1,76 @@
#include <catch2/catch_message.hpp>
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/Model.hpp"
#include "libslic3r/TexturePainting.hpp"
#include "texture_import_cgal.hpp"
#include <algorithm>
#include <array>
#include <string>
#include <vector>
namespace {
void check_texture_import(const std::string& fixture)
{
const std::string filename = std::string(TEST_DATA_DIR) + "/texture_import/" + fixture;
INFO(filename);
const Slic3r::Model model = Slic3r::Model::read_from_file(filename);
REQUIRE_FALSE(model.objects.empty());
REQUIRE(model.texture_mesh);
const Slic3r::TexturedMesh& mesh = *model.texture_mesh;
Slic3r::TexturePaintingSettings settings;
settings.target_colors_num = 0; // Match the dialog's initial automatic color count.
settings.smooth_weight = 0.5;
settings.mesh_repair_decision = Slic3r::TexturePaintingSettings::MeshRepairDecision::ImportWithoutRepair;
Slic3r::PaintedMesh painted;
// Follow the dialog worker's format-dependent path, including the boundary
// smoothing that needs a consistent CGAL Kd_tree layout across libraries.
if (!mesh.precomputed_face_colors.empty())
REQUIRE(Slic3r::face_colors_to_painting(mesh, painted, settings));
else
REQUIRE(Slic3r::texture_to_painting(mesh, painted, settings));
REQUIRE_FALSE(painted.indices.empty());
REQUIRE(painted.face_colors.size() == painted.indices.size());
REQUIRE(std::any_of(painted.face_colors.begin(), painted.face_colors.end(),
[](const auto& color) { return color[0] > color[2]; }));
REQUIRE(std::any_of(painted.face_colors.begin(), painted.face_colors.end(),
[](const auto& color) { return color[2] > color[0]; }));
const std::vector<std::array<float, 4>> filament_colors{
{1.f, 0.f, 0.f, 1.f}, {0.f, 0.f, 1.f, 1.f}};
const auto matches = Slic3r::match_clusters_to_filaments(
painted.cluster_colors, filament_colors, {"Red PLA", "Blue PLA"});
REQUIRE(matches.size() == painted.cluster_colors.size());
REQUIRE(std::any_of(matches.begin(), matches.end(),
[](const auto& match) { return match.filament_index == 0; }));
REQUIRE(std::any_of(matches.begin(), matches.end(),
[](const auto& match) { return match.filament_index == 1; }));
}
} // namespace
TEST_CASE("Color-boundary smoothing shares its CGAL tree layout with the geometry backend", "[TextureImport][CGAL][Regression]")
{
// An ABI mismatch need not crash every link of the importer. Compare the
// layouts directly so a lucky choice of inline symbols cannot mask it.
REQUIRE(sizeof(TextureImportTest::SearchTree) == TextureImportTest::backend_search_tree_size());
}
TEST_CASE("A JPEG textured GLB retains both colors through filament matching", "[TextureImport][Regression]")
{
check_texture_import("two_color_jpeg.glb");
}
TEST_CASE("An OBJ preserves both MTL colors through filament matching", "[TextureImport][OBJ][Regression]")
{
check_texture_import("two_color_sphere/test_two_color_sphere.obj");
}
TEST_CASE("An OBJ resolves its MTL and external JPEG through filament matching", "[TextureImport][OBJ][Regression]")
{
check_texture_import("two_color_sphere/test_two_color_sphere_textured.obj");
}
+8
View File
@@ -0,0 +1,8 @@
#include "texture_import_cgal.hpp"
#include <cstddef>
std::size_t TextureImportTest::backend_search_tree_size()
{
return sizeof(SearchTree);
}
+28
View File
@@ -0,0 +1,28 @@
#pragma once
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/AABB_traits_3.h>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Kd_tree.h>
#include <CGAL/Search_traits_adapter.h>
#include <CGAL/Surface_mesh/Surface_mesh.h>
#include <CGAL/property_map.h>
#include <cstddef>
namespace TextureImportTest {
// The distance-query tree used by ColorUtils.cpp's boundary smoothing. Its
// type name stays the same when CGAL changes its storage for TBB support.
using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel;
using Mesh = CGAL::Surface_mesh<Kernel::Point_3>;
using Primitive = CGAL::AABB_face_graph_triangle_primitive<Mesh>;
using Traits = CGAL::AABB_traits_3<Kernel, Primitive>;
using PointId = Traits::Point_and_primitive_id;
using SearchTraits = CGAL::Search_traits_adapter<PointId, CGAL::First_of_pair_property_map<PointId>, Traits>;
using SearchTree = CGAL::Kd_tree<SearchTraits>;
// Implemented inside the actual geometry target, using its private definitions.
std::size_t backend_search_tree_size();
} // namespace TextureImportTest
+1
View File
@@ -44,6 +44,7 @@ add_executable(${_TEST_NAME}_tests
test_shortcuts.cpp
test_texture_color_palette.cpp
test_texture_island_view.cpp
test_timelapse_codecs.cpp
test_file_url.cpp
test_imgui_wrapper.cpp
test_user_manager.cpp
+100
View File
@@ -0,0 +1,100 @@
#include <catch2/catch_test_macros.hpp>
#include "libslic3r/GCode/ThumbnailData.hpp"
#include "libslic3r/GCode/Thumbnails.hpp"
#include "libslic3r/PrintConfig.hpp"
#include "libslic3r/TexturePainting.hpp"
#include "slic3r/GUI/AVVideoDecoder.hpp"
#include "slic3r/GUI/Printer/BambuTunnel.h"
#include <atomic>
#include <cstddef>
#include <cstdlib>
#include <thread>
#include <vector>
#include <wx/bitmap.h>
#include <wx/gdicmn.h>
#include <wx/image.h>
#include <wx/init.h>
#include <wx/mstream.h>
TEST_CASE("JPEG texture decoding coexists with thumbnails and video frames", "[TimelapseCodecs][Regression]")
{
#if defined(__linux__)
if (!std::getenv("DISPLAY") && !std::getenv("WAYLAND_DISPLAY"))
SKIP("This integration test needs a display (for example, xvfb-run).");
#endif
wxInitializer init;
REQUIRE(init.IsOk());
wxInitAllImageHandlers();
// Generate a JPEG through the same encoder used for G-code thumbnails.
constexpr int width = 160, height = 90, iterations = 1000;
Slic3r::ThumbnailData thumbnail;
thumbnail.set(width, height);
for (std::size_t i = 0; i < thumbnail.pixels.size(); i += 4) {
thumbnail.pixels[i] = 180;
thumbnail.pixels[i + 1] = 70;
thumbnail.pixels[i + 2] = 30;
thumbnail.pixels[i + 3] = 255;
}
const auto jpeg = Slic3r::GCodeThumbnails::compress_thumbnail(thumbnail, Slic3r::GCodeThumbnailsFormat::JPG);
REQUIRE(jpeg);
REQUIRE(jpeg->size > 0);
const auto* bytes = static_cast<const unsigned char*>(jpeg->data);
Slic3r::TextureImage texture;
texture.width = texture.height = -1;
texture.data.assign(bytes, bytes + jpeg->size);
std::atomic<bool> texture_ok{true};
std::thread texture_worker([&] {
for (int i = 0; i < iterations; ++i) {
std::vector<unsigned char> pixels;
int decoded_width = 0, decoded_height = 0;
if (!Slic3r::decode_texture_to_pixels(texture, pixels, decoded_width, decoded_height) ||
decoded_width != width || decoded_height != height || pixels.size() != width * height * 3)
texture_ok = false;
}
});
// PrinterFileSystem decodes timelapse thumbnails with wxImage. Do not
// assert until the worker is joined: Catch assertions can unwind the scope.
bool thumbnails_ok = true;
for (int i = 0; i < iterations; ++i) {
wxMemoryInputStream stream(jpeg->data, jpeg->size);
wxImage image(stream, "image/jpeg");
if (!image.IsOk() || image.GetWidth() != width || image.GetHeight() != height ||
image.GetRed(width / 2, height / 2) < 170 || image.GetGreen(width / 2, height / 2) > 80)
thumbnails_ok = false;
}
texture_worker.join();
REQUIRE(texture_ok.load());
REQUIRE(thumbnails_ok);
// Exercise Orca's real FFmpeg decoder and its platform display conversion.
AVVideoDecoder decoder;
Bambu_StreamInfo info{};
info.type = VIDE;
info.sub_type = MJPG;
info.format_type = video_jpeg;
REQUIRE(decoder.open(info) == 0);
Bambu_Sample sample{};
sample.size = static_cast<int>(jpeg->size);
sample.buffer = bytes;
for (int i = 0; i < iterations; ++i) {
REQUIRE(decoder.decode(sample) == 0);
wxImage image;
REQUIRE(decoder.toWxImage(image, wxSize(width, height)));
REQUIRE(image.IsOk());
REQUIRE(image.GetWidth() == width);
REQUIRE(image.GetHeight() == height);
#ifdef _WIN32
// Playback uses this raw 32-bit bitmap conversion only on Windows.
wxBitmap bitmap;
REQUIRE(decoder.toWxBitmap(bitmap, wxSize(width, height)));
REQUIRE(bitmap.IsOk());
REQUIRE(bitmap.GetWidth() == width);
REQUIRE(bitmap.GetHeight() == height);
#endif
}
}