commit 62ff97ee72b9944937e10cc9ba9083bfaab55130
parent 646f16a4a9bced32ccb1e5f7509883cc6428d8b6
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Tue, 23 Aug 2016 16:53:47 +0200
Make box geometry available for other tests
Diffstat:
3 files changed, 101 insertions(+), 80 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -118,6 +118,7 @@ if(NOT NO_TEST)
function(build_test _name)
add_executable(${_name}
${SSOL_SOURCE_DIR}/test_ssol_utils.h
+ ${SSOL_SOURCE_DIR}/test_ssol_box.h
${SSOL_SOURCE_DIR}/${_name}.c)
target_link_libraries(${_name} solstice-solver RSys Star3D StarSP)
set(_libraries ${ARGN})
diff --git a/src/test_ssol_box.h b/src/test_ssol_box.h
@@ -0,0 +1,99 @@
+/* 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 TEST_SSOL_BOX_H
+#define TEST_SSOL_BOX_H
+
+ /*******************************************************************************
+ * Box
+ ******************************************************************************/
+struct desc {
+ const float* vertices;
+ const unsigned* indices;
+};
+
+static const float walls [] = {
+ 552.f, 0.f, 0.f,
+ 0.f, 0.f, 0.f,
+ 0.f, 559.f, 0.f,
+ 552.f, 559.f, 0.f,
+ 552.f, 0.f, 548.f,
+ 0.f, 0.f, 548.f,
+ 0.f, 559.f, 548.f,
+ 552.f, 559.f, 548.f
+};
+const unsigned walls_nverts = sizeof(walls) / sizeof(float[3]);
+
+const unsigned walls_ids [] = {
+ 0, 1, 2, 2, 3, 0, /* Bottom */
+ 4, 5, 6, 6, 7, 4, /* Top */
+ 1, 2, 6, 6, 5, 1, /* Left */
+ 0, 3, 7, 7, 4, 0, /* Right */
+ 2, 3, 7, 7, 6, 2 /* Back */
+};
+const unsigned walls_ntris = sizeof(walls_ids) / sizeof(unsigned[3]);
+
+static const struct desc walls_desc = { walls, walls_ids };
+
+/*******************************************************************************
+* Callbacks
+******************************************************************************/
+static INLINE void
+get_ids(const unsigned itri, unsigned ids[3], void* data)
+{
+ const unsigned id = itri * 3;
+ struct desc* desc = data;
+ NCHECK(desc, NULL);
+ ids[0] = desc->indices[id + 0];
+ ids[1] = desc->indices[id + 1];
+ ids[2] = desc->indices[id + 2];
+}
+
+static INLINE void
+get_position(const unsigned ivert, float position[3], void* data)
+{
+ struct desc* desc = data;
+ NCHECK(desc, NULL);
+ position[0] = desc->vertices[ivert * 3 + 0];
+ position[1] = desc->vertices[ivert * 3 + 1];
+ position[2] = desc->vertices[ivert * 3 + 2];
+}
+
+static INLINE void
+get_normal(const unsigned ivert, float normal[3], void* data)
+{
+ (void) ivert, (void) data;
+ normal[0] = 1.f;
+ normal[1] = 0.f;
+ normal[2] = 0.f;
+}
+
+static INLINE void
+get_uv(const unsigned ivert, float uv[2], void* data)
+{
+ (void) ivert, (void) data;
+ uv[0] = -1.f;
+ uv[1] = 1.f;
+}
+
+static INLINE void
+get_polygon_vertices(const size_t ivert, double position[2], void* ctx)
+{
+ (void) ivert, (void) ctx;
+ position[0] = -1.f;
+ position[1] = 1.f;
+}
+
+#endif /* TEST_SSOL_BOX_H */
diff --git a/src/test_ssol_shape.c b/src/test_ssol_shape.c
@@ -15,90 +15,11 @@
#include "ssol.h"
#include "test_ssol_utils.h"
+#include "test_ssol_box.h"
#include <rsys/logger.h>
/*******************************************************************************
- * Box
- ******************************************************************************/
-struct desc {
- const float* vertices;
- const unsigned* indices;
-};
-
-static const float walls [] = {
- 552.f, 0.f, 0.f,
- 0.f, 0.f, 0.f,
- 0.f, 559.f, 0.f,
- 552.f, 559.f, 0.f,
- 552.f, 0.f, 548.f,
- 0.f, 0.f, 548.f,
- 0.f, 559.f, 548.f,
- 552.f, 559.f, 548.f
-};
-const unsigned walls_nverts = sizeof(walls) / sizeof(float[3]);
-
-const unsigned walls_ids [] = {
- 0, 1, 2, 2, 3, 0, /* Bottom */
- 4, 5, 6, 6, 7, 4, /* Top */
- 1, 2, 6, 6, 5, 1, /* Left */
- 0, 3, 7, 7, 4, 0, /* Right */
- 2, 3, 7, 7, 6, 2 /* Back */
-};
-const unsigned walls_ntris = sizeof(walls_ids) / sizeof(unsigned[3]);
-
-static const struct desc walls_desc = { walls, walls_ids };
-
-/*******************************************************************************
- * Callbacks
- ******************************************************************************/
-static INLINE void
-get_ids(const unsigned itri, unsigned ids[3], void* data)
-{
- const unsigned id = itri * 3;
- struct desc* desc = data;
- NCHECK(desc, NULL);
- ids[0] = desc->indices[id + 0];
- ids[1] = desc->indices[id + 1];
- ids[2] = desc->indices[id + 2];
-}
-
-static INLINE void
-get_position(const unsigned ivert, float position[3], void* data)
-{
- struct desc* desc = data;
- NCHECK(desc, NULL);
- position[0] = desc->vertices[ivert * 3 + 0];
- position[1] = desc->vertices[ivert * 3 + 1];
- position[2] = desc->vertices[ivert * 3 + 2];
-}
-
-static INLINE void
-get_normal(const unsigned ivert, float normal[3], void* data)
-{
- (void) ivert, (void) data;
- normal[0] = 1.f;
- normal[1] = 0.f;
- normal[2] = 0.f;
-}
-
-static INLINE void
-get_uv(const unsigned ivert, float uv[2], void* data)
-{
- (void) ivert, (void) data;
- uv[0] = -1.f;
- uv[1] = 1.f;
-}
-
-static INLINE void
-get_polygon_vertices(const size_t ivert, double position[2], void* ctx)
-{
- (void) ivert, (void) ctx;
- position[0] = -1.f;
- position[1] = 1.f;
-}
-
-/*******************************************************************************
* Test main program
******************************************************************************/
int