diff --git a/Cargo.lock b/Cargo.lock index 52fa79d..07efbef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,12 @@ version = "1.0.2" source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + [[package]] name = "ahash" version = "0.7.6" @@ -46,6 +52,15 @@ dependencies = [ "num-traits", ] +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +dependencies = [ + "derive_arbitrary", +] + [[package]] name = "arrayref" version = "0.3.6" @@ -85,7 +100,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.5.4", "object", "rustc-demangle", ] @@ -122,15 +137,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.11.0" +version = "3.16.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.12.1" +version = "1.18.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "2f5715e491b5a1598fc2bef5a606847b5dc1d48ea625bd3c02c00de8285591da" +checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" [[package]] name = "byteorder" @@ -165,13 +180,13 @@ checksum = "5b6d248e3ca02f3fbfabcb9284464c596baec223a26d91bbf44a5a62ddb0d900" dependencies = [ "clap 3.2.22", "heck", - "indexmap", + "indexmap 1.9.1", "log", "proc-macro2", "quote", "serde", "serde_json", - "syn", + "syn 1.0.101", "tempfile", "toml", ] @@ -243,7 +258,7 @@ dependencies = [ "atty", "bitflags", "clap_lex", - "indexmap", + "indexmap 1.9.1", "strsim", "termcolor", "textwrap 0.15.1", @@ -359,9 +374,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.2" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] @@ -402,16 +417,6 @@ dependencies = [ "itertools", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.6" -source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - [[package]] name = "crossbeam-deque" version = "0.8.2" @@ -438,12 +443,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.12" +version = "0.8.20" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac" -dependencies = [ - "cfg-if", -] +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crossfont" @@ -517,7 +519,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 1.0.101", ] [[package]] @@ -528,7 +530,18 @@ checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ "darling_core", "quote", - "syn", + "syn 1.0.101", +] + +[[package]] +name = "derive_arbitrary" +version = "1.3.2" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", ] [[package]] @@ -537,6 +550,17 @@ version = "0.2.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "dlib" version = "0.5.0" @@ -572,6 +596,12 @@ version = "1.8.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "expat-sys" version = "2.1.6" @@ -592,7 +622,7 @@ dependencies = [ "flume", "half", "lebe", - "miniz_oxide", + "miniz_oxide 0.5.4", "smallvec", "threadpool", ] @@ -608,12 +638,12 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.24" +version = "1.0.33" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" +checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.8.0", ] [[package]] @@ -671,7 +701,7 @@ checksum = "c8469d0d40519bc608ec6863f1cc88f3f1deee15913f2f3b3e573d81ed38cccc" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.101", ] [[package]] @@ -735,9 +765,9 @@ dependencies = [ [[package]] name = "gif" -version = "0.11.4" +version = "0.13.1" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "3edd93c6756b4dfaf2709eafcc345ba2636565295c198a9cfbf75fa5e3e00b06" +checksum = "3fb2d69b19215e18bb912fa30f7ce15846e301408695e44e0ef719f1da9e19f2" dependencies = [ "color_quant", "weezl", @@ -853,6 +883,12 @@ version = "0.12.3" source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + [[package]] name = "heck" version = "0.4.0" @@ -889,9 +925,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "image" -version = "0.24.4" +version = "0.24.9" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "bd8e4fb07cf672b1642304e731ef8a6a4c7891d67bb4fd4f5ce58cd6ed86803c" +checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" dependencies = [ "bytemuck", "byteorder", @@ -899,10 +935,9 @@ dependencies = [ "exr", "gif", "jpeg-decoder", - "num-rational", "num-traits", "png", - "scoped_threadpool", + "qoi", "tiff", ] @@ -913,7 +948,17 @@ source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.5.0" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +dependencies = [ + "equivalent", + "hashbrown 0.14.5", ] [[package]] @@ -957,9 +1002,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "jpeg-decoder" -version = "0.2.6" +version = "0.3.1" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "9478aa10f73e7528198d75109c8be5cd7d15fb530238040148d5f9a22d4c5b3b" +checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" dependencies = [ "rayon", ] @@ -1017,14 +1062,17 @@ dependencies = [ "scopeguard", ] +[[package]] +name = "lockfree-object-pool" +version = "0.1.6" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "9374ef4228402d4b7e403e5838cb880d9ee663314b0a900d5a6aabf0c213552e" + [[package]] name = "log" -version = "0.4.17" +version = "0.4.22" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "malloc_buf" @@ -1037,9 +1085,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.7.4" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memmap2" @@ -1074,6 +1122,15 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + [[package]] name = "mint" version = "0.5.9" @@ -1147,7 +1204,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.101", ] [[package]] @@ -1191,17 +1248,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.15" @@ -1239,7 +1285,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 1.0.101", ] [[package]] @@ -1262,9 +1308,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.15.0" +version = "1.19.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "oorandom" @@ -1333,7 +1379,7 @@ checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.101", ] [[package]] @@ -1379,7 +1425,7 @@ dependencies = [ "bitflags", "crc32fast", "flate2", - "miniz_oxide", + "miniz_oxide 0.5.4", ] [[package]] @@ -1395,18 +1441,37 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.46" +version = "1.0.86" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] +[[package]] +name = "qoi" +version = "0.4.1" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "quick-xml" +version = "0.36.1" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "96a05e2e8efddfa51a84ca47cec303fac86c8541b686d37cac5efc0e094417bc" +dependencies = [ + "memchr", + "serde", +] + [[package]] name = "quote" -version = "1.0.21" +version = "1.0.37" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -1431,26 +1496,22 @@ dependencies = [ [[package]] name = "rayon" -version = "1.5.3" +version = "1.10.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ - "autocfg", - "crossbeam-deque", "either", "rayon-core", ] [[package]] name = "rayon-core" -version = "1.9.3" +version = "1.12.1" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] @@ -1528,12 +1589,6 @@ version = "1.0.0" source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" -[[package]] -name = "scoped_threadpool" -version = "0.1.9" -source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" - [[package]] name = "scopeguard" version = "1.1.0" @@ -1554,9 +1609,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.145" +version = "1.0.210" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] @@ -1573,13 +1628,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.145" +version = "1.0.210" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.77", ] [[package]] @@ -1624,6 +1679,12 @@ dependencies = [ "libc", ] +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + [[package]] name = "slotmap" version = "1.0.6" @@ -1696,6 +1757,7 @@ dependencies = [ "mint", "stderrlog", "stl_io", + "threemf", "tobj", ] @@ -1726,6 +1788,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.77" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "takeable-option" version = "0.5.0" @@ -1772,22 +1845,22 @@ checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16" [[package]] name = "thiserror" -version = "1.0.37" +version = "1.0.63" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.37" +version = "1.0.63" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.77", ] [[package]] @@ -1808,11 +1881,23 @@ dependencies = [ "num_cpus", ] +[[package]] +name = "threemf" +version = "0.6.0" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "eb5fd806deaf82c90e87d9bf7d2a43fc1782bdeadc161bf1f5cd5b0f2096c693" +dependencies = [ + "quick-xml", + "serde", + "thiserror", + "zip", +] + [[package]] name = "tiff" -version = "0.7.3" +version = "0.9.1" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "7259662e32d1e219321eb309d5f9d898b779769d81b76e762c07c8e5d38fcb65" +checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e" dependencies = [ "flate2", "jpeg-decoder", @@ -1932,34 +2017,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.83" +version = "0.2.93" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.83" +version = "0.2.93" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.77", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.83" +version = "0.2.93" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1967,22 +2053,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.83" +version = "0.2.93" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.77", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.83" +version = "0.2.93" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "wayland-client" @@ -2079,9 +2165,9 @@ dependencies = [ [[package]] name = "weezl" -version = "0.1.7" +version = "0.1.8" source = "registry+/~https://github.com/rust-lang/crates.io-index" -checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" +checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" [[package]] name = "winapi" @@ -2224,3 +2310,34 @@ name = "xml-rs" version = "0.8.4" source = "registry+/~https://github.com/rust-lang/crates.io-index" checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3" + +[[package]] +name = "zip" +version = "2.2.0" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "dc5e4288ea4057ae23afc69a4472434a87a2495cafce6632fd1c4ec9f5cf3494" +dependencies = [ + "arbitrary", + "crc32fast", + "crossbeam-utils", + "displaydoc", + "flate2", + "indexmap 2.5.0", + "memchr", + "thiserror", + "zopfli", +] + +[[package]] +name = "zopfli" +version = "0.8.1" +source = "registry+/~https://github.com/rust-lang/crates.io-index" +checksum = "e5019f391bac5cf252e93bbcc53d039ffd62c7bfb7c150414d61369afe57e946" +dependencies = [ + "bumpalo", + "crc32fast", + "lockfree-object-pool", + "log", + "once_cell", + "simd-adler32", +] diff --git a/Cargo.toml b/Cargo.toml index be51f72..33ccc90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ log = "0.4.17" mint = "0.5.9" stderrlog = "0.5.1" stl_io = "0.6.0" +threemf = { version = "0.6.0" } tobj = "3.2.3" #[patch.crates-io] diff --git a/src/lib.rs b/src/lib.rs index cb4c49d..77842b9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -557,4 +557,29 @@ mod tests { assert_ne!(0, size); } + + #[test] + fn cube_3mf() { + let img_filename = "cube-3mf.png".to_string(); + let config = Config { + stl_filename: "test_data/cube.3mf".to_string(), + img_filename: img_filename.clone(), + format: image::ImageOutputFormat::Png, + ..Default::default() + }; + + match fs::remove_file(&img_filename) { + Ok(_) => (), + Err(ref error) if error.kind() == ErrorKind::NotFound => (), + Err(_) => { + panic!("Couldn't clean files before testing"); + } + } + + render_to_file(&config).expect("Error in render function"); + + let size = fs::metadata(img_filename).expect("No file created").len(); + + assert_ne!(0, size); + } } diff --git a/src/mesh.rs b/src/mesh.rs index 16e859b..7225bcc 100644 --- a/src/mesh.rs +++ b/src/mesh.rs @@ -106,10 +106,10 @@ pub struct Mesh { impl Mesh { // Load mesh data from file (if provided) or stdin - pub fn load(stl_filename: &String, recalc_normals: bool) -> Result> { + pub fn load(stl_filename: &str, recalc_normals: bool) -> Result> { // TODO: Add support for URIs instead of plain file names // https://developer.gnome.org/integration-guide/stable/thumbnailer.html.en - match stl_filename.as_str() { + match stl_filename { "-" => { // create_stl_reader requires Seek, so we must read the entire stream into memory before proceeding. // So I guess this can just consume all RAM if it gets bad input. Hmmm.... @@ -118,18 +118,71 @@ impl Mesh { Mesh::from_stl(Cursor::new(input_buffer), recalc_normals) } _ => { + let stl_filename = std::path::Path::new(stl_filename); // TODO: Try BufReader and see if it's faster - let stl_file = File::open(&stl_filename)?; - let mesh = if stl_filename.ends_with(".obj") { - Mesh::from_obj(stl_file, recalc_normals)? - } else { - Mesh::from_stl(stl_file, recalc_normals)? - }; - Ok(mesh) + let stl_file = File::open(stl_filename)?; + Ok( + match stl_filename + .extension() + .and_then(std::ffi::OsStr::to_str) + .unwrap_or("") + { + "obj" => Mesh::from_obj(stl_file, recalc_normals)?, + "stl" => Mesh::from_stl(stl_file, recalc_normals)?, + "3mf" => Mesh::from_3mf(stl_file, recalc_normals)?, + _ => unimplemented!("Format not supported"), + }, + ) } } } + pub fn from_3mf(stl_file: R, _recalc_normals: bool) -> Result> + where + R: Read + Seek, + { + let models = threemf::read(stl_file)?; + + let mut result = None; + + let vertex_translator = |vertex: &threemf::model::Vertex| { + stl_io::Vertex::new([vertex.x as f32, vertex.y as f32, vertex.z as f32]) + }; + + // Combine all the models into a single mesh. + for model in models { + for object in model.resources.object { + if let Some(mesh) = object.mesh { + eprintln!("Received a mesh"); + for triangle in &mesh.triangles.triangle { + // Re-use `Mesh::process_tri`, which creates new vertices for every + // triangle. + // Possible optimization: re-use triangles instead. + let triangle = stl_io::Triangle { + normal: stl_io::Normal::new([1f32, 0f32, 0f32]), + vertices: [ + vertex_translator(&mesh.vertices.vertex[triangle.v1]), + vertex_translator(&mesh.vertices.vertex[triangle.v2]), + vertex_translator(&mesh.vertices.vertex[triangle.v3]), + ], + }; + result + .get_or_insert_with(|| Mesh { + vertices: Vec::new(), + normals: Vec::new(), + indices: Vec::new(), + bounds: BoundingBox::new(&triangle.vertices[0]), + stl_had_normals: false, + }) + .process_tri(&triangle, true); + } + } + } + } + + Ok(result.unwrap()) + } + pub fn from_stl(mut stl_file: R, recalc_normals: bool) -> Result> where R: Read + Seek, @@ -172,7 +225,7 @@ impl Mesh { Ok(mesh) } - pub fn from_obj(obj_file: File, recalc_normals: bool) -> Result> { + pub fn from_obj(obj_file: File, _recalc_normals: bool) -> Result> { let mut input = BufReader::new(obj_file); let (models, _) = tobj::load_obj_buf( &mut input, diff --git a/stl-thumb.thumbnailer b/stl-thumb.thumbnailer index a9d3fc6..35e057d 100644 --- a/stl-thumb.thumbnailer +++ b/stl-thumb.thumbnailer @@ -1,4 +1,4 @@ [Thumbnailer Entry] TryExec=stl-thumb Exec=xvfb-run --auto-servernum -w 0 stl-thumb -f png -s %s %i %o -MimeType=model/stl;model/x.stl-ascii;model/x.stl-binary;application/sla; +MimeType=model/3mf;model/stl;model/x.stl-ascii;model/x.stl-binary;application/sla; diff --git a/test_data/cube.3mf b/test_data/cube.3mf new file mode 100644 index 0000000..cb81bd4 Binary files /dev/null and b/test_data/cube.3mf differ