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/intern/delaunay_2d.c')
-rw-r--r--source/blender/blenlib/intern/delaunay_2d.c64
1 files changed, 30 insertions, 34 deletions
diff --git a/source/blender/blenlib/intern/delaunay_2d.c b/source/blender/blenlib/intern/delaunay_2d.c
index 5f663dcb2e1..baf49ddaffd 100644
--- a/source/blender/blenlib/intern/delaunay_2d.c
+++ b/source/blender/blenlib/intern/delaunay_2d.c
@@ -600,19 +600,19 @@ static int site_lexicographic_cmp(const void *a, const void *b)
if (co1[0] < co2[0]) {
return -1;
}
- else if (co1[0] > co2[0]) {
+ if (co1[0] > co2[0]) {
return 1;
}
- else if (co1[1] < co2[1]) {
+ if (co1[1] < co2[1]) {
return -1;
}
- else if (co1[1] > co2[1]) {
+ if (co1[1] > co2[1]) {
return 1;
}
- else if (s1->orig_index < s2->orig_index) {
+ if (s1->orig_index < s2->orig_index) {
return -1;
}
- else if (s1->orig_index > s2->orig_index) {
+ if (s1->orig_index > s2->orig_index) {
return 1;
}
return 0;
@@ -974,7 +974,7 @@ static void initial_triangulation(CDT_state *cdt)
if (jco[0] > xend) {
break; /* No more j's to process. */
}
- else if (jco[1] > yend) {
+ if (jco[1] > yend) {
/* Get past any string of v's with the same x and too-big y. */
xcur = jco[0];
while (++j < n) {
@@ -1414,7 +1414,7 @@ static bool get_next_crossing_from_vert(CDT_state *cdt,
ok = true;
break;
}
- else if (t->face != cdt->outer_face) {
+ if (t->face != cdt->outer_face) {
orient2 = orient2d(vcur->co, vb->co, v2->co);
#ifdef DEBUG_CDT
if (dbg_level > 1) {
@@ -1683,14 +1683,12 @@ static void add_edge_constraint(
(cd_prev->lambda != 0.0 && cd_prev->in->vert != v && cd_prev->in->next->vert != v)) {
break;
}
- else {
- cd_prev->lambda = -1.0; /* Mark cd_prev as 'deleted'. */
+ cd_prev->lambda = -1.0; /* Mark cd_prev as 'deleted'. */
#ifdef DEBUG_CDT
- if (dbg_level > 0) {
- fprintf(stderr, "deleted crossing %d\n", j);
- }
-#endif
+ if (dbg_level > 0) {
+ fprintf(stderr, "deleted crossing %d\n", j);
}
+#endif
}
if (j < i - 1) {
/* Some crossings were deleted. Fix the in and out edges across gap. */
@@ -2002,19 +2000,19 @@ static int evl_cmp(const void *a, const void *b)
if (area->e_id < sb->e_id) {
return -1;
}
- else if (area->e_id > sb->e_id) {
+ if (area->e_id > sb->e_id) {
return 1;
}
- else if (area->lambda < sb->lambda) {
+ if (area->lambda < sb->lambda) {
return -1;
}
- else if (area->lambda > sb->lambda) {
+ if (area->lambda > sb->lambda) {
return 1;
}
- else if (area->v_id < sb->v_id) {
+ if (area->v_id < sb->v_id) {
return -1;
}
- else if (area->v_id > sb->v_id) {
+ if (area->v_id > sb->v_id) {
return 1;
}
return 0;
@@ -2236,16 +2234,15 @@ static const CDT_input *modify_input_for_near_edge_ends(const CDT_input *input,
new_input->epsilon = input->epsilon;
new_input->verts_len = input->verts_len;
new_input->vert_coords = (float(*)[2])MEM_malloc_arrayN(
- new_input->verts_len, 2 * sizeof(float), __func__);
+ new_input->verts_len, sizeof(float[2]), __func__);
/* We don't do it now, but may decide to change coords of snapped verts. */
memmove(new_input->vert_coords,
input->vert_coords,
- (size_t)new_input->verts_len * sizeof(float) * 2);
+ sizeof(float[2]) * (size_t)new_input->verts_len);
if (edges_len > 0) {
new_input->edges_len = new_tot_con_edges;
- new_input->edges = (int(*)[2])MEM_malloc_arrayN(
- new_tot_con_edges, 2 * sizeof(int), __func__);
+ new_input->edges = (int(*)[2])MEM_malloc_arrayN(new_tot_con_edges, sizeof(int[2]), __func__);
}
if (input->faces_len > 0) {
@@ -2386,9 +2383,7 @@ static const CDT_input *modify_input_for_near_edge_ends(const CDT_input *input,
if (new_input != NULL) {
return (const CDT_input *)new_input;
}
- else {
- return input;
- }
+ return input;
}
static void free_modified_input(CDT_input *input)
@@ -2745,7 +2740,7 @@ static int edge_to_sort_cmp(const void *a, const void *b)
if (e1->len_squared > e2->len_squared) {
return -1;
}
- else if (e1->len_squared < e2->len_squared) {
+ if (e1->len_squared < e2->len_squared) {
return 1;
}
return 0;
@@ -4570,17 +4565,13 @@ static double orient2d(const double *pa, const double *pb, const double *pc)
if (detright <= 0.0) {
return det;
}
- else {
- detsum = detleft + detright;
- }
+ detsum = detleft + detright;
}
else if (detleft < 0.0) {
if (detright >= 0.0) {
return det;
}
- else {
- detsum = -detleft - detright;
- }
+ detsum = -detleft - detright;
}
else {
return det;
@@ -4609,8 +4600,13 @@ static double orient2d(const double *pa, const double *pb, const double *pc)
* returned value has the correct sign. Hence, incircle() is usually quite
* fast, but will run more slowly when the input points are cocircular or
* nearly so.
- */
-
+ *
+ * This function is allowed to be long for two reasons. Firstly, it was taken
+ * from an external source and only slightly adapted, and keeping its original
+ * form will make integration of upstream changes easier. Secondly, it is very
+ * sensitive to floating point errors, and refactoring may break it in subtle
+ * and hard to detect ways.
+ * NOLINTNEXTLINE: readability-function-size */
static double incircleadapt(
const double *pa, const double *pb, const double *pc, const double *pd, double permanent)
{