Skip to content

Repository files navigation

mesh-conversion

Strict Python conversion from ASCII OBJ, OFF, and ASCII STL meshes to binary Gmsh MSH 4.1.

Source meshes are parsed by this package, not by meshio. meshio is used only to write binary MSH and to read the generated MSH during validation.

from mesh_conversion import convert, validate_round_trip

convert("mesh.obj", "mesh.msh")
report = validate_round_trip("mesh.obj", "mesh.msh")
assert report.ok

Development

conda env create -f environment.yml
conda activate mesh-conversion
pip install -e '.[dev]'
pytest

Binary MSH stores floating point values, not the original text. Validation therefore compares the original coordinate tokens to the canonical stringification of the float64 values read back from the MSH file. Decimal spellings with the same exact decimal value are accepted, so 4.508350 can round-trip as 4.50835, 0 can round-trip as 0.0, and -0.000037 can round-trip as -3.7e-05.

Supported v1 geometry:

  • OBJ: v, triangular f, and l edge/polyline records. vt, vn, and other non-geometry records are ignored.
  • OFF: triangular faces.
  • STL: ASCII triangle facets.

pytest automatically clones the pinned wildmeshing/data2 test checkout into data/, then recursively validates every .obj, .off, and .stl file under it. Fixtures in the pinned checkout that are outside the strict v1 contract (for example source decimals that are not the same exact decimal value as the canonical binary64 spelling) are marked as expected failures.

To point the same test at a different folder:

MESH_CONVERSION_DATA_DIR=/path/to/data pytest

The default revision is pinned to 9a29d7e482aea8d58260895a9e06cb20cdb7fd63 for repeatability. The generated data/ checkout is ignored by git.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages