commit 3411e7a80c38804c20e45779dfed4b8743771cf6
parent 3a8d762c360d98b5ea4cda00a695dd49cb7573e3
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 19 Feb 2018 14:03:22 +0100
Merge branch 'release_0.2.2'
Diffstat:
17 files changed, 367 insertions(+), 396 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,3 +1,4 @@
+compile_commands.json
.gitignore
CMakeCache.txt
CMakeFiles
diff --git a/README.md b/README.md
@@ -55,6 +55,10 @@ for further informations on CMake).
## Release notes
+### Version 0.2.2
+
+- Bump the version of the dependencies and fix the code to handle their updates.
+
### Version 0.2.1
- Fix a crash that occurred in scenes having medium with a null absorption. In
@@ -72,7 +76,7 @@ for further informations on CMake).
Star-GF is developed by [|Meso|Star>](http://www.meso-star.com) for
[Électricité De France](http://researchers.edf.com/edf-researchers-209799.html)
-(EDF). It is Copyright (C) 2015-2016 EDF
+(EDF). It is Copyright (C) 2015-2018 EDF
S.A., France (<syrthes-support@edf.fr>). It is a free software released under
the [OSI](http://opensource.org)-approved GPL v3.0 license. You are welcome to
redistribute it under certain conditions; refer to the COPYING file for
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2016 EDF S.A., France (syrthes-support@edf.fr)
+# Copyright (C) 2015-2018 EDF S.A., France (syrthes-support@edf.fr)
#
# 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
@@ -24,10 +24,10 @@ option(NO_TEST "Disable the test" OFF)
# Check dependencies
################################################################################
find_package(RCMake 0.2.3 REQUIRED)
-find_package(RSys 0.3 REQUIRED)
-find_package(StarSP 0.3 REQUIRED)
-find_package(Star3D 0.3 REQUIRED)
-find_package(Star2D REQUIRED)
+find_package(RSys 0.6 REQUIRED)
+find_package(StarSP 0.7 REQUIRED)
+find_package(Star3D 0.5 REQUIRED)
+find_package(Star2D 0.1 REQUIRED)
find_package(OpenMP 1.2 REQUIRED)
include_directories(
@@ -44,7 +44,7 @@ include(rcmake_runtime)
################################################################################
set(VERSION_MAJOR 0)
set(VERSION_MINOR 2)
-set(VERSION_PATCH 1)
+set(VERSION_PATCH 2)
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
set(SGF_FILES_SRC
diff --git a/src/sgf.h b/src/sgf.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015-2016 EDF S.A., France (syrthes-support@edf.fr)
+/* Copyright (C) 2015-2018 EDF S.A., France (syrthes-support@edf.fr)
*
* 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/sgf_device.c b/src/sgf_device.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015-2016 EDF S.A., France (syrthes-support@edf.fr)
+/* Copyright (C) 2015-2018 EDF S.A., France (syrthes-support@edf.fr)
*
* 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/sgf_device_c.h b/src/sgf_device_c.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015-2016 EDF S.A., France (syrthes-support@edf.fr)
+/* Copyright (C) 2015-2018 EDF S.A., France (syrthes-support@edf.fr)
*
* 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/sgf_estimator.c b/src/sgf_estimator.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015-2016 EDF S.A., France (syrthes-support@edf.fr)
+/* Copyright (C) 2015-2018 EDF S.A., France (syrthes-support@edf.fr)
*
* 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
@@ -139,15 +139,12 @@ sgf_integrate
const size_t steps_count,
struct sgf_estimator** out_estimator)
{
- #define SXD_FUNC(Func) (scn->dimensionality == 2 ? S2D(Func) : S3D(Func))
- #define SXD_ENUM(Enum) (scn->dimensionality == 2 ? S2D_##Enum : S3D_##Enum)
struct htable_bounce path;
struct sgf_estimator* estimator = NULL;
size_t istep;
size_t iband;
size_t nprims;
- void* scene;
- int mask;
+ void* view;
res_T res = RES_OK;
gebhart_radiative_path_T gebhart_radiative_path;
@@ -164,19 +161,20 @@ sgf_integrate
switch(scn->dimensionality) {
case 2:
- scene = scn->geometry.s2d.scn;
+ view = scn->geometry.s2d.view;
gebhart_radiative_path = gebhart_radiative_path_2d;
+ if(view) S2D(scene_view_primitives_count(view, &nprims));
break;
case 3:
- scene = scn->geometry.s3d.scn;
+ view = scn->geometry.s3d.view;
gebhart_radiative_path = gebhart_radiative_path_3d;
+ if(view) S3D(scene_view_primitives_count(view, &nprims));
break;
default: FATAL("Unreachable code\n"); break;
}
/* Check scene active sessions */
- SXD_FUNC(scene_get_session_mask(scene, &mask));
- if(!(mask & SXD_ENUM(TRACE)) || !(mask & SXD_ENUM(GET_PRIMITIVE))) {
+ if(!view) {
log_error(scn->dev,
"%s: no active integration on subimitted scene.\n", FUNC_NAME);
res = RES_BAD_OP;
@@ -184,7 +182,6 @@ sgf_integrate
}
/* Check submitted primitive_id */
- SXD_FUNC(scene_primitives_count(scene, &nprims));
if(iprim >= nprims) {
log_error(scn->dev, "%s: invalid primitive index `%lu'\n",
FUNC_NAME, (unsigned long)iprim);
@@ -277,9 +274,6 @@ exit:
error:
if(estimator) SGF(estimator_ref_put(estimator));
goto exit;
-
- #undef SXD_FUNC
- #undef SXD_ENUM
}
res_T
diff --git a/src/sgf_realisation.h b/src/sgf_realisation.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015-2016 EDF S.A., France (syrthes-support@edf.fr)
+/* Copyright (C) 2015-2018 EDF S.A., France (syrthes-support@edf.fr)
*
* 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
@@ -76,7 +76,7 @@ accum_weight(struct accum* accum, const double weight)
* 2D helper functions
******************************************************************************/
static FINLINE void
-primitive2d_get_normal(struct s2d_primitive* prim, float normal[3])
+primitive_get_normal_2d(struct s2d_primitive* prim, float normal[3])
{
struct s2d_attrib attr;
const float s = 0;
@@ -88,7 +88,7 @@ primitive2d_get_normal(struct s2d_primitive* prim, float normal[3])
}
static FINLINE void
-primitive2d_sample_position
+primitive_sample_position_2d
(struct s2d_primitive* prim,
struct ssp_rng* rng,
float position[3])
@@ -104,7 +104,7 @@ primitive2d_sample_position
}
static FINLINE void
-hit2d_get_normal(struct s2d_hit* hit, float normal[3])
+hit_get_normal_2d(struct s2d_hit* hit, float normal[3])
{
ASSERT(hit && normal);
f2_normalize(normal, hit->normal);
@@ -115,7 +115,7 @@ hit2d_get_normal(struct s2d_hit* hit, float normal[3])
* 3D helper functions
******************************************************************************/
static FINLINE void
-primitive3d_get_normal(struct s3d_primitive* prim, float normal[3])
+primitive_get_normal_3d(struct s3d_primitive* prim, float normal[3])
{
struct s3d_attrib attr;
const float st[2] = { 0.f, 0.f };
@@ -126,7 +126,7 @@ primitive3d_get_normal(struct s3d_primitive* prim, float normal[3])
}
static FINLINE void
-primitive3d_sample_position
+primitive_sample_position_3d
(struct s3d_primitive* prim,
struct ssp_rng* rng,
float position[3])
@@ -145,7 +145,7 @@ primitive3d_sample_position
}
static FINLINE void
-hit3d_get_normal(struct s3d_hit* hit, float normal[3])
+hit_get_normal_3d(struct s3d_hit* hit, float normal[3])
{
ASSERT(hit && normal);
f3_normalize(normal, hit->normal);
@@ -156,60 +156,23 @@ hit3d_get_normal(struct s3d_hit* hit, float normal[3])
#else /* !SGF_DIMENSIONALITY */
#if SGF_DIMENSIONALITY == 2
- #define GEBHART_RADIATIVE_PATH gebhart_radiative_path_2d
-
- /* Wrap type */
- #define sXd_scene_T struct s2d_scene
- #define sXd_hit_T struct s2d_hit
- #define sXd_primitive_T struct s2d_primitive
-
- /* Wrap macros */
- #define SXD_HIT_NONE(Hit) S2D_HIT_NONE(Hit)
- #define SXD_PRIMITIVE_EQ(A, B) S2D_PRIMITIVE_EQ(A, B)
-
- /* Wrap Functions */
- #define sXd_scene_get_primitive(Scn, IPrim, prim) \
- S2D(scene_get_primitive(Scn, IPrim, prim))
- #define sXd_primitive_get_normal(Prim, Normal) \
- primitive2d_get_normal(Prim, Normal)
- #define sXd_primitive_sample_position(Prim, Rng, Position) \
- primitive2d_sample_position(Prim, Rng, Position)
- #define sXd_scene_trace_ray(Scn, Org, Dir, Range, RayData, Hit) \
- S2D(scene_trace_ray_3d(Scn, Org, Dir, Range, RayData, Hit))
- #define sXd_hit_get_normal(Hit, Normal) \
- hit2d_get_normal(Hit, Normal)
- #define sgf_scene_get_sXd_scene(Scn) (Scn)->geometry.s2d.scn
+ /* Wrap */
+ #define sXd(Name) CONCAT(s2d_, Name)
+ #define SXD(Name) CONCAT(S2D_, Name)
+ #define Xd(Name) CONCAT(Name, _2d)
#elif SGF_DIMENSIONALITY == 3
- #define GEBHART_RADIATIVE_PATH gebhart_radiative_path_3d
-
- /* Wrap type */
- #define sXd_scene_T struct s3d_scene
- #define sXd_hit_T struct s3d_hit
- #define sXd_primitive_T struct s3d_primitive
-
- /* Wrap macros */
- #define SXD_HIT_NONE(Hit) S3D_HIT_NONE(Hit)
- #define SXD_PRIMITIVE_EQ(A, B) S3D_PRIMITIVE_EQ(A, B)
-
- /* Wrap Functions */
- #define sXd_scene_get_primitive(Scn, IPrim, prim) \
- S3D(scene_get_primitive(Scn, IPrim, prim))
- #define sXd_primitive_get_normal(Prim, Normal) \
- primitive3d_get_normal(Prim, Normal)
- #define sXd_primitive_sample_position(Prim, Rng, Position) \
- primitive3d_sample_position(Prim, Rng, Position)
- #define sXd_scene_trace_ray(Scn, Org, Dir, Range, RayData, Hit) \
- S3D(scene_trace_ray(Scn, Org, Dir, Range, RayData, Hit))
- #define sXd_hit_get_normal(Hit, Normal) \
- hit3d_get_normal(Hit, Normal)
- #define sgf_scene_get_sXd_scene(Scn) (Scn)->geometry.s3d.scn
+ /* Wrap */
+ #define sXd(Name) CONCAT(s3d_, Name)
+ #define SXD(Name) CONCAT(S3D_, Name)
+ #define Xd(Name) CONCAT(Name, _3d)
+
#else
#error Unexpected dimensionility
#endif
static res_T
-GEBHART_RADIATIVE_PATH
+Xd(gebhart_radiative_path)
(struct sgf_device* dev,
struct accum* accums,
struct accum* accum_infinity,
@@ -221,9 +184,9 @@ GEBHART_RADIATIVE_PATH
const size_t primitive_id,
struct sgf_scene* scn)
{
- sXd_scene_T* sXd_scn;
- sXd_hit_T hit;
- sXd_primitive_T prim;
+ struct sXd(scene_view)* view;
+ struct sXd(hit) hit;
+ struct sXd(primitive) prim;
struct htable_bounce_iterator it, end;
const double trans_min = 1.e-8; /* Minimum transmissivity threshold */
double proba_reflec_spec;
@@ -237,14 +200,18 @@ GEBHART_RADIATIVE_PATH
float vec0[3]; /* Temporary vector */
float normal[3]; /* Geometric normal */
float pos[3]; /* Radiative path position */
- float dir[4]; /* Radiative path direction. dir[3] <=> sampled dir pdf */
+ float dir[3]; /* Radiative path direction */
float range[2]; /* Traced ray range */
res_T res = RES_OK;
ASSERT(accums && rng && scn);
ASSERT(absorption_coef < 0 || accum_medium);
ASSERT(absorption_coef >= 0 || accum_infinity);
- sXd_scn = sgf_scene_get_sXd_scene(scn);
+#if SGF_DIMENSIONALITY == 2
+ view = scn->geometry.s2d.view;
+#else
+ view = scn->geometry.s3d.view;
+#endif
htable_bounce_clear(path);
/* Discard faces with no emissivity */
@@ -253,24 +220,28 @@ GEBHART_RADIATIVE_PATH
return RES_OK;
/* Retrieve the sXd_scn primitive */
- sXd_scene_get_primitive(sXd_scn, (unsigned)primitive_id, &prim);
+ sXd(scene_view_get_primitive)(view, (unsigned)primitive_id, &prim);
/* Get the geometric normal of the input primitive */
- sXd_primitive_get_normal(&prim, normal);
+ Xd(primitive_get_normal)(&prim, normal);
/* Uniformly sample prim to define the origin of the radiative path */
- sXd_primitive_sample_position(&prim, rng, pos);
+ Xd(primitive_sample_position)(&prim, rng, pos);
/* Cosine weighted sampling of the radiative path direction around `normal' */
- ssp_ran_hemisphere_cos(rng, normal, dir);
+ ssp_ran_hemisphere_cos_float(rng, normal, dir, NULL);
transmissivity = 1.0;
for(;;) { /* Here we go */
- sXd_primitive_T prim_from = prim;
+ struct sXd(primitive) prim_from = prim;
range[0] = FLT_MIN, range[1] = FLT_MAX;
- sXd_scene_trace_ray(sXd_scn, pos, dir, range, &prim_from, &hit);
+#if SGF_DIMENSIONALITY == 2
+ s2d_scene_view_trace_ray_3d(view, pos, dir, range, &prim_from, &hit);
+#else
+ s3d_scene_view_trace_ray(view, pos, dir, range, &prim_from, &hit);
+#endif
/* Handle medium absorption */
if(absorption_coef >= 0) {
- if(SXD_HIT_NONE(&hit)) { /* The ray shoulnd't be outside the volume */
+ if(SXD(HIT_NONE)(&hit)) { /* The ray shoulnd't be outside the volume */
log_error(dev,
"The radiative random walk goes to the infinity while the submitted geometry \n"
"should surround a close medium. This may be due to numerical issues or to an\n"
@@ -295,7 +266,7 @@ GEBHART_RADIATIVE_PATH
transmissivity *= medium_transmissivity;
medium_radiative_flux += weight;
}
- } else if(SXD_HIT_NONE(&hit)) { /* The ray is outside the volume */
+ } else if(SXD(HIT_NONE)(&hit)) { /* The ray is outside the volume */
infinite_radiative_flux = transmissivity;
break;
}
@@ -342,10 +313,10 @@ GEBHART_RADIATIVE_PATH
if(reflectivity <= 0.0) break;
proba_reflec_spec = specularity / reflectivity;
- sXd_hit_get_normal(&hit, normal);
+ Xd(hit_get_normal)(&hit, normal);
if(ssp_rng_canonical(rng) >= proba_reflec_spec) { /* Diffuse reflection */
- ssp_ran_hemisphere_cos(rng, normal, dir);
+ ssp_ran_hemisphere_cos_float(rng, normal, dir, NULL);
ASSERT(f3_dot(normal, dir) > 0);
} else { /* Specular reflection */
const float tmp = -2.f * f3_dot(dir, normal);
@@ -380,19 +351,9 @@ GEBHART_RADIATIVE_PATH
return RES_OK;
}
-#undef GEBHART_RADIATIVE_PATH
-#undef sXd_scene_T
-#undef sXd_hit_T
-#undef sXd_primitive_T
-#undef SXD_HIT_NONE
-#undef SXD_PRIMITIVE_EQ
-#undef sXd_scene_get_primitive
-#undef sXd_primitive_get_normal
-#undef sXd_primitive_sample_position
-#undef sXd_scene_trace_ray
-#undef sXd_hit_get_normal
-#undef sgf_scene_get_sXd_scene
-
+#undef sXd
+#undef SXD
+#undef Xd
#undef SGF_DIMENSIONALITY
#endif /* !SGF_DIMENSIONALITY */
diff --git a/src/sgf_scene.c b/src/sgf_scene.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015-2016 EDF S.A., France (syrthes-support@edf.fr)
+/* Copyright (C) 2015-2018 EDF S.A., France (syrthes-support@edf.fr)
*
* 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
@@ -364,48 +364,57 @@ sgf_scene_primitives_count(struct sgf_scene* scn, unsigned* nprims)
res_T
sgf_scene_begin_integration(struct sgf_scene* scn)
{
- int session_mask;
+ int i;
+ res_T res = RES_OK;
if(!scn) return RES_BAD_ARG;
if(scn->dimensionality == 2) {
- S2D(scene_get_session_mask(scn->geometry.s2d.scn, &session_mask));
+ i = scn->geometry.s2d.view == NULL;
} else {
ASSERT(scn->dimensionality == 3);
- S3D(scene_get_session_mask(scn->geometry.s3d.scn, &session_mask));
+ i = scn->geometry.s3d.view == NULL;
}
- if(session_mask != 0) {
+ if(!i) {
log_error(scn->dev, "%s: an integration process is already active.\n",
FUNC_NAME);
return RES_BAD_OP;
}
- return scn->dimensionality == 2
- ? s2d_scene_begin_session(scn->geometry.s2d.scn, S2D_TRACE|S2D_GET_PRIMITIVE)
- : s3d_scene_begin_session(scn->geometry.s3d.scn, S3D_TRACE|S3D_GET_PRIMITIVE);
+
+ if(scn->dimensionality == 2) {
+ res = s2d_scene_view_create(scn->geometry.s2d.scn,
+ S2D_TRACE|S2D_GET_PRIMITIVE, &scn->geometry.s2d.view);
+ } else {
+ res = s3d_scene_view_create(scn->geometry.s3d.scn,
+ S3D_TRACE|S3D_GET_PRIMITIVE, &scn->geometry.s3d.view);
+ }
+ return res;
}
res_T
sgf_scene_end_integration(struct sgf_scene* scn)
{
- int session_mask;
+ res_T res = RES_OK;
if(!scn) return RES_BAD_ARG;
if(scn->dimensionality == 2) {
- S2D(scene_get_session_mask(scn->geometry.s2d.scn, &session_mask));
- } else {
- ASSERT(scn->dimensionality == 3);
- S3D(scene_get_session_mask(scn->geometry.s3d.scn, &session_mask));
- }
-
- if(session_mask == 0) {
- log_error(scn->dev, "%s: there is no active integration process.\n",
- FUNC_NAME);
- return RES_BAD_OP;
- }
- if(scn->dimensionality == 2) {
- S2D(scene_end_session(scn->geometry.s2d.scn));
+ if(!scn->geometry.s2d.view) {
+ res = RES_BAD_OP;
+ } else {
+ res = s2d_scene_view_ref_put(scn->geometry.s2d.view);
+ if(res == RES_OK) scn->geometry.s2d.view = NULL;
+ }
} else {
- S3D(scene_end_session(scn->geometry.s3d.scn));
+ if(!scn->geometry.s3d.view) {
+ res = RES_BAD_OP;
+ } else {
+ res = s3d_scene_view_ref_put(scn->geometry.s3d.view);
+ if(res == RES_OK) scn->geometry.s3d.view = NULL;
+ }
}
- return RES_OK;
+ if(res != RES_OK) goto error;
+exit:
+ return res;
+error:
+ goto exit;
}
diff --git a/src/sgf_scene_c.h b/src/sgf_scene_c.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015-2016 EDF S.A., France (syrthes-support@edf.fr)
+/* Copyright (C) 2015-2018 EDF S.A., France (syrthes-support@edf.fr)
*
* 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
@@ -33,10 +33,12 @@ struct sgf_scene {
struct {
struct s2d_scene* scn;
struct s2d_shape* shape;
+ struct s2d_scene_view* view;
} s2d;
struct {
struct s3d_scene* scn;
struct s3d_shape* shape;
+ struct s3d_scene_view* view;
} s3d;
} geometry;
diff --git a/src/test_sgf_cube.c b/src/test_sgf_cube.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015-2016 EDF S.A., France (syrthes-support@edf.fr)
+/* Copyright (C) 2015-2018 EDF S.A., France (syrthes-support@edf.fr)
*
* 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
@@ -115,33 +115,33 @@ check_bottom_top_medium_gf
struct sgf_status status[6];
double E, SE;
- CHECK(sgf_scene_begin_integration(scn), RES_OK);
+ CHK(sgf_scene_begin_integration(scn) == RES_OK);
/* Estimate the Gebhart factors for the 1st triangle of the bottom face */
- CHECK(sgf_integrate(scn, BOTTOM0, rng, NSTEPS, &estimator), RES_OK);
- CHECK(sgf_estimator_get_status(estimator, TOP0, 0, status + 0), RES_OK);
- CHECK(sgf_estimator_get_status(estimator, TOP1, 0, status + 1), RES_OK);
- CHECK(sgf_estimator_get_status_medium(estimator, 0, status + 2), RES_OK);
- CHECK(sgf_estimator_get_status_medium(estimator, 0, status + 3), RES_OK);
- CHECK(sgf_estimator_ref_put(estimator), RES_OK);
+ CHK(sgf_integrate(scn, BOTTOM0, rng, NSTEPS, &estimator) == RES_OK);
+ CHK(sgf_estimator_get_status(estimator, TOP0, 0, status + 0) == RES_OK);
+ CHK(sgf_estimator_get_status(estimator, TOP1, 0, status + 1) == RES_OK);
+ CHK(sgf_estimator_get_status_medium(estimator, 0, status + 2) == RES_OK);
+ CHK(sgf_estimator_get_status_medium(estimator, 0, status + 3) == RES_OK);
+ CHK(sgf_estimator_ref_put(estimator) == RES_OK);
/* Estimate the Gebhart factors for the 2nd triangle of the bottom face */
- CHECK(sgf_integrate(scn, BOTTOM1, rng, NSTEPS, &estimator), RES_OK);
- CHECK(sgf_estimator_get_status(estimator, TOP0, 0, status + 4), RES_OK);
- CHECK(sgf_estimator_get_status(estimator, TOP1, 0, status + 5), RES_OK);
- CHECK(sgf_estimator_ref_put(estimator), RES_OK);
+ CHK(sgf_integrate(scn, BOTTOM1, rng, NSTEPS, &estimator) == RES_OK);
+ CHK(sgf_estimator_get_status(estimator, TOP0, 0, status + 4) == RES_OK);
+ CHK(sgf_estimator_get_status(estimator, TOP1, 0, status + 5) == RES_OK);
+ CHK(sgf_estimator_ref_put(estimator) == RES_OK);
/* Check the Gebhart factor between the bottom and the top plane. */
E = (status[0].E + status[1].E + status[4].E + status[5].E)/2;
SE = (status[0].SE + status[1].SE + status[4].SE + status[5].SE)/2;
- CHECK(eq_eps(E, gf_bottom_top, SE), 1);
+ CHK(eq_eps(E, gf_bottom_top, SE) == 1);
/* Check the Gebhart factor between the bottom plane and the medium */
E = (status[2].E + status[3].E)/2;
SE = (status[2].SE + status[3].SE)/2;
- CHECK(eq_eps(E, gf_bottom_medium, SE), 1);
+ CHK(eq_eps(E, gf_bottom_medium, SE) == 1);
- CHECK(sgf_scene_end_integration(scn), RES_OK);
+ CHK(sgf_scene_end_integration(scn) == RES_OK);
}
int
@@ -164,9 +164,9 @@ main(int argc, char** argv)
mem_init_proxy_allocator(&allocator, &mem_default_allocator);
nbuckets = (unsigned)omp_get_num_procs();
- CHECK(ssp_rng_proxy_create(&allocator, &ssp_rng_threefry, nbuckets, &proxy), RES_OK);
- CHECK(sgf_device_create(NULL, &allocator, 1, &sgf), RES_OK);
- CHECK(sgf_scene_create(sgf, &scn), RES_OK);
+ CHK(ssp_rng_proxy_create(&allocator, &ssp_rng_threefry, nbuckets, &proxy) == RES_OK);
+ CHK(sgf_device_create(NULL, &allocator, 1, &sgf) == RES_OK);
+ CHK(sgf_scene_create(sgf, &scn) == RES_OK);
shape.vertices = vertices;
shape.nvertices = nvertices;
@@ -186,15 +186,15 @@ main(int argc, char** argv)
desc.nbands = 1;
desc.context = &shape;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_OK);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_OK);
status = sa_add(status, nprims*nprims);
rngs = sa_add(rngs, nbuckets);
FOR_EACH(i, 0, nbuckets)
- CHECK(ssp_rng_proxy_create_rng(proxy, i, rngs + i), RES_OK);
+ CHK(ssp_rng_proxy_create_rng(proxy, i, rngs + i) == RES_OK);
- CHECK(sgf_scene_begin_integration(scn), RES_OK);
+ CHK(sgf_scene_begin_integration(scn) == RES_OK);
/* Integrate the Gebhart Factors */
#pragma omp parallel for
@@ -205,18 +205,18 @@ main(int argc, char** argv)
struct sgf_status infinity;
const int ithread = omp_get_thread_num();
- CHECK(sgf_integrate
- (scn, (size_t)iprim, rngs[ithread], NSTEPS, &est), RES_OK);
+ CHK(sgf_integrate
+ (scn, (size_t)iprim, rngs[ithread], NSTEPS, &est) == RES_OK);
FOR_EACH(iprim2, 0, nprims) {
- CHECK(sgf_estimator_get_status(est, iprim2, 0, row + iprim2), RES_OK);
- CHECK(row[iprim2].nsteps, NSTEPS);
+ CHK(sgf_estimator_get_status(est, iprim2, 0, row + iprim2) == RES_OK);
+ CHK(row[iprim2].nsteps == NSTEPS);
}
- CHECK(sgf_estimator_get_status_infinity(est, 0, &infinity), RES_OK);
- CHECK(eq_eps(infinity.E, 0, infinity.SE), 1);
+ CHK(sgf_estimator_get_status_infinity(est, 0, &infinity) == RES_OK);
+ CHK(eq_eps(infinity.E, 0, infinity.SE) == 1);
- CHECK(sgf_estimator_ref_put(est), RES_OK);
+ CHK(sgf_estimator_ref_put(est) == RES_OK);
}
/* Merge the radiative flux of coplanar primitives */
@@ -237,10 +237,10 @@ main(int argc, char** argv)
printf("%.6f ", E);
}
printf("\n");
- CHECK(eq_eps(sum, 1.0, 1.e-3), 1); /* Ensure the energy conservation */
+ CHK(eq_eps(sum, 1.0, 1.e-3) == 1); /* Ensure the energy conservation */
}
- CHECK(sgf_scene_end_integration(scn), RES_OK);
+ CHK(sgf_scene_end_integration(scn) == RES_OK);
/*
* Check medium attenuation with 2 parallel infinite planes. To simulate
@@ -254,32 +254,32 @@ main(int argc, char** argv)
desc.get_absorption = get_absorption;
FOR_EACH(i, 0, 12) ka[i] = 0;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_OK);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_OK);
check_bottom_top_medium_gf(scn, rngs[0], 1, 0);
FOR_EACH(i, 0, 12) ka[i] = 0.1;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_OK);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_OK);
check_bottom_top_medium_gf(scn, rngs[0], 0.832583, 0.167417);
FOR_EACH(i, 0, 12) ka[i] = 1;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_OK);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_OK);
check_bottom_top_medium_gf(scn, rngs[0], 0.219384, 0.780616);
FOR_EACH(i, 0, 12) ka[i] = 10;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_OK);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_OK);
check_bottom_top_medium_gf(scn, rngs[0], 7.0975e-6, 0.999992902);
- CHECK(ssp_rng_proxy_ref_put(proxy), RES_OK);
- CHECK(sgf_device_ref_put(sgf), RES_OK);
- CHECK(sgf_scene_ref_put(scn), RES_OK);
+ CHK(ssp_rng_proxy_ref_put(proxy) == RES_OK);
+ CHK(sgf_device_ref_put(sgf) == RES_OK);
+ CHK(sgf_scene_ref_put(scn) == RES_OK);
FOR_EACH(i, 0, nbuckets)
- CHECK(ssp_rng_ref_put(rngs[i]), RES_OK);
+ CHK(ssp_rng_ref_put(rngs[i]) == RES_OK);
sa_release(rngs);
sa_release(status);
check_memory_allocator(&allocator);
mem_shutdown_proxy_allocator(&allocator);
- CHECK(mem_allocated_size(), 0);
+ CHK(mem_allocated_size() == 0);
return 0;
}
diff --git a/src/test_sgf_device.c b/src/test_sgf_device.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015-2016 EDF S.A., France (syrthes-support@edf.fr)
+/* Copyright (C) 2015-2018 EDF S.A., France (syrthes-support@edf.fr)
*
* 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
@@ -35,39 +35,39 @@ main(int argc, char** argv)
struct sgf_device* dev;
(void)argc, (void)argv;
- CHECK(sgf_device_create(NULL, NULL, 0, NULL), RES_BAD_ARG);
- CHECK(sgf_device_create(NULL, NULL, 0, &dev), RES_OK);
+ CHK(sgf_device_create(NULL, NULL, 0, NULL) == RES_BAD_ARG);
+ CHK(sgf_device_create(NULL, NULL, 0, &dev) == RES_OK);
- CHECK(sgf_device_ref_get(NULL), RES_BAD_ARG);
- CHECK(sgf_device_ref_get(dev), RES_OK);
- CHECK(sgf_device_ref_put(NULL), RES_BAD_ARG);
- CHECK(sgf_device_ref_put(dev), RES_OK);
- CHECK(sgf_device_ref_put(dev), RES_OK);
+ CHK(sgf_device_ref_get(NULL) == RES_BAD_ARG);
+ CHK(sgf_device_ref_get(dev) == RES_OK);
+ CHK(sgf_device_ref_put(NULL) == RES_BAD_ARG);
+ CHK(sgf_device_ref_put(dev) == RES_OK);
+ CHK(sgf_device_ref_put(dev) == RES_OK);
mem_init_proxy_allocator(&allocator, &mem_default_allocator);
- CHECK(MEM_ALLOCATED_SIZE(&allocator), 0);
- CHECK(sgf_device_create(NULL, &allocator, 1, NULL), RES_BAD_ARG);
- CHECK(sgf_device_create(NULL, &allocator, 1, &dev), RES_OK);
- CHECK(sgf_device_ref_put(dev), RES_OK);
- CHECK(MEM_ALLOCATED_SIZE(&allocator), 0);
+ CHK(MEM_ALLOCATED_SIZE(&allocator) == 0);
+ CHK(sgf_device_create(NULL, &allocator, 1, NULL) == RES_BAD_ARG);
+ CHK(sgf_device_create(NULL, &allocator, 1, &dev) == RES_OK);
+ CHK(sgf_device_ref_put(dev) == RES_OK);
+ CHK(MEM_ALLOCATED_SIZE(&allocator) == 0);
- CHECK(logger_init(&allocator, &logger), RES_OK);
+ CHK(logger_init(&allocator, &logger) == RES_OK);
logger_set_stream(&logger, LOG_OUTPUT, log_stream, NULL);
logger_set_stream(&logger, LOG_ERROR, log_stream, NULL);
logger_set_stream(&logger, LOG_WARNING, log_stream, NULL);
- CHECK(sgf_device_create(&logger, NULL, 0, NULL), RES_BAD_ARG);
- CHECK(sgf_device_create(&logger, NULL, 0, &dev), RES_OK);
- CHECK(sgf_device_ref_put(dev), RES_OK);
+ CHK(sgf_device_create(&logger, NULL, 0, NULL) == RES_BAD_ARG);
+ CHK(sgf_device_create(&logger, NULL, 0, &dev) == RES_OK);
+ CHK(sgf_device_ref_put(dev) == RES_OK);
- CHECK(sgf_device_create(&logger, &allocator, 4, NULL), RES_BAD_ARG);
- CHECK(sgf_device_create(&logger, &allocator, 4, &dev), RES_OK);
- CHECK(sgf_device_ref_put(dev), RES_OK);
+ CHK(sgf_device_create(&logger, &allocator, 4, NULL) == RES_BAD_ARG);
+ CHK(sgf_device_create(&logger, &allocator, 4, &dev) == RES_OK);
+ CHK(sgf_device_ref_put(dev) == RES_OK);
logger_release(&logger);
check_memory_allocator(&allocator);
mem_shutdown_proxy_allocator(&allocator);
- CHECK(mem_allocated_size(), 0);
+ CHK(mem_allocated_size() == 0);
return 0;
}
diff --git a/src/test_sgf_estimator.c b/src/test_sgf_estimator.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015-2016 EDF S.A., France (syrthes-support@edf.fr)
+/* Copyright (C) 2015-2018 EDF S.A., France (syrthes-support@edf.fr)
*
* 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
@@ -79,9 +79,9 @@ main(int argc, char** argv)
mem_init_proxy_allocator(&allocator, &mem_default_allocator);
- CHECK(ssp_rng_create(&allocator, &ssp_rng_threefry, &rng), RES_OK);
- CHECK(sgf_device_create(NULL, &allocator, 1, &sgf), RES_OK);
- CHECK(sgf_scene_create(sgf, &scn), RES_OK);
+ CHK(ssp_rng_create(&allocator, &ssp_rng_threefry, &rng) == RES_OK);
+ CHK(sgf_device_create(NULL, &allocator, 1, &sgf) == RES_OK);
+ CHK(sgf_scene_create(sgf, &scn) == RES_OK);
shape.vertices = vertices;
shape.nvertices = nvertices;
@@ -101,100 +101,100 @@ main(int argc, char** argv)
desc.nbands = 1;
desc.context = &shape;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_OK);
- CHECK(sgf_scene_begin_integration(scn), RES_OK);
-
- CHECK(sgf_integrate(NULL, SIZE_MAX, NULL, 0, NULL), RES_BAD_ARG);
- CHECK(sgf_integrate(scn, SIZE_MAX, NULL, 0, NULL), RES_BAD_ARG);
- CHECK(sgf_integrate(NULL, 0, NULL, 0, NULL), RES_BAD_ARG);
- CHECK(sgf_integrate(scn, 0, NULL, 0, NULL), RES_BAD_ARG);
- CHECK(sgf_integrate(NULL, SIZE_MAX, rng, 0, NULL), RES_BAD_ARG);
- CHECK(sgf_integrate(scn, SIZE_MAX, rng, 0, NULL), RES_BAD_ARG);
- CHECK(sgf_integrate(NULL, 0, rng, 0, NULL), RES_BAD_ARG);
- CHECK(sgf_integrate(scn, 0, rng, 0, NULL), RES_BAD_ARG);
- CHECK(sgf_integrate(NULL, SIZE_MAX, NULL, NSTEPS, NULL), RES_BAD_ARG);
- CHECK(sgf_integrate(scn, SIZE_MAX, NULL, NSTEPS, NULL), RES_BAD_ARG);
- CHECK(sgf_integrate(NULL, 0, NULL, NSTEPS, NULL), RES_BAD_ARG);
- CHECK(sgf_integrate(scn, 0, NULL, NSTEPS, NULL), RES_BAD_ARG);
- CHECK(sgf_integrate(NULL, SIZE_MAX, rng, NSTEPS, NULL), RES_BAD_ARG);
- CHECK(sgf_integrate(scn, SIZE_MAX, rng, NSTEPS, NULL), RES_BAD_ARG);
- CHECK(sgf_integrate(NULL, 0, rng, NSTEPS, NULL), RES_BAD_ARG);
- CHECK(sgf_integrate(scn, 0, rng, NSTEPS, NULL), RES_BAD_ARG);
- CHECK(sgf_integrate(NULL, SIZE_MAX, NULL, 0, &estimator), RES_BAD_ARG);
- CHECK(sgf_integrate(scn, SIZE_MAX, NULL, 0, &estimator), RES_BAD_ARG);
- CHECK(sgf_integrate(NULL, 0, NULL, 0, &estimator), RES_BAD_ARG);
- CHECK(sgf_integrate(scn, 0, NULL, 0, &estimator), RES_BAD_ARG);
- CHECK(sgf_integrate(NULL, SIZE_MAX, rng, 0, &estimator), RES_BAD_ARG);
- CHECK(sgf_integrate(scn, SIZE_MAX, rng, 0, &estimator), RES_BAD_ARG);
- CHECK(sgf_integrate(NULL, 0, rng, 0, &estimator), RES_BAD_ARG);
- CHECK(sgf_integrate(scn, 0, rng, 0, &estimator), RES_BAD_ARG);
- CHECK(sgf_integrate(NULL, SIZE_MAX, NULL, NSTEPS, &estimator), RES_BAD_ARG);
- CHECK(sgf_integrate(scn, SIZE_MAX, NULL, NSTEPS, &estimator), RES_BAD_ARG);
- CHECK(sgf_integrate(NULL, 0, NULL, NSTEPS, &estimator), RES_BAD_ARG);
- CHECK(sgf_integrate(scn, 0, NULL, NSTEPS, &estimator), RES_BAD_ARG);
- CHECK(sgf_integrate(NULL, SIZE_MAX, rng, NSTEPS, &estimator), RES_BAD_ARG);
- CHECK(sgf_integrate(scn, SIZE_MAX, rng, NSTEPS, &estimator), RES_BAD_ARG);
- CHECK(sgf_integrate(NULL, 0, rng, NSTEPS, &estimator), RES_BAD_ARG);
- CHECK(sgf_integrate(scn, 0, rng, NSTEPS, &estimator), RES_OK);
-
- CHECK(sgf_estimator_get_status(NULL, SIZE_MAX, SIZE_MAX, NULL), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status(estimator, SIZE_MAX, SIZE_MAX, NULL), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status(NULL, 0, SIZE_MAX, NULL), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status(estimator, 0, SIZE_MAX, NULL), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status(NULL, SIZE_MAX, SIZE_MAX, &status), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status(estimator, SIZE_MAX, SIZE_MAX, &status), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status(NULL, 0, SIZE_MAX, &status), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status(estimator, 0, SIZE_MAX, &status), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status(NULL, SIZE_MAX, 0, NULL), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status(estimator, SIZE_MAX, 0, NULL), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status(NULL, 0, 0, NULL), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status(estimator, 0, 0, NULL), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status(NULL, SIZE_MAX, 0, &status), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status(estimator, SIZE_MAX, 0, &status), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status(NULL, 0, 0, &status), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status(estimator, 0, 0, &status), RES_OK);
- CHECK(status.nsteps, NSTEPS);
-
- CHECK(sgf_estimator_get_status_infinity(NULL, SIZE_MAX, NULL), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status_infinity(estimator, SIZE_MAX, NULL), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status_infinity(NULL, 0, NULL), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status_infinity(estimator, 0, NULL), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status_infinity(NULL, SIZE_MAX, &status), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status_infinity(estimator, SIZE_MAX, &status), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status_infinity(NULL, 0, &status), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status_infinity(estimator, 0, &status), RES_OK);
- CHECK(eq_eps(status.E, 0, status.SE), 1);
- CHECK(status.nsteps, NSTEPS);
-
- CHECK(sgf_estimator_get_status_medium(NULL, SIZE_MAX, NULL), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status_medium(estimator, SIZE_MAX, NULL), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status_medium(NULL, 0, NULL), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status_medium(estimator, 0, NULL), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status_medium(NULL, SIZE_MAX, &status), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status_medium(estimator, SIZE_MAX,&status), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status_medium(NULL, 0, &status), RES_BAD_ARG);
- CHECK(sgf_estimator_get_status_medium(estimator, 0, &status), RES_OK);
- CHECK(status.E, 0);
- CHECK(status.V, 0);
- CHECK(status.SE, 0);
- CHECK(status.nsteps, NSTEPS);
-
- CHECK(sgf_estimator_ref_get(NULL), RES_BAD_ARG);
- CHECK(sgf_estimator_ref_get(estimator), RES_OK);
- CHECK(sgf_estimator_ref_put(NULL), RES_BAD_ARG);
- CHECK(sgf_estimator_ref_put(estimator), RES_OK);
- CHECK(sgf_estimator_ref_put(estimator), RES_OK);
-
- CHECK(sgf_scene_end_integration(scn), RES_OK);
- CHECK(sgf_integrate(scn, 0, rng, NSTEPS, &estimator), RES_BAD_OP);
-
- CHECK(ssp_rng_ref_put(rng), RES_OK);
- CHECK(sgf_device_ref_put(sgf), RES_OK);
- CHECK(sgf_scene_ref_put(scn), RES_OK);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_OK);
+ CHK(sgf_scene_begin_integration(scn) == RES_OK);
+
+ CHK(sgf_integrate(NULL, SIZE_MAX, NULL, 0, NULL) == RES_BAD_ARG);
+ CHK(sgf_integrate(scn, SIZE_MAX, NULL, 0, NULL) == RES_BAD_ARG);
+ CHK(sgf_integrate(NULL, 0, NULL, 0, NULL) == RES_BAD_ARG);
+ CHK(sgf_integrate(scn, 0, NULL, 0, NULL) == RES_BAD_ARG);
+ CHK(sgf_integrate(NULL, SIZE_MAX, rng, 0, NULL) == RES_BAD_ARG);
+ CHK(sgf_integrate(scn, SIZE_MAX, rng, 0, NULL) == RES_BAD_ARG);
+ CHK(sgf_integrate(NULL, 0, rng, 0, NULL) == RES_BAD_ARG);
+ CHK(sgf_integrate(scn, 0, rng, 0, NULL) == RES_BAD_ARG);
+ CHK(sgf_integrate(NULL, SIZE_MAX, NULL, NSTEPS, NULL) == RES_BAD_ARG);
+ CHK(sgf_integrate(scn, SIZE_MAX, NULL, NSTEPS, NULL) == RES_BAD_ARG);
+ CHK(sgf_integrate(NULL, 0, NULL, NSTEPS, NULL) == RES_BAD_ARG);
+ CHK(sgf_integrate(scn, 0, NULL, NSTEPS, NULL) == RES_BAD_ARG);
+ CHK(sgf_integrate(NULL, SIZE_MAX, rng, NSTEPS, NULL) == RES_BAD_ARG);
+ CHK(sgf_integrate(scn, SIZE_MAX, rng, NSTEPS, NULL) == RES_BAD_ARG);
+ CHK(sgf_integrate(NULL, 0, rng, NSTEPS, NULL) == RES_BAD_ARG);
+ CHK(sgf_integrate(scn, 0, rng, NSTEPS, NULL) == RES_BAD_ARG);
+ CHK(sgf_integrate(NULL, SIZE_MAX, NULL, 0, &estimator) == RES_BAD_ARG);
+ CHK(sgf_integrate(scn, SIZE_MAX, NULL, 0, &estimator) == RES_BAD_ARG);
+ CHK(sgf_integrate(NULL, 0, NULL, 0, &estimator) == RES_BAD_ARG);
+ CHK(sgf_integrate(scn, 0, NULL, 0, &estimator) == RES_BAD_ARG);
+ CHK(sgf_integrate(NULL, SIZE_MAX, rng, 0, &estimator) == RES_BAD_ARG);
+ CHK(sgf_integrate(scn, SIZE_MAX, rng, 0, &estimator) == RES_BAD_ARG);
+ CHK(sgf_integrate(NULL, 0, rng, 0, &estimator) == RES_BAD_ARG);
+ CHK(sgf_integrate(scn, 0, rng, 0, &estimator) == RES_BAD_ARG);
+ CHK(sgf_integrate(NULL, SIZE_MAX, NULL, NSTEPS, &estimator) == RES_BAD_ARG);
+ CHK(sgf_integrate(scn, SIZE_MAX, NULL, NSTEPS, &estimator) == RES_BAD_ARG);
+ CHK(sgf_integrate(NULL, 0, NULL, NSTEPS, &estimator) == RES_BAD_ARG);
+ CHK(sgf_integrate(scn, 0, NULL, NSTEPS, &estimator) == RES_BAD_ARG);
+ CHK(sgf_integrate(NULL, SIZE_MAX, rng, NSTEPS, &estimator) == RES_BAD_ARG);
+ CHK(sgf_integrate(scn, SIZE_MAX, rng, NSTEPS, &estimator) == RES_BAD_ARG);
+ CHK(sgf_integrate(NULL, 0, rng, NSTEPS, &estimator) == RES_BAD_ARG);
+ CHK(sgf_integrate(scn, 0, rng, NSTEPS, &estimator) == RES_OK);
+
+ CHK(sgf_estimator_get_status(NULL, SIZE_MAX, SIZE_MAX, NULL) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status(estimator, SIZE_MAX, SIZE_MAX, NULL) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status(NULL, 0, SIZE_MAX, NULL) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status(estimator, 0, SIZE_MAX, NULL) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status(NULL, SIZE_MAX, SIZE_MAX, &status) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status(estimator, SIZE_MAX, SIZE_MAX, &status) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status(NULL, 0, SIZE_MAX, &status) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status(estimator, 0, SIZE_MAX, &status) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status(NULL, SIZE_MAX, 0, NULL) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status(estimator, SIZE_MAX, 0, NULL) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status(NULL, 0, 0, NULL) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status(estimator, 0, 0, NULL) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status(NULL, SIZE_MAX, 0, &status) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status(estimator, SIZE_MAX, 0, &status) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status(NULL, 0, 0, &status) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status(estimator, 0, 0, &status) == RES_OK);
+ CHK(status.nsteps == NSTEPS);
+
+ CHK(sgf_estimator_get_status_infinity(NULL, SIZE_MAX, NULL) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status_infinity(estimator, SIZE_MAX, NULL) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status_infinity(NULL, 0, NULL) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status_infinity(estimator, 0, NULL) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status_infinity(NULL, SIZE_MAX, &status) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status_infinity(estimator, SIZE_MAX, &status) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status_infinity(NULL, 0, &status) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status_infinity(estimator, 0, &status) == RES_OK);
+ CHK(eq_eps(status.E, 0, status.SE) == 1);
+ CHK(status.nsteps == NSTEPS);
+
+ CHK(sgf_estimator_get_status_medium(NULL, SIZE_MAX, NULL) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status_medium(estimator, SIZE_MAX, NULL) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status_medium(NULL, 0, NULL) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status_medium(estimator, 0, NULL) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status_medium(NULL, SIZE_MAX, &status) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status_medium(estimator, SIZE_MAX,&status) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status_medium(NULL, 0, &status) == RES_BAD_ARG);
+ CHK(sgf_estimator_get_status_medium(estimator, 0, &status) == RES_OK);
+ CHK(status.E == 0);
+ CHK(status.V == 0);
+ CHK(status.SE == 0);
+ CHK(status.nsteps == NSTEPS);
+
+ CHK(sgf_estimator_ref_get(NULL) == RES_BAD_ARG);
+ CHK(sgf_estimator_ref_get(estimator) == RES_OK);
+ CHK(sgf_estimator_ref_put(NULL) == RES_BAD_ARG);
+ CHK(sgf_estimator_ref_put(estimator) == RES_OK);
+ CHK(sgf_estimator_ref_put(estimator) == RES_OK);
+
+ CHK(sgf_scene_end_integration(scn) == RES_OK);
+ CHK(sgf_integrate(scn, 0, rng, NSTEPS, &estimator) == RES_BAD_OP);
+
+ CHK(ssp_rng_ref_put(rng) == RES_OK);
+ CHK(sgf_device_ref_put(sgf) == RES_OK);
+ CHK(sgf_scene_ref_put(scn) == RES_OK);
check_memory_allocator(&allocator);
mem_shutdown_proxy_allocator(&allocator);
- CHECK(mem_allocated_size(), 0);
+ CHK(mem_allocated_size() == 0);
return 0;
}
diff --git a/src/test_sgf_scene.c b/src/test_sgf_scene.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015-2016 EDF S.A., France (syrthes-support@edf.fr)
+/* Copyright (C) 2015-2018 EDF S.A., France (syrthes-support@edf.fr)
*
* 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
@@ -81,12 +81,12 @@ main(int argc, char** argv)
mem_init_proxy_allocator(&allocator, &mem_default_allocator);
- CHECK(sgf_device_create(NULL, &allocator, 1, &sgf), RES_OK);
+ CHK(sgf_device_create(NULL, &allocator, 1, &sgf) == RES_OK);
- CHECK(sgf_scene_create(NULL, NULL), RES_BAD_ARG);
- CHECK(sgf_scene_create(sgf, NULL), RES_BAD_ARG);
- CHECK(sgf_scene_create(NULL, &scn), RES_BAD_ARG);
- CHECK(sgf_scene_create(sgf, &scn), RES_OK);
+ CHK(sgf_scene_create(NULL, NULL) == RES_BAD_ARG);
+ CHK(sgf_scene_create(sgf, NULL) == RES_BAD_ARG);
+ CHK(sgf_scene_create(NULL, &scn) == RES_BAD_ARG);
+ CHK(sgf_scene_create(sgf, &scn) == RES_OK);
shape.emissivity = plane_emi;
shape.specularity = plane_spec;
@@ -106,60 +106,60 @@ main(int argc, char** argv)
desc.nverts = (unsigned)plane_nverts;
desc.nbands = 1;
- CHECK(sgf_scene_setup_3d(NULL, NULL), RES_BAD_ARG);
- CHECK(sgf_scene_setup_3d(scn, NULL), RES_BAD_ARG);
- CHECK(sgf_scene_setup_3d(NULL, &desc), RES_BAD_ARG);
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_OK);
+ CHK(sgf_scene_setup_3d(NULL, NULL) == RES_BAD_ARG);
+ CHK(sgf_scene_setup_3d(scn, NULL) == RES_BAD_ARG);
+ CHK(sgf_scene_setup_3d(NULL, &desc) == RES_BAD_ARG);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_OK);
- CHECK(sgf_scene_primitives_count(NULL, NULL), RES_BAD_ARG);
- CHECK(sgf_scene_primitives_count(scn, NULL), RES_BAD_ARG);
- CHECK(sgf_scene_primitives_count(NULL, &n), RES_BAD_ARG);
- CHECK(sgf_scene_primitives_count(scn, &n), RES_OK);
- CHECK(n, 2);
+ CHK(sgf_scene_primitives_count(NULL, NULL) == RES_BAD_ARG);
+ CHK(sgf_scene_primitives_count(scn, NULL) == RES_BAD_ARG);
+ CHK(sgf_scene_primitives_count(NULL, &n) == RES_BAD_ARG);
+ CHK(sgf_scene_primitives_count(scn, &n) == RES_OK);
+ CHK(n == 2);
desc.get_position = NULL;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_BAD_ARG);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_BAD_ARG);
desc.get_position = get_position;
desc.get_indices = NULL;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_BAD_ARG);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_BAD_ARG);
desc.get_indices = get_indices;
desc.get_emissivity = NULL;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_BAD_ARG);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_BAD_ARG);
desc.get_emissivity = get_emissivity;
desc.get_reflectivity = NULL;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_BAD_ARG);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_BAD_ARG);
desc.get_reflectivity = get_reflectivity;
desc.get_specularity = NULL;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_BAD_ARG);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_BAD_ARG);
desc.get_specularity = get_specularity;
desc.nprims = 0;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_BAD_ARG);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_BAD_ARG);
desc.nprims = (unsigned)plane_nprims;
desc.nverts = 0;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_BAD_ARG);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_BAD_ARG);
desc.nverts = (unsigned)plane_nverts;
desc.nbands = 0;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_BAD_ARG);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_BAD_ARG);
desc.nbands = 1;
shape.emissivity = plane_emi_bad;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_BAD_ARG);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_BAD_ARG);
shape.emissivity = plane_emi;
shape.specularity = plane_spec_bad;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_BAD_ARG);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_BAD_ARG);
shape.specularity = plane_spec;
desc.get_absorption = get_absorption;
shape.absorption = plane_abs;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_OK);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_OK);
shape.absorption = plane_abs_bad;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_BAD_ARG);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_BAD_ARG);
- CHECK(sgf_scene_begin_integration(NULL), RES_BAD_ARG);
- CHECK(sgf_scene_begin_integration(scn), RES_OK);
- CHECK(sgf_scene_begin_integration(scn), RES_BAD_OP);
+ CHK(sgf_scene_begin_integration(NULL) == RES_BAD_ARG);
+ CHK(sgf_scene_begin_integration(scn) == RES_OK);
+ CHK(sgf_scene_begin_integration(scn) == RES_BAD_OP);
- CHECK(sgf_scene_end_integration(NULL), RES_BAD_ARG);
- CHECK(sgf_scene_end_integration(scn), RES_OK);
- CHECK(sgf_scene_end_integration(scn), RES_BAD_OP);
+ CHK(sgf_scene_end_integration(NULL) == RES_BAD_ARG);
+ CHK(sgf_scene_end_integration(scn) == RES_OK);
+ CHK(sgf_scene_end_integration(scn) == RES_BAD_OP);
shape.emissivity = square_emi;
shape.specularity = square_spec;
@@ -171,22 +171,22 @@ main(int argc, char** argv)
desc.nprims = (unsigned)square_nprims;
desc.nverts = (unsigned)square_nverts;
- CHECK(sgf_scene_begin_integration(scn), RES_OK);
- CHECK(sgf_scene_begin_integration(scn), RES_BAD_OP);
+ CHK(sgf_scene_begin_integration(scn) == RES_OK);
+ CHK(sgf_scene_begin_integration(scn) == RES_BAD_OP);
- CHECK(sgf_scene_end_integration(scn), RES_OK);
- CHECK(sgf_scene_end_integration(scn), RES_BAD_OP);
+ CHK(sgf_scene_end_integration(scn) == RES_OK);
+ CHK(sgf_scene_end_integration(scn) == RES_BAD_OP);
- CHECK(sgf_scene_ref_get(NULL), RES_BAD_ARG);
- CHECK(sgf_scene_ref_get(scn), RES_OK);
- CHECK(sgf_scene_ref_put(NULL), RES_BAD_ARG);
- CHECK(sgf_scene_ref_put(scn), RES_OK);
- CHECK(sgf_scene_ref_put(scn), RES_OK);
+ CHK(sgf_scene_ref_get(NULL) == RES_BAD_ARG);
+ CHK(sgf_scene_ref_get(scn) == RES_OK);
+ CHK(sgf_scene_ref_put(NULL) == RES_BAD_ARG);
+ CHK(sgf_scene_ref_put(scn) == RES_OK);
+ CHK(sgf_scene_ref_put(scn) == RES_OK);
- CHECK(sgf_device_ref_put(sgf), RES_OK);
+ CHK(sgf_device_ref_put(sgf) == RES_OK);
check_memory_allocator(&allocator);
mem_shutdown_proxy_allocator(&allocator);
- CHECK(mem_allocated_size(), 0);
+ CHK(mem_allocated_size() == 0);
return RES_OK;
}
diff --git a/src/test_sgf_square.c b/src/test_sgf_square.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015-2016 EDF S.A., France (syrthes-support@edf.fr)
+/* Copyright (C) 2015-2018 EDF S.A., France (syrthes-support@edf.fr)
*
* 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
@@ -85,21 +85,21 @@ check_bottom_top_medium_gf
struct sgf_estimator* estimator;
struct sgf_status status[2];
- CHECK(sgf_scene_begin_integration(scn), RES_OK);
+ CHK(sgf_scene_begin_integration(scn) == RES_OK);
/* Estimate the Gebhart factors for the bottom segment */
- CHECK(sgf_integrate(scn, BOTTOM, rng, NSTEPS, &estimator), RES_OK);
- CHECK(sgf_estimator_get_status(estimator, TOP, 0, status + 0), RES_OK);
- CHECK(sgf_estimator_get_status_medium(estimator, 0, status + 1), RES_OK);
- CHECK(sgf_estimator_ref_put(estimator), RES_OK);
+ CHK(sgf_integrate(scn, BOTTOM, rng, NSTEPS, &estimator) == RES_OK);
+ CHK(sgf_estimator_get_status(estimator, TOP, 0, status + 0) == RES_OK);
+ CHK(sgf_estimator_get_status_medium(estimator, 0, status + 1) == RES_OK);
+ CHK(sgf_estimator_ref_put(estimator) == RES_OK);
/* Check the Gebhart factor between the bottom and the top plane. */
- CHECK(eq_eps(status[0].E, gf_bottom_top, status[0].SE), 1);
+ CHK(eq_eps(status[0].E, gf_bottom_top, status[0].SE) == 1);
/* Check the Gebhart factor between the bottom plane and the medium */
- CHECK(eq_eps(status[1].E, gf_bottom_medium, status[1].SE), 1);
+ CHK(eq_eps(status[1].E, gf_bottom_medium, status[1].SE) == 1);
- CHECK(sgf_scene_end_integration(scn), RES_OK);
+ CHK(sgf_scene_end_integration(scn) == RES_OK);
}
int
@@ -119,9 +119,9 @@ main(int argc, char** argv)
mem_init_proxy_allocator(&allocator, &mem_default_allocator);
- CHECK(ssp_rng_create(&allocator, &ssp_rng_threefry, &rng), RES_OK);
- CHECK(sgf_device_create(NULL, &allocator, 1, &sgf), RES_OK);
- CHECK(sgf_scene_create(sgf, &scn), RES_OK);
+ CHK(ssp_rng_create(&allocator, &ssp_rng_threefry, &rng) == RES_OK);
+ CHK(sgf_device_create(NULL, &allocator, 1, &sgf) == RES_OK);
+ CHK(sgf_scene_create(sgf, &scn) == RES_OK);
shape.vertices = vertices;
shape.nvertices = nverts;
@@ -141,34 +141,34 @@ main(int argc, char** argv)
desc.nbands = 1;
desc.context = &shape;
- CHECK(sgf_scene_setup_2d(scn, &desc), RES_OK);
- CHECK(sgf_integrate(scn, 0, rng, NSTEPS, &estimator), RES_BAD_OP);
+ CHK(sgf_scene_setup_2d(scn, &desc) == RES_OK);
+ CHK(sgf_integrate(scn, 0, rng, NSTEPS, &estimator) == RES_BAD_OP);
- CHECK(sgf_scene_begin_integration(scn), RES_OK);
+ CHK(sgf_scene_begin_integration(scn) == RES_OK);
FOR_EACH(iprim, 0, 3) {
- CHECK(sgf_integrate(scn, iprim, rng, NSTEPS, &estimator), RES_OK);
+ CHK(sgf_integrate(scn, iprim, rng, NSTEPS, &estimator) == RES_OK);
FOR_EACH(i, 0, 3) {
- CHECK(sgf_estimator_get_status(estimator, i, 0, &status), RES_OK);
+ CHK(sgf_estimator_get_status(estimator, i, 0, &status) == RES_OK);
if(i == iprim) {
- CHECK(eq_eps(status.E, 0, status.SE), 1);
+ CHK(eq_eps(status.E, 0, status.SE) == 1);
} else if(i == iprim + 2 || i == iprim - 2) { /* parallel faces */
- CHECK(eq_eps(status.E, sqrt(2) - 1, 2*status.SE), 1);
+ CHK(eq_eps(status.E, sqrt(2) - 1, 2*status.SE) == 1);
} else { /* Orthogonal faces */
- CHECK(iprim == i+1 || iprim == i-1, 1);
- CHECK(eq_eps(status.E, 1 - sqrt(2)/2, 2*status.SE), 1);
+ CHK(iprim == i+1 || iprim == i-1);
+ CHK(eq_eps(status.E, 1 - sqrt(2)/2, 2*status.SE) == 1);
}
}
- CHECK(sgf_estimator_get_status_infinity(estimator, 0, &status), RES_OK);
- CHECK(eq_eps(status.E, 0, status.SE), 1);
+ CHK(sgf_estimator_get_status_infinity(estimator, 0, &status) == RES_OK);
+ CHK(eq_eps(status.E, 0, status.SE) == 1);
- CHECK(sgf_estimator_ref_put(estimator), RES_OK);
+ CHK(sgf_estimator_ref_put(estimator) == RES_OK);
}
- CHECK(sgf_integrate(scn, 4, rng, NSTEPS, &estimator), RES_BAD_ARG);
+ CHK(sgf_integrate(scn, 4, rng, NSTEPS, &estimator) == RES_BAD_ARG);
- CHECK(sgf_scene_end_integration(scn), RES_OK);
+ CHK(sgf_scene_end_integration(scn) == RES_OK);
/*
* Check medium attenuation with 2 parallel infinite segments. To simulate
@@ -182,28 +182,28 @@ main(int argc, char** argv)
desc.get_absorption = get_absorption;
FOR_EACH(i, 0, 4) ka[i] = 0;
- CHECK(sgf_scene_setup_2d(scn, &desc), RES_OK);
+ CHK(sgf_scene_setup_2d(scn, &desc) == RES_OK);
check_bottom_top_medium_gf(scn, rng, 1, 0);
FOR_EACH(i, 0, 4) ka[i] = 0.1;
- CHECK(sgf_scene_setup_2d(scn, &desc), RES_OK);
+ CHK(sgf_scene_setup_2d(scn, &desc) == RES_OK);
check_bottom_top_medium_gf(scn, rng, 0.832583, 0.167417);
FOR_EACH(i, 0, 4) ka[i] = 1;
- CHECK(sgf_scene_setup_2d(scn, &desc), RES_OK);
+ CHK(sgf_scene_setup_2d(scn, &desc) == RES_OK);
check_bottom_top_medium_gf(scn, rng, 0.219384, 0.780616);
FOR_EACH(i, 0, 4) ka[i] = 10;
- CHECK(sgf_scene_setup_2d(scn, &desc), RES_OK);
+ CHK(sgf_scene_setup_2d(scn, &desc) == RES_OK);
check_bottom_top_medium_gf(scn, rng, 7.0975e-6, 0.999992902);
- CHECK(ssp_rng_ref_put(rng), RES_OK);
- CHECK(sgf_device_ref_put(sgf), RES_OK);
- CHECK(sgf_scene_ref_put(scn), RES_OK);
+ CHK(ssp_rng_ref_put(rng) == RES_OK);
+ CHK(sgf_device_ref_put(sgf) == RES_OK);
+ CHK(sgf_scene_ref_put(scn) == RES_OK);
check_memory_allocator(&allocator);
mem_shutdown_proxy_allocator(&allocator);
- CHECK(mem_allocated_size(), 0);
+ CHK(mem_allocated_size() == 0);
return 0;
}
diff --git a/src/test_sgf_tetrahedron.c b/src/test_sgf_tetrahedron.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015-2016 EDF S.A., France (syrthes-support@edf.fr)
+/* Copyright (C) 2015-2018 EDF S.A., France (syrthes-support@edf.fr)
*
* 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
@@ -63,9 +63,9 @@ main(int argc, char** argv)
mem_init_proxy_allocator(&allocator, &mem_default_allocator);
nbuckets = (unsigned)omp_get_num_procs();
- CHECK(ssp_rng_proxy_create(&allocator, &ssp_rng_threefry, nbuckets, &proxy), RES_OK);
- CHECK(sgf_device_create(NULL, &allocator, 1, &sgf), RES_OK);
- CHECK(sgf_scene_create(sgf, &scn), RES_OK);
+ CHK(ssp_rng_proxy_create(&allocator, &ssp_rng_threefry, nbuckets, &proxy) == RES_OK);
+ CHK(sgf_device_create(NULL, &allocator, 1, &sgf) == RES_OK);
+ CHK(sgf_scene_create(sgf, &scn) == RES_OK);
shape.vertices = vertices;
shape.nvertices = nvertices;
@@ -85,15 +85,15 @@ main(int argc, char** argv)
desc.nbands = 1;
desc.context = &shape;
- CHECK(sgf_scene_setup_3d(scn, &desc), RES_OK);
+ CHK(sgf_scene_setup_3d(scn, &desc) == RES_OK);
status = sa_add(status, nprims*nprims);
rngs = sa_add(rngs, nbuckets);
FOR_EACH(i, 0, nbuckets)
- CHECK(ssp_rng_proxy_create_rng(proxy, i, rngs + i), RES_OK);
+ CHK(ssp_rng_proxy_create_rng(proxy, i, rngs + i) == RES_OK);
- CHECK(sgf_scene_begin_integration(scn), RES_OK);
+ CHK(sgf_scene_begin_integration(scn) == RES_OK);
/* Gebhart Factor integration */
#pragma omp parallel for
@@ -104,20 +104,20 @@ main(int argc, char** argv)
size_t iprim2;
const int ithread = omp_get_thread_num();
- CHECK(sgf_integrate
- (scn, (size_t)iprim, rngs[ithread], NSTEPS, &estimator), RES_OK);
+ CHK(sgf_integrate
+ (scn, (size_t)iprim, rngs[ithread], NSTEPS, &estimator) == RES_OK);
FOR_EACH(iprim2, 0, nprims) {
- CHECK(sgf_estimator_get_status(estimator, iprim2, 0, row + iprim2), RES_OK);
- CHECK(row[iprim2].nsteps, NSTEPS);
+ CHK(sgf_estimator_get_status(estimator, iprim2, 0, row + iprim2) == RES_OK);
+ CHK(row[iprim2].nsteps == NSTEPS);
}
- CHECK(sgf_estimator_get_status_infinity(estimator, 0, &infinity), RES_OK);
- CHECK(eq_eps(infinity.E, 0, infinity.SE), 1);
+ CHK(sgf_estimator_get_status_infinity(estimator, 0, &infinity) == RES_OK);
+ CHK(eq_eps(infinity.E, 0, infinity.SE) == 1);
- CHECK(sgf_estimator_ref_put(estimator), RES_OK);
+ CHK(sgf_estimator_ref_put(estimator) == RES_OK);
}
- CHECK(sgf_scene_end_integration(scn), RES_OK);
+ CHK(sgf_scene_end_integration(scn) == RES_OK);
/* Expected value */
for(iprim=0; iprim < (int)nprims; ++iprim) {
@@ -130,7 +130,7 @@ main(int argc, char** argv)
}
printf("\n");
/* Ensure the energy conservation property */
- CHECK(eq_eps(sum, 1.0, 1.e-3), 1);
+ CHK(eq_eps(sum, 1.0, 1.e-3) == 1);
}
printf("\n");
@@ -144,18 +144,18 @@ main(int argc, char** argv)
printf("\n");
}
- CHECK(ssp_rng_proxy_ref_put(proxy), RES_OK);
- CHECK(sgf_device_ref_put(sgf), RES_OK);
- CHECK(sgf_scene_ref_put(scn), RES_OK);
+ CHK(ssp_rng_proxy_ref_put(proxy) == RES_OK);
+ CHK(sgf_device_ref_put(sgf) == RES_OK);
+ CHK(sgf_scene_ref_put(scn) == RES_OK);
FOR_EACH(i, 0, nbuckets)
- CHECK(ssp_rng_ref_put(rngs[i]), RES_OK);
+ CHK(ssp_rng_ref_put(rngs[i]) == RES_OK);
sa_release(rngs);
sa_release(status);
check_memory_allocator(&allocator);
mem_shutdown_proxy_allocator(&allocator);
- CHECK(mem_allocated_size(), 0);
+ CHK(mem_allocated_size() == 0);
return 0;
}
diff --git a/src/test_sgf_utils.h b/src/test_sgf_utils.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2015-2016 EDF S.A., France (syrthes-support@edf.fr)
+/* Copyright (C) 2015-2018 EDF S.A., France (syrthes-support@edf.fr)
*
* 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
@@ -36,10 +36,10 @@ get_indices(const unsigned itri, unsigned ids[], void* data)
const struct shape_context* shape = data;
const unsigned id = itri * shape->dim;
unsigned i;
- NCHECK(shape, NULL);
- NCHECK(ids, NULL);
- CHECK(shape->dim == 2 || shape->dim == 3, 1);
- CHECK(itri < shape->nprimitives, 1);
+ CHK(shape != NULL);
+ CHK(ids != NULL);
+ CHK(shape->dim == 2 || shape->dim == 3);
+ CHK(itri < shape->nprimitives);
FOR_EACH(i, 0, shape->dim) ids[i] = shape->indices[id + i];
}
@@ -49,9 +49,9 @@ get_position(const unsigned ivert, float pos[], void* data)
const struct shape_context* shape = data;
const unsigned id = ivert*shape->dim;
unsigned i;
- NCHECK(shape, NULL);
- NCHECK(pos, NULL);
- CHECK(ivert < shape->nvertices, 1);
+ CHK(shape != NULL);
+ CHK(pos != NULL);
+ CHK(ivert < shape->nvertices);
FOR_EACH(i, 0, shape->dim) pos[i] = shape->vertices[id + i];
}
@@ -59,7 +59,7 @@ static INLINE double
get_absorption(const unsigned iprim, const unsigned iband, void* ctx)
{
struct shape_context* shape = ctx;
- NCHECK(shape, NULL);
+ CHK(shape != NULL);
(void)iband;
return shape->absorption[iprim];
}
@@ -68,7 +68,7 @@ static INLINE double
get_emissivity(const unsigned iprim, const unsigned iband, void* ctx)
{
struct shape_context* shape = ctx;
- NCHECK(shape, NULL);
+ CHK(shape != NULL);
(void)iband;
return shape->emissivity[iprim];
}
@@ -77,7 +77,7 @@ static INLINE double
get_specularity(const unsigned iprim, const unsigned iband, void* ctx)
{
struct shape_context* shape = ctx;
- NCHECK(shape, NULL);
+ CHK(shape != NULL);
(void)iband;
return shape->specularity[iprim];
}
@@ -92,7 +92,7 @@ static INLINE void
dump_triangle_mesh(struct shape_context* mesh)
{
unsigned i;
- NCHECK(mesh, NULL);
+ CHK(mesh != NULL);
FOR_EACH(i, 0, mesh->nvertices)
printf("v %f %f %f\n", SPLIT3(mesh->vertices + i*3));
FOR_EACH(i, 0, mesh->nprimitives) {