Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 73f1c80

Browse files
committed
svn path=/trunk/matplotlib/; revision=2756
1 parent 212b514 commit 73f1c80

1 file changed

Lines changed: 12 additions & 16 deletions

File tree

src/nxutils.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ points_inside_poly(PyObject *self, PyObject *args)
109109
PyArrayObject *xypoints, *verts;
110110
PyArrayObject *mask;
111111
int dimensions[1];
112-
112+
113113
if (! PyArg_ParseTuple(args, "OO", &xypointsarg, &vertsarg))
114114
return NULL;
115115

@@ -157,7 +157,7 @@ points_inside_poly(PyObject *self, PyObject *args)
157157
yv[i] = *(double *)(verts->data + i*verts->strides[0] + verts->strides[1]);
158158
//printf("adding vert: %1.3f, %1.3f\n", xv[i], yv[i]);
159159
}
160-
160+
161161
xypoints = (PyArrayObject *) PyArray_FromObject(xypointsarg,PyArray_DOUBLE, 2, 2);
162162

163163
if (xypoints == NULL)
@@ -186,47 +186,43 @@ points_inside_poly(PyObject *self, PyObject *args)
186186

187187
npoints = xypoints->dimensions[0];
188188
dimensions[0] = npoints;
189-
189+
190190
mask = (PyArrayObject *)PyArray_FromDims(1,dimensions,PyArray_INT);
191191
if (mask==NULL) {
192-
Py_XDECREF(verts);
193-
Py_XDECREF(xypoints);
194-
PyMem_Free(xv);
195-
PyMem_Free(yv);
196-
return NULL; }
197-
192+
Py_XDECREF(verts);
193+
Py_XDECREF(xypoints);
194+
PyMem_Free(xv);
195+
PyMem_Free(yv);
196+
return NULL; }
197+
198198
for (i=0; i<npoints; ++i) {
199199
x = *(double *)(xypoints->data + i*xypoints->strides[0]);
200200
y = *(double *)(xypoints->data + i*xypoints->strides[0] + xypoints->strides[1]);
201201
b = pnpoly_api(npol, xv, yv, x, y);
202202
//printf("checking %d, %d, %1.3f, %1.3f, %d\n", npol, npoints, x, y, b);
203203
*(int *)(mask->data+i*mask->strides[0]) = b;
204-
204+
205205
}
206206

207207

208208
Py_XDECREF(verts);
209209
Py_XDECREF(xypoints);
210-
210+
211211
PyMem_Free(xv);
212212
PyMem_Free(yv);
213213
PyObject* ret = Py_BuildValue("O", mask);
214214
Py_XDECREF(mask);
215215
return ret;
216-
216+
217217

218218
}
219219

220-
221-
222-
223220
static PyMethodDef module_methods[] = {
224221
{"pnpoly", pnpoly, METH_VARARGS, "inside = pnpoly(x, y, xyverts)\nreturn 1 if x,y is inside the polygon defined by the sequence of x,y vertices in xyverts"},
225222
{"points_inside_poly", points_inside_poly, METH_VARARGS, "mask = points_inside_poly(xypoints, xyverts)\nreturn a mask of length xypoints indicating whether each x,y point is inside the polygon defined by the sequence of x,y vertices in xyverts"},
226223
{NULL} /* Sentinel */
227224
}
228225

229-
230226
#ifdef NUMARRAY
231227
#if PY_MINOR_VERSION > 2
232228
PyMODINIT_FUNC

0 commit comments

Comments
 (0)