Skip to main content

Process, analyze and visualize N-dim, N-degree splines

Project description

splinepy

workflow PyPI version Binder

splinepy is a python library for splines of arbitrary dimensions and degrees. The library supports Bezier, Rational Bezier, BSpline and NURBS with fast and easy-to-use APIs.

Install guide

splinepy wheels are available for python3.8+ for MacOS, Linux, and Windows:

# including all optional dependencies
pip install "splinepy[all]"  # quotation marks required for some shells
# or
pip install splinepy

Of course, you can install it directly from the source. In addition to the aforementioned compilers, this requires a cmake3.16+. If you don't have cmake, the easiest way to install it would be: pip install cmake.

git clone git@github.com:tataratat/splinepy.git
cd splinepy
git submodule update --init --recursive
pip install -e .

Quick start

import splinepy
import numpy as np

# Initialize bspline with any array-like input
bspline = splinepy.BSpline(
    degrees=[2, 1],
    knot_vectors=[
        [0.0, 0.0, 0.0, 1.0, 1.0, 1.0],
        [0.0, 0.0, 1.0, 1.0],
    ],
    control_points=[
        [0.0, 0.0],  # [0, 0] (control grid index)
        [0.5, 0.0],  # [1, 0]
        [1.0, 0.0],  # [2, 0]
        [0.0, 1.0],  # [0, 1]
        [0.5, 1.0],  # [1, 1]
        [1.0, 1.0],  # [2, 1]
    ],
)

# We always store control points in 2D arrays with shape
# (total_number_of_control_points, physical_dimension).
# The indexing of the control grid is defined by iterating
# lower-indexed dimensions first. But if you prefer a
# grid-like structure, try
multi_index = bspline.multi_index
grid_cps = np.empty(bspline.control_points.shape)
grid_cps[multi_index[0, 0]] = [0.0, 0.0]
grid_cps[multi_index[1, 0]] = [0.5, 0.0]
grid_cps[multi_index[2, 0], 0] = 1.0
# which also supports ranges
grid_cps[multi_index[:, 0], 1] = 0.0
grid_cps[multi_index[:, 1], 1] = 1.0
grid_cps[multi_index[:, 1], 0] = [0.0, 0.5, 1.0]

assert np.allclose(bspline.control_points, grid_cps)

# Evaluate spline mapping.
# First, let's form parametric coordinate queries
queries = [
    [0.1, 0.2],  # first query
    [0.4, 0.5],  # second query
    [0.1156, 0.9091],  # third query
]
physical_coords = bspline.evaluate(queries)

# we can also execute this in parallel using multithread
# executions on c++ side (for heavy multi-queries scenarios)
physical_coords_parallel = bspline.evaluate(queries, nthreads=2)

# this holds
assert np.allclose(physical_coords, physical_coords_parallel)

You can also try splinepy online by clicking the Binder badge above!

Feature Summary

For details, please take a look at the documentation. Most of the functions are vectorized and capable of multithread executions.

Splines

Any type of spline is capable of:

  • computing spline mappings, derivatives, partial derivatives, jacobian, basis functions, basis function derivatives, basis function partial derivatives, and proximity (point inversion, nearest mapping search),
  • degree elevation,
  • extracting boundary splines, and
  • visualization (see visualizing with splinepy).

In addition to the common features, Bezier and Rational Bezier can:

  • add/multiply two splines,
  • split itself into multiple patches,
  • create derivative splines, and
  • compose an inner spline into an outer spline and compute its composition derivative

and BSpline and NURBS can:

  • reduce degrees,
  • insert and remove knots, and
  • extract bezier patches.

Some BSpline fitting routines from The NURBS Book:

  • curve interpolation/approximation
  • surface interpolation/approximation

Multipatch

Splinepy offers a common interface for multipatch geometries, i.e., geometries consisting of multiple, individual splines of arbitrary types. This concept is used for complex geometries and for Isogeometric Analysis. Multipatch objects have the following functionalities:

  • determine patch-interfaces automatically
  • identification of boundary faces
  • boundary assignment using different techniques, relying either on the boundary position or on the continuity in between patches
  • Boundary extraction

IO

Available in splinepy.io.

Formats Description
iges Loads/Exports splines from an IGES file
irit IRIT compatible format
json (Custom) easy-to-read format, supports base64 encoding
mfem MFEM compatible .mesh format. Supports structured multi-patch splines in controlpoints_cartesian and 2D single-patch splines
gismo GISMO compatible .xml format
npz Based on np.savez()
xml RWTH CATS spline format

Dependencies

The following are direct dependencies for splinepy. Please feel free to check out the repositories linked.

Package Description Python C++
pybind11 Binds c++ and python X X
SplineLib Main functionalities for BSplines and NURBS X
bezman Main functionalities for Beziers and rational Beziers X
napf Creates k-d trees that provide initial guess for proximity search. Wraps nanoflann X
numpy Fast array data storage and manipulation X
gustaf Conversion to mesh representation, visualization, and helpers X
scipy (Optional) Creates sparse matrices, where applicable X
cmake Platform independent build system for c++ implementations X
setuptools Build python package X
wheel Implementation of python binary packaging standard X X
cibuildwheel Builds and tests wheels on CI server X X

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

splinepy-0.0.51.tar.gz (1.9 MB view details)

Uploaded Source

Built Distributions

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

splinepy-0.0.51-cp312-cp312-win_amd64.whl (62.4 MB view details)

Uploaded CPython 3.12Windows x86-64

splinepy-0.0.51-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (35.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

splinepy-0.0.51-cp312-cp312-macosx_11_0_arm64.whl (34.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

splinepy-0.0.51-cp312-cp312-macosx_10_9_x86_64.whl (39.3 MB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

splinepy-0.0.51-cp311-cp311-win_amd64.whl (62.3 MB view details)

Uploaded CPython 3.11Windows x86-64

splinepy-0.0.51-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (34.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

splinepy-0.0.51-cp311-cp311-macosx_11_0_arm64.whl (34.6 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

splinepy-0.0.51-cp311-cp311-macosx_10_9_x86_64.whl (39.3 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

splinepy-0.0.51-cp310-cp310-win_amd64.whl (62.3 MB view details)

Uploaded CPython 3.10Windows x86-64

splinepy-0.0.51-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (34.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

splinepy-0.0.51-cp310-cp310-macosx_11_0_arm64.whl (34.6 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

splinepy-0.0.51-cp310-cp310-macosx_10_9_x86_64.whl (39.3 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

splinepy-0.0.51-cp39-cp39-win_amd64.whl (62.3 MB view details)

Uploaded CPython 3.9Windows x86-64

splinepy-0.0.51-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (34.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

splinepy-0.0.51-cp39-cp39-macosx_11_0_arm64.whl (34.6 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

splinepy-0.0.51-cp39-cp39-macosx_10_9_x86_64.whl (39.3 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

splinepy-0.0.51-cp38-cp38-win_amd64.whl (62.3 MB view details)

Uploaded CPython 3.8Windows x86-64

splinepy-0.0.51-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (34.8 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

splinepy-0.0.51-cp38-cp38-macosx_11_0_arm64.whl (34.6 MB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

splinepy-0.0.51-cp38-cp38-macosx_10_9_x86_64.whl (39.3 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

File details

Details for the file splinepy-0.0.51.tar.gz.

File metadata

  • Download URL: splinepy-0.0.51.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for splinepy-0.0.51.tar.gz
Algorithm Hash digest
SHA256 72cee0a8a200bc6be988162c27507a4d4d54551c37de0dcdbc463828651b34c5
MD5 6ca8493b25ba987ff824d96a30cb5d78
BLAKE2b-256 b260372cb3f7180b265cd5edb538a390674fbe9a9bcb9288b5e29c912f10fca2

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: splinepy-0.0.51-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 62.4 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for splinepy-0.0.51-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 70e8c834bea07e13904e217d7aa7101b435b8749ce40c45dc733750dd5ed2d38
MD5 567bf441919c2d45550ea12a10455ae5
BLAKE2b-256 fdc58cd9b24081a4b3924ca9e918f39b304b59bf4245ee9be2e6ffce9ceab74a

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for splinepy-0.0.51-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b8eb8254ab292c4edc0ce585e52956df3554d2cd06cb8f213cb8617b5abf53dd
MD5 f6486a2d9407b696e61770ac1c8572c5
BLAKE2b-256 df10b520996cd6b132820667a655e3d700f537f11a5d95f17282bf5809b0355c

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for splinepy-0.0.51-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bff0429a90765abcc9d8393751a643d028746ebd128a2e150b6cc48378426619
MD5 290c1e09a0acd46e40f946bd1e4650f3
BLAKE2b-256 7617c64dea37bab84daf6184865e3c725349df4ef30006f1042c38bd4af6082e

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for splinepy-0.0.51-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7040791591e6c8866e8df8f5f1a9fb7da3c6f483a93a0dafe3560dd1a3f652a7
MD5 62033d712f8b5dbabd35126b7544f9bc
BLAKE2b-256 443be2d4698c564cf3b0c818ba0e7fda49cdc43e64fe5a0c221b40a9c44389b0

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: splinepy-0.0.51-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 62.3 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for splinepy-0.0.51-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 070691e27319f95a02476043668d03894ac4cb5d9a3869dc54b74e2add5f2c19
MD5 47f2b6045ff8cbc6634ddcc32d435169
BLAKE2b-256 93986faa193681490cfb6092d35387793513e2ab5eb98c2d288da1c7c594f483

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for splinepy-0.0.51-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0a9cf6aeb9b3ea9a62d2026fd0d1cd0991068d7119322253ba90dd6b613e0a34
MD5 0d5c06454cb9234f5a8adab450c4c6c2
BLAKE2b-256 f3612c95698851b38c97b4f207926cc32aef4f47bc251f8ebb90f32979587057

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for splinepy-0.0.51-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dee7e8f9d8be7f6b0f22a7b6cfe330a3a0a709b209a3f8b363a66d5b1d1c8f79
MD5 34c43aae9d85549c2f43e756e50c070a
BLAKE2b-256 151ae29d170248ba44b9ccffe972f57d48066240a11bbe1722ec08e66a8d1dbb

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for splinepy-0.0.51-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b61a4833436d798c41f08c1d83e206f2031a88648a15fd9c7077ae493dc37625
MD5 28e6a5ba92508e8135c152fb21ccd53b
BLAKE2b-256 9b1e73b02e5d694114b8f5120541e60ea5b0213148bbed6b6a7e3b8fa034cd77

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: splinepy-0.0.51-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 62.3 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for splinepy-0.0.51-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d9689610356d5990be78fd0a0c2f5aeaf1a31763a5f87a6d4d5f3bb3819f4425
MD5 be5f6502f0c1797df046d697807065d2
BLAKE2b-256 a2a05a773ab782de688bcd3809218eee9178ed15d5d6f432bf148f1c951d706a

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for splinepy-0.0.51-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d96172252c8ca65fa8461df9157fdab0deb24067443b943bca6c04859d94fb6c
MD5 c6a275fd52047f155f50c4e1ee010fb7
BLAKE2b-256 8f5dc14d4b21b0def0f96a589b779de97e92621f67d01e1b824909bb7a32daa5

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for splinepy-0.0.51-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 463500e23f3a767ef274d6623070cadfe7de0a46bbcdb0d87c4aac1873a48afa
MD5 9ddddafd0d5593621f536a6d0756bc71
BLAKE2b-256 2a01fcee76807990bff88f9482199afbabd7da31b6740030da154a23b2331ef5

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for splinepy-0.0.51-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dd076f297beb81d2c66cd109e9c609941382b1f23bca8e1cc0ce712bbcef1c64
MD5 d718f2f0c52871f9877f1857290d166c
BLAKE2b-256 98d92807a12d3da48ce5831b3fe68eee4004f51d68fe17ad06840b3dfc30cc3d

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: splinepy-0.0.51-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 62.3 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for splinepy-0.0.51-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 25f8af773c83fcf8787fe53e9ec51c80d2a46af23377aa06f407972cb3730616
MD5 0063d68362b7c4ffdb62a9b169a2af90
BLAKE2b-256 488c280e132c2827ddd6dea031a7255f9f7ad8cd235bc2badc4f378a3f8c3b9e

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for splinepy-0.0.51-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e9e32d999be589fd2b5dc32c8da4daaec2afbc94e0f80c896df0a65b9847ed82
MD5 28319dc246d27262a7f16d8809560971
BLAKE2b-256 658e8d415dca36abd5979f92a1d16ae38a6cb8e6a4f68d61c92215d42638eaa8

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for splinepy-0.0.51-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 24acda3c3566a13731480173375de48c91a37f329ece142405fc8a92301ca03c
MD5 571761e567fa92d7840124e0589d2425
BLAKE2b-256 39aa25375b94ef0b22d7185d4cc78fd66ef449eebe2c06e551238e4ebd7c0264

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for splinepy-0.0.51-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 dc7156c828e60a364febd90a579a21c8cd3e1549140b3751f2f365db85f81b5b
MD5 b6939aa573231b66ea7e57114403ea7e
BLAKE2b-256 178179c03a2d7a639e631e6992d5778e905e77b7e43f381f76a03af94bd71171

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: splinepy-0.0.51-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 62.3 MB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for splinepy-0.0.51-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e1dd28347cd6ce8ba7edf7c820ec514bbf0c5b80711072436216544e020d0e83
MD5 d058beef09c0e27582598501cb5c025a
BLAKE2b-256 dabb44a8e8a9a94e2258e85e0828531f04fb67bbabf754a57010f55e87756672

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for splinepy-0.0.51-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8d20bc60c9d52af94fe86ae50bcfb4199413bf9e0bd0b55054605c24f85e9a59
MD5 6166a00118aa3f2d60e88d75a1fd3c37
BLAKE2b-256 224f9ec745c349f672520914bea89243551936f8813fe8fd7d5e4940610b07ed

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for splinepy-0.0.51-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fdee4d969bdc55691a388724cd31b72eb1c80c0a7218b3f3c3407d7179c2b1d2
MD5 5e97c423fcaa0f3ab377baa733c77cb7
BLAKE2b-256 e026f457e6af35455205da0982f9559aa9178ca6bf76cf4b81c82ceefa1bd483

See more details on using hashes here.

File details

Details for the file splinepy-0.0.51-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for splinepy-0.0.51-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1969e0245f098f4d7f55fd662e913b3cf1713fe90c676a1eae5a247838bc5814
MD5 7f5a0564fe0b0742a99cdb02f4b41e9d
BLAKE2b-256 603070964fba45c7f61ffe3a936b420edc51241d820da8333350c1a12cf8714a

See more details on using hashes here.

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