Skip to main content

shapemesh

CI

A Gmsh-powered geometry and meshing library: a small, closed set of 0–3D shapes, n-ary booleans, and entity-level MSH 4.1 I/O.

Status: v0.1.0 — initial release.

Why shapemesh?

shapemesh is an easy-to-use wrapper for the powerful Gmsh meshing library. It simplifies creating complex geometries and meshing them into three steps: create primitive 1D to 3D shapes using the Shape primitives — for example a Line, Polygon, or Box; combine them into more complex shapes with boolean operations such as Union; and label them. Labels become Gmsh physical groups, so after calling build() you can query the elements belonging to each labelled shape.

Features

  • 12 shape primitives: Point, Line, Polyline, Circle, Ellipse, Polygon, Rectangle, Disk, EllipticalDisk, Sphere, Box, Cylinder. Missing something? Open an issue — the v1 set is intentionally small.
  • n-ary booleans: Union, Intersection, Difference with variadic or sequence constructors.
  • Overlapping physical groups: labels are preserved across Gmsh fragment remapping, so an intersection volume can belong to multiple groups.
  • MSH 4.1 ASCII I/O: read and write entity-classified meshes, with or without Gmsh running.
  • Typed public API: NumPy-based data model, PEP 561 py.typed marker, and strict Python ≥3.12 typing.

Install

pip install shapemesh

Gmsh (≥4.0) is installed automatically as a runtime dependency. shapemesh is tested against Gmsh 4.15.2.

Quick start

from shapemesh import Box, MeshSettings, build

column = Box(origin=(0, 0, 0), dx=1, dy=1, dz=1, label="column")
mesh = build(shapes=column, settings=MeshSettings())
mesh.write_msh("column.msh")

How it works

shapemesh builds a small scene graph of immutable shapes, hands it to Gmsh, and then remaps the resulting entities back to your labels.

  1. Define shapes. Every primitive takes a label. Labels are not just metadata — they become Gmsh physical groups.
  2. Build. build() realizes the geometry in a fresh Gmsh model, sets mesh settings, and generates the mesh.
  3. Fragment and remap. When shapes overlap, Gmsh fragments them into conformal pieces. shapemesh tracks which output pieces came from which input label and rebuilds the physical groups. A piece that lies in the overlap of two shapes belongs to both groups.
from shapemesh import Box, MeshSettings, build

a = Box(origin=(0, 0, 0), dx=1, dy=1, dz=1, label="a")
b = Box(origin=(0.5, 0, 0), dx=1, dy=1, dz=1, label="b")
mesh = build(shapes=[a, b], settings=MeshSettings())

# Three volume pieces: a-only, overlap, b-only.
assert len(mesh.entities(dim=3)) == 3

# The overlap piece is in both physical groups.
shared = set(mesh.physical_group(name="a", dim=3).entities) & set(
    mesh.physical_group(name="b", dim=3).entities
)
assert len(shared) == 1

This fragment remap is what makes overlapping physical groups work without any manual entity bookkeeping.

Examples

Structural examples covering 1D, 2D, and 3D workflows live in examples/:

Documentation

License

shapemesh is licensed under the GNU Lesser General Public License v3 or later (LGPL-3.0-or-later). See COPYING and COPYING.LESSER for the full texts.

Note on Gmsh: shapemesh itself is LGPL-3.0-or-later. It requires Gmsh as a runtime dependency, and Gmsh is licensed under GPL-2.0-or-later. If you distribute a combined work that includes Gmsh — for example, a closed-source application shipped with shapemesh and Gmsh — Gmsh's copyleft obligations apply to that distribution. Internal or server-side use without distribution is not affected.

Metadata

Release files for shapemesh 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shapemesh 0.1.0
File Size Uploaded Provenance Actions
shapemesh-0.1.0.tar.gz 87.0 kB Without provenance Details for shapemesh-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for shapemesh 0.1.0
File Interpreter ABI Platform Actions
shapemesh-0.1.0-py3-none-any.whl Python 3 none any Details for shapemesh-0.1.0-py3-none-any.whl

Total release size: 130.7 kB

Release files / shapemesh-0.1.0.tar.gz

Download URL shapemesh-0.1.0.tar.gz
Size 87.0 kB
Tags Source
SHA-256 checksum
How to use checksums
877e46cdeaf31c2a28ba63a0a9e6028631d0890cb9ca5786ced98c5a3f9a4361
BLAKE2b-256 checksum
How to use checksums
ac4e741bcf27ae8efa70b3477a31bb9b09afdeae1cfb7c996073e72d1bb06225
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / shapemesh-0.1.0-py3-none-any.whl

Download URL shapemesh-0.1.0-py3-none-any.whl
Size 43.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aeebc8fcebb3baec111049327dc452cecf0b7a1c243fe130dcffd59a9491328b
BLAKE2b-256 checksum
How to use checksums
4bd8f3f76406b932a842198eb01ebe931351d84c181bfab53d1229ced00abb17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for shapemesh 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page