commit 132f0250d5f493272d67c9f93eb0da22883bee60
parent 870651a54c9b24b8a1bbcbb3a1fe60c74dd22a94
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 25 May 2026 12:20:36 +0200
Merge branch 'release_0.2'
Diffstat:
17 files changed, 550 insertions(+), 457 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,12 +1,11 @@
-.gitignore
-[Bb]uild*
-*.sw[po]
+!test*.[ch]
*.[aod]
+*.pc
*.so
+*.sw[po]
*~
-test*
-!test*.[ch]
.config
-.test
+.gitignore
+rngrd-lint
tags
-*.pc
+test*
diff --git a/Makefile b/Makefile
@@ -1,7 +1,7 @@
# Copyright (C) 2022, 2023, 2025 Centre National de la Recherche Scientifique
# Copyright (C) 2022, 2023, 2025 Institut Pierre-Simon Laplace
# Copyright (C) 2022, 2023, 2025 Institut de Physique du Globe de Paris
-# Copyright (C) 2022, 2023, 2025 |Méso|Star> (contact@meso-star.com)
+# Copyright (C) 2022, 2023, 2025, 2026 |Méso|Star> (contact@meso-star.com)
# Copyright (C) 2022, 2023, 2025 Observatoire de Paris
# Copyright (C) 2022, 2023, 2025 Université de Reims Champagne-Ardenne
# Copyright (C) 2022, 2023, 2025 Université de Versaille Saint-Quentin
@@ -29,6 +29,9 @@ LIBNAME_STATIC = librngrd.a
LIBNAME_SHARED = librngrd.so
LIBNAME = $(LIBNAME_$(LIB_TYPE))
+default: library utils
+all: default
+
################################################################################
# Library building
################################################################################
@@ -36,7 +39,10 @@ SRC = src/rngrd.c src/rngrd_log.c src/rngrd_mesh.c src/rngrd_properties.c
OBJ = $(SRC:.c=.o)
DEP = $(SRC:.c=.d)
-build_library: .config $(DEP)
+CFLAGS_LIB = $(CFLAGS_SO) $(INCS) -DRNGRD_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)"; \
@@ -47,7 +53,7 @@ build_library: .config $(DEP)
$(DEP) $(OBJ): config.mk
$(LIBNAME_SHARED): $(OBJ)
- $(CC) $(CFLAGS_SO) $(DPDC_CFLAGS) -o $@ $(OBJ) $(LDFLAGS_SO) $(DPDC_LIBS)
+ $(CC) $(CFLAGS_LIB) -o $@ $(OBJ) $(LDFLAGS_LIB)
$(LIBNAME_STATIC): librngrd.o
$(AR) -rc $@ $?
@@ -58,28 +64,44 @@ librngrd.o: $(OBJ)
$(OBJCOPY) $(OCPFLAGS) $@
.config: config.mk
- @if ! $(PKG_CONFIG) --atleast-version $(MRUMTL_VERSION) mrumtl; then \
- echo "mrumtl $(MRUMTL_VERSION) not found" >&2; exit 1; fi
- @if ! $(PKG_CONFIG) --atleast-version $(RNSL_VERSION) rnsl; then \
- echo "rnsl $(RNSL_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
- @if ! $(PKG_CONFIG) --atleast-version $(S3D_VERSION) s3d; then \
- echo "s3d $(S3D_VERSION) not found" >&2; exit 1; fi
- @if ! $(PKG_CONFIG) --atleast-version $(SBUF_VERSION) sbuf; then \
- echo "sbuf $(SBUF_VERSION) not found" >&2; exit 1; fi
- @if ! $(PKG_CONFIG) --atleast-version $(SMSH_VERSION) smsh; then \
- echo "smsh $(SMSH_VERSION) not found" >&2; exit 1; fi
- @if ! $(PKG_CONFIG) --atleast-version $(SSF_VERSION) ssf; then \
- echo "ssf $(SSF_VERSION) not found" >&2; exit 1; fi
- @echo "config done" > $@
+ $(PKG_CONFIG) --atleast-version $(MRUMTL_VERSION) mrumtl
+ $(PKG_CONFIG) --atleast-version $(RNSL_VERSION) rnsl
+ $(PKG_CONFIG) --atleast-version $(RSYS_VERSION) rsys
+ $(PKG_CONFIG) --atleast-version $(S3D_VERSION) s3d
+ $(PKG_CONFIG) --atleast-version $(SBUF_VERSION) sbuf
+ $(PKG_CONFIG) --atleast-version $(SMSH_VERSION) smsh
+ $(PKG_CONFIG) --atleast-version $(SSF_VERSION) ssf
+ echo "config done" > $@
.SUFFIXES: .c .d .o
.c.d:
- @$(CC) $(CFLAGS_SO) $(DPDC_CFLAGS) -MM -MT "$(@:.d=.o) $@" $< -MF $@
+ @$(CC) $(CFLAGS_LIB) -MM -MT "$(@:.d=.o) $@" $< -MF $@
.c.o:
- $(CC) $(CFLAGS_SO) $(DPDC_CFLAGS) -DRNGRD_SHARED_BUILD -c $< -o $@
+ $(CC) $(CFLAGS_LIB) -c $< -o $@
+
+################################################################################
+# Utils
+################################################################################
+PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./:$${PKG_CONFIG_PATH}" $(PKG_CONFIG)
+
+INCS_UTIL = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags rngrd-local rsys)
+LIBS_UTIL = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs rngrd-local rsys)
+
+CFLAGS_UTIL = $(CFLAGS_EXE) $(INCS_UTIL)
+LDFLAGS_UTIL = $(LDFLAGS_EXE) $(LIBS_UTIL)
+
+utils: library src/rngrd_lint.d
+ @$(MAKE) -fMakefile -f src/rngrd_lint.d rngrd-lint
+
+src/rngrd_lint.d: config.mk rngrd-local.pc src/rngrd_lint.c
+ @$(CC) $(CFLAGS_UTIL) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
+
+src/rngrd_lint.o: config.mk rngrd-local.pc src/rngrd_lint.c
+ $(CC) $(CFLAGS_UTIL) -c $(@:.o=.c) -o $@
+
+rngrd-lint: config.mk rngrd-local.pc src/rngrd_lint.o $(LIBNAME)
+ $(CC) $(CFLAGS_UTIL) -o $@ src/rngrd_lint.o $(LDFLAGS_UTIL)
################################################################################
# Installation
@@ -110,60 +132,38 @@ rngrd-local.pc: rngrd.pc.in
-e 's#@SSF_VERSION@#$(SSF_VERSION)#g'\
rngrd.pc.in > $@
-install: build_library pkg
- @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib" $(LIBNAME)
- @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/lib/pkgconfig" rngrd.pc
- @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/include/rad-net" src/rngrd.h
- @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/doc/rngrd" COPYING README.md
- @$(SHELL) make.sh install "$(DESTDIR)$(PREFIX)/share/man/man5" rnsp.5
+install: library utils pkg
+ install() { mode="$$1"; prefix="$$2"; shift 2; \
+ mkdir -p "$${prefix}"; \
+ cp "$$@" "$${prefix}"; \
+ printf '%s\n' "$${@}" | while read -r i; do \
+ chmod "$${mode}" "$${prefix}/$${i##*/}"; \
+ done; \
+ }; \
+ if [ "$(LIB_TYPE)" = "STATIC" ]; then mode=644; else mode=755; fi; \
+ install "$${mode}" "$(DESTDIR)$(LIBPREFIX)" $(LIBNAME); \
+ install 755 "$(DESTDIR)$(BINPREFIX)" rngrd-lint; \
+ install 644 "$(DESTDIR)$(LIBPREFIX)/pkgconfig" rngrd.pc; \
+ install 644 "$(DESTDIR)$(INCPREFIX)/rad-net" src/rngrd.h; \
+ install 644 "$(DESTDIR)$(MANPREFIX)/man1" doc/rngrd-lint.1; \
+ install 644 "$(DESTDIR)$(MANPREFIX)/man5" doc/rnsp.5; \
+ install 644 "$(DESTDIR)$(PREFIX)/share/doc/rngrd" COPYING README.md
uninstall:
- rm -f "$(DESTDIR)$(PREFIX)/lib/$(LIBNAME)"
- rm -f "$(DESTDIR)$(PREFIX)/lib/pkgconfig/rngrd.pc"
+ rm -f "$(DESTDIR)$(LIBPREFIX)/$(LIBNAME)"
+ rm -f "$(DESTDIR)$(BINPREFIX)/rngrd-lint"
+ rm -f "$(DESTDIR)$(LIBPREFIX)/pkgconfig/rngrd.pc"
+ rm -f "$(DESTDIR)$(INCPREFIX)/rad-net/rngrd.h"
+ rm -f "$(DESTDIR)$(MANPREFIX)/man1/rngrd-lint.1"
+ rm -f "$(DESTDIR)$(MANPREFIX)/man5/rnsp.5"
rm -f "$(DESTDIR)$(PREFIX)/share/doc/rngrd/COPYING"
rm -f "$(DESTDIR)$(PREFIX)/share/doc/rngrd/README.md"
- rm -f "$(DESTDIR)$(PREFIX)/include/rad-net/rngrd.h"
- rm -f "$(DESTDIR)$(PREFIX)/share/man/man5/rnsp.5"
-
-################################################################################
-# Miscellaneous targets
-################################################################################
-all: build_library build_tests
-clean: clean_test
- rm -f $(OBJ) $(LIBNAME)
+clean:
+ rm -f $(OBJ) $(DEP) $(LIBNAME)
+ rm -f rngrd-lint src/rngrd_lint.o src/rngrd_lint.d
rm -f .config librngrd.o rngrd.pc rngrd-local.pc
-distclean: clean
- rm -f $(DEP) src/test_rngrd.d
-
lint:
- shellcheck -o all make.sh
- mandoc -Tlint -Wall rnsp.5 || [ $$? -le 1 ]
-
-################################################################################
-# Tests
-################################################################################
-TEST_SRC = src/test_rngrd.c
-TEST_OBJ = $(TEST_SRC:.c=.o)
-TEST_DEP = $(TEST_SRC:.c=.d)
-
-PKG_CONFIG_LOCAL = PKG_CONFIG_PATH="./:$${PKG_CONFIG_PATH}" $(PKG_CONFIG)
-RNGRD_CFLAGS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --cflags rngrd-local.pc)
-RNGRD_LIBS = $$($(PKG_CONFIG_LOCAL) $(PCFLAGS) --libs rngrd-local.pc)
-
-build_tests: build_library src/test_rngrd.d
- @$(MAKE) -fMakefile -f src/test_rngrd.d test_rngrd
-
-clean_test:
- rm -f test_rngrd src/test_rngrd.o
-
-$(TEST_DEP): config.mk rngrd-local.pc
- @$(CC) $(CFLAGS_EXE) $(RNGRD_CFLAGS) $(RSYS_CFLAGS) \
- -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
-
-src/test_rngrd.o: config.mk rngrd-local.pc
- $(CC) $(CFLAGS_EXE) $(RNGRD_CFLAGS) $(RSYS_CFLAGS) -c $(@:.o=.c) -o $@
-
-test_rngrd: src/test_rngrd.o config.mk rngrd-local.pc $(LIBNAME)
- $(CC) $(CFLAGS_EXE) -o $@ src/$@.o $(LDFLAGS_EXE) $(RNGRD_LIBS) $(RSYS_LIBS)
+ mandoc -Tlint -Wwarning doc/rnsp.5
+ mandoc -Tlint -Wwarning doc/rngrd-lint.1
diff --git a/README.md b/README.md
@@ -8,13 +8,13 @@ properties of of a telluric planet's ground.
- C compiler
- POSIX make
- pkg-config
-- [ModRadUrb: MaTeriaL](https://gitlab.com/meso-star/mrumtl)
-- [Rad-Net String List](https://gitlab.com/meso-star/rnsl)
-- [RSys](https://gitlab.com/vaplv/rsys)
-- [Star 3D](https://gitlab.com/meso-star/star-3d)
-- [Star Buffer](https://gitlab.com/meso-star/star-buffer)
-- [Star Mesh](https://gitlab.com/meso-star/star-mesh)
-- [Star Scattering Functions](https://gitlab.com/meso-star/star-sf)
+- [ModRadUrb: MaTeriaL](https://www.meso-star.com/git/mrumtl)
+- [Rad-Net String List](https://www.meso-star.com/git/rnsl)
+- [RSys](https://www.meso-star.com/git/rsys)
+- [Star 3D](https://www.meso-star.com/git/star-3d)
+- [Star Buffer](https://www.meso-star.com/git/star-buffer)
+- [Star Mesh](https://www.meso-star.com/git/star-mesh)
+- [Star Scattering Functions](https://www.meso-star.com/git/star-sf)
## Installation
@@ -24,6 +24,17 @@ Edit config.mk as needed, then run:
## Release notes
+### Version 0.2
+
+- Add the `rngrd_closest_point` API function, which determines the
+ closest point on the geometry based on a given position and a search
+ radius (default: infinite).
+- Add the rngrd-lint utility.
+ It checks the loading and structuring of the library's input data.
+- Improves the building system.
+ Simplify it by doing everything in one place (the Makefile).
+ Add macros to control installation subdirectories.
+
### Version 0.1.1
- Fix a typo in the rnsp manual
@@ -43,7 +54,7 @@ Edit config.mk as needed, then run:
Copyright (C) 2022, 2023, 2025 Centre National de la Recherche Scientifique
Copyright (C) 2022, 2023, 2025 Institut Pierre-Simon Laplace
Copyright (C) 2022, 2023, 2025 Institut de Physique du Globe de Paris
-Copyright (C) 2022, 2023, 2025 [|Méso|Star>](https://www.meso-star.com) (contact@meso-star.com)
+Copyright (C) 2022, 2023, 2025, 2026 [|Méso|Star>](https://www.meso-star.com) (contact@meso-star.com)
Copyright (C) 2022, 2023, 2025 Observatoire de Paris
Copyright (C) 2022, 2023, 2025 Université de Reims Champagne-Ardenne
Copyright (C) 2022, 2023, 2025 Université de Versaille Saint-Quentin
@@ -51,6 +62,6 @@ Copyright (C) 2022, 2023, 2025 Université Paul Sabatier
## License
-Rad-Net Ground is free software released under the GPL v3+ license: GNU
+Rad-Net GRounD is free software released under the GPL v3+ license: GNU
GPL version 3 or later. You are welcome to redistribute it under certain
conditions; refer to the COPYING file for details.
diff --git a/config.mk b/config.mk
@@ -1,5 +1,10 @@
-VERSION = 0.1.1
+VERSION = 0.2.0
+
PREFIX = /usr/local
+BINPREFIX = $(PREFIX)/bin
+LIBPREFIX = $(PREFIX)/lib
+INCPREFIX = $(PREFIX)/include
+MANPREFIX = $(PREFIX)/share/man
LIB_TYPE = SHARED
#LIB_TYPE = STATIC
@@ -25,51 +30,17 @@ PCFLAGS_STATIC = --static
PCFLAGS = $(PCFLAGS_$(LIB_TYPE))
MRUMTL_VERSION = 0.2
-MRUMTL_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags mrumtl)
-MRUMTL_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs mrumtl)
-
RNSL_VERSION = 0.1
-RNSL_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags rnsl)
-RNSL_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs rnsl)
-
RSYS_VERSION = 0.14
-RSYS_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags rsys)
-RSYS_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs rsys)
-
S3D_VERSION = 0.10
-S3D_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags s3d)
-S3D_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs s3d)
-
SBUF_VERSION = 0.1
-SBUF_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags sbuf)
-SBUF_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs sbuf)
-
SMSH_VERSION = 0.1
-SMSH_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags smsh)
-SMSH_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs smsh)
-
SSF_VERSION = 0.9
-SSF_CFLAGS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags ssf)
-SSF_LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs ssf)
-
-DPDC_CFLAGS =\
- $(MRUMTL_CFLAGS)\
- $(RNSL_CFLAGS)\
- $(RSYS_CFLAGS)\
- $(S3D_CFLAGS)\
- $(SBUF_CFLAGS)\
- $(SMSH_CFLAGS)\
- $(SSF_CFLAGS)
-
-DPDC_LIBS =\
- $(MRUMTL_LIBS)\
- $(RNSL_LIBS)\
- $(RSYS_LIBS)\
- $(S3D_LIBS)\
- $(SBUF_LIBS)\
- $(SMSH_LIBS)\
- $(SSF_LIBS)\
- -lm
+
+PC = mrumtl rnsl rsys s3d sbuf smsh ssf
+
+INCS = $$($(PKG_CONFIG) $(PCFLAGS) --cflags $(PC))
+LIBS = $$($(PKG_CONFIG) $(PCFLAGS) --libs $(PC)) -lm
################################################################################
# Compilation options
diff --git a/doc/rngrd-lint.1 b/doc/rngrd-lint.1
@@ -0,0 +1,105 @@
+.\" Copyright (C) 2022, 2023, 2025 Centre National de la Recherche Scientifique
+.\" Copyright (C) 2022, 2023, 2025 Institut Pierre-Simon Laplace
+.\" Copyright (C) 2022, 2023, 2025 Institut de Physique du Globe de Paris
+.\" Copyright (C) 2022, 2023, 2025, 2026 |Méso|Star>(contact@meso-star.com)
+.\" Copyright (C) 2022, 2023, 2025 Observatoire de Paris
+.\" Copyright (C) 2022, 2023, 2025 Université de Reims Champagne-Ardenne
+.\" Copyright (C) 2022, 2023, 2025 Université de Versaille Saint-Quentin
+.\" Copyright (C) 2022, 2023, 2025 Université Paul Sabatier
+.\"
+.\" 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 May 25, 2026
+.Dt RNGRD-LINT 1
+.Os
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh NAME
+.Nm rngrd-lint
+.Nd check the loading and structuring of a decorated mesh
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh SYNOPSIS
+.Nm
+.Op Fl hVv
+.Fl M Ar material_list
+.Fl m Ar geometry
+.Fl p Ar properties
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh DESCRIPTION
+.Nm
+checks the data used to define a triangular mesh, to which a temperature
+and a spectrally varying Bidirectional Reflectance Distribution Function
+.Pq BRDF
+are associated for each triangle.
+.Pp
+This utility effectively validates the behavior of the Rad-Net GRouD
+library
+.Pq RNGRD
+regarding the loading and internal structuring of this data.
+Its purpose is therefore to verify that the input data is valid and
+conforms to the library's expectations prior to running another program
+that relies on the same library and is intended to process the same
+data.
+.Pp
+The options are as follows:
+.Bl -tag -width Ds
+.\""""""""""""""""""""""""""""""""""
+.It Fl h
+Display short help and exit.
+.\""""""""""""""""""""""""""""""""""
+.It Fl M Ar material_list
+File that lists all the materials used by the geometry.
+It is a text file in
+.Xr rnsl 5
+format, where each line specifies the path to a material file in
+.Xr mrumtl 5
+format.
+.\""""""""""""""""""""""""""""""""""
+.It Fl m Ar mesh
+File that stores triangular mesh data in the
+.Xr smsh 5
+format.
+.\""""""""""""""""""""""""""""""""""
+.It Fl p Ar properties
+File that defines triangle properties in
+.Xr rnsp 5
+format.
+.\""""""""""""""""""""""""""""""""""
+.It Fl V
+Perform more thorough validation tests, such as checking all surface
+properties to verify that they match the mesh they are associated with
+and the list of loaded materials.
+.\""""""""""""""""""""""""""""""""""
+.It Fl v
+Make the program verbose.
+.El
+.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh EXIT STATUS
+.Ex -std
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh EXAMPLES
+Verify the loading and structure of the triangular mesh geometry
+.Pa geom.smsh
+as well as its triangle-specific properties in
+.Pa props.rnsp .
+The materials referenced in the
+.Pa props.rnsp
+file are listed in the text file
+.Pa mat.rnsl .
+Perform a thorough validation of the loaded data
+.Pq option Fl V
+and make the command verbose
+.Pq option Fl v
+to obtain more information than just its return code:
+.Bd -literal -offset Ds
+rngrd-lint -m geom.smsh -p props.rnsp -M mat.rnsl -Vv
+.Ed
diff --git a/doc/rnsp.5 b/doc/rnsp.5
@@ -0,0 +1,111 @@
+.\" Copyright (C) 2022, 2023, 2025 Centre National de la Recherche Scientifique
+.\" Copyright (C) 2022, 2023, 2025 Institut Pierre-Simon Laplace
+.\" Copyright (C) 2022, 2023, 2025 Institut de Physique du Globe de Paris
+.\" Copyright (C) 2022, 2023, 2025, 2026 |Méso|Star>(contact@meso-star.com)
+.\" Copyright (C) 2022, 2023, 2025 Observatoire de Paris
+.\" Copyright (C) 2022, 2023, 2025 Université de Reims Champagne-Ardenne
+.\" Copyright (C) 2022, 2023, 2025 Université de Versaille Saint-Quentin
+.\" Copyright (C) 2022, 2023, 2025 Université Paul Sabatier
+.\"
+.\" 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 May 25, 2026
+.Dt RNSP 5
+.Os
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh NAME
+.Nm rnsp
+.Nd Rad-Net Surface Properties file format
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh DESCRIPTION
+.Nm
+is a binary file format for storing surface mesh properties.
+The properties are listed by geometric primitive
+.Pq for example by triangle .
+The mesh to which the properties are attached is
+.Em not
+described there but must be
+defined in a separate file, for example in an
+.Xr smsh 5
+file.
+The number of available properties and their order should match the geometric
+primitives listed in the corresponding mesh.
+.Pp
+A
+.Nm
+file is actually a Star-Buffer file
+.Pq see Xr sbuf 5 .
+It starts with a header of 4 integers.
+The first integer is a power of two
+.Pq usually 4096
+that defines the size of the memory page in bytes
+.Pq Va pagesize
+on which the list of properties are aligned.
+By aligning data to
+.Va pagesize ,
+and depending on system requirements, memory mapping can be used to
+automatically load/unload pages on demand
+.Pq see Xr mmap 2 .
+The second integer is the
+.Va size
+of the array, i.e. the number of property sets stored in the list.
+The 2 remaining integers store the memory size
+.Pq 8 bytes
+and the memory alignment
+.Pq 8 bytes
+of the property set defined by geometric primitive.
+.Pp
+Fill bytes follow the file header to align the listed properties to
+.Va pagesize .
+.Pp
+For each geometric primitive, the properties are composed of a 32-bit integer,
+which is the material identifier of the primitive
+.Pq Va matid ,
+and a 32-bit floating-point number that stores temperature in Kelvin.
+.Pp
+Padding bytes are finally added at the end of the file to align its overall size
+with the size of a page.
+.Pp
+Data are encoded with respect to the little endian bytes ordering, i.e. least
+significant bytes are stored first.
+.Pp
+The file format is as follows:
+.Bl -column (temperature) (::=) ()
+.It Ao Va rnsp Ac Ta ::= Ta Ao Va pagesize Ac Ao Va size Ac Li 8 8
+.It Ta Ta Aq Va padding
+.It Ta Ta Aq Va properties
+.It Ta Ta Aq Va padding
+.It Ao Va pagesize Ac Ta ::= Ta Vt uint64_t
+.It Ao Va size Ac Ta ::= Ta Vt uint64_t
+# Number of items stored
+.It \ Ta Ta
+.It Ao Va properties Ac Ta ::= Ta Ao Va property Ac Va ...
+.It Ao Va property Ac Ta ::= Ta Ao Va matid Ac Ao Va temperature Ac
+.It Ao Va matid Ac Ta ::= Ta Vt uint32_t
+.It Ao Va temperature Ac Ta ::= Ta Vt float
+# In K
+.It \ Ta Ta
+.It Ao Va padding Ac Ta ::= Ta Op Vt int8_t ...
+.El
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh SEE ALSO
+.Xr mmap 2 ,
+.Xr sbuf 5 ,
+.Xr smsh 5
+.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+.Sh HISTORY
+The
+.Nm
+format was first developed for the
+.Xr htrdr-planets 1
+program.
diff --git a/make.sh b/make.sh
@@ -1,46 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2022, 2023 Centre National de la Recherche Scientifique
-# Copyright (C) 2022, 2023 Institut Pierre-Simon Laplace
-# Copyright (C) 2022, 2023 Institut de Physique du Globe de Paris
-# Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com)
-# Copyright (C) 2022, 2023 Observatoire de Paris
-# Copyright (C) 2022, 2023 Université de Reims Champagne-Ardenne
-# Copyright (C) 2022, 2023 Université de Versaille Saint-Quentin
-# Copyright (C) 2022, 2023 Université Paul Sabatier
-#
-# 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
-
-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/rnsp.5 b/rnsp.5
@@ -1,107 +0,0 @@
-.\" Copyright (C) 2022, 2023, 2025 Centre National de la Recherche Scientifique
-.\" Copyright (C) 2022, 2023, 2025 Institut Pierre-Simon Laplace
-.\" Copyright (C) 2022, 2023, 2025 Institut de Physique du Globe de Paris
-.\" Copyright (C) 2022, 2023, 2025 |Méso|Star>(contact@meso-star.com)
-.\" Copyright (C) 2022, 2023, 2025 Observatoire de Paris
-.\" Copyright (C) 2022, 2023, 2025 Université de Reims Champagne-Ardenne
-.\" Copyright (C) 2022, 2023, 2025 Université de Versaille Saint-Quentin
-.\" Copyright (C) 2022, 2023, 2025 Université Paul Sabatier
-.\"
-.\" 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 September 15, 2023
-.Dt RNSP 5
-.Os
-.Sh NAME
-.Nm rnsp
-.Nd Rad-Net Surface Properties file format
-.Sh DESCRIPTION
-.Nm
-is a binary file format for storing surface mesh properties.
-The properties are listed by geometric primitive
-.Pq for example by triangle .
-The mesh to which the properties are attached is
-.Em not
-described there but must be
-defined in a separate file, for example in an
-.Xr smsh 5
-file.
-The number of available properties and their order should match the geometric
-primitives listed in the corresponding mesh.
-.Pp
-A
-.Nm
-file is actually a Star-Buffer file
-.Pq see Xr sbuf 5 .
-It starts with a header of 4 integers.
-The first integer is a power of two
-.Pq usually 4096
-that defines the size of the memory page in bytes
-.Pq Va pagesize
-on which the list of properties are aligned.
-By aligning data to
-.Va pagesize ,
-and depending on system requirements, memory mapping can be used to
-automatically load/unload pages on demand
-.Pq see Xr mmap 2 .
-The second integer is the
-.Va size
-of the array, i.e. the number of property sets stored in the list.
-The 2 remaining integers store the memory size
-.Pq 8 bytes
-and the memory alignment
-.Pq 8 bytes
-of the property set defined by geometric primitive.
-.Pp
-Fill bytes follow the file header to align the listed properties to
-.Va pagesize .
-.Pp
-For each geometric primitive, the properties are composed of a 32-bit integer,
-which is the material identifier of the primitive
-.Pq Va matid ,
-and a 32-bit floating-point number that stores temperature in Kelvin.
-.Pp
-Padding bytes are finally added at the end of the file to align its overall size
-with the size of a page.
-.Pp
-Data are encoded with respect to the little endian bytes ordering, i.e. least
-significant bytes are stored first.
-.Pp
-The file format is as follows:
-.Bl -column (temperature) (::=) ()
-.It Ao Va rnsp Ac Ta ::= Ta Ao Va pagesize Ac Ao Va size Ac Li 8 8
-.It Ta Ta Aq Va padding
-.It Ta Ta Aq Va properties
-.It Ta Ta Aq Va padding
-.It Ao Va pagesize Ac Ta ::= Ta Vt uint64_t
-.It Ao Va size Ac Ta ::= Ta Vt uint64_t
-# Number of items stored
-.It \ Ta Ta
-.It Ao Va properties Ac Ta ::= Ta Ao Va property Ac Va ...
-.It Ao Va property Ac Ta ::= Ta Ao Va matid Ac Ao Va temperature Ac
-.It Ao Va matid Ac Ta ::= Ta Vt uint32_t
-.It Ao Va temperature Ac Ta ::= Ta Vt float
-# In K
-.It \ Ta Ta
-.It Ao Va padding Ac Ta ::= Ta Op Vt int8_t ...
-.El
-.Sh SEE ALSO
-.Xr mmap 2 ,
-.Xr sbuf 5 ,
-.Xr smsh 5
-.Sh HISTORY
-The
-.Nm
-format was first developed for the
-.Xr htrdr-planeto 1
-program.
diff --git a/src/rngrd.c b/src/rngrd.c
@@ -1,7 +1,7 @@
/* Copyright (C) 2022, 2023, 2025 Centre National de la Recherche Scientifique
* Copyright (C) 2022, 2023, 2025 Institut Pierre-Simon Laplace
* Copyright (C) 2022, 2023, 2025 Institut de Physique du Globe de Paris
- * Copyright (C) 2022, 2023, 2025 |Méso|Star> (contact@meso-star.com)
+ * Copyright (C) 2022, 2023, 2025, 2026 |Méso|Star> (contact@meso-star.com)
* Copyright (C) 2022, 2023, 2025 Observatoire de Paris
* Copyright (C) 2022, 2023, 2025 Université de Reims Champagne-Ardenne
* Copyright (C) 2022, 2023, 2025 Université de Versaille Saint-Quentin
diff --git a/src/rngrd.h b/src/rngrd.h
@@ -1,7 +1,7 @@
/* Copyright (C) 2022, 2023, 2025 Centre National de la Recherche Scientifique
* Copyright (C) 2022, 2023, 2025 Institut Pierre-Simon Laplace
* Copyright (C) 2022, 2023, 2025 Institut de Physique du Globe de Paris
- * Copyright (C) 2022, 2023, 2025 |Méso|Star> (contact@meso-star.com)
+ * Copyright (C) 2022, 2023, 2025, 2026 |Méso|Star> (contact@meso-star.com)
* Copyright (C) 2022, 2023, 2025 Observatoire de Paris
* Copyright (C) 2022, 2023, 2025 Université de Reims Champagne-Ardenne
* Copyright (C) 2022, 2023, 2025 Université de Versaille Saint-Quentin
@@ -97,6 +97,23 @@ struct rngrd_trace_ray_args {
static const struct rngrd_trace_ray_args RNGRD_TRACE_RAY_ARGS_DEFAULT =
RNGRD_TRACE_RAY_ARGS_DEFAULT__;
+struct rngrd_closest_point_args {
+ double position[3];
+ double radius; /* Search radius around the position */
+
+ s3d_hit_filter_function_T filter; /* NULL <=> Return closest triangle */
+ void* filter_data; /* User data send to the filter function */
+};
+#define RNGRD_CLOSEST_POINT_ARGS_DEFAULT__ { \
+ {0,0,0}, /* Position */ \
+ DBL_MAX, /* Radius */ \
+ \
+ NULL, /* Filter function */ \
+ NULL /* Filter data */ \
+}
+static const struct rngrd_closest_point_args
+RNGRD_CLOSEST_POINT_ARGS_DEFAULT = RNGRD_CLOSEST_POINT_ARGS_DEFAULT__;
+
struct rngrd_create_bsdf_args {
struct s3d_primitive prim; /* Surface primitive to query */
double barycentric_coords[3]; /* Position into and relative to `prim' */
@@ -151,6 +168,12 @@ rngrd_trace_ray
struct s3d_hit* hit);
RNGRD_API res_T
+rngrd_closest_point
+ (const struct rngrd* ground,
+ struct rngrd_closest_point_args* args,
+ struct s3d_hit* hit);
+
+RNGRD_API res_T
rngrd_create_bsdf
(struct rngrd* ground,
const struct rngrd_create_bsdf_args* args,
diff --git a/src/rngrd_c.h b/src/rngrd_c.h
@@ -1,7 +1,7 @@
/* Copyright (C) 2022, 2023, 2025 Centre National de la Recherche Scientifique
* Copyright (C) 2022, 2023, 2025 Institut Pierre-Simon Laplace
* Copyright (C) 2022, 2023, 2025 Institut de Physique du Globe de Paris
- * Copyright (C) 2022, 2023, 2025 |Méso|Star> (contact@meso-star.com)
+ * Copyright (C) 2022, 2023, 2025, 2026 |Méso|Star> (contact@meso-star.com)
* Copyright (C) 2022, 2023, 2025 Observatoire de Paris
* Copyright (C) 2022, 2023, 2025 Université de Reims Champagne-Ardenne
* Copyright (C) 2022, 2023, 2025 Université de Versaille Saint-Quentin
diff --git a/src/rngrd_lint.c b/src/rngrd_lint.c
@@ -0,0 +1,140 @@
+/* Copyright (C) 2022, 2023, 2025 Centre National de la Recherche Scientifique
+ * Copyright (C) 2022, 2023, 2025 Institut Pierre-Simon Laplace
+ * Copyright (C) 2022, 2023, 2025 Institut de Physique du Globe de Paris
+ * Copyright (C) 2022, 2023, 2025, 2026 |Méso|Star> (contact@meso-star.com)
+ * Copyright (C) 2022, 2023, 2025 Observatoire de Paris
+ * Copyright (C) 2022, 2023, 2025 Université de Reims Champagne-Ardenne
+ * Copyright (C) 2022, 2023, 2025 Université de Versaille Saint-Quentin
+ * Copyright (C) 2022, 2023, 2025 Université Paul Sabatier
+ *
+ * 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/>. */
+
+#include "rngrd.h"
+
+#include <rsys/mem_allocator.h>
+
+#include <getopt.h>
+
+struct args {
+ struct rngrd_create_args rngrd;
+ int validate;
+ int quit;
+};
+#define ARGS_DEFAULT__ {RNGRD_CREATE_ARGS_DEFAULT__, 0, 0}
+static const struct args ARGS_DEFAULT = ARGS_DEFAULT__;
+
+/*******************************************************************************
+ * Helper functions
+ ******************************************************************************/
+static void
+usage(FILE* stream)
+{
+ fprintf(stream,
+ "usage: rngrd-lint [-hVv] -M material_list -m geometry -p properties\n");
+}
+
+static void
+args_release(struct args* args)
+{
+ ASSERT(args);
+ *args = ARGS_DEFAULT;
+}
+
+static res_T
+args_init(struct args* args, int argc, char** argv)
+{
+ res_T res = RES_OK;
+ int opt;
+ ASSERT(args && argc && argv);
+
+ *args = ARGS_DEFAULT;
+
+ while((opt = getopt(argc, argv, "hM:m:n:p:Vv")) != -1) {
+ switch(opt) {
+ case 'h':
+ usage(stdout);
+ args_release(args);
+ args->quit = 1;
+ goto exit;
+ case 'M': args->rngrd.mtllst_filename = optarg; break;
+ case 'm': args->rngrd.smsh_filename = optarg; break;
+ case 'n': args->rngrd.name = optarg; break;
+ case 'p': args->rngrd.props_filename = optarg; break;
+ case 'V': args->validate = 1; break;
+ case 'v': args->rngrd.verbose = 1; break;
+ default: res = RES_BAD_ARG; break;
+ }
+ if(res != RES_OK) {
+ if(optarg) {
+ fprintf(stderr, "%s: invalid option args `%s' -- `%c'\n",
+ argv[0], optarg, opt);
+ }
+ goto error;
+ }
+ }
+ #define MANDATORY(Cond, Name, Opt) { \
+ if(!(Cond)) { \
+ fprintf(stderr, "rngrd-lint: missing %s -- option '-%c'\n", (Name), (Opt)); \
+ res = RES_BAD_ARG; \
+ goto error; \
+ } \
+ } (void)0
+ MANDATORY(args->rngrd.mtllst_filename, "material list", 'M');
+ MANDATORY(args->rngrd.smsh_filename, "mesh", 'm');
+ MANDATORY(args->rngrd.props_filename, "properties", 'p');
+ #undef MANDATORY
+
+exit:
+ return res;
+error:
+ usage(stderr);
+ goto exit;
+}
+
+/*******************************************************************************
+ * Main function
+ ******************************************************************************/
+int
+main(int argc, char** argv)
+{
+ struct args args = ARGS_DEFAULT;
+ struct rngrd* rngrd = NULL;
+ res_T res = RES_OK;
+ int err = 0;
+
+ res = args_init(&args, argc, argv);
+ if(res != RES_OK) goto error;
+ if(args.quit) goto exit;
+
+ res = rngrd_create(&args.rngrd, &rngrd);
+ if(res != RES_OK) goto error;
+
+ if(args.validate) {
+ res = rngrd_validate(rngrd);
+ if(res != RES_OK) goto error;
+ }
+
+exit:
+ args_release(&args);
+ if(rngrd) RNGRD(ref_put(rngrd));
+ if(mem_allocated_size() !=0) {
+ fprintf(stderr, "Memory leaks: %lu bytes\n",
+ (unsigned long)mem_allocated_size());
+ err = -1;
+ }
+ return err;
+error:
+ err = -1;
+ goto exit;
+}
diff --git a/src/rngrd_log.c b/src/rngrd_log.c
@@ -1,7 +1,7 @@
/* Copyright (C) 2022, 2023, 2025 Centre National de la Recherche Scientifique
* Copyright (C) 2022, 2023, 2025 Institut Pierre-Simon Laplace
* Copyright (C) 2022, 2023, 2025 Institut de Physique du Globe de Paris
- * Copyright (C) 2022, 2023, 2025 |Méso|Star> (contact@meso-star.com)
+ * Copyright (C) 2022, 2023, 2025, 2026 |Méso|Star> (contact@meso-star.com)
* Copyright (C) 2022, 2023, 2025 Observatoire de Paris
* Copyright (C) 2022, 2023, 2025 Université de Reims Champagne-Ardenne
* Copyright (C) 2022, 2023, 2025 Université de Versaille Saint-Quentin
diff --git a/src/rngrd_log.h b/src/rngrd_log.h
@@ -1,7 +1,7 @@
/* Copyright (C) 2022, 2023, 2025 Centre National de la Recherche Scientifique
* Copyright (C) 2022, 2023, 2025 Institut Pierre-Simon Laplace
* Copyright (C) 2022, 2023, 2025 Institut de Physique du Globe de Paris
- * Copyright (C) 2022, 2023, 2025 |Méso|Star> (contact@meso-star.com)
+ * Copyright (C) 2022, 2023, 2025, 2026 |Méso|Star> (contact@meso-star.com)
* Copyright (C) 2022, 2023, 2025 Observatoire de Paris
* Copyright (C) 2022, 2023, 2025 Université de Reims Champagne-Ardenne
* Copyright (C) 2022, 2023, 2025 Université de Versaille Saint-Quentin
diff --git a/src/rngrd_mesh.c b/src/rngrd_mesh.c
@@ -1,7 +1,7 @@
/* Copyright (C) 2022, 2023, 2025 Centre National de la Recherche Scientifique
* Copyright (C) 2022, 2023, 2025 Institut Pierre-Simon Laplace
* Copyright (C) 2022, 2023, 2025 Institut de Physique du Globe de Paris
- * Copyright (C) 2022, 2023, 2025 |Méso|Star> (contact@meso-star.com)
+ * Copyright (C) 2022, 2023, 2025, 2026 |Méso|Star> (contact@meso-star.com)
* Copyright (C) 2022, 2023, 2025 Observatoire de Paris
* Copyright (C) 2022, 2023, 2025 Université de Reims Champagne-Ardenne
* Copyright (C) 2022, 2023, 2025 Université de Versaille Saint-Quentin
@@ -31,6 +31,14 @@
#include <rsys/float2.h>
#include <rsys/float3.h>
+struct filter_args {
+ struct s3d_hit hit;
+
+ s3d_hit_filter_function_T func; /* NULL <=> Stop RT at 1st hit triangle */
+ void* context; /* User data send to the filter function */
+};
+static const struct filter_args FILTER_ARGS_NULL = {S3D_HIT_NULL, NULL, NULL};
+
/*******************************************************************************
* Helper functions
******************************************************************************/
@@ -129,7 +137,7 @@ mesh_filter
void* ray_data,
void* filter_data)
{
- const struct rngrd_trace_ray_args* ray_args = ray_data;
+ const struct filter_args* filter = ray_data;
(void)filter_data;
/* Internally, Star-3D relies on Embree which, due to numerical imprecision,
@@ -138,18 +146,18 @@ mesh_filter
if(hit->distance <= ray_range[0] || hit->distance >= ray_range[1])
return 1;
- if(!ray_args) /* Nothing more to do */
+ if(!filter) /* Nothing more to do */
return 0;
/* Discard this intersection */
- if(self_hit(hit, ray_org, ray_dir, ray_range, &ray_args->hit_from))
+ if(self_hit(hit, ray_org, ray_dir, ray_range, &filter->hit))
return 1;
- if(!ray_args->filter) /* No user-defined filter functions */
+ if(!filter->func) /* No user-defined filter functions */
return 0;
- return ray_args->filter /* Invoke user-defined filtering */
- (hit, ray_org, ray_dir, ray_range, ray_args->filter_data, filter_data);
+ return filter->func /* Invoke user-defined filtering */
+ (hit, ray_org, ray_dir, ray_range, filter->context, filter_data);
}
static void
@@ -269,6 +277,7 @@ rngrd_trace_ray
struct rngrd_trace_ray_args* args,
struct s3d_hit* hit)
{
+ struct filter_args filter = FILTER_ARGS_NULL;
float org[3];
float dir[3];
float range[2];
@@ -283,9 +292,13 @@ rngrd_trace_ray
f3_set_d3(dir, args->ray_dir);
f2_set_d2(range, args->ray_range);
+ filter.hit = args->hit_from;
+ filter.func = args->filter;
+ filter.context = args->filter_data;
+
*hit = S3D_HIT_NULL;
- res = s3d_scene_view_trace_ray(ground->s3d_view, org, dir, range, args, hit);
+ res = s3d_scene_view_trace_ray(ground->s3d_view, org, dir, range, &filter, hit);
if(res != RES_OK) {
log_err(ground,
"%s: error tracing ray "
@@ -300,6 +313,44 @@ error:
goto exit;
}
+res_T
+rngrd_closest_point
+ (const struct rngrd* ground,
+ struct rngrd_closest_point_args* args,
+ struct s3d_hit* hit)
+{
+ struct filter_args filter = FILTER_ARGS_NULL;
+ float pos[3];
+ float radius;
+ res_T res = RES_OK;
+
+ if(!ground || !args || !hit) {
+ res = RES_BAD_ARG;
+ goto error;
+ }
+
+ f3_set_d3(pos, args->position);
+ radius = (float)args->radius;
+ filter.func = args->filter;
+ filter.context = args->filter_data;
+
+ *hit = S3D_HIT_NULL;
+
+ res = s3d_scene_view_closest_point(ground->s3d_view, pos, radius, &filter, hit);
+ if(res != RES_OK) {
+ log_err(ground,
+ "%s: error finding the closest point "
+ "(position = %g, %g, %g; radius = %g)\n",
+ FUNC_NAME, SPLIT3(pos), radius);
+ goto error;
+ }
+
+exit:
+ return res;
+error:
+ goto exit;
+}
+
/*******************************************************************************
* Local function
******************************************************************************/
diff --git a/src/rngrd_properties.c b/src/rngrd_properties.c
@@ -1,7 +1,7 @@
/* Copyright (C) 2022, 2023, 2025 Centre National de la Recherche Scientifique
* Copyright (C) 2022, 2023, 2025 Institut Pierre-Simon Laplace
* Copyright (C) 2022, 2023, 2025 Institut de Physique du Globe de Paris
- * Copyright (C) 2022, 2023, 2025 |Méso|Star> (contact@meso-star.com)
+ * Copyright (C) 2022, 2023, 2025, 2026 |Méso|Star> (contact@meso-star.com)
* Copyright (C) 2022, 2023, 2025 Observatoire de Paris
* Copyright (C) 2022, 2023, 2025 Université de Reims Champagne-Ardenne
* Copyright (C) 2022, 2023, 2025 Université de Versaille Saint-Quentin
diff --git a/src/test_rngrd.c b/src/test_rngrd.c
@@ -1,165 +0,0 @@
-/* Copyright (C) 2022, 2023, 2025 Centre National de la Recherche Scientifique
- * Copyright (C) 2022, 2023, 2025 Institut Pierre-Simon Laplace
- * Copyright (C) 2022, 2023, 2025 Institut de Physique du Globe de Paris
- * Copyright (C) 2022, 2023, 2025 |Méso|Star> (contact@meso-star.com)
- * Copyright (C) 2022, 2023, 2025 Observatoire de Paris
- * Copyright (C) 2022, 2023, 2025 Université de Reims Champagne-Ardenne
- * Copyright (C) 2022, 2023, 2025 Université de Versaille Saint-Quentin
- * Copyright (C) 2022, 2023, 2025 Université Paul Sabatier
- *
- * 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/>. */
-
-#include "rngrd.h"
-
-#include <rsys/mem_allocator.h>
-
-#include <getopt.h>
-
-struct args {
- struct rngrd_create_args rngrd;
- int validate;
- int quit;
-};
-#define ARGS_DEFAULT__ {RNGRD_CREATE_ARGS_DEFAULT__, 0, 0}
-static const struct args ARGS_DEFAULT = ARGS_DEFAULT__;
-
-/*******************************************************************************
- * Helper functions
- ******************************************************************************/
-static void
-print_help(const char* cmd)
-{
- ASSERT(cmd);
- printf(
-"Usage: %s -m mesh -p pops -M matlst [ option ... ]\n"
-"Test the Rad-Net GRound library\n\n", cmd);
- printf(
-" -h display this help and exit\n");
- printf(
-" -M matlst path toward the list of ground materials (rnsl(5))\n");
- printf(
-" -m mesh path toward the ground mesh (smsh(5))\n");
- printf(
-" -n name ground name\n");
- printf(
-" -p props path toward the ground properties (rnsp(5))\n");
- printf(
-" -V validate data\n");
- printf(
-" -v make the program verbose\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");
-}
-
-static void
-args_release(struct args* args)
-{
- ASSERT(args);
- *args = ARGS_DEFAULT;
-}
-
-static res_T
-args_init(struct args* args, int argc, char** argv)
-{
- res_T res = RES_OK;
- int opt;
- ASSERT(args && argc && argv);
-
- *args = ARGS_DEFAULT;
-
- while((opt = getopt(argc, argv, "hM:m:n:p:Vv")) != -1) {
- switch(opt) {
- case 'h':
- print_help(argv[0]);
- args_release(args);
- args->quit = 1;
- goto exit;
- case 'M': args->rngrd.mtllst_filename = optarg; break;
- case 'm': args->rngrd.smsh_filename = optarg; break;
- case 'n': args->rngrd.name = optarg; break;
- case 'p': args->rngrd.props_filename = optarg; break;
- case 'V': args->validate = 1; break;
- case 'v': args->rngrd.verbose = 1; break;
- default: res = RES_BAD_ARG; break;
- }
- if(res != RES_OK) {
- if(optarg) {
- fprintf(stderr, "%s: invalid option args `%s' -- `%c'\n",
- argv[0], optarg, opt);
- }
- goto error;
- }
- }
- if(!args->rngrd.smsh_filename) {
- fprintf(stderr, "Mesh filename is missing -- option `-m'\n");
- res = RES_BAD_ARG;
- goto error;
- }
- if(!args->rngrd.props_filename) {
- fprintf(stderr, "Properties filename is missing -- option `-p'\n");
- res = RES_BAD_ARG;
- goto error;
- }
- if(!args->rngrd.mtllst_filename) {
- fprintf(stderr, "The material list filename is missing -- option `-M'\n");
- res = RES_BAD_ARG;
- goto error;
- }
-
-exit:
- return res;
-error:
- args_release(args);
- goto exit;
-}
-
-/*******************************************************************************
- * Main function
- ******************************************************************************/
-int
-main(int argc, char** argv)
-{
- struct args args = ARGS_DEFAULT;
- struct rngrd* rngrd = NULL;
- res_T res = RES_OK;
- int err = 0;
-
- res = args_init(&args, argc, argv);
- if(res != RES_OK) goto error;
- if(args.quit) goto exit;
-
- res = rngrd_create(&args.rngrd, &rngrd);
- if(res != RES_OK) goto error;
-
- if(args.validate) {
- res = rngrd_validate(rngrd);
- if(res != RES_OK) goto error;
- }
-
-exit:
- args_release(&args);
- if(rngrd) RNGRD(ref_put(rngrd));
- if(mem_allocated_size() !=0) {
- fprintf(stderr, "Memory leaks: %lu bytes\n",
- (unsigned long)mem_allocated_size());
- err = -1;
- }
- return err;
-error:
- err = -1;
- goto exit;
-}