Gordon Surface Library for CadQuery's OCP
This library provides a Python implementation for creating Gordon surfaces, a method for interpolating a network of curves to generate a smooth surface. It is designed to be compatible with CadQuery's OCP and leverages B-spline mathematics.
The implementation is written entirely in Python and is adapted from the original C++ code in occ_gordon
It is currently used by build123d, but can also be used independently.
Features
- Gordon surface interpolation from profile and guide curves.
- Compatibility with B-spline representations.
- Integration with CadQuery's OCP (OpenCASCADE Python) for geometric primitives.
Installation
This package can be installed using pip.
pip install ocp_gordon
Dependencies
- CadQuery OCP 8.x (
cadquery-ocp-novtk) - NumPy
- SciPy
The OCP 8 bindings expose typed arrays through OCP.collections (for example,
Array1_gp_Pnt, Array2_gp_Pnt, Array1_double, and Array1_int). Array
elements are read with .Value(...) and written with SetValue(...).
Usage
Here's a basic example of how to use the library:
# Assume you have profile_curves and guide_curves defined as lists of B-spline objects
# profile_curves = [...] # List of Geom_BSplineCurve objects
# guide_curves = [...] # List of Geom_BSplineCurve objects
from ocp_gordon import interpolate_curve_network
gordon_surface = interpolate_curve_network(profile_curves, guide_curves, tolerance=3e-4)
For more detailed examples, please refer to the examples/ directory in the source code.
Test
To run tests, first install pytest, then:
python -m pytest
Notable Difference from C++ Code
- In
intersect_bsplines.py, themath_BFGSmethod is polyfilled and used in place ofmath_FRPR, as neithermath_BFGSnormath_FRPRis usable in OCP due to the lack ofmath_Vectorexposure. The intersect detection algorithm has been improved for both speed and reliability. - In the
_solve()function ofbspline_approx_interp.py, regularization has been added to prevent singular matrix issues, which can occur in cases such as when the input curve is a B-spline derived from a circle. - A new file,
misc.py, has been introduced to implement missing OCP utilities. The primary additions includeclone_bsplineandmath_BFGS. - Modified
curve_network_sorter.py,bspline_algorithms.py, andinterpolate_curve_network.pyto allow a single point to be used as either a profile or a guide. - The reparameterization process is now skipped if the input profiles and guides are already iso-parametric, improving accuracy and performance for such cases.
- In
bspline_algorithms.py, theGeomConvert_ApproxCurve()function is utilized for improved representation of conic curves.
Caveats
Potential misalignments can occur between the generated Gordon surface and its input curves, especially at boundaries. This is primarily due to the approximation involved in the reparameterization process for non-iso-parametric inputs. For a detailed explanation and mitigation strategies, please refer to the Gordon Surface Misalignment wiki page.
License
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
Citing
The algorithm was originally described in:
@article{siggel2019tigl,
title={TiGL: an open source computational geometry library for parametric aircraft design},
author={Siggel, Martin and Kleinert, Jan and Stollenwerk, Tobias and Maierl, Reinhold},
journal={Mathematics in Computer Science},
volume={13},
number={3},
pages={367--389},
year={2019},
publisher={Springer},
doi={10.1007/s11786-019-00401-y}
}
Metadata
Release files for ocp-gordon 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ocp_gordon-0.3.0.tar.gz | 114.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ocp_gordon-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 166.4 kB
Release files / ocp_gordon-0.3.0.tar.gz
| Download URL | ocp_gordon-0.3.0.tar.gz |
|---|---|
| Size | 114.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
220f1ee6af6e40688b7a66044af839e328f59509ecfb1f87e4197bd4ab84ed80
|
|
BLAKE2b-256 checksum How to use checksums |
61485d9a25dae403a11c19e79c9c0b356bc16db5d608a9203731ad13a32b58a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.
Transparency logRelease files / ocp_gordon-0.3.0-py3-none-any.whl
| Download URL | ocp_gordon-0.3.0-py3-none-any.whl |
|---|---|
| Size | 52.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d90477bea04a9a6fbb78590a04ffde50da8d9ce853c9dce3e9e03eda5615b6f
|
|
BLAKE2b-256 checksum How to use checksums |
1a869d3997995e3a2cbfe36a000dc511a49059444b6aa007fc575459d4dbbd2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.
Transparency log