This can be modified or extended to include the other kinds of DLLs supported by Zemax.
The entry points for the raytrace and the parameter names are defined in the ./src/lib.rs file.
The pointers coming from Zemax are cast to the struct defined in ./src/data_structures.rs.
The code can be compiled to a DLL using the following command:
cargo build --releaseand the resulting DLL will be in the ./target/release/ folder, ready to be copied in the Zemax DLL folder.
You need to have the following pre-requisites:
-
The
mingw-w64toolchain installed, which can be obtained from the package manager of your distribution on Linux or from homebrew on macOS, here a few examples:# On Ubuntu sudo apt install mingw-w64 # On macOS brew install mingw-w64
-
The
x86_64-pc-windows-gnutarget installed in your Rust toolchain, which can be done using the following command:rustup target add x86_64-pc-windows-gnu
Then, you can compile the DLL using the following command:
cargo build --release --target=x86_64-pc-windows-gnuand the resulting DLL will be in the ./target/x86_64-pc-windows-gnu/release/ folder, ready to be copied in the Zemax DLL folder.
Simply run:
cargo doc --document-private-items --no-deps --target=x86_64-pc-windows-gnuAdd the additional --open flag to open the documentation in your default web browser.
Credits to Zemax for the examples in C and C++ that inspired this.