Python bindings for CDT: C++ library for constrained Delaunay triangulation implemented with pybind11
If PythonCDT helped you please consider adding a star on GitHub. This means a lot to the authors 🤩
- Clone with submodules:
git clone --recurse-submodules https://github.com/artem-ogre/PythonCDT.git - Make sure packages from requirements.txt are available.
# build the wheel and install the package with pip
pip3 install .
# run tests
pytest ./cdt_bindings_test.pyimport numpy as np
import PythonCDT as cdt
t = cdt.Triangulation(cdt.VertexInsertionOrder.AUTO, cdt.IntersectingConstraintEdges.TRY_RESOLVE, 0.0)
t.insert_vertices(np.array([[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0]]))
t.insert_edges(np.array([[0, 3]], dtype=np.uintc))
t.erase_super_triangle()
vertices = t.vertices_array() # numpy array with fields 'x' and 'y'
triangles = t.triangles_array() # numpy array with fields 'vertices' and 'neighbors'
triangles["vertices"] # (T, 3) vertex indices into verticesvertices_array() and triangles_array() return copies. With copy=False they return read-only views of the
triangulation's memory without copying; a view is invalidated by any call that modifies the triangulation.
Triangulating releases the GIL, so separate triangulations can be built in parallel on Python threads.
One triangulation can be shared between threads: calls on it wait for each other.
Iterators (*_iter()) and copy=False views are not protected: don't use them while another thread modifies the triangulation.
Mozilla Public License, v. 2.0
- SioulisChris: fixing the tests on Windows