Skip to main content

CPGEO — Control-Point Geometry for Closed Surfaces

Developed by Zenan Song

CPGEO represents a closed, genus-zero surface by a triangular control mesh and a map from the unit sphere to physical space. Each surface point is a weighted combination of nearby control points. Moving those controls changes the shape while preserving its reference coordinates. MorphOpt uses this representation to optimize the outer walls and internal cavities of pneumatic soft actuators.

Features

The C++20 kernel exposes a C99 interface and a NumPy-based Python class.

  • Surface construction from a closed control mesh, including spherical parameterization and control-point updates.
  • Surface evaluation at reference-sphere or UV coordinates, with positions, first and second UV derivatives, and sparse control-point weights.
  • Sampling and reconstruction with adaptive seed spacing, patch-based smoothing, and fixed control points.
  • Mirror and rotational symmetry with mesh previews and control-point correspondence between symmetric regions.
  • CAD export through bicubic B-spline patch fitting with a specified geometric tolerance and STEP solid export through Python OCP.

Quick Start

Install the platform wheel from PyPI:

python -m pip install cpgeo
# Optional STEP export
python -m pip install "cpgeo[step]"

For a source checkout, python -m pip install . invokes CMake through setup.py and installs the Python package together with the shared library. Source builds require a C++20 compiler; the Python build environment supplies CMake. Use python -m pip install -e ".[test,step]" for development. Editable installation also builds the native library into src/python/cpgeo/bin/.

Python calls the C99 interface through ctypes. Each wheel contains the native library for one OS and architecture and uses the py3-none-<platform> tag. The release workflow builds Linux x86-64/AArch64, Windows x86-64/ARM64, and macOS Intel/Apple Silicon wheels. Windows ARM64 artifacts are tested on Python 3.12 and 3.14; other platforms use Python 3.10, 3.12, and 3.14. Set CPGEO_LIBRARY to select an explicit development build.

from cpgeo import CPGEO, set_max_threads

set_max_threads(4)
with CPGEO.load("surface.npz") as surface:
    vertices, faces = surface.sample_mesh(seed_size=1.0, smoothing_sweeps=2)
    fit = surface.fit_spline_patches(tolerance=0.01, target_nodes=64)
    fit.write_step("surface.stp")

surface.save("surface.npz") writes a compressed archive containing control_points, cp_faces, and knot_influence_num. CPGEO.save and CPGEO.load support paths and binary streams. Loading also accepts legacy CPGEO and MorphOpt geometry archives and rebuilds the reference parameterization.

Python uses NumPy for C buffer layout and result ownership. Geometry operations run in the shared library. Use the native generator helpers for mirrors and cyclic rotations, including offset planes and arbitrary rotation axes.

from cpgeo import symmetry_mirror, symmetry_rotation

generators = [symmetry_mirror("xz"), symmetry_rotation("z", periods=6)]
result = surface.symmetry(generators, seed_size=1., apply=True)
primary, image, transform = result.relations.T
fixed_points = result.control_points[:result.fixed_count]

The default previews the stitched mesh. With apply=True, the surface snapshot also stores the correspondence and its shared table of 4 × 4 transformations. Each relation maps one primary control to its image using the indexed matrix.

The position tolerance uses model units. STEP export interprets coordinates as millimetres. The Python exporter loads cadquery-ocp on the first export, sews the fitted faces into a solid, and validates the temporary STEP file before replacing the destination. Native builds only require the geometry kernel's C++ toolchain.

The Python acceptance suite uses pytest and SciPy for independent numerical checks. To run the C99, C++ and Python suites, use

cmake -S tests -B build/acceptance -DCMAKE_BUILD_TYPE=Release
cmake --build build/acceptance --parallel
ctest --test-dir build/acceptance --output-on-failure
python -m pip install -e ".[test,step]"
python -m pytest -q tests/python

The suites check winding, fixed controls, serial and parallel sampling, symmetry correspondence, independent spline evaluation and STEP round trips. Acceptance test guide (Chinese)

Builds and Releases

pyproject.toml owns package metadata, dependencies, and the wheel matrix. setup.py connects setuptools to the CMake target; CMake owns native compilation and OpenMP discovery. GitHub Actions builds wheels from the source distribution, repairs runtime dependencies with auditwheel/delocate/delvewheel, and tests the installed wheels. Version tags trigger PyPI publication through Trusted Publishing.

python -m pip install build twine
python -m build
python -m twine check dist/*

Build and PyPI publication guide (Chinese) covers local builds, the platform matrix, TestPyPI, publisher configuration, and version tags. For a standalone native library and C header installation:

cmake -S . -B build/native -DCMAKE_BUILD_TYPE=Release
cmake --build build/native --config Release --parallel
cmake --install build/native --config Release --prefix ./build/install

Repository Layout

Path Contents
setup.py CMake-backed setuptools build and Python-independent platform wheel tags
pyproject.toml Package metadata, build dependencies, extras, and cibuildwheel configuration
.github/workflows/release.yml Native tests, six platform wheels, and PyPI/TestPyPI publication
CMakeLists.txt Shared-library target and standalone C SDK installation
include/cpgeo.h Public C99 interface, surface handles, options, and result types
src/cpgeo.cpp C99 adapter for the public header
src/cpp/include/ Internal C++ declarations for construction, mapping, reconstruction, and symmetry
src/cpp/include/types/ Shared kernel types; private stage data is nested in its owning class
src/cpp/src/ C++ translation units mirroring the kernel header tree
src/python/cpgeo/ NumPy surface class and typed C ABI bindings
tests/cpp/ C++ kernel tests, C99 interface tests, and geometric fixtures
tests/python/ Python binding and STEP round-trip tests
tests/packaging/ Wheel layout, native binary format, and installed-library checks
docs/releasing.md Source builds, platform wheels, and PyPI publication (Chinese)
docs/api.md C API reference with parameter types, array layouts, and ownership rules (Chinese)
docs/cpp_kernel.md Complete C++ kernel reference with per-type sections and a dedicated half-edge mesh chapter (Chinese)

Citation

For the geometric model and adaptive surface reconstruction used in soft robot shape optimization, please cite the following paper. IEEE Transactions on Robotics

@article{song2026continuum,
  author  = {Song, Zenan and Chen, Feifei and Gu, Guoying and Zhu, Xiangyang},
  title   = {Continuum Jacobian-Based Computational Morphogenesis for Soft Robotic Workspace Optimization},
  journal = {IEEE Transactions on Robotics},
  year    = {2026},
  volume  = {42},
  pages   = {3048--3068},
  doi     = {10.1109/TRO.2026.3716051}
}

Metadata

Release files for cpgeo 2.0.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 cpgeo 2.0.1
File Size Uploaded Provenance Actions
cpgeo-2.0.1.tar.gz 1.8 MB With provenance Details for cpgeo-2.0.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for cpgeo 2.0.1
File Actions
cpgeo-2.0.1-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details for cpgeo-2.0.1-py3-none-win_arm64.whl
cpgeo-2.0.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for cpgeo-2.0.1-py3-none-win_amd64.whl
cpgeo-2.0.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for cpgeo-2.0.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
cpgeo-2.0.1-py3-none-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.26+ ARM64, Linux glibc 2.28+ ARM64 Details for cpgeo-2.0.1-py3-none-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
cpgeo-2.0.1-py3-none-macosx_15_0_x86_64.whl Python 3 none macOS 15.0+ x86-64 Details for cpgeo-2.0.1-py3-none-macosx_15_0_x86_64.whl
cpgeo-2.0.1-py3-none-macosx_15_0_arm64.whl Python 3 none macOS 15.0+ ARM64 Details for cpgeo-2.0.1-py3-none-macosx_15_0_arm64.whl

Total release size: 5.3 MB

Release files / cpgeo-2.0.1.tar.gz

Download URL cpgeo-2.0.1.tar.gz
Size 1.8 MB
Tags Source
SHA-256 checksum
How to use checksums
b17a6c23b839565d89832017d4b0fafea47fe94a5799b042d44dd2198cce7b38
BLAKE2b-256 checksum
How to use checksums
9b0be709c98a8975a3e091fd8747cdb95cbce977978f2841cb1e6ec4ee1653cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

Release files / cpgeo-2.0.1-py3-none-win_arm64.whl

Download URL cpgeo-2.0.1-py3-none-win_arm64.whl
Size 990.2 kB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
395aa53a0dd8d18ec05a0ab60360ac9f66a5802c27bc3a0364668712d8a8e693
BLAKE2b-256 checksum
How to use checksums
6a8f59cbd8e7f320cb7eaa5d288ab9e4c4d60a1c838ecc23cb80631c07fb960c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

Release files / cpgeo-2.0.1-py3-none-win_amd64.whl

Download URL cpgeo-2.0.1-py3-none-win_amd64.whl
Size 710.1 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
9a98f58bf0ee84e51284302d8199496a532dc8a292dd9aa0f57dc79ed1aa7c35
BLAKE2b-256 checksum
How to use checksums
0c0969da8f59ec4248d14f65f628333c10a5a6505e8fb018f5f3de8a4623987b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

Release files / cpgeo-2.0.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL cpgeo-2.0.1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 430.1 kB
Tags Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
b904869d475571d0bf16504a8c97e79e74c6d759409915fe0e86bdffeb8dc509
BLAKE2b-256 checksum
How to use checksums
b293923a59b32d331ff009ebf1c913b5c95f736c485e7ec1bf480363eb6c403c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

Release files / cpgeo-2.0.1-py3-none-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

Download URL cpgeo-2.0.1-py3-none-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Size 395.7 kB
Tags Linux glibc 2.26+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
2fdfa8acf9b51cb6a4213b48b94020e24907fb6b74e8b097ce709a38c0018680
BLAKE2b-256 checksum
How to use checksums
a2dc996aa7445bf5394f5cdb51af98747b11a662412698aa8009e7253875ecae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

Release files / cpgeo-2.0.1-py3-none-macosx_15_0_x86_64.whl

Download URL cpgeo-2.0.1-py3-none-macosx_15_0_x86_64.whl
Size 552.0 kB
Tags Python 3 macOS 15.0+ x86-64
SHA-256 checksum
How to use checksums
bee1907918ceee4adc07406d5422cb63938b765131c51f623705e340f1520ae1
BLAKE2b-256 checksum
How to use checksums
1eb834de2e6c7166ff65865f33adb311e1b0ba3d92acad3edf34059db108a301
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

Release files / cpgeo-2.0.1-py3-none-macosx_15_0_arm64.whl

Download URL cpgeo-2.0.1-py3-none-macosx_15_0_arm64.whl
Size 483.7 kB
Tags Python 3 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
6cc2f27e6741f166d8c99140745ab3145f0f69f9eac66ba97812e2ea2d46b585
BLAKE2b-256 checksum
How to use checksums
57f74f6315c350fd04d491b8dff862765de053c2319fa24eb13f195f0ae52185
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

Security for cpgeo 2.0.1

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.

Full provenance

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for cpgeo-2.0.1.tar.gz

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 Dec 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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