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

To build the shared library, run

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

Install the Python package from the repository with python -m pip install .. For the STEP example below, install the export dependency with python -m pip install ".[step]". The wheel build invokes CMake and includes the shared library. For development, PYTHONPATH=src/python uses the library built in build/native. Set CPGEO_LIBRARY to select a specific 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 surface.symmetry_mirror(plane="xz") or surface.symmetry_rotational(periods=4) to preview the mesh and correspondence. Pass apply=True to rebuild the surface. surface.snapshot() copies the control mesh, reference nodes, support radii, symmetry groups and construction options.

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
PYTHONPATH=src/python 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)

Repository Layout

Path Contents
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/ All kernel structs, including internal stage data, with one header per type
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
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.0

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.0
File Size Uploaded Provenance Actions
cpgeo-2.0.0.tar.gz 2.4 MB Without provenance Details for cpgeo-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cpgeo 2.0.0
File Interpreter ABI Platform Actions
cpgeo-2.0.0-py3-none-any.whl Python 3 none any Details for cpgeo-2.0.0-py3-none-any.whl

Total release size: 4.7 MB

Release files / cpgeo-2.0.0.tar.gz

Download URL cpgeo-2.0.0.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
fc29129e729ad0b299c3e749b81e7b08637e8d991d72e3c6039b745aaf4e0cbe
BLAKE2b-256 checksum
How to use checksums
afaf60e660be23d41d9ae597d83a7453d6981fe5c5f88cc6da3a6a45aeca6ca7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / cpgeo-2.0.0-py3-none-any.whl

Download URL cpgeo-2.0.0-py3-none-any.whl
Size 2.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
c6c4c577ce6102d59c5c4029c7de2b0658f42aa9d2322506791c4937c4caceb7
BLAKE2b-256 checksum
How to use checksums
addc1559187eb9414522dd81d2cafeb81ee0d5cf1f47f5ca4da7c1891cef91fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for cpgeo 2.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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