commit 8009404285eecf4930527cc627e4e2bc141783e3
parent b050d29f63075e5da901ecaad7ecca1c86d03f05
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 12 Jul 2016 12:31:58 +0200
Fix compilation & make consistent the coding style
The // comments are not allowed in C89. Replace them by /**/
comments
Diffstat:
4 files changed, 290 insertions(+), 258 deletions(-)
diff --git a/src/ssol_distributions.c b/src/ssol_distributions.c
@@ -1,35 +1,33 @@
/* 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/>. */
+ *
+ * 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/>. */
#include "ssol.h"
#include "ssol_distributions_c.h"
#include <star/ssp.h>
+#include <rsys/double33.h>
+#include <rsys/math.h>
+#include <rsys/mem_allocator.h>
#include <rsys/rsys.h>
#include <rsys/ref_count.h>
-#include <rsys/mem_allocator.h>
-#include <rsys/math.h>
-#include <rsys/double33.h>
/*******************************************************************************
-* distributions types
-******************************************************************************/
-
-struct ran_buie_state
-{
+ * Distributions types
+ ******************************************************************************/
+struct ran_buie_state {
double thetaSD;
double deltaThetaCSSD;
double gamma;
@@ -37,38 +35,37 @@ struct ran_buie_state
double alpha;
double hRect1;
double hRect2;
- double probaRect1;
+ double proba_rect1;
double basis[9];
};
-struct ran_pillbox_state
-{
+struct ran_pillbox_state {
double radius;
double basis[9];
};
-struct ran_dirac_state
-{
+struct ran_dirac_state {
double dir[3];
};
-/* one single type for all distributions
-* only the state type depends on the distribution type */
+/* One single type for all distributions. Only the state type depends on the
+ * distribution type */
struct ssol_ranst_sun_dir {
- double*(*get)(const struct ssol_ranst_sun_dir* ran, struct ssp_rng* rng, double dir[3]);
- ref_T ref;
- struct mem_allocator* allocator;
+ double*(*get)
+ (const struct ssol_ranst_sun_dir* ran, struct ssp_rng* rng, double dir[3]);
union {
struct ran_buie_state buie;
struct ran_pillbox_state pillbox;
struct ran_dirac_state dirac;
} state;
+
+ ref_T ref;
+ struct mem_allocator* allocator;
};
/*******************************************************************************
-* sun direction distribution
-******************************************************************************/
-
+ * Helper functions
+ ******************************************************************************/
static void
distrib_sun_release(ref_T* ref)
{
@@ -78,127 +75,106 @@ distrib_sun_release(ref_T* ref)
MEM_RM(ran->allocator, ran);
}
-res_T
-ssol_ranst_sun_dir_create
- (struct mem_allocator* allocator,
- struct ssol_ranst_sun_dir** out_ran)
-{
- struct ssol_ranst_sun_dir* ran = NULL;
-
- if (!out_ran) return RES_BAD_ARG;
-
- allocator = allocator ? allocator : &mem_default_allocator;
-
- ran = MEM_CALLOC(allocator, 1, sizeof(struct ssol_ranst_sun_dir));
- if (!ran) return RES_MEM_ERR;
-
- ref_init(&ran->ref);
- ran->allocator = allocator;
- *out_ran = ran;
-
- return RES_OK;
-}
-
-res_T
-ssol_ranst_sun_dir_ref_get
- (struct ssol_ranst_sun_dir* ran)
-{
- if (!ran) return RES_BAD_ARG;
- ref_get(&ran->ref);
- return RES_OK;
-}
-
-res_T
-ssol_ranst_sun_dir_ref_put
- (struct ssol_ranst_sun_dir* ran)
-{
- if (!ran) return RES_BAD_ARG;
- ref_put(&ran->ref, distrib_sun_release);
- return RES_OK;
-}
-
-double*
-ssol_ranst_sun_dir_get
- (const struct ssol_ranst_sun_dir* ran,
- struct ssp_rng* rng,
- double dir[3])
-{
- return ran->get(ran, rng, dir);
-}
-
/*******************************************************************************
-* Buie distribution
-******************************************************************************/
-
-double chiValue(double csr)
+ * Buie distribution
+ ******************************************************************************/
+static double
+chi_value(const double csr)
{
- if (csr > 0.145)
- return -0.04419909985804843 + csr * (1.401323894233574 + csr * (-0.3639746714505299 + csr * (-0.9579768560161194 + 1.1550475450828657 * csr)));
-
- if (csr > 0.035)
- return 0.022652077593662934 + csr * (0.5252380349996234 + (2.5484334534423887 - 0.8763755326550412 * csr) * csr);
-
- return 0.004733749294807862 + csr * (4.716738065192151 + csr * (-463.506669149804 + csr * (24745.88727411664 + csr * (-606122.7511711778 + 5521693.445014727 * csr))));
+ if (csr > 0.145) {
+ return -0.04419909985804843 +
+ csr * (1.401323894233574 +
+ csr * (-0.3639746714505299 +
+ csr * (-0.9579768560161194 + 1.1550475450828657 * csr)));
+ }
+ if (csr > 0.035) {
+ return 0.022652077593662934 +
+ csr * (0.5252380349996234 +
+ csr * (2.5484334534423887 - 0.8763755326550412 * csr));
+ }
+ return 0.004733749294807862 +
+ csr * (4.716738065192151 +
+ csr * (-463.506669149804 +
+ csr * (24745.88727411664 +
+ csr * (-606122.7511711778 + 5521693.445014727 * csr))));
}
-double phiSolarDisk(double theta)
+static double
+phi_solar_disk(const double theta)
{
- // The parameter theta is the zenith angle in radians
+ /* The parameter theta is the zenith angle in radians */
return cos(326 * theta) / cos(308 * theta);
}
-double phiCircumSolarRegion(double theta, const struct ran_buie_state* state)
+static double
+phi_circum_solor_region(const double theta, const struct ran_buie_state* state)
{
- // The parameter theta is the zenith angle in radians
+ /* The parameter theta is the zenith angle in radians */
return state->etokTimes1000toGamma * pow(theta, state->gamma);
}
-double phi(double theta, const struct ran_buie_state* state)
+static double
+phi(const double theta, const struct ran_buie_state* state)
{
- // The parameter theta is the zenith angle in radians
- if (theta < state->thetaSD) return phiSolarDisk(theta);
- else return phiCircumSolarRegion(theta, state);
+ /* The parameter theta is the zenith angle in radians */
+ if (theta < state->thetaSD) return phi_solar_disk(theta);
+ else return phi_circum_solor_region(theta, state);
}
-double pdfTheta(double theta, const struct ran_buie_state* state)
+static double
+pdf_theta(const double theta, const struct ran_buie_state* state)
{
- // The parameter theta is the zenith angle in radians
+ /* The parameter theta is the zenith angle in radians */
return state->alpha * phi(theta, state) * sin(theta);
}
-double gammaValue(double chi)
+static double
+gamma_value(const double chi)
{
/* gamma is the gradient of the 2nd part of the curve in log/log space*/
return 2.2 * log(0.52 * chi) * pow(chi, 0.43) - 0.1;
}
-double kValue(double chi)
+static double
+k_value(const double chi)
{
- /* k is the intercept of the 2nd part of the
- curve at an angular displacement of zero */
+ /* k is the intercept of the 2nd part of the curve at an angular displacement
+ * of zero */
return 0.9 * log(13.5 * chi) * pow(chi, -0.3);
}
-double intregralB(double k, double gamma, double thetaCS, double thetaSD)
+static double
+integral_B
+ (const double k,
+ const double gamma,
+ const double thetaCS,
+ const double thetaSD)
{
- double g2 = gamma + 2.0;
+ const double g2 = gamma + 2.0;
return exp(k) * pow(1000, gamma) / g2 * (pow(thetaCS, g2) - pow(thetaSD, g2));
}
-double probaRect1(double widthR1, double heightR1, double widthR2, double heightR2)
+static double
+proba_rect1
+ (const double widthR1,
+ const double heightR1,
+ const double widthR2,
+ const double heightR2)
{
- double areaR1 = widthR1 * heightR1;
- double areaR2 = widthR2 * heightR2;
+ const double areaR1 = widthR1 * heightR1;
+ const double areaR2 = widthR2 * heightR2;
return areaR1 / (areaR1 + areaR2);
}
-double zenithAngle(struct ssp_rng* rng, const struct ran_buie_state* state)
+static double
+zenith_angle(struct ssp_rng* rng, const struct ran_buie_state* state)
{
double theta;
double value;
+ ASSERT(state);
do {
- if (ssp_rng_canonical(rng) < state->probaRect1) {
+ if (ssp_rng_canonical(rng) < state->proba_rect1) {
theta = ssp_rng_canonical(rng) * state->thetaSD;
value = ssp_rng_canonical(rng) * state->hRect1;
}
@@ -206,44 +182,45 @@ double zenithAngle(struct ssp_rng* rng, const struct ran_buie_state* state)
theta = state->thetaSD + ssp_rng_canonical(rng) * state->deltaThetaCSSD;
value = ssp_rng_canonical(rng) * state->hRect2;
}
- } while (value > pdfTheta(theta, state));
+ } while (value > pdf_theta(theta, state));
return theta;
}
-void fill_buie_state(struct ran_buie_state* s, double p) {
+static void
+fill_buie_state(struct ran_buie_state* s, const double p)
+{
double thetaCS, integralA, chi, k, integralB;
ASSERT(s);
ASSERT(0 <= p && p < 1);
+
s->thetaSD = 0.00465;
thetaCS = 0.0436;
s->deltaThetaCSSD = thetaCS - s->thetaSD;
integralA = 9.224724736098827E-6;
- chi = chiValue(p);
- k = kValue(chi);
- s->gamma = gammaValue(chi);
+ chi = chi_value(p);
+ k = k_value(chi);
+ s->gamma = gamma_value(chi);
s->etokTimes1000toGamma = exp(k) * pow(1000, s->gamma);
- integralB = intregralB(k, s->gamma, thetaCS, s->thetaSD);
+ integralB = integral_B(k, s->gamma, thetaCS, s->thetaSD);
s->alpha = 1 / (integralA + integralB);
- /*
- The value 0.0038915695846209047 radians is the value for which the
- probability density function is a maximum. The value of the maximum
- varies with the circumsolar ratio, but the value of theta where the
- maximum is obtained remains fixed.
- */
- s->hRect1 = 1.001 * pdfTheta(0.0038915695846209047, s);
- s->hRect2 = pdfTheta(s->thetaSD, s);
- s->probaRect1 = probaRect1(s->thetaSD, s->hRect1, s->deltaThetaCSSD, s->hRect2);
+ /* The value 0.0038915695846209047 radians is the value for which the
+ * probability density function is a maximum. The value of the maximum varies
+ * with the circumsolar ratio, but the value of theta where the maximum is
+ * obtained remains fixed. */
+ s->hRect1 = 1.001 * pdf_theta(0.0038915695846209047, s);
+ s->hRect2 = pdf_theta(s->thetaSD, s);
+ s->proba_rect1 = proba_rect1(s->thetaSD, s->hRect1, s->deltaThetaCSSD, s->hRect2);
}
-double*
+static double*
ssol_ran_buie_get
(const struct ssol_ranst_sun_dir* ran, struct ssp_rng* rng, double dir[3])
{
double phi, theta, sinTheta, cosTheta, cosPhi, sinPhi;
ASSERT(ran->state.buie.thetaSD > 0);
phi = ssp_rng_uniform_double(rng, 0, 2 * PI);
- theta = zenithAngle(rng, &ran->state.buie);
+ theta = zenith_angle(rng, &ran->state.buie);
sinTheta = sin(theta);
cosTheta = cos(theta);
cosPhi = cos(phi);
@@ -255,6 +232,90 @@ ssol_ran_buie_get
return dir;
}
+/*******************************************************************************
+ * Pillbox distribution
+ ******************************************************************************/
+static double*
+ssol_ran_pillbox_get
+ (const struct ssol_ranst_sun_dir* ran,
+ struct ssp_rng* rng,
+ double dir[3])
+{
+ double pt[3];
+
+ ASSERT(ran && ran->state.pillbox.radius > 0);
+ ssp_ran_uniform_disk(rng, ran->state.pillbox.radius, pt);
+ pt[2] = 1;
+ d33_muld3(dir, ran->state.pillbox.basis, pt);
+ d3_normalize(dir, pt);
+ return dir;
+}
+
+/*******************************************************************************
+* Dirac distribution
+******************************************************************************/
+static double*
+ssol_ran_dirac_get
+(const struct ssol_ranst_sun_dir* ran,
+ struct ssp_rng* rng,
+ double dir[3])
+{
+ (void) rng;
+ ASSERT(d3_is_normalized(ran->state.dirac.dir));
+ d3_set(dir, ran->state.dirac.dir);
+ return dir;
+}
+
+/*******************************************************************************
+ * Local functions
+ ******************************************************************************/
+res_T
+ssol_ranst_sun_dir_create
+ (struct mem_allocator* allocator,
+ struct ssol_ranst_sun_dir** out_ran)
+{
+ struct ssol_ranst_sun_dir* ran = NULL;
+
+ if (!out_ran) return RES_BAD_ARG;
+
+ allocator = allocator ? allocator : &mem_default_allocator;
+
+ ran = MEM_CALLOC(allocator, 1, sizeof(struct ssol_ranst_sun_dir));
+ if (!ran) return RES_MEM_ERR;
+
+ ref_init(&ran->ref);
+ ran->allocator = allocator;
+ *out_ran = ran;
+
+ return RES_OK;
+}
+
+res_T
+ssol_ranst_sun_dir_ref_get(struct ssol_ranst_sun_dir* ran)
+{
+ if (!ran) return RES_BAD_ARG;
+ ref_get(&ran->ref);
+ return RES_OK;
+}
+
+res_T
+ssol_ranst_sun_dir_ref_put(struct ssol_ranst_sun_dir* ran)
+{
+ if (!ran) return RES_BAD_ARG;
+ ref_put(&ran->ref, distrib_sun_release);
+ return RES_OK;
+}
+
+double*
+ssol_ranst_sun_dir_get
+ (const struct ssol_ranst_sun_dir* ran,
+ struct ssp_rng* rng,
+ double dir[3])
+{
+ ASSERT(ran);
+ return ran->get(ran, rng, dir);
+}
+
res_T
ssol_ranst_sun_dir_buie_setup
(struct ssol_ranst_sun_dir* ran,
@@ -264,33 +325,14 @@ ssol_ranst_sun_dir_buie_setup
const double minCRSValue = 1E-6;
const double maxCRSValue = 0.849;
if (!ran || !dir || param < minCRSValue || param > maxCRSValue)
- return RES_BAD_ARG;
+ return RES_BAD_ARG;
- ran->get = ssol_ran_buie_get;
+ ran->get = ssol_ran_buie_get;
d33_basis(ran->state.buie.basis, dir);
fill_buie_state(&ran->state.buie, param);
return RES_OK;
}
-/*******************************************************************************
-* Pillbox distribution
-******************************************************************************/
-
-double*
-ssol_ran_pillbox_get
-(const struct ssol_ranst_sun_dir* ran,
- struct ssp_rng* rng,
- double dir[3])
-{
- double pt[3];
- ASSERT(ran->state.pillbox.radius > 0);
- ssp_ran_uniform_disk(rng, ran->state.pillbox.radius, pt);
- pt[2] = 1;
- d33_muld3(dir, ran->state.pillbox.basis, pt);
- d3_normalize(dir, pt);
- return dir;
-}
-
res_T
ssol_ranst_sun_dir_pillbox_setup
(struct ssol_ranst_sun_dir* ran,
@@ -307,22 +349,6 @@ ssol_ranst_sun_dir_pillbox_setup
return RES_OK;
}
-/*******************************************************************************
-* Dirac distribution
-******************************************************************************/
-
-double*
-ssol_ran_dirac_get
-(const struct ssol_ranst_sun_dir* ran,
- struct ssp_rng* rng,
- double dir[3])
-{
- (void) rng;
- ASSERT(d3_is_normalized(ran->state.dirac.dir));
- d3_set(dir, ran->state.dirac.dir);
- return dir;
-}
-
res_T
ssol_ranst_sun_dir_dirac_setup
(struct ssol_ranst_sun_dir* ran,
@@ -334,4 +360,5 @@ ssol_ranst_sun_dir_dirac_setup
return RES_BAD_ARG;
ran->get = ssol_ran_dirac_get;
return RES_OK;
-}
-\ No newline at end of file
+}
+
diff --git a/src/ssol_distributions_c.h b/src/ssol_distributions_c.h
@@ -1,24 +1,24 @@
/* 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/>. */
+ *
+ * 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 SSOL_DISTRIBUTIONS_C_H
#define SSOL_DISTRIBUTIONS_C_H
/*******************************************************************************
-* Sun distributions
-******************************************************************************/
+ * Sun distributions
+ ******************************************************************************/
/* Forward declaration of opaque types */
struct ssol_ranst_sun_dir;
@@ -40,14 +40,14 @@ ssol_ranst_sun_dir_buie_setup
res_T
ssol_ranst_sun_dir_pillbox_setup
-(struct ssol_ranst_sun_dir* ran,
- double aperture, /* apparent size in radians */
- const double dir[3]);
+ (struct ssol_ranst_sun_dir* ran,
+ double aperture, /* apparent size in radians */
+ const double dir[3]);
res_T
ssol_ranst_sun_dir_dirac_setup
-(struct ssol_ranst_sun_dir* ran,
- const double dir[3]);
+ (struct ssol_ranst_sun_dir* ran,
+ const double dir[3]);
res_T
ssol_ranst_sun_dir_ref_get
diff --git a/src/ssol_solver.c b/src/ssol_solver.c
@@ -1,17 +1,17 @@
/* 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/>. */
+ *
+ * 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/>. */
#include "ssol.h"
#include "ssol_solver_c.h"
@@ -23,19 +23,20 @@
#include "ssol_spectrum_c.h"
#include "ssol_object_instance_c.h"
-#include <rsys/rsys.h>
#include <rsys/mem_allocator.h>
#include <rsys/ref_count.h>
+#include <rsys/rsys.h>
#include <star/ssp.h>
/*******************************************************************************
-* Helper functions
-******************************************************************************/
+ * Helper functions
+ ******************************************************************************/
-static void quadric_to_mat4x4
- (const struct ssol_general_quadric* from, double* to)
+static void
+quadric_to_mat4x4(const struct ssol_general_quadric* from, double* to)
{
+ ASSERT(from && to);
to[0] = from->a;
to[1] = to[4] = from->b;
to[2] = to[8] = from->c;
@@ -48,9 +49,10 @@ static void quadric_to_mat4x4
to[15] = from->j;
}
-static void mat4x4_to_quadric
- (const double* from, struct ssol_general_quadric* to)
+static void
+mat4x4_to_quadric(const double* from, struct ssol_general_quadric* to)
{
+ ASSERT(to && from);
to->a = from[0];
to->b = from[1];
to->c = from[2];
@@ -63,10 +65,12 @@ static void mat4x4_to_quadric
to->j = from[15];
}
-static void mat_3x4_to_4x4
- (const double* from, double* to)
+static void
+mat_3x4_to_4x4(const double* from, double* to)
{
int r, c, idx_f = 0, idx_t = 0;
+ ASSERT(from && to);
+
for (c = 0; c < 4; c++) {
for (r = 0; r < 3; r++) {
to[idx_t++] = from[idx_f++];
@@ -76,10 +80,11 @@ static void mat_3x4_to_4x4
}
static void
-mat_4x4_mul
- (const double* a, const double* b, double* to)
+mat_4x4_mul(const double* a, const double* b, double* to)
{
int r, c, k;
+ ASSERT(a && b && to);
+
for (c = 0; c < 4; c++) {
for (r = 0; r < 4; r++) {
to[r * 4 + c] = 0;
@@ -91,10 +96,11 @@ mat_4x4_mul
}
static void
-mat_4x4_transp
- (const double* from, double* to)
+mat_4x4_transp(const double* from, double* to)
{
int r, c, idx_f = 0, idx_t = 0;
+ ASSERT(from && to);
+
for (c = 0; c < 4; c++) {
for (r = 0; r < 4; r++) {
to[15 - idx_t++] = from[idx_f++];
@@ -102,43 +108,41 @@ mat_4x4_transp
}
}
-static int
+static INLINE int
is_instance_punched
(const struct ssol_object_instance* instance)
{
+ ASSERT(instance);
return instance->object->shape->type == SHAPE_PUNCHED;
}
static const struct ssol_quadric*
-get_quadric
- (const struct ssol_object_instance* instance)
+get_quadric (const struct ssol_object_instance* instance)
{
- ASSERT(is_instance_punched(instance));
+ ASSERT(instance && is_instance_punched(instance));
return instance->object->shape->quadric;
}
static struct s3d_scene*
-get_3dscene
-(const struct ssol_object_instance* instance)
+get_3dscene(const struct ssol_object_instance* instance)
{
+ ASSERT(instance);
return instance->object->shape->scene;
}
static const double*
-get_transform
-(const struct ssol_object_instance* instance)
+get_transform(const struct ssol_object_instance* instance)
{
+ ASSERT(instance);
return instance->transform;
}
-/*******************************************************************************
-* ssol_solver functions
-******************************************************************************/
-
-res_T
+/* FIXME Dead code. Remove it? */
+#if 0
+static res_T
init_solver_data
-(struct solver_data* data,
- struct ssol_device* dev)
+ (struct solver_data* data,
+ struct ssol_device* dev)
{
res_T res = RES_OK;
if (!data || !dev) return RES_BAD_ARG;
@@ -155,14 +159,17 @@ init_solver_data
}
return res;
}
+#endif
+/*******************************************************************************
+ * Local functions
+ ******************************************************************************/
res_T
set_sun_distributions
(const struct ssol_sun* sun,
struct solver_data* data)
{
struct ssol_spectrum* spectrum;
- struct mem_allocator* allocator;
const double* frequencies;
const double* intensities;
res_T res = RES_OK;
@@ -170,13 +177,13 @@ set_sun_distributions
if (!sun || !data) return RES_BAD_ARG;
ASSERT(data->dev && data->dev->allocator);
- allocator = data->dev->allocator;
/* first set the spectrum distribution */
spectrum = sun->spectrum;
frequencies = darray_double_cdata_get(&spectrum->frequencies);
intensities = darray_double_cdata_get(&spectrum->intensities);
sz = darray_double_size_get(&spectrum->frequencies);
- res = ssp_ranst_piecewise_linear_setup(data->sun_spectrum_ran, frequencies, intensities, sz);
+ res = ssp_ranst_piecewise_linear_setup
+ (data->sun_spectrum_ran, frequencies, intensities, sz);
if (res != RES_OK) return res;
/* then the direction distribution */
switch (sun->type) {
@@ -184,10 +191,12 @@ set_sun_distributions
res = ssol_ranst_sun_dir_dirac_setup(data->sun_dir_ran, sun->direction);
break;
case SUN_PILLBOX:
- res = ssol_ranst_sun_dir_pillbox_setup(data->sun_dir_ran, sun->data.pillbox.aperture, sun->direction);
+ res = ssol_ranst_sun_dir_pillbox_setup
+ (data->sun_dir_ran, sun->data.pillbox.aperture, sun->direction);
break;
case SUN_CSR:
- res = ssol_ranst_sun_dir_buie_setup(data->sun_dir_ran, sun->data.csr.ratio, sun->direction);
+ res = ssol_ranst_sun_dir_buie_setup
+ (data->sun_dir_ran, sun->data.csr.ratio, sun->direction);
break;
default:
res = RES_OK;
@@ -208,8 +217,7 @@ set_sun_distributions
* Ultimately we could process quadric directly without intermediate
* matricial representation.
*
- * These are possible performance improvement.
- */
+ * These are possible performance improvement. */
res_T
quadric_transform
(const struct ssol_quadric* quadric,
@@ -277,7 +285,6 @@ quadric_transform
mat_4x4_mul(transp, quadric44, tmp);
mat_4x4_mul(tmp, transform44, quadric44);
mat4x4_to_quadric(quadric44, tr);
-
return RES_OK;
}
@@ -326,4 +333,4 @@ process_instances
}
return RES_OK;
-}
-\ No newline at end of file
+}
diff --git a/src/ssol_solver_c.h b/src/ssol_solver_c.h
@@ -1,17 +1,17 @@
/* 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/>. */
+ *
+ * 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 SSOL_SOLVER_C_H
#define SSOL_SOLVER_C_H
@@ -24,7 +24,6 @@
#include <star/ssp.h>
-
#define DARRAY_NAME quadric
#define DARRAY_DATA struct ssol_quadric
#include <rsys/dynamic_array.h>
@@ -51,21 +50,22 @@ struct solver_data {
struct ssp_ranst_piecewise_linear* sun_spectrum_ran;
};
-res_T
+extern LOCAL_SYM res_T
set_sun_distributions
(const struct ssol_sun* sun,
struct solver_data* data);
-res_T
+extern LOCAL_SYM res_T
process_instances
(const struct ssol_scene* scene,
struct solver_data* data);
/* transform a single quadric in world space */
-res_T
+extern LOCAL_SYM res_T
quadric_transform
(const struct ssol_quadric* quadric,
const double transform[],
struct ssol_quadric* transformed);
#endif /* SSOL_SOLVER_C_H */
+