meshck 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ name: release
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v5
12
+ - uses: astral-sh/setup-uv@v10.4.0
13
+ - name: Check that the tag matches the package version
14
+ run: test "${GITHUB_REF_NAME#v}" = "$(uv version --short)"
15
+ - run: uv build
16
+ - uses: actions/upload-artifact@v7
17
+ with:
18
+ name: dist
19
+ path: dist/
20
+
21
+ publish:
22
+ needs: build
23
+ runs-on: ubuntu-latest
24
+ environment:
25
+ name: pypi
26
+ url: https://pypi.org/p/meshck
27
+ permissions:
28
+ id-token: write
29
+ steps:
30
+ - uses: actions/download-artifact@v8
31
+ with:
32
+ name: dist
33
+ path: dist/
34
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,36 @@
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ schedule:
8
+ - cron: "0 5 * * 1" # weekly, to catch breakage from new dependency releases
9
+ workflow_dispatch:
10
+
11
+ jobs:
12
+ test:
13
+ name: ${{ matrix.os }} / py${{ matrix.python }}${{ matrix.upgrade && ' / latest deps' || '' }}
14
+ runs-on: ${{ matrix.os }}
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ os: [ubuntu-latest, windows-latest, macos-latest]
19
+ python: ["3.13"]
20
+ upgrade: [false]
21
+ include:
22
+ - { os: ubuntu-latest, python: "3.11", upgrade: false }
23
+ - { os: ubuntu-latest, python: "3.14", upgrade: false }
24
+ - { os: ubuntu-latest, python: "3.14", upgrade: true }
25
+ steps:
26
+ - uses: actions/checkout@v5
27
+ - uses: astral-sh/setup-uv@v10.4.0
28
+ with:
29
+ python-version: ${{ matrix.python }}
30
+ - name: Install (locked)
31
+ if: ${{ !matrix.upgrade }}
32
+ run: uv sync --locked
33
+ - name: Install (latest dependency releases)
34
+ if: ${{ matrix.upgrade }}
35
+ run: uv sync --upgrade
36
+ - run: uv run pytest -q
@@ -0,0 +1,5 @@
1
+ __pycache__/
2
+ .venv/
3
+ *.egg-info/
4
+ dist/
5
+ .pytest_cache/
meshck-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 David Straub
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
meshck-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,160 @@
1
+ Metadata-Version: 2.5
2
+ Name: meshck
3
+ Version: 0.1.0
4
+ Summary: Check and repair triangle meshes (STL) before additive manufacturing
5
+ Project-URL: Repository, https://github.com/DavidMStraub/meshck
6
+ Author: David Straub
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
11
+ Classifier: Topic :: Scientific/Engineering
12
+ Requires-Python: >=3.11
13
+ Requires-Dist: manifold3d>=3.5.4
14
+ Requires-Dist: numpy
15
+ Requires-Dist: pymeshfix
16
+ Requires-Dist: rtree>=1.4.1
17
+ Requires-Dist: scipy>=1.17.1
18
+ Requires-Dist: trimesh
19
+ Description-Content-Type: text/markdown
20
+
21
+ # meshck
22
+
23
+ Check and repair triangle meshes (STL) before additive manufacturing.
24
+
25
+ meshck finds holes, flipped triangles and overlapping bodies in STL files
26
+ and repairs them. Like `fsck` for file systems, it checks by default and
27
+ repairs on request. It runs on Linux, macOS and Windows.
28
+
29
+ Status: early development.
30
+
31
+ ## Installation
32
+
33
+ ```sh
34
+ pip install meshck
35
+ ```
36
+
37
+ or, in a uv project:
38
+
39
+ ```sh
40
+ uv add meshck
41
+ ```
42
+
43
+ Requires Python 3.11 or newer.
44
+
45
+ ## Usage
46
+
47
+ Check one or more files:
48
+
49
+ ```sh
50
+ meshck part.stl
51
+ ```
52
+
53
+ ```
54
+ part.stl: FAIL
55
+ triangles=327580 shells=1 boundary_edges=54 holes=1 misoriented=4900 ...
56
+ error closed: mesh is open: 1 hole(s), 54 boundary edges
57
+ error oriented: 4900 misoriented triangles
58
+ ```
59
+
60
+ Repair and write a fixed copy (`part_repaired.stl`, or the path given with
61
+ `-o`). The input file is never overwritten:
62
+
63
+ ```sh
64
+ meshck --repair part.stl
65
+ ```
66
+
67
+ ```
68
+ part.stl -> part_repaired.stl: PASS
69
+ before: triangles=327580 shells=1 boundary_edges=54 holes=1 misoriented=4900 ...
70
+ after: triangles=327674 shells=1 boundary_edges=0 holes=0 misoriented=0 ...
71
+ repair: flipped 4900 misoriented triangles
72
+ repair: rebuilt 1 open shell(s) with pymeshfix
73
+ deviation_mm=0.0000
74
+ ```
75
+
76
+ Options:
77
+
78
+ | Option | Effect |
79
+ |---|---|
80
+ | `-r`, `--repair` | repair and write a fixed copy |
81
+ | `-o OUT`, `--output OUT` | where to write the repaired copy (one input file only) |
82
+ | `--fill-cavities` | when repairing, also fill cavities (see below) |
83
+ | `--strict` | treat warnings as errors |
84
+ | `--json` | print results as JSON |
85
+
86
+ Exit codes: `0` all files pass, `1` errors remain, `2` a file could not be
87
+ read or written.
88
+
89
+ ## What is checked
90
+
91
+ | Check | Severity |
92
+ |---|---|
93
+ | Empty mesh (no triangles) | error |
94
+ | Open mesh (holes, boundary edges) | error |
95
+ | Edges shared by more than two triangles | error |
96
+ | Misoriented triangles (including inverted parts and cavities) | error |
97
+ | Triangles crossing other triangles of the same shell | error |
98
+ | Overlapping shells, including a solid inside a solid | error |
99
+ | Shells touching over an area (they fuse when printed) | warning |
100
+ | Closed shells of zero thickness (they do not print) | warning |
101
+ | Degenerate (zero-area) triangles | warning |
102
+ | Several separate parts | warning |
103
+
104
+ Separate parts are only a warning because moving parts printed in one piece
105
+ are separate by design. Size and volume are reported without a limit.
106
+
107
+ A closed shell inside another one is a cavity if it points inwards and a
108
+ solid inside a solid if it points outwards. Crossings less than 1 µm deep are
109
+ ignored as rounding noise. Shells touching only along an edge or at a point
110
+ do not count as touching.
111
+
112
+ ## What repair does
113
+
114
+ Each step runs only if the check finds the problem it addresses:
115
+
116
+ 1. Remove collapsed and duplicate triangles.
117
+ 2. Flip misoriented triangles.
118
+ 3. Split edges shared by more than two triangles, so touching bodies become
119
+ separate closed shells.
120
+ 4. Rebuild shells that are still open with
121
+ [pymeshfix](https://github.com/pyvista/pymeshfix), one shell at a time,
122
+ and remove leftovers of zero thickness: stray triangles, flat sheets and
123
+ fins. If pymeshfix cannot close a shell that has thickness, the shell is
124
+ kept as it is.
125
+ 5. Merge overlapping shells, and shells touching over an area, with a boolean
126
+ union ([manifold3d](https://github.com/elalish/manifold)).
127
+ 6. With `--fill-cavities` only: remove every shell enclosed by another one,
128
+ so that cavities become solid.
129
+
130
+ `deviation_mm` is the largest distance the original surface moved. Filled
131
+ holes, filled cavities and inner walls removed by a merge are not counted,
132
+ deleted shells are.
133
+
134
+ Separate parts are kept, and so are cavities unless `--fill-cavities` is
135
+ given. meshck does not rebuild the whole outer surface and does not repair
136
+ self-intersecting shells. If the steps above are not enough, the mesh has to
137
+ be fixed by hand.
138
+
139
+ ## Python API
140
+
141
+ ```python
142
+ from pathlib import Path
143
+
144
+ from meshck.check import check_mesh, load_mesh
145
+ from meshck.repair import repair
146
+
147
+ mesh = load_mesh(Path("part.stl"))
148
+ result = repair(mesh.vertices, mesh.faces)
149
+ print(result.steps, result.deviation)
150
+ print(check_mesh(result.vertices, result.faces, Path("part.stl")).to_text())
151
+ ```
152
+
153
+ ## Scope
154
+
155
+ meshck checks whether a mesh is a valid solid. It does not check design
156
+ rules such as wall thickness, build volume or clearances.
157
+
158
+ ## License
159
+
160
+ MIT, see [LICENSE](https://github.com/DavidMStraub/meshck/blob/main/LICENSE).
meshck-0.1.0/README.md ADDED
@@ -0,0 +1,140 @@
1
+ # meshck
2
+
3
+ Check and repair triangle meshes (STL) before additive manufacturing.
4
+
5
+ meshck finds holes, flipped triangles and overlapping bodies in STL files
6
+ and repairs them. Like `fsck` for file systems, it checks by default and
7
+ repairs on request. It runs on Linux, macOS and Windows.
8
+
9
+ Status: early development.
10
+
11
+ ## Installation
12
+
13
+ ```sh
14
+ pip install meshck
15
+ ```
16
+
17
+ or, in a uv project:
18
+
19
+ ```sh
20
+ uv add meshck
21
+ ```
22
+
23
+ Requires Python 3.11 or newer.
24
+
25
+ ## Usage
26
+
27
+ Check one or more files:
28
+
29
+ ```sh
30
+ meshck part.stl
31
+ ```
32
+
33
+ ```
34
+ part.stl: FAIL
35
+ triangles=327580 shells=1 boundary_edges=54 holes=1 misoriented=4900 ...
36
+ error closed: mesh is open: 1 hole(s), 54 boundary edges
37
+ error oriented: 4900 misoriented triangles
38
+ ```
39
+
40
+ Repair and write a fixed copy (`part_repaired.stl`, or the path given with
41
+ `-o`). The input file is never overwritten:
42
+
43
+ ```sh
44
+ meshck --repair part.stl
45
+ ```
46
+
47
+ ```
48
+ part.stl -> part_repaired.stl: PASS
49
+ before: triangles=327580 shells=1 boundary_edges=54 holes=1 misoriented=4900 ...
50
+ after: triangles=327674 shells=1 boundary_edges=0 holes=0 misoriented=0 ...
51
+ repair: flipped 4900 misoriented triangles
52
+ repair: rebuilt 1 open shell(s) with pymeshfix
53
+ deviation_mm=0.0000
54
+ ```
55
+
56
+ Options:
57
+
58
+ | Option | Effect |
59
+ |---|---|
60
+ | `-r`, `--repair` | repair and write a fixed copy |
61
+ | `-o OUT`, `--output OUT` | where to write the repaired copy (one input file only) |
62
+ | `--fill-cavities` | when repairing, also fill cavities (see below) |
63
+ | `--strict` | treat warnings as errors |
64
+ | `--json` | print results as JSON |
65
+
66
+ Exit codes: `0` all files pass, `1` errors remain, `2` a file could not be
67
+ read or written.
68
+
69
+ ## What is checked
70
+
71
+ | Check | Severity |
72
+ |---|---|
73
+ | Empty mesh (no triangles) | error |
74
+ | Open mesh (holes, boundary edges) | error |
75
+ | Edges shared by more than two triangles | error |
76
+ | Misoriented triangles (including inverted parts and cavities) | error |
77
+ | Triangles crossing other triangles of the same shell | error |
78
+ | Overlapping shells, including a solid inside a solid | error |
79
+ | Shells touching over an area (they fuse when printed) | warning |
80
+ | Closed shells of zero thickness (they do not print) | warning |
81
+ | Degenerate (zero-area) triangles | warning |
82
+ | Several separate parts | warning |
83
+
84
+ Separate parts are only a warning because moving parts printed in one piece
85
+ are separate by design. Size and volume are reported without a limit.
86
+
87
+ A closed shell inside another one is a cavity if it points inwards and a
88
+ solid inside a solid if it points outwards. Crossings less than 1 µm deep are
89
+ ignored as rounding noise. Shells touching only along an edge or at a point
90
+ do not count as touching.
91
+
92
+ ## What repair does
93
+
94
+ Each step runs only if the check finds the problem it addresses:
95
+
96
+ 1. Remove collapsed and duplicate triangles.
97
+ 2. Flip misoriented triangles.
98
+ 3. Split edges shared by more than two triangles, so touching bodies become
99
+ separate closed shells.
100
+ 4. Rebuild shells that are still open with
101
+ [pymeshfix](https://github.com/pyvista/pymeshfix), one shell at a time,
102
+ and remove leftovers of zero thickness: stray triangles, flat sheets and
103
+ fins. If pymeshfix cannot close a shell that has thickness, the shell is
104
+ kept as it is.
105
+ 5. Merge overlapping shells, and shells touching over an area, with a boolean
106
+ union ([manifold3d](https://github.com/elalish/manifold)).
107
+ 6. With `--fill-cavities` only: remove every shell enclosed by another one,
108
+ so that cavities become solid.
109
+
110
+ `deviation_mm` is the largest distance the original surface moved. Filled
111
+ holes, filled cavities and inner walls removed by a merge are not counted,
112
+ deleted shells are.
113
+
114
+ Separate parts are kept, and so are cavities unless `--fill-cavities` is
115
+ given. meshck does not rebuild the whole outer surface and does not repair
116
+ self-intersecting shells. If the steps above are not enough, the mesh has to
117
+ be fixed by hand.
118
+
119
+ ## Python API
120
+
121
+ ```python
122
+ from pathlib import Path
123
+
124
+ from meshck.check import check_mesh, load_mesh
125
+ from meshck.repair import repair
126
+
127
+ mesh = load_mesh(Path("part.stl"))
128
+ result = repair(mesh.vertices, mesh.faces)
129
+ print(result.steps, result.deviation)
130
+ print(check_mesh(result.vertices, result.faces, Path("part.stl")).to_text())
131
+ ```
132
+
133
+ ## Scope
134
+
135
+ meshck checks whether a mesh is a valid solid. It does not check design
136
+ rules such as wall thickness, build volume or clearances.
137
+
138
+ ## License
139
+
140
+ MIT, see [LICENSE](https://github.com/DavidMStraub/meshck/blob/main/LICENSE).
@@ -0,0 +1,43 @@
1
+ [project]
2
+ name = "meshck"
3
+ version = "0.1.0"
4
+ description = "Check and repair triangle meshes (STL) before additive manufacturing"
5
+ readme = "README.md"
6
+ requires-python = ">=3.11"
7
+ license = "MIT"
8
+ authors = [{ name = "David Straub" }]
9
+ classifiers = [
10
+ "Programming Language :: Python :: 3",
11
+ "Topic :: Scientific/Engineering",
12
+ "Topic :: Multimedia :: Graphics :: 3D Modeling",
13
+ ]
14
+ dependencies = [
15
+ "manifold3d>=3.5.4",
16
+ "numpy",
17
+ "pymeshfix",
18
+ "rtree>=1.4.1",
19
+ "scipy>=1.17.1",
20
+ "trimesh",
21
+ ]
22
+
23
+ [project.urls]
24
+ Repository = "https://github.com/DavidMStraub/meshck"
25
+
26
+ [project.scripts]
27
+ meshck = "meshck.cli:main"
28
+
29
+ [dependency-groups]
30
+ dev = ["pytest"]
31
+
32
+ [build-system]
33
+ requires = ["hatchling"]
34
+ build-backend = "hatchling.build"
35
+
36
+ [tool.uv]
37
+ # Same platforms as the CAx course stack: every dependency must ship wheels.
38
+ required-environments = [
39
+ "sys_platform == 'win32' and platform_machine == 'AMD64'",
40
+ "sys_platform == 'darwin' and platform_machine == 'arm64'",
41
+ "sys_platform == 'darwin' and platform_machine == 'x86_64'",
42
+ "sys_platform == 'linux' and platform_machine == 'x86_64'",
43
+ ]
@@ -0,0 +1,5 @@
1
+ """Check and repair triangle meshes before additive manufacturing."""
2
+
3
+ from importlib.metadata import version
4
+
5
+ __version__ = version("meshck")
@@ -0,0 +1,5 @@
1
+ import sys
2
+
3
+ from meshck.cli import main
4
+
5
+ sys.exit(main())