Skip to main content

Base classes for mesh fileloader plugins producing mesh-schema DataNode trees

Project description

vcti-fileloader-mesh

Base classes for mesh fileloader plugins producing mesh-schema DataNode trees.

Overview

vcti-fileloader-mesh is the shared base of the mesh loader family. A mesh format loader (SLIM, PLY, ...) differs from its siblings only in how it opens a file and enumerates its blocks; everything else — the subtree transaction, lazy-vs-eager attachment, schema guarantees, locking, and rollback — is identical. MeshLoaderBase implements that shared part once: subclasses provide can_load / load / unload plus a block_specs() that yields one MeshBlockSpec per block, and inherit a populate() that grafts a locked, mesh-schema-conforming subtree into any LockableTree. The result satisfies the vcti.fileloader.core.Loader protocol, so mesh loaders register and dispatch like every other fileloader plugin.

Installation

pip install vcti-fileloader-mesh

In requirements.txt

vcti-fileloader-mesh>=1.0.0

In pyproject.toml dependencies

dependencies = [
    "vcti-fileloader-mesh>=1.0.0",
]

Quick Start

A complete mesh format loader is the format-specific part only:

from pathlib import Path
from typing import Any

from vcti.fileloader.mesh import MeshBlockSpec, MeshLoaderBase

class MyMeshLoader(MeshLoaderBase):
    id = "mymesh-numpy-loader"

    def can_load(self, path: Path) -> bool:
        return path.suffix.lower() == ".mymesh"

    def load(self, path: Path, **options: Any):
        return open_my_format(path)          # opaque handle

    def unload(self, handle) -> None:
        handle.close()                        # idempotent

    def block_specs(self, handle, **options):
        for element in handle.header:         # cheap metadata only
            yield MeshBlockSpec(
                name=element.name,            # "node", "triangle", ...
                count=element.count,
                dtype=element.record_dtype,
                read=lambda e=element: handle.read_block(e),
            )

Using it is the standard fileloader lifecycle:

from vcti.fileloader.core import DataNode
from vcti.tree.core import DictTree

loader = MyMeshLoader()
tree = DictTree(root_data=DataNode())
with loader.open(Path("part.mymesh")) as handle:
    mesh_root = loader.populate(handle, tree, tree.root_handle)

Blocks attach lazily — nothing is read until a block's .load() — and the subtree is guaranteed to conform to the mesh schema's structure, so vcti.mesh.schema accessors and the mesh exporters consume it directly.


API surface

Name Kind Purpose
MeshLoaderBase ABC populate() template; subclasses add can_load/load/unload/block_specs
MeshLoaderBase.populate(handle, tree, parent, *, before_lock, lazy) method Attach a locked mesh subtree (lazy blocks by default)
MeshLoaderBase.root_attributes(handle) hook File-native attributes for the mesh root (default: none)
MeshLoaderBase.open(path) context manager load()/unload() pairing
MeshBlockSpec dataclass One block: name, count, dtype, read callable, attributes

See docs/design.md for the model and docs/extending.md for the full guide to writing a format loader.


Dependencies

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vcti_fileloader_mesh-1.0.0.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vcti_fileloader_mesh-1.0.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file vcti_fileloader_mesh-1.0.0.tar.gz.

File metadata

  • Download URL: vcti_fileloader_mesh-1.0.0.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vcti_fileloader_mesh-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c065b2f7e102e71f559ec8661651f027ad21357673709d8710cddf56b64b93e6
MD5 39ace946f471ab04964efdbd9d6934d4
BLAKE2b-256 8e434beb77dac18ea34ebc1a06a3898e805f087b033a7df61ea202189c21a0aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_fileloader_mesh-1.0.0.tar.gz:

Publisher: release.yml on vcollab/vcti-python-fileloader-mesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vcti_fileloader_mesh-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for vcti_fileloader_mesh-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fbe5feffb9adb199b1816b82c520860e8e273518c481d002d01034b1dc42413e
MD5 be72e5516f6e4f64780b3b8018db01ab
BLAKE2b-256 c5a12a8e9aa0de359e66155688d151a83cc5ede9792ac6ebfd5be5a5b7ecefc0

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_fileloader_mesh-1.0.0-py3-none-any.whl:

Publisher: release.yml on vcollab/vcti-python-fileloader-mesh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page