Skip to main content

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, the math_BFGS method is polyfilled and used in place of math_FRPR, as neither math_BFGS nor math_FRPR is usable in OCP due to the lack of math_Vector exposure. The intersect detection algorithm has been improved for both speed and reliability.
  • In the _solve() function of bspline_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 include clone_bspline and math_BFGS.
  • Modified curve_network_sorter.py, bspline_algorithms.py, and interpolate_curve_network.py to 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, the GeomConvert_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:

Siggel M. et. al. (2019), TiGL: An Open Source Computational Geometry Library for Parametric Aircraft Design

@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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ocp-gordon 0.3.1
File Size Uploaded
ocp_gordon-0.3.1.tar.gz 114.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ocp-gordon 0.3.1
File Interpreter ABI Platform
ocp_gordon-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 166.5 kB

Release files / ocp_gordon-0.3.1.tar.gz

Download URL ocp_gordon-0.3.1.tar.gz
Size 114.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e55e695fd421e4dc10fe91636e7f2fa376ad81572faaf74e7bbed4b78c7918b7
BLAKE2b-256 checksum
How to use checksums
35b266ed6601660648ad5bf84a571460cd57e9db4b28c6833c55e229211a418d
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 9, 2026.

Transparency log

Release files / ocp_gordon-0.3.1-py3-none-any.whl

Download URL ocp_gordon-0.3.1-py3-none-any.whl
Size 52.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5df14c38032dcca582ba788e53f8d2e8b39a646a5ea786a0309e8494b3061a81
BLAKE2b-256 checksum
How to use checksums
3edcffc8307cd048f4f1e28d95cff6fe694af74f2bae771af6da272701d9646a
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 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.9

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page