Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: CI

on:
push:
branches: [master]
pull_request:

# Cancel superseded runs on the same branch/PR
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-and-test:
name: ${{ matrix.os }} / Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10", "3.13"]

defaults:
run:
shell: bash

steps:
- name: Check out with submodules
uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install build and test dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build
python -m pip install -r requirements.txt

- name: Build the wheel
run: python -m build --wheel --outdir dist

- name: Install the built wheel
run: python -m pip install --no-index --find-links dist PythonCDT

- name: Run tests
run: pytest ./cdt_bindings_test.py

- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.os }}-py${{ matrix.python-version }}
path: dist/*.whl
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
.cache/*
.pytest_cache/
__pycache__/
.vscode/*
.idea/*
build/*
dist/*
*.egg-info/
cmake-build-*/*
python/.venv/*
.venv/*
Expand Down
2 changes: 1 addition & 1 deletion CDT
Submodule CDT updated 56 files
+2 −1 .clang-format
+99 −17 .github/workflows/ci_builds.yml
+33 −2 CDT/CMakeLists.txt
+15 −3 CDT/conanfile.py
+15 −18 CDT/extras/InitializeWithGrid.h
+4 −2 CDT/extras/VerifyTopology.h
+3 −3 CDT/include/CDT.h
+4 −0 CDT/include/CDT.hpp
+158 −58 CDT/include/CDTUtils.h
+8 −58 CDT/include/CDTUtils.hpp
+105 −46 CDT/include/KDTree.h
+2 −2 CDT/include/LocatorKDTree.h
+408 −53 CDT/include/Triangulation.h
+367 −230 CDT/include/Triangulation.hpp
+10 −5 CDT/src/CDT.cpp
+1 −1 CDT/tests/Catch2
+396 −3 CDT/tests/cdt.test.cpp
+44 −44 CDT/tests/expected/cdt__as-provided_ignore_all.txt
+44 −44 CDT/tests/expected/cdt__as-provided_resolve_all.txt
+44 −44 CDT/tests/expected/cdt__auto_ignore_all.txt
+44 −44 CDT/tests/expected/cdt__auto_resolve_all.txt
+10 −10 CDT/tests/expected/dont_flip_constraint_when_resolving_intersection__f64_as-provided_resolve_all.txt
+17 −17 CDT/tests/expected/gh_issue__as-provided_ignore_all.txt
+17 −17 CDT/tests/expected/gh_issue__as-provided_resolve_all.txt
+52 −52 CDT/tests/expected/guitar no box__f32_as-provided_ignore_all.txt
+52 −52 CDT/tests/expected/guitar no box__f32_as-provided_resolve_all.txt
+28 −28 CDT/tests/expected/guitar no box__f32_auto_ignore_all.txt
+28 −28 CDT/tests/expected/guitar no box__f32_auto_resolve_all.txt
+52 −52 CDT/tests/expected/guitar no box__f64_as-provided_ignore_all.txt
+52 −52 CDT/tests/expected/guitar no box__f64_as-provided_resolve_all.txt
+28 −28 CDT/tests/expected/guitar no box__f64_auto_ignore_all.txt
+28 −28 CDT/tests/expected/guitar no box__f64_auto_resolve_all.txt
+35 −35 CDT/tests/expected/kidney__as-provided_ignore_all.txt
+35 −35 CDT/tests/expected/kidney__as-provided_resolve_all.txt
+4 −4 CDT/tests/expected/kidney__auto_ignore_all.txt
+4 −4 CDT/tests/expected/kidney__auto_resolve_all.txt
+10 −10 CDT/tests/expected/overlapping constraints__f32_as-provided_ignore_all.txt
+10 −10 CDT/tests/expected/overlapping constraints__f32_as-provided_resolve_all.txt
+10 −10 CDT/tests/expected/overlapping constraints__f32_auto_ignore_all.txt
+10 −10 CDT/tests/expected/overlapping constraints__f32_auto_resolve_all.txt
+10 −10 CDT/tests/expected/overlapping constraints__f64_as-provided_ignore_all.txt
+10 −10 CDT/tests/expected/overlapping constraints__f64_as-provided_resolve_all.txt
+10 −10 CDT/tests/expected/overlapping constraints__f64_auto_ignore_all.txt
+10 −10 CDT/tests/expected/overlapping constraints__f64_auto_resolve_all.txt
+6 −6 CDT/tests/expected/points_on_constraint_edge__as-provided_ignore_all.txt
+6 −6 CDT/tests/expected/points_on_constraint_edge__as-provided_resolve_all.txt
+8 −8 CDT/tests/expected/triple-hanging-flipped__auto_ignore_all.txt
+8 −8 CDT/tests/expected/triple-hanging-flipped__auto_resolve_all.txt
+14 −0 CDT/tests/inputs/hang-duplicate-constraint-edge-tryresolve.txt
+198 −0 CDT/tests/inputs/issue-211.txt
+69 −0 CDT/tests/standards_check.cpp
+73 −28 docs/README.md
+4 −1 docs/doxygen-custom/doxygen-awesome/doxygen-awesome-sidebar-only.css
+690 −144 docs/doxygen-custom/doxygen-awesome/doxygen-awesome.css
+1 −1 visualizer/CMakeLists.txt
+138 −19 visualizer/main.cpp
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

project(
PythonCDT
VERSION 0.1.0
DESCRIPTION "Software surface data rasterizer library"
VERSION 1.4.5
DESCRIPTION "Python bindings for CDT: constrained Delaunay triangulation"
LANGUAGES CXX
)

Expand All @@ -19,5 +19,11 @@ target_include_directories(
PythonCDT PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
)
target_link_libraries(PythonCDT PRIVATE CDT::CDT)
# Exposed to Python as PythonCDT.__version__. setup.py passes the wheel
# version; fall back to the project version for plain CMake builds.
if(NOT DEFINED VERSION_INFO)
set(VERSION_INFO ${PROJECT_VERSION})
endif()
target_compile_definitions(PythonCDT PRIVATE VERSION_INFO=${VERSION_INFO})
# Use rasterizer as pre-compiled header for faster test-only re-compiles
#target_precompile_headers(PythonCDT PRIVATE include/rasterizer.h)
3 changes: 3 additions & 0 deletions cdt_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
#include <sstream>
#include <utility>

#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)

namespace py = pybind11;

using coord_t = double;
Expand Down
15 changes: 10 additions & 5 deletions cdt_bindings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ def test_constants() -> None:
assert cdt.NO_VERTEX == np.iinfo(np.uintc).max, "NO_VERTEX constant has wrong value"


def test_version() -> None:
"""Test that the version is passed in from the build system"""
assert cdt.__version__ != "dev", "Version was not passed in from the build system"


def test_V2d() -> None:
"""Test 2D vector"""
p = cdt.V2d(42, 42)
Expand Down Expand Up @@ -140,7 +145,7 @@ def test_triangulate_input_file() -> None:
with tempfile.TemporaryDirectory() as tmp_dir:
off_file = f"{tmp_dir}/cdt.off"
save_triangulation_as_off(t, off_file)
assert md5_checksum(off_file) == '5fb163a9f27ec6bdd05b7d5f2b23416c', "Wrong OFF file contents"
assert md5_checksum(off_file) == 'db59c00d9dad866781cd96779e5262b7', "Wrong OFF file contents"


def test_conform_to_edges() -> None:
Expand All @@ -149,7 +154,7 @@ def test_conform_to_edges() -> None:
t.insert_vertices(vv)
t.conform_to_edges(ee)
t.erase_outer_triangles_and_holes()
assert triangulation_md5_checksum(t) == 'df2503c614e2f98656038948b355b27e', "Wrong OFF file contents"
assert triangulation_md5_checksum(t) == 'b64cae39c91a55dd4e23a146eb7df0d3', "Wrong OFF file contents"


@pytest.mark.parametrize("vv", [[cdt.V2d(-1, 0), cdt.V2d(0, 0.5), cdt.V2d(1, 0), cdt.V2d(0, -0.5)],
Expand All @@ -161,7 +166,7 @@ def test_insert_vertices(vv) -> None:
assert len(t.vertices) == 7, "Wrong vertex count in triangulation"
assert len(t.triangles) == 9, "Wrong triangle count in triangulation"
assert len(t.fixed_edges) == 0, "Wrong fixed edge count in triangulation"
assert triangulation_md5_checksum(t) == 'c424c4f2691dc3b9aabd39dcf2e17c53', "Wrong OFF file contents"
assert triangulation_md5_checksum(t) == 'db9176f4429942862a7a73155fb55322', "Wrong OFF file contents"


@pytest.mark.parametrize("ee", [[cdt.Edge(0, 1), cdt.Edge(2, 3), cdt.Edge(3, 4), cdt.Edge(5, 6)],
Expand All @@ -175,7 +180,7 @@ def test_insert_conform_edges(ee) -> None:
assert len(t.vertices) == 10, "Wrong vertex count in triangulation"
assert len(t.triangles) == 15, "Wrong triangle count in triangulation"
assert len(t.fixed_edges) == 4, "Wrong fixed edge count in triangulation"
assert triangulation_md5_checksum(t) == '8424ba2c8f8ebabe1bea4141464a347b', "Wrong OFF file contents"
assert triangulation_md5_checksum(t) == '639c7a1492b2adb8f25464ec81ff6a00', "Wrong OFF file contents"

# conform to edges
t = cdt.Triangulation(cdt.VertexInsertionOrder.AS_PROVIDED, cdt.IntersectingConstraintEdges.NOT_ALLOWED, 0.0)
Expand All @@ -184,4 +189,4 @@ def test_insert_conform_edges(ee) -> None:
assert len(t.vertices) == 12, "Wrong vertex count in triangulation"
assert len(t.triangles) == 19, "Wrong triangle count in triangulation"
assert len(t.fixed_edges) == 6, "Wrong fixed edge count in triangulation"
assert triangulation_md5_checksum(t) == '9cb9dbaca4943ff0e3aab6c1d31f5a35', "Wrong OFF file contents"
assert triangulation_md5_checksum(t) == '9c87b435e247c1658ec0f04af3340dc7', "Wrong OFF file contents"
2 changes: 1 addition & 1 deletion pybind11
Submodule pybind11 updated 323 files
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ minversion = "6.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
filterwarnings = ["error"]
testpaths = ["tests"]
testpaths = ["cdt_bindings_test.py"]

[tool.cibuildwheel]
test-command = "pytest {project}/tests"
test-command = "pytest {project}/cdt_bindings_test.py"
test-extras = ["test"]
test-skip = ["*universal2:arm64"]
# Setuptools bug causes collision between pypy and cpython artifacts
Expand Down
55 changes: 43 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@ def build_extension(self, ext):
# Can be set with Conda-Build, for example.
cmake_generator = os.environ.get("CMAKE_GENERATOR", "")

# Set Python_EXECUTABLE instead if you use PYBIND11_FINDPYTHON
# EXAMPLE_VERSION_INFO shows you how to pass a value into the C++ code
# from Python.
# Both spellings are passed on purpose: pybind11 < 3 uses its own
# PYTHON_EXECUTABLE, while pybind11 >= 3 defaults to CMake's
# FindPython, which reads Python_EXECUTABLE. Passing only the former
# lets CMake pick an unrelated interpreter and build against the
# wrong Python headers.
# VERSION_INFO is passed into the C++ code and surfaces as
# PythonCDT.__version__.
cmake_args = [
f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}",
f"-DPYTHON_EXECUTABLE={sys.executable}",
f"-DPython_EXECUTABLE={sys.executable}",
f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm
]
build_args = []
Expand All @@ -56,9 +61,7 @@ def build_extension(self, ext):
cmake_args += [
item for item in os.environ["CMAKE_ARGS"].split(" ") if item]

# In this example, we pass in the version to C++. You might not need to.
cmake_args += [
f"-DEXAMPLE_VERSION_INFO={self.distribution.get_version()}"]
cmake_args += [f"-DVERSION_INFO={self.distribution.get_version()}"]

if self.compiler.compiler_type != "msvc":
# Using Ninja-build since it a) is available as a wheel and b)
Expand Down Expand Up @@ -123,18 +126,46 @@ def build_extension(self, ext):
)


# Explicit encoding: the README contains non-ASCII characters, which would
# fail to decode under the default locale on Windows.
with open(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "README.md"),
encoding="utf-8",
) as f:
long_description = f.read()

# The information here can also be placed in setup.cfg - better separation of
# logic and declaration, and simpler if you include description/version in a file.
setup(
name="PythonCDT",
version="0.0.1",
author="Leica Geosystems",
author_email="",
description="Test",
long_description="",
version="1.4.5",
author="Artem Amirkhanov",
description=(
"Python bindings for CDT: constrained Delaunay triangulation"
),
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/artem-ogre/PythonCDT",
project_urls={
"Source": "https://github.com/artem-ogre/PythonCDT",
"Issues": "https://github.com/artem-ogre/PythonCDT/issues",
"CDT": "https://github.com/artem-ogre/CDT",
},
license="MPL-2.0",
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Programming Language :: C++",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Multimedia :: Graphics :: 3D Modeling",
],
keywords="delaunay triangulation constrained cdt computational-geometry",
ext_modules=[CMakeExtension("PythonCDT")],
cmdclass={"build_ext": CMakeBuild},
zip_safe=False,
extras_require={"test": ["pytest>=6.0"]},
python_requires=">=3.6",
# pybind11 3.x supports Python 3.8 and newer
python_requires=">=3.8",
)
Loading