Skip to main content

A Python library for Gordon Surface interpolation using B-splines.

Project description

Gordon Surface Library for CadQuery's OCP

This library provides a Python implementation for creating Gordon surfaces, which are 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.

It is a pure Python library which is adapted from the original C++ code in occ_gordon

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

  • OCP (OpenCASCADE Python)
  • NumPy
  • SciPy

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=0.0003)

For more detailed examples, please refer to the examples/ directory in the source code.

Test

To run tests, first install pytest, then:

cd tests
python test_all.py

Notable Difference from C++ Code

  • In intersect_bsplines.py, a polyfilled math_BFGS is used instead of math_FRPR. Both math_BFGS and math_FRPR are not usable in OCP because OCP does not expose math_Vector. The activate() function in this file has also been changed since the original one does not work well. In IntersectBSplines function, first check if the intersection occurs at the end points before using 2d minimizer.
  • In the _solve() function in bspline_approx_interp.py, the regularization is added to prevent singular matrix which occurs in some cases for example when the input curve is a bspline converted from a circle.
  • A new file misc.py is added to implement some missing classes/functions from OCP. The major ones are clone_bspline and math_BFGS.

Caveats

  • In the IntersectBSplines function, the 2d minimizer does not work well when the number of profile/guides is high (>5). Increase the tolerance parameter in interpolate_curve_network can help.

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}
}

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

ocp_gordon-0.1.4.tar.gz (108.1 kB view details)

Uploaded Source

Built Distribution

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

ocp_gordon-0.1.4-py3-none-any.whl (48.3 kB view details)

Uploaded Python 3

File details

Details for the file ocp_gordon-0.1.4.tar.gz.

File metadata

  • Download URL: ocp_gordon-0.1.4.tar.gz
  • Upload date:
  • Size: 108.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ocp_gordon-0.1.4.tar.gz
Algorithm Hash digest
SHA256 53f2ccf5082523744ce794d0b9f779a5d55a320a10904af9a5dafebad0365de9
MD5 e7098dac7b994e824d6246f9946e1ba6
BLAKE2b-256 0e937af716fc1d0c21664399b59420e563e3c424ad575bbba711514584f7c82d

See more details on using hashes here.

Provenance

The following attestation bundles were made for ocp_gordon-0.1.4.tar.gz:

Publisher: release.yml on gongfan99/ocp_gordon

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

File details

Details for the file ocp_gordon-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: ocp_gordon-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 48.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ocp_gordon-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d3b7866f99e08a07289adea5e451490c792cb0b9307c2029609bab1e47e39de7
MD5 8f5a82550d6682ba066ddfe338882e2b
BLAKE2b-256 94868adc38870967bc1bb4916835e7306712891b1b2e0004ac65297c3f299cee

See more details on using hashes here.

Provenance

The following attestation bundles were made for ocp_gordon-0.1.4-py3-none-any.whl:

Publisher: release.yml on gongfan99/ocp_gordon

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