commit 4196a0f5f9ea60498b3ed67598e8ef84e0e5413c
parent 685263c5681692d22d713f887c928fb3c37d678c
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Fri, 16 Dec 2016 12:04:30 +0100
Merge branch 'master' of gitlab.com:meso-star/solstice
Diffstat:
5 files changed, 110 insertions(+), 61 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -48,7 +48,8 @@ include_directories(
${SolAnim_INCLUDE_DIR}
${SolSolver_INCLUDE_DIR}
${StarSP_INCLUDE_DIR}
- ${Star3DUT_INCLUDE_DIR})
+ ${Star3DUT_INCLUDE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR})
################################################################################
# Build subprojects
@@ -57,6 +58,20 @@ add_subdirectory(parser)
add_subdirectory(core)
################################################################################
+# Generate files
+################################################################################
+set(SOLSTICE_ARGS_DEFAULT_NREALISATIONS "10000")
+set(SOLSTICE_ARGS_DEFAULT_CAMERA_POS "0,0,0")
+set(SOLSTICE_ARGS_DEFAULT_CAMERA_TGT "0,0,-1")
+set(SOLSTICE_ARGS_DEFAULT_CAMERA_UP "0,1,0")
+set(SOLSTICE_ARGS_DEFAULT_CAMERA_FOV "70")
+set(SOLSTICE_ARGS_DEFAULT_IMG_WIDTH "800")
+set(SOLSTICE_ARGS_DEFAULT_IMG_HEIGHT "600")
+
+configure_file(${SOLSTICE_SOURCE_DIR}/solstice_args.h.in
+ ${CMAKE_CURRENT_BINARY_DIR}/solstice_args.h @ONLY)
+
+################################################################################
# Configure and define targets
################################################################################
set(VERSION_MAJOR 0)
@@ -72,7 +87,7 @@ set(SOLSTICE_FILES_SRC
solstice_object.c)
set(SOLSTICE_FILES_INC
solstice.h
- solstice_args.h
+ solstice_args.h.in
solstice_c.h)
set(SOLSTICE_FILES_DOC COPYING README.md)
diff --git a/src/solstice_args.c b/src/solstice_args.c
@@ -239,7 +239,7 @@ solstice_args_init(struct solstice_args* args, const int argc, char** argv)
res_T res = RES_OK;
ASSERT(args && argc && argv);
- *args = SOLSTICE_ARGS_NULL;
+ *args = SOLSTICE_ARGS_DEFAULT;
optind = 1;
while((opt = getopt(argc, argv, "hn:o:qr:")) != -1) {
diff --git a/src/solstice_args.h b/src/solstice_args.h
@@ -1,55 +0,0 @@
-/* Copyright (C) CNRS 2016
- *
- * 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 SOLSTICE_ARGS_H
-#define SOLSTICE_ARGS_H
-
-#include <rsys/rsys.h>
-
-struct solstice_args {
- const char* output_filename;
- unsigned long nrealisations; /* #realisations */
-
- struct {
- double pos[3];
- double tgt[3];
- double up[3];
- double fov_x;
- } camera;
-
- struct {
- unsigned long width;
- unsigned long height;
- } img;
-
- int rendering;
- int quiet;
-};
-
-#define SOLSTICE_ARGS_NULL__ {0}
-static const struct solstice_args SOLSTICE_ARGS_NULL = SOLSTICE_ARGS_NULL__;
-
-extern LOCAL_SYM res_T
-solstice_args_init
- (struct solstice_args* args,
- const int argc,
- char** argv);
-
-extern LOCAL_SYM void
-solstice_args_release
- (struct solstice_args* args);
-
-#endif /* SOLSTICE_ARGS_H */
-
diff --git a/src/solstice_args.h.in b/src/solstice_args.h.in
@@ -0,0 +1,77 @@
+/* Copyright (C) CNRS 2016
+ *
+ * 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 SOLSTICE_ARGS_H
+#define SOLSTICE_ARGS_H
+
+#include <rsys/math.h>
+
+struct solstice_args {
+ const char* output_filename;
+ unsigned long nrealisations; /* #realisations */
+
+ struct {
+ double pos[3];
+ double tgt[3];
+ double up[3];
+ double fov_x;
+ } camera;
+
+ struct {
+ unsigned long width;
+ unsigned long height;
+ } img;
+
+ int rendering;
+ int quiet;
+};
+
+#define SOLSTICE_ARGS_NULL__ {0}
+static const struct solstice_args SOLSTICE_ARGS_NULL = SOLSTICE_ARGS_NULL__;
+
+#define SOLSTICE_ARGS_DEFAULT__ { \
+ NULL, /* Output_filename */ \
+ @SOLSTICE_ARGS_DEFAULT_NREALISATIONS@, \
+ \
+ { /* Camera */ \
+ { @SOLSTICE_ARGS_DEFAULT_CAMERA_POS@ }, \
+ { @SOLSTICE_ARGS_DEFAULT_CAMERA_TGT@ }, \
+ { @SOLSTICE_ARGS_DEFAULT_CAMERA_UP@ }, \
+ MDEG2RAD(@SOLSTICE_ARGS_DEFAULT_CAMERA_FOV@) \
+ }, \
+ \
+ { /* Image */ \
+ @SOLSTICE_ARGS_DEFAULT_IMG_WIDTH@, \
+ @SOLSTICE_ARGS_DEFAULT_IMG_HEIGHT@ \
+ }, \
+ \
+ 0, /* Rendering */ \
+ 0 /* Quiet */ \
+}
+static const struct solstice_args SOLSTICE_ARGS_DEFAULT =
+ SOLSTICE_ARGS_DEFAULT__;
+
+extern LOCAL_SYM res_T
+solstice_args_init
+ (struct solstice_args* args,
+ const int argc,
+ char** argv);
+
+extern LOCAL_SYM void
+solstice_args_release
+ (struct solstice_args* args);
+
+#endif /* SOLSTICE_ARGS_H */
+
diff --git a/src/test_solstice_args.c b/src/test_solstice_args.c
@@ -73,9 +73,14 @@ main(int argc, char** argv)
cmd = cmd_create(0, "test", "-r", "img=1280x720", NULL);
CHECK(solstice_args_init(&args, cmd_size(cmd), cmd), RES_OK);
+ CHECK(args.rendering, 1);
+ CHECK(args.nrealisations, SOLSTICE_ARGS_DEFAULT.nrealisations);
+ CHECK(d3_eq(args.camera.pos, SOLSTICE_ARGS_DEFAULT.camera.pos), 1);
+ CHECK(d3_eq(args.camera.tgt, SOLSTICE_ARGS_DEFAULT.camera.tgt), 1);
+ CHECK(d3_eq(args.camera.up, SOLSTICE_ARGS_DEFAULT.camera.up), 1);
+ CHECK(args.camera.fov_x, SOLSTICE_ARGS_DEFAULT.camera.fov_x);
CHECK(args.img.width, 1280);
CHECK(args.img.height, 720);
- CHECK(args.rendering, 1);
CHECK(args.quiet, 0);
CHECK(args.output_filename, NULL);
solstice_args_release(&args);
@@ -83,11 +88,14 @@ main(int argc, char** argv)
cmd = cmd_create(0, "test", "-q", "-r", "img=640x480:fov=70:pos=1,2,3", NULL);
CHECK(solstice_args_init(&args, cmd_size(cmd), cmd), RES_OK);
+ CHECK(args.rendering, 1);
+ CHECK(args.nrealisations, SOLSTICE_ARGS_DEFAULT.nrealisations);
+ CHECK(d3_eq(args.camera.pos, d3(tmp, 1, 2, 3)), 1);
+ CHECK(d3_eq(args.camera.tgt, SOLSTICE_ARGS_DEFAULT.camera.tgt), 1);
+ CHECK(d3_eq(args.camera.up, SOLSTICE_ARGS_DEFAULT.camera.up), 1);
CHECK(args.img.width, 640);
CHECK(args.img.height, 480);
- CHECK(args.rendering, 1);
CHECK(args.quiet, 1);
- CHECK(d3_eq(args.camera.pos, d3(tmp, 1, 2, 3)), 1);
CHECK(eq_eps(args.camera.fov_x, MDEG2RAD(70), 1.e-6), 1);
CHECK(args.output_filename, NULL);
solstice_args_release(&args);
@@ -95,8 +103,12 @@ main(int argc, char** argv)
cmd = cmd_create(0, "test", "-r", "up=0,0,1:tgt=0,-10,0", NULL);
CHECK(solstice_args_init(&args, cmd_size(cmd), cmd), RES_OK);
+ CHECK(args.nrealisations, SOLSTICE_ARGS_DEFAULT.nrealisations);
+ CHECK(d3_eq(args.camera.pos, SOLSTICE_ARGS_DEFAULT.camera.pos), 1);
CHECK(d3_eq(args.camera.tgt, d3(tmp, 0,-10, 0)), 1);
CHECK(d3_eq(args.camera.up, d3(tmp, 0, 0, 1)), 1);
+ CHECK(args.img.width, SOLSTICE_ARGS_DEFAULT.img.width);
+ CHECK(args.img.height, SOLSTICE_ARGS_DEFAULT.img.height);
CHECK(args.rendering, 1);
CHECK(args.quiet, 0);
CHECK(args.output_filename, NULL);