A Python library for Gordon Surface interpolation using B-splines.
Maintained. Last release 3 months ago, commits in 3 of the last 26 weeks. Weaker on commit activity and contributor spread.
pip install ocp-gordonGordon 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.