fabriks 2.0.0__tar.gz → 3.0.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.
- {fabriks-2.0.0 → fabriks-3.0.0}/PKG-INFO +4 -2
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/__init__.py +4 -3
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/build.py +2 -2
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/codecs/meshopt.py +8 -8
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/simplifiers/__init__.py +5 -4
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/simplifiers/meshopt.py +1 -1
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/simplifiers/registry.py +19 -5
- {fabriks-2.0.0 → fabriks-3.0.0}/pyproject.toml +9 -8
- {fabriks-2.0.0 → fabriks-3.0.0}/.gitignore +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/README.md +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/codecs/__init__.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/codecs/blobs.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/codecs/compression.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/codecs/protocol.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/codecs/raw.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/contrib/__init__.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/contrib/catalog.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/contrib/fit.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/contrib/gltf.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/contrib/meshes.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/contrib/obj.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/contrib/scene.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/errors.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/frames.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/geometry.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/manifest.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/octree.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/planner.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/py.typed +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/reader.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/simplifiers/greedy.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/simplifiers/measure.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/simplifiers/protocol.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/simplifiers/quadric.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/sizing.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/sources.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/stores/__init__.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/stores/access.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/stores/directory.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/stores/file.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/stores/memory.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/stores/protocol.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/verify.py +0 -0
- {fabriks-2.0.0 → fabriks-3.0.0}/fabriks/writer.py +0 -0
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: fabriks
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0
|
|
4
4
|
Summary: a level-of-detail mesh wire format: octree-partitioned surfaces written to any object store
|
|
5
5
|
Author-email: jhnnsrs <jhnnsrs@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
Requires-Python: >=3.11
|
|
8
8
|
Requires-Dist: fast-simplification>=0.1.7
|
|
9
|
-
Requires-Dist: meshoptimizer>=0.2.30a0
|
|
10
9
|
Requires-Dist: numpy>=1.26
|
|
11
10
|
Requires-Dist: pyarrow>=12
|
|
12
11
|
Requires-Dist: scipy>=1.11
|
|
13
12
|
Requires-Dist: shapely>=2.0
|
|
14
13
|
Requires-Dist: trimesh>=4.0
|
|
15
14
|
Provides-Extra: complete
|
|
15
|
+
Requires-Dist: meshoptimizer>=0.2.30a0; extra == 'complete'
|
|
16
16
|
Requires-Dist: obstore>=0.10; extra == 'complete'
|
|
17
|
+
Provides-Extra: meshopt
|
|
18
|
+
Requires-Dist: meshoptimizer>=0.2.30a0; extra == 'meshopt'
|
|
17
19
|
Provides-Extra: obstore
|
|
18
20
|
Requires-Dist: obstore>=0.10; extra == 'obstore'
|
|
19
21
|
Description-Content-Type: text/markdown
|
|
@@ -62,7 +62,8 @@ and mesh cells pulls the same regions.
|
|
|
62
62
|
Simplification
|
|
63
63
|
--------------
|
|
64
64
|
A coarse level is made by a pluggable backend, named the way a codec is: ``"MESHOPT"`` is the
|
|
65
|
-
default
|
|
65
|
+
default where ``meshoptimizer`` is installed (``fabriks[meshopt]``), ``"QUADRIC"`` otherwise.
|
|
66
|
+
MESHOPT locks exactly the vertices on this level's cell planes
|
|
66
67
|
and never repositions a vertex, so every survivor is at exactly its input position, which is what
|
|
67
68
|
makes ``boundary: LOCKED`` provable rather than intended. ``"QUADRIC"`` (``fast-simplification``)
|
|
68
69
|
moves interior vertices to the quadric-optimal shape but pins the whole topological boundary;
|
|
@@ -145,7 +146,6 @@ from fabriks.reader import (
|
|
|
145
146
|
open_collection,
|
|
146
147
|
)
|
|
147
148
|
from fabriks.simplifiers import (
|
|
148
|
-
SIMPLIFICATION_DEFAULT,
|
|
149
149
|
SIMPLIFICATION_GREEDY,
|
|
150
150
|
SIMPLIFICATION_MESHOPT,
|
|
151
151
|
SIMPLIFICATION_QUADRIC,
|
|
@@ -154,6 +154,7 @@ from fabriks.simplifiers import (
|
|
|
154
154
|
QuadricSimplifier,
|
|
155
155
|
Simplified,
|
|
156
156
|
Simplifier,
|
|
157
|
+
default_simplification,
|
|
157
158
|
simplifier_for,
|
|
158
159
|
)
|
|
159
160
|
from fabriks.sizing import (
|
|
@@ -198,7 +199,6 @@ __all__ = [
|
|
|
198
199
|
"POSITIONS_UINT16_QUANTIZED_PER_CELL",
|
|
199
200
|
"QUANT_MAX",
|
|
200
201
|
"REQUIRED_COLUMNS",
|
|
201
|
-
"SIMPLIFICATION_DEFAULT",
|
|
202
202
|
"SIMPLIFICATION_GREEDY",
|
|
203
203
|
"SIMPLIFICATION_MESHOPT",
|
|
204
204
|
"SIMPLIFICATION_QUADRIC",
|
|
@@ -252,6 +252,7 @@ __all__ = [
|
|
|
252
252
|
"decimate_fixed",
|
|
253
253
|
"decode_indices",
|
|
254
254
|
"decode_positions",
|
|
255
|
+
"default_simplification",
|
|
255
256
|
"encode_indices",
|
|
256
257
|
"encode_positions",
|
|
257
258
|
"level_part_path",
|
|
@@ -198,8 +198,8 @@ def build_collection(
|
|
|
198
198
|
state wrong, and this one is a fact about the bytes.
|
|
199
199
|
|
|
200
200
|
``simplifier`` is how a coarse level is made, and like ``codec`` it is a name out of a small
|
|
201
|
-
vocabulary: ``"MESHOPT"`` (the default -- exactly this level's cell
|
|
202
|
-
moved), ``"QUADRIC"`` (quadric-optimal shapes, the whole topological boundary pinned) or
|
|
201
|
+
vocabulary: ``"MESHOPT"`` (the default with ``fabriks[meshopt]`` -- exactly this level's cell
|
|
202
|
+
planes locked, no vertex moved), ``"QUADRIC"`` (the default without it ; quadric-optimal shapes, the whole topological boundary pinned) or
|
|
203
203
|
``"GREEDY"``. Pass an instance instead -- ``fabriks.GreedyEdgeCollapse(placement="onto_fixed")``
|
|
204
204
|
-- to adjust a backend's own settings, or your own object providing ``simplify``. See
|
|
205
205
|
:mod:`fabriks.simplifiers`. ``decimation`` is how much survives each level,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"""``codec: MESHOPT`` -- meshoptimizer's vertex and index codecs.
|
|
2
2
|
|
|
3
|
-
Trades a decoder on the reading side for size. ``meshoptimizer`` is
|
|
4
|
-
also backs ``simplification: MESHOPT``),
|
|
5
|
-
|
|
3
|
+
Trades a decoder on the reading side for size. ``meshoptimizer`` is the ``meshopt`` extra (it
|
|
4
|
+
also backs ``simplification: MESHOPT``), resolved only when a manifest actually asks for this
|
|
5
|
+
codec, so an install without it fails there with a message saying so.
|
|
6
6
|
|
|
7
7
|
The declared ``compression`` never reaches these methods: ``MESHOPT`` with ``ZSTD`` is refused
|
|
8
8
|
when the manifest is validated -- a compressed frame carries no reliable length and a meshopt
|
|
@@ -26,15 +26,15 @@ from fabriks.manifest import CODEC_MESHOPT, CODEC_NONE
|
|
|
26
26
|
STRIDE = 8
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
def require_meshoptimizer() -> Any: # noqa: ANN401
|
|
29
|
+
def require_meshoptimizer(what: str = f"`codec={CODEC_MESHOPT!r}`") -> Any: # noqa: ANN401
|
|
30
30
|
"""Import meshoptimizer, saying what asked for it when the install is missing it."""
|
|
31
31
|
try:
|
|
32
32
|
import meshoptimizer # type: ignore
|
|
33
|
-
except ImportError as error:
|
|
33
|
+
except ImportError as error:
|
|
34
34
|
raise MissingExtraError(
|
|
35
|
-
f"
|
|
36
|
-
f"
|
|
37
|
-
f"
|
|
35
|
+
f"{what} needs meshoptimizer, which is not installed: install `fabriks[meshopt]` (it builds from "
|
|
36
|
+
f"source, so it needs a C++ compiler). Without it the default simplifier is "
|
|
37
|
+
f"`simplifier='QUADRIC'` and the default codec `codec={CODEC_NONE!r}`, which need nothing."
|
|
38
38
|
) from error
|
|
39
39
|
return meshoptimizer
|
|
40
40
|
|
|
@@ -7,14 +7,15 @@ two-fold: hit a face budget (``decimation``), and leave the cut boundary exactly
|
|
|
7
7
|
Everything else about *how* is a choice, so the backend is named the way a codec is -- a value
|
|
8
8
|
out of a small vocabulary, resolved to an implementation -- rather than a hardcoded loop::
|
|
9
9
|
|
|
10
|
-
fabriks.build_collection(objects, cell_size=...) # MESHOPT,
|
|
10
|
+
fabriks.build_collection(objects, cell_size=...) # MESHOPT if installed, else QUADRIC
|
|
11
11
|
fabriks.build_collection(objects, cell_size=..., simplifier="GREEDY")
|
|
12
12
|
fabriks.build_collection(objects, cell_size=..., simplifier=fabriks.GreedyEdgeCollapse(placement="onto_fixed"))
|
|
13
13
|
|
|
14
14
|
Three backends ship:
|
|
15
15
|
|
|
16
16
|
``MESHOPT`` (:class:`~fabriks.simplifiers.meshopt.MeshoptSimplifier`)
|
|
17
|
-
The default, backed by
|
|
17
|
+
The default where it is installed (``fabriks[meshopt]``; it builds from source), backed by
|
|
18
|
+
`meshoptimizer <https://github.com/zeux/meshoptimizer>`_'s
|
|
18
19
|
``simplifyWithAttributes``. Its ``vertex_lock`` pins **exactly** the ``fixed`` mask -- this
|
|
19
20
|
level's cell planes -- and it never repositions a vertex, so every survivor keeps its exact
|
|
20
21
|
input position. That is the format's constraint stated directly, where ``QUADRIC`` can only
|
|
@@ -49,14 +50,13 @@ from fabriks.simplifiers.meshopt import SIMPLIFICATION_MESHOPT, MeshoptSimplifie
|
|
|
49
50
|
from fabriks.simplifiers.protocol import Simplified, Simplifier
|
|
50
51
|
from fabriks.simplifiers.quadric import SIMPLIFICATION_QUADRIC, QuadricSimplifier
|
|
51
52
|
from fabriks.simplifiers.registry import (
|
|
52
|
-
|
|
53
|
+
default_simplification,
|
|
53
54
|
resolve_simplifier,
|
|
54
55
|
simplifier_for,
|
|
55
56
|
simplify_to_target,
|
|
56
57
|
)
|
|
57
58
|
|
|
58
59
|
__all__ = [
|
|
59
|
-
"SIMPLIFICATION_DEFAULT",
|
|
60
60
|
"SIMPLIFICATION_GREEDY",
|
|
61
61
|
"SIMPLIFICATION_MESHOPT",
|
|
62
62
|
"SIMPLIFICATION_QUADRIC",
|
|
@@ -66,6 +66,7 @@ __all__ = [
|
|
|
66
66
|
"Simplified",
|
|
67
67
|
"Simplifier",
|
|
68
68
|
"boundary_held",
|
|
69
|
+
"default_simplification",
|
|
69
70
|
"measure_deviation",
|
|
70
71
|
"pinned_held",
|
|
71
72
|
"resolve_simplifier",
|
|
@@ -5,7 +5,7 @@ pins exactly the vertices in ``fixed`` and nothing else. :class:`~fabriks.simpli
|
|
|
5
5
|
can only say ``preserve_border``, which pins the whole topological boundary -- inherited level-0
|
|
6
6
|
seams included -- and so stalls short of the budget on a heavily cut object.
|
|
7
7
|
|
|
8
|
-
meshoptimizer is
|
|
8
|
+
meshoptimizer is the ``meshopt`` extra of fabriks, and it is reached through the binding's private loader,
|
|
9
9
|
so it is resolved on the first simplify rather than on ``import fabriks``: a reader that never
|
|
10
10
|
builds a collection never touches it.
|
|
11
11
|
"""
|
|
@@ -1,26 +1,38 @@
|
|
|
1
1
|
"""Which backend a name selects, and the retry policy every backend is driven through.
|
|
2
2
|
|
|
3
3
|
``simplification`` is a *value*, the way ``codec`` is: a name from a vocabulary the format
|
|
4
|
-
defines, resolved to an implementation here. ``MESHOPT`` is the default
|
|
4
|
+
defines, resolved to an implementation here. ``MESHOPT`` is the default where meshoptimizer is
|
|
5
|
+
installed (the ``meshopt`` extra), ``QUADRIC`` otherwise. Adding a backend is a
|
|
5
6
|
module beside this one and an entry in the table -- and passing an instance stays available for
|
|
6
7
|
the cases where the defaults need adjusting.
|
|
7
8
|
"""
|
|
8
9
|
|
|
9
10
|
from __future__ import annotations
|
|
10
11
|
|
|
12
|
+
import importlib.util
|
|
11
13
|
from typing import Any
|
|
12
14
|
|
|
13
15
|
import numpy as np
|
|
14
16
|
import numpy.typing as npt
|
|
15
17
|
|
|
18
|
+
from fabriks.codecs.meshopt import require_meshoptimizer
|
|
16
19
|
from fabriks.errors import FormatError
|
|
17
20
|
from fabriks.simplifiers.greedy import SIMPLIFICATION_GREEDY, GreedyEdgeCollapse
|
|
18
21
|
from fabriks.simplifiers.meshopt import SIMPLIFICATION_MESHOPT, MeshoptSimplifier
|
|
19
22
|
from fabriks.simplifiers.protocol import Simplified, Simplifier
|
|
20
23
|
from fabriks.simplifiers.quadric import SIMPLIFICATION_QUADRIC, QuadricSimplifier
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
|
|
26
|
+
def default_simplification() -> str:
|
|
27
|
+
"""The backend used when none is named.
|
|
28
|
+
|
|
29
|
+
``MESHOPT`` -- the one that pins exactly the cell planes and no more -- where meshoptimizer is
|
|
30
|
+
installed (``fabriks[meshopt]``); ``QUADRIC`` otherwise. meshoptimizer is an extra because it
|
|
31
|
+
ships as source only, and a mesh collection should not need a compiler to be built.
|
|
32
|
+
"""
|
|
33
|
+
if importlib.util.find_spec("meshoptimizer") is not None:
|
|
34
|
+
return SIMPLIFICATION_MESHOPT
|
|
35
|
+
return SIMPLIFICATION_QUADRIC
|
|
24
36
|
|
|
25
37
|
#: Every backend that ships, keyed by the ``simplification`` value that selects it.
|
|
26
38
|
_SIMPLIFIERS: dict[str, type[Simplifier]] = {
|
|
@@ -43,6 +55,8 @@ def simplifier_for(simplification: str) -> Simplifier:
|
|
|
43
55
|
raise FormatError(
|
|
44
56
|
f"`simplification` is {simplification!r}; fabriks ships {', '.join(sorted(_SIMPLIFIERS))}."
|
|
45
57
|
) from None
|
|
58
|
+
if simplification == SIMPLIFICATION_MESHOPT:
|
|
59
|
+
require_meshoptimizer(f"`simplifier={SIMPLIFICATION_MESHOPT!r}`")
|
|
46
60
|
return factory()
|
|
47
61
|
|
|
48
62
|
|
|
@@ -53,7 +67,7 @@ def resolve_simplifier(simplifier: Any) -> Simplifier: # noqa: ANN401
|
|
|
53
67
|
vocabulary, or an instance they have configured themselves.
|
|
54
68
|
"""
|
|
55
69
|
if simplifier is None:
|
|
56
|
-
return simplifier_for(
|
|
70
|
+
return simplifier_for(default_simplification())
|
|
57
71
|
if isinstance(simplifier, str):
|
|
58
72
|
return simplifier_for(simplifier)
|
|
59
73
|
if not hasattr(simplifier, "simplify"):
|
|
@@ -105,7 +119,7 @@ def simplify_to_target(
|
|
|
105
119
|
|
|
106
120
|
|
|
107
121
|
__all__ = [
|
|
108
|
-
"
|
|
122
|
+
"default_simplification",
|
|
109
123
|
"resolve_simplifier",
|
|
110
124
|
"simplifier_for",
|
|
111
125
|
"simplify_to_target",
|
|
@@ -8,8 +8,8 @@ readme = "README.md"
|
|
|
8
8
|
license = "MIT"
|
|
9
9
|
# fabriks builds mesh collections, so everything that takes part in building one is a
|
|
10
10
|
# dependency rather than an extra. `trimesh` cuts a mesh at the cell planes and
|
|
11
|
-
# `
|
|
12
|
-
#
|
|
11
|
+
# `fast-simplification` makes the coarse levels (QUADRIC); reaching a remote store and the
|
|
12
|
+
# MESHOPT simplifier and codec are optional.
|
|
13
13
|
#
|
|
14
14
|
# scipy and shapely are named because trimesh does not require them and the clipper does.
|
|
15
15
|
# trimesh hard-depends on numpy alone -- both of these sit in its `easy` extra -- while
|
|
@@ -23,18 +23,19 @@ dependencies = [
|
|
|
23
23
|
"scipy>=1.11",
|
|
24
24
|
"shapely>=2.0",
|
|
25
25
|
"fast-simplification>=0.1.7",
|
|
26
|
-
# The MESHOPT simplifier declares `meshopt_simplifyWithAttributes` with its `vertex_lock`
|
|
27
|
-
# argument itself (the binding leaves it undeclared), so the bundled library must have it.
|
|
28
|
-
# Every published binding is a pre-release, hence the pre-release floor. It also provides
|
|
29
|
-
# `codec: MESHOPT`.
|
|
30
|
-
"meshoptimizer>=0.2.30a0",
|
|
31
26
|
]
|
|
32
27
|
|
|
33
28
|
[project.optional-dependencies]
|
|
34
29
|
# Writing to S3 (or anywhere else obstore reaches). fabriks only needs three methods off a
|
|
35
30
|
# store, so this is for callers who want one rather than a directory.
|
|
36
31
|
obstore = ["obstore>=0.10"]
|
|
37
|
-
|
|
32
|
+
# `simplification: MESHOPT` (the default when it is installed) and `codec: MESHOPT`. An extra
|
|
33
|
+
# because PyPI ships meshoptimizer as source only: installing it needs a C++ compiler, which a
|
|
34
|
+
# slim image does not have. The MESHOPT simplifier declares `meshopt_simplifyWithAttributes`
|
|
35
|
+
# with its `vertex_lock` argument itself (the binding leaves it undeclared), so the bundled
|
|
36
|
+
# library must have it; every published binding is a pre-release, hence the pre-release floor.
|
|
37
|
+
meshopt = ["meshoptimizer>=0.2.30a0"]
|
|
38
|
+
complete = ["obstore>=0.10", "meshoptimizer>=0.2.30a0"]
|
|
38
39
|
|
|
39
40
|
[tool.uv]
|
|
40
41
|
dev-dependencies = [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|