htrdr

Solving radiative transfer in heterogeneous media
git clone git://git.meso-star.fr/htrdr.git
Log | Files | Refs | README | LICENSE

commit 06a309a6d58c2822d81ec64449d80db705febbaa
parent f963f4df779a87e96bf61c1d5dfb2f5512d5bdd5
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon, 12 Nov 2018 11:31:11 +0100

Write the man page of the htrdr CLI

Simplify the short help and add the "--version" option.

Diffstat:
MREADME.md | 9++++-----
Mcmake/CMakeLists.txt | 42++++++++++++++++++++++++++++++++++++++----
Acmake/doc/CMakeLists.txt | 90+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adoc/htrdr.1.txt.in | 259+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/htrdr_args.c | 73++++++++++++++++++++++++++++++++++++++++---------------------------------
Dsrc/htrdr_args.h | 108-------------------------------------------------------------------------------
Asrc/htrdr_args.h.in | 108+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/htrdr_version.h.in | 24++++++++++++++++++++++++
8 files changed, 563 insertions(+), 150 deletions(-)

diff --git a/README.md b/README.md @@ -6,11 +6,10 @@ Monte-Carlo algorithms in cloudy atmospheres. This program implements a rendering algorithm that computes the radiance in the spectral interval [380, 780] nanometres that reaches an image through a pinhole -camera. The rendered scene is at least composed of an infinite 1D atmosphere -along the Z axis. Optionally, one can add 3D data describing the cloud -properties and/or a geometry describing the ground with a lambertian -reflectivity. The clouds and the ground, can be both infinitely repeated along -the X and Y axis. +camera. The rendered scene is at least composed of an 1D atmosphere along the Z +axis. Optionally, one can add 3D data describing the cloud properties and/or a +geometry describing the ground with a lambertian reflectivity. The clouds and +the ground, can be both infinitely repeated along the X and Y axis. In addition of shared memory parallelism, htrdr supports the [*M*essage *P*assing *I*nterface](https://www.mpi-forum.org/) specification to diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -20,6 +20,9 @@ enable_testing() set(HTRDR_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../src) option(NO_TEST "Do not build the tests" OFF) +set(HTRDR_DOC "TROFF & HTML" CACHE STRING + "Type of the documentation to generate install.") + ################################################################################ # Check dependencies ################################################################################ @@ -52,16 +55,41 @@ include_directories( ${HTCP_INCLUDE_DIR} ${HTGOP_INCLUDE_DIR} ${HTMIE_INCLUDE_DIR} - ${MPI_INCLUDE_PATH}) + ${MPI_INCLUDE_PATH} + ${CMAKE_CURRENT_BINARY_DIR}) ################################################################################ -# Configure and define targets +# Generate files ################################################################################ set(VERSION_MAJOR 0) set(VERSION_MINOR 0) set(VERSION_PATCH 0) set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) +set(HTRDR_ARGS_DEFAULT_CAMERA_POS "0,0,0") +set(HTRDR_ARGS_DEFAULT_CAMERA_TGT "0,1,0") +set(HTRDR_ARGS_DEFAULT_CAMERA_UP "0,0,1") +set(HTRDR_ARGS_DEFAULT_CAMERA_FOV "70") +set(HTRDR_ARGS_DEFAULT_IMG_WIDTH "320") +set(HTRDR_ARGS_DEFAULT_IMG_HEIGHT "240") +set(HTRDR_ARGS_DEFAULT_IMG_SPP "1") +set(HTRDR_ARGS_DEFAULT_GROUND_REFLECTIVITY "0.5") + +configure_file(${HTRDR_SOURCE_DIR}/htrdr_version.h.in + ${CMAKE_CURRENT_BINARY_DIR}/htrdr_version.h @ONLY) + +configure_file(${HTRDR_SOURCE_DIR}/htrdr_args.h.in + ${CMAKE_CURRENT_BINARY_DIR}/htrdr_args.h @ONLY) + +################################################################################ +# Add sub projects +################################################################################ +add_subdirectory(doc) + +################################################################################ +# Configure and define targets +################################################################################ + set(HTRDR_FILES_SRC htrdr.c htrdr_args.c @@ -79,7 +107,6 @@ set(HTRDR_FILES_SRC set(HTRDR_FILES_INC htrdr.h htrdr_c.h - htrdr_args.h htrdr_buffer.h htrdr_camera.h htrdr_grid.h @@ -89,14 +116,21 @@ set(HTRDR_FILES_INC htrdr_sky.h htrdr_sun.h htrdr_solve.h) +set(HTRDR_FILES_INC2 # Generated files + htrdr_args.h + htrdr_version.h) + set(HTDRD_FILES_DOC COPYING README.md) # Prepend each file in the `HTRDR_FILES_<SRC|INC>' list by `HTRDR_SOURCE_DIR' rcmake_prepend_path(HTRDR_FILES_SRC ${HTRDR_SOURCE_DIR}) rcmake_prepend_path(HTRDR_FILES_INC ${HTRDR_SOURCE_DIR}) +rcmake_prepend_path(HTRDR_FILES_INC2 ${CMAKE_CURRENT_BINARY_DIR}) rcmake_prepend_path(HTRDR_FILES_DOC ${PROJECT_SOURCE_DIR}/../) -add_executable(htrdr ${HTRDR_FILES_SRC} ${HTRDR_FILES_INC}) +message(STATUS ${HTRDR_FILES_INC2}) + +add_executable(htrdr ${HTRDR_FILES_SRC} ${HTRDR_FILES_INC} ${HTRDR_FILES_INC2}) target_link_libraries(htrdr HTCP HTGOP HTMIE RSys Star3D Star3DAW StarSF StarSP StarVX) if(CMAKE_COMPILER_IS_GNUCC) diff --git a/cmake/doc/CMakeLists.txt b/cmake/doc/CMakeLists.txt @@ -0,0 +1,90 @@ +# Copyright (C) 2018 CNRS, Université Paul Sabatier, |Meso|Star> +# +# 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/>. + +string(REGEX MATCH ".*HTML.*" _html ${HTRDR_DOC}) +string(REGEX MATCH ".*ROFF.*" _roff ${HTRDR_DOC}) + +set(HTRDR_DOC_DIR ${PROJECT_SOURCE_DIR}/../doc) + +################################################################################ +# Look for asciidoc and a2x programs +################################################################################ +if(_html) + find_program(ASCIIDOC NAMES asciidoc asciidoc.py) + if(NOT ASCIIDOC) + unset(_html) + message(WARNING + "The `asciidoc' program is missing. " + "The htrdr HTML documentation cannot be generated.") + endif() +endif() + +if(_roff) + find_program(A2X NAMES a2x a2x.py) + if(NOT A2X) + unset(_roff) + message(WARNING + "The `a2x' program is missing. " + "The htrdr man pages cannot be generated.") + endif() +endif() + +################################################################################ +# Copy doc files +################################################################################ +configure_file(${HTRDR_SOURCE_DIR}/../doc/htrdr.1.txt.in + ${CMAKE_CURRENT_BINARY_DIR}/htrdr.1.txt @ONLY) + +add_custom_target(man-copy ALL) # TODO + +list(APPEND MAN_NAMES htrdr.1) + +################################################################################ +# ROFF man pages +################################################################################ +if(_roff) + set(A2X_OPTS -dmanpage -fmanpage) + set(MAN_FILES) + set(MAN5_FILES) + set(MAN1_FILES) + foreach(_name IN LISTS MAN_NAMES) + set(_man ${CMAKE_CURRENT_BINARY_DIR}/${_name}) + set(_txt ${CMAKE_CURRENT_BINARY_DIR}/${_name}.txt) + + add_custom_command( + OUTPUT ${_man} + COMMAND ${A2X} ${A2X_OPTS} ${_txt} + DEPENDS man-copy ${_txt} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Build ROFF man page ${_man}" + VERBATIM) + list(APPEND MAN_FILES ${_man}) + + string(REGEX MATCH "^.*.5$" _man5 ${_man}) + string(REGEX MATCH "^.*.1$" _man1 ${_man}) + if(_man1) + list(APPEND MAN1_FILES ${_man1}) + elseif(_man5) + list(APPEND MAN5_FILES ${_man5}) + else() + message(FATAL_ERROR "Unexpected man type") + endif() + endforeach() + add_custom_target(man-roff ALL DEPENDS ${MAN_FILES}) + + install(FILES ${MAN1_FILES} DESTINATION share/man/man1) + install(FILES ${MAN5_FILES} DESTINATION share/man/man5) +endif() + diff --git a/doc/htrdr.1.txt.in b/doc/htrdr.1.txt.in @@ -0,0 +1,259 @@ +// Copyright (C) 2018 CNRS, Université Paul Sabatier, |Meso|Star> +// +// 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/>. +:toc: + +htrdr(1) +======== + +NAME +---- +htrdr - render the image of a cloudy atmosphere + +SYNOPSIS +-------- +[verse] +*htrdr* [_option_]... -a _atmosphere_ -m _mie_ + +DESCRIPTION +----------- +*htrdr* is an image renderer in the visible part of the spectrum, for scenes +composed of an atmospheric gaz mixture, clouds, and a ground. It uses spectral +data that should be provided for the pressure and temperature atmospheric +vertical profile [1] (*-a* _atmosphere_), the liquid water content +in suspension within the clouds that is a result of Large Eddy Simulation +computations stored in a *htcp*(5) file (*-c* _clouds_), and the optical +properties of water droplets that have been obtained from a Mie code and +formatted according to the *htmie*(5) file format (*-m* _mie_). The user +also has to provide: the characteristics of the simulated camera (*-C* +_camera_), the sensor definition (*-i* _image_), and the position of the sun +(*-D* _azimuth_,_elevation_). It is also possible to provide an OBJ [2] +representing the ground geometry (*-g* _ground_). Both, the clouds and the +ground, can be infinitely repeated along the X and Y axis by setting the *-r* +and the *-R* options, respectively. + +*htrdr* evaluates the intensity incoming on each pixel of the sensor +array. The underlying algorithm is based on a Monte-Carlo method: it consists +in simulating a given number of optical paths originating from the camera, +directed into the atmosphere, taking into account light absorption and +scattering phenomena. The computation is performed over the whole visible part +of the spectrum, for the three components of the CIE 1931 XYZ colorimetric +space that are subsequently recombined in order to obtain the final color for +each pixel, and finally the whole image of the scene as seen from the required +observation position. + +In *htrdr* the spatial unit 1.0 corresponds to one meter. The estimated +radiance of each pixel component is given in W.sr^-1.m^-2. The pixels are +written into the _output_ file or to the standard output whether the *-o* +option is defined or not, respectively. The output image is al ist of raw +ASCII data formatted with respect to the *htrdr-image*(5) file format. Since +*htrdr* relies on the Monte-Carlo method, the estimated radiance of a pixel +component is provided with its numerical accuracy. + +*htrdr* supports the shared memory parallelism and relies on the Message +Passing Interface specification [5] to parallelise its computations in a +distribute memory environment. *htrdr* can thus be run either directly or +through a MPI process launcher like *mpirun*(1). + +OPTIONS +------- +*-a* _atmosphere_:: + Path toward the file containing the gas optical properties of the atmosphere. + Data must be formatted according to the fileformat described in [1]. + +*-c* _clouds_:: + Submit a *htcp*(5) file describing the properties of the clouds. If not + defined, only the atmopshere properties submitted through the *-a* option + are taken into account. + +*-C* <__camera-parameter__:...>:: + Define the rendering point of view. Available camera parameters are: + + **fov**=**_angle_**;; + Vertical field of view of the camera in [30, 120] degrees. By default + _angle_ is set to @HTRDR_ARGS_DEFAULT_CAMERA_FOV@ degrees. + + **pos**=**_x_**,**_y_**,**_z_**;; + Position of the camera. By default it is set to + {@HTRDR_ARGS_DEFAULT_CAMERA_POS@}. + + **tgt**=**_x_**,**_y_**,**_z_**;; + Position targeted by the camera. By default it is set to + {@HTRDR_ARGS_DEFAULT_CAMERA_TGT@}. + + **up**=**_x_**,**_y_**,**_z_**;; + Up vector of the camera. By default it is set to + {@HTRDR_ARGS_DEFAULT_CAMERA_UP@}. + +*-D* <__azimuth__,__elevation__>:: + Direction toward the sun center. The direction is defined by two angles in + degrees: the __azimuth__ angle in [0, 360[ and the __elevation__ angle in [0, + 90]. Following the right-handed convention, the azimuthal rotation is + counter-clockwise, with 0 degree on the X axis. The elevation starts from 0 + degree for a direction in the XY plane, up to 90 degrees at zenith. Thus + -D0,0 -D0,90 -D0,180 and -D0,270 will produce solar vectors {-1,0,0} {0,-1,0} + {+1,0,0} and {0,+1,0} respectively, while -D__azimuth__,90 will produce + {0,0,-1} regardless of _azimuth value. + +*-d*:: + Write in _output_ the data structure used to speed up the radiative transfer + computations in the clouds. The written data are 3D grids saved in the VTK + file format [4]. Each grid are separated of the previous one by a line with + three minus character, i.e. '---'. + +*-e* _reflectivity_:: + Reflectivity of the ground geometry in [0, 1]. By default it is set to + @HTRDR_ARGS_DEFAULT_GROUND_REFLECTIVITY@. + +*-f*:: + Force overwrite of the _output_ file. + +*-g* _ground_:: + Path toward an OBJ file [3] representing the ground geometry. + +*-G*:: + Pre-compute or use cached grids of the cloud properties built from the + _clouds_, the _atmosphere_ and the _mie_ files. If the corresponding grids + were generated in a previous run, reuse them as far as it is possible, i.e. + if the _clouds_, the _atmosphere_ and the _mie_ files were not updated. The + cached data, are written in a hidden directory named *.htrdr* located in the + directory where *htrdr* is run. On platforms with an efficient hard-drive and + plenty of random access memory, this cache mechanism can speed-up the + pre-computation step on _clouds_ data. Note that this option is incompatible + with a MPI execution and is thus forced to off if *htrdr* is run through a + process launcher. + +*-h*:: + List short help and exit. + +*-i* <__image-parameter__:>:: + Define the image to render. Available image parameters are: + + **def**=**_width_**,**_height_**;; + Definition of the image. By default the image definition is + @HTRDR_ARGS_DEFAULT_IMG_WIDTH@x@HTRDR_ARGS_DEFAULT_IMG_HEIGHT@. + + **spp**=**_samples-count_**;; + Number of samples per pixel and per component. i.e. the estimation of a + pixel will use "3 * _samples-count_" Monte-Carlo realisations, one set of + _samples-count_ realisations for each X, Y and Z component of the CIE 1931 + XYZ color space. By default, *spp* is set to @HTRDR_ARGS_DEFAULT_IMG_SPP@. + +*-R*:: + Infinitely repeat the _ground_ along the X and Y axis. + +*-r*:: + Infinitely repeat the _clouds_ along the X and Y axis. + +*-m* _mie_:: + Path toward a *htmie*(5) file defining the optical properties of water + droplets. + +*-o* _output_:: + File where *htrdr* write its _output_ data. If not defined, write results to + standard output. + +*-T* _threshold_:: + Optical thickness used as threshold criteria to partition the properties of + the clouds. By default its value is @HTRDR_ARGS_DEFAULT_OPTICAL_THICKNESS_THRESHOLD@. + +*-t* _threads-count_:: + Hint on the number of threads to use. By default use as many threads as CPU + cores. + +*-v*:: + Make *htrdr* verbose. + +*--version*:: + Display version information and exit. + +EXAMPLES +-------- + +Render a clear sky scene, i.e. a scene without any cloud, whose sun is at +zenith. The vertical atmospheric gaz mixture along the Z axis is described in +the *gas.txt* file. The Mie data are provided through the *Mie.nc* file and +the ground geometry is a quad repeated to the infinity. The camera is +positioned at 400 meters high and looks toward the positive Y axis. The +definition of the rendered image is *800* by *600* pixels and the radiance of +each pixel component is estimated with *64* Monte-Carlo realisations. The +resulting image is written to *output* excepted if the file already exists; in +this case an error is notified, the program stops and the *output* file +remains unchanged: + + $ htrdr -D0,90 -a gas.txt -m Mie.nc -g quad.obj -R \ + -C pos=0,0,400:tgt=0,1,0:up=0,0,1 \ + -i def=800x600:spp=64 \ + -o output + +Add clouds to the previous scene and use a more complex geometry to represent +the ground. The ground geometry was carefully designed to be cyclic and can be +thus repeated to the infinity without visual glitches. Use the *-f* option to +write the rendered image to *output* even though the file already exists: + + $ htrdr -D0,90 -a gas.txt -m Mie.nc -g mountains.obj -R -c clouds.htcp \ + -C pos=0,0,400:tgt=0,1,0:up=0,0,1 \ + -i def=800x600:spp=64 \ + -f -o output + +Move the sun by setting its azimuthal and elevation angles to *120* and *40* +degrees respectively. Use the *-G* option to enable the cache mechanism on +clouds data. Increase the image definition to *1280* by *720* and set the +number of samples per pixel component to *1024*. Write results on standard +output and redirect it to the *output* file: + + $ htrdr -D120,40 -a gas.txt -m Mie.nc -g mountains.obj -R -c clouds.htcp -G \ + -C pos=0,0,400:tgt=0,1,0:up=0,0,1 \ + -i def=1280x720:spp=1024 > output + +Write into *output* the data structures used to partition the clouds +properties. Use the *csplit*(1) Unix command to extract from *output* the list +of the generated grids and save each of them in a specific VTK file whose name +is *cloud_grid_*<__NUM__>*.vtk with __NUM__ in [0, N-1] where N is the number +of grids written into *output*: + + $ htrdr -a gas.txt -m Mie.nc -c clouds.htcp -d -f -o output + $ csplit -f cloud_grid_ -b %02d.vtk -z --suppress-matched output /^---$/ {*} + +Use *mpirun*(1) to launch *htrdr* on several hosts defined in the *my_hosts* +file. Make the clouds infinite along the X and Y axis: + + $ mpirun --hostfile my_hosts htrdr \ + -D120,40 -a gas.txt -m Mie.nc -g mountains.obj -R -c clouds.htcp -r \ + -C pos=0,0,400:tgt=0,1,0:up=0,0,1 \ + -i def=1280x720:spp=1024 \ + -f -o output + +NOTES +----- +1. High-Tune: Gas Optical Properties file format - + <https://www.meso-star.com/projects/dowloads/htgop.pdf> +2. Network Common Data Form - <https://www.unidata.ucar.edu/software/netcdf/> +3. OBJ file format - + <http://www.martinreddy.net/gfx/3d/OBJ.spec> +4. VTK file format - + <http://www.vtk.org/wp-content/uploads/2015/04/file-formats.pdf> + +COPYRIGHT +--------- +*htrdr* is copyright &copy; 2018 CNRS, Université Paul Sabatier +<contact-edstar@laplace.univ-tlse.fr>, |Meso|Star> <contact@meso-star.com>. +License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. +This is a free software. You are free to change and redistribute it. There is +NO WARRANTY, to the extent permitted by law. + +SEE ALSO +-------- +*csplit*(1), *htpp*(1), *mpirun*(1), *htcp*(5), *htmie*(5), *htrdr-image*(5) + diff --git a/src/htrdr_args.c b/src/htrdr_args.c @@ -16,6 +16,7 @@ #define _POSIX_C_SOURCE 2 /* strtok_r support */ #include "htrdr_args.h" +#include "htrdr_version.h" #include <rsys/cstr.h> #include <rsys/double3.h> @@ -30,63 +31,57 @@ static void print_help(const char* cmd) { ASSERT(cmd); - printf("Usage: %s -i INPUT [OPIONS]\n", cmd); + printf("Usage: %s [OPION]... -a ATMOSPHERE -m MIE\n", cmd); printf( -"Estimates the radiance in the spectral interval [380, 780] nanometres that\n" -"reaches an image through a pinhole camera.\n\n"); +"Render an image in the visible part of the spectrum, for scenes composed of an\n" +"atmospheric gaz mixture, clouds and a ground.\n\n"); printf( -" -a FILENAME path of gas optical properties file.\n"); +" -a ATMOSPHERE gas optical properties of the atmosphere.\n"); printf( -" -c FILENAME path of the HTCP cloud properties file.\n"); +" -c CLOUDS properties of the clouds.\n"); printf( -" -C <camera> define the rendering point of view.\n"); +" -C <camera> define the rendering point of view.\n"); printf( " -D AZIMUTH,ELEVATION\n" -" sun direction in degrees. Following the right-handed\n" -" convention, the azimuthal rotation is counter-clockwise\n" -" around the Z axis, with 0 aligned on the X axis. The\n" -" elevation rotation starts from 0 up to 90 at zenith. By\n" -" default, the AZIMUTH angle is set to %g and the ELEVATION is\n" -" set to %g.\n", +" direction in degrees toward the sun center. By default\n" +" AZIMUTH is %g and ELEVATION is %g.\n", HTRDR_ARGS_DEFAULT.sun_azimuth, HTRDR_ARGS_DEFAULT.sun_elevation); printf( -" -d dump octree data to OUTPUT wrt the VTK ASCII file format.\n"); +" -d dump octrees data to OUTPUT and exit.\n"); printf( -" -e ground reflectivity in [0, 1]. By default its value is `%g'.\n", +" -e REFLECT ground reflectivity in [0, 1]. Default value is %g.\n", HTRDR_ARGS_DEFAULT.ground_reflectivity); printf( -" -f overwrite the OUTPUT file if it already exists.\n"); +" -f overwrite the OUTPUT file if it already exists.\n"); printf( -" -g FILENAME path of an OBJ file representing the ground geometry.\n"); +" -g GROUND ground geometry.\n"); printf( -" -G precompute/use grids of raw cloud opitical properties built\n" -" from the HTCP file, the atmospheric profile and the Mie's\n" -" data. If the corresponding grids were generated in a\n" -" previous run, reuse them as far as it is possible, i.e. if\n" -" the HTCP, Mie and atmospheric files were not updated.\n"); +" -G precompute/use cached grids of cloud properties.\n"); printf( -" -h display this help and exit.\n"); +" -h display this help and exit.\n"); printf( -" -i <image> define the image to compute.\n"); +" -i <image> define the image to compute.\n"); printf( -" -R infinitely repeat the ground along the X and Y axis.\n"); +" -R infinitely repeat the ground along the X and Y axis.\n"); printf( -" -r infinitely repeat the clouds along the X and Y axis.\n"); +" -r infinitely repeat the clouds along the X and Y axis.\n"); printf( -" -m FILENAME path of the Mie data file.\n"); +" -m MIE file of Mie's data.\n"); printf( -" -o OUTPUT file where data are written. If not defined, data are\n" -" written to standard output.\n"); +" -o OUTPUT file where data are written. If not defined, data are\n" +" written to standard output.\n"); printf( -" -T THRESHOLD optical thickness used as threshold during the octree\n" -" building. By default its value is `%g'.\n", +" -T THRESHOLD optical thickness used as threshold during the octree\n" +" building. By default its value is `%g'.\n", HTRDR_ARGS_DEFAULT.optical_thickness); printf( -" -t THREADS hint on the number of threads to use. By default use as\n" -" many threads as CPU cores.\n"); +" -t THREADS hint on the number of threads to use. By default use as\n" +" many threads as CPU cores.\n"); printf( -" -v make the program more verbose.\n"); +" -v make the program verbose.\n"); + printf( +" --version display version information and exit.\n"); printf("\n"); printf( "%s (C) 2018 CNRS, Université Paul Sabatier <contact-edstar@laplace.univ-tlse.fr>,\n" @@ -332,11 +327,23 @@ res_T htrdr_args_init(struct htrdr_args* args, int argc, char** argv) { int opt; + int i; res_T res = RES_OK; ASSERT(args && argc && argv); *args = HTRDR_ARGS_DEFAULT; + FOR_EACH(i, 1, argc) { + if(!strcmp(argv[i], "--version")) { + printf("High-Tune: RenDeRer %d.%d.%d\n", + HTRDR_VERSION_MAJOR, + HTRDR_VERSION_MINOR, + HTRDR_VERSION_PATCH); + args->quit = 1; + goto exit; + } + } + while((opt = getopt(argc, argv, "a:C:c:D:de:fGg:hi:m:o:RrT:t:v")) != -1) { switch(opt) { case 'a': args->filename_gas = optarg; break; diff --git a/src/htrdr_args.h b/src/htrdr_args.h @@ -1,108 +0,0 @@ -/* Copyright (C) 2018 CNRS, Université Paul Sabatier, |Meso|Star> - * - * 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/>. */ - -#ifndef HTRDR_ARGS_H -#define HTRDR_ARGS_H - -#include <rsys/rsys.h> - -struct htrdr_args { - const char* filename_gas; /* Path of the gas file */ - const char* filename_les; /* Path of the HTCP file */ - const char* filename_mie; /* Path of the Mie properties */ - const char* filename_obj; /* Path of the 3D geometry */ - const char* output; - - struct { - double pos[3]; /* Position */ - double tgt[3]; /* Target */ - double up[3]; /* Up vector */ - double sz[2]; /* Plane size in world space */ - } rectangle; - - struct { - double pos[3]; - double tgt[3]; - double up[3]; - double fov_y; /* In degrees */ - } camera; - - struct { - unsigned definition[2]; /* #pixels in X and Y */ - unsigned spp; /* #samples per pixel */ - } image; - - double sun_azimuth; /* In degrees */ - double sun_elevation; /* In degrees */ - double optical_thickness; /* Threshold used during octree building */ - double ground_reflectivity; /* Reflectivity of the ground */ - - unsigned nthreads; /* Hint on the number of threads to use */ - int force_overwriting; - int dump_vtk; /* Dump the loaded cloud properties in a VTK file */ - int cache_grids; /* Use grid caching mechanism */ - int verbose; /* Verbosity level */ - int repeat_clouds; /* Make the clouds infinite in X and Y */ - int repeat_ground; /* Make the ground infinite in X and Y */ - int quit; /* Quit the application */ -}; - -#define HTRDR_ARGS_DEFAULT__ { \ - NULL, /* Gas filename */ \ - NULL, /* LES filename */ \ - NULL, /* Mie filename */ \ - NULL, /* Obj filename */ \ - NULL, /* Output filename */ \ - { \ - {0, 0, 0}, /* plane position */ \ - {0, 0, 1}, /* plane target */ \ - {0, 1, 0}, /* plane up */ \ - {1, 1}, /* plane size */ \ - }, { \ - {0, 0, 0}, /* Camera position */ \ - {0, 0, 1}, /* Camera target */ \ - {0, 1, 0}, /* Camera up */ \ - 70, /* Horizontal field of view */ \ - }, { \ - {32, 32}, /* image definition */ \ - 1 /* #samples per pixel */ \ - }, \ - 0, /* Sun azimuth */ \ - 90, /* Sun elevation */ \ - 1.0, /* Optical thickness */ \ - 0.5, /* Ground reflectivity */ \ - (unsigned)~0, /* #threads */ \ - 0, /* Force overwriting */ \ - 0, /* dump VTK */ \ - 0, /* Grid cache */ \ - 0, /* Verbose flag */ \ - 0, /* Repeat clouds */ \ - 0, /* Repeat ground */ \ - 0 /* Quit the application */ \ -} -static const struct htrdr_args HTRDR_ARGS_DEFAULT = HTRDR_ARGS_DEFAULT__; - -extern LOCAL_SYM res_T -htrdr_args_init - (struct htrdr_args* args, - int argc, - char** argv); - -extern LOCAL_SYM void -htrdr_args_release - (struct htrdr_args* args); - -#endif /* HTRDR_ARGS_H */ - diff --git a/src/htrdr_args.h.in b/src/htrdr_args.h.in @@ -0,0 +1,108 @@ +/* Copyright (C) 2018 CNRS, Université Paul Sabatier, |Meso|Star> + * + * 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/>. */ + +#ifndef HTRDR_ARGS_H +#define HTRDR_ARGS_H + +#include <rsys/rsys.h> + +struct htrdr_args { + const char* filename_gas; /* Path of the gas file */ + const char* filename_les; /* Path of the HTCP file */ + const char* filename_mie; /* Path of the Mie properties */ + const char* filename_obj; /* Path of the 3D geometry */ + const char* output; + + struct { + double pos[3]; /* Position */ + double tgt[3]; /* Target */ + double up[3]; /* Up vector */ + double sz[2]; /* Plane size in world space */ + } rectangle; + + struct { + double pos[3]; + double tgt[3]; + double up[3]; + double fov_y; /* In degrees */ + } camera; + + struct { + unsigned definition[2]; /* #pixels in X and Y */ + unsigned spp; /* #samples per pixel */ + } image; + + double sun_azimuth; /* In degrees */ + double sun_elevation; /* In degrees */ + double optical_thickness; /* Threshold used during octree building */ + double ground_reflectivity; /* Reflectivity of the ground */ + + unsigned nthreads; /* Hint on the number of threads to use */ + int force_overwriting; + int dump_vtk; /* Dump the loaded cloud properties in a VTK file */ + int cache_grids; /* Use grid caching mechanism */ + int verbose; /* Verbosity level */ + int repeat_clouds; /* Make the clouds infinite in X and Y */ + int repeat_ground; /* Make the ground infinite in X and Y */ + int quit; /* Quit the application */ +}; + +#define HTRDR_ARGS_DEFAULT__ { \ + NULL, /* Gas filename */ \ + NULL, /* LES filename */ \ + NULL, /* Mie filename */ \ + NULL, /* Obj filename */ \ + NULL, /* Output filename */ \ + { \ + {0, 0, 0}, /* plane position */ \ + {0, 0, 1}, /* plane target */ \ + {0, 1, 0}, /* plane up */ \ + {1, 1}, /* plane size */ \ + }, { \ + {@HTRDR_ARGS_DEFAULT_CAMERA_POS@}, /* Camera position */ \ + {@HTRDR_ARGS_DEFAULT_CAMERA_TGT@}, /* Camera target */ \ + {@HTRDR_ARGS_DEFAULT_CAMERA_UP@}, /* Camera up */ \ + @HTRDR_ARGS_DEFAULT_CAMERA_FOV@, /* Horizontal field of view */ \ + }, { \ + {@HTRDR_ARGS_DEFAULT_IMG_WIDTH@, @HTRDR_ARGS_DEFAULT_IMG_HEIGHT@}, \ + @HTRDR_ARGS_DEFAULT_IMG_SPP@ \ + }, \ + 0, /* Sun azimuth */ \ + 90, /* Sun elevation */ \ + 1.0, /* Optical thickness */ \ + @HTRDR_ARGS_DEFAULT_GROUND_REFLECTIVITY@, /* Ground reflectivity */ \ + (unsigned)~0, /* #threads */ \ + 0, /* Force overwriting */ \ + 0, /* dump VTK */ \ + 0, /* Grid cache */ \ + 0, /* Verbose flag */ \ + 0, /* Repeat clouds */ \ + 0, /* Repeat ground */ \ + 0 /* Quit the application */ \ +} +static const struct htrdr_args HTRDR_ARGS_DEFAULT = HTRDR_ARGS_DEFAULT__; + +extern LOCAL_SYM res_T +htrdr_args_init + (struct htrdr_args* args, + int argc, + char** argv); + +extern LOCAL_SYM void +htrdr_args_release + (struct htrdr_args* args); + +#endif /* HTRDR_ARGS_H */ + diff --git a/src/htrdr_version.h.in b/src/htrdr_version.h.in @@ -0,0 +1,24 @@ +/* Copyright (C) 2018 CNRS, Université Paul Sabatier, |Meso|Star> + * + * 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/>. */ + +#ifndef HTRDR_VERSION_H +#define HTRDR_VERSION_H + +#define HTRDR_VERSION_MAJOR @VERSION_MAJOR@ +#define HTRDR_VERSION_MINOR @VERSION_MINOR@ +#define HTRDR_VERSION_PATCH @VERSION_PATCH@ + +#endif /* SOLSTICE_VERSION_H */ +