Metadata-Version: 2.2
Name: cascadio
Version: 0.0.18rc5
Summary: Convert STEP files to GLB using OpenCASCADE
Keywords: graphics,STEP,GLTF
Author-Email: Michael Dawson-Haggerty <mikedh@kerfed.com>
License: The MIT License (MIT)
         
         Copyright (c) 2024 Michael Dawson-Haggerty
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in all
         copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         SOFTWARE.
         
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Natural Language :: English
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
Project-URL: Homepage, https://github.com/trimesh/cascadio
Requires-Python: >=3.8
Provides-Extra: tests
Requires-Dist: pytest; extra == "tests"
Requires-Dist: trimesh; extra == "tests"
Requires-Dist: chardet; extra == "tests"
Requires-Dist: jsonschema; extra == "tests"
Description-Content-Type: text/markdown

# cascadio

A Python library which uses [OpenCASCADE](https://github.com/Open-Cascade-SAS/OCCT) to convert STEP files to a GLB file which can quickly be loaded by [trimesh](https://github.com/mikedh/trimesh) and other libraries.

The primary effort here is build and packaging using the wonderful work done recently on [scikit-build-core](https://github.com/scikit-build/scikit-build-core) and [cibuildwheel](https://github.com/pypa/cibuildwheel). The goal is to produce wheels that don't require users to build OpenCASCADE themselves.

This is *not* intended to be a full binding of OpenCASCADE like [OCP](https://github.com/CadQuery/OCP) or [PythonOCC](https://github.com/tpaviot/pythonocc-core). Rather it is intended to be an easy minimal way to load boundary representation files into a triangulated scene in Python. There are a few options for loading STEP geometry in the open-source ecosystem: GMSH, FreeCAD, etc. However nearly all of them use OpenCASCADE under the hood as it is pretty much the only open-source BREP kernel.



### Install

The primary goal of this project is building wheels so vanilla `pip` can be used:

```
pip install cascadio
```

Currently this works on non-MUSL flavors of Linux, Windows x64, and MacOS x64+ARM. You can check [PyPi](https://pypi.org/project/cascadio/#files) for current platforms.

### :warning: :warning: :warning: :warning:
PyPI has a size limit, and each release of this is large! We will *not* be keeping every release on PyPi (i.e. if we run out of space we delete versions) so be very careful pinning the version!

We'll keep the following versions as "LTS" style releases on PyPi:
```
pip install cascadio==0.0.13
```


### Motivation

A lot of analysis can be done on triangulated surface meshes that doesn't need the analytical surfaces from a STEP or BREP file. 

### Contributing

Developed on Linux which should build wheels locally with docker:
```bash
# Build wheels using cibuildwheel (builds OCCT inside container)
CIBW_BUILD="cp312-manylinux_x86_64" cibuildwheel --platform linux
```

For local development without docker:
```bash
# install build tools
uv pip install cmake ninja

# build OCCT to occt_cache/
uv run python scripts/build_occt.py

# source the env vars it writes
source occt_cache/env.sh

# install and test
uv pip install -e .
pytest tests/
```

#### Patching OCCT

When modifying OpenCASCADE source files:

```bash
# 1. Start with clean OCCT (reset any local changes)
git -C upstream/OCCT checkout -- .

# 2. Build OCCT (applies existing patches from patches/)
uv run python scripts/build_occt.py

# 3. Make your changes to OCCT source files
#    Edit files in upstream/OCCT/src/...

# 4. Regenerate the patch file from your changes
uv run python scripts/build_occt.py --build-patch

# 5. Rebuild OCCT with your changes
uv run python scripts/build_occt.py

# 6. Source env and test
source occt_cache/env.sh
uv pip install -e .
pytest tests/
```


### Future Work

Pull requests welcome! 

- Add passable parameters for options included in the RWGLTF writer.
- use in-memory data for input and output, i.e. `stepReader.ReadStream()` instead of a file name. Ideally the Python function signature would be:
  - `convert_to_glb(data: bytes, file_type: str, **parameters) -> bytes`
  - Currently using file names because it's easier. 
- Support IGES 
  - Investigate using OpenCASCADE "Advanced Data Exchange" for Parasolid `.x_b`/`.x_t` and JT `.jt` support.

