commit 5d5b23c1dfe2e57b094516faf2bc833cebba2845
parent 37560fc4845676aff50bd7b05006526854dbf3db
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 28 Oct 2020 11:56:14 +0100
Add the -n option defining the name of the sky material
Diffstat:
10 files changed, 28 insertions(+), 19 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -75,6 +75,7 @@ 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_OPTICAL_THICKNESS_THRESHOLD "1")
+set(HTRDR_ARGS_DEFAULT_SKY_MTL_NAME "\"air\"")
configure_file(${HTRDR_SOURCE_DIR}/htrdr_version.h.in
${CMAKE_CURRENT_BINARY_DIR}/htrdr_version.h @ONLY)
diff --git a/src/htrdr.c b/src/htrdr.c
@@ -494,6 +494,7 @@ htrdr_init
htrdr->grid_max_definition[2] = args->grid_max_definition[2];
htrdr->spectral_type = args->spectral_type;
htrdr->ref_temperature = args->ref_temperature;
+ htrdr->sky_mtl_name = args->sky_mtl_name;
res = init_mpi(htrdr);
if(res != RES_OK) goto error;
diff --git a/src/htrdr.h b/src/htrdr.h
@@ -60,6 +60,7 @@ struct htrdr {
struct htrdr_buffer* buf;
struct htsky* sky;
+ const char* sky_mtl_name;
enum htrdr_spectral_type spectral_type;
double wlen_range_m[2]; /* Integration range in *meters* */
double ref_temperature; /* Reference temperature in Kelvin */
diff --git a/src/htrdr_args.c b/src/htrdr_args.c
@@ -65,6 +65,10 @@ print_help(const char* cmd)
printf(
" -m MIE file of Mie's data.\n");
printf(
+" -n SKY-NAME name used to identify the sky in the MATERIALS file.\n"
+" Its default value is `%s'.\n",
+ HTRDR_ARGS_DEFAULT.sky_mtl_name);
+ printf(
" -O CACHE name of the cache file used to store/restore the sky\n"
" data.\n");
printf(
@@ -531,7 +535,7 @@ htrdr_args_init(struct htrdr_args* args, int argc, char** argv)
}
}
- while((opt = getopt(argc, argv, "a:C:c:D:dfg:hi:M:m:O:o:p:Rrs:T:t:V:v")) != -1) {
+ while((opt = getopt(argc, argv, "a:C:c:D:dfg:hi:M:m:n:O:o:p:Rrs:T:t:V:v")) != -1) {
switch(opt) {
case 'a': args->filename_gas = optarg; break;
case 'C':
@@ -555,6 +559,7 @@ htrdr_args_init(struct htrdr_args* args, int argc, char** argv)
break;
case 'M': args->filename_mtl = optarg; break;
case 'm': args->filename_mie = optarg; break;
+ case 'n': args->sky_mtl_name = optarg; break;
case 'O': args->cache = optarg; break;
case 'o': args->output = optarg; break;
case 'p':
diff --git a/src/htrdr_args.h.in b/src/htrdr_args.h.in
@@ -32,6 +32,7 @@ struct htrdr_args {
const char* filename_mtl; /* Path of the materials */
const char* cache;
const char* output;
+ const char* sky_mtl_name;
struct {
double pos[3]; /* Center of the renctangle */
@@ -79,6 +80,7 @@ struct htrdr_args {
NULL, /* Mtl filename */ \
NULL, /* Cache filename */ \
NULL, /* Output filename */ \
+ @HTRDR_ARGS_DEFAULT_SKY_MTL_NAME@, /* Sky mtl name */ \
{ \
{@HTRDR_ARGS_DEFAULT_RECTANGLE_POS@}, /* Rectangle center */ \
{@HTRDR_ARGS_DEFAULT_RECTANGLE_TGT@}, /* Rectangle target */ \
diff --git a/src/htrdr_draw_map.c b/src/htrdr_draw_map.c
@@ -636,7 +636,7 @@ draw_pixel_flux
/* Begin the registration of the time spent in the realisation */
time_current(&t0);
- res = htrdr_sensor_sample_primary_ray(&htrdr->sensor, htrdr->ground, ipix,
+ res = htrdr_sensor_sample_primary_ray(&htrdr->sensor, htrdr, ipix,
pix_sz, rng, ray_org, ray_dir);
if(res != RES_OK) continue; /* Reject the current sample */
@@ -779,7 +779,7 @@ draw_pixel_xwave
/* Begin the registration of the time spent in the realisation */
time_current(&t0);
- res = htrdr_sensor_sample_primary_ray(sensor, htrdr->ground, ipix,
+ res = htrdr_sensor_sample_primary_ray(sensor, htrdr, ipix,
pix_sz, rng, ray_org, ray_dir);
if(res != RES_OK) continue; /* Reject the current sample */
diff --git a/src/htrdr_materials.c b/src/htrdr_materials.c
@@ -1,5 +1,5 @@
-/* Copyright (C) 2018, 2019 CNRS, Université Paul Sabatier
- * Copyright (C) 2018, 2019, 2020 |Meso|Star> (contact@meso-star.com)
+/* Copyright (C) 2018, 2019, 2020 |Meso|Star> (contact@meso-star.com)
+ * Copyright (C) 2018, 2019 CNRS, 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
diff --git a/src/htrdr_materials.h b/src/htrdr_materials.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 2018, 2019 CNRS, Université Paul Sabatier
- * Copyright (C) 2018, 2019, 2020 |Meso|Star> (contact@meso-star.com)
+/* Copyright (C) 2018, 2019, 2020 |Meso|Star> (contact@meso-star.com)
+ * Copyright (C) 2018, 2019 CNRS, 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
diff --git a/src/htrdr_sensor.c b/src/htrdr_sensor.c
@@ -53,7 +53,7 @@ sample_camera_ray
static res_T
sample_rectangle_ray
(struct htrdr_rectangle* rect,
- struct htrdr_ground* ground,
+ struct htrdr* htrdr,
const size_t ipix[2],
const double pix_sz[2],
struct ssp_rng* rng,
@@ -65,7 +65,7 @@ sample_rectangle_ray
const double up_dir[3] = {0,0,1};
const double range[2] = {0, INF};
double normal[3];
- ASSERT(rect && ground && ipix && pix_sz && rng && ray_org && ray_dir);
+ ASSERT(rect && htrdr && ipix && pix_sz && rng && ray_org && ray_dir);
/* Sample a position into the pixel, in the normalized image plane */
pix_samp[0] = ((double)ipix[0] + ssp_rng_canonical(rng)) * pix_sz[0];
@@ -75,7 +75,7 @@ sample_rectangle_ray
htrdr_rectangle_sample_pos(rect, pix_samp, ray_org);
/* Check that `ray_org' is not included into a geometry */
- HTRDR(ground_trace_ray(ground, ray_org, up_dir, range, NULL, &hit));
+ HTRDR(ground_trace_ray(htrdr->ground, ray_org, up_dir, range, NULL, &hit));
/* Up direction is occluded. Check if the sample must be rejected, i.e. does it
* lies inside a geometry? */
@@ -93,12 +93,11 @@ sample_rectangle_ray
/* Fetch the hit interface and retrieve the material into which the ray was
* traced */
- htrdr_ground_get_interface(ground, &hit, &interf);
+ htrdr_ground_get_interface(htrdr->ground, &hit, &interf);
mtl = cos_wi_N < 0 ? &interf.mtl_front : &interf.mtl_back;
- /* Reject the sample if the incident direction do not travel into the
- * external air */
- if(strcmp("air", mtl->name)) return RES_BAD_OP;
+ /* Reject the sample if the incident direction do not travel into the sky */
+ if(strcmp(mtl->name, htrdr->sky_mtl_name) != 0) return RES_BAD_OP;
}
/* Sample a ray direction */
@@ -114,7 +113,7 @@ sample_rectangle_ray
res_T
htrdr_sensor_sample_primary_ray
(const struct htrdr_sensor* sensor,
- struct htrdr_ground* ground,
+ struct htrdr* htrdr,
const size_t ipix[2],
const double pix_sz[2],
struct ssp_rng* rng,
@@ -127,8 +126,8 @@ htrdr_sensor_sample_primary_ray
res = sample_camera_ray(sensor->camera, ipix, pix_sz, rng, ray_org, ray_dir);
break;
case HTRDR_SENSOR_RECTANGLE:
- res = sample_rectangle_ray(sensor->rectangle, ground, ipix, pix_sz, rng,
- ray_org, ray_dir);
+ res = sample_rectangle_ray(sensor->rectangle, htrdr, ipix,
+ pix_sz, rng, ray_org, ray_dir);
break;
default: FATAL("Unreachable code.\n"); break;
}
diff --git a/src/htrdr_sensor.h b/src/htrdr_sensor.h
@@ -20,7 +20,7 @@
#include <rsys/rsys.h>
/* Forward declarations */
-struct htrdr_ground;
+struct htrdr;
struct ssp_rng;
enum htrdr_sensor_type {
@@ -37,7 +37,7 @@ struct htrdr_sensor {
extern LOCAL_SYM res_T
htrdr_sensor_sample_primary_ray
(const struct htrdr_sensor* sensor,
- struct htrdr_ground* ground,
+ struct htrdr* htrdr,
const size_t ipix[2],
const double pix_sz[2],
struct ssp_rng* rng,