| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,8 +12,8 @@ using namespace std; | |||
| 12 | 12 | ||
| 13 | 13 | extern "C" { | |
| 14 | 14 | ||
| 15 | - static void reorder_edges(int npoints, int ntriangles, | ||
| 16 | - double *x, double *y, | ||
| 15 | + static void reorder_edges(int npoints, int ntriangles, | ||
| 16 | + double *x, double *y, | ||
| 17 | 17 | int *edge_db, int *tri_edges, int *tri_nbrs) | |
| 18 | 18 | { | |
| 19 | 19 | int neighbors[3], nodes[3]; | |
@@ -69,7 +69,7 @@ static void reorder_edges(int npoints, int ntriangles, | |||
| 69 | 69 | ||
| 70 | 70 | // Not trusting me? Okay, let's go through it: | |
| 71 | 71 | // We have three edges to deal with and three nodes. Without loss | |
| 72 | - // of generality, let's label the nodes A, B, and C with (A, B) | ||
| 72 | + // of generality, let's label the nodes A, B, and C with (A, B) | ||
| 73 | 73 | // forming the first edge in the order they arrive on input. | |
| 74 | 74 | // Then there are eight possibilities as to how the other edge-tuples | |
| 75 | 75 | // may be labeled, but only two variations that are going to affect the | |
@@ -85,7 +85,7 @@ static void reorder_edges(int npoints, int ntriangles, | |||
| 85 | 85 | // The second test we need to perform is for counter-clockwiseness. | |
| 86 | 86 | // Again, there are only two variations that will affect the outcome: | |
| 87 | 87 | // either ABC is counter-clockwise, or it isn't. In the former case, | |
| 88 | - // we're done setting the node order, we just need to associate the | ||
| 88 | + // we're done setting the node order, we just need to associate the | ||
| 89 | 89 | // appropriate neighbor triangles with their opposite nodes, something | |
| 90 | 90 | // which can be done by inspection. In the latter case, to order the | |
| 91 | 91 | // nodes counter-clockwise, we only have to switch B and C to get | |
@@ -113,7 +113,7 @@ static void reorder_edges(int npoints, int ntriangles, | |||
| 113 | 113 | ||
| 114 | 114 | static PyObject* getMesh(int npoints, double *x, double *y) | |
| 115 | 115 | { | |
| 116 | - PyObject *vertices, *edge_db, *tri_edges, *tri_nbrs; | ||
| 116 | + PyObject *vertices = NULL, *edge_db = NULL, *tri_edges = NULL, *tri_nbrs = NULL; | ||
| 117 | 117 | PyObject *temp; | |
| 118 | 118 | int tri0, tri1, reg0, reg1; | |
| 119 | 119 | double tri0x, tri0y, tri1x, tri1y; | |
@@ -138,7 +138,7 @@ static PyObject* getMesh(int npoints, double *x, double *y) | |||
| 138 | 138 | edge_db = PyArray_SimpleNew(2, dim, PyArray_INT); | |
| 139 | 139 | if (!edge_db) goto fail; | |
| 140 | 140 | edge_db_ptr = (int*)PyArray_DATA(edge_db); | |
| 141 | - | ||
| 141 | + | ||
| 142 | 142 | dim[0] = numtri; | |
| 143 | 143 | vertices = PyArray_SimpleNew(2, dim, PyArray_DOUBLE); | |
| 144 | 144 | if (!vertices) goto fail; | |
@@ -192,7 +192,7 @@ static PyObject* getMesh(int npoints, double *x, double *y) | |||
| 192 | 192 | // tri_edges contains lists of edges; convert to lists of nodes in | |
| 193 | 193 | // counterclockwise order and reorder tri_nbrs to match. Each node | |
| 194 | 194 | // corresponds to the edge opposite it in the triangle. | |
| 195 | - reorder_edges(npoints, numtri, x, y, edge_db_ptr, tri_edges_ptr, | ||
| 195 | + reorder_edges(npoints, numtri, x, y, edge_db_ptr, tri_edges_ptr, | ||
| 196 | 196 | tri_nbrs_ptr); | |
| 197 | 197 | ||
| 198 | 198 | temp = Py_BuildValue("(OOOO)", vertices, edge_db, tri_edges, tri_nbrs); | |
@@ -221,7 +221,7 @@ static PyObject *linear_planes(int ntriangles, double *x, double *y, double *z, | |||
| 221 | 221 | int i; | |
| 222 | 222 | double *planes_ptr; | |
| 223 | 223 | double x02, y02, z02, x12, y12, z12, xy0212; | |
| 224 | - | ||
| 224 | + | ||
| 225 | 225 | dims[0] = ntriangles; | |
| 226 | 226 | dims[1] = 3; | |
| 227 | 227 | planes = PyArray_SimpleNew(2, dims, PyArray_DOUBLE); | |
@@ -240,40 +240,40 @@ static PyObject *linear_planes(int ntriangles, double *x, double *y, double *z, | |||
| 240 | 240 | xy0212 = y02/y12; | |
| 241 | 241 | INDEX3(planes_ptr,i,0) = (z02 - z12 * xy0212) / (x02 - x12 * xy0212); | |
| 242 | 242 | INDEX3(planes_ptr,i,1) = (z12 - INDEX3(planes_ptr,i,0)*x12) / y12; | |
| 243 | - INDEX3(planes_ptr,i,2) = (z[INDEX3(nodes,i,2)] - | ||
| 244 | - INDEX3(planes_ptr,i,0)*x[INDEX3(nodes,i,2)] - | ||
| 243 | + INDEX3(planes_ptr,i,2) = (z[INDEX3(nodes,i,2)] - | ||
| 244 | + INDEX3(planes_ptr,i,0)*x[INDEX3(nodes,i,2)] - | ||
| 245 | 245 | INDEX3(planes_ptr,i,1)*y[INDEX3(nodes,i,2)]); | |
| 246 | 246 | } else { | |
| 247 | 247 | xy0212 = x02/x12; | |
| 248 | 248 | INDEX3(planes_ptr,i,1) = (z02 - z12 * xy0212) / (y02 - y12 * xy0212); | |
| 249 | 249 | INDEX3(planes_ptr,i,0) = (z12 - INDEX3(planes_ptr,i,1)*y12) / x12; | |
| 250 | - INDEX3(planes_ptr,i,2) = (z[INDEX3(nodes,i,2)] - | ||
| 251 | - INDEX3(planes_ptr,i,0)*x[INDEX3(nodes,i,2)] - | ||
| 250 | + INDEX3(planes_ptr,i,2) = (z[INDEX3(nodes,i,2)] - | ||
| 251 | + INDEX3(planes_ptr,i,0)*x[INDEX3(nodes,i,2)] - | ||
| 252 | 252 | INDEX3(planes_ptr,i,1)*y[INDEX3(nodes,i,2)]); | |
| 253 | 253 | } | |
| 254 | 254 | } | |
| 255 | 255 | ||
| 256 | 256 | return (PyObject*)planes; | |
| 257 | 257 | } | |
| 258 | 258 | ||
| 259 | - static double linear_interpolate_single(double targetx, double targety, | ||
| 259 | + static double linear_interpolate_single(double targetx, double targety, | ||
| 260 | 260 | double *x, double *y, int *nodes, int *neighbors, | |
| 261 | 261 | PyObject *planes, double defvalue, int start_triangle, int *end_triangle) | |
| 262 | 262 | { | |
| 263 | 263 | double *planes_ptr; | |
| 264 | 264 | planes_ptr = (double*)PyArray_DATA(planes); | |
| 265 | 265 | if (start_triangle == -1) start_triangle = 0; | |
| 266 | - *end_triangle = walking_triangles(start_triangle, targetx, targety, | ||
| 266 | + *end_triangle = walking_triangles(start_triangle, targetx, targety, | ||
| 267 | 267 | x, y, nodes, neighbors); | |
| 268 | 268 | if (*end_triangle == -1) return defvalue; | |
| 269 | - return (targetx*INDEX3(planes_ptr,*end_triangle,0) + | ||
| 269 | + return (targetx*INDEX3(planes_ptr,*end_triangle,0) + | ||
| 270 | 270 | targety*INDEX3(planes_ptr,*end_triangle,1) + | |
| 271 | 271 | INDEX3(planes_ptr,*end_triangle,2)); | |
| 272 | 272 | } | |
| 273 | 273 | ||
| 274 | - static PyObject *linear_interpolate_grid(double x0, double x1, int xsteps, | ||
| 274 | + static PyObject *linear_interpolate_grid(double x0, double x1, int xsteps, | ||
| 275 | 275 | double y0, double y1, int ysteps, | |
| 276 | - PyObject *planes, double defvalue, | ||
| 276 | + PyObject *planes, double defvalue, | ||
| 277 | 277 | int npoints, double *x, double *y, int *nodes, int *neighbors) | |
| 278 | 278 | { | |
| 279 | 279 | int ix, iy; | |
@@ -312,7 +312,7 @@ static PyObject *linear_interpolate_grid(double x0, double x1, int xsteps, | |||
| 312 | 312 | static PyObject *compute_planes_method(PyObject *self, PyObject *args) | |
| 313 | 313 | { | |
| 314 | 314 | PyObject *pyx, *pyy, *pyz, *pynodes; | |
| 315 | - PyObject *x, *y, *z, *nodes; | ||
| 315 | + PyObject *x = NULL, *y = NULL, *z = NULL, *nodes = NULL; | ||
| 316 | 316 | int npoints, ntriangles; | |
| 317 | 317 | ||
| 318 | 318 | PyObject *planes; | |
@@ -351,7 +351,7 @@ static PyObject *compute_planes_method(PyObject *self, PyObject *args) | |||
| 351 | 351 | goto fail; | |
| 352 | 352 | } | |
| 353 | 353 | ||
| 354 | - planes = linear_planes(ntriangles, (double*)PyArray_DATA(x), | ||
| 354 | + planes = linear_planes(ntriangles, (double*)PyArray_DATA(x), | ||
| 355 | 355 | (double*)PyArray_DATA(y), (double*)PyArray_DATA(z), (int*)PyArray_DATA(nodes)); | |
| 356 | 356 | ||
| 357 | 357 | Py_DECREF(x); | |
@@ -374,7 +374,7 @@ static PyObject *linear_interpolate_method(PyObject *self, PyObject *args) | |||
| 374 | 374 | double x0, x1, y0, y1, defvalue; | |
| 375 | 375 | int xsteps, ysteps; | |
| 376 | 376 | PyObject *pyplanes, *pyx, *pyy, *pynodes, *pyneighbors, *grid; | |
| 377 | - PyObject *planes, *x, *y, *nodes, *neighbors; | ||
| 377 | + PyObject *planes = NULL, *x = NULL, *y = NULL, *nodes = NULL, *neighbors = NULL; | ||
| 378 | 378 | int npoints; | |
| 379 | 379 | ||
| 380 | 380 | ||
@@ -417,7 +417,7 @@ static PyObject *linear_interpolate_method(PyObject *self, PyObject *args) | |||
| 417 | 417 | (PyObject*)planes, defvalue, npoints, | |
| 418 | 418 | (double*)PyArray_DATA(x), (double*)PyArray_DATA(y), | |
| 419 | 419 | (int*)PyArray_DATA(nodes), (int*)PyArray_DATA(neighbors)); | |
| 420 | - | ||
| 420 | + | ||
| 421 | 421 | Py_DECREF(x); | |
| 422 | 422 | Py_DECREF(y); | |
| 423 | 423 | Py_DECREF(planes); | |
@@ -455,7 +455,7 @@ static PyObject *nn_interpolate_unstructured_method(PyObject *self, PyObject *ar | |||
| 455 | 455 | { | |
| 456 | 456 | PyObject *pyx, *pyy, *pyz, *pycenters, *pynodes, *pyneighbors, *pyintx, *pyinty; | |
| 457 | 457 | PyObject *x = NULL, *y = NULL, *z = NULL, *centers = NULL, *nodes = NULL, | |
| 458 | - *neighbors = NULL, *intx = NULL, *inty = NULL, *intz; | ||
| 458 | + *neighbors = NULL, *intx = NULL, *inty = NULL, *intz = NULL; | ||
| 459 | 459 | double defvalue; | |
| 460 | 460 | int size, npoints, ntriangles; | |
| 461 | 461 | ||
@@ -506,7 +506,7 @@ static PyObject *nn_interpolate_unstructured_method(PyObject *self, PyObject *ar | |||
| 506 | 506 | return NULL; | |
| 507 | 507 | } | |
| 508 | 508 | ntriangles = PyArray_DIM(neighbors, 0); | |
| 509 | - if ((PyArray_DIM(nodes, 0) != ntriangles) || | ||
| 509 | + if ((PyArray_DIM(nodes, 0) != ntriangles) || | ||
| 510 | 510 | (PyArray_DIM(centers, 0) != ntriangles)) { | |
| 511 | 511 | PyErr_SetString(PyExc_ValueError, "centers,nodes,neighbors must be of equal length"); | |
| 512 | 512 | CLEANUP | |
@@ -542,13 +542,13 @@ static PyObject *nn_interpolate_unstructured_method(PyObject *self, PyObject *ar | |||
| 542 | 542 | return NULL; | |
| 543 | 543 | } | |
| 544 | 544 | ||
| 545 | - NaturalNeighbors nn(npoints, ntriangles, | ||
| 545 | + NaturalNeighbors nn(npoints, ntriangles, | ||
| 546 | 546 | (double*)PyArray_DATA(x), (double*)PyArray_DATA(y), | |
| 547 | - (double*)PyArray_DATA(centers), (int*)PyArray_DATA(nodes), | ||
| 547 | + (double*)PyArray_DATA(centers), (int*)PyArray_DATA(nodes), | ||
| 548 | 548 | (int*)PyArray_DATA(neighbors)); | |
| 549 | 549 | size = PyArray_Size(intx); | |
| 550 | - nn.interpolate_unstructured((double*)PyArray_DATA(z), size, | ||
| 551 | - (double*)PyArray_DATA(intx), (double*)PyArray_DATA(inty), | ||
| 550 | + nn.interpolate_unstructured((double*)PyArray_DATA(z), size, | ||
| 551 | + (double*)PyArray_DATA(intx), (double*)PyArray_DATA(inty), | ||
| 552 | 552 | (double*)PyArray_DATA(intz), defvalue); | |
| 553 | 553 | ||
| 554 | 554 | Py_XDECREF(x); | |
@@ -575,13 +575,13 @@ static PyObject *nn_interpolate_unstructured_method(PyObject *self, PyObject *ar | |||
| 575 | 575 | static PyObject *nn_interpolate_method(PyObject *self, PyObject *args) | |
| 576 | 576 | { | |
| 577 | 577 | PyObject *pyx, *pyy, *pyz, *pycenters, *pynodes, *pyneighbors, *grid; | |
| 578 | - PyObject *x, *y, *z, *centers, *nodes, *neighbors; | ||
| 578 | + PyObject *x = NULL, *y = NULL, *z = NULL, *centers = NULL, *nodes = NULL, *neighbors = NULL; | ||
| 579 | 579 | double x0, x1, y0, y1, defvalue; | |
| 580 | 580 | int xsteps, ysteps; | |
| 581 | 581 | int npoints, ntriangles; | |
| 582 | 582 | intp dims[2]; | |
| 583 | 583 | ||
| 584 | - if (!PyArg_ParseTuple(args, "ddiddidOOOOOO", &x0, &x1, &xsteps, | ||
| 584 | + if (!PyArg_ParseTuple(args, "ddiddidOOOOOO", &x0, &x1, &xsteps, | ||
| 585 | 585 | &y0, &y1, &ysteps, &defvalue, &pyx, &pyy, &pyz, &pycenters, &pynodes, | |
| 586 | 586 | &pyneighbors)) { | |
| 587 | 587 | return NULL; | |
@@ -629,7 +629,7 @@ static PyObject *nn_interpolate_method(PyObject *self, PyObject *args) | |||
| 629 | 629 | return NULL; | |
| 630 | 630 | } | |
| 631 | 631 | ntriangles = PyArray_DIM(neighbors, 0); | |
| 632 | - if ((PyArray_DIM(nodes, 0) != ntriangles) || | ||
| 632 | + if ((PyArray_DIM(nodes, 0) != ntriangles) || | ||
| 633 | 633 | (PyArray_DIM(centers, 0) != ntriangles)) { | |
| 634 | 634 | PyErr_SetString(PyExc_ValueError, "centers,nodes,neighbors must be of equal length"); | |
| 635 | 635 | CLEANUP | |
@@ -644,11 +644,11 @@ static PyObject *nn_interpolate_method(PyObject *self, PyObject *args) | |||
| 644 | 644 | return NULL; | |
| 645 | 645 | } | |
| 646 | 646 | ||
| 647 | - NaturalNeighbors nn(npoints, ntriangles, | ||
| 647 | + NaturalNeighbors nn(npoints, ntriangles, | ||
| 648 | 648 | (double*)PyArray_DATA(x), (double*)PyArray_DATA(y), | |
| 649 | - (double*)PyArray_DATA(centers), (int*)PyArray_DATA(nodes), | ||
| 649 | + (double*)PyArray_DATA(centers), (int*)PyArray_DATA(nodes), | ||
| 650 | 650 | (int*)PyArray_DATA(neighbors)); | |
| 651 | - nn.interpolate_grid((double*)PyArray_DATA(z), | ||
| 651 | + nn.interpolate_grid((double*)PyArray_DATA(z), | ||
| 652 | 652 | x0, x1, xsteps, | |
| 653 | 653 | y0, y1, ysteps, | |
| 654 | 654 | (double*)PyArray_DATA(grid), | |
@@ -664,7 +664,7 @@ static PyObject *nn_interpolate_method(PyObject *self, PyObject *args) | |||
| 664 | 664 | static PyObject *delaunay_method(PyObject *self, PyObject *args) | |
| 665 | 665 | { | |
| 666 | 666 | PyObject *pyx, *pyy, *mesh; | |
| 667 | - PyObject *x, *y; | ||
| 667 | + PyObject *x = NULL, *y = NULL; | ||
| 668 | 668 | int npoints; | |
| 669 | 669 | ||
| 670 | 670 | if (!PyArg_ParseTuple(args, "OO", &pyx, &pyy)) { | |
@@ -703,7 +703,7 @@ static PyObject *delaunay_method(PyObject *self, PyObject *args) | |||
| 703 | 703 | } | |
| 704 | 704 | ||
| 705 | 705 | static PyMethodDef delaunay_methods[] = { | |
| 706 | - {"delaunay", (PyCFunction)delaunay_method, METH_VARARGS, | ||
| 706 | + {"delaunay", (PyCFunction)delaunay_method, METH_VARARGS, | ||
| 707 | 707 | "Compute the Delaunay triangulation of a cloud of 2-D points.\n\n" | |
| 708 | 708 | "circumcenters, edges, tri_points, tri_neighbors = delaunay(x, y)\n\n" | |
| 709 | 709 | "x, y -- shape-(npoints,) arrays of floats giving the X and Y coordinates of the points\n" | |
@@ -730,7 +730,7 @@ static PyMethodDef delaunay_methods[] = { | |||
| 730 | 730 | PyMODINIT_FUNC init_delaunay(void) | |
| 731 | 731 | { | |
| 732 | 732 | PyObject* m; | |
| 733 | - m = Py_InitModule3("_delaunay", delaunay_methods, | ||
| 733 | + m = Py_InitModule3("_delaunay", delaunay_methods, | ||
| 734 | 734 | "Tools for computing the Delaunay triangulation and some operations on it.\n" | |
| 735 | 735 | ); | |
| 736 | 736 | if (m == NULL) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -990,7 +990,8 @@ void | |||
| 990 | 990 | #endif | |
| 991 | 991 | init_tri() | |
| 992 | 992 | { | |
| 993 | - static TriModule* triModule = new TriModule; | ||
| 993 | + static TriModule* triModule = NULL; | ||
| 994 | + triModule = new TriModule(); | ||
| 994 | 995 | import_array(); | |
| 995 | 996 | } | |
| 996 | 997 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -818,7 +818,7 @@ void clip_to_rect(PathIterator& path, | |||
| 818 | 818 | } | |
| 819 | 819 | ||
| 820 | 820 | Polygon polygon1, polygon2; | |
| 821 | - double x, y; | ||
| 821 | + double x = 0, y = 0; | ||
| 822 | 822 | unsigned code = 0; | |
| 823 | 823 | path.rewind(0); | |
| 824 | 824 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -607,8 +607,8 @@ edge_walker (Csite * site, int pass2) | |||
| 607 | 607 | } | |
| 608 | 608 | if (fwd < 0 && level0 && left < 0) | |
| 609 | 609 | { | |
| 610 | - /* remove J0_START from this boundary edge as boundary is | ||
| 611 | - * included by the upwards slit from contour line below. */ | ||
| 610 | + /* remove J0_START from this boundary edge as boundary is | ||
| 611 | + * included by the upwards slit from contour line below. */ | ||
| 612 | 612 | data[edge] &= ~J0_START; | |
| 613 | 613 | if (n_kind) kcp[n_kind] += kind_start_slit; | |
| 614 | 614 | return slit_cutter (site, 0, pass2); | |
@@ -1479,8 +1479,8 @@ build_cntr_list_v2(long *np, double *xp, double *yp, short *kp, | |||
| 1479 | 1479 | int nparts, long ntotal) | |
| 1480 | 1480 | { | |
| 1481 | 1481 | PyObject *all_contours; | |
| 1482 | - PyArrayObject *xyv; | ||
| 1483 | - PyArrayObject *kv; | ||
| 1482 | + PyArrayObject *xyv = NULL; | ||
| 1483 | + PyArrayObject *kv = NULL; | ||
| 1484 | 1484 | npy_intp dims[2]; | |
| 1485 | 1485 | npy_intp kdims[1]; | |
| 1486 | 1486 | int i; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -233,9 +233,9 @@ class PathNanRemover : protected EmbeddedQueue<4> { | |||
| 233 | 233 | } while (MPL_notisfinite64(*x) || MPL_notisfinite64(*y)); | |
| 234 | 234 | return agg::path_cmd_move_to; | |
| 235 | 235 | } | |
| 236 | - } | ||
| 237 | 236 | ||
| 238 | - return code; | ||
| 237 | + return code; | ||
| 238 | + } | ||
| 239 | 239 | } | |
| 240 | 240 | }; | |
| 241 | 241 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments