star-uvm

Spatial structuring of unstructured volumetric meshes
git clone git://git.meso-star.fr/star-uvm.git
Log | Files | Refs | README | LICENSE

commit 10f346872dba1c6fc3cde3a6bc1c97f87b3aa5c0
parent 71658aa595082061e738ee2ac81bbcab35f8202a
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri, 23 May 2025 12:15:22 +0200

Merge branch 'release_0.4'

Diffstat:
M.gitignore | 17++++++++---------
MMakefile | 186+++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------
MREADME.md | 7++++++-
Mconfig.mk | 26+++++++++++++-------------
Adoc/suvm-voxelize.1 | 93+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dmake.sh | 70----------------------------------------------------------------------
Msrc/suvm.h | 2+-
Msrc/suvm_backend.h | 2+-
Msrc/suvm_c.h | 2+-
Msrc/suvm_device.c | 2+-
Msrc/suvm_device.h | 2+-
Msrc/suvm_primitive.c | 2+-
Msrc/suvm_volume.c | 2+-
Msrc/suvm_volume.h | 2+-
Msrc/suvm_volume_at.c | 2+-
Msrc/suvm_volume_intersect_aabb.c | 2+-
Msrc/suvm_voxelize.c | 42+++++++++---------------------------------
Msrc/test_suvm_ball.h | 2+-
Msrc/test_suvm_box.h | 2+-
Msrc/test_suvm_device.c | 2+-
Msrc/test_suvm_primitive_intersection.c | 2+-
Msrc/test_suvm_utils.h | 2+-
Msrc/test_suvm_volume.c | 2+-
23 files changed, 265 insertions(+), 208 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,14 +1,13 @@ -.gitignore -[Bb]uild* -*.sw[po] +*~ *.[aod] +.config +.config_utils +.gitignore +*.pc *.so -*~ +suvm-voxelize +*.sw[po] +tags test* !test*.[ch] -.config -.test -tags -*.pc *.vtk -suvm_voxelize diff --git a/Makefile b/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +# Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,7 +14,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. */ .POSIX: -.SUFFIXES: # Clean up default inference rules +.SUFFIXES: .t .c .d .o include config.mk @@ -22,6 +22,9 @@ LIBNAME_STATIC = libsuvm.a LIBNAME_SHARED = libsuvm.so LIBNAME = $(LIBNAME_$(LIB_TYPE)) +default: library +all: default tests $(ADDON) + ################################################################################ # Library building ################################################################################ @@ -34,7 +37,10 @@ SRC =\ OBJ = $(SRC:.c=.o) DEP = $(SRC:.c=.d) -build_library: .config $(DEP) +CFLAGS_LIB = -std=c99 $(CFLAGS_SO) $(INCS) -DSUVM_SHARED_BUILD +LDFLAGS_LIB = $(LDFLAGS_SO) $(LIBS) + +library: .config $(DEP) @$(MAKE) -fMakefile $$(for i in $(DEP); do echo -f $${i}; done) \ $$(if [ -n "$(LIBNAME)" ]; then\ echo "$(LIBNAME)";\ @@ -45,7 +51,7 @@ build_library: .config $(DEP) $(DEP) $(OBJ): config.mk $(LIBNAME_SHARED): $(OBJ) - $(CC) -std=c99 $(CFLAGS_SO) $(DPDC_CFLAGS) -o $@ $(OBJ) $(LDFLAGS_SO) $(DPDC_LIBS) + $(CC) $(CFLAGS_LIB) -o $@ $(OBJ) $(LDFLAGS_LIB) $(LIBNAME_STATIC): libsuvm.o $(AR) -rc $@ $? @@ -56,18 +62,15 @@ libsuvm.o: $(OBJ) $(OBJCOPY) $(OCPFLAGS) $@ .config: config.mk - @if ! $(PKG_CONFIG) --atleast-version $(EMBREE_VERSION) embree4; then \ - echo "embree4 $(EMBREE_VERSION) not found" >&2; exit 1; fi - @if ! $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys; then \ - echo "rsys $(RSYS_VERSION) not found" >&2; exit 1; fi + $(PKG_CONFIG) --atleast-version $(EMBREE_VERSION) embree4 + $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys @echo "config done" > $@ -.SUFFIXES: .c .d .o .c.d: - @$(CC) -std=c99 $(CFLAGS_SO) $(DPDC_CFLAGS) -MM -MT "$(@:.d=.o) $@" $< -MF $@ + @$(CC) $(CFLAGS_LIB) -MM -MT "$(@:.d=.o) $@" $< -MF $@ .c.o: - $(CC) -std=c99 $(CFLAGS_SO) $(DPDC_CFLAGS) -DSUVM_SHARED_BUILD -c $< -o $@ + $(CC) $(CFLAGS_LIB) -c $< -o $@ ################################################################################ # Installation @@ -88,34 +91,83 @@ suvm-local.pc: suvm.pc.in -e 's#@RSYS_VERSION@#$(RSYS_VERSION)#g'\ suvm.pc.in > $@ -install: build_library pkg - @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib" $(LIBNAME) - @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib/pkgconfig" suvm.pc - @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/star" src/suvm.h - @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/doc/star-uvm" COPYING README.md - -uninstall: - rm -f "$(DESTDIR)$(PREFIX)/lib/$(LIBNAME)" - rm -f "$(DESTDIR)$(PREFIX)/lib/pkgconfig/suvm.pc" - rm -f "$(DESTDIR)$(PREFIX)/include/star/suvm.h" +install: library pkg install_$(ADDON) + install() { mode="$$1"; prefix="$$2"; shift 2; \ + mkdir -p "$${prefix}"; \ + cp "$$@" "$${prefix}"; \ + chmod "$${mode}" "$$@"; \ + }; \ + install 755 "$(DESTDIR)$(LIBPREFIX)" $(LIBNAME); \ + install 644 "$(DESTDIR)$(LIBPREFIX)/pkgconfig" suvm.pc; \ + install 644 "$(DESTDIR)$(INCPREFIX)/star" src/suvm.h; \ + install 644 "$(DESTDIR)$(PREFIX)/share/doc/star-uvm" COPYING README.md + +install_: # Dummy target run when ADDON is disabled + +uninstall: uninstall_utils + rm -f "$(DESTDIR)$(LIBPREFIX)/$(LIBNAME)" + rm -f "$(DESTDIR)$(LIBPREFIX)/pkgconfig/suvm.pc" + rm -f "$(DESTDIR)$(INCPREFIX)/star/suvm.h" rm -f "$(DESTDIR)$(PREFIX)/share/doc/star-uvm/COPYING" rm -f "$(DESTDIR)$(PREFIX)/share/doc/star-uvm/README.md" -################################################################################ -# Miscellaneous targets -################################################################################ -all: build_library build_tests +lint: lint_utils -clean: clean_test - rm -f $(OBJ) $(TEST_OBJ) $(LIBNAME) - rm -f .config .test libsuvm.o suvm.pc suvm-local.pc - rm -f ball.vtk box.vtk +clean: clean_test clean_utils + rm -f $(DEP) $(OBJ) $(LIBNAME) + rm -f .config libsuvm.o suvm.pc suvm-local.pc + +################################################################################# +# Utils +################################################################################# +UTIL_SRC = src/suvm_voxelize.c +UTIL_OBJ = $(UTIL_SRC:.c=.o) +UTIL_DEP = $(UTIL_SRC:.c=.d) + +PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./:$${PKG_CONFIG_PATH}" $(PKG_CONFIG) + +INCS_UTIL = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags rsys smsh suvm-local.pc) +LIBS_UTIL = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs rsys smsh suvm-local.pc) -lm + +CFLAGS_UTIL = -std=c89 $(CFLAGS_EXE) $(INCS_UTIL) +LDFLAGS_UTIL = $(LDFLAGS_EXE) $(LIBS_UTIL) + +utils: library .config_utils + @$(MAKE) $(UTIL_DEP); \ + $(MAKE) -f Makefile -f src/suvm_voxelize.d suvm-voxelize + +.config_utils: config.mk + $(PKG_CONFIG) --atleast-version $(SMSH_VERSION) smsh + @echo "config done" > $@ + +src/suvm_voxelize.d: config.mk suvm-local.pc + @$(CC) $(CFLAGS_UTIL) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ -distclean: clean - rm -f $(DEP) $(TEST_DEP) +src/suvm_voxelize.o: config.mk suvm-local.pc + $(CC) $(CFLAGS_UTIL) -c $(@:.o=.c) -o $@ + +suvm-voxelize: config.mk suvm-local.pc $(LIBNAME) src/suvm_voxelize.o + $(CC) $(CFLAGS_UTIL) -o $@ src/suvm_voxelize.o $(LDFLAGS_UTIL) + +clean_utils: + rm -f $(UTIL_DEP) $(UTIL_OBJ) suvm-voxelize + rm -f .config_utils + +install_utils: utils + install() { mode="$$1"; prefix="$$2"; shift 2; \ + mkdir -p "$${prefix}"; \ + cp "$$@" "$${prefix}"; \ + chmod "$${mode}" "$$@"; \ + }; \ + install 755 "$(DESTDIR)$(BINPREFIX)" suvm-voxelize; \ + install 644 "$(DESTDIR)$(MANPREFIX)/man1" doc/suvm-voxelize.1 -lint: - shellcheck -o all make.sh +uninstall_utils: + rm -f "$(DESTDIR)$(BINPREFIX)/suvm-voxelize" + rm -f "$(DESTDIR)$(MANPREFIX)/man1/suvm-voxelize.1" + +lint_utils: + mandoc -Tlint -Wall doc/suvm-voxelize.1 || [ $$? -le 1 ] ################################################################################ # Tests @@ -126,51 +178,53 @@ TEST_SRC =\ src/test_suvm_primitive_intersection.c TEST_OBJ = $(TEST_SRC:.c=.o) TEST_DEP = $(TEST_SRC:.c=.d) +TEST_TGT = $(TEST_SRC:.c=.t) -SMSH_FOUND = $(PKG_CONFIG) --atleast-version $(SMSH_VERSION) smsh +INCS_TEST = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags rsys suvm-local.pc) +LIBS_TEST = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs rsys suvm-local.pc) -lm -PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./:$${PKG_CONFIG_PATH}" $(PKG_CONFIG) -SUVM_CFLAGS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags suvm-local.pc) -SUVM_LIBS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs suvm-local.pc) +CFLAGS_TEST = -std=c89 $(CFLAGS_EXE) $(INCS_TEST) +LDFLAGS_TEST = $(LDFLAGS_EXE) $(LIBS_TEST) -build_tests: build_library $(TEST_DEP) .test - @if $(SMSH_FOUND); then $(MAKE) src/suvm_voxelize.d; fi; \ - $(MAKE) -fMakefile -f.test \ +tests: library $(TEST_DEP) $(TEST_TGT) + @$(MAKE) -fMakefile \ $$(for i in $(TEST_DEP); do echo -f"$${i}"; done) \ - $$($(SMSH_FOUND) && echo "-fsrc/suvm_voxelize.d") \ - test_bin - -test: build_tests - @$(SHELL) make.sh run_test $(TEST_SRC) - -.test: Makefile - @{ $(SHELL) make.sh config_test $(TEST_SRC); \ - if $(SMSH_FOUND); then \ - $(SHELL) make.sh config_test src/suvm_voxelize.c; fi \ + $$(for i in $(TEST_TGT); do echo -f"$${i}"; done) \ + test_list + +.c.t: + @{ \ + tgt="$$(basename "$<" ".c")"; \ + printf '%s: %s\n' "$${tgt}" $(<:.c=.o); \ + printf 'test_list: %s\n' "$${tgt}"; \ } > $@ -clean_test: - $(SHELL) make.sh clean_test $(TEST_SRC) src/suvm_voxelize.c - $(TEST_DEP): config.mk suvm-local.pc - @$(CC) -std=c89 $(CFLAGS_EXE) $(RSYS_CFLAGS) $(SUVM_CFLAGS) \ - -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ - -src/suvm_voxelize.d: config.mk suvm-local.pc - @$(CC) -std=c89 $(CFLAGS_EXE) $(RSYS_CFLAGS) $(SUVM_CFLAGS) $(SMSH_CFLAGS) \ - -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ + @$(CC) $(CFLAGS_TEST) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@ $(TEST_OBJ): config.mk suvm-local.pc - $(CC) -std=c89 $(CFLAGS_EXE) $(RSYS_CFLAGS) $(SUVM_CFLAGS) -c $(@:.o=.c) -o $@ - -src/suvm_voxelize.o: config.mk suvm-local.pc - $(CC) -std=c89 $(CFLAGS_EXE) $(RSYS_CFLAGS) $(SUVM_CFLAGS) $(SMSH_CFLAGS) -c $(@:.o=.c) -o $@ + $(CC) $(CFLAGS_TEST) -c $(@:.o=.c) -o $@ test_suvm_device \ test_suvm_volume \ test_suvm_primitive_intersection \ : config.mk suvm-local.pc $(LIBNAME) - $(CC) -std=c89 $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(SUVM_LIBS) $(RSYS_LIBS) -lm + $(CC) -std=c89 $(CFLAGS_TEST) -o $@ src/$@.o $(LDFLAGS_TEST) -suvm_voxelize: config.mk suvm-local.pc $(LIBNAME) - $(CC) -std=c89 $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(SUVM_LIBS) $(RSYS_LIBS) $(SMSH_LIBS) -lm +clean_test: + rm -f $(TEST_BIN) $(TEST_DEP) $(TEST_OBJ) + rm -f ball.vtk box.vtk + for i in $(TEST_SRC); do rm -f "$$(basename "$${i}" ".c")"; done + +test: tests + @err=0; \ + for i in $(TEST_SRC); do \ + test="$$(basename "$${i}" ".c")"; \ + if "./$${test}" > /dev/null 2>&1; then \ + printf '%s\n' "$${test}"; \ + else \ + >&2 printf '%s: error %s\n' "$${test}" "$$?"; \ + err=$$((err+1)); \ + fi \ + done; \ + [ "$${err}" -eq 0 ] diff --git a/README.md b/README.md @@ -29,6 +29,11 @@ Edit config.mk as needed, then run: ## Release notes +### Version 0.4 + +- Make suvm-voxelize an installable utility. +- Add the suvm-voxelize man page. + ### Version 0.3.1 - In release, replace the -O2 compilation flag by -O3 since significant @@ -62,7 +67,7 @@ Embree4 ## License -Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) Star-UVM is free software released under the GPL v3+ license: GNU GPL version 3 or later. You are welcome to redistribute it under certain diff --git a/config.mk b/config.mk @@ -1,4 +1,4 @@ -VERSION = 0.3.1 +VERSION = 0.4.0 PREFIX = /usr/local LIB_TYPE = SHARED @@ -7,6 +7,15 @@ LIB_TYPE = SHARED BUILD_TYPE = RELEASE #BUILD_TYPE = DEBUG +BINPREFIX = $(PREFIX)/bin +LIBPREFIX = $(PREFIX)/lib +INCPREFIX = $(PREFIX)/include/stardis +MANPREFIX = $(PREFIX)/share/man + +# Enable building and installation of additional utilities +# Comment it to build and install the library only +#ADDON = utils + ################################################################################ # Tools ################################################################################ @@ -24,20 +33,11 @@ PCFLAGS_STATIC = --static PCFLAGS = $(PCFLAGS_$(LIB_TYPE)) EMBREE_VERSION = 4.0 -EMBREE_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags embree4) -EMBREE_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs embree4) - RSYS_VERSION = 0.14 -RSYS_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags rsys) -RSYS_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs rsys) - -# Optional (required only by suvm_voxelize tool) -SMSH_VERSION = 0.1 -SMSH_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags smsh) -SMSH_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs smsh) +SMSH_VERSION = 0.1 # Optional (required by utils) -DPDC_CFLAGS = $(EMBREE_CFLAGS) $(RSYS_CFLAGS) -DPDC_LIBS = $(EMBREE_LIBS) $(RSYS_LIBS) -lm +INCS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags embree4 rsys) +LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs embree4 rsys) -lm ################################################################################ # Compilation options diff --git a/doc/suvm-voxelize.1 b/doc/suvm-voxelize.1 @@ -0,0 +1,93 @@ +.\" Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) +.\" +.\" This program is free software: you can redistribute it and/or modify +.\" it under the terms of the GNU General Public License as published by +.\" the Free Software Foundation, either version 3 of the License, or +.\" (at your option) any later version. +.\" +.\" This program is distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public License +.\" along with this program. If not, see <http://www.gnu.org/licenses/>. +.Dd February 20, 2025 +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.Dt SUVM-VOXELIZE 1 +.Os +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.Sh NAME +.Nm suvm-voxelize +.Nd voxelize a tetrahedral mesh +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.Sh SYNOPSIS +.Nm +.Op Fl hnv +.Op Fl d Ar x , Ns Ar y , Ns Ar z +.Op Fl o Ar output +.Op Ar input +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.Sh DESCRIPTION +.Nm +voxelize a tetrahedral mesh stored in the +.Xr smsh 5 +file format. +Generated voxels are parallelepipeds saved in VTK format. +Each voxel stores the number of tetrahedra covering it. +.Pp +If input is not defined, the mesh is read from standard input. +.Pp +The options are as follows: +.Bl -tag -width Ds +.It Fl d Ar x , Ns Ar y , Ns Ar z +definition of voxelization along the 3 axes. +Default is 64,64,64. +.It Fl h +Display short help and exit. +.It Fl n +pre-calculate tetrahedron normals. +This should speed up voxelization speed by calculating normals once and +for all, rather than re-evaluating them each time a tetrahedron is +tested against a voxel. +On the other hand, the memory space used to store normals increases the +memory footprint. +.It Fl o Ar output +Output file. +Voxels are stored in VTK format. +If not defined, data is written to standard output. +.It Fl v +Make +.Nm +verbose. +.El +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.Sh EXIT STATUS +.Ex -std +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.Sh EXAMPLES +Voxelize +.Pa volumic_mesh.smsh +and save the results in +.Pa voxels.vtk : +.Bd -literal -offset Ds +suvm-voxelize -o voxels.vtk volumic_mesh.smsh +.Ed +.Pp +Same as above but with a voxelization definition of 256^3: +.Bd -literal -offset Ds +suvm-voxelize -d256,256,256 -o voxels.vtk volumic_mesh.smsh +.Ed +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.Sh SEE ALSO +.Xr smsh 5 +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.Sh STANDARDS +.Rs +.%B The VTK User's Guide +.%O Simple Legacy Formats +.%I Kitware, Inc +.%N 11 +.%D 2010 +.%P 470--482 +.Re diff --git a/make.sh b/make.sh @@ -1,70 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. */ - -set -e - -config_test() -{ - for i in "$@"; do - test=$(basename "${i}" ".c") - test_list="${test_list} ${test}" - printf "%s: %s\n" "${test}" "src/${test}.o" - done - printf "test_bin: %s\n" "${test_list}" -} - -run_test() -{ - for i in "$@"; do - test=$(basename "${i}" ".c") - - printf "%s " "${test}" - if "./${test}" > /dev/null 2>&1; then - printf "\033[1;32mOK\033[m\n" - else - printf "\033[1;31mError\033[m\n" - fi - done 2> /dev/null -} - -clean_test() -{ - for i in "$@"; do - rm -f "$(basename "${i}" ".c")" - done -} - -install() -{ - prefix=$1 - shift 1 - - mkdir -p "${prefix}" - - for i in "$@"; do - dst="${prefix}/${i##*/}" - - if cmp -s "${i}" "${dst}"; then - printf "Up to date %s\n" "${dst}" - else - printf "Installing %s\n" "${dst}" - cp "${i}" "${prefix}" - fi - done -} - -"$@" diff --git a/src/suvm.h b/src/suvm.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/suvm_backend.h b/src/suvm_backend.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/suvm_c.h b/src/suvm_c.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/suvm_device.c b/src/suvm_device.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/suvm_device.h b/src/suvm_device.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/suvm_primitive.c b/src/suvm_primitive.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/suvm_volume.c b/src/suvm_volume.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/suvm_volume.h b/src/suvm_volume.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/suvm_volume_at.c b/src/suvm_volume_at.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/suvm_volume_intersect_aabb.c b/src/suvm_volume_intersect_aabb.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/suvm_voxelize.c b/src/suvm_voxelize.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,36 +45,11 @@ static const struct args ARGS_DEFAULT = { /******************************************************************************* * Helper functions ******************************************************************************/ -static void -print_help(const char* cmd) +static INLINE void +usage(FILE* stream) { - ASSERT(cmd); - printf( -"Usage: %s [options] [file]\n" -"Voxelize a smsh(5) file and save result following VTK file format.\n" -"With no file option, mesh is read from standard input\n", - cmd); - printf("\n"); - printf( -" -d X:Y:Z voxelisation definition along the 3 axes.\n" -" Default definition is %u:%u:%u.\n", - ARGS_DEFAULT.def[0], - ARGS_DEFAULT.def[1], - ARGS_DEFAULT.def[2]); - printf( -" -h display this help and exit.\n"); - printf( -" -n precompute the tetrahedra normals.\n"); - printf( -" -o <output> filename of the output VTK file. If not defined, write\n" -" results to standard ouput\n"); - printf( -" -v make the program verobse.\n"); - printf("\n"); - printf( -"This is free software released under the GNU GPL license, version 3 or\n" -"later. You are free to change or redistribute it under certain\n" -"conditions <http://gnu.org.licenses/gpl.html>\n"); + fprintf(stream, + "usage: suvm-voxelize [-hnv] [-d x,y,z] [-o output] [input]\n"); } static void @@ -97,12 +72,12 @@ args_init(struct args* args, const int argc, char** argv) while((opt = getopt(argc, argv, "d:hno:v")) != -1) { switch(opt) { case 'd': - res = cstr_to_list_uint(optarg, ':', args->def, &n, 3); + res = cstr_to_list_uint(optarg, ',', args->def, &n, 3); if(res == RES_OK && n != 3) res = RES_BAD_ARG; if(!args->def[0] || !args->def[1] || !args->def[2]) res = RES_BAD_ARG; break; case 'h': - print_help(argv[0]); + usage(stdin); args_release(args); args->quit = 1; break; @@ -132,6 +107,7 @@ exit: optind = 1; return res; error: + usage(stderr); args_release(args); goto exit; } @@ -191,7 +167,7 @@ write_voxels fprintf(stream, "\n"); fprintf(stream, "CELL_DATA %u\n", def[0]*def[1]*def[2]); - fprintf(stream, "SCALARS intersect_type int 1\n"); + fprintf(stream, "SCALARS nintersections int 1\n"); fprintf(stream, "LOOKUP_TABLE default\n"); ivxl = 0; diff --git a/src/test_suvm_ball.h b/src/test_suvm_ball.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_suvm_box.h b/src/test_suvm_box.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_suvm_device.c b/src/test_suvm_device.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_suvm_primitive_intersection.c b/src/test_suvm_primitive_intersection.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_suvm_utils.h b/src/test_suvm_utils.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_suvm_volume.c b/src/test_suvm_volume.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2020-2023 |Méso|Star> (contact@meso-star.com) +/* Copyright (C) 2020-2023, 2025 |Méso|Star> (contact@meso-star.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by