Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/tests/BLI_polyfill_2d_test.cc')
-rw-r--r--source/blender/blenlib/tests/BLI_polyfill_2d_test.cc114
1 files changed, 57 insertions, 57 deletions
diff --git a/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc b/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc
index db2fb1ba671..69c60c5bdb9 100644
--- a/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc
+++ b/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc
@@ -29,20 +29,20 @@
static void polyfill_to_obj(const char *id,
const float poly[][2],
- const unsigned int poly_num,
- const unsigned int tris[][3],
- const unsigned int tris_num);
+ const uint poly_num,
+ const uint tris[][3],
+ const uint tris_num);
/* -------------------------------------------------------------------- */
/* test utility functions */
-#define TRI_ERROR_VALUE (unsigned int)-1
+#define TRI_ERROR_VALUE (uint) - 1
-static void test_valid_polyfill_prepare(unsigned int tris[][3], unsigned int tris_num)
+static void test_valid_polyfill_prepare(uint tris[][3], uint tris_num)
{
- unsigned int i;
+ uint i;
for (i = 0; i < tris_num; i++) {
- unsigned int j;
+ uint j;
for (j = 0; j < 3; j++) {
tris[i][j] = TRI_ERROR_VALUE;
}
@@ -57,14 +57,14 @@ static void test_valid_polyfill_prepare(unsigned int tris[][3], unsigned int tri
* - all verts used at least once.
*/
static void test_polyfill_simple(const float /*poly*/[][2],
- const unsigned int poly_num,
- const unsigned int tris[][3],
- const unsigned int tris_num)
+ const uint poly_num,
+ const uint tris[][3],
+ const uint tris_num)
{
- unsigned int i;
+ uint i;
int *used_num = (int *)MEM_callocN(poly_num * sizeof(int), __func__);
for (i = 0; i < tris_num; i++) {
- unsigned int j;
+ uint j;
for (j = 0; j < 3; j++) {
EXPECT_NE(TRI_ERROR_VALUE, tris[i][j]);
used_num[tris[i][j]] += 1;
@@ -80,18 +80,18 @@ static void test_polyfill_simple(const float /*poly*/[][2],
}
static void test_polyfill_topology(const float /*poly*/[][2],
- const unsigned int poly_num,
- const unsigned int tris[][3],
- const unsigned int tris_num)
+ const uint poly_num,
+ const uint tris[][3],
+ const uint tris_num)
{
EdgeHash *edgehash = BLI_edgehash_new(__func__);
EdgeHashIterator *ehi;
- unsigned int i;
+ uint i;
for (i = 0; i < tris_num; i++) {
- unsigned int j;
+ uint j;
for (j = 0; j < 3; j++) {
- const unsigned int v1 = tris[i][j];
- const unsigned int v2 = tris[i][(j + 1) % 3];
+ const uint v1 = tris[i][j];
+ const uint v2 = tris[i][(j + 1) % 3];
void **p = BLI_edgehash_lookup_p(edgehash, v1, v2);
if (p) {
*p = (void *)((intptr_t)*p + (intptr_t)1);
@@ -104,8 +104,8 @@ static void test_polyfill_topology(const float /*poly*/[][2],
EXPECT_EQ(BLI_edgehash_len(edgehash), poly_num + (poly_num - 3));
for (i = 0; i < poly_num; i++) {
- const unsigned int v1 = i;
- const unsigned int v2 = (i + 1) % poly_num;
+ const uint v1 = i;
+ const uint v2 = (i + 1) % poly_num;
void **p = BLI_edgehash_lookup_p(edgehash, v1, v2);
EXPECT_NE((void *)p, nullptr);
EXPECT_EQ((intptr_t)*p, 1);
@@ -125,12 +125,12 @@ static void test_polyfill_topology(const float /*poly*/[][2],
* Check all faces are flipped the same way
*/
static void test_polyfill_winding(const float poly[][2],
- const unsigned int /*poly_num*/,
- const unsigned int tris[][3],
- const unsigned int tris_num)
+ const uint /*poly_num*/,
+ const uint tris[][3],
+ const uint tris_num)
{
- unsigned int i;
- unsigned int count[2] = {0, 0};
+ uint i;
+ uint count[2] = {0, 0};
for (i = 0; i < tris_num; i++) {
float winding_test = cross_tri_v2(poly[tris[i][0]], poly[tris[i][1]], poly[tris[i][2]]);
if (fabsf(winding_test) > FLT_EPSILON) {
@@ -144,11 +144,11 @@ static void test_polyfill_winding(const float poly[][2],
* Check the accumulated triangle area is close to the original area.
*/
static void test_polyfill_area(const float poly[][2],
- const unsigned int poly_num,
- const unsigned int tris[][3],
- const unsigned int tris_num)
+ const uint poly_num,
+ const uint tris[][3],
+ const uint tris_num)
{
- unsigned int i;
+ uint i;
const float area_total = area_poly_v2(poly, poly_num);
float area_total_tris = 0.0f;
const float eps_abs = 0.00001f;
@@ -167,9 +167,9 @@ static void test_polyfill_area(const float poly[][2],
static void test_polyfill_template_check(const char *id,
bool is_degenerate,
const float poly[][2],
- const unsigned int poly_num,
- const unsigned int tris[][3],
- const unsigned int tris_num)
+ const uint poly_num,
+ const uint tris[][3],
+ const uint tris_num)
{
test_polyfill_simple(poly, poly_num, tris, tris_num);
test_polyfill_topology(poly, poly_num, tris, tris_num);
@@ -184,9 +184,9 @@ static void test_polyfill_template_check(const char *id,
static void test_polyfill_template(const char *id,
bool is_degenerate,
const float poly[][2],
- const unsigned int poly_num,
- unsigned int tris[][3],
- const unsigned int tris_num)
+ const uint poly_num,
+ uint tris[][3],
+ const uint tris_num)
{
test_valid_polyfill_prepare(tris, tris_num);
BLI_polyfill_calc(poly, poly_num, 0, tris);
@@ -213,9 +213,9 @@ static void test_polyfill_template(const char *id,
static void test_polyfill_template_flip_sign(const char *id,
bool is_degenerate,
const float poly[][2],
- const unsigned int poly_num,
- unsigned int tris[][3],
- const unsigned int tris_num)
+ const uint poly_num,
+ uint tris[][3],
+ const uint tris_num)
{
float(*poly_copy)[2] = (float(*)[2])MEM_mallocN(sizeof(float[2]) * poly_num, id);
for (int flip_x = 0; flip_x < 2; flip_x++) {
@@ -236,19 +236,19 @@ static void test_polyfill_template_flip_sign(const char *id,
static void test_polyfill_template_main(const char *id,
bool is_degenerate,
const float poly[][2],
- const unsigned int poly_num,
- unsigned int tris[][3],
- const unsigned int tris_num)
+ const uint poly_num,
+ uint tris[][3],
+ const uint tris_num)
{
/* overkill? - try at _every_ offset & reverse */
- unsigned int poly_reverse;
+ uint poly_reverse;
float(*poly_copy)[2] = (float(*)[2])MEM_mallocN(sizeof(float[2]) * poly_num, id);
float tmp[2];
memcpy(poly_copy, poly, sizeof(float[2]) * poly_num);
for (poly_reverse = 0; poly_reverse < 2; poly_reverse++) {
- unsigned int poly_cycle;
+ uint poly_cycle;
if (poly_reverse) {
BLI_array_reverse(poly_copy, poly_num);
@@ -271,9 +271,9 @@ static void test_polyfill_template_main(const char *id,
static void test_polyfill_template_main(const char *id,
bool is_degenerate,
const float poly[][2],
- const unsigned int poly_num,
- unsigned int tris[][3],
- const unsigned int tris_num)
+ const uint poly_num,
+ uint tris[][3],
+ const uint tris_num)
{
test_polyfill_template_flip_sign(id, is_degenerate, poly, poly_num, tris, tris_num);
}
@@ -281,9 +281,9 @@ static void test_polyfill_template_main(const char *id,
#define TEST_POLYFILL_TEMPLATE_STATIC(poly, is_degenerate) \
{ \
- unsigned int tris[POLY_TRI_COUNT(ARRAY_SIZE(poly))][3]; \
- const unsigned int poly_num = ARRAY_SIZE(poly); \
- const unsigned int tris_num = ARRAY_SIZE(tris); \
+ uint tris[POLY_TRI_COUNT(ARRAY_SIZE(poly))][3]; \
+ const uint poly_num = ARRAY_SIZE(poly); \
+ const uint tris_num = ARRAY_SIZE(tris); \
const char *id = typeid(*this).name(); \
\
test_polyfill_template_main(id, is_degenerate, poly, poly_num, tris, tris_num); \
@@ -296,13 +296,13 @@ static void test_polyfill_template_main(const char *id,
#ifdef USE_OBJ_PREVIEW
static void polyfill_to_obj(const char *id,
const float poly[][2],
- const unsigned int poly_num,
- const unsigned int tris[][3],
- const unsigned int tris_num)
+ const uint poly_num,
+ const uint tris[][3],
+ const uint tris_num)
{
char path[1024];
FILE *f;
- unsigned int i;
+ uint i;
BLI_snprintf(path, sizeof(path), "%s.obj", id);
@@ -324,9 +324,9 @@ static void polyfill_to_obj(const char *id,
#else
static void polyfill_to_obj(const char *id,
const float poly[][2],
- const unsigned int poly_num,
- const unsigned int tris[][3],
- const unsigned int tris_num)
+ const uint poly_num,
+ const uint tris[][3],
+ const uint tris_num)
{
(void)id;
(void)poly, (void)poly_num;