Cython: polygon_ext.pyx

Generated by Cython 0.29.28

Yellow lines hint at Python interaction.
Click on a line that starts with a "`+`" to see the C code that Cython generated for it.

Raw output: polygon_ext.c

    +01: #cython: wraparound=False, boundscheck=False, cdivision=True, profile=False, nonecheck=False, overflowcheck=False, cdivision_warnings=False, unraisable_tracebacks=False

      __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     02: import cython

     03:

     04: # import both numpy and the Cython declarations for numpy

    +05: import numpy as np

      __pyx_t_1 = __Pyx_Import(__pyx_n_s_numpy, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_np, __pyx_t_1) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     06: cimport numpy as np

     07:

     08: # declare the interface to the C code

     09: cdef extern from "polygon.c":

     10:     int __point_on_line(double x, double y, double x0, double y0, double x1, double y1, double rtol, double atol)

     11:     int __interpolate_polyline(int number_of_nodes, int number_of_points, double* data, double* polyline_nodes, long* gauge_neighbour_id, double* interpolation_points, double* interpolated_values, double rtol, double atol)

     12:     int __polygon_overlap(double* polygon, double* triangles, long* indices, int M, int polygon_number_of_vertices)

     13:     int __line_intersect(double* line, double* triangles, long* indices, int M)

     14:     int __is_inside_triangle(double* point, double* triangle, int closed, double rtol, double atol)

     15:     int __separate_points_by_polygon(int M, int N, double* points, double* polygon, long* indices, int closed, int verbose)

     16:

    +17: def _point_on_line(double x,\

    /* Python wrapper */
    static PyObject *__pyx_pw_5anuga_8geometry_11polygon_ext_1_point_on_line(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_5anuga_8geometry_11polygon_ext_1_point_on_line = {"_point_on_line", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5anuga_8geometry_11polygon_ext_1_point_on_line, METH_VARARGS|METH_KEYWORDS, 0};
    static PyObject *__pyx_pw_5anuga_8geometry_11polygon_ext_1_point_on_line(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      double __pyx_v_x;
      double __pyx_v_y;
      double __pyx_v_x0;
      double __pyx_v_y0;
      double __pyx_v_x1;
      double __pyx_v_y1;
      double __pyx_v_rtol;
      double __pyx_v_atol;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_point_on_line (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_x,&__pyx_n_s_y,&__pyx_n_s_x0,&__pyx_n_s_y0,&__pyx_n_s_x1,&__pyx_n_s_y1,&__pyx_n_s_rtol,&__pyx_n_s_atol,0};
        PyObject* values[8] = {0,0,0,0,0,0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
            CYTHON_FALLTHROUGH;
            case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
            CYTHON_FALLTHROUGH;
            case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
            CYTHON_FALLTHROUGH;
            case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
            CYTHON_FALLTHROUGH;
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            CYTHON_FALLTHROUGH;
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            CYTHON_FALLTHROUGH;
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            CYTHON_FALLTHROUGH;
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            CYTHON_FALLTHROUGH;
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            CYTHON_FALLTHROUGH;
            case  1:
            if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_point_on_line", 1, 8, 8, 1); __PYX_ERR(0, 17, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  2:
            if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x0)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_point_on_line", 1, 8, 8, 2); __PYX_ERR(0, 17, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  3:
            if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y0)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_point_on_line", 1, 8, 8, 3); __PYX_ERR(0, 17, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  4:
            if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_x1)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_point_on_line", 1, 8, 8, 4); __PYX_ERR(0, 17, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  5:
            if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_y1)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_point_on_line", 1, 8, 8, 5); __PYX_ERR(0, 17, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  6:
            if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rtol)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_point_on_line", 1, 8, 8, 6); __PYX_ERR(0, 17, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  7:
            if (likely((values[7] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_atol)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_point_on_line", 1, 8, 8, 7); __PYX_ERR(0, 17, __pyx_L3_error)
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_point_on_line") < 0)) __PYX_ERR(0, 17, __pyx_L3_error)
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 8) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
          values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
          values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
          values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
          values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
          values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
        }
        __pyx_v_x = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_x == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 17, __pyx_L3_error)
        __pyx_v_y = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_y == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 18, __pyx_L3_error)
        __pyx_v_x0 = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_x0 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 19, __pyx_L3_error)
        __pyx_v_y0 = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_y0 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 20, __pyx_L3_error)
        __pyx_v_x1 = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_x1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 21, __pyx_L3_error)
        __pyx_v_y1 = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_y1 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 22, __pyx_L3_error)
        __pyx_v_rtol = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_rtol == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 23, __pyx_L3_error)
        __pyx_v_atol = __pyx_PyFloat_AsDouble(values[7]); if (unlikely((__pyx_v_atol == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 24, __pyx_L3_error)
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("_point_on_line", 1, 8, 8, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 17, __pyx_L3_error)
      __pyx_L3_error:;
      __Pyx_AddTraceback("anuga.geometry.polygon_ext._point_on_line", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      __pyx_r = __pyx_pf_5anuga_8geometry_11polygon_ext__point_on_line(__pyx_self, __pyx_v_x, __pyx_v_y, __pyx_v_x0, __pyx_v_y0, __pyx_v_x1, __pyx_v_y1, __pyx_v_rtol, __pyx_v_atol);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_5anuga_8geometry_11polygon_ext__point_on_line(CYTHON_UNUSED PyObject *__pyx_self, double __pyx_v_x, double __pyx_v_y, double __pyx_v_x0, double __pyx_v_y0, double __pyx_v_x1, double __pyx_v_y1, double __pyx_v_rtol, double __pyx_v_atol) {
      int __pyx_v_res;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_point_on_line", 0);
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_1);
      __Pyx_AddTraceback("anuga.geometry.polygon_ext._point_on_line", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__3 = PyTuple_Pack(9, __pyx_n_s_x, __pyx_n_s_y, __pyx_n_s_x0, __pyx_n_s_y0, __pyx_n_s_x1, __pyx_n_s_y1, __pyx_n_s_rtol, __pyx_n_s_atol, __pyx_n_s_res); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 17, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__3);
      __Pyx_GIVEREF(__pyx_tuple__3);
    /* … */
      __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5anuga_8geometry_11polygon_ext_1_point_on_line, NULL, __pyx_n_s_anuga_geometry_polygon_ext); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_point_on_line, __pyx_t_1) < 0) __PYX_ERR(0, 17, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(8, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_anuga_geometry_polygon_ext_pyx, __pyx_n_s_point_on_line, 17, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 17, __pyx_L1_error)

     18:                     double y,\

     19:                     double x0,\

     20:                     double y0,\

     21:                     double x1,\

     22:                     double y1,\

     23:                     double rtol,\

     24:                     double atol):

     25:

     26:     cdef int res

    +27:     res = __point_on_line(x, y, x0, y0, x1, y1, rtol, atol)

      __pyx_v_res = __point_on_line(__pyx_v_x, __pyx_v_y, __pyx_v_x0, __pyx_v_y0, __pyx_v_x1, __pyx_v_y1, __pyx_v_rtol, __pyx_v_atol);

    +28:     return res

      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_res); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_r = __pyx_t_1;
      __pyx_t_1 = 0;
      goto __pyx_L0;

     29:

    +30: def _interpolate_polyline(np.ndarray[double, ndim=1, mode="c"] data not None,\

    /* Python wrapper */
    static PyObject *__pyx_pw_5anuga_8geometry_11polygon_ext_3_interpolate_polyline(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_5anuga_8geometry_11polygon_ext_3_interpolate_polyline = {"_interpolate_polyline", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5anuga_8geometry_11polygon_ext_3_interpolate_polyline, METH_VARARGS|METH_KEYWORDS, 0};
    static PyObject *__pyx_pw_5anuga_8geometry_11polygon_ext_3_interpolate_polyline(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_data = 0;
      PyArrayObject *__pyx_v_polyline_nodes = 0;
      PyArrayObject *__pyx_v_gauge_neighbour_id = 0;
      PyArrayObject *__pyx_v_interpolation_points = 0;
      PyArrayObject *__pyx_v_interpolated_values = 0;
      double __pyx_v_rtol;
      double __pyx_v_atol;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_interpolate_polyline (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_data,&__pyx_n_s_polyline_nodes,&__pyx_n_s_gauge_neighbour_id,&__pyx_n_s_interpolation_points,&__pyx_n_s_interpolated_values,&__pyx_n_s_rtol,&__pyx_n_s_atol,0};
        PyObject* values[7] = {0,0,0,0,0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
            CYTHON_FALLTHROUGH;
            case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
            CYTHON_FALLTHROUGH;
            case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
            CYTHON_FALLTHROUGH;
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            CYTHON_FALLTHROUGH;
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            CYTHON_FALLTHROUGH;
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            CYTHON_FALLTHROUGH;
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            CYTHON_FALLTHROUGH;
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            CYTHON_FALLTHROUGH;
            case  1:
            if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_polyline_nodes)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_interpolate_polyline", 1, 7, 7, 1); __PYX_ERR(0, 30, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  2:
            if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_gauge_neighbour_id)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_interpolate_polyline", 1, 7, 7, 2); __PYX_ERR(0, 30, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  3:
            if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_interpolation_points)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_interpolate_polyline", 1, 7, 7, 3); __PYX_ERR(0, 30, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  4:
            if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_interpolated_values)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_interpolate_polyline", 1, 7, 7, 4); __PYX_ERR(0, 30, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  5:
            if (likely((values[5] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rtol)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_interpolate_polyline", 1, 7, 7, 5); __PYX_ERR(0, 30, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  6:
            if (likely((values[6] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_atol)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_interpolate_polyline", 1, 7, 7, 6); __PYX_ERR(0, 30, __pyx_L3_error)
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_interpolate_polyline") < 0)) __PYX_ERR(0, 30, __pyx_L3_error)
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 7) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
          values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
          values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
          values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
          values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
        }
        __pyx_v_data = ((PyArrayObject *)values[0]);
        __pyx_v_polyline_nodes = ((PyArrayObject *)values[1]);
        __pyx_v_gauge_neighbour_id = ((PyArrayObject *)values[2]);
        __pyx_v_interpolation_points = ((PyArrayObject *)values[3]);
        __pyx_v_interpolated_values = ((PyArrayObject *)values[4]);
        __pyx_v_rtol = __pyx_PyFloat_AsDouble(values[5]); if (unlikely((__pyx_v_rtol == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 35, __pyx_L3_error)
        __pyx_v_atol = __pyx_PyFloat_AsDouble(values[6]); if (unlikely((__pyx_v_atol == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 36, __pyx_L3_error)
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("_interpolate_polyline", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 30, __pyx_L3_error)
      __pyx_L3_error:;
      __Pyx_AddTraceback("anuga.geometry.polygon_ext._interpolate_polyline", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_data), __pyx_ptype_5numpy_ndarray, 0, "data", 0))) __PYX_ERR(0, 30, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_polyline_nodes), __pyx_ptype_5numpy_ndarray, 0, "polyline_nodes", 0))) __PYX_ERR(0, 31, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_gauge_neighbour_id), __pyx_ptype_5numpy_ndarray, 0, "gauge_neighbour_id", 0))) __PYX_ERR(0, 32, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_interpolation_points), __pyx_ptype_5numpy_ndarray, 0, "interpolation_points", 0))) __PYX_ERR(0, 33, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_interpolated_values), __pyx_ptype_5numpy_ndarray, 0, "interpolated_values", 0))) __PYX_ERR(0, 34, __pyx_L1_error)
      __pyx_r = __pyx_pf_5anuga_8geometry_11polygon_ext_2_interpolate_polyline(__pyx_self, __pyx_v_data, __pyx_v_polyline_nodes, __pyx_v_gauge_neighbour_id, __pyx_v_interpolation_points, __pyx_v_interpolated_values, __pyx_v_rtol, __pyx_v_atol);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_5anuga_8geometry_11polygon_ext_2_interpolate_polyline(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_data, PyArrayObject *__pyx_v_polyline_nodes, PyArrayObject *__pyx_v_gauge_neighbour_id, PyArrayObject *__pyx_v_interpolation_points, PyArrayObject *__pyx_v_interpolated_values, double __pyx_v_rtol, double __pyx_v_atol) {
      int __pyx_v_number_of_nodes;
      int __pyx_v_number_of_points;
      CYTHON_UNUSED int __pyx_v_res;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_data;
      __Pyx_Buffer __pyx_pybuffer_data;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_gauge_neighbour_id;
      __Pyx_Buffer __pyx_pybuffer_gauge_neighbour_id;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_interpolated_values;
      __Pyx_Buffer __pyx_pybuffer_interpolated_values;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_interpolation_points;
      __Pyx_Buffer __pyx_pybuffer_interpolation_points;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_polyline_nodes;
      __Pyx_Buffer __pyx_pybuffer_polyline_nodes;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_interpolate_polyline", 0);
      __pyx_pybuffer_data.pybuffer.buf = NULL;
      __pyx_pybuffer_data.refcount = 0;
      __pyx_pybuffernd_data.data = NULL;
      __pyx_pybuffernd_data.rcbuffer = &__pyx_pybuffer_data;
      __pyx_pybuffer_polyline_nodes.pybuffer.buf = NULL;
      __pyx_pybuffer_polyline_nodes.refcount = 0;
      __pyx_pybuffernd_polyline_nodes.data = NULL;
      __pyx_pybuffernd_polyline_nodes.rcbuffer = &__pyx_pybuffer_polyline_nodes;
      __pyx_pybuffer_gauge_neighbour_id.pybuffer.buf = NULL;
      __pyx_pybuffer_gauge_neighbour_id.refcount = 0;
      __pyx_pybuffernd_gauge_neighbour_id.data = NULL;
      __pyx_pybuffernd_gauge_neighbour_id.rcbuffer = &__pyx_pybuffer_gauge_neighbour_id;
      __pyx_pybuffer_interpolation_points.pybuffer.buf = NULL;
      __pyx_pybuffer_interpolation_points.refcount = 0;
      __pyx_pybuffernd_interpolation_points.data = NULL;
      __pyx_pybuffernd_interpolation_points.rcbuffer = &__pyx_pybuffer_interpolation_points;
      __pyx_pybuffer_interpolated_values.pybuffer.buf = NULL;
      __pyx_pybuffer_interpolated_values.refcount = 0;
      __pyx_pybuffernd_interpolated_values.data = NULL;
      __pyx_pybuffernd_interpolated_values.rcbuffer = &__pyx_pybuffer_interpolated_values;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_data.rcbuffer->pybuffer, (PyObject*)__pyx_v_data, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 30, __pyx_L1_error)
      }
      __pyx_pybuffernd_data.diminfo[0].strides = __pyx_pybuffernd_data.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_data.diminfo[0].shape = __pyx_pybuffernd_data.rcbuffer->pybuffer.shape[0];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_polyline_nodes.rcbuffer->pybuffer, (PyObject*)__pyx_v_polyline_nodes, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 30, __pyx_L1_error)
      }
      __pyx_pybuffernd_polyline_nodes.diminfo[0].strides = __pyx_pybuffernd_polyline_nodes.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_polyline_nodes.diminfo[0].shape = __pyx_pybuffernd_polyline_nodes.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_polyline_nodes.diminfo[1].strides = __pyx_pybuffernd_polyline_nodes.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_polyline_nodes.diminfo[1].shape = __pyx_pybuffernd_polyline_nodes.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_gauge_neighbour_id.rcbuffer->pybuffer, (PyObject*)__pyx_v_gauge_neighbour_id, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 30, __pyx_L1_error)
      }
      __pyx_pybuffernd_gauge_neighbour_id.diminfo[0].strides = __pyx_pybuffernd_gauge_neighbour_id.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_gauge_neighbour_id.diminfo[0].shape = __pyx_pybuffernd_gauge_neighbour_id.rcbuffer->pybuffer.shape[0];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_interpolation_points.rcbuffer->pybuffer, (PyObject*)__pyx_v_interpolation_points, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 30, __pyx_L1_error)
      }
      __pyx_pybuffernd_interpolation_points.diminfo[0].strides = __pyx_pybuffernd_interpolation_points.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_interpolation_points.diminfo[0].shape = __pyx_pybuffernd_interpolation_points.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_interpolation_points.diminfo[1].strides = __pyx_pybuffernd_interpolation_points.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_interpolation_points.diminfo[1].shape = __pyx_pybuffernd_interpolation_points.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_interpolated_values.rcbuffer->pybuffer, (PyObject*)__pyx_v_interpolated_values, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 30, __pyx_L1_error)
      }
      __pyx_pybuffernd_interpolated_values.diminfo[0].strides = __pyx_pybuffernd_interpolated_values.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_interpolated_values.diminfo[0].shape = __pyx_pybuffernd_interpolated_values.rcbuffer->pybuffer.shape[0];
    /* … */
      /* function exit code */
      __pyx_r = Py_None; __Pyx_INCREF(Py_None);
      goto __pyx_L0;
      __pyx_L1_error:;
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_gauge_neighbour_id.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_interpolated_values.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_interpolation_points.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_polyline_nodes.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("anuga.geometry.polygon_ext._interpolate_polyline", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_data.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_gauge_neighbour_id.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_interpolated_values.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_interpolation_points.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_polyline_nodes.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__5 = PyTuple_Pack(10, __pyx_n_s_data, __pyx_n_s_polyline_nodes, __pyx_n_s_gauge_neighbour_id, __pyx_n_s_interpolation_points, __pyx_n_s_interpolated_values, __pyx_n_s_rtol, __pyx_n_s_atol, __pyx_n_s_number_of_nodes, __pyx_n_s_number_of_points, __pyx_n_s_res); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 30, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__5);
      __Pyx_GIVEREF(__pyx_tuple__5);
    /* … */
      __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5anuga_8geometry_11polygon_ext_3_interpolate_polyline, NULL, __pyx_n_s_anuga_geometry_polygon_ext); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_interpolate_polyline, __pyx_t_1) < 0) __PYX_ERR(0, 30, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(7, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_anuga_geometry_polygon_ext_pyx, __pyx_n_s_interpolate_polyline, 30, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 30, __pyx_L1_error)

     31:                         np.ndarray[double, ndim=2, mode="c"] polyline_nodes not None,\

     32:                         np.ndarray[long, ndim=1, mode="c"] gauge_neighbour_id not None,\

     33:                         np.ndarray[double, ndim=2, mode="c"] interpolation_points not None,\

     34:                         np.ndarray[double, ndim=1, mode="c"] interpolated_values not None,\

     35:                         double rtol,\

     36:                         double atol):

     37:

     38:     cdef int number_of_nodes, number_of_points, res

     39:

    +40:     number_of_nodes = polyline_nodes.shape[0]

      __pyx_v_number_of_nodes = (__pyx_v_polyline_nodes->dimensions[0]);

    +41:     number_of_points = interpolation_points.shape[0]

      __pyx_v_number_of_points = (__pyx_v_interpolation_points->dimensions[0]);

     42:

    +43:     res = __interpolate_polyline(number_of_nodes,\

      __pyx_v_res = __interpolate_polyline(__pyx_v_number_of_nodes, __pyx_v_number_of_points, (&(*__Pyx_BufPtrCContig1d(double *, __pyx_pybuffernd_data.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_data.diminfo[0].strides))), (&(*__Pyx_BufPtrCContig2d(double *, __pyx_pybuffernd_polyline_nodes.rcbuffer->pybuffer.buf, __pyx_t_2, __pyx_pybuffernd_polyline_nodes.diminfo[0].strides, __pyx_t_3, __pyx_pybuffernd_polyline_nodes.diminfo[1].strides))), (&(*__Pyx_BufPtrCContig1d(long *, __pyx_pybuffernd_gauge_neighbour_id.rcbuffer->pybuffer.buf, __pyx_t_4, __pyx_pybuffernd_gauge_neighbour_id.diminfo[0].strides))), (&(*__Pyx_BufPtrCContig2d(double *, __pyx_pybuffernd_interpolation_points.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_interpolation_points.diminfo[0].strides, __pyx_t_6, __pyx_pybuffernd_interpolation_points.diminfo[1].strides))), (&(*__Pyx_BufPtrCContig1d(double *, __pyx_pybuffernd_interpolated_values.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_interpolated_values.diminfo[0].strides))), __pyx_v_rtol, __pyx_v_atol);

     44:                                 number_of_points,\

    +45:                                 &data[0],\

      __pyx_t_1 = 0;

    +46:                                 &polyline_nodes[0,0],\

      __pyx_t_2 = 0;
      __pyx_t_3 = 0;

    +47:                                 &gauge_neighbour_id[0],\

      __pyx_t_4 = 0;

    +48:                                 &interpolation_points[0,0],\

      __pyx_t_5 = 0;
      __pyx_t_6 = 0;

    +49:                                 &interpolated_values[0],\

      __pyx_t_7 = 0;

     50:                                 rtol,\

     51:                                 atol)

     52:

    +53: def _polygon_overlap(np.ndarray[double, ndim=2, mode="c"] polygon not None, np.ndarray[double, ndim=2, mode="c"] triangles not None, np.ndarray[long, ndim=1, mode="c"] indices not None):

    /* Python wrapper */
    static PyObject *__pyx_pw_5anuga_8geometry_11polygon_ext_5_polygon_overlap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_5anuga_8geometry_11polygon_ext_5_polygon_overlap = {"_polygon_overlap", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5anuga_8geometry_11polygon_ext_5_polygon_overlap, METH_VARARGS|METH_KEYWORDS, 0};
    static PyObject *__pyx_pw_5anuga_8geometry_11polygon_ext_5_polygon_overlap(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_polygon = 0;
      PyArrayObject *__pyx_v_triangles = 0;
      PyArrayObject *__pyx_v_indices = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_polygon_overlap (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_polygon,&__pyx_n_s_triangles,&__pyx_n_s_indices,0};
        PyObject* values[3] = {0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            CYTHON_FALLTHROUGH;
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            CYTHON_FALLTHROUGH;
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            CYTHON_FALLTHROUGH;
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_polygon)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            CYTHON_FALLTHROUGH;
            case  1:
            if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_triangles)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_polygon_overlap", 1, 3, 3, 1); __PYX_ERR(0, 53, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  2:
            if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_indices)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_polygon_overlap", 1, 3, 3, 2); __PYX_ERR(0, 53, __pyx_L3_error)
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_polygon_overlap") < 0)) __PYX_ERR(0, 53, __pyx_L3_error)
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        }
        __pyx_v_polygon = ((PyArrayObject *)values[0]);
        __pyx_v_triangles = ((PyArrayObject *)values[1]);
        __pyx_v_indices = ((PyArrayObject *)values[2]);
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("_polygon_overlap", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 53, __pyx_L3_error)
      __pyx_L3_error:;
      __Pyx_AddTraceback("anuga.geometry.polygon_ext._polygon_overlap", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_polygon), __pyx_ptype_5numpy_ndarray, 0, "polygon", 0))) __PYX_ERR(0, 53, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_triangles), __pyx_ptype_5numpy_ndarray, 0, "triangles", 0))) __PYX_ERR(0, 53, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_indices), __pyx_ptype_5numpy_ndarray, 0, "indices", 0))) __PYX_ERR(0, 53, __pyx_L1_error)
      __pyx_r = __pyx_pf_5anuga_8geometry_11polygon_ext_4_polygon_overlap(__pyx_self, __pyx_v_polygon, __pyx_v_triangles, __pyx_v_indices);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_5anuga_8geometry_11polygon_ext_4_polygon_overlap(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_polygon, PyArrayObject *__pyx_v_triangles, PyArrayObject *__pyx_v_indices) {
      int __pyx_v_res;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_indices;
      __Pyx_Buffer __pyx_pybuffer_indices;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_polygon;
      __Pyx_Buffer __pyx_pybuffer_polygon;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_triangles;
      __Pyx_Buffer __pyx_pybuffer_triangles;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_polygon_overlap", 0);
      __pyx_pybuffer_polygon.pybuffer.buf = NULL;
      __pyx_pybuffer_polygon.refcount = 0;
      __pyx_pybuffernd_polygon.data = NULL;
      __pyx_pybuffernd_polygon.rcbuffer = &__pyx_pybuffer_polygon;
      __pyx_pybuffer_triangles.pybuffer.buf = NULL;
      __pyx_pybuffer_triangles.refcount = 0;
      __pyx_pybuffernd_triangles.data = NULL;
      __pyx_pybuffernd_triangles.rcbuffer = &__pyx_pybuffer_triangles;
      __pyx_pybuffer_indices.pybuffer.buf = NULL;
      __pyx_pybuffer_indices.refcount = 0;
      __pyx_pybuffernd_indices.data = NULL;
      __pyx_pybuffernd_indices.rcbuffer = &__pyx_pybuffer_indices;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_polygon.rcbuffer->pybuffer, (PyObject*)__pyx_v_polygon, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 53, __pyx_L1_error)
      }
      __pyx_pybuffernd_polygon.diminfo[0].strides = __pyx_pybuffernd_polygon.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_polygon.diminfo[0].shape = __pyx_pybuffernd_polygon.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_polygon.diminfo[1].strides = __pyx_pybuffernd_polygon.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_polygon.diminfo[1].shape = __pyx_pybuffernd_polygon.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_triangles.rcbuffer->pybuffer, (PyObject*)__pyx_v_triangles, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 53, __pyx_L1_error)
      }
      __pyx_pybuffernd_triangles.diminfo[0].strides = __pyx_pybuffernd_triangles.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_triangles.diminfo[0].shape = __pyx_pybuffernd_triangles.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_triangles.diminfo[1].strides = __pyx_pybuffernd_triangles.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_triangles.diminfo[1].shape = __pyx_pybuffernd_triangles.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indices.rcbuffer->pybuffer, (PyObject*)__pyx_v_indices, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 53, __pyx_L1_error)
      }
      __pyx_pybuffernd_indices.diminfo[0].strides = __pyx_pybuffernd_indices.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indices.diminfo[0].shape = __pyx_pybuffernd_indices.rcbuffer->pybuffer.shape[0];
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_6);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_polygon.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_triangles.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("anuga.geometry.polygon_ext._polygon_overlap", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_polygon.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_triangles.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__7 = PyTuple_Pack(4, __pyx_n_s_polygon, __pyx_n_s_triangles, __pyx_n_s_indices, __pyx_n_s_res); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 53, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__7);
      __Pyx_GIVEREF(__pyx_tuple__7);
    /* … */
      __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5anuga_8geometry_11polygon_ext_5_polygon_overlap, NULL, __pyx_n_s_anuga_geometry_polygon_ext); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_polygon_overlap, __pyx_t_1) < 0) __PYX_ERR(0, 53, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_anuga_geometry_polygon_ext_pyx, __pyx_n_s_polygon_overlap, 53, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 53, __pyx_L1_error)

     54:

     55:     cdef int res

     56:

    +57:     res = __polygon_overlap(&polygon[0,0], &triangles[0,0], &indices[0], triangles.shape[0]/3, polygon.shape[0])

      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      __pyx_v_res = __polygon_overlap((&(*__Pyx_BufPtrCContig2d(double *, __pyx_pybuffernd_polygon.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_polygon.diminfo[0].strides, __pyx_t_2, __pyx_pybuffernd_polygon.diminfo[1].strides))), (&(*__Pyx_BufPtrCContig2d(double *, __pyx_pybuffernd_triangles.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_triangles.diminfo[0].strides, __pyx_t_4, __pyx_pybuffernd_triangles.diminfo[1].strides))), (&(*__Pyx_BufPtrCContig1d(long *, __pyx_pybuffernd_indices.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_indices.diminfo[0].strides))), ((__pyx_v_triangles->dimensions[0]) / 3), (__pyx_v_polygon->dimensions[0]));

     58:

    +59:     return res

      __Pyx_XDECREF(__pyx_r);
      __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_res); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 59, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_r = __pyx_t_6;
      __pyx_t_6 = 0;
      goto __pyx_L0;

     60:

    +61: def _line_intersect(np.ndarray[double, ndim=2, mode="c"] line not None, np.ndarray[double, ndim=2, mode="c"] triangles not None, np.ndarray[long, ndim=1, mode="c"] indices not None):

    /* Python wrapper */
    static PyObject *__pyx_pw_5anuga_8geometry_11polygon_ext_7_line_intersect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_5anuga_8geometry_11polygon_ext_7_line_intersect = {"_line_intersect", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5anuga_8geometry_11polygon_ext_7_line_intersect, METH_VARARGS|METH_KEYWORDS, 0};
    static PyObject *__pyx_pw_5anuga_8geometry_11polygon_ext_7_line_intersect(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_line = 0;
      PyArrayObject *__pyx_v_triangles = 0;
      PyArrayObject *__pyx_v_indices = 0;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_line_intersect (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_line,&__pyx_n_s_triangles,&__pyx_n_s_indices,0};
        PyObject* values[3] = {0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            CYTHON_FALLTHROUGH;
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            CYTHON_FALLTHROUGH;
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            CYTHON_FALLTHROUGH;
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_line)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            CYTHON_FALLTHROUGH;
            case  1:
            if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_triangles)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_line_intersect", 1, 3, 3, 1); __PYX_ERR(0, 61, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  2:
            if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_indices)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_line_intersect", 1, 3, 3, 2); __PYX_ERR(0, 61, __pyx_L3_error)
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_line_intersect") < 0)) __PYX_ERR(0, 61, __pyx_L3_error)
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
        }
        __pyx_v_line = ((PyArrayObject *)values[0]);
        __pyx_v_triangles = ((PyArrayObject *)values[1]);
        __pyx_v_indices = ((PyArrayObject *)values[2]);
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("_line_intersect", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 61, __pyx_L3_error)
      __pyx_L3_error:;
      __Pyx_AddTraceback("anuga.geometry.polygon_ext._line_intersect", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_line), __pyx_ptype_5numpy_ndarray, 0, "line", 0))) __PYX_ERR(0, 61, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_triangles), __pyx_ptype_5numpy_ndarray, 0, "triangles", 0))) __PYX_ERR(0, 61, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_indices), __pyx_ptype_5numpy_ndarray, 0, "indices", 0))) __PYX_ERR(0, 61, __pyx_L1_error)
      __pyx_r = __pyx_pf_5anuga_8geometry_11polygon_ext_6_line_intersect(__pyx_self, __pyx_v_line, __pyx_v_triangles, __pyx_v_indices);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_5anuga_8geometry_11polygon_ext_6_line_intersect(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_line, PyArrayObject *__pyx_v_triangles, PyArrayObject *__pyx_v_indices) {
      int __pyx_v_res;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_indices;
      __Pyx_Buffer __pyx_pybuffer_indices;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_line;
      __Pyx_Buffer __pyx_pybuffer_line;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_triangles;
      __Pyx_Buffer __pyx_pybuffer_triangles;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_line_intersect", 0);
      __pyx_pybuffer_line.pybuffer.buf = NULL;
      __pyx_pybuffer_line.refcount = 0;
      __pyx_pybuffernd_line.data = NULL;
      __pyx_pybuffernd_line.rcbuffer = &__pyx_pybuffer_line;
      __pyx_pybuffer_triangles.pybuffer.buf = NULL;
      __pyx_pybuffer_triangles.refcount = 0;
      __pyx_pybuffernd_triangles.data = NULL;
      __pyx_pybuffernd_triangles.rcbuffer = &__pyx_pybuffer_triangles;
      __pyx_pybuffer_indices.pybuffer.buf = NULL;
      __pyx_pybuffer_indices.refcount = 0;
      __pyx_pybuffernd_indices.data = NULL;
      __pyx_pybuffernd_indices.rcbuffer = &__pyx_pybuffer_indices;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_line.rcbuffer->pybuffer, (PyObject*)__pyx_v_line, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 61, __pyx_L1_error)
      }
      __pyx_pybuffernd_line.diminfo[0].strides = __pyx_pybuffernd_line.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_line.diminfo[0].shape = __pyx_pybuffernd_line.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_line.diminfo[1].strides = __pyx_pybuffernd_line.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_line.diminfo[1].shape = __pyx_pybuffernd_line.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_triangles.rcbuffer->pybuffer, (PyObject*)__pyx_v_triangles, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 61, __pyx_L1_error)
      }
      __pyx_pybuffernd_triangles.diminfo[0].strides = __pyx_pybuffernd_triangles.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_triangles.diminfo[0].shape = __pyx_pybuffernd_triangles.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_triangles.diminfo[1].strides = __pyx_pybuffernd_triangles.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_triangles.diminfo[1].shape = __pyx_pybuffernd_triangles.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indices.rcbuffer->pybuffer, (PyObject*)__pyx_v_indices, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 61, __pyx_L1_error)
      }
      __pyx_pybuffernd_indices.diminfo[0].strides = __pyx_pybuffernd_indices.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indices.diminfo[0].shape = __pyx_pybuffernd_indices.rcbuffer->pybuffer.shape[0];
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_6);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_line.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_triangles.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("anuga.geometry.polygon_ext._line_intersect", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_line.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_triangles.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__9 = PyTuple_Pack(4, __pyx_n_s_line, __pyx_n_s_triangles, __pyx_n_s_indices, __pyx_n_s_res); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 61, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__9);
      __Pyx_GIVEREF(__pyx_tuple__9);
    /* … */
      __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5anuga_8geometry_11polygon_ext_7_line_intersect, NULL, __pyx_n_s_anuga_geometry_polygon_ext); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_line_intersect, __pyx_t_1) < 0) __PYX_ERR(0, 61, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(3, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_anuga_geometry_polygon_ext_pyx, __pyx_n_s_line_intersect, 61, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 61, __pyx_L1_error)

     62:

     63:     cdef int res

     64:

    +65:     res = __line_intersect(&line[0,0], &triangles[0,0], &indices[0], triangles.shape[0]/3)

      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_t_4 = 0;
      __pyx_t_5 = 0;
      __pyx_v_res = __line_intersect((&(*__Pyx_BufPtrCContig2d(double *, __pyx_pybuffernd_line.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_line.diminfo[0].strides, __pyx_t_2, __pyx_pybuffernd_line.diminfo[1].strides))), (&(*__Pyx_BufPtrCContig2d(double *, __pyx_pybuffernd_triangles.rcbuffer->pybuffer.buf, __pyx_t_3, __pyx_pybuffernd_triangles.diminfo[0].strides, __pyx_t_4, __pyx_pybuffernd_triangles.diminfo[1].strides))), (&(*__Pyx_BufPtrCContig1d(long *, __pyx_pybuffernd_indices.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_indices.diminfo[0].strides))), ((__pyx_v_triangles->dimensions[0]) / 3));

     66:

    +67:     return res

      __Pyx_XDECREF(__pyx_r);
      __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_res); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 67, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_r = __pyx_t_6;
      __pyx_t_6 = 0;
      goto __pyx_L0;

     68:

    +69: def _is_inside_triangle(np.ndarray[double, ndim=1, mode="c"] point not None,\

    /* Python wrapper */
    static PyObject *__pyx_pw_5anuga_8geometry_11polygon_ext_9_is_inside_triangle(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_5anuga_8geometry_11polygon_ext_9_is_inside_triangle = {"_is_inside_triangle", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5anuga_8geometry_11polygon_ext_9_is_inside_triangle, METH_VARARGS|METH_KEYWORDS, 0};
    static PyObject *__pyx_pw_5anuga_8geometry_11polygon_ext_9_is_inside_triangle(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_point = 0;
      PyArrayObject *__pyx_v_triangle = 0;
      int __pyx_v_closed;
      double __pyx_v_rtol;
      double __pyx_v_atol;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_is_inside_triangle (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_point,&__pyx_n_s_triangle,&__pyx_n_s_closed,&__pyx_n_s_rtol,&__pyx_n_s_atol,0};
        PyObject* values[5] = {0,0,0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
            CYTHON_FALLTHROUGH;
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            CYTHON_FALLTHROUGH;
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            CYTHON_FALLTHROUGH;
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            CYTHON_FALLTHROUGH;
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            CYTHON_FALLTHROUGH;
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_point)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            CYTHON_FALLTHROUGH;
            case  1:
            if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_triangle)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_is_inside_triangle", 1, 5, 5, 1); __PYX_ERR(0, 69, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  2:
            if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_closed)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_is_inside_triangle", 1, 5, 5, 2); __PYX_ERR(0, 69, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  3:
            if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_rtol)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_is_inside_triangle", 1, 5, 5, 3); __PYX_ERR(0, 69, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  4:
            if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_atol)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_is_inside_triangle", 1, 5, 5, 4); __PYX_ERR(0, 69, __pyx_L3_error)
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_is_inside_triangle") < 0)) __PYX_ERR(0, 69, __pyx_L3_error)
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
          values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
          values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        }
        __pyx_v_point = ((PyArrayObject *)values[0]);
        __pyx_v_triangle = ((PyArrayObject *)values[1]);
        __pyx_v_closed = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_closed == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 71, __pyx_L3_error)
        __pyx_v_rtol = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_rtol == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 72, __pyx_L3_error)
        __pyx_v_atol = __pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_atol == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 73, __pyx_L3_error)
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("_is_inside_triangle", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 69, __pyx_L3_error)
      __pyx_L3_error:;
      __Pyx_AddTraceback("anuga.geometry.polygon_ext._is_inside_triangle", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_point), __pyx_ptype_5numpy_ndarray, 0, "point", 0))) __PYX_ERR(0, 69, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_triangle), __pyx_ptype_5numpy_ndarray, 0, "triangle", 0))) __PYX_ERR(0, 70, __pyx_L1_error)
      __pyx_r = __pyx_pf_5anuga_8geometry_11polygon_ext_8_is_inside_triangle(__pyx_self, __pyx_v_point, __pyx_v_triangle, __pyx_v_closed, __pyx_v_rtol, __pyx_v_atol);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_5anuga_8geometry_11polygon_ext_8_is_inside_triangle(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_point, PyArrayObject *__pyx_v_triangle, int __pyx_v_closed, double __pyx_v_rtol, double __pyx_v_atol) {
      int __pyx_v_res;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_point;
      __Pyx_Buffer __pyx_pybuffer_point;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_triangle;
      __Pyx_Buffer __pyx_pybuffer_triangle;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_is_inside_triangle", 0);
      __pyx_pybuffer_point.pybuffer.buf = NULL;
      __pyx_pybuffer_point.refcount = 0;
      __pyx_pybuffernd_point.data = NULL;
      __pyx_pybuffernd_point.rcbuffer = &__pyx_pybuffer_point;
      __pyx_pybuffer_triangle.pybuffer.buf = NULL;
      __pyx_pybuffer_triangle.refcount = 0;
      __pyx_pybuffernd_triangle.data = NULL;
      __pyx_pybuffernd_triangle.rcbuffer = &__pyx_pybuffer_triangle;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_point.rcbuffer->pybuffer, (PyObject*)__pyx_v_point, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 69, __pyx_L1_error)
      }
      __pyx_pybuffernd_point.diminfo[0].strides = __pyx_pybuffernd_point.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_point.diminfo[0].shape = __pyx_pybuffernd_point.rcbuffer->pybuffer.shape[0];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_triangle.rcbuffer->pybuffer, (PyObject*)__pyx_v_triangle, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 69, __pyx_L1_error)
      }
      __pyx_pybuffernd_triangle.diminfo[0].strides = __pyx_pybuffernd_triangle.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_triangle.diminfo[0].shape = __pyx_pybuffernd_triangle.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_triangle.diminfo[1].strides = __pyx_pybuffernd_triangle.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_triangle.diminfo[1].shape = __pyx_pybuffernd_triangle.rcbuffer->pybuffer.shape[1];
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_4);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_point.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_triangle.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("anuga.geometry.polygon_ext._is_inside_triangle", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_point.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_triangle.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__11 = PyTuple_Pack(6, __pyx_n_s_point, __pyx_n_s_triangle, __pyx_n_s_closed, __pyx_n_s_rtol, __pyx_n_s_atol, __pyx_n_s_res); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 69, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__11);
      __Pyx_GIVEREF(__pyx_tuple__11);
    /* … */
      __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5anuga_8geometry_11polygon_ext_9_is_inside_triangle, NULL, __pyx_n_s_anuga_geometry_polygon_ext); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_is_inside_triangle, __pyx_t_1) < 0) __PYX_ERR(0, 69, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(5, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_anuga_geometry_polygon_ext_pyx, __pyx_n_s_is_inside_triangle, 69, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 69, __pyx_L1_error)

     70:                         np.ndarray[double, ndim=2, mode="c"] triangle not None,\

     71:                         int closed,\

     72:                         double rtol,\

     73:                         double atol):

     74:

     75:     cdef int res

     76:

    +77:     res = __is_inside_triangle(&point[0], &triangle[0,0], closed, rtol, atol)

      __pyx_t_1 = 0;
      __pyx_t_2 = 0;
      __pyx_t_3 = 0;
      __pyx_v_res = __is_inside_triangle((&(*__Pyx_BufPtrCContig1d(double *, __pyx_pybuffernd_point.rcbuffer->pybuffer.buf, __pyx_t_1, __pyx_pybuffernd_point.diminfo[0].strides))), (&(*__Pyx_BufPtrCContig2d(double *, __pyx_pybuffernd_triangle.rcbuffer->pybuffer.buf, __pyx_t_2, __pyx_pybuffernd_triangle.diminfo[0].strides, __pyx_t_3, __pyx_pybuffernd_triangle.diminfo[1].strides))), __pyx_v_closed, __pyx_v_rtol, __pyx_v_atol);

     78:

    +79:     return res

      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_res); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 79, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L0;

     80:

    +81: def _separate_points_by_polygon(np.ndarray[double, ndim=2, mode="c"] points not None,\

    /* Python wrapper */
    static PyObject *__pyx_pw_5anuga_8geometry_11polygon_ext_11_separate_points_by_polygon(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
    static PyMethodDef __pyx_mdef_5anuga_8geometry_11polygon_ext_11_separate_points_by_polygon = {"_separate_points_by_polygon", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_5anuga_8geometry_11polygon_ext_11_separate_points_by_polygon, METH_VARARGS|METH_KEYWORDS, 0};
    static PyObject *__pyx_pw_5anuga_8geometry_11polygon_ext_11_separate_points_by_polygon(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
      PyArrayObject *__pyx_v_points = 0;
      PyArrayObject *__pyx_v_polygon = 0;
      PyArrayObject *__pyx_v_indices = 0;
      int __pyx_v_closed;
      int __pyx_v_verbose;
      PyObject *__pyx_r = 0;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_separate_points_by_polygon (wrapper)", 0);
      {
        static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_points,&__pyx_n_s_polygon,&__pyx_n_s_indices,&__pyx_n_s_closed,&__pyx_n_s_verbose,0};
        PyObject* values[5] = {0,0,0,0,0};
        if (unlikely(__pyx_kwds)) {
          Py_ssize_t kw_args;
          const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
          switch (pos_args) {
            case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
            CYTHON_FALLTHROUGH;
            case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
            CYTHON_FALLTHROUGH;
            case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
            CYTHON_FALLTHROUGH;
            case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
            CYTHON_FALLTHROUGH;
            case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
            CYTHON_FALLTHROUGH;
            case  0: break;
            default: goto __pyx_L5_argtuple_error;
          }
          kw_args = PyDict_Size(__pyx_kwds);
          switch (pos_args) {
            case  0:
            if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_points)) != 0)) kw_args--;
            else goto __pyx_L5_argtuple_error;
            CYTHON_FALLTHROUGH;
            case  1:
            if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_polygon)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_separate_points_by_polygon", 1, 5, 5, 1); __PYX_ERR(0, 81, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  2:
            if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_indices)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_separate_points_by_polygon", 1, 5, 5, 2); __PYX_ERR(0, 81, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  3:
            if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_closed)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_separate_points_by_polygon", 1, 5, 5, 3); __PYX_ERR(0, 81, __pyx_L3_error)
            }
            CYTHON_FALLTHROUGH;
            case  4:
            if (likely((values[4] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_verbose)) != 0)) kw_args--;
            else {
              __Pyx_RaiseArgtupleInvalid("_separate_points_by_polygon", 1, 5, 5, 4); __PYX_ERR(0, 81, __pyx_L3_error)
            }
          }
          if (unlikely(kw_args > 0)) {
            if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_separate_points_by_polygon") < 0)) __PYX_ERR(0, 81, __pyx_L3_error)
          }
        } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
          goto __pyx_L5_argtuple_error;
        } else {
          values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
          values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
          values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
          values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
          values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
        }
        __pyx_v_points = ((PyArrayObject *)values[0]);
        __pyx_v_polygon = ((PyArrayObject *)values[1]);
        __pyx_v_indices = ((PyArrayObject *)values[2]);
        __pyx_v_closed = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_closed == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 84, __pyx_L3_error)
        __pyx_v_verbose = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_verbose == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L3_error)
      }
      goto __pyx_L4_argument_unpacking_done;
      __pyx_L5_argtuple_error:;
      __Pyx_RaiseArgtupleInvalid("_separate_points_by_polygon", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 81, __pyx_L3_error)
      __pyx_L3_error:;
      __Pyx_AddTraceback("anuga.geometry.polygon_ext._separate_points_by_polygon", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __Pyx_RefNannyFinishContext();
      return NULL;
      __pyx_L4_argument_unpacking_done:;
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_points), __pyx_ptype_5numpy_ndarray, 0, "points", 0))) __PYX_ERR(0, 81, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_polygon), __pyx_ptype_5numpy_ndarray, 0, "polygon", 0))) __PYX_ERR(0, 82, __pyx_L1_error)
      if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_indices), __pyx_ptype_5numpy_ndarray, 0, "indices", 0))) __PYX_ERR(0, 83, __pyx_L1_error)
      __pyx_r = __pyx_pf_5anuga_8geometry_11polygon_ext_10_separate_points_by_polygon(__pyx_self, __pyx_v_points, __pyx_v_polygon, __pyx_v_indices, __pyx_v_closed, __pyx_v_verbose);
      int __pyx_lineno = 0;
      const char *__pyx_filename = NULL;
      int __pyx_clineno = 0;

      /* function exit code */
      goto __pyx_L0;
      __pyx_L1_error:;
      __pyx_r = NULL;
      __pyx_L0:;
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }

    static PyObject *__pyx_pf_5anuga_8geometry_11polygon_ext_10_separate_points_by_polygon(CYTHON_UNUSED PyObject *__pyx_self, PyArrayObject *__pyx_v_points, PyArrayObject *__pyx_v_polygon, PyArrayObject *__pyx_v_indices, int __pyx_v_closed, int __pyx_v_verbose) {
      int __pyx_v_count;
      int __pyx_v_M;
      int __pyx_v_N;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_indices;
      __Pyx_Buffer __pyx_pybuffer_indices;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_points;
      __Pyx_Buffer __pyx_pybuffer_points;
      __Pyx_LocalBuf_ND __pyx_pybuffernd_polygon;
      __Pyx_Buffer __pyx_pybuffer_polygon;
      PyObject *__pyx_r = NULL;
      __Pyx_RefNannyDeclarations
      __Pyx_RefNannySetupContext("_separate_points_by_polygon", 0);
      __pyx_pybuffer_points.pybuffer.buf = NULL;
      __pyx_pybuffer_points.refcount = 0;
      __pyx_pybuffernd_points.data = NULL;
      __pyx_pybuffernd_points.rcbuffer = &__pyx_pybuffer_points;
      __pyx_pybuffer_polygon.pybuffer.buf = NULL;
      __pyx_pybuffer_polygon.refcount = 0;
      __pyx_pybuffernd_polygon.data = NULL;
      __pyx_pybuffernd_polygon.rcbuffer = &__pyx_pybuffer_polygon;
      __pyx_pybuffer_indices.pybuffer.buf = NULL;
      __pyx_pybuffer_indices.refcount = 0;
      __pyx_pybuffernd_indices.data = NULL;
      __pyx_pybuffernd_indices.rcbuffer = &__pyx_pybuffer_indices;
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_points.rcbuffer->pybuffer, (PyObject*)__pyx_v_points, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 81, __pyx_L1_error)
      }
      __pyx_pybuffernd_points.diminfo[0].strides = __pyx_pybuffernd_points.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_points.diminfo[0].shape = __pyx_pybuffernd_points.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_points.diminfo[1].strides = __pyx_pybuffernd_points.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_points.diminfo[1].shape = __pyx_pybuffernd_points.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_polygon.rcbuffer->pybuffer, (PyObject*)__pyx_v_polygon, &__Pyx_TypeInfo_double, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 2, 0, __pyx_stack) == -1)) __PYX_ERR(0, 81, __pyx_L1_error)
      }
      __pyx_pybuffernd_polygon.diminfo[0].strides = __pyx_pybuffernd_polygon.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_polygon.diminfo[0].shape = __pyx_pybuffernd_polygon.rcbuffer->pybuffer.shape[0]; __pyx_pybuffernd_polygon.diminfo[1].strides = __pyx_pybuffernd_polygon.rcbuffer->pybuffer.strides[1]; __pyx_pybuffernd_polygon.diminfo[1].shape = __pyx_pybuffernd_polygon.rcbuffer->pybuffer.shape[1];
      {
        __Pyx_BufFmt_StackElem __pyx_stack[1];
        if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_pybuffernd_indices.rcbuffer->pybuffer, (PyObject*)__pyx_v_indices, &__Pyx_TypeInfo_long, PyBUF_FORMAT| PyBUF_C_CONTIGUOUS, 1, 0, __pyx_stack) == -1)) __PYX_ERR(0, 81, __pyx_L1_error)
      }
      __pyx_pybuffernd_indices.diminfo[0].strides = __pyx_pybuffernd_indices.rcbuffer->pybuffer.strides[0]; __pyx_pybuffernd_indices.diminfo[0].shape = __pyx_pybuffernd_indices.rcbuffer->pybuffer.shape[0];
    /* … */
      /* function exit code */
      __pyx_L1_error:;
      __Pyx_XDECREF(__pyx_t_2);
      __Pyx_XDECREF(__pyx_t_3);
      __Pyx_XDECREF(__pyx_t_4);
      { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_points.rcbuffer->pybuffer);
        __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_polygon.rcbuffer->pybuffer);
      __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
      __Pyx_AddTraceback("anuga.geometry.polygon_ext._separate_points_by_polygon", __pyx_clineno, __pyx_lineno, __pyx_filename);
      __pyx_r = NULL;
      goto __pyx_L2;
      __pyx_L0:;
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_indices.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_points.rcbuffer->pybuffer);
      __Pyx_SafeReleaseBuffer(&__pyx_pybuffernd_polygon.rcbuffer->pybuffer);
      __pyx_L2:;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      return __pyx_r;
    }
    /* … */
      __pyx_tuple__13 = PyTuple_Pack(8, __pyx_n_s_points, __pyx_n_s_polygon, __pyx_n_s_indices, __pyx_n_s_closed, __pyx_n_s_verbose, __pyx_n_s_count, __pyx_n_s_M, __pyx_n_s_N); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 81, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_tuple__13);
      __Pyx_GIVEREF(__pyx_tuple__13);
    /* … */
      __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5anuga_8geometry_11polygon_ext_11_separate_points_by_polygon, NULL, __pyx_n_s_anuga_geometry_polygon_ext); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_d, __pyx_n_s_separate_points_by_polygon, __pyx_t_1) < 0) __PYX_ERR(0, 81, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

     82:                                 np.ndarray[double, ndim=2, mode="c"] polygon not None,\

     83:                                 np.ndarray[long, ndim=1, mode="c"] indices not None,\

     84:                                 int closed,\

     85:                                 int verbose):

     86:

     87:     cdef int count, M, N

     88:

    +89:     M = points.shape[0]

      __pyx_v_M = (__pyx_v_points->dimensions[0]);

    +90:     N = polygon.shape[0]

      __pyx_v_N = (__pyx_v_polygon->dimensions[0]);

     91:

    +92:     if verbose:

      __pyx_t_1 = (__pyx_v_verbose != 0);
      if (__pyx_t_1) {
    /* … */
      }

    +93:         print "Got %d points and %d polygon vertices" % (M,N)

        __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_M); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_N); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 93, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_2);
        PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_3);
        PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
        __pyx_t_2 = 0;
        __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyString_Format(__pyx_kp_s_Got_d_points_and_d_polygon_verti, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (__Pyx_PrintOne(0, __pyx_t_3) < 0) __PYX_ERR(0, 93, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

     94:

    +95:     count = __separate_points_by_polygon(M, N, &points[0,0], &polygon[0,0], &indices[0], closed, verbose)

      __pyx_t_5 = 0;
      __pyx_t_6 = 0;
      __pyx_t_7 = 0;
      __pyx_t_8 = 0;
      __pyx_t_9 = 0;
      __pyx_v_count = __separate_points_by_polygon(__pyx_v_M, __pyx_v_N, (&(*__Pyx_BufPtrCContig2d(double *, __pyx_pybuffernd_points.rcbuffer->pybuffer.buf, __pyx_t_5, __pyx_pybuffernd_points.diminfo[0].strides, __pyx_t_6, __pyx_pybuffernd_points.diminfo[1].strides))), (&(*__Pyx_BufPtrCContig2d(double *, __pyx_pybuffernd_polygon.rcbuffer->pybuffer.buf, __pyx_t_7, __pyx_pybuffernd_polygon.diminfo[0].strides, __pyx_t_8, __pyx_pybuffernd_polygon.diminfo[1].strides))), (&(*__Pyx_BufPtrCContig1d(long *, __pyx_pybuffernd_indices.rcbuffer->pybuffer.buf, __pyx_t_9, __pyx_pybuffernd_indices.diminfo[0].strides))), __pyx_v_closed, __pyx_v_verbose);

     96:

    +97:     return count

      __Pyx_XDECREF(__pyx_r);
      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_count); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 97, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L0;