Skip to content

Commit eac7567

Browse files
authored
Merge pull request #16 from berenslab/draco
v0.1.8: remove `.ctm` support
2 parents d8800cc + db47d57 commit eac7567

File tree

9 files changed

+4666
-84
lines changed

9 files changed

+4666
-84
lines changed

pyproject.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "skeliner"
7-
version = "0.1.7"
7+
version = "0.1.8"
88
description = "A lightweight neuromorphological mesh skeletonizer."
99
authors = []
1010
requires-python = ">=3.10.0"
1111
dependencies = [
1212
"igraph>=0.11.8",
1313
"numpy>=2.0.2",
1414
"scipy>=1.13.1",
15-
"trimesh>=4.6.9",
16-
"python-openctm>=1.0.12; python_version < '3.12'",
17-
"openctm>=0.0.6; python_version >= '3.12'",
15+
"trimesh>=4.6.13",
1816
"matplotlib>=3.10.3",
1917
]
2018
license = "GPL-3.0-or-later"

skeliner/io.py

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
from typing import Iterable, List
55

66
import numpy as np
7-
import openctm
87
import trimesh
98

109
from .core import Skeleton, Soma, _bfs_parents
1110

1211
__all__ = [
1312
"load_mesh",
14-
"to_ctm",
1513
"load_swc",
1614
"to_swc",
1715
"load_npz",
@@ -21,40 +19,31 @@
2119
_META_KV = re.compile(r"#\s*([^:]+)\s*:\s*(.+)") # key: value
2220
_META_JSON = re.compile(r"#\s*meta\s+(\{.*\})") # single-line JSON
2321

24-
22+
2523
# ------------
2624
# --- Mesh ---
2725
# ------------
2826

2927
def load_mesh(filepath: str | Path) -> trimesh.Trimesh:
3028

3129
filepath = Path(filepath)
32-
33-
if filepath.suffix == ".ctm":
34-
try:
35-
mesh = openctm.import_mesh(filepath)
36-
mesh = trimesh.Trimesh(vertices=mesh.vertices, faces=mesh.faces, process=False)
37-
except AttributeError:
38-
# trimesh should work out-of-box for py>=3.12 on non-intel mac
39-
mesh = trimesh.load_mesh(filepath, process=False)
40-
else:
41-
mesh = trimesh.load_mesh(filepath, process=False)
42-
43-
return mesh
44-
45-
def to_ctm(mesh: trimesh.Trimesh, path: str | Path) -> None:
46-
path = Path(path)
47-
if path.suffix.lower() != ".ctm":
48-
mesh.export(path, file_type=path.suffix.lstrip("."))
49-
raise ValueError(
50-
f"Expected a .ctm file, got {path.suffix}. "
30+
if filepath.suffix.lower() == ".ctm":
31+
print(
32+
"CTM file detected. skeliner no longer bundles explicit OpenCTM "
33+
"support. Loading will fall back to trimesh’s limited reader.\n"
34+
"Full read/write support is still possible on compatible setups:\n"
35+
" • Python ≤ 3.11, x86-64 → pip install python-openctm\n"
36+
"Then load manually:\n"
37+
" import openctm, trimesh\n"
38+
" mesh = openctm.import_mesh(filepath)\n"
39+
" mesh = trimesh.Trimesh(vertices=mesh.vertices,\n"
40+
" faces=mesh.faces,\n"
41+
" process=False)\n"
5142
)
43+
44+
mesh = trimesh.load_mesh(filepath, process=False)
5245

53-
verts = mesh.vertices.astype(np.float32, copy=False)
54-
faces = mesh.faces.astype(np.uint32, copy=False)
55-
56-
ctm_mesh = openctm.CTM(verts, faces, None)
57-
openctm.export_mesh(ctm_mesh, path)
46+
return mesh
5847

5948
# -----------
6049
# --- SWC ---

tests/data/60427.ctm

-17.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)