solstice-solver

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

commit 1764dd4f965bd360eb15f6764751d67133901c2c
parent 49160bcfd6e6247d1941043c5753c3655f1a8175
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Fri,  2 Sep 2016 15:54:52 +0200

Fix issues in the triangulation of the quadric mesh

Diffstat:
Msrc/ssol_shape.c | 16+++++++++-------
Msrc/test_ssol_shape.c | 7+++++--
2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/ssol_shape.c b/src/ssol_shape.c @@ -250,7 +250,7 @@ build_triangulated_plane size_t nverts[2]; size_t ix, iy; double size[2]; - double size_max; + double size_min; double delta; res_T res = RES_OK; ASSERT(coords && lower && upper && nsteps); @@ -260,14 +260,14 @@ build_triangulated_plane darray_size_t_clear(ids); d2_sub(size, upper, lower); - size_max = MMAX(size[0], size[1]); + size_min = MMIN(size[0], size[1]); - if(eq_eps(size_max, 0, 1.e-6)) { + if(eq_eps(size_min, 0, 1.e-6)) { res = RES_BAD_ARG; goto error; } - delta = size_max / (double)nsteps; + delta = size_min / (double)nsteps; nsteps2[0] = (size_t)ceil(size[0] / delta); nsteps2[1] = (size_t)ceil(size[1] / delta); nverts[0] = nsteps2[0] + 1; @@ -285,9 +285,11 @@ build_triangulated_plane /* Setup the plane vertices */ FOR_EACH(ix, 0, nverts[0]) { - const double x = MMIN((double)ix*delta, upper[0]); + double x = lower[0] + (double)ix*delta; + x = MMIN(x, upper[0]); FOR_EACH(iy, 0, nverts[1]) { - const double y = MMIN((double)iy*delta, upper[1]); + double y = lower[1] + (double)iy*delta; + y = MMIN(y, upper[1]); darray_double_push_back(coords, &x); darray_double_push_back(coords, &y); } @@ -565,7 +567,7 @@ ssol_punched_surface_setup } /* Define the #slices of the discretized quadric */ - nslices = psurf->quadric->type == SSOL_QUADRIC_PLANE ? 1 : 100; + nslices = psurf->quadric->type == SSOL_QUADRIC_PLANE ? 1 : 50; res = build_triangulated_plane(&coords, &ids, lower, upper, nslices); if(res != RES_OK) goto error; diff --git a/src/test_ssol_shape.c b/src/test_ssol_shape.c @@ -33,7 +33,9 @@ main(int argc, char** argv) struct ssol_punched_surface punched_surface; struct ssol_carving carving; struct ssol_quadric quadric; - const double polygon[] = { -1.0, -1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0 }; + const double polygon[] = { + -1.0, -1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 0.f, -2.f + }; const size_t npolygon_verts = sizeof(polygon)/sizeof(double[2]); (void) argc, (void) argv; @@ -45,7 +47,7 @@ main(int argc, char** argv) logger_set_stream(&logger, LOG_WARNING, log_stream, NULL); CHECK(ssol_device_create - (&logger, &allocator, SSOL_NTHREADS_DEFAULT, 1, &dev), RES_OK); + (&logger, &allocator, SSOL_NTHREADS_DEFAULT, 0, &dev), RES_OK); CHECK(ssol_shape_create_mesh(NULL, NULL), RES_BAD_ARG); CHECK(ssol_shape_create_mesh(dev, NULL), RES_BAD_ARG); @@ -130,6 +132,7 @@ main(int argc, char** argv) quadric.type = SSOL_QUADRIC_PARABOL; quadric.data.parabol.focal = 1; CHECK(ssol_punched_surface_setup(shape, &punched_surface), RES_OK); + return 0; quadric.data.parabol.focal = 0; CHECK(ssol_punched_surface_setup(shape, &punched_surface), RES_BAD_ARG);