solstice-solver

Solver library of the solstice app
git clone git://git.meso-star.com/solstice-solver.git
Log | Files | Refs | README | LICENSE

commit 295a156fb02ba102cca4c9d466ef0cd961df363e
parent 3cb917292b45e3d90ab02e09a83c9ac3e7927195
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Thu, 25 Aug 2016 13:59:10 +0200

Remove the general quadrics for user use

First implementation will use ray transform instead of quadric transform,
avoiding the use of general quadrics for solver use

Diffstat:
Msrc/ssol.h | 11+----------
Msrc/ssol_shape.c | 12------------
Msrc/ssol_solver.c | 132-------------------------------------------------------------------------------
Msrc/ssol_solver_c.h | 7-------
Msrc/test_ssol_shape.c | 3---
5 files changed, 1 insertion(+), 164 deletions(-)

diff --git a/src/ssol.h b/src/ssol.h @@ -71,10 +71,7 @@ enum ssol_quadric_type { SSOL_QUADRIC_PLANE, SSOL_QUADRIC_PARABOL, SSOL_QUADRIC_PARABOLIC_CYLINDER, - SSOL_GENERAL_QUADRIC, - - SSOL_QUADRIC_FIRST_TYPE = SSOL_QUADRIC_PLANE, - SSOL_QUADRIC_LAST_TYPE = SSOL_GENERAL_QUADRIC + SSOL_QUADRIC_TYPE_COUNT__ }; enum ssol_carving_type { @@ -130,18 +127,12 @@ struct ssol_quadric_parabolic_cylinder { double focal; /* Define y^2 - 4 focal z = 0 */ }; -struct ssol_general_quadric { - /* Define ax^2 + 2bxy + 2cxz + 2dx + ey^2 + 2fyz + 2gy + hz^2 + 2iz + j = 0 */ - double a, b, c, d, e, f, g, h, i, j; -}; - struct ssol_quadric { enum ssol_quadric_type type; union { struct ssol_quadric_plane plane; struct ssol_quadric_parabol parabol; struct ssol_quadric_parabolic_cylinder parabolic_cylinder; - struct ssol_general_quadric general_quadric; } data; }; diff --git a/src/ssol_shape.c b/src/ssol_shape.c @@ -65,16 +65,6 @@ check_parabolic_cylinder_ok } static INLINE res_T -check_general_quadric_ok(const struct ssol_general_quadric* quadric) -{ - if (!quadric) - return RES_BAD_ARG; - /* we don't check that the quadric equation has solutions - * in such case, the quadric is valid but has zero surface */ - return RES_OK; -} - -static INLINE res_T quadric_ok(const struct ssol_quadric* quadric) { if (!quadric) @@ -86,8 +76,6 @@ quadric_ok(const struct ssol_quadric* quadric) return check_parabol_ok(&quadric->data.parabol); case SSOL_QUADRIC_PARABOLIC_CYLINDER: return check_parabolic_cylinder_ok(&quadric->data.parabolic_cylinder); - case SSOL_GENERAL_QUADRIC: - return check_general_quadric_ok(&quadric->data.general_quadric); default: return RES_BAD_ARG; } } diff --git a/src/ssol_solver.c b/src/ssol_solver.c @@ -74,56 +74,6 @@ struct realisation { size_t s_idx; }; -/******************************************************************************* - * Helper functions - ******************************************************************************/ - -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; - to[3] = to[12] = from->d; - to[5] = from->e; - to[6] = to[9] = from->f; - to[7] = to[13] = from->g; - to[10] = from->h; - to[11] = to[14] = from->i; - to[15] = from->j; -} - -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]; - to->d = from[3]; - to->e = from[5]; - to->f = from[6]; - to->g = from[7]; - to->h = from[10]; - to->i = from[11]; - to->j = from[15]; -} - -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++]; - } - to[idx_t++] = (c == 3) ? 1 : 0; - } -} - static INLINE int is_instance_punched (const struct ssol_object_instance* instance) @@ -216,88 +166,6 @@ error: goto exit; } -/* Implementation notes: - * - * The transform of a plane is still a plane (first degree equation) - * so we could construct a ssol_quadric that would be a plane if - * the input quadric is a plane. - * - * The quadric matrices are diagonal, so that operators could be specialized. - * - * Ultimately we could process quadric directly without intermediate - * matricial representation. - * - * These are possible performance improvement. */ -res_T -quadric_transform - (const struct ssol_quadric* quadric, - const double transform [], - struct ssol_quadric* transformed) -{ - double transform44[16], quadric44[16], transp[16], tmp[16]; - struct ssol_general_quadric* tr = &transformed->data.general_quadric; - if (!quadric || !transformed || !transform) - return RES_BAD_ARG; - - /* feed transformed with quadric data */ - transformed->type = SSOL_GENERAL_QUADRIC; - switch (quadric->type) { - case SSOL_QUADRIC_PLANE: - /* Define z = 0 */ - tr->a = 0; - tr->b = 0; - tr->c = 0; - tr->d = 0; - tr->e = 0; - tr->f = 0; - tr->g = 0; - tr->h = 0; - tr->i = 0.5; - tr->j = 0; - break; - case SSOL_QUADRIC_PARABOL: - /* Define x^2 + y^2 - 4 focal z = 0 */ - tr->a = 1; - tr->b = 0; - tr->c = 0; - tr->d = 0; - tr->e = 1; - tr->f = 0; - tr->g = 0; - tr->h = 0; - tr->i = -2 * quadric->data.parabol.focal; - tr->j = 0; - break; - case SSOL_QUADRIC_PARABOLIC_CYLINDER: - /* Define y^2 - 4 focal z = 0 */ - tr->a = 0; - tr->b = 0; - tr->c = 0; - tr->d = 0; - tr->e = 1; - tr->f = 0; - tr->g = 0; - tr->h = 0; - tr->i = -2 * quadric->data.parabolic_cylinder.focal;; - tr->j = 0; - break; - case SSOL_GENERAL_QUADRIC: - /* Define ax² + 2bxy + 2cxz + 2dx + ey² + 2fyz + 2gy + hz² + 2iz + j = 0 */ - *tr = quadric->data.general_quadric; - break; - default: - FATAL("Unreachable code \n"); - } - /* transform */ - quadric_to_mat4x4(tr, quadric44); - mat_3x4_to_4x4(transform, transform44); - d44_transpose(transp, transform44); - d44_muld44(tmp, transp, quadric44); - d44_muld44(quadric44, tmp, transform44); - mat4x4_to_quadric(quadric44, tr); - return RES_OK; -} - res_T set_views(struct solver_data* data) { res_T res = RES_OK; diff --git a/src/ssol_solver_c.h b/src/ssol_solver_c.h @@ -51,12 +51,5 @@ set_sun_distributions(struct solver_data* data); extern LOCAL_SYM res_T set_views(struct solver_data* data); -/* transform a single quadric in world space */ -extern LOCAL_SYM res_T -quadric_transform - (const struct ssol_quadric* quadric, - const double transform[], - struct ssol_quadric* transformed); - #endif /* SSOL_SOLVER_C_H */ diff --git a/src/test_ssol_shape.c b/src/test_ssol_shape.c @@ -155,9 +155,6 @@ main(int argc, char** argv) CHECK(ssol_punched_surface_setup(shape, &punched_surface), RES_BAD_ARG); quadric.data.parabolic_cylinder.focal = 1; - quadric.type = SSOL_GENERAL_QUADRIC; - CHECK(ssol_punched_surface_setup(shape, &punched_surface), RES_OK); - CHECK(ssol_shape_ref_put(shape), RES_OK); CHECK(ssol_device_ref_put(dev), RES_OK);