htrdr

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

commit 665b15420bffc5117a5817681aa48d6bc8af1e66
parent 94bba955b26a67b46c4a076346ec7d108c03c1ca
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri, 28 Oct 2022 11:47:58 +0200

htrdr-planeto: add options of a perspective camera

Diffstat:
Msrc/combustion/htrdr_combustion_draw_map.c | 2+-
Msrc/planeto/htrdr_planeto.c | 3+++
Msrc/planeto/htrdr_planeto_args.c | 66++++++++++++++++++++++++++++++++++++++++++++++--------------------
Msrc/planeto/htrdr_planeto_args.h | 4++++
4 files changed, 54 insertions(+), 21 deletions(-)

diff --git a/src/combustion/htrdr_combustion_draw_map.c b/src/combustion/htrdr_combustion_draw_map.c @@ -287,7 +287,7 @@ combustion_draw_map(struct htrdr_combustion* cmd) res = htrdr_draw_map(cmd->htrdr, &args, cmd->buf); if(res != RES_OK) goto error; - /* No more to do on non master processes */ + /* Nothing more to do on non master processes */ if(htrdr_get_mpi_rank(cmd->htrdr) != 0) goto exit; /* Write buffer to output */ diff --git a/src/planeto/htrdr_planeto.c b/src/planeto/htrdr_planeto.c @@ -243,6 +243,9 @@ setup_buffer cmd->buf_layout.elmt_size = pixfmt.size; cmd->buf_layout.alignment = pixfmt.alignment; + /* Save the number of samples per pixel */ + cmd->spp = args->image.spp; + /* Create the image buffer only on the master process; Image parts rendered * by other processes are collected there */ if(htrdr_get_mpi_rank(cmd->htrdr) != 0) goto exit; diff --git a/src/planeto/htrdr_planeto_args.c b/src/planeto/htrdr_planeto_args.c @@ -107,14 +107,16 @@ print_help(const char* cmd) printf( "Usage: %s [-dfhv] [-s spectral_domain] [-t threads]\n" " [-T optical_thickness] [-V octree_definition]\n" -" [-O octrees_storage] [-o output]\n" -" [-a aerosol]... -g gas -G ground -S source\n", cmd); +" [-O octrees_storage] [-o output] [-C camera]\n" +" [-S source] [-G ground] [-a aerosol]... -g gas\n", cmd); printf( "Simulate radiative transfer in heterogeneous 3D planetary atmosphere.\n" "See htrdr-planeto(1) man page for details\n\n"); printf( " -a aerosol define an aerosol\n"); printf( +" -C camera configure a perspective camera\n"); + printf( " -d write the atmospheric acceleration structures\n"); printf( " -f force overwrite the output file\n"); @@ -476,7 +478,7 @@ htrdr_planeto_args_init(struct htrdr_planeto_args* args, int argc, char** argv) *args = HTRDR_PLANETO_ARGS_DEFAULT; - while((opt = getopt(argc, argv, "a:dfG:g:hi:O:o:S:s:T:t:V:v")) != -1) { + while((opt = getopt(argc, argv, "a:C:dfG:g:hi:O:o:S:s:T:t:V:v")) != -1) { switch(opt) { case 'a': sa_add(args->aerosols, 1); @@ -487,6 +489,10 @@ htrdr_planeto_args_init(struct htrdr_planeto_args* args, int argc, char** argv) res = check_aerosol_args(args->aerosols+args->naerosols-1); } break; + case 'C': + res = htrdr_args_camera_perspective_parse(&args->cam_persp, optarg); + args->output_type = HTRDR_PLANETO_ARGS_OUTPUT_IMAGE; + break; case 'd': args->output_type = HTRDR_PLANETO_ARGS_OUTPUT_OCTREES; break; @@ -545,21 +551,28 @@ htrdr_planeto_args_init(struct htrdr_planeto_args* args, int argc, char** argv) } } - res = check_gas_args(&args->gas); if(res != RES_OK) { fprintf(stderr, "Missing gas definition -- option '-a'\n"); goto error; } - res = check_ground_args(&args->ground); - if(res != RES_OK) { - fprintf(stderr, "Missing ground definition -- option '-G'\n"); - goto error; - } - res = htrdr_planeto_source_args_check(&args->source); - if(res != RES_OK) { - fprintf(stderr, "Missing source definition -- option '-S'\n"); - goto error; + + if(args->output_type != HTRDR_PLANETO_ARGS_OUTPUT_OCTREES) { + res = check_ground_args(&args->ground); + if(res != RES_OK) { + fprintf(stderr, "Missing ground definition -- option '-G'\n"); + goto error; + } + + /* Check the source */ + if(args->spectral_domain.spectral_type == HTRDR_SPECTRAL_SW + || args->spectral_domain.spectral_type == HTRDR_SPECTRAL_SW_CIE_XYZ) { + res = htrdr_planeto_source_args_check(&args->source); + if(res != RES_OK) { + fprintf(stderr, "Missing source definition -- option '-S'\n"); + goto error; + } + } } exit: @@ -614,10 +627,6 @@ htrdr_planeto_args_check(const struct htrdr_planeto_args* args) if(res != RES_OK) return res; } - /* Check the ground */ - res = check_ground_args(&args->ground); - if(res != RES_OK) return res; - /* Check the octree parameters */ if(args->octree_definition_hint == 0 || args->optical_thickness < 0) @@ -627,9 +636,26 @@ htrdr_planeto_args_check(const struct htrdr_planeto_args* args) res = check_spectral_args(&args->spectral_domain); if(res != RES_OK) return res; - /* Check the source */ - res = htrdr_planeto_source_args_check(&args->source); - if(res != RES_OK) return res; + if(args->output_type != HTRDR_PLANETO_ARGS_OUTPUT_OCTREES) { + /* Check the ground */ + res = check_ground_args(&args->ground); + if(res != RES_OK) return res; + + /* Check the source */ + if(args->spectral_domain.spectral_type == HTRDR_SPECTRAL_SW + || args->spectral_domain.spectral_type == HTRDR_SPECTRAL_SW_CIE_XYZ) { + res = htrdr_planeto_source_args_check(&args->source); + if(res != RES_OK) return res; + } + } + + if(args->output_type != HTRDR_PLANETO_ARGS_OUTPUT_IMAGE) { + res = htrdr_args_camera_perspective_check(&args->cam_persp); + if(res != RES_OK) return res; + + res = htrdr_args_image_check(&args->image); + if(res != RES_OK) return res; + } /* Check miscalleneous parameters */ if(args->nthreads == 0 diff --git a/src/planeto/htrdr_planeto_args.h b/src/planeto/htrdr_planeto_args.h @@ -71,6 +71,8 @@ struct htrdr_planeto_args { struct htrdr_planeto_source_args source; struct htrdr_args_image image; + struct htrdr_args_camera_perspective cam_persp; /* Perspective camera */ + /* Miscellaneous arguments */ unsigned nthreads; /* Hint on the nimber of threads to use */ enum htrdr_planeto_args_output_type output_type; @@ -94,6 +96,8 @@ struct htrdr_planeto_args { HTRDR_PLANETO_SOURCE_ARGS_NULL__, /* Source */ \ HTRDR_ARGS_IMAGE_DEFAULT__, /* Image */ \ \ + HTRDR_ARGS_CAMERA_PERSPECTIVE_DEFAULT__, /* Perspective camera */ \ + \ UINT_MAX, /* Number of threads */ \ HTRDR_PLANETO_ARGS_OUTPUT_IMAGE, \ 0, /* Force output overwrite */ \