From c039ffd4bbbb0691164d452ad67e2ddc9a12f842 Mon Sep 17 00:00:00 2001 From: L-Nafaryus Date: Tue, 16 Apr 2024 22:36:38 +0500 Subject: [PATCH] test bindings --- Cargo.lock | 623 +++++++++++++++++++++++++++++- Cargo.toml | 7 +- crates/hpr-shape/Cargo.toml | 13 + crates/hpr-shape/src/lib.rs | 106 +++++ crates/occt-rs/.cargo/config.toml | 2 + crates/occt-rs/Cargo.toml | 12 + crates/occt-rs/build.rs | 100 +++++ crates/occt-rs/patch/adm/MODULES | 4 + crates/occt-rs/src/lib.rs | 214 ++++++++++ crates/occt-rs/src/wrapper.hpp | 146 +++++++ examples/bottle.rs | 36 +- flake.nix | 1 + 12 files changed, 1231 insertions(+), 33 deletions(-) create mode 100644 crates/hpr-shape/Cargo.toml create mode 100644 crates/hpr-shape/src/lib.rs create mode 100644 crates/occt-rs/.cargo/config.toml create mode 100644 crates/occt-rs/Cargo.toml create mode 100644 crates/occt-rs/build.rs create mode 100644 crates/occt-rs/patch/adm/MODULES create mode 100644 crates/occt-rs/src/lib.rs create mode 100644 crates/occt-rs/src/wrapper.hpp diff --git a/Cargo.lock b/Cargo.lock index 56dea39..782657d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,7 +68,7 @@ dependencies = [ "accesskit", "accesskit_macos", "accesskit_windows", - "raw-window-handle", + "raw-window-handle 0.6.0", "winit", ] @@ -178,6 +178,25 @@ dependencies = [ "num-traits", ] +[[package]] +name = "arboard" +version = "3.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2041f1943049c7978768d84e6d0fd95de98b76d6c4727b09e78ec253d29fa58" +dependencies = [ + "clipboard-win", + "core-graphics", + "image", + "log", + "objc", + "objc-foundation", + "objc_id", + "parking_lot", + "thiserror", + "windows-sys 0.48.0", + "x11rb", +] + [[package]] name = "arrayref" version = "0.3.7" @@ -502,6 +521,27 @@ dependencies = [ "syn 2.0.53", ] +[[package]] +name = "bevy_egui" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44197ead4c9e40303fa5056be44de593f17151bd08d1d9dbe7b127700e1b9d01" +dependencies = [ + "arboard", + "bevy", + "console_log", + "crossbeam-channel", + "egui", + "js-sys", + "log", + "thread_local", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webbrowser", + "winit", +] + [[package]] name = "bevy_encase_derive" version = "0.13.1" @@ -1008,7 +1048,7 @@ dependencies = [ "bevy_math", "bevy_reflect", "bevy_utils", - "raw-window-handle", + "raw-window-handle 0.6.0", "smol_str", ] @@ -1031,7 +1071,7 @@ dependencies = [ "bevy_utils", "bevy_window", "crossbeam-channel", - "raw-window-handle", + "raw-window-handle 0.6.0", "wasm-bindgen", "web-sys", "winit", @@ -1212,6 +1252,18 @@ dependencies = [ "thiserror", ] +[[package]] +name = "calloop-wayland-source" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02" +dependencies = [ + "calloop", + "rustix", + "wayland-backend", + "wayland-client", +] + [[package]] name = "cc" version = "1.0.90" @@ -1260,6 +1312,15 @@ dependencies = [ "libloading 0.8.3", ] +[[package]] +name = "clipboard-win" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d517d4b86184dbb111d3556a10f1c8a04da7428d2987bf1081602bf11c3aa9ee" +dependencies = [ + "error-code", +] + [[package]] name = "cmake" version = "0.1.50" @@ -1345,6 +1406,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "console_log" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8aed40e4edbf4d3b4431ab260b63fdc40f5780a4766824329ea0f1eefe3c0f" +dependencies = [ + "log", + "web-sys", +] + [[package]] name = "const-fnv1a-hash" version = "1.1.0" @@ -1493,9 +1564,9 @@ checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991" [[package]] name = "cxx" -version = "1.0.120" +version = "1.0.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dc7287237dd438b926a81a1a5605dad33d286870e5eee2db17bf2bcd9e92a" +checksum = "21db378d04296a84d8b7d047c36bb3954f0b46529db725d7e62fb02f9ba53ccc" dependencies = [ "cc", "cxxbridge-flags", @@ -1505,9 +1576,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.119" +version = "1.0.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9324397d262f63ef77eb795d900c0d682a34a43ac0932bec049ed73055d52f63" +checksum = "3e5262a7fa3f0bae2a55b767c223ba98032d7c328f5c13fa5cdc980b77fc0658" dependencies = [ "cc", "codespan-reporting", @@ -1520,15 +1591,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.120" +version = "1.0.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "701a1ac7a697e249cdd8dc026d7a7dafbfd0dbcd8bd24ec55889f2bc13dd6287" +checksum = "be8dcadd2e2fb4a501e1d9e93d6e88e6ea494306d8272069c92d5a9edf8855c0" [[package]] name = "cxxbridge-macro" -version = "1.0.120" +version = "1.0.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b404f596046b0bb2d903a9c786b875a126261b52b7c3a64bbb66382c41c771df" +checksum = "ad08a837629ad949b73d032c637653d069e909cffe4ee7870b02301939ce39cc" dependencies = [ "proc-macro2", "quote", @@ -1590,12 +1661,41 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" +[[package]] +name = "ecolor" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03cfe80b1890e1a8cdbffc6044d6872e814aaf6011835a2a5e2db0e5c5c4ef4e" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "egui" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180f595432a5b615fc6b74afef3955249b86cfea72607b40740a4cd60d5297d0" +dependencies = [ + "ahash", + "epaint", + "nohash-hasher", +] + [[package]] name = "either" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +[[package]] +name = "emath" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6916301ecf80448f786cdf3eb51d9dbdd831538732229d49119e2d4312eaaf09" +dependencies = [ + "bytemuck", +] + [[package]] name = "encase" version = "0.7.0" @@ -1628,6 +1728,21 @@ dependencies = [ "syn 2.0.53", ] +[[package]] +name = "epaint" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77b9fdf617dd7f58b0c8e6e9e4a1281f730cde0831d40547da446b2bb76a47af" +dependencies = [ + "ab_glyph", + "ahash", + "bytemuck", + "ecolor", + "emath", + "nohash-hasher", + "parking_lot", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -1653,6 +1768,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "error-code" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0474425d51df81997e2f90a21591180b38eccf27292d755f3e30750225c175b" + [[package]] name = "euclid" version = "0.22.9" @@ -1774,6 +1895,15 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + [[package]] name = "futures-core" version = "0.3.30" @@ -1856,6 +1986,21 @@ dependencies = [ "windows 0.54.0", ] +[[package]] +name = "git2" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "232e6a7bfe35766bf715e55a88b39a700596c0ccfd88cd3680b4cdb40d66ef70" +dependencies = [ + "bitflags 2.5.0", + "libc", + "libgit2-sys", + "log", + "openssl-probe", + "openssl-sys", + "url", +] + [[package]] name = "gl_generator" version = "0.14.0" @@ -2085,16 +2230,37 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "hpr" version = "0.1.0" dependencies = [ "bevy", + "bevy_egui", "cxx", "glam 0.24.2", "nalgebra", "opencascade", - "opencascade-sys", + "opencascade-sys 0.2.0 (git+https://github.com/bschwind/opencascade-rs.git?branch=main)", +] + +[[package]] +name = "hpr-shape" +version = "0.1.0" +dependencies = [ + "cxx", + "nalgebra", + "occt-rs", + "opencascade", + "opencascade-sys 0.2.0 (git+https://github.com/bschwind/opencascade-rs.git?branch=main)", ] [[package]] @@ -2108,6 +2274,16 @@ dependencies = [ "objc2 0.4.1", ] +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + [[package]] name = "image" version = "0.24.9" @@ -2119,6 +2295,7 @@ dependencies = [ "color_quant", "num-traits", "png", + "tiff", ] [[package]] @@ -2213,6 +2390,12 @@ dependencies = [ "libc", ] +[[package]] +name = "jpeg-decoder" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" + [[package]] name = "js-sys" version = "0.3.69" @@ -2277,6 +2460,20 @@ version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +[[package]] +name = "libgit2-sys" +version = "0.16.2+1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee4126d8b4ee5c9d9ea891dd875cfdc1e9d0950437179104b183d7d8a74d24e8" +dependencies = [ + "cc", + "libc", + "libssh2-sys", + "libz-sys", + "openssl-sys", + "pkg-config", +] + [[package]] name = "libloading" version = "0.7.4" @@ -2308,6 +2505,20 @@ dependencies = [ "redox_syscall 0.4.1", ] +[[package]] +name = "libssh2-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dc8a030b787e2119a731f1951d6a773e2280c660f8ec4b0f5e1505a386e71ee" +dependencies = [ + "cc", + "libc", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", +] + [[package]] name = "libudev-sys" version = "0.1.4" @@ -2318,6 +2529,18 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "libz-sys" +version = "1.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e143b5e666b2695d28f6bca6497720813f699c9602dd7f5cac91008b8ada7f9" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "link-cplusplus" version = "1.0.9" @@ -2392,6 +2615,15 @@ version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +[[package]] +name = "memmap2" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" +dependencies = [ + "libc", +] + [[package]] name = "metal" version = "0.27.0" @@ -2502,7 +2734,7 @@ dependencies = [ "log", "ndk-sys", "num_enum", - "raw-window-handle", + "raw-window-handle 0.6.0", "thiserror", ] @@ -2533,6 +2765,12 @@ dependencies = [ "libc", ] +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + [[package]] name = "nom" version = "7.1.3" @@ -2648,6 +2886,17 @@ dependencies = [ "objc_exception", ] +[[package]] +name = "objc-foundation" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" +dependencies = [ + "block", + "objc", + "objc_id", +] + [[package]] name = "objc-sys" version = "0.2.0-beta.2" @@ -2705,6 +2954,15 @@ dependencies = [ "cc", ] +[[package]] +name = "objc_id" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" +dependencies = [ + "objc", +] + [[package]] name = "oboe" version = "0.6.1" @@ -2728,6 +2986,16 @@ dependencies = [ "cc", ] +[[package]] +name = "occt-rs" +version = "0.1.0" +dependencies = [ + "cmake", + "cxx", + "cxx-build", + "git2", +] + [[package]] name = "occt-sys" version = "0.2.0" @@ -2737,6 +3005,15 @@ dependencies = [ "cmake", ] +[[package]] +name = "occt-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abf7e266531942bf47dfbc2e257cbd83a2b21dd997c15ec257a1168bb62c030a" +dependencies = [ + "cmake", +] + [[package]] name = "ogg" version = "0.8.0" @@ -2760,7 +3037,7 @@ checksum = "7cac07d534d3e8edff488853310e616f402682490a06ed558ea21376e3dd0ac6" dependencies = [ "cxx", "glam 0.23.0", - "opencascade-sys", + "opencascade-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "thiserror", ] @@ -2773,7 +3050,36 @@ dependencies = [ "cmake", "cxx", "cxx-build", - "occt-sys", + "occt-sys 0.2.0", +] + +[[package]] +name = "opencascade-sys" +version = "0.2.0" +source = "git+https://github.com/bschwind/opencascade-rs.git?branch=main#7ed1ba8766e968f9b860c95c9640a32aee85b030" +dependencies = [ + "cmake", + "cxx", + "cxx-build", + "occt-sys 0.3.0", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", ] [[package]] @@ -2941,6 +3247,15 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58" +[[package]] +name = "quick-xml" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +dependencies = [ + "memchr", +] + [[package]] name = "quote" version = "1.0.35" @@ -2962,6 +3277,12 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8a99fddc9f0ba0a85884b8d14e3592853e787d581ca1816c91349b10e4eeab" +[[package]] +name = "raw-window-handle" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" + [[package]] name = "raw-window-handle" version = "0.6.0" @@ -3124,6 +3445,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + [[package]] name = "scopeguard" version = "1.2.0" @@ -3136,6 +3463,19 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" +[[package]] +name = "sctk-adwaita" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82b2eaf3a5b264a521b988b2e73042e742df700c4f962cde845d1541adb46550" +dependencies = [ + "ab_glyph", + "log", + "memmap2", + "smithay-client-toolkit", + "tiny-skia", +] + [[package]] name = "serde" version = "1.0.197" @@ -3228,6 +3568,31 @@ dependencies = [ "serde", ] +[[package]] +name = "smithay-client-toolkit" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "922fd3eeab3bd820d76537ce8f582b1cf951eceb5475c28500c7457d9d17f53a" +dependencies = [ + "bitflags 2.5.0", + "calloop", + "calloop-wayland-source", + "cursor-icon", + "libc", + "log", + "memmap2", + "rustix", + "thiserror", + "wayland-backend", + "wayland-client", + "wayland-csd-frame", + "wayland-cursor", + "wayland-protocols", + "wayland-protocols-wlr", + "wayland-scanner", + "xkeysym", +] + [[package]] name = "smol_str" version = "0.2.1" @@ -3252,6 +3617,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strict-num" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" + [[package]] name = "svg_fmt" version = "0.4.2" @@ -3345,6 +3716,42 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tiff" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e" +dependencies = [ + "flate2", + "jpeg-decoder", + "weezl", +] + +[[package]] +name = "tiny-skia" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab" +dependencies = [ + "arrayref", + "arrayvec", + "bytemuck", + "cfg-if", + "log", + "tiny-skia-path", +] + +[[package]] +name = "tiny-skia-path" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" +dependencies = [ + "arrayref", + "bytemuck", + "strict-num", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -3482,12 +3889,27 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-segmentation" version = "1.11.0" @@ -3506,6 +3928,17 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" +[[package]] +name = "url" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + [[package]] name = "uuid" version = "1.8.0" @@ -3522,6 +3955,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "vec_map" version = "0.8.2" @@ -3616,6 +4055,115 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +[[package]] +name = "wayland-backend" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d50fa61ce90d76474c87f5fc002828d81b32677340112b4ef08079a9d459a40" +dependencies = [ + "cc", + "downcast-rs", + "rustix", + "scoped-tls", + "smallvec", + "wayland-sys", +] + +[[package]] +name = "wayland-client" +version = "0.31.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82fb96ee935c2cea6668ccb470fb7771f6215d1691746c2d896b447a00ad3f1f" +dependencies = [ + "bitflags 2.5.0", + "rustix", + "wayland-backend", + "wayland-scanner", +] + +[[package]] +name = "wayland-csd-frame" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" +dependencies = [ + "bitflags 2.5.0", + "cursor-icon", + "wayland-backend", +] + +[[package]] +name = "wayland-cursor" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71ce5fa868dd13d11a0d04c5e2e65726d0897be8de247c0c5a65886e283231ba" +dependencies = [ + "rustix", + "wayland-client", + "xcursor", +] + +[[package]] +name = "wayland-protocols" +version = "0.31.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4" +dependencies = [ + "bitflags 2.5.0", + "wayland-backend", + "wayland-client", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-plasma" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23803551115ff9ea9bce586860c5c5a971e360825a0309264102a9495a5ff479" +dependencies = [ + "bitflags 2.5.0", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-wlr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6" +dependencies = [ + "bitflags 2.5.0", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b3a62929287001986fb58c789dce9b67604a397c15c611ad9f747300b6c283" +dependencies = [ + "proc-macro2", + "quick-xml", + "quote", +] + +[[package]] +name = "wayland-sys" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15a0c8eaff5216d07f226cb7a549159267f3467b289d9a2e52fd3ef5aae2b7af" +dependencies = [ + "dlib", + "log", + "once_cell", + "pkg-config", +] + [[package]] name = "web-sys" version = "0.3.69" @@ -3636,6 +4184,29 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webbrowser" +version = "0.8.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1b04c569c83a9bb971dd47ec6fd48753315f4bf989b9b04a2e7ca4d7f0dc950" +dependencies = [ + "core-foundation", + "home", + "jni", + "log", + "ndk-context", + "objc", + "raw-window-handle 0.5.2", + "url", + "web-sys", +] + +[[package]] +name = "weezl" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" + [[package]] name = "wgpu" version = "0.19.3" @@ -3650,7 +4221,7 @@ dependencies = [ "naga", "parking_lot", "profiling", - "raw-window-handle", + "raw-window-handle 0.6.0", "smallvec", "static_assertions", "wasm-bindgen", @@ -3678,7 +4249,7 @@ dependencies = [ "once_cell", "parking_lot", "profiling", - "raw-window-handle", + "raw-window-handle 0.6.0", "rustc-hash", "smallvec", "thiserror", @@ -3721,7 +4292,7 @@ dependencies = [ "parking_lot", "profiling", "range-alloc", - "raw-window-handle", + "raw-window-handle 0.6.0", "renderdoc-sys", "rustc-hash", "smallvec", @@ -4075,6 +4646,7 @@ version = "0.29.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d59ad965a635657faf09c8f062badd885748428933dad8e8bdd64064d92e5ca" dependencies = [ + "ahash", "android-activity", "atomic-waker", "bitflags 2.5.0", @@ -4088,19 +4660,26 @@ dependencies = [ "js-sys", "libc", "log", + "memmap2", "ndk", "ndk-sys", "objc2 0.4.1", "once_cell", "orbclient", "percent-encoding", - "raw-window-handle", + "raw-window-handle 0.6.0", "redox_syscall 0.3.5", "rustix", + "sctk-adwaita", + "smithay-client-toolkit", "smol_str", "unicode-segmentation", "wasm-bindgen", "wasm-bindgen-futures", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-plasma", "web-sys", "web-time", "windows-sys 0.48.0", @@ -4150,6 +4729,12 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e63e71c4b8bd9ffec2c963173a4dc4cbde9ee96961d4fcb4429db9929b606c34" +[[package]] +name = "xcursor" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a0ccd7b4a5345edfcd0c3535718a4e9ff7798ffc536bb5b5a0e26ff84732911" + [[package]] name = "xi-unicode" version = "0.3.0" diff --git a/Cargo.toml b/Cargo.toml index db78919..285ab3f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,12 +6,15 @@ authors = ["L-Nafaryus , +} + +impl Point { + pub fn with_coords(px: f64, py: f64, pz: f64) -> Self { + Self { + data: ffi::gp_Pnt_WithCoords(px, py, pz), + } + } + + pub fn set_x(&mut self, px: f64) { + self.data.pin_mut().SetX(px); + } + + pub fn set_y(&mut self, py: f64) { + self.data.pin_mut().SetY(py); + } + + pub fn set_z(&mut self, pz: f64) { + self.data.pin_mut().SetZ(pz); + } + + pub fn x(&self) -> f64 { + self.data.X() + } + + pub fn y(&self) -> f64 { + self.data.Y() + } + + pub fn z(&self) -> f64 { + self.data.Z() + } + + pub fn distance(&self, other: &Point) -> f64 { + self.data.Distance(&other.data) + } +} + +impl Default for Point { + fn default() -> Self { + Self { + data: ffi::gp_Pnt_Default(), + } + } +} + +impl From> for Point { + fn from(vec: Vector3) -> Self { + Point::with_coords(vec.x, vec.y, vec.z) + } +} + +#[derive(Debug)] +pub enum ShapeType { + Compound, + CompoundSolid, + Solid, + Shell, + Face, + Wire, + Edge, + Vertex, + Shape, + Unknown, +} + +impl From for ShapeType { + fn from(shape_enum: ffi::TopAbs_ShapeEnum) -> Self { + match shape_enum { + ffi::TopAbs_ShapeEnum::TopAbs_SHAPE => Self::Shape, + ffi::TopAbs_ShapeEnum::TopAbs_VERTEX => Self::Vertex, + ffi::TopAbs_ShapeEnum::TopAbs_EDGE => Self::Edge, + ffi::TopAbs_ShapeEnum::TopAbs_WIRE => Self::Wire, + ffi::TopAbs_ShapeEnum::TopAbs_FACE => Self::Face, + ffi::TopAbs_ShapeEnum::TopAbs_SHELL => Self::Shell, + ffi::TopAbs_ShapeEnum::TopAbs_SOLID => Self::Solid, + ffi::TopAbs_ShapeEnum::TopAbs_COMPSOLID => Self::CompoundSolid, + ffi::TopAbs_ShapeEnum::TopAbs_COMPOUND => Self::Compound, + ffi::TopAbs_ShapeEnum { repr: _ } => Self::Unknown, + } + } +} + +pub struct Vertex { + pub data: UniquePtr, +} + +impl Vertex { + pub fn new(point: Point) -> Self { + let mut make_vertex = ffi::BRepBuilderAPI_MakeVertex_WithPoint(&point.data); + let vertex = make_vertex.pin_mut().Vertex(); + + Self { + data: ffi::TopoDS_Vertex_ToOwned(vertex), + } + } +} diff --git a/crates/occt-rs/.cargo/config.toml b/crates/occt-rs/.cargo/config.toml new file mode 100644 index 0000000..df5527b --- /dev/null +++ b/crates/occt-rs/.cargo/config.toml @@ -0,0 +1,2 @@ +[env] +OCCT_VERSION = "V7_8_1" diff --git a/crates/occt-rs/Cargo.toml b/crates/occt-rs/Cargo.toml new file mode 100644 index 0000000..7e499eb --- /dev/null +++ b/crates/occt-rs/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "occt-rs" +version = "0.1.0" +edition = "2021" + +[build-dependencies] +cmake = "0.1.50" +git2 = "0.18.3" +cxx-build = "1.0.121" + +[dependencies] +cxx = "1.0.121" diff --git a/crates/occt-rs/build.rs b/crates/occt-rs/build.rs new file mode 100644 index 0000000..b06ff6f --- /dev/null +++ b/crates/occt-rs/build.rs @@ -0,0 +1,100 @@ +use std::{env, fs, path::Path}; + +use git2::{build::RepoBuilder, FetchOptions}; + +fn main() { + let occt_version: &str = "V7_8_1"; // &env::var("OCCT_VERSION").expect("Set env variable OCCT_VERSION"); + + let current_dir = env::current_dir().expect("Should have 'current' directory"); + let patch_dir = current_dir.join("patch"); + + let out = env::var("OUT_DIR").expect("Should have 'out' directory"); + let out_dir = Path::new(&out); + let target_dir = out_dir.join("opencascade"); + let lib_dir = out_dir.join("lib"); + let include_dir = out_dir.join("include"); + + let url = "https://github.com/Open-Cascade-SAS/OCCT.git"; + + let mut fetch_options = FetchOptions::new(); + fetch_options.depth(1); + let mut builder = RepoBuilder::new(); + builder.fetch_options(fetch_options).branch("master"); + + println!("cargo:rustc-env=OCCT_VERSION={}", occt_version); + + if !target_dir.is_dir() { + //fs::remove_dir_all(target_dir.clone()).expect("Failed to remove directory"); + + let repo = builder.clone(url, &target_dir).expect(""); + + let refname = "V7_8_1"; + let (object, reference) = repo + .revparse_ext(refname) + .unwrap_or_else(|_| panic!("Should have ref: {}", refname)); + + repo.checkout_tree(&object, None) + .expect("Failed to checkout"); + + match reference { + Some(gref) => repo.set_head(gref.name().unwrap()), + None => repo.set_head_detached(object.id()), + } + .expect("Failed to set HEAD"); + } + + //if !(lib_dir.exists() && include_dir.exists()) { + cmake::Config::new(target_dir) + .define("BUILD_PATCH", patch_dir) + .define("BUILD_LIBRARY_TYPE", "Static") + .define("USE_D3D", "OFF") + .define("USE_DRACO", "OFF") + .define("USE_EIGEN", "OFF") + .define("USE_FFMPEG", "OFF") + .define("USE_FREEIMAGE", "OFF") + .define("USE_FREETYPE", "OFF") + .define("USE_GLES2", "OFF") + .define("USE_OPENGL", "OFF") + .define("USE_OPENVR", "OFF") + .define("USE_RAPIDJSON", "OFF") + .define("USE_TBB", "OFF") + .define("USE_TCL", "OFF") + .define("USE_TK", "OFF") + .define("USE_VTK", "OFF") + .define("USE_XLIB", "OFF") + .define("INSTALL_DIR_LIB", lib_dir.clone()) + .define("INSTALL_DIR_INCLUDE", "include") //include_dir.clone()) + .build(); + //} + + println!( + "cargo:rustc-link-search=native={}", + lib_dir.to_str().unwrap() + ); + + for entry in fs::read_dir(lib_dir).unwrap() { + if entry.is_err() { + continue; + } + let path = entry.unwrap().path(); + if path.is_file() { + let name = path.file_stem().unwrap().to_str().unwrap(); + println!("cargo:rustc-link-lib=static={}", &name[3..]); + } + } + + println!("cargo:rustc-link-lib=static=wrapper"); + println!("cargo:warning={}", include_dir.display()); + + cxx_build::bridge("src/lib.rs") + .cpp(true) + .flag_if_supported("-std=c++11") + .define("_USE_MATH_DEFINES", "TRUE") + .include(include_dir) + .include("src") + .compile("wrapper"); + + println!("cargo:rerun-if-env-changed=OCCT_VERSION"); + println!("cargo:rerun-if-changed=src/lib.rs"); + println!("cargo:rerun-if-changed=src/wrapper.hpp"); +} diff --git a/crates/occt-rs/patch/adm/MODULES b/crates/occt-rs/patch/adm/MODULES new file mode 100644 index 0000000..d9bfa9e --- /dev/null +++ b/crates/occt-rs/patch/adm/MODULES @@ -0,0 +1,4 @@ +FoundationClasses TKernel TKMath +ModelingData TKG2d TKG3d TKGeomBase TKBRep +ModelingAlgorithms TKGeomAlgo TKTopAlgo TKPrim TKBO TKBool TKFillet TKOffset TKFeat TKMesh TKShHealing +DataExchange TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKSTL diff --git a/crates/occt-rs/src/lib.rs b/crates/occt-rs/src/lib.rs new file mode 100644 index 0000000..4dcb48a --- /dev/null +++ b/crates/occt-rs/src/lib.rs @@ -0,0 +1,214 @@ +#[cxx::bridge] +pub mod ffi { + #[repr(u32)] + enum TopAbs_ShapeEnum { + TopAbs_COMPOUND, + TopAbs_COMPSOLID, + TopAbs_SOLID, + TopAbs_SHELL, + TopAbs_FACE, + TopAbs_WIRE, + TopAbs_EDGE, + TopAbs_VERTEX, + TopAbs_SHAPE, + } + + unsafe extern "C++" { + include!("wrapper.hpp"); + + type HStandard_Type; + + /* + * Geometry processors + * gp + */ + type gp_Pnt; + + #[cxx_name = "constructor"] + #[rust_name = "gp_Pnt_Default"] + pub fn gp_Pnt() -> UniquePtr; + + #[cxx_name = "constructor"] + #[rust_name = "gp_Pnt_WithCoords"] + pub fn gp_Pnt(px: f64, py: f64, pz: f64) -> UniquePtr; + + pub fn SetX(self: Pin<&mut gp_Pnt>, px: f64); + + pub fn SetY(self: Pin<&mut gp_Pnt>, py: f64); + + pub fn SetZ(self: Pin<&mut gp_Pnt>, pz: f64); + + pub fn X(self: &gp_Pnt) -> f64; + + pub fn Y(self: &gp_Pnt) -> f64; + + pub fn Z(self: &gp_Pnt) -> f64; + + pub fn Distance(self: &gp_Pnt, other: &gp_Pnt) -> f64; + + /* + * Topology and builders + * TopAbs, TopoDS, BRepBuilderAPI + */ + + type TopAbs_ShapeEnum; + + type TopoDS_Vertex; + type TopoDS_Edge; + type TopoDS_Wire; + type TopoDS_Face; + type TopoDS_Shell; + type TopoDS_Solid; + type TopoDS_Compound; + type TopoDS_CompSolid; + type TopoDS_Shape; + + #[cxx_name = "constructor"] + #[rust_name = "TopoDS_Vertex_ToOwned"] + pub fn TopoDS_Vertex(vertex: &TopoDS_Vertex) -> UniquePtr; + + #[cxx_name = "constructor"] + #[rust_name = "TopoDS_Edge_ToOwned"] + pub fn TopoDS_Edge(vertex: &TopoDS_Edge) -> UniquePtr; + + #[cxx_name = "constructor"] + #[rust_name = "TopoDS_Wire_ToOwned"] + pub fn TopoDS_Wire(vertex: &TopoDS_Wire) -> UniquePtr; + + #[cxx_name = "constructor"] + #[rust_name = "TopoDS_Face_ToOwned"] + pub fn TopoDS_Face(vertex: &TopoDS_Face) -> UniquePtr; + + #[cxx_name = "constructor"] + #[rust_name = "TopoDS_Shell_ToOwned"] + pub fn TopoDS_Shell(vertex: &TopoDS_Shell) -> UniquePtr; + + #[cxx_name = "constructor"] + #[rust_name = "TopoDS_Solid_ToOwned"] + pub fn TopoDS_Solid(vertex: &TopoDS_Solid) -> UniquePtr; + + #[cxx_name = "constructor"] + #[rust_name = "TopoDS_Compound_ToOwned"] + pub fn TopoDS_Compound(vertex: &TopoDS_Compound) -> UniquePtr; + + #[cxx_name = "constructor"] + #[rust_name = "TopoDS_CompSolid_ToOwned"] + pub fn TopoDS_CompSolid(vertex: &TopoDS_CompSolid) -> UniquePtr; + + pub fn cast_to_vertex(shape: &TopoDS_Shape) -> &TopoDS_Vertex; + pub fn cast_to_edge(shape: &TopoDS_Shape) -> &TopoDS_Edge; + pub fn cast_to_wire(shape: &TopoDS_Shape) -> &TopoDS_Wire; + pub fn cast_to_face(shape: &TopoDS_Shape) -> &TopoDS_Face; + pub fn cast_to_shell(shape: &TopoDS_Shape) -> &TopoDS_Shell; + pub fn cast_to_solid(shape: &TopoDS_Shape) -> &TopoDS_Solid; + pub fn cast_to_compound(shape: &TopoDS_Shape) -> &TopoDS_Compound; + pub fn cast_to_compsolid(shape: &TopoDS_Shape) -> &TopoDS_CompSolid; + + pub fn cast_from_vertex(vertex: &TopoDS_Vertex) -> &TopoDS_Shape; + pub fn cast_from_edge(edge: &TopoDS_Edge) -> &TopoDS_Shape; + pub fn cast_from_wire(wire: &TopoDS_Wire) -> &TopoDS_Shape; + pub fn cast_from_face(face: &TopoDS_Face) -> &TopoDS_Shape; + pub fn cast_from_shell(shell: &TopoDS_Shell) -> &TopoDS_Shape; + pub fn cast_from_solid(solid: &TopoDS_Solid) -> &TopoDS_Shape; + pub fn cast_from_compound(compound: &TopoDS_Compound) -> &TopoDS_Shape; + pub fn cast_from_compsolid(compsolid: &TopoDS_CompSolid) -> &TopoDS_Shape; + + type BRepBuilderAPI_MakeVertex; + type BRepBuilderAPI_MakeEdge; + type BRepBuilderAPI_MakeWire; + type BRepBuilderAPI_MakeFace; + type BRepBuilderAPI_MakeShell; + type BRepBuilderAPI_MakeSolid; + + #[cxx_name = "constructor"] + #[rust_name = "BRepBuilderAPI_MakeVertex_WithPoint"] + pub fn BRepBuilderAPI_MakeVertex(p: &gp_Pnt) -> UniquePtr; + + pub fn Vertex(self: Pin<&mut BRepBuilderAPI_MakeVertex>) -> &TopoDS_Vertex; + + #[cxx_name = "constructor"] + #[rust_name = "BRepBuilderAPI_MakeEdge_WithVertices"] + pub fn BRepBuilderAPI_MakeEdge( + v1: &TopoDS_Vertex, + v2: &TopoDS_Vertex, + ) -> UniquePtr; + + #[cxx_name = "constructor"] + #[rust_name = "BRepBuilderAPI_MakeEdge_WithPoints"] + pub fn BRepBuilderAPI_MakeEdge( + p1: &gp_Pnt, + p2: &gp_Pnt, + ) -> UniquePtr; + + pub fn Edge(self: Pin<&mut BRepBuilderAPI_MakeEdge>) -> &TopoDS_Edge; + + pub fn Vertex1(self: Pin<&mut BRepBuilderAPI_MakeEdge>) -> &TopoDS_Vertex; + + pub fn Vertex2(self: Pin<&mut BRepBuilderAPI_MakeEdge>) -> &TopoDS_Vertex; + + /* + * Primitives + * BRepPrimAPI + */ + + type Message_ProgressRange; + type BRepPrimAPI_MakeBox; + + #[cxx_name = "constructor"] + #[rust_name = "Message_ProgressRange_Default"] + pub fn Message_ProgressRange() -> UniquePtr; + + #[cxx_name = "constructor"] + #[rust_name = "BRepPrimAPI_MakeBox_Default"] + pub fn BRepPrimAPI_MakeBox() -> UniquePtr; + + #[cxx_name = "constructor"] + #[rust_name = "BRepPrimAPI_MakeBox_WithSize"] + pub fn BRepPrimAPI_MakeBox(dx: f64, dy: f64, dz: f64) -> UniquePtr; + + #[cxx_name = "constructor"] + #[rust_name = "BRepPrimAPI_MakeBox_WithCorner"] + pub fn BRepPrimAPI_MakeBox( + p: &gp_Pnt, + dx: f64, + dy: f64, + dz: f64, + ) -> UniquePtr; + + #[cxx_name = "constructor"] + #[rust_name = "BRepPrimAPI_MakeBox_WithCorners"] + pub fn BRepPrimAPI_MakeBox(p1: &gp_Pnt, p2: &gp_Pnt) -> UniquePtr; + + #[rust_name = "Init_WithSize"] + pub fn Init(self: Pin<&mut BRepPrimAPI_MakeBox>, dx: f64, dy: f64, dz: f64); + + #[rust_name = "Init_WithCorner"] + pub fn Init(self: Pin<&mut BRepPrimAPI_MakeBox>, p: &gp_Pnt, dx: f64, dy: f64, dz: f64); + + #[rust_name = "Init_WithCorners"] + pub fn Init(self: Pin<&mut BRepPrimAPI_MakeBox>, p1: &gp_Pnt, p2: &gp_Pnt); + + pub fn Build(self: Pin<&mut BRepPrimAPI_MakeBox>, theRange: &Message_ProgressRange); + + pub fn IsDone(self: &BRepPrimAPI_MakeBox) -> bool; + + pub fn Shape(self: Pin<&mut BRepPrimAPI_MakeBox>) -> &TopoDS_Shape; + + pub fn Shell(self: Pin<&mut BRepPrimAPI_MakeBox>) -> &TopoDS_Shell; + + pub fn Solid(self: Pin<&mut BRepPrimAPI_MakeBox>) -> &TopoDS_Solid; + + pub fn BottomFace(self: Pin<&mut BRepPrimAPI_MakeBox>) -> &TopoDS_Face; + + pub fn BackFace(self: Pin<&mut BRepPrimAPI_MakeBox>) -> &TopoDS_Face; + + pub fn FrontFace(self: Pin<&mut BRepPrimAPI_MakeBox>) -> &TopoDS_Face; + + pub fn LeftFace(self: Pin<&mut BRepPrimAPI_MakeBox>) -> &TopoDS_Face; + + pub fn RightFace(self: Pin<&mut BRepPrimAPI_MakeBox>) -> &TopoDS_Face; + + pub fn TopFace(self: Pin<&mut BRepPrimAPI_MakeBox>) -> &TopoDS_Face; + + } +} diff --git a/crates/occt-rs/src/wrapper.hpp b/crates/occt-rs/src/wrapper.hpp new file mode 100644 index 0000000..a50a542 --- /dev/null +++ b/crates/occt-rs/src/wrapper.hpp @@ -0,0 +1,146 @@ +//#pragma once + +#include "rust/cxx.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +/*#include +#include + +#include +#include +#include */ + +#include + +#include + +#include +#include +#include + + +#include +#include +#include + + +template +std::unique_ptr constructor(Args... args) { + return std::unique_ptr(new T(args...)); +} + +using HStandard_Type = opencascade::handle; + + +inline const TopoDS_Vertex& cast_to_vertex(const TopoDS_Shape& shape) { + return TopoDS::Vertex(shape); +} + +inline const TopoDS_Edge& cast_to_edge(const TopoDS_Shape& shape) { + return TopoDS::Edge(shape); +} + +inline const TopoDS_Wire& cast_to_wire(const TopoDS_Shape& shape) { + return TopoDS::Wire(shape); +} + +inline const TopoDS_Face& cast_to_face(const TopoDS_Shape& shape) { + return TopoDS::Face(shape); +} + +inline const TopoDS_Shell& cast_to_shell(const TopoDS_Shape& shape) { + return TopoDS::Shell(shape); +} + +inline const TopoDS_Solid& cast_to_solid(const TopoDS_Shape& shape) { + return TopoDS::Solid(shape); +} + +inline const TopoDS_Compound& cast_to_compound(const TopoDS_Shape& shape) { + return TopoDS::Compound(shape); +} + +inline const TopoDS_CompSolid& cast_to_compsolid(const TopoDS_Shape& shape) { + return TopoDS::CompSolid(shape); +} + + +inline const TopoDS_Shape& cast_from_vertex(const TopoDS_Vertex& vertex) { + return vertex; +} + +inline const TopoDS_Shape& cast_from_edge(const TopoDS_Edge& edge) { + return edge; +} + +inline const TopoDS_Shape& cast_from_wire(const TopoDS_Wire& wire) { + return wire; +} + +inline const TopoDS_Shape& cast_from_face(const TopoDS_Face& face) { + return face; +} + +inline const TopoDS_Shape& cast_from_shell(const TopoDS_Shell& shell) { + return shell; +} + +inline const TopoDS_Shape& cast_from_solid(const TopoDS_Solid& solid) { + return solid; +} + +inline const TopoDS_Shape& cast_from_compound(const TopoDS_Compound& compound) { + return compound; +} + +inline const TopoDS_Shape& cast_from_compsolid(const TopoDS_CompSolid& compsolid) { + return compsolid; +} diff --git a/examples/bottle.rs b/examples/bottle.rs index d18dff0..e06ddac 100644 --- a/examples/bottle.rs +++ b/examples/bottle.rs @@ -1,7 +1,7 @@ use cxx::UniquePtr; use opencascade_sys::ffi::{ compute_normals, cylinder_to_surface, ellipse_to_HandleGeom2d_Curve, ellipse_value, - gp_Ax2_ctor, gp_Ax2d_ctor, gp_Ax3_from_gp_Ax2, gp_DZ, gp_Dir2d_ctor, gp_OX, + gp_Ax2_ctor, gp_Ax2d_ctor, gp_Ax3_from_gp_Ax2, gp_DZ, gp_Dir2d_ctor, gp_OX, gp_Pnt, handle_geom_plane_location, new_HandleGeomCurve_from_HandleGeom_TrimmedCurve, new_HandleGeomPlane_from_HandleGeomSurface, new_list_of_shape, new_point, new_point_2d, new_transform, new_vec, shape_list_append_face, type_name, write_stl, BRepAlgoAPI_Fuse_ctor, @@ -10,17 +10,18 @@ use opencascade_sys::ffi::{ BRepBuilderAPI_MakeWire_edge_edge_edge, BRepBuilderAPI_Transform_ctor, BRepFilletAPI_MakeFillet_ctor, BRepLibBuildCurves3d, BRepMesh_IncrementalMesh_ctor, BRepOffsetAPI_MakeThickSolid_ctor, BRepOffsetAPI_ThruSections_ctor, - BRepPrimAPI_MakeCylinder_ctor, BRepPrimAPI_MakePrism_ctor, BRep_Builder_ctor, - BRep_Builder_upcast_to_topods_builder, BRep_Tool_Surface, BRep_Tool_Triangulation, DynamicType, - ExplorerCurrentShape, GCE2d_MakeSegment_point_point, GC_MakeArcOfCircle_Value, - GC_MakeArcOfCircle_point_point_point, GC_MakeSegment_Value, GC_MakeSegment_point_point, - Geom2d_Ellipse_ctor, Geom2d_TrimmedCurve_ctor, Geom_CylindricalSurface_ctor, - HandleGeom2d_TrimmedCurve_to_curve, Handle_Poly_Triangulation_Get, MakeThickSolidByJoin, - Poly_Triangulation_Node, Poly_Triangulation_Normal, Poly_Triangulation_UV, StlAPI_Writer_ctor, - TColgp_Array1OfDir_ctor, TopAbs_Orientation, TopAbs_ShapeEnum, TopExp_Explorer_ctor, - TopLoc_Location_Transformation, TopLoc_Location_ctor, TopoDS_Compound_as_shape, - TopoDS_Compound_ctor, TopoDS_Face, TopoDS_Face_to_owned, TopoDS_Shape_to_owned, - TopoDS_cast_to_edge, TopoDS_cast_to_face, TopoDS_cast_to_wire, + BRepPrimAPI_MakeCylinder_ctor, BRepPrimAPI_MakePrism_ctor, BRepPrimAPI_MakeSphere_ctor, + BRep_Builder_ctor, BRep_Builder_upcast_to_topods_builder, BRep_Tool_Surface, + BRep_Tool_Triangulation, DynamicType, ExplorerCurrentShape, GCE2d_MakeSegment_point_point, + GC_MakeArcOfCircle_Value, GC_MakeArcOfCircle_point_point_point, GC_MakeSegment_Value, + GC_MakeSegment_point_point, Geom2d_Ellipse_ctor, Geom2d_TrimmedCurve_ctor, + Geom_CylindricalSurface_ctor, HandleGeom2d_TrimmedCurve_to_curve, + Handle_Poly_Triangulation_Get, MakeThickSolidByJoin, Poly_Triangulation_Node, + Poly_Triangulation_Normal, Poly_Triangulation_UV, StlAPI_Writer_ctor, TColgp_Array1OfDir_ctor, + TopAbs_Orientation, TopAbs_ShapeEnum, TopExp_Explorer_ctor, TopLoc_Location_Transformation, + TopLoc_Location_ctor, TopoDS_Compound_as_shape, TopoDS_Compound_ctor, TopoDS_Face, + TopoDS_Face_to_owned, TopoDS_Shape_to_owned, TopoDS_cast_to_edge, TopoDS_cast_to_face, + TopoDS_cast_to_wire, }; use bevy::prelude::*; @@ -29,6 +30,7 @@ use bevy::render::{ render_asset::RenderAssetUsages, render_resource::PrimitiveTopology, }; +use bevy_egui::{egui, EguiContexts, EguiPlugin}; #[derive(Debug)] pub struct BMesh { @@ -39,6 +41,8 @@ pub struct BMesh { } pub fn bottle_mesh() -> BMesh { + //let pnt = gp_Ax2(0., 0., 0.); + //let sphere = BRepPrimAPI_MakeSphere_ctor(5.); let height = 70.0; let width = 50.0; let thickness = 30.0; @@ -468,9 +472,17 @@ fn create_bottle_mesh() -> Mesh { )) } +fn ui_example_system(mut contexts: EguiContexts) { + egui::Window::new("Hello").show(contexts.ctx_mut(), |ui| { + ui.label("world"); + }); +} + fn main() { App::new() .add_plugins(DefaultPlugins) + .add_plugins(EguiPlugin) + .add_systems(Update, ui_example_system) .add_systems(Startup, setup) .add_systems(Update, input_handler) .run(); diff --git a/flake.nix b/flake.nix index 938b965..eddd57d 100644 --- a/flake.nix +++ b/flake.nix @@ -63,6 +63,7 @@ lld libxkbcommon pkg-config alsa-lib libudev-zero libGL vulkan-tools vulkan-headers vulkan-loader vulkan-validation-layers + openssl ]; shellHook = '' export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${