[Bf-blender-cvs] [a4082a6e623] temp-D5423-update: Cleanup: add braces
Campbell Barton
noreply at git.blender.org
Fri Aug 9 09:13:21 CEST 2019
Commit: a4082a6e623c0c78c792804b1bc1724c42741164
Author: Campbell Barton
Date: Fri Aug 9 15:18:58 2019 +1000
Branches: temp-D5423-update
https://developer.blender.org/rBa4082a6e623c0c78c792804b1bc1724c42741164
Cleanup: add braces
===================================================================
M source/blender/blenlib/intern/delaunay_2d.c
===================================================================
diff --git a/source/blender/blenlib/intern/delaunay_2d.c b/source/blender/blenlib/intern/delaunay_2d.c
index 03881a4da02..1c0b68ddb3b 100644
--- a/source/blender/blenlib/intern/delaunay_2d.c
+++ b/source/blender/blenlib/intern/delaunay_2d.c
@@ -184,21 +184,25 @@ static int isect_seg_seg_v2_lambda_mu_db(const double v1[2],
double div, lambda, mu;
div = (v2[0] - v1[0]) * (v4[1] - v3[1]) - (v2[1] - v1[1]) * (v4[0] - v3[0]);
- if (fabs(div) < DBL_EPSILON)
+ if (fabs(div) < DBL_EPSILON) {
return ISECT_LINE_LINE_COLINEAR;
+ }
lambda = ((v1[1] - v3[1]) * (v4[0] - v3[0]) - (v1[0] - v3[0]) * (v4[1] - v3[1])) / div;
mu = ((v1[1] - v3[1]) * (v2[0] - v1[0]) - (v1[0] - v3[0]) * (v2[1] - v1[1])) / div;
- if (r_lambda)
+ if (r_lambda) {
*r_lambda = lambda;
- if (r_mu)
+ }
+ if (r_mu) {
*r_mu = mu;
+ }
if (lambda >= 0.0 && lambda <= 1.0 && mu >= 0.0 && mu <= 1.0) {
- if (lambda == 0.0 || lambda == 1.0 || mu == 0.0 || mu == 1.0)
+ if (lambda == 0.0 || lambda == 1.0 || mu == 0.0 || mu == 1.0) {
return ISECT_LINE_LINE_EXACT;
+ }
return ISECT_LINE_LINE_CROSS;
}
return ISECT_LINE_LINE_NONE;
@@ -213,13 +217,16 @@ static int CCW_test(const double a[2], const double b[2], const double c[2])
/* This is twice the signed area of triangle abc. */
det = (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1]);
ab = len_v2v2_db(a, b);
- if (ab < DBL_EPSILON)
+ if (ab < DBL_EPSILON) {
return 0;
+ }
det /= ab;
- if (det > DBL_EPSILON)
+ if (det > DBL_EPSILON) {
return 1;
- else if (det < -DBL_EPSILON)
+ }
+ else if (det < -DBL_EPSILON) {
return -1;
+ }
return 0;
}
@@ -239,8 +246,9 @@ static bool reachable(SymEdge *s1, SymEdge *s2, int limit)
{
int count = 0;
for (SymEdge *s = s1; s && count < limit; s = s->next) {
- if (s == s2)
+ if (s == s2) {
return true;
+ }
count++;
}
return false;
@@ -295,11 +303,13 @@ static CDTEdge *add_cdtedge(
se->face = fleft;
sesym->face = fright;
se->vert = v1;
- if (v1->symedge == NULL)
+ if (v1->symedge == NULL) {
v1->symedge = se;
+ }
sesym->vert = v2;
- if (v2->symedge == NULL)
+ if (v2->symedge == NULL) {
v2->symedge = sesym;
+ }
se->next = sesym->next = se->rot = sesym->rot = NULL;
return e;
}
@@ -320,8 +330,9 @@ static bool id_in_list(const LinkNode *id_list, int id)
const LinkNode *ln;
for (ln = id_list; ln; ln = ln->next) {
- if (POINTER_AS_INT(ln->link) == id)
+ if (POINTER_AS_INT(ln->link) == id) {
return true;
+ }
}
return false;
}
@@ -334,8 +345,9 @@ static bool id_range_in_list(const LinkNode *id_list, int range_start, int range
for (ln = id_list; ln; ln = ln->next) {
id = POINTER_AS_INT(ln->link);
- if (id >= range_start && id <= range_end)
+ if (id >= range_start && id <= range_end) {
return true;
+ }
}
return false;
}
@@ -394,11 +406,13 @@ static bool exists_edge(const CDTVert *a, const CDTVert *b)
{
SymEdge *se, *ss;
se = a->symedge;
- if (se->next->vert == b)
+ if (se->next->vert == b) {
return true;
+ }
for (ss = se->rot; ss != se; ss = ss->rot) {
- if (ss->next->vert == b)
+ if (ss->next->vert == b) {
return true;
+ }
}
return false;
}
@@ -483,8 +497,9 @@ static CDTEdge *split_edge(CDT_state *cdt, SymEdge *se, double lambda)
senext->rot = newsesym;
newsesym->rot = sesymprevsym;
sesymprev->next = newsesym;
- if (newsesym->vert->symedge == sesym)
+ if (newsesym->vert->symedge == sesym) {
newsesym->vert->symedge = newsesym;
+ }
add_list_to_input_ids(&e->input_ids, se->edge->input_ids, cdt);
calc_face_centroid(se);
calc_face_centroid(sesym);
@@ -548,25 +563,31 @@ static void delete_edge(CDT_state *cdt, SymEdge *e)
}
/* If e was representative symedge for v1 or v2, fix that. */
- if (v1_isolated)
+ if (v1_isolated) {
v1->symedge = NULL;
- else if (v1->symedge == e)
+ }
+ else if (v1->symedge == e) {
v1->symedge = i;
- if (v2_isolated)
+ }
+ if (v2_isolated) {
v2->symedge = NULL;
- else if (v2->symedge == esym)
+ }
+ else if (v2->symedge == esym) {
v2->symedge = f;
+ }
/* Mark SymEdge as deleted by setting all its pointers to NULL. */
e->next = e->rot = NULL;
esym->next = esym->rot = NULL;
if (!v1_isolated && !v2_isolated && aface != bface) {
bface->deleted = true;
- if (cdt->outer_face == bface)
+ if (cdt->outer_face == bface) {
cdt->outer_face = aface;
+ }
}
- if (aface != cdt->outer_face)
+ if (aface != cdt->outer_face) {
calc_face_centroid(f);
+ }
}
/**
@@ -615,10 +636,12 @@ static CDT_state *cdt_init(double minx, double maxx, double miny, double maxy, d
/* Expand bounding box a bit and make initial CDT from it. */
margin = DLNY_MARGIN_PCT * max_dd(maxx - minx, maxy - miny) / 100.0;
- if (margin <= 0.0)
+ if (margin <= 0.0) {
margin = 1.0;
- if (margin < epsilon)
+ }
+ if (margin < epsilon) {
margin = 4 * epsilon; /* Make sure constraint verts don't merge with border verts. */
+ }
cdt->margin = margin;
x0 = minx - margin;
y0 = miny - margin;
@@ -632,8 +655,9 @@ static CDT_state *cdt_init(double minx, double maxx, double miny, double maxy, d
v[3] = add_cdtvert(cdt, x0, y1);
cdt->outer_face = fouter = add_cdtface(cdt);
f0 = add_cdtface(cdt);
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; i++) {
e[i] = add_cdtedge(cdt, v[i], v[(i + 1) % 4], f0, fouter);
+ }
for (i = 0; i < 4; i++) {
inext = (i + 1) % 4;
iprev = (i + 3) % 4;
@@ -696,8 +720,9 @@ static bool locate_point_final(const double p[2],
if (len_close_p < epsilon) {
if (len_v2v2_db(p, a) < epsilon) {
#ifdef DEBUG_CDT
- if (dbglevel > 0)
+ if (dbglevel > 0) {
fprintf(stderr, "OnVert case a (%.2f,%.2f)\n", F2(a));
+ }
#endif
r_lr->loc_kind = OnVert;
r_lr->se = se;
@@ -706,8 +731,9 @@ static bool locate_point_final(const double p[2],
}
else if (len_v2v2_db(p, b) < epsilon) {
#ifdef DEBUG_CDT
- if (dbglevel > 0)
+ if (dbglevel > 0) {
fprintf(stderr, "OnVert case b (%.2f,%.2f)\n", F2(b));
+ }
#endif
r_lr->loc_kind = OnVert;
r_lr->se = se->next;
@@ -736,12 +762,13 @@ static bool locate_point_final(const double p[2],
} while (se != tri_se && !done);
if (!done) {
#ifdef DEBUG_CDT
- if (dbglevel > 1)
+ if (dbglevel > 1) {
fprintf(stderr,
"not done, dist_inside=%f %f %f\n",
dist_inside[0],
dist_inside[1],
dist_inside[2]);
+ }
#endif
if (dist_inside[0] >= 0.0 && dist_inside[1] >= 0.0 && dist_inside[2] >= 0.0) {
#ifdef DEBUG_CDT
@@ -765,12 +792,15 @@ static bool locate_point_final(const double p[2],
if (!done) {
/* Shouldn't happen desperation mode: pick something. */
se = NULL;
- if (dist_inside[0] > 0)
+ if (dist_inside[0] > 0) {
se = tri_se;
- if (dist_inside[1] > 0 && (se == NULL || dist_inside[1] < dist_inside[i]))
+ }
+ if (dist_inside[1] > 0 && (se == NULL || dist_inside[1] < dist_inside[i])) {
se = tri_se->next;
- if (se == NULL)
+ }
+ if (se == NULL) {
se = tri_se->next->next;
+ }
a = se->vert->co;
b = se->next->vert->co;
lambda = closest_to_line_v2_db(close, p, a, b);
@@ -821,14 +851,16 @@ static LocateResult locate_point(CDT_state *cdt, const double p[2])
#ifdef DEBUG_CDT
int dbglevel = 0;
- if (dbglevel > 0)
+ if (dbglevel > 0) {
fprintf(stderr, "locate_point (%.2f,%.2f), visit_index=%d\n", F2(p), visit);
+ }
#endif
/* Starting point determined by closest to p in an n ** (1/3) sized sample of current points. */
BLI_assert(cdt->vert_array_len > 0);
sample_n = (int)round(pow((double)cdt->vert_array_len, 0.33333));
- if (sample_n < 1)
+ if (sample_n < 1) {
sample_n = 1;
+ }
best_start_vert = NULL;
best_dist_squared = DBL_MAX;
for (k = 0; k < sample_n; k++) {
@@ -854,16 +886,18 @@ static LocateResult locate_point(CDT_state *cdt, const double p[2])
BLI_assert(cur_se->face != cdt->outer_face);
}
#ifdef DEBUG_CDT
- if (dbglevel > 0)
+ if (dbglevel > 0) {
dump_se(cur_se, "start vert edge");
+ }
#endif
done = false;
while (!done) {
/* Find edge of cur_tri that separates p and t's centroid,
* and where other tri over the edge is unvisited. */
#ifdef DEBUG_CDT
- if (dbglevel > 0)
+ if (dbglevel > 0) {
dump_se_cycle(cur_se, "cur search face", 5);
+ }
#endif
cur_tri = cur_se->face;
BLI_assert(cur_tri != cdt->outer_face);
@@ -874,8 +908,9 @@ static LocateResult locate_point(CDT_state *cdt, const double p[2])
c = cur_se->next->next->vert->co;
if (CCW_test(a, b, p) >= 0 && CCW_test(b, c, p) >= 0 && CCW_test(c, a, p) >= 0) {
#ifdef DEBUG_CDT
- if (dbglevel > 1)
+ if (dbglevel > 1) {
fprintf(stderr, "p in current triangle\n");
+ }
#endif
done = locate_point_final(p, cur_se, false, epsilon, &lr);
BLI_assert(done == true);
@@ -897,8 +932,9 @@ static LocateResult locate_point(CDT_state *cdt, const double p[2])
next_se_sym = sym(next_se);
if (CCW_test(a, b, p) <= 0 && next_se->face != cdt->outer_face) {
#ifdef DEBUG_CDT
- if (dbglevel > 1)
+ if (dbglevel > 1) {
fprintf(stderr, "CCW_test(a, b, p) <= 0\n");
+ }
#endif
#ifdef DEBUG_CDT
if (dbglevel > 0) {
@@ -908,8 +944,9 @@ static LocateResult locate_point(CDT_state *cdt, const double p[2])
#endif
if (next_se_sym->face->visit_index != visit) {
#ifdef DEBUG_CDT
- if (dbglevel > 0)
+ if (dbglevel > 0) {
fprintf(stderr, "found edge to cross\n");
+ }
#endif
found_next = true;
cur_se = next_se_sym;
@@ -950,8 +987,9 @@ static bool delaunay_check(CDTVert *v1, CDTVert *v2, CDTVert *v3, CDTVert *p, co
c = z1 * (p2[0] - p3[0]) + z2 * (p3[0] - p1[0]) + z3 * (p1[0] - p2[0]);
d = z1 * (p3[0] * p2[1] - p2[0] * p3[1]) + z2 * (p1[0] * p3[1] - p3[0] *
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list