Installation
Use automesh from one of the following interfaces:
- command line interface,
- Rust interface, or
- Python interface.
All interfaces are independent from each other:
- The Rust interfaces can be used without the Python interface.
- The Python interface can be used without the Rust interfaces.
For macOS and Linux, use a terminal. For Windows, use a Command Prompt (CMD) or PowerShell.
Some macOS users have encountered a build error with the netcdf-src crate. See Troubleshooting for a solution to this error.
Step 1: Install Prerequisites
- The command line interface and Rust interface depend on Rust and Cargo.
- Cargo is the Rust package manager.
- Cargo is included with the Rust installation.
- The Python interface depends on Python and pip.
- pip is the Python package installer.
- pip is included with the standard installation of Python starting from Python 3.4.
Rust Prerequisites
It is recommended to install Rust using Rustup, which is an installer and version management tool.
Python Prerequisites
macOS
- Install Homebrew (if you don't have it already). Open the Terminal and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install Python. After Homebrew is installed, run:
brew install python
- Verify Python and pip are installed:
python3 --version
pip3 --version
Linux
- Update Package List. Open a terminal and run:
sudo apt update
- Install Python and pip. For Ubuntu or Debian-based systems, run:
sudo apt install python3 python3-pip
- Verify Python and pip are installed:
python3 --version
pip3 --version
Windows
- Download Python. Go to the official Python website and download the latest version of Python for Windows.
- Run the Installer. During installation, make sure to check the box that says "Add Python to PATH."
- Verify Python and pip are installed:
python --version
pip --version
All Environments
On all environments, a virtual environment is recommended, but not required. Create a virtual environment:
python3 -m venv .venv # venv, or
uv venv .venv # using uv
uv is a fast Python package manager, written in Rust. It is an alternative to pip.
Activate the virtual environment:
source .venv/bin/activate # for bash shell
source .venv/bin/activate.csh # for c shell
source .venv/bin/activate.fish # for fish shell
.\.venv\Scripts\activate # for powershell
Step 2: Install automesh
Install the desired interface.
Command Line Interface
cargo install automesh
Rust Interface
cargo add automesh
Python Interface
pip install automesh # using pip, or
uv pip install automesh # using uv
Step 3: Verify Installation
Rust Interfaces
Run the command line help:
automesh
which should display the following:
@@@@@@@@@@@@@@@@
@@@@ @@@@@@@@@@
@@@@ @@@@@@@@@@@
@@@@ @@@@@@@@@@@@ automesh: Automatic mesh generation
@@ @@ @@ v0.3.6 build 05acfd9 linux x86_64
@@ @@ @@ Chad B. Hovey <chovey@sandia.gov>
@@@@@@@@@@@@ @@@ Michael R. Buche <mrbuche@sandia.gov>
@@@@@@@@@@@ @@@@
@@@@@@@@@@ @@@@@ @
@@@@@@@@@@@@@@@@
Usage: automesh [COMMAND]
Commands:
convert Converts between mesh or segmentation file types
defeature Defeatures and creates a new segmentation
diff Show the difference between two segmentations
extract Extracts a specified range of voxels from a segmentation
mesh Creates a finite element mesh from a tessellation or segmentation
metrics Quality metrics for an existing finite element mesh
remesh Applies isotropic remeshing to an existing mesh
segment Creates a segmentation or voxelized mesh from an existing mesh
smooth Applies smoothing to an existing mesh
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
Python Interface
python
# In Python, import the module
>>> import automesh
# List all attributes and methods of the module
>>> dir(automesh)
# Get help on the module
>>> help(automesh)
Troubleshooting
ZLIB target not found
Some users have encountered an error when trying to build the netcdf crate, e.g.,
...
error: failed to run custom build command for `netcdf-src v0.4.3`
...
The link interface of target "hdf5-static" contains:
ZLIB::ZLIB
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
...
HDF5 is looking for ZLIB::ZLIB as a CMake target, but it's not being found
even though ZLIB is present.
A solution is to use a dynamically-linked netcdf from Homebrew instead of
trying to build it statically. This should avoid the CMake ZLIB::ZLIB target
issue entirely.
Update the Cargo.toml for automesh to avoid static linking:
...
# netcdf = { version = "=0.11.1", features = ["ndarray", "static"] }
netcdf = { version = "=0.11.1", features = ["ndarray"] }
...
Then,
# Make sure netcdf is installed via Homebrew
brew install netcdf
# Set the environment variable to use system netcdf
export NETCDF_DIR=/opt/homebrew
# Clean and build
cargo clean
cargo build
If you still encounter errors about netcdf not being found, also try:
export PKG_CONFIG_PATH=/opt/homebrew/lib/pkgconfig
export DYLD_LIBRARY_PATH=/opt/homebrew/lib