Repository navigation
libcvc drops CGAL: nanoflann replaces its GPL Spatial Searching uses - #1080
Merged
Merged
Conversation
CGAL's Spatial Searching package is GPL-3+, and it was libcvc's only CGAL use: - nav/spatial.cpp (neighbors_within_radius) used Kd_tree + Fuzzy_sphere; - geometry/project_verts.h (geometry::project without libigl) used K_neighbor_search. Both now use nanoflann 2.0.1 (BSD-2-Clause), vendored unchanged as a private header in src/cvc/third_party/nanoflann. It has no mutable static state and builds wherever libcvc does, wasm included. neighbors_within_radius keeps its contract exactly: self excluded, indices ascending, inclusive dx*dx + dy*dy <= r*r. nanoflann's radius test is exclusive, so it queries a hair wider and filters exactly. The naive O(N^2) DISABLE_CGAL fallback is gone, so wasm gets the k-d tree too. project_verts becomes cvc::project_points_to_triangles in project_verts.cpp, with the old iterator template kept as a wrapper. It computes the exact closest point (Ericson 5.1.5) on every triangle that uses one of the k nearest vertices. The old edge fallback clamped with max(1, min(0, r)), which is always 1, so a point past an edge went to the edge's end vertex. geometry::project now works without libigl in every build, not only CGAL builds. With no CGAL left: - cvc no longer links CGAL::CGAL, and through it GMP and MPFR; - cvcConfig.cmake no longer finds CGAL; - the unused FindCGAL/SetupCGAL modules are deleted; - DISABLE_CGAL is accepted and ignored, so existing scripts still configure; - the libcvc and libcvc-cuda recipes drop cgal, gmp and mpfr. Tests: - NavSpatial: exact-boundary (3-4-5 lattice) and duplicate points at r = 0, 1, sqrt(2), 5; empty and single-point input. - ProjectVerts: each Voronoi region of a triangle, including the edge case the old clamp got wrong; a cube against a brute-force oracle; degenerate triangles; free vertices, non-finite points, bad indices, k = 0; the legacy wrapper; two threads at once equal to sequential. - geometry::project's bunny test is no longer CGAL-gated. - system_macro_headers_test now includes project_verts.h.
tools/cgal_ab/cgal_ab.cpp runs each permissive replacement beside the CGAL code it replaced, on the same deterministic inputs: - nav::neighbors_within_radius against CGAL's Kd_tree + Fuzzy_sphere, as nav/spatial.cpp had it. The neighbour lists must be identical, on uniform, lattice (exact boundary distances) and clustered points with duplicates. - project_points_to_triangles against CGAL's exact AABB_tree::closest_point. No point may land closer than exact, and distances must match exactly when every triangle is a candidate. With the default k = 10 it reports how often the nearest-vertex heuristic is exact and by how much it misses: on a UV sphere (random and near-surface points) and a sliver strip. It prints TIME lines for both sides. It links CGAL, so as built it is GPL-3+. It is never installed or packaged, and it builds only with -DCVC_BUILD_CGAL_AB=ON. ci.yml's new cgal-ab job builds a minimal libcvc with it on ubuntu-24.04 (boost, pegtl, cgal, gmp, mpfr from cvcpkg) when the compared code changes. The output goes to the job summary. Run locally on Windows (MSVC 14.38, CGAL 6.0.1), all pass: - neighbours identical in all 15 cases, nanoflann 1.1-2.1x faster; - projection with k = 10 exact on all 3,000 sphere queries (random and near-surface) and 2,000 sliver-strip queries, to 1e-15, 1.1-2.6x faster than CGAL's AABB tree, build included.
transfix
added a commit
that referenced
this pull request
Nov 9, 2026
…r the app, CGAL A/B Joe's answers to the second revision: - No GPL code. Permissive libraries replace every GPL CGAL package the ports use, so there is no cvc_gpl library and no -gpl package: - reentrant Qhull for 3D Delaunay; - Clipper2 for Booleans, offsets and Minkowski sums; - CDT for constrained Delaunay; - Boost.Polygon's segment Voronoi for the medial axis; - Shewchuk's predicates and Eigen. CGAL's licence facts come from its package overview. Geogram is rejected for its process-wide init singletons. libcvc's own CGAL use is gone in #1080. - Wasm from the first PR of every phase (new section 1.8, T14). cy-pca/cvcpkg#578 adds qhull wasm/wasm-mt and a clipper2 recipe. A local emsdk smoke under node checked both, plus CDT. Qhull runs as "d Qbb Qt Qz", since QJ adds slivers and seeds from the clock. - Everything under an app: section 1.3 now holds the audit of libcvc's process-wide state: - 152 mutable objects, 31 of them locks, and 63 thread_locals; - three real bugs (duplicated I/O handlers per app, registries bound to the last app, stale app*-keyed tables); - what P0a does with each group. P0a becomes XL and comes before the ports. - An A/B of every replacement against the CGAL code it replaces: the tools/cgal_ab harness from #1080, with its results, and T16. - VolumeGridRover keeps the legacy XY/XZ/ZY switch (m_SliceCanvasTab) as the default layout, with quad as the other. The skeleton is a mesh_lab request again, and Tile is direct in volume_grid. - GenSeg's default seeding is settled as recommended. Section 9 now holds the library arrival (done), ContourTiler parity, the 4.0 API break, names, and what may stay process-wide.
Linking CGAL::CGAL PUBLIC put CGAL_setup_CGAL_flags on cvc's interface, so every target that links cvc inherited them. Dropping CGAL dropped them, and recipe / windows-2022 / Release failed: ariadne_runtime_test.cpp: fatal error C1128: number of sections exceeded object file format limit: compile with /bigobj cvc now sets the same flags itself, PUBLIC as before, so this PR changes no build flag and no floating-point behaviour: - MSVC: /bigobj, /fp:strict, /fp:except-, _SCL_SECURE_NO_DEPRECATE and _SCL_SECURE_NO_WARNINGS. - GCC: -frounding-math. Whether libcvc wants strict floating point for its own sake is a separate question. Checked locally: ariadne_runtime_test.cpp compiles with /bigobj back in build.ninja.
transfix
enabled auto-merge (squash)
November 9, 2026 03:37
transfix
added a commit
that referenced
this pull request
Nov 9, 2026
…gletons, state tree, intrinsics, tests (#1074) * docs(roadmap): VolumeRover ports: GPL library, no singletons, state tree, intrinsics, tests Adds the rules every port follows (sections 1.2-1.7): - the GPL-licensed parts (Skeletonization, ContourTiler: their CGAL packages are GPL) go in cvc_gpl / cvcgl_gpl / pycvc_gpl, never linked by libcvc, enforced with CGAL_LICENSE_ERROR and an OFF lane; - no singletons, with a per-port inventory, per-app forms of the process-wide node-type, intrinsic and I/O handler registries, and an object-file scan in CI; - one API shape SWIG wraps directly, with result_job<R> owning its result; - every parameter declared once in a param_table that drives state keys, properties, CLI flags, Python keywords and DSL dicts; bulk data on the data channel, and GPL nodes reading LGPL nodes' data through it; - DSL async intrinsics per port; - a 14-row test matrix per port. Phases gain P0a-c; decision 1 is settled and the open list is revised. * docs(roadmap): no GPL at all, wasm from the start, all of libcvc under the app, CGAL A/B Joe's answers to the second revision: - No GPL code. Permissive libraries replace every GPL CGAL package the ports use, so there is no cvc_gpl library and no -gpl package: - reentrant Qhull for 3D Delaunay; - Clipper2 for Booleans, offsets and Minkowski sums; - CDT for constrained Delaunay; - Boost.Polygon's segment Voronoi for the medial axis; - Shewchuk's predicates and Eigen. CGAL's licence facts come from its package overview. Geogram is rejected for its process-wide init singletons. libcvc's own CGAL use is gone in #1080. - Wasm from the first PR of every phase (new section 1.8, T14). cy-pca/cvcpkg#578 adds qhull wasm/wasm-mt and a clipper2 recipe. A local emsdk smoke under node checked both, plus CDT. Qhull runs as "d Qbb Qt Qz", since QJ adds slivers and seeds from the clock. - Everything under an app: section 1.3 now holds the audit of libcvc's process-wide state: - 152 mutable objects, 31 of them locks, and 63 thread_locals; - three real bugs (duplicated I/O handlers per app, registries bound to the last app, stale app*-keyed tables); - what P0a does with each group. P0a becomes XL and comes before the ports. - An A/B of every replacement against the CGAL code it replaces: the tools/cgal_ab harness from #1080, with its results, and T16. - VolumeGridRover keeps the legacy XY/XZ/ZY switch (m_SliceCanvasTab) as the default layout, with quad as the other. The skeleton is a mesh_lab request again, and Tile is direct in volume_grid. - GenSeg's default seeding is settled as recommended. Section 9 now holds the library arrival (done), ContourTiler parity, the 4.0 API break, names, and what may stay process-wide.
transfix
added a commit
that referenced
this pull request
Nov 10, 2026
Joe, 2026-11-09: "dont vendor third party libraries in the libcvc repo!! make cvcpkg packages for them". The vendored src/cvc/third_party/CDT and shewchuk/ are gone; both are now cvcpkg packages (cy-pca/cvcpkg#597, open), as Qhull and Clipper2 already were (cy-pca/cvcpkg#578): - cdt 2.0.1 (CDT::CDT, #include <CDT/CDT.h>), with the same no-mutable-statics changes as a recipe patch; - shewchuk-predicates (Shewchuk::predicates, #include <shewchuk/predicates.hpp>), the same generated header, its generator in cvcpkg's third-party/shewchuk-predicates. CVC_WITH_CDT and CVC_WITH_SHEWCHUK find them like Qhull and Clipper2 (OFF when missing). cvc links the two header-only ones $<BUILD_INTERFACE:...>, as it links PEGTL, so they never reach its exports. permissive_libs_test runs each section whose package is present and prints SKIP otherwise. cgal_ab_test needs all four. CI: cgal-ab and permissive-wasm fetch #597's head (which includes #578) and let cvcpkg build whatever the catalog lacks from those recipes (--fallback-to-source), until the packages are published. libcvc's recipe gains them once published (install-deps is all-or-nothing). The roadmap's rule (1.2), 1.8, the P0c row and 9 item 1 now say: cvcpkg packages, never vendored. #597 also adds nanoflann 2.0.1, so the vendored nanoflann (#1080) can go once it is published; THIRD_PARTY_NOTICES and the third_party README say so. Checked locally against the packages as #597's scripts install them (Windows, MSVC 19.44): all four found, permissive_libs_test 19/19, cgal_ab_test ok, 0 failures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
libcvc's only CGAL use was the Spatial Searching package, which is GPL-3+, in two places:
nav/spatial.cpp:neighbors_within_radius, built onKd_tree+Fuzzy_sphere;geometry/project_verts.h:geometry::projectwithout libigl, built onK_neighbor_search.Both now use nanoflann 2.0.1 (BSD-2-Clause). It is vendored unchanged as a private header in
src/cvc/third_party/nanoflann, following the stb precedent, and no installed header includes it. nanoflann has no mutable static state and builds wherever libcvc does, wasm included. So libcvc no longer links CGAL, or GMP and MPFR through it.What changes
neighbors_within_radius: same contract.dx*dx + dy*dy <= r*r.DISABLE_CGALO(N²) fallback is gone, so wasm gets the k-d tree too.project_verts: nowcvc::project_points_to_trianglesinproject_verts.cpp. The original iterator template stays as a thin wrapper.max(1.0, min(0.0, r)), which is always 1, so a point past an edge went to that edge's end vertex.geometry::projectnow works without libigl in every build. Before, it was a silent no-op unless CGAL was found. libigl builds are unchanged and still use libigl's exact AABB tree.cvcno longer callsSetupCGAL.cvcConfig.cmakeno longer finds CGAL for consumers.CMake/FindCGAL.cmakeandCMake/SetupCGAL.cmakeare deleted.DISABLE_CGALis accepted and ignored, so the workflows and scripts that pass it still configure.libcvcandlibcvc-cudarecipes drop cgal, gmp and mpfr.mingw-w64-runtimestays until a Windows package is checked without it, since gsl is MinGW-built too.THIRD_PARTY_NOTICES.md(nanoflann's notice),GEOMETRY_API.md(projection), README andFULL_BUILD_CVCPKG.md(dependency lists), andsrc/cvc/third_party/README.md.Consumer note:
cvc::cvcno longer brings CGAL in transitively. A downstream that used CGAL through libcvc mustfind_package(CGAL)itself.Tests
nav_test:NavSpatial.NeighborsWithinRadiusIncludesTheBoundaryAndDuplicates: an integer lattice with exact 3-4-5 and axis distances, plus duplicates, at r = 0, 1, √2 and 5, against brute force.NavSpatial.NeighborsWithinRadiusOfNothingOrOnePoint.geometry_test,ProjectVerts.*:GeometryTest.ProjectToTargetSurfaceis no longer CGAL-gated.system_macro_headers_testnow includesproject_verts.h.geometry::projecttakes the new path):nav_test: 64/64 pass;geometry_test: 120 pass, with its usual environment skips;system_macro_headers_test: 3/3 pass.This comes from the VolumeRover ports plan (#1074), which now has no GPL code anywhere in libcvc.
A/B against CGAL (
tools/cgal_ab, newcgal-abCI job)cgal_ab_testruns each replacement beside the CGAL code it replaced, on the same deterministic inputs. It links CGAL, so as built it is GPL-3+. It is never installed or packaged and builds only with-DCVC_BUILD_CGAL_AB=ON.The new
cgal-abjob builds a minimal libcvc with it on ubuntu-24.04 (boost, pegtl, cgal, gmp and mpfr from cvcpkg) whenever the compared code changes, and writes the output to the job summary.Local run on Windows (MSVC 14.38, CGAL 6.0.1), all passing:
neighbors_within_radiusvsKd_tree+Fuzzy_sphere: uniform n = 1k and 20k at r = 0.5, 2, 5; integer lattice at r = 1, √2, 5; a clump with duplicates at r = 0, 0.01, 0.1project_points_to_triangles(k = 10) vsAABB_tree::closest_point: UV sphere with 3,000 random and 3,000 near-surface queries; a sliver strip with 2,000 queriesCompiler flags that came from CGAL (10c1d36)
Linking
CGAL::CGALPUBLIC also put CGAL's own compiler flags oncvc's interface, so every test, binding and consumer inherited them. Dropping CGAL dropped them, andrecipe / windows-2022 / Releasefailed withC1128: number of sections exceeded object file format limitinariadne_runtime_test.cpp.cvcnow sets the same flags itself, PUBLIC as before, so this PR changes no build flag and no floating-point behaviour:/bigobj,/fp:strict,/fp:except-,_SCL_SECURE_NO_DEPRECATEand_SCL_SECURE_NO_WARNINGS;-frounding-math.Whether libcvc wants strict floating point for its own sake is a separate question.