commit a521ecc3164478d79baeb74e33013929ca7bfb41
parent 0f1fa93bbb7ca967fffe8005d42f1f2210f18635
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 11 Oct 2017 16:17:48 +0200
Rename the s3dut_ends enum in s3dut_cap_flag
Diffstat:
7 files changed, 42 insertions(+), 42 deletions(-)
diff --git a/src/s3dut.h b/src/s3dut.h
@@ -45,9 +45,9 @@ struct s3dut_mesh_data {
size_t nprimitives; /* # primitives */
};
-enum s3dut_ends {
- S3DUT_END_BOTTOM = BIT(0),
- S3DUT_END_TOP = BIT(1)
+enum s3dut_cap_flag {
+ S3DUT_CAP_NEG_Z = BIT(0),
+ S3DUT_CAP_POS_Z = BIT(1)
};
/*******************************************************************************
@@ -167,7 +167,7 @@ s3dut_create_truncated_sphere
const unsigned nslices, /* # subdivisions around Z axis in [3, INF) */
const unsigned nstacks, /* # subdivisions along Z axis in [2, INF) */
const double z_range[2], /* Clamp the sphere to z_range. NULL <=> no clamp */
- const unsigned close_ends, /* Combination of s3dut_ends. Ignored if no clamp */
+ const int cap_mask, /* Combination of s3dut_cap_flag. Ignored if no clamp */
struct s3dut_mesh** sphere);
/* Create a triangulated thick UV sphere centered in 0 discretized in `nslices'
@@ -187,7 +187,7 @@ s3dut_create_thick_truncated_sphere
const unsigned nslices, /* # subdivisions around Z axis in [3, INF) */
const unsigned nstacks, /* # subdivisions along Z axis in [2, INF) */
const double z_range[2], /* Clamp the sphere to z_range. NULL <=> no clamp */
- const unsigned close_ends, /* mask of s3dut_ends. Ignored if no clamp */
+ const int cap_mask, /* Combination of s3dut_cap_flag. Ignored if no clamp */
struct s3dut_mesh** sphere);
#endif /* S3DUT_H */
diff --git a/src/s3dut_cylinder.c b/src/s3dut_cylinder.c
@@ -186,8 +186,8 @@ s3dut_create_thin_cylinder
size_t* ids = NULL;
size_t nverts;
size_t ntris;
- const int close_bottom = close_ends & S3DUT_END_BOTTOM;
- const int close_top = close_ends & S3DUT_END_TOP;
+ const int close_bottom = close_ends & S3DUT_CAP_NEG_Z;
+ const int close_top = close_ends & S3DUT_CAP_POS_Z;
const unsigned nb_closed_ends = (close_bottom ? 1u : 0) + (close_top ? 1u : 0);
res_T res = RES_OK;
@@ -239,8 +239,8 @@ s3dut_create_thick_cylinder
size_t nverts;
size_t ntris;
size_t id_offset;
- const int close_bottom = close_ends & S3DUT_END_BOTTOM;
- const int close_top = close_ends & S3DUT_END_TOP;
+ const int close_bottom = close_ends & S3DUT_CAP_NEG_Z;
+ const int close_top = close_ends & S3DUT_CAP_POS_Z;
const unsigned nb_closed_ends = (close_bottom ? 1u : 0) + (close_top ? 1u : 0);
res_T res = RES_OK;
@@ -252,8 +252,8 @@ s3dut_create_thick_cylinder
}
nverts = 2 * (nslices*(nstacks+1)/*#contour*/ + nb_closed_ends/*#polar*/);
- ntris = 2 *
- ( 2 * nslices*nstacks /*#contour*/
+ ntris = 2 *
+ ( 2 * nslices*nstacks /*#contour*/
+ 2 * nslices/*#trg fans tris, regardless of closedness*/);
res = mesh_create
diff --git a/src/s3dut_sphere.c b/src/s3dut_sphere.c
@@ -27,7 +27,7 @@ setup_sphere_coords
const double z_range[2],
const unsigned nslices, /* # subdivisions around the Z axis */
const unsigned nstacks, /* # subdivisions along the Z axis */
- const unsigned close_ends)
+ const int close_ends)
{
enum { SIN, COS };
double* coords;
@@ -37,8 +37,8 @@ setup_sphere_coords
const int top_truncated = z_range && z_range[1] < +radius;
const int bottom_truncated = z_range && z_range[0] > -radius;
const unsigned nb_truncated = (unsigned)(top_truncated + bottom_truncated);
- const int close_top = top_truncated && (close_ends & S3DUT_END_TOP);
- const int close_bottom = bottom_truncated && (close_ends & S3DUT_END_BOTTOM);
+ const int close_top = top_truncated && (close_ends & S3DUT_CAP_POS_Z);
+ const int close_bottom = bottom_truncated && (close_ends & S3DUT_CAP_NEG_Z);
const unsigned nrings = nstacks - 1 + nb_truncated;
const double phi_z_min
= bottom_truncated ? asin(CLAMP(z_range[0] / radius, -1, 1)) : -PI / 2;
@@ -118,13 +118,13 @@ setup_sphere_indices
const unsigned nstacks, /* # subdivisions along the Z axis */
const double radius,
const double z_range[2],
- const unsigned close_ends,
+ const int close_ends,
const int cw_out)
{
const int top_truncated = z_range && z_range[1] < +radius;
const int bottom_truncated = z_range && z_range[0] > -radius;
- const int close_top = top_truncated && (close_ends & S3DUT_END_TOP);
- const int close_bottom = bottom_truncated && (close_ends & S3DUT_END_BOTTOM);
+ const int close_top = top_truncated && (close_ends & S3DUT_CAP_POS_Z);
+ const int close_bottom = bottom_truncated && (close_ends & S3DUT_CAP_NEG_Z);
const unsigned nb_truncated = (unsigned)(top_truncated + bottom_truncated);
const unsigned nrings = nstacks - 1 + nb_truncated;
size_t ibottom;
@@ -212,15 +212,15 @@ sphere_accum_counts
const unsigned nslices,
const unsigned nstacks,
const double z_range[2],
- const unsigned close_ends,
+ const int close_ends,
unsigned* nrings,
size_t* ntris,
size_t* nverts)
{
const int top_truncated = z_range && z_range[1] < +radius;
const int bottom_truncated = z_range && z_range[0] > -radius;
- const int close_top = top_truncated && (close_ends & S3DUT_END_TOP);
- const int close_bottom = bottom_truncated && (close_ends & S3DUT_END_BOTTOM);
+ const int close_top = top_truncated && (close_ends & S3DUT_CAP_POS_Z);
+ const int close_bottom = bottom_truncated && (close_ends & S3DUT_CAP_NEG_Z);
const unsigned nb_truncated = (unsigned)(top_truncated + bottom_truncated);
const unsigned nb_closed_ends = (close_top ? 1u : 0) + (close_bottom ? 1u : 0);
const unsigned nb_pole_vrtx = nb_closed_ends + (2 - nb_truncated);
@@ -268,14 +268,14 @@ s3dut_create_truncated_sphere
const unsigned nslices,
const unsigned nstacks,
const double z_range[2],
- const unsigned close_ends,
+ const int close_ends,
struct s3dut_mesh** mesh)
{
struct s3dut_mesh* sphere = NULL;
const int top_truncated = z_range && z_range[1] < +radius;
const int bottom_truncated = z_range && z_range[0] > -radius;
- const int close_top = top_truncated && (close_ends & S3DUT_END_TOP);
- const int close_bottom = bottom_truncated && (close_ends & S3DUT_END_BOTTOM);
+ const int close_top = top_truncated && (close_ends & S3DUT_CAP_POS_Z);
+ const int close_bottom = bottom_truncated && (close_ends & S3DUT_CAP_NEG_Z);
const unsigned nb_truncated = (unsigned)(top_truncated + bottom_truncated);
const unsigned nb_closed_ends = (close_top ? 1u : 0) + (close_bottom ? 1u : 0);
const unsigned nb_pole_vrtx = nb_closed_ends + (2 - nb_truncated);
@@ -324,11 +324,11 @@ s3dut_create_thick_truncated_sphere
const unsigned nslices,
const unsigned nstacks,
const double z_range[2],
- const unsigned c_e,
+ const int c_e,
struct s3dut_mesh** mesh)
{
struct s3dut_mesh* sphere = NULL;
- unsigned close_ends = c_e;
+ int close_ends = c_e;
double* coords = NULL;
double* prev_coords;
size_t* ids_out = NULL;
@@ -338,8 +338,8 @@ s3dut_create_thick_truncated_sphere
const double internal_radius = radius - thickness;
const int top_truncated = z_range && (z_range[1] < +radius);
const int bottom_truncated = z_range && (z_range[0] > -radius);
- const int close_top = top_truncated && (close_ends & S3DUT_END_TOP);
- const int close_bottom = bottom_truncated && (close_ends & S3DUT_END_BOTTOM);
+ const int close_top = top_truncated && (close_ends & S3DUT_CAP_POS_Z);
+ const int close_bottom = bottom_truncated && (close_ends & S3DUT_CAP_NEG_Z);
const int top_seam = z_range && (z_range[1] < internal_radius) && !close_top;
const int bottom_seam
= z_range && (z_range[0] > -internal_radius) && ! close_bottom;
@@ -358,10 +358,10 @@ s3dut_create_thick_truncated_sphere
/* Special case when a single sphere is truncated */
if(top_truncated && (z_range[1] >= internal_radius)) {
- close_ends |= S3DUT_END_TOP; /* close the external sphere's top end */
+ close_ends |= S3DUT_CAP_POS_Z; /* close the external sphere's top end */
}
if(bottom_truncated && (z_range[0] <= -internal_radius)) {
- close_ends |= S3DUT_END_BOTTOM; /* close the external sphere's bottom end */
+ close_ends |= S3DUT_CAP_NEG_Z; /* close the external sphere's bottom end */
}
z_internal_range[0] = (bottom_truncated && !close_bottom)
? z_range[0] : (z_range ? z_range[0] : -radius) + thickness;
diff --git a/src/test_s3dut_thick_cylinder.c b/src/test_s3dut_thick_cylinder.c
@@ -102,13 +102,13 @@ main(int argc, char** argv)
CHECK(CR_CYL(&allocator, 1, 1, -0.1, 3, 1, 0, &msh), RES_BAD_ARG);
CHECK(CR_CYL(&allocator, 1, 1, 1, 3, 1, 0, &msh), RES_BAD_ARG);
CHECK(CR_CYL(&allocator, 2, 1, 0.5, 3, 1,
- S3DUT_END_TOP| S3DUT_END_BOTTOM, &msh), RES_BAD_ARG);
- CHECK(CR_CYL(&allocator, 2, 0.5, 0.5, 3, 1, S3DUT_END_TOP, &msh), RES_BAD_ARG);
- CHECK(CR_CYL(&allocator, 2, 0.5, 0.5, 3, 1, S3DUT_END_BOTTOM, &msh), RES_BAD_ARG);
+ S3DUT_CAP_POS_Z| S3DUT_CAP_NEG_Z, &msh), RES_BAD_ARG);
+ CHECK(CR_CYL(&allocator, 2, 0.5, 0.5, 3, 1, S3DUT_CAP_POS_Z, &msh), RES_BAD_ARG);
+ CHECK(CR_CYL(&allocator, 2, 0.5, 0.5, 3, 1, S3DUT_CAP_NEG_Z, &msh), RES_BAD_ARG);
CHECK(CR_CYL(&allocator, 1, 1, 0.1, 2, 1, 0, &msh), RES_BAD_ARG);
CHECK(CR_CYL(&allocator, 1, 1, 0.1, 3, 0, 0, &msh), RES_BAD_ARG);
- CHECK(CR_CYL(&allocator, 1, 2, 0.1, 16, 4, S3DUT_END_TOP, &msh), RES_OK);
+ CHECK(CR_CYL(&allocator, 1, 2, 0.1, 16, 4, S3DUT_CAP_POS_Z, &msh), RES_OK);
#undef CR_CYL
CHECK(s3dut_mesh_get_data(msh, &data), RES_OK);
diff --git a/src/test_s3dut_thick_truncated_sphere.c b/src/test_s3dut_thick_truncated_sphere.c
@@ -69,14 +69,14 @@ main(int argc, char** argv)
z_range[0] = -0.8;
z_range[1] = -0.1;
- CHECK(CR_SPH(&allocator, 1, 0.1, 16, 8, z_range, S3DUT_END_BOTTOM, &msh), RES_OK);
+ CHECK(CR_SPH(&allocator, 1, 0.1, 16, 8, z_range, S3DUT_CAP_NEG_Z, &msh), RES_OK);
CHECK(s3dut_mesh_ref_put(msh), RES_OK);
- CHECK(CR_SPH(&allocator, 1, 0.1, 16, 8, z_range, S3DUT_END_TOP, &msh), RES_OK);
+ CHECK(CR_SPH(&allocator, 1, 0.1, 16, 8, z_range, S3DUT_CAP_POS_Z, &msh), RES_OK);
CHECK(s3dut_mesh_ref_put(msh), RES_OK);
CHECK(CR_SPH(&allocator, 1, 0.1, 16, 8, z_range,
- S3DUT_END_TOP | S3DUT_END_BOTTOM, &msh), RES_OK);
+ S3DUT_CAP_POS_Z | S3DUT_CAP_NEG_Z, &msh), RES_OK);
CHECK(s3dut_mesh_ref_put(msh), RES_OK);
z_range[0] = 0;
@@ -95,7 +95,7 @@ main(int argc, char** argv)
z_range[0] = 0;
z_range[1] = 0.8;
- CHECK(CR_SPH(&allocator, 1, 0.1, 16, 8, z_range, S3DUT_END_BOTTOM, &msh), RES_OK);
+ CHECK(CR_SPH(&allocator, 1, 0.1, 16, 8, z_range, S3DUT_CAP_NEG_Z, &msh), RES_OK);
CHECK(s3dut_mesh_get_data(msh, &data), RES_OK);
NCHECK(data.positions, NULL);
diff --git a/src/test_s3dut_thin_cylinder.c b/src/test_s3dut_thin_cylinder.c
@@ -67,19 +67,19 @@ main(int argc, char** argv)
CHECK(CR_CYL(&allocator, 1, 1, 3, 1, 0, &msh), RES_OK);
CHECK(s3dut_mesh_ref_put(msh), RES_OK);
- CHECK(CR_CYL(&allocator, 1, 1, 3, 1, S3DUT_END_TOP, &msh), RES_OK);
+ CHECK(CR_CYL(&allocator, 1, 1, 3, 1, S3DUT_CAP_POS_Z, &msh), RES_OK);
CHECK(s3dut_mesh_ref_put(msh), RES_OK);
- CHECK(CR_CYL(&allocator, 1, 1, 3, 1, S3DUT_END_BOTTOM, &msh), RES_OK);
+ CHECK(CR_CYL(&allocator, 1, 1, 3, 1, S3DUT_CAP_NEG_Z, &msh), RES_OK);
CHECK(s3dut_mesh_ref_put(msh), RES_OK);
CHECK(CR_CYL(&allocator, 1, 1, 3, 1,
- S3DUT_END_TOP | S3DUT_END_BOTTOM, &msh), RES_OK);
+ S3DUT_CAP_POS_Z | S3DUT_CAP_NEG_Z, &msh), RES_OK);
CHECK(s3dut_mesh_ref_put(msh), RES_OK);
CHECK(CR_CYL(&allocator, -1, 1, 3, 1, 0, &msh), RES_BAD_ARG);
CHECK(CR_CYL(&allocator, 1, -1, 3, 1, 0, &msh), RES_BAD_ARG);
CHECK(CR_CYL(&allocator, 1, 1, 2, 1, 0, &msh), RES_BAD_ARG);
CHECK(CR_CYL(&allocator, 1, 1, 3, 0, 0, &msh), RES_BAD_ARG);
- CHECK(CR_CYL(&allocator, 1, 2, 16, 4, S3DUT_END_BOTTOM, &msh), RES_OK);
+ CHECK(CR_CYL(&allocator, 1, 2, 16, 4, S3DUT_CAP_NEG_Z, &msh), RES_OK);
CHECK(s3dut_mesh_get_data(msh, &data), RES_OK);
dump_mesh_data(stdout, &data);
diff --git a/src/test_s3dut_truncated_sphere.c b/src/test_s3dut_truncated_sphere.c
@@ -46,7 +46,7 @@ main(int argc, char** argv)
z_range[0] = 0;
z_range[1] = 0.9;
- CHECK(CR_TS(&allocator, 1, 16, 8, z_range, S3DUT_END_BOTTOM, &msh), RES_OK);
+ CHECK(CR_TS(&allocator, 1, 16, 8, z_range, S3DUT_CAP_NEG_Z, &msh), RES_OK);
CHECK(s3dut_mesh_get_data(msh, &data), RES_OK);
NCHECK(data.positions, NULL);