# Upstream's last release, v2.4 (2019-06), predates 63 commits on master that # include the build fixes this spec relies on (CLI targets usable without the # GUI, "Cleaver2" renamed to "Cleaver" in the CLI). Master has been quiet since # 2023-05, so the snapshot is what upstream itself ships. %global commit 04338ff9e68e4cfb9a1bbec36a674e107e44e1f2 %global shortcommit %(c=%{commit}; echo ${c:0:7}) %global snapdate 20230514 Name: cleaver Version: 2.4^%{snapdate}git%{shortcommit} # Explicit, not %%autorelease -- that macro is inert in this COPR # (ci/PROCEDURES.md golden rule 3). Release: 1%{?dist} Summary: Multi-material tetrahedral mesh generator for segmented volumes # LICENSE is MIT, and 49 of the 68 compiled sources carry MIT text; 16 carry # no header. Roots3And4.cpp is Jochen Schwarze's cubic/quartic solver from # Graphics Gems I (1990), compiled in and called from # TopologicalInterfaceCalculator. SPDX has Graphics-Gems; fedora-license-data # 1.76 does not classify it yet, so this is fine for the COPR but needs a # fedora-license-data request before any Fedora submission. # # Timer.h/Timer.cpp carry a 2012 notice by the same author as LICENSE: "This # source code is not to be used, copied, or shared, without explicit # permission from the author." That contradicts the MIT LICENSE, so they are # NOT built: Source1/Source2 replace them with an MIT std::chrono # implementation of the same class (cleaver-timer.h explains). The tarball # still contains them, covered by the repository-wide MIT LICENSE from the same # copyright holder; upstream is asked to fix the header # (docs/upstream/cleaver2library-install-and-headers.md). # # Vendored copies of jsoncpp, CLI11 and teem are deleted in %%prep and never # built, so their licences do not apply. License: MIT AND Graphics-Gems URL: https://github.com/SCIInstitute/Cleaver Source0: %{url}/archive/%{commit}/Cleaver-%{commit}.tar.gz Source1: cleaver-timer.h Source2: cleaver-timer.cpp # %%check oracle: per-material volumes against upstream's reference meshes. Source3: cleaver-mesh-check.py # System jsoncpp, CLI11 and GoogleTest instead of the vendored copies and a # configure-time git clone of CIBC-Internal/googletest. Patch0: cleaver-system-libs.patch BuildRequires: cmake BuildRequires: ninja-build BuildRequires: gcc-c++ BuildRequires: cli11-devel BuildRequires: jsoncpp-devel BuildRequires: gtest-devel BuildRequires: gmock-devel BuildRequires: python3 # Segmentation (label-map) input is implemented only in the ITK reader; # upstream's teem reader refuses it ("Please use ITK"), so ITK it is. BuildRequires: InsightToolkit5-devel >= 5.4 # ITK's CMake config loads ITKVtkGlue -> find_package(VTK), whose transitive # dependencies vtk-devel does not pull in itself (same list as c3d.spec). BuildRequires: hdf5-devel BuildRequires: eigen3-devel BuildRequires: python3-devel BuildRequires: qt6-qtdeclarative-devel %if 0%{?fedora} BuildRequires: libminc-devel %endif # ITK freezes sonames across releases while adding symbols, so rpm's soname # dependencies cannot see a too-old ITK; floor on the version built against. # The two-part expansion is required: ">= UNSET" is satisfied, so an undefined # macro would make the floor vacuous, which the %%build guard catches. Requires: InsightToolkit5%{?_isa} >= %{?itk_ver}%{!?itk_ver:UNSET} # itk(abi): ITK_LEGACY_REMOVE changes class layouts at unchanged sonames, so the itk_ver floor alone let a # consumer built against the removed state install over the present one (python3-simpleitk -11 on ITK -23 # returned all-zero images). Equality on the legacy-state token; see InsightToolkit5.spec. Requires: itk(abi) = %{?itk_abi}%{!?itk_abi:UNSET} %description Cleaver is a multi-material tetrahedral meshing tool from the SCI Institute, University of Utah. It produces conforming tetrahedral meshes of a domain partitioned into several materials, with guaranteed bounds on element quality, from either a labeled segmentation volume or a set of per-material indicator functions. Typical inputs are segmented head or heart images for finite-element simulation (EEG/MEG/TMS forward models, cardiac electrical simulation). This package ships the command-line mesh generator, cleaver-cli, which reads NRRD and the other image formats ITK supports and writes TetGen, SCIRun, MATLAB, VTK and PLY meshes. The Qt 5 GUI is not built. SCIRun uses a different, forked copy of the library, packaged separately as cleaver2. %prep %autosetup -n Cleaver-%{commit} -p1 rm -r src/lib/jsoncpp src/lib/cli11 src/lib/teem cp -p %{SOURCE1} src/lib/cleaver/Timer.h cp -p %{SOURCE2} src/lib/cleaver/Timer.cpp %build test -n "%{?itk_ver}" || { echo "ERROR: itk_ver undefined - needs InsightToolkit5-devel's macros.itk" >&2; exit 1; } test -n "%{?itk_abi}" || { echo "ERROR: itk_abi undefined - needs InsightToolkit5-devel >= 5.4.7-24 (macros.itk)" >&2; exit 1; } # BUILD_SHARED_LIBS=OFF: the internal libraries (cleaver, nrrd2cleaver) are # linked into cleaver-cli and not installed; no other package uses this copy. # C++17: ITK 5.4 and GoogleTest need it; upstream defaults to C++11 unless set. %cmake -S src -G Ninja \ -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_CXX_STANDARD=17 \ -DUSE_ITK=ON \ -DBUILD_CLI=ON \ -DBUILD_GUI=OFF \ -DBUILD_TESTING=ON %cmake_build %install %cmake_install %check # The library unit tests (vec3, tet, tetmesh, violation checker, mesher). # Upstream's CLI regression tests stay off, as upstream has them: they pass # options the CLI no longer has (--scale, -S, -P) and reference an undefined # global, so they cannot build. %ctest # End to end with the installed binary, against upstream's reference meshes. exe=%{buildroot}%{_bindir}/cleaver-cli in=src/test/test_data/input # -o is a prefix, joined to -n without a separator: keep the trailing slash. out=$(mktemp -d) # Four indicator functions (spheres). $exe -I -i $in/spheres1.nrrd $in/spheres2.nrrd $in/spheres3.nrrd $in/spheres4.nrrd \ -o $out/ -n basic %{python3} -I %{SOURCE3} $out/basic src/test/test_data/basic/output 4 0.02 # A labeled segmentation, read by the ITK reader. mickey.nrrd has labels 1-5 # (232028, 16348, 822, 822 and 27 voxels); the 27-voxel cube does not survive # the blending, in upstream's reference either, so 4 materials. The reference # was made with -P (a padding material, label 1, since removed from the CLI), # so it is compared with that material dropped. Measured -1: within 0.6% on # the large materials and 2% on the two small ones; total = 63^3 exactly. $exe -i $in/mickey.nrrd -o $out/ -n seg %{python3} -I %{SOURCE3} $out/seg src/test/test_data/segmentation/output 4 0.03 1 %files %license LICENSE %doc README.md %{_bindir}/cleaver-cli %changelog * Thu Oct 08 2026 Morgan Hough - 2.4^20230514git04338ff-1 - Initial package: the CLI mesher on system ITK, jsoncpp, CLI11 and GoogleTest; Timer.h/.cpp replaced (restrictive header, see License comment)