/* Generated by Cython 0.14.1 on Tue Nov  8 18:34:50 2011 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#else

#include <stddef.h> /* For offsetof */
#ifndef offsetof
#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif

#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif

#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif

#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif

#if PY_VERSION_HEX < 0x02040000
  #define METH_COEXIST 0
  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
  #define PyDict_Contains(d,o)   PySequence_Contains(d,o)
#endif

#if PY_VERSION_HEX < 0x02050000
  typedef int Py_ssize_t;
  #define PY_SSIZE_T_MAX INT_MAX
  #define PY_SSIZE_T_MIN INT_MIN
  #define PY_FORMAT_SIZE_T ""
  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
  #define PyNumber_Index(o)    PyNumber_Int(o)
  #define PyIndex_Check(o)     PyNumber_Check(o)
  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
#endif

#if PY_VERSION_HEX < 0x02060000
  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
  #define PyVarObject_HEAD_INIT(type, size) \
          PyObject_HEAD_INIT(type) size,
  #define PyType_Modified(t)

  typedef struct {
     void *buf;
     PyObject *obj;
     Py_ssize_t len;
     Py_ssize_t itemsize;
     int readonly;
     int ndim;
     char *format;
     Py_ssize_t *shape;
     Py_ssize_t *strides;
     Py_ssize_t *suboffsets;
     void *internal;
  } Py_buffer;

  #define PyBUF_SIMPLE 0
  #define PyBUF_WRITABLE 0x0001
  #define PyBUF_FORMAT 0x0004
  #define PyBUF_ND 0x0008
  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)

#endif

#if PY_MAJOR_VERSION < 3
  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
#else
  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
#endif

#if PY_MAJOR_VERSION >= 3
  #define Py_TPFLAGS_CHECKTYPES 0
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif

#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBaseString_Type            PyUnicode_Type
  #define PyStringObject               PyUnicodeObject
  #define PyString_Type                PyUnicode_Type
  #define PyString_Check               PyUnicode_Check
  #define PyString_CheckExact          PyUnicode_CheckExact
#endif

#if PY_VERSION_HEX < 0x02060000
  #define PyBytesObject                PyStringObject
  #define PyBytes_Type                 PyString_Type
  #define PyBytes_Check                PyString_Check
  #define PyBytes_CheckExact           PyString_CheckExact
  #define PyBytes_FromString           PyString_FromString
  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
  #define PyBytes_FromFormat           PyString_FromFormat
  #define PyBytes_DecodeEscape         PyString_DecodeEscape
  #define PyBytes_AsString             PyString_AsString
  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
  #define PyBytes_Size                 PyString_Size
  #define PyBytes_AS_STRING            PyString_AS_STRING
  #define PyBytes_GET_SIZE             PyString_GET_SIZE
  #define PyBytes_Repr                 PyString_Repr
  #define PyBytes_Concat               PyString_Concat
  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
#endif

#if PY_VERSION_HEX < 0x02060000
  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
#endif

#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)

#if PY_MAJOR_VERSION >= 3
  #define PyIntObject                  PyLongObject
  #define PyInt_Type                   PyLong_Type
  #define PyInt_Check(op)              PyLong_Check(op)
  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
  #define PyInt_FromString             PyLong_FromString
  #define PyInt_FromUnicode            PyLong_FromUnicode
  #define PyInt_FromLong               PyLong_FromLong
  #define PyInt_FromSize_t             PyLong_FromSize_t
  #define PyInt_FromSsize_t            PyLong_FromSsize_t
  #define PyInt_AsLong                 PyLong_AsLong
  #define PyInt_AS_LONG                PyLong_AS_LONG
  #define PyInt_AsSsize_t              PyLong_AsSsize_t
  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyBoolObject                 PyLongObject
#endif


#if PY_MAJOR_VERSION >= 3
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#else
  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
#endif

#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
  #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
  #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
#else
  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
#endif

#if PY_MAJOR_VERSION >= 3
  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
#else
  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
#endif

#if PY_VERSION_HEX < 0x02050000
  #define __Pyx_NAMESTR(n) ((char *)(n))
  #define __Pyx_DOCSTR(n)  ((char *)(n))
#else
  #define __Pyx_NAMESTR(n) (n)
  #define __Pyx_DOCSTR(n)  (n)
#endif

#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif

#if defined(WIN32) || defined(MS_WINDOWS)
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#define __PYX_HAVE_API___region_filter
#include "stdio.h"
#include "stdlib.h"
#include "numpy/arrayobject.h"
#include "math.h"

#ifdef PYREX_WITHOUT_ASSERTIONS
#define CYTHON_WITHOUT_ASSERTIONS
#endif


/* inline attribute */
#ifndef CYTHON_INLINE
  #if defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

/* unused attribute */
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || defined(__INTEL_COMPILER)
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif

typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/


/* Type Conversion Predeclarations */

#define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
#define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))

#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);

#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))


#ifdef __GNUC__
/* Test for GCC > 2.95 */
#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
#define likely(x)   __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#else /* __GNUC__ > 2 ... */
#define likely(x)   (x)
#define unlikely(x) (x)
#endif /* __GNUC__ > 2 ... */
#else /* __GNUC__ */
#define likely(x)   (x)
#define unlikely(x) (x)
#endif /* __GNUC__ */
    
static PyObject *__pyx_m;
static PyObject *__pyx_b;
static PyObject *__pyx_empty_tuple;
static PyObject *__pyx_empty_bytes;
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * __pyx_cfilenm= __FILE__;
static const char *__pyx_filename;


static const char *__pyx_f[] = {
  "_region_filter.pyx",
  "c_numpy.pxd",
};

typedef int __pyx_t_14_region_filter_Py_ssize_t;

/* Type declarations */

/* "_region_filter.pyx":38
 * 
 * 
 * cdef struct Metric:             # <<<<<<<<<<<<<<
 *     double x0
 *     double y0
 */

struct __pyx_t_14_region_filter_Metric {
  double x0;
  double y0;
  double g_x;
  double g_y;
};

/* "_region_filter.pyx":52
 * 
 * 
 * cdef struct _RegionContext:             # <<<<<<<<<<<<<<
 *     int (*update_metric)(Metric *m)
 * 
 */

struct __pyx_t_14_region_filter__RegionContext {
  int (*update_metric)(struct __pyx_t_14_region_filter_Metric *);
};

/* "_region_filter.pyx":55
 *     int (*update_metric)(Metric *m)
 * 
 * cdef class RegionContext:             # <<<<<<<<<<<<<<
 *     #cdef int (*init_metric)(Metric *m, double x0, double y0)
 *     cdef _RegionContext c
 */

struct __pyx_obj_14_region_filter_RegionContext {
  PyObject_HEAD
  struct __pyx_vtabstruct_14_region_filter_RegionContext *__pyx_vtab;
  struct __pyx_t_14_region_filter__RegionContext c;
};

/* "_region_filter.pyx":92
 *     pass
 * 
 * cdef class RegionBase:             # <<<<<<<<<<<<<<
 *     #cdef double sin_theta
 *     #cdef double cos_theta
 */

struct __pyx_obj_14_region_filter_RegionBase {
  PyObject_HEAD
  struct __pyx_vtabstruct_14_region_filter_RegionBase *__pyx_vtab;
  struct __pyx_t_14_region_filter_Metric m;
  struct __pyx_obj_14_region_filter_RegionContext *c;
};

/* "_region_filter.pyx":323
 * 
 * 
 * cdef class RegionList(RegionBase):             # <<<<<<<<<<<<<<
 *     cdef object child_regions
 * 
 */

struct __pyx_obj_14_region_filter_RegionList {
  struct __pyx_obj_14_region_filter_RegionBase __pyx_base;
  PyObject *child_regions;
};

/* "_region_filter.pyx":387
 * 
 * 
 * cdef class RegionAndList(RegionList):             # <<<<<<<<<<<<<<
 * 
 *     """
 */

struct __pyx_obj_14_region_filter_RegionAndList {
  struct __pyx_obj_14_region_filter_RegionList __pyx_base;
};

/* "_region_filter.pyx":683
 * 
 * 
 * cdef class Ellipse(RegionBase):             # <<<<<<<<<<<<<<
 *     """
 *     Ellipse
 */

struct __pyx_obj_14_region_filter_Ellipse {
  struct __pyx_obj_14_region_filter_RegionBase __pyx_base;
  double xc;
  double yc;
  double radius_major;
  double radius_major_2;
  double radius_minor;
  double radius_minor_2;
  double radius_major_2_radius_minor_2;
};

/* "_region_filter.pyx":310
 * 
 * 
 * cdef class RegionNot(RegionBase):             # <<<<<<<<<<<<<<
 *     """
 *     >>> r = RegionNot(r2)
 */

struct __pyx_obj_14_region_filter_RegionNot {
  struct __pyx_obj_14_region_filter_RegionBase __pyx_base;
  struct __pyx_obj_14_region_filter_RegionBase *child_region;
};

/* "_region_filter.pyx":367
 * 
 * 
 * cdef class RegionOrList(RegionList):             # <<<<<<<<<<<<<<
 *     """
 *     >>> r = RegionOrList(r1, r2, r3, r4, ...)
 */

struct __pyx_obj_14_region_filter_RegionOrList {
  struct __pyx_obj_14_region_filter_RegionList __pyx_base;
};

/* "_region_filter.pyx":731
 * 
 * 
 * cdef class Box(RegionBase):             # <<<<<<<<<<<<<<
 *     """
 *     Box
 */

struct __pyx_obj_14_region_filter_Box {
  struct __pyx_obj_14_region_filter_RegionBase __pyx_base;
  double x1;
  double x2;
  double y1;
  double y2;
};

/* "_region_filter.pyx":523
 * 
 * 
 * cdef class Transform(RegionBase):             # <<<<<<<<<<<<<<
 *     cdef RegionBase child_region
 * 
 */

struct __pyx_obj_14_region_filter_Transform {
  struct __pyx_obj_14_region_filter_RegionBase __pyx_base;
  struct __pyx_obj_14_region_filter_RegionBase *child_region;
};

/* "_region_filter.pyx":560
 * 
 * 
 * cdef class Rotated(Transform):             # <<<<<<<<<<<<<<
 *     """
 *     Rotated
 */

struct __pyx_obj_14_region_filter_Rotated {
  struct __pyx_obj_14_region_filter_Transform __pyx_base;
  double sin_theta;
  double cos_theta;
  double origin_x;
  double origin_y;
};

/* "_region_filter.pyx":844
 * 
 * 
 * cdef class AngleRange(RegionBase):             # <<<<<<<<<<<<<<
 *     """
 *     AngleRange
 */

struct __pyx_obj_14_region_filter_AngleRange {
  struct __pyx_obj_14_region_filter_RegionBase __pyx_base;
  double xc;
  double yc;
  double degree1;
  double degree2;
  double radian1;
  double radian2;
};

/* "_region_filter.pyx":637
 * # Basic Shapes
 * 
 * cdef class Circle(RegionBase):             # <<<<<<<<<<<<<<
 *     """
 *     Circle
 */

struct __pyx_obj_14_region_filter_Circle {
  struct __pyx_obj_14_region_filter_RegionBase __pyx_base;
  double xc;
  double yc;
  double radius;
  double radius2;
};

/* "_region_filter.pyx":607
 * 
 * 
 * cdef class Translated(Transform):             # <<<<<<<<<<<<<<
 *     """
 *     Translated region
 */

struct __pyx_obj_14_region_filter_Translated {
  struct __pyx_obj_14_region_filter_Transform __pyx_base;
  double dx;
  double dy;
};

/* "_region_filter.pyx":766
 * 
 * 
 * cdef class Polygon(RegionBase):             # <<<<<<<<<<<<<<
 *     """
 *     Polygon
 */

struct __pyx_obj_14_region_filter_Polygon {
  struct __pyx_obj_14_region_filter_RegionBase __pyx_base;
  PyArrayObject *xa;
  PyArrayObject *ya;
  double *x;
  double *y;
  int n;
};


/* "_region_filter.pyx":92
 *     pass
 * 
 * cdef class RegionBase:             # <<<<<<<<<<<<<<
 *     #cdef double sin_theta
 *     #cdef double cos_theta
 */

struct __pyx_vtabstruct_14_region_filter_RegionBase {
  PyObject *(*update_metric)(struct __pyx_obj_14_region_filter_RegionBase *);
  PyObject *(*metric_set_origin)(struct __pyx_obj_14_region_filter_RegionBase *, double, double, struct __pyx_obj_14_region_filter_RegionContext *);
  npy_bool (*_inside)(struct __pyx_obj_14_region_filter_RegionBase *, double, double);
  PyArrayObject *(*_mask)(struct __pyx_obj_14_region_filter_RegionBase *, npy_intp, npy_intp);
};
static struct __pyx_vtabstruct_14_region_filter_RegionBase *__pyx_vtabptr_14_region_filter_RegionBase;


/* "_region_filter.pyx":637
 * # Basic Shapes
 * 
 * cdef class Circle(RegionBase):             # <<<<<<<<<<<<<<
 *     """
 *     Circle
 */

struct __pyx_vtabstruct_14_region_filter_Circle {
  struct __pyx_vtabstruct_14_region_filter_RegionBase __pyx_base;
  PyObject *(*_set_v)(struct __pyx_obj_14_region_filter_Circle *, double, double, double);
  PyObject *(*_get_v)(struct __pyx_obj_14_region_filter_Circle *);
};
static struct __pyx_vtabstruct_14_region_filter_Circle *__pyx_vtabptr_14_region_filter_Circle;


/* "_region_filter.pyx":310
 * 
 * 
 * cdef class RegionNot(RegionBase):             # <<<<<<<<<<<<<<
 *     """
 *     >>> r = RegionNot(r2)
 */

struct __pyx_vtabstruct_14_region_filter_RegionNot {
  struct __pyx_vtabstruct_14_region_filter_RegionBase __pyx_base;
};
static struct __pyx_vtabstruct_14_region_filter_RegionNot *__pyx_vtabptr_14_region_filter_RegionNot;


/* "_region_filter.pyx":323
 * 
 * 
 * cdef class RegionList(RegionBase):             # <<<<<<<<<<<<<<
 *     cdef object child_regions
 * 
 */

struct __pyx_vtabstruct_14_region_filter_RegionList {
  struct __pyx_vtabstruct_14_region_filter_RegionBase __pyx_base;
};
static struct __pyx_vtabstruct_14_region_filter_RegionList *__pyx_vtabptr_14_region_filter_RegionList;


/* "_region_filter.pyx":387
 * 
 * 
 * cdef class RegionAndList(RegionList):             # <<<<<<<<<<<<<<
 * 
 *     """
 */

struct __pyx_vtabstruct_14_region_filter_RegionAndList {
  struct __pyx_vtabstruct_14_region_filter_RegionList __pyx_base;
};
static struct __pyx_vtabstruct_14_region_filter_RegionAndList *__pyx_vtabptr_14_region_filter_RegionAndList;


/* "_region_filter.pyx":367
 * 
 * 
 * cdef class RegionOrList(RegionList):             # <<<<<<<<<<<<<<
 *     """
 *     >>> r = RegionOrList(r1, r2, r3, r4, ...)
 */

struct __pyx_vtabstruct_14_region_filter_RegionOrList {
  struct __pyx_vtabstruct_14_region_filter_RegionList __pyx_base;
};
static struct __pyx_vtabstruct_14_region_filter_RegionOrList *__pyx_vtabptr_14_region_filter_RegionOrList;


/* "_region_filter.pyx":844
 * 
 * 
 * cdef class AngleRange(RegionBase):             # <<<<<<<<<<<<<<
 *     """
 *     AngleRange
 */

struct __pyx_vtabstruct_14_region_filter_AngleRange {
  struct __pyx_vtabstruct_14_region_filter_RegionBase __pyx_base;
  double (*_fix_angle)(struct __pyx_obj_14_region_filter_AngleRange *, double);
};
static struct __pyx_vtabstruct_14_region_filter_AngleRange *__pyx_vtabptr_14_region_filter_AngleRange;


/* "_region_filter.pyx":766
 * 
 * 
 * cdef class Polygon(RegionBase):             # <<<<<<<<<<<<<<
 *     """
 *     Polygon
 */

struct __pyx_vtabstruct_14_region_filter_Polygon {
  struct __pyx_vtabstruct_14_region_filter_RegionBase __pyx_base;
};
static struct __pyx_vtabstruct_14_region_filter_Polygon *__pyx_vtabptr_14_region_filter_Polygon;


/* "_region_filter.pyx":731
 * 
 * 
 * cdef class Box(RegionBase):             # <<<<<<<<<<<<<<
 *     """
 *     Box
 */

struct __pyx_vtabstruct_14_region_filter_Box {
  struct __pyx_vtabstruct_14_region_filter_RegionBase __pyx_base;
};
static struct __pyx_vtabstruct_14_region_filter_Box *__pyx_vtabptr_14_region_filter_Box;


/* "_region_filter.pyx":523
 * 
 * 
 * cdef class Transform(RegionBase):             # <<<<<<<<<<<<<<
 *     cdef RegionBase child_region
 * 
 */

struct __pyx_vtabstruct_14_region_filter_Transform {
  struct __pyx_vtabstruct_14_region_filter_RegionBase __pyx_base;
  int (*_transform)(struct __pyx_obj_14_region_filter_Transform *, double, double, double *, double *);
};
static struct __pyx_vtabstruct_14_region_filter_Transform *__pyx_vtabptr_14_region_filter_Transform;


/* "_region_filter.pyx":607
 * 
 * 
 * cdef class Translated(Transform):             # <<<<<<<<<<<<<<
 *     """
 *     Translated region
 */

struct __pyx_vtabstruct_14_region_filter_Translated {
  struct __pyx_vtabstruct_14_region_filter_Transform __pyx_base;
};
static struct __pyx_vtabstruct_14_region_filter_Translated *__pyx_vtabptr_14_region_filter_Translated;


/* "_region_filter.pyx":55
 *     int (*update_metric)(Metric *m)
 * 
 * cdef class RegionContext:             # <<<<<<<<<<<<<<
 *     #cdef int (*init_metric)(Metric *m, double x0, double y0)
 *     cdef _RegionContext c
 */

struct __pyx_vtabstruct_14_region_filter_RegionContext {
  PyObject *(*set_update_func)(struct __pyx_obj_14_region_filter_RegionContext *, int (*)(struct __pyx_t_14_region_filter_Metric *));
};
static struct __pyx_vtabstruct_14_region_filter_RegionContext *__pyx_vtabptr_14_region_filter_RegionContext;


/* "_region_filter.pyx":683
 * 
 * 
 * cdef class Ellipse(RegionBase):             # <<<<<<<<<<<<<<
 *     """
 *     Ellipse
 */

struct __pyx_vtabstruct_14_region_filter_Ellipse {
  struct __pyx_vtabstruct_14_region_filter_RegionBase __pyx_base;
};
static struct __pyx_vtabstruct_14_region_filter_Ellipse *__pyx_vtabptr_14_region_filter_Ellipse;


/* "_region_filter.pyx":560
 * 
 * 
 * cdef class Rotated(Transform):             # <<<<<<<<<<<<<<
 *     """
 *     Rotated
 */

struct __pyx_vtabstruct_14_region_filter_Rotated {
  struct __pyx_vtabstruct_14_region_filter_Transform __pyx_base;
};
static struct __pyx_vtabstruct_14_region_filter_Rotated *__pyx_vtabptr_14_region_filter_Rotated;

#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif

#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, int);
    void (*DECREF)(void*, PyObject*, int);
    void (*GOTREF)(void*, PyObject*, int);
    void (*GIVEREF)(void*, PyObject*, int);
    void* (*SetupContext)(const char*, int, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule((char *)modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
  end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
  }
  #define __Pyx_RefNannySetupContext(name)           void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
  #define __Pyx_RefNannyFinishContext()           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
  #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
#else
  #define __Pyx_RefNannySetupContext(name)
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
#endif /* CYTHON_REFNANNY */
#define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
#define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/

static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict,
    const char* function_name, int kw_allowed); /*proto*/

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact); /*proto*/

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name, PyObject* kw_name); /*proto*/

static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/


static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
    PyObject *r;
    if (!j) return NULL;
    r = PyObject_GetItem(o, j);
    Py_DECREF(j);
    return r;
}


#define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_List_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
            PyObject *r = PyList_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}

#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Tuple_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
    if (likely(o != Py_None)) {
        if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
            PyObject *r = PyTuple_GET_ITEM(o, i);
            Py_INCREF(r);
            return r;
        }
        else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
            PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
            Py_INCREF(r);
            return r;
        }
    }
    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
}


#define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_GetItemInt_Fast(o, i) : \
                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))

static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
    PyObject *r;
    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        r = PyList_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
        r = PyTuple_GET_ITEM(o, i);
        Py_INCREF(r);
    }
    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
        r = PySequence_GetItem(o, i);
    }
    else {
        r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
    }
    return r;
}

#define __Pyx_SetItemInt(o, i, v, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_SetItemInt_Fast(o, i, v) : \
                                                    __Pyx_SetItemInt_Generic(o, to_py_func(i), v))

static CYTHON_INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
    int r;
    if (!j) return -1;
    r = PyObject_SetItem(o, j, v);
    Py_DECREF(j);
    return r;
}

static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v) {
    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
        Py_INCREF(v);
        Py_DECREF(PyList_GET_ITEM(o, i));
        PyList_SET_ITEM(o, i, v);
        return 1;
    }
    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_ass_item && (likely(i >= 0)))
        return PySequence_SetItem(o, i, v);
    else {
        PyObject *j = PyInt_FromSsize_t(i);
        return __Pyx_SetItemInt_Generic(o, j, v);
    }
}

#define __Pyx_DelItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
                                                    __Pyx_DelItemInt_Fast(o, i) : \
                                                    __Pyx_DelItem_Generic(o, to_py_func(i)))

static CYTHON_INLINE int __Pyx_DelItem_Generic(PyObject *o, PyObject *j) {
    int r;
    if (!j) return -1;
    r = PyObject_DelItem(o, j);
    Py_DECREF(j);
    return r;
}

static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i) {
    if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_ass_item && likely(i >= 0))
        return PySequence_DelItem(o, i);
    else {
        PyObject *j = PyInt_FromSsize_t(i);
        return __Pyx_DelItem_Generic(o, j);
    }
}

static CYTHON_INLINE long __Pyx_NegateNonNeg(long b) { return unlikely(b < 0) ? b : !b; }
static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
    return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
}

static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases); /*proto*/

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
                                   PyObject *modname); /*proto*/

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_bool(npy_bool);

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);

static void __Pyx_WriteUnraisable(const char *name); /*proto*/

static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/

static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size, int strict);  /*proto*/

static PyObject *__Pyx_ImportModule(const char *name); /*proto*/

static void __Pyx_AddTraceback(const char *funcname); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
/* Module declarations from numpy */

/* Module declarations from c_numpy */

static PyTypeObject *__pyx_ptype_7c_numpy_dtype = 0;
static PyTypeObject *__pyx_ptype_7c_numpy_ndarray = 0;
static PyTypeObject *__pyx_ptype_7c_numpy_flatiter = 0;
static PyTypeObject *__pyx_ptype_7c_numpy_broadcast = 0;
/* Module declarations from c_python */

/* Module declarations from _region_filter */

static PyTypeObject *__pyx_ptype_14_region_filter_RegionContext = 0;
static PyTypeObject *__pyx_ptype_14_region_filter_RegionBase = 0;
static PyTypeObject *__pyx_ptype_14_region_filter_RegionNot = 0;
static PyTypeObject *__pyx_ptype_14_region_filter_RegionList = 0;
static PyTypeObject *__pyx_ptype_14_region_filter_RegionOrList = 0;
static PyTypeObject *__pyx_ptype_14_region_filter_RegionAndList = 0;
static PyTypeObject *__pyx_ptype_14_region_filter_Transform = 0;
static PyTypeObject *__pyx_ptype_14_region_filter_Rotated = 0;
static PyTypeObject *__pyx_ptype_14_region_filter_Translated = 0;
static PyTypeObject *__pyx_ptype_14_region_filter_Circle = 0;
static PyTypeObject *__pyx_ptype_14_region_filter_Ellipse = 0;
static PyTypeObject *__pyx_ptype_14_region_filter_Box = 0;
static PyTypeObject *__pyx_ptype_14_region_filter_Polygon = 0;
static PyTypeObject *__pyx_ptype_14_region_filter_AngleRange = 0;
static struct __pyx_obj_14_region_filter_RegionContext *__pyx_v_14_region_filter_metric_wcs = 0;
static int __pyx_f_14_region_filter_MetricSetOrigin(struct __pyx_t_14_region_filter_Metric *, double, double); /*proto*/
static int __pyx_f_14_region_filter__update_metric_default(struct __pyx_t_14_region_filter_Metric *); /*proto*/
static int __pyx_f_14_region_filter__update_metric_wcs(struct __pyx_t_14_region_filter_Metric *); /*proto*/
#define __Pyx_MODULE_NAME "_region_filter"
static int __pyx_module_is_main__region_filter = 0;

/* Implementation of _region_filter */
static PyObject *__pyx_builtin_Exception;
static PyObject *__pyx_builtin_ValueError;
static PyObject *__pyx_builtin_TypeError;
static char __pyx_k_1[] = "BaseClassInitException";
static char __pyx_k_2[] = "RegionFilterException";
static char __pyx_k_3[] = "the inut needs to be a numpy 2-d array or a tuple of two integers";
static char __pyx_k_5[] = "shape of the input image must be 2d: %s is given";
static char __pyx_k_6[] = "input array has a wrong shape";
static char __pyx_k_8[] = "All elements should be subclass of RegionBase type: %s";
static char __pyx_k_9[] = "Circle(%f, %f, %f)";
static char __pyx_k_10[] = "radius_major_2_radius_minor_2";
static char __pyx_k_11[] = "Ellipse(%f, %f, %f, %f)";
static char __pyx_k_12[] = "AngleRange(%f, %f, %f, %f)";
static char __pyx_k_13[] = "RegionAnd (line 409)";
static char __pyx_k_14[] = "\n    >>> r = RegionAnd(reg1, reg2)\n    ";
static char __pyx_k_15[] = "RegionOr (line 426)";
static char __pyx_k_16[] = "\n    >>> r = RegionOr(reg1, reg2)\n    ";
static char __pyx_k__c[] = "c";
static char __pyx_k__m[] = "m";
static char __pyx_k__n[] = "n";
static char __pyx_k__x[] = "x";
static char __pyx_k__y[] = "y";
static char __pyx_k__Or[] = "Or";
static char __pyx_k__dx[] = "dx";
static char __pyx_k__dy[] = "dy";
static char __pyx_k__nd[] = "nd";
static char __pyx_k__x0[] = "x0";
static char __pyx_k__x1[] = "x1";
static char __pyx_k__x2[] = "x2";
static char __pyx_k__xa[] = "xa";
static char __pyx_k__xc[] = "xc";
static char __pyx_k__y0[] = "y0";
static char __pyx_k__y1[] = "y1";
static char __pyx_k__y2[] = "y2";
static char __pyx_k__ya[] = "ya";
static char __pyx_k__yc[] = "yc";
static char __pyx_k__And[] = "And";
static char __pyx_k__g_x[] = "g_x";
static char __pyx_k__g_y[] = "g_y";
static char __pyx_k___mask[] = "_mask";
static char __pyx_k__shape[] = "shape";
static char __pyx_k__width[] = "width";
static char __pyx_k___set_v[] = "_set_v";
static char __pyx_k__asList[] = "asList";
static char __pyx_k__degree[] = "degree";
static char __pyx_k__height[] = "height";
static char __pyx_k__radius[] = "radius";
static char __pyx_k___inside[] = "_inside";
static char __pyx_k__degree1[] = "degree1";
static char __pyx_k__degree2[] = "degree2";
static char __pyx_k__radian1[] = "radian1";
static char __pyx_k__radian2[] = "radian2";
static char __pyx_k__radius2[] = "radius2";
static char __pyx_k__region1[] = "region1";
static char __pyx_k__region2[] = "region2";
static char __pyx_k__RegionOr[] = "RegionOr";
static char __pyx_k____init__[] = "__init__";
static char __pyx_k____main__[] = "__main__";
static char __pyx_k____test__[] = "__test__";
static char __pyx_k__origin_x[] = "origin_x";
static char __pyx_k__origin_y[] = "origin_y";
static char __pyx_k__Exception[] = "Exception";
static char __pyx_k__RegionAnd[] = "RegionAnd";
static char __pyx_k__TypeError[] = "TypeError";
static char __pyx_k__cos_theta[] = "cos_theta";
static char __pyx_k__inside_xy[] = "inside_xy";
static char __pyx_k__sin_theta[] = "sin_theta";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k___fix_angle[] = "_fix_angle";
static char __pyx_k___transform[] = "_transform";
static char __pyx_k__dimensions[] = "dimensions";
static char __pyx_k__inside_x_y[] = "inside_x_y";
static char __pyx_k__set_context[] = "set_context";
static char __pyx_k__child_region[] = "child_region";
static char __pyx_k__radius_major[] = "radius_major";
static char __pyx_k__radius_minor[] = "radius_minor";
static char __pyx_k__child_regions[] = "child_regions";
static char __pyx_k__update_metric[] = "update_metric";
static char __pyx_k___region_filter[] = "_region_filter";
static char __pyx_k__radius_major_2[] = "radius_major_2";
static char __pyx_k__radius_minor_2[] = "radius_minor_2";
static char __pyx_k__set_update_func[] = "set_update_func";
static char __pyx_k__NotYetImplemented[] = "NotYetImplemented";
static char __pyx_k__metric_set_origin[] = "metric_set_origin";
static char __pyx_k___check_type_of_list[] = "_check_type_of_list";
static PyObject *__pyx_n_s_1;
static PyObject *__pyx_n_s_10;
static PyObject *__pyx_kp_s_11;
static PyObject *__pyx_kp_s_12;
static PyObject *__pyx_kp_u_13;
static PyObject *__pyx_kp_u_14;
static PyObject *__pyx_kp_u_15;
static PyObject *__pyx_kp_u_16;
static PyObject *__pyx_n_s_2;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_kp_s_5;
static PyObject *__pyx_kp_s_6;
static PyObject *__pyx_kp_s_8;
static PyObject *__pyx_kp_s_9;
static PyObject *__pyx_n_s__And;
static PyObject *__pyx_n_s__Exception;
static PyObject *__pyx_n_s__NotYetImplemented;
static PyObject *__pyx_n_s__Or;
static PyObject *__pyx_n_s__RegionAnd;
static PyObject *__pyx_n_s__RegionOr;
static PyObject *__pyx_n_s__TypeError;
static PyObject *__pyx_n_s__ValueError;
static PyObject *__pyx_n_s____init__;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
static PyObject *__pyx_n_s___check_type_of_list;
static PyObject *__pyx_n_s___fix_angle;
static PyObject *__pyx_n_s___inside;
static PyObject *__pyx_n_s___mask;
static PyObject *__pyx_n_s___region_filter;
static PyObject *__pyx_n_s___set_v;
static PyObject *__pyx_n_s___transform;
static PyObject *__pyx_n_s__asList;
static PyObject *__pyx_n_s__c;
static PyObject *__pyx_n_s__child_region;
static PyObject *__pyx_n_s__child_regions;
static PyObject *__pyx_n_s__cos_theta;
static PyObject *__pyx_n_s__degree;
static PyObject *__pyx_n_s__degree1;
static PyObject *__pyx_n_s__degree2;
static PyObject *__pyx_n_s__dimensions;
static PyObject *__pyx_n_s__dx;
static PyObject *__pyx_n_s__dy;
static PyObject *__pyx_n_s__g_x;
static PyObject *__pyx_n_s__g_y;
static PyObject *__pyx_n_s__height;
static PyObject *__pyx_n_s__inside_x_y;
static PyObject *__pyx_n_s__inside_xy;
static PyObject *__pyx_n_s__m;
static PyObject *__pyx_n_s__metric_set_origin;
static PyObject *__pyx_n_s__n;
static PyObject *__pyx_n_s__nd;
static PyObject *__pyx_n_s__origin_x;
static PyObject *__pyx_n_s__origin_y;
static PyObject *__pyx_n_s__radian1;
static PyObject *__pyx_n_s__radian2;
static PyObject *__pyx_n_s__radius;
static PyObject *__pyx_n_s__radius2;
static PyObject *__pyx_n_s__radius_major;
static PyObject *__pyx_n_s__radius_major_2;
static PyObject *__pyx_n_s__radius_minor;
static PyObject *__pyx_n_s__radius_minor_2;
static PyObject *__pyx_n_s__region1;
static PyObject *__pyx_n_s__region2;
static PyObject *__pyx_n_s__set_context;
static PyObject *__pyx_n_s__set_update_func;
static PyObject *__pyx_n_s__shape;
static PyObject *__pyx_n_s__sin_theta;
static PyObject *__pyx_n_s__update_metric;
static PyObject *__pyx_n_s__width;
static PyObject *__pyx_n_s__x;
static PyObject *__pyx_n_s__x0;
static PyObject *__pyx_n_s__x1;
static PyObject *__pyx_n_s__x2;
static PyObject *__pyx_n_s__xa;
static PyObject *__pyx_n_s__xc;
static PyObject *__pyx_n_s__y;
static PyObject *__pyx_n_s__y0;
static PyObject *__pyx_n_s__y1;
static PyObject *__pyx_n_s__y2;
static PyObject *__pyx_n_s__ya;
static PyObject *__pyx_n_s__yc;
static PyObject *__pyx_int_2;
static PyObject *__pyx_k_tuple_4;
static PyObject *__pyx_k_tuple_7;

/* "_region_filter.pyx":45
 * 
 * 
 * cdef int MetricSetOrigin(Metric *m, double x0, double y0):             # <<<<<<<<<<<<<<
 *     m.x0 = x0
 *     m.y0 = y0
 */

static  int __pyx_f_14_region_filter_MetricSetOrigin(struct __pyx_t_14_region_filter_Metric *__pyx_v_m, double __pyx_v_x0, double __pyx_v_y0) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("MetricSetOrigin");

  /* "_region_filter.pyx":46
 * 
 * cdef int MetricSetOrigin(Metric *m, double x0, double y0):
 *     m.x0 = x0             # <<<<<<<<<<<<<<
 *     m.y0 = y0
 *     #m.g_x = 1.
 */
  __pyx_v_m->x0 = __pyx_v_x0;

  /* "_region_filter.pyx":47
 * cdef int MetricSetOrigin(Metric *m, double x0, double y0):
 *     m.x0 = x0
 *     m.y0 = y0             # <<<<<<<<<<<<<<
 *     #m.g_x = 1.
 *     #m.g_y = 1.
 */
  __pyx_v_m->y0 = __pyx_v_y0;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":59
 *     cdef _RegionContext c
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         pass
 * 
 */

static int __pyx_pf_14_region_filter_13RegionContext___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_14_region_filter_13RegionContext___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":62
 *         pass
 * 
 *     cdef set_update_func(self, int (*update_metric)(Metric *m)):             # <<<<<<<<<<<<<<
 *         self.c.update_metric = update_metric
 * 
 */

static  PyObject *__pyx_f_14_region_filter_13RegionContext_set_update_func(struct __pyx_obj_14_region_filter_RegionContext *__pyx_v_self, int (*__pyx_v_update_metric)(struct __pyx_t_14_region_filter_Metric *)) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("set_update_func");

  /* "_region_filter.pyx":63
 * 
 *     cdef set_update_func(self, int (*update_metric)(Metric *m)):
 *         self.c.update_metric = update_metric             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_self->c.update_metric = __pyx_v_update_metric;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":66
 * 
 * 
 * cdef int _update_metric_default(Metric *m):             # <<<<<<<<<<<<<<
 *     m.g_x = 1.
 *     m.g_y = 1.
 */

static  int __pyx_f_14_region_filter__update_metric_default(struct __pyx_t_14_region_filter_Metric *__pyx_v_m) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("_update_metric_default");

  /* "_region_filter.pyx":67
 * 
 * cdef int _update_metric_default(Metric *m):
 *     m.g_x = 1.             # <<<<<<<<<<<<<<
 *     m.g_y = 1.
 * 
 */
  __pyx_v_m->g_x = 1.;

  /* "_region_filter.pyx":68
 * cdef int _update_metric_default(Metric *m):
 *     m.g_x = 1.
 *     m.g_y = 1.             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_m->g_y = 1.;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":71
 * 
 * 
 * cdef int _update_metric_wcs(Metric *m):             # <<<<<<<<<<<<<<
 *     cdef double theta
 *     theta = m.y0/180.*3.1415926;
 */

static  int __pyx_f_14_region_filter__update_metric_wcs(struct __pyx_t_14_region_filter_Metric *__pyx_v_m) {
  double __pyx_v_theta;
  int __pyx_r;
  __Pyx_RefNannySetupContext("_update_metric_wcs");

  /* "_region_filter.pyx":73
 * cdef int _update_metric_wcs(Metric *m):
 *     cdef double theta
 *     theta = m.y0/180.*3.1415926;             # <<<<<<<<<<<<<<
 * 
 *     m.g_x = cos(theta)
 */
  __pyx_v_theta = ((__pyx_v_m->y0 / 180.) * 3.1415926);

  /* "_region_filter.pyx":75
 *     theta = m.y0/180.*3.1415926;
 * 
 *     m.g_x = cos(theta)             # <<<<<<<<<<<<<<
 *     m.g_y = 1.
 * 
 */
  __pyx_v_m->g_x = cos(__pyx_v_theta);

  /* "_region_filter.pyx":76
 * 
 *     m.g_x = cos(theta)
 *     m.g_y = 1.             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_m->g_y = 1.;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":102
 *     #    MetricInit(&(self.m), xc, yc)
 * 
 *     def __init__(self):             # <<<<<<<<<<<<<<
 *         #selc.c = metric_default
 *         #self.update_context(metric_default)
 */

static int __pyx_pf_14_region_filter_10RegionBase___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_14_region_filter_10RegionBase___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;

  /* "_region_filter.pyx":106
 *         #self.update_context(metric_default)
 *         #MetricInit(&(self.m), x0, y0)
 *         raise BaseClassInitException()             # <<<<<<<<<<<<<<
 * 
 *     cdef update_metric(self):
 */
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_Raise(__pyx_t_2, 0, 0);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("_region_filter.RegionBase.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":108
 *         raise BaseClassInitException()
 * 
 *     cdef update_metric(self):             # <<<<<<<<<<<<<<
 *         if self.c:
 *             self.c.c.update_metric(&(self.m))
 */

static  PyObject *__pyx_f_14_region_filter_10RegionBase_update_metric(struct __pyx_obj_14_region_filter_RegionBase *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("update_metric");

  /* "_region_filter.pyx":109
 * 
 *     cdef update_metric(self):
 *         if self.c:             # <<<<<<<<<<<<<<
 *             self.c.c.update_metric(&(self.m))
 *         else:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_self->c)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "_region_filter.pyx":110
 *     cdef update_metric(self):
 *         if self.c:
 *             self.c.c.update_metric(&(self.m))             # <<<<<<<<<<<<<<
 *         else:
 *             _update_metric_default(&(self.m))
 */
    __pyx_v_self->c->c.update_metric((&__pyx_v_self->m));
    goto __pyx_L3;
  }
  /*else*/ {

    /* "_region_filter.pyx":112
 *             self.c.c.update_metric(&(self.m))
 *         else:
 *             _update_metric_default(&(self.m))             # <<<<<<<<<<<<<<
 * 
 *     def set_context(self, RegionContext cnt):
 */
    __pyx_f_14_region_filter__update_metric_default((&__pyx_v_self->m));
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("_region_filter.RegionBase.update_metric");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":114
 *             _update_metric_default(&(self.m))
 * 
 *     def set_context(self, RegionContext cnt):             # <<<<<<<<<<<<<<
 *         self.c = cnt
 *         self.update_metric()
 */

static PyObject *__pyx_pf_14_region_filter_10RegionBase_1set_context(PyObject *__pyx_v_self, PyObject *__pyx_v_cnt); /*proto*/
static PyObject *__pyx_pf_14_region_filter_10RegionBase_1set_context(PyObject *__pyx_v_self, PyObject *__pyx_v_cnt) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("set_context");
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cnt), __pyx_ptype_14_region_filter_RegionContext, 1, "cnt", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "_region_filter.pyx":115
 * 
 *     def set_context(self, RegionContext cnt):
 *         self.c = cnt             # <<<<<<<<<<<<<<
 *         self.update_metric()
 * 
 */
  __Pyx_INCREF(__pyx_v_cnt);
  __Pyx_GIVEREF(__pyx_v_cnt);
  __Pyx_GOTREF(((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self)->c);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self)->c));
  ((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self)->c = ((struct __pyx_obj_14_region_filter_RegionContext *)__pyx_v_cnt);

  /* "_region_filter.pyx":116
 *     def set_context(self, RegionContext cnt):
 *         self.c = cnt
 *         self.update_metric()             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_14_region_filter_RegionBase *)((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self)->__pyx_vtab)->update_metric(((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("_region_filter.RegionBase.set_context");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":119
 * 
 * 
 *     cdef metric_set_origin(self, double xc, double yc,             # <<<<<<<<<<<<<<
 *                            RegionContext cnt):
 * 
 */

static  PyObject *__pyx_f_14_region_filter_10RegionBase_metric_set_origin(struct __pyx_obj_14_region_filter_RegionBase *__pyx_v_self, double __pyx_v_xc, double __pyx_v_yc, struct __pyx_obj_14_region_filter_RegionContext *__pyx_v_cnt) {
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("metric_set_origin");

  /* "_region_filter.pyx":122
 *                            RegionContext cnt):
 * 
 *         MetricSetOrigin(&(self.m), xc, yc)             # <<<<<<<<<<<<<<
 *         if cnt:
 *             self.set_context(cnt)
 */
  __pyx_f_14_region_filter_MetricSetOrigin((&__pyx_v_self->m), __pyx_v_xc, __pyx_v_yc);

  /* "_region_filter.pyx":123
 * 
 *         MetricSetOrigin(&(self.m), xc, yc)
 *         if cnt:             # <<<<<<<<<<<<<<
 *             self.set_context(cnt)
 *         else:
 */
  __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_cnt)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "_region_filter.pyx":124
 *         MetricSetOrigin(&(self.m), xc, yc)
 *         if cnt:
 *             self.set_context(cnt)             # <<<<<<<<<<<<<<
 *         else:
 *             self.update_metric()
 */
    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__set_context); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_INCREF(((PyObject *)__pyx_v_cnt));
    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_cnt));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_cnt));
    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "_region_filter.pyx":126
 *             self.set_context(cnt)
 *         else:
 *             self.update_metric()             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_t_4 = ((struct __pyx_vtabstruct_14_region_filter_RegionBase *)__pyx_v_self->__pyx_vtab)->update_metric(__pyx_v_self); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  }
  __pyx_L3:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("_region_filter.RegionBase.metric_set_origin");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":130
 * 
 * 
 *     def __invert__(self):             # <<<<<<<<<<<<<<
 *         return RegionNot(self)
 * 
 */

static PyObject *__pyx_pf_14_region_filter_10RegionBase_2__invert__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_14_region_filter_10RegionBase_2__invert__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__invert__");

  /* "_region_filter.pyx":131
 * 
 *     def __invert__(self):
 *         return RegionNot(self)             # <<<<<<<<<<<<<<
 * 
 *     def __and__(self, RegionBase o):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14_region_filter_RegionNot)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("_region_filter.RegionBase.__invert__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":133
 *         return RegionNot(self)
 * 
 *     def __and__(self, RegionBase o):             # <<<<<<<<<<<<<<
 *         return RegionAnd(self, o)
 * 
 */

static PyObject *__pyx_pf_14_region_filter_10RegionBase_3__and__(PyObject *__pyx_v_self, PyObject *__pyx_v_o); /*proto*/
static PyObject *__pyx_pf_14_region_filter_10RegionBase_3__and__(PyObject *__pyx_v_self, PyObject *__pyx_v_o) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__and__");
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_o), __pyx_ptype_14_region_filter_RegionBase, 1, "o", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "_region_filter.pyx":134
 * 
 *     def __and__(self, RegionBase o):
 *         return RegionAnd(self, o)             # <<<<<<<<<<<<<<
 * 
 *     def __or__(self, RegionBase o):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__RegionAnd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  __Pyx_INCREF(__pyx_v_o);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_o);
  __Pyx_GIVEREF(__pyx_v_o);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("_region_filter.RegionBase.__and__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":136
 *         return RegionAnd(self, o)
 * 
 *     def __or__(self, RegionBase o):             # <<<<<<<<<<<<<<
 *         return RegionOr(self, o)
 * 
 */

static PyObject *__pyx_pf_14_region_filter_10RegionBase_4__or__(PyObject *__pyx_v_self, PyObject *__pyx_v_o); /*proto*/
static PyObject *__pyx_pf_14_region_filter_10RegionBase_4__or__(PyObject *__pyx_v_self, PyObject *__pyx_v_o) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__or__");
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_o), __pyx_ptype_14_region_filter_RegionBase, 1, "o", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "_region_filter.pyx":137
 * 
 *     def __or__(self, RegionBase o):
 *         return RegionOr(self, o)             # <<<<<<<<<<<<<<
 * 
 *     cdef npy_bool _inside(self, double x, double y):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__RegionOr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  __Pyx_INCREF(__pyx_v_o);
  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_o);
  __Pyx_GIVEREF(__pyx_v_o);
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("_region_filter.RegionBase.__or__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":139
 *         return RegionOr(self, o)
 * 
 *     cdef npy_bool _inside(self, double x, double y):             # <<<<<<<<<<<<<<
 *         return (0)
 * 
 */

static  npy_bool __pyx_f_14_region_filter_10RegionBase__inside(struct __pyx_obj_14_region_filter_RegionBase *__pyx_v_self, double __pyx_v_x, double __pyx_v_y) {
  npy_bool __pyx_r;
  __Pyx_RefNannySetupContext("_inside");

  /* "_region_filter.pyx":140
 * 
 *     cdef npy_bool _inside(self, double x, double y):
 *         return (0)             # <<<<<<<<<<<<<<
 * 
 *     def mask(self, img_or_shape):
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":142
 *         return (0)
 * 
 *     def mask(self, img_or_shape):             # <<<<<<<<<<<<<<
 *         """
 *         Create a mask ( a 2-d image whose pixel value is 1 if the
 */

static PyObject *__pyx_pf_14_region_filter_10RegionBase_5mask(PyObject *__pyx_v_self, PyObject *__pyx_v_img_or_shape); /*proto*/
static char __pyx_doc_14_region_filter_10RegionBase_5mask[] = "\n        Create a mask ( a 2-d image whose pixel value is 1 if the\n        pixel is inside the filter, otherwise 0). It takes a single\n        argument which is numpy 2d array (or any python object with\n        *shape* attribute) or a tuple of two integer representing the\n        image shape.\n        ";
static PyObject *__pyx_pf_14_region_filter_10RegionBase_5mask(PyObject *__pyx_v_self, PyObject *__pyx_v_img_or_shape) {
  int __pyx_v_nx;
  int __pyx_v_ny;
  PyObject *__pyx_v_shape;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("mask");
  __pyx_v_shape = Py_None; __Pyx_INCREF(Py_None);

  /* "_region_filter.pyx":153
 *         cdef int l, nx, ny
 * 
 *         if hasattr(img_or_shape, "shape"):             # <<<<<<<<<<<<<<
 *             shape = img_or_shape.shape
 *         elif c_python.PySequence_Check(img_or_shape):
 */
  __pyx_t_1 = PyObject_HasAttr(__pyx_v_img_or_shape, ((PyObject *)__pyx_n_s__shape)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_t_1) {

    /* "_region_filter.pyx":154
 * 
 *         if hasattr(img_or_shape, "shape"):
 *             shape = img_or_shape.shape             # <<<<<<<<<<<<<<
 *         elif c_python.PySequence_Check(img_or_shape):
 *             shape = img_or_shape
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_img_or_shape, __pyx_n_s__shape); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_v_shape);
    __pyx_v_shape = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L5;
  }

  /* "_region_filter.pyx":155
 *         if hasattr(img_or_shape, "shape"):
 *             shape = img_or_shape.shape
 *         elif c_python.PySequence_Check(img_or_shape):             # <<<<<<<<<<<<<<
 *             shape = img_or_shape
 *         else:
 */
  __pyx_t_3 = PySequence_Check(__pyx_v_img_or_shape);
  if (__pyx_t_3) {

    /* "_region_filter.pyx":156
 *             shape = img_or_shape.shape
 *         elif c_python.PySequence_Check(img_or_shape):
 *             shape = img_or_shape             # <<<<<<<<<<<<<<
 *         else:
 *             raise RegionFilterException("the inut needs to be a numpy 2-d array or a tuple of two integers")
 */
    __Pyx_INCREF(__pyx_v_img_or_shape);
    __Pyx_DECREF(__pyx_v_shape);
    __pyx_v_shape = __pyx_v_img_or_shape;
    goto __pyx_L5;
  }
  /*else*/ {

    /* "_region_filter.pyx":158
 *             shape = img_or_shape
 *         else:
 *             raise RegionFilterException("the inut needs to be a numpy 2-d array or a tuple of two integers")             # <<<<<<<<<<<<<<
 * 
 *         if c_python.PySequence_Length(shape) != 2:
 */
    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_Raise(__pyx_t_4, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  }
  __pyx_L5:;

  /* "_region_filter.pyx":160
 *             raise RegionFilterException("the inut needs to be a numpy 2-d array or a tuple of two integers")
 * 
 *         if c_python.PySequence_Length(shape) != 2:             # <<<<<<<<<<<<<<
 *             raise RegionFilterException("shape of the input image must be 2d: %s is given" % (str(shape)))
 * 
 */
  __pyx_t_1 = (PySequence_Length(__pyx_v_shape) != 2);
  if (__pyx_t_1) {

    /* "_region_filter.pyx":161
 * 
 *         if c_python.PySequence_Length(shape) != 2:
 *             raise RegionFilterException("shape of the input image must be 2d: %s is given" % (str(shape)))             # <<<<<<<<<<<<<<
 * 
 *         ny = c_python.PySequence_GetItem(shape, 0)
 */
    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_INCREF(__pyx_v_shape);
    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_shape);
    __Pyx_GIVEREF(__pyx_v_shape);
    __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2));
    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
    __pyx_t_2 = 0;
    __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
    __Pyx_Raise(__pyx_t_2, 0, 0);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    goto __pyx_L6;
  }
  __pyx_L6:;

  /* "_region_filter.pyx":163
 *             raise RegionFilterException("shape of the input image must be 2d: %s is given" % (str(shape)))
 * 
 *         ny = c_python.PySequence_GetItem(shape, 0)             # <<<<<<<<<<<<<<
 *         nx = c_python.PySequence_GetItem(shape, 1)
 * 
 */
  __pyx_t_2 = PySequence_GetItem(__pyx_v_shape, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_ny = __pyx_t_3;

  /* "_region_filter.pyx":164
 * 
 *         ny = c_python.PySequence_GetItem(shape, 0)
 *         nx = c_python.PySequence_GetItem(shape, 1)             # <<<<<<<<<<<<<<
 * 
 *         return self._mask(nx, ny)
 */
  __pyx_t_2 = PySequence_GetItem(__pyx_v_shape, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_nx = __pyx_t_3;

  /* "_region_filter.pyx":166
 *         nx = c_python.PySequence_GetItem(shape, 1)
 * 
 *         return self._mask(nx, ny)             # <<<<<<<<<<<<<<
 * 
 *     cdef c_numpy.ndarray _mask(self, c_numpy.npy_intp nx, c_numpy.npy_intp ny):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_14_region_filter_RegionBase *)((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self)->__pyx_vtab)->_mask(((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self), __pyx_v_nx, __pyx_v_ny)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("_region_filter.RegionBase.mask");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_shape);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":168
 *         return self._mask(nx, ny)
 * 
 *     cdef c_numpy.ndarray _mask(self, c_numpy.npy_intp nx, c_numpy.npy_intp ny):             # <<<<<<<<<<<<<<
 * 
 *         cdef c_numpy.npy_intp ny_nx[2]
 */

static  PyArrayObject *__pyx_f_14_region_filter_10RegionBase__mask(struct __pyx_obj_14_region_filter_RegionBase *__pyx_v_self, npy_intp __pyx_v_nx, npy_intp __pyx_v_ny) {
  npy_intp __pyx_v_ny_nx[2];
  PyArrayObject *__pyx_v_ra;
  npy_bool *__pyx_v_rd;
  int __pyx_v_iy;
  int __pyx_v_ix;
  PyArrayObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  npy_intp __pyx_t_2;
  npy_intp __pyx_t_3;
  __Pyx_RefNannySetupContext("_mask");
  __pyx_v_ra = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);

  /* "_region_filter.pyx":175
 *         cdef int iy, ix
 * 
 *         ny_nx[0] = ny             # <<<<<<<<<<<<<<
 *         ny_nx[1] = nx
 * 
 */
  (__pyx_v_ny_nx[0]) = __pyx_v_ny;

  /* "_region_filter.pyx":176
 * 
 *         ny_nx[0] = ny
 *         ny_nx[1] = nx             # <<<<<<<<<<<<<<
 * 
 *         ra = c_numpy.PyArray_EMPTY(2, ny_nx,
 */
  (__pyx_v_ny_nx[1]) = __pyx_v_nx;

  /* "_region_filter.pyx":179
 * 
 *         ra = c_numpy.PyArray_EMPTY(2, ny_nx,
 *                                    c_numpy.NPY_BOOL, 0)             # <<<<<<<<<<<<<<
 * 
 *         rd = <npy_bool *> c_numpy.PyArray_DATA(ra)
 */
  __pyx_t_1 = PyArray_EMPTY(2, __pyx_v_ny_nx, NPY_BOOL, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7c_numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_ra));
  __pyx_v_ra = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "_region_filter.pyx":181
 *                                    c_numpy.NPY_BOOL, 0)
 * 
 *         rd = <npy_bool *> c_numpy.PyArray_DATA(ra)             # <<<<<<<<<<<<<<
 * 
 *         for iy from 0 <= iy < ny:
 */
  __pyx_v_rd = ((npy_bool *)PyArray_DATA(__pyx_v_ra));

  /* "_region_filter.pyx":183
 *         rd = <npy_bool *> c_numpy.PyArray_DATA(ra)
 * 
 *         for iy from 0 <= iy < ny:             # <<<<<<<<<<<<<<
 *             for ix from 0 <= ix < nx:
 *                 #rd[iy*nx + ix] = self._inside(i, j)
 */
  __pyx_t_2 = __pyx_v_ny;
  for (__pyx_v_iy = 0; __pyx_v_iy < __pyx_t_2; __pyx_v_iy++) {

    /* "_region_filter.pyx":184
 * 
 *         for iy from 0 <= iy < ny:
 *             for ix from 0 <= ix < nx:             # <<<<<<<<<<<<<<
 *                 #rd[iy*nx + ix] = self._inside(i, j)
 *                 # altenatively more optimized
 */
    __pyx_t_3 = __pyx_v_nx;
    for (__pyx_v_ix = 0; __pyx_v_ix < __pyx_t_3; __pyx_v_ix++) {

      /* "_region_filter.pyx":188
 *                 # altenatively more optimized
 *                 #rd[0] = self._inside(ix+1, iy+1) # +1 for (1,1) based..
 *                 rd[0] = self._inside(ix, iy)             # <<<<<<<<<<<<<<
 *                 rd = rd + 1
 * 
 */
      (__pyx_v_rd[0]) = ((struct __pyx_vtabstruct_14_region_filter_RegionBase *)__pyx_v_self->__pyx_vtab)->_inside(__pyx_v_self, __pyx_v_ix, __pyx_v_iy);

      /* "_region_filter.pyx":189
 *                 #rd[0] = self._inside(ix+1, iy+1) # +1 for (1,1) based..
 *                 rd[0] = self._inside(ix, iy)
 *                 rd = rd + 1             # <<<<<<<<<<<<<<
 * 
 *         return ra
 */
      __pyx_v_rd = (__pyx_v_rd + 1);
    }
  }

  /* "_region_filter.pyx":191
 *                 rd = rd + 1
 * 
 *         return ra             # <<<<<<<<<<<<<<
 * 
 *     def inside1(self, double x, double y):
 */
  __Pyx_XDECREF(((PyObject *)__pyx_r));
  __Pyx_INCREF(((PyObject *)__pyx_v_ra));
  __pyx_r = __pyx_v_ra;
  goto __pyx_L0;

  __pyx_r = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("_region_filter.RegionBase._mask");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_ra);
  __Pyx_XGIVEREF((PyObject *)__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":193
 *         return ra
 * 
 *     def inside1(self, double x, double y):             # <<<<<<<<<<<<<<
 *         """
 *         inside1(float, float) : returns True if the point (x,y) is inside the filter.
 */

static PyObject *__pyx_pf_14_region_filter_10RegionBase_6inside1(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_14_region_filter_10RegionBase_6inside1[] = "\n        inside1(float, float) : returns True if the point (x,y) is inside the filter.\n        ";
static PyObject *__pyx_pf_14_region_filter_10RegionBase_6inside1(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_x;
  double __pyx_v_y;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__x,&__pyx_n_s__y,0};
  __Pyx_RefNannySetupContext("inside1");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("inside1", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "inside1") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_x = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_x == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_y = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_y == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_x = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_x == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_y = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_y == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("inside1", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("_region_filter.RegionBase.inside1");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "_region_filter.pyx":197
 *         inside1(float, float) : returns True if the point (x,y) is inside the filter.
 *         """
 *         return self._inside(x, y)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyInt_to_py_npy_bool(((struct __pyx_vtabstruct_14_region_filter_RegionBase *)((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self)->__pyx_vtab)->_inside(((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self), __pyx_v_x, __pyx_v_y)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("_region_filter.RegionBase.inside1");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":200
 * 
 * 
 *     def inside(self, x, y=None):             # <<<<<<<<<<<<<<
 *         if y is None:
 *             if len(x.shape) == 2 and x.shape[-1] == 2:
 */

static PyObject *__pyx_pf_14_region_filter_10RegionBase_7inside(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_pf_14_region_filter_10RegionBase_7inside(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_x = 0;
  PyObject *__pyx_v_y = 0;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__x,&__pyx_n_s__y,0};
  __Pyx_RefNannySetupContext("inside");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    values[1] = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y);
        if (value) { values[1] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "inside") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_x = values[0];
    __pyx_v_y = values[1];
  } else {
    __pyx_v_y = ((PyObject *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: __pyx_v_y = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: __pyx_v_x = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("inside", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("_region_filter.RegionBase.inside");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "_region_filter.pyx":201
 * 
 *     def inside(self, x, y=None):
 *         if y is None:             # <<<<<<<<<<<<<<
 *             if len(x.shape) == 2 and x.shape[-1] == 2:
 *                 return self.inside_xy(x)
 */
  __pyx_t_1 = (__pyx_v_y == Py_None);
  if (__pyx_t_1) {

    /* "_region_filter.pyx":202
 *     def inside(self, x, y=None):
 *         if y is None:
 *             if len(x.shape) == 2 and x.shape[-1] == 2:             # <<<<<<<<<<<<<<
 *                 return self.inside_xy(x)
 *             else:
 */
    __pyx_t_2 = PyObject_GetAttr(__pyx_v_x, __pyx_n_s__shape); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_1 = (__pyx_t_3 == 2);
    if (__pyx_t_1) {
      __pyx_t_2 = PyObject_GetAttr(__pyx_v_x, __pyx_n_s__shape); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_2, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_int_2, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_6 = __pyx_t_5;
    } else {
      __pyx_t_6 = __pyx_t_1;
    }
    if (__pyx_t_6) {

      /* "_region_filter.pyx":203
 *         if y is None:
 *             if len(x.shape) == 2 and x.shape[-1] == 2:
 *                 return self.inside_xy(x)             # <<<<<<<<<<<<<<
 *             else:
 *                 raise ValueError("input array has a wrong shape")
 */
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__inside_xy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
      __Pyx_INCREF(__pyx_v_x);
      PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_x);
      __Pyx_GIVEREF(__pyx_v_x);
      __pyx_t_7 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
      __pyx_r = __pyx_t_7;
      __pyx_t_7 = 0;
      goto __pyx_L0;
      goto __pyx_L7;
    }
    /*else*/ {

      /* "_region_filter.pyx":205
 *                 return self.inside_xy(x)
 *             else:
 *                 raise ValueError("input array has a wrong shape")             # <<<<<<<<<<<<<<
 *         else:
 *             return self.inside_x_y(x, y)
 */
      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_7), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_Raise(__pyx_t_7, 0, 0);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    }
    __pyx_L7:;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "_region_filter.pyx":207
 *                 raise ValueError("input array has a wrong shape")
 *         else:
 *             return self.inside_x_y(x, y)             # <<<<<<<<<<<<<<
 * 
 *     def inside_xy(self, xy):
 */
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__inside_x_y); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
    __Pyx_INCREF(__pyx_v_x);
    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_x);
    __Pyx_GIVEREF(__pyx_v_x);
    __Pyx_INCREF(__pyx_v_y);
    PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_y);
    __Pyx_GIVEREF(__pyx_v_y);
    __pyx_t_2 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
    __pyx_r = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L0;
  }
  __pyx_L6:;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("_region_filter.RegionBase.inside");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":209
 *             return self.inside_x_y(x, y)
 * 
 *     def inside_xy(self, xy):             # <<<<<<<<<<<<<<
 *         """
 *         inside(x, y) : given the numpy array of x and y, returns an
 */

static PyObject *__pyx_pf_14_region_filter_10RegionBase_8inside_xy(PyObject *__pyx_v_self, PyObject *__pyx_v_xy); /*proto*/
static char __pyx_doc_14_region_filter_10RegionBase_8inside_xy[] = "\n        inside(x, y) : given the numpy array of x and y, returns an\n        array b of same shape, where b[i] = inside1(x[i], y[i])\n        ";
static PyObject *__pyx_pf_14_region_filter_10RegionBase_8inside_xy(PyObject *__pyx_v_self, PyObject *__pyx_v_xy) {
  PyArrayObject *__pyx_v_xya;
  PyArrayObject *__pyx_v_ra;
  double *__pyx_v_xyd;
  npy_bool *__pyx_v_rd;
  int __pyx_v_i;
  int __pyx_v_n;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  __Pyx_RefNannySetupContext("inside_xy");
  __pyx_v_xya = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_ra = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);

  /* "_region_filter.pyx":221
 *         cdef int n
 * 
 *         xya = c_numpy.PyArray_ContiguousFromAny(xy, c_numpy.NPY_DOUBLE, 1, 0)             # <<<<<<<<<<<<<<
 * 
 *         ra = c_numpy.PyArray_EMPTY(1, xya.dimensions,
 */
  __pyx_t_1 = PyArray_ContiguousFromAny(__pyx_v_xy, NPY_DOUBLE, 1, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7c_numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_xya));
  __pyx_v_xya = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "_region_filter.pyx":224
 * 
 *         ra = c_numpy.PyArray_EMPTY(1, xya.dimensions,
 *                                    c_numpy.NPY_BOOL, 0)             # <<<<<<<<<<<<<<
 * 
 *         xyd = <double *> c_numpy.PyArray_DATA(xya)
 */
  __pyx_t_1 = PyArray_EMPTY(1, __pyx_v_xya->dimensions, NPY_BOOL, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7c_numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_ra));
  __pyx_v_ra = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "_region_filter.pyx":226
 *                                    c_numpy.NPY_BOOL, 0)
 * 
 *         xyd = <double *> c_numpy.PyArray_DATA(xya)             # <<<<<<<<<<<<<<
 *         rd = <npy_bool *> c_numpy.PyArray_DATA(ra)
 * 
 */
  __pyx_v_xyd = ((double *)PyArray_DATA(__pyx_v_xya));

  /* "_region_filter.pyx":227
 * 
 *         xyd = <double *> c_numpy.PyArray_DATA(xya)
 *         rd = <npy_bool *> c_numpy.PyArray_DATA(ra)             # <<<<<<<<<<<<<<
 * 
 *         n = xya.dimensions[0] # c_numpy.PyArray_SIZE(xya) / 2
 */
  __pyx_v_rd = ((npy_bool *)PyArray_DATA(__pyx_v_ra));

  /* "_region_filter.pyx":229
 *         rd = <npy_bool *> c_numpy.PyArray_DATA(ra)
 * 
 *         n = xya.dimensions[0] # c_numpy.PyArray_SIZE(xya) / 2             # <<<<<<<<<<<<<<
 *         #_inside_ptr = self._inside
 *         for i from 0 <= i < n:
 */
  __pyx_v_n = (__pyx_v_xya->dimensions[0]);

  /* "_region_filter.pyx":231
 *         n = xya.dimensions[0] # c_numpy.PyArray_SIZE(xya) / 2
 *         #_inside_ptr = self._inside
 *         for i from 0 <= i < n:             # <<<<<<<<<<<<<<
 *             rd[i] = self._inside(xyd[2*i], xyd[2*i+1])
 *         return ra
 */
  __pyx_t_2 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "_region_filter.pyx":232
 *         #_inside_ptr = self._inside
 *         for i from 0 <= i < n:
 *             rd[i] = self._inside(xyd[2*i], xyd[2*i+1])             # <<<<<<<<<<<<<<
 *         return ra
 * 
 */
    (__pyx_v_rd[__pyx_v_i]) = ((struct __pyx_vtabstruct_14_region_filter_RegionBase *)((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self)->__pyx_vtab)->_inside(((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self), (__pyx_v_xyd[(2 * __pyx_v_i)]), (__pyx_v_xyd[((2 * __pyx_v_i) + 1)]));
  }

  /* "_region_filter.pyx":233
 *         for i from 0 <= i < n:
 *             rd[i] = self._inside(xyd[2*i], xyd[2*i+1])
 *         return ra             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_ra));
  __pyx_r = ((PyObject *)__pyx_v_ra);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("_region_filter.RegionBase.inside_xy");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_xya);
  __Pyx_DECREF((PyObject *)__pyx_v_ra);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":236
 * 
 * 
 *     def inside_x_y(self, x, y):             # <<<<<<<<<<<<<<
 *         """
 *         inside(x, y) : given the numpy array of x and y, returns an
 */

static PyObject *__pyx_pf_14_region_filter_10RegionBase_9inside_x_y(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_14_region_filter_10RegionBase_9inside_x_y[] = "\n        inside(x, y) : given the numpy array of x and y, returns an\n        array b of same shape, where b[i] = inside1(x[i], y[i])\n        ";
static PyObject *__pyx_pf_14_region_filter_10RegionBase_9inside_x_y(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_x = 0;
  PyObject *__pyx_v_y = 0;
  PyArrayObject *__pyx_v_xa;
  PyArrayObject *__pyx_v_ya;
  PyArrayObject *__pyx_v_ra;
  double *__pyx_v_xd;
  double *__pyx_v_yd;
  npy_bool *__pyx_v_rd;
  int __pyx_v_i;
  int __pyx_v_n;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__x,&__pyx_n_s__y,0};
  __Pyx_RefNannySetupContext("inside_x_y");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("inside_x_y", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "inside_x_y") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_x = values[0];
    __pyx_v_y = values[1];
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_x = PyTuple_GET_ITEM(__pyx_args, 0);
    __pyx_v_y = PyTuple_GET_ITEM(__pyx_args, 1);
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("inside_x_y", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("_region_filter.RegionBase.inside_x_y");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_xa = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_ya = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
  __pyx_v_ra = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);

  /* "_region_filter.pyx":253
 *         # FIX : check if two input has identical shape
 * 
 *         xa = c_numpy.PyArray_ContiguousFromAny(x, c_numpy.NPY_DOUBLE, 1, 0)             # <<<<<<<<<<<<<<
 *         ya = c_numpy.PyArray_ContiguousFromAny(y, c_numpy.NPY_DOUBLE, 1, 0)
 * 
 */
  __pyx_t_1 = PyArray_ContiguousFromAny(__pyx_v_x, NPY_DOUBLE, 1, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7c_numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_xa));
  __pyx_v_xa = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "_region_filter.pyx":254
 * 
 *         xa = c_numpy.PyArray_ContiguousFromAny(x, c_numpy.NPY_DOUBLE, 1, 0)
 *         ya = c_numpy.PyArray_ContiguousFromAny(y, c_numpy.NPY_DOUBLE, 1, 0)             # <<<<<<<<<<<<<<
 * 
 *         ra = c_numpy.PyArray_EMPTY(xa.nd, xa.dimensions,
 */
  __pyx_t_1 = PyArray_ContiguousFromAny(__pyx_v_y, NPY_DOUBLE, 1, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7c_numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_ya));
  __pyx_v_ya = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "_region_filter.pyx":257
 * 
 *         ra = c_numpy.PyArray_EMPTY(xa.nd, xa.dimensions,
 *                                    c_numpy.NPY_BOOL, 0)             # <<<<<<<<<<<<<<
 * 
 *         xd = <double *> c_numpy.PyArray_DATA(xa)
 */
  __pyx_t_1 = PyArray_EMPTY(__pyx_v_xa->nd, __pyx_v_xa->dimensions, NPY_BOOL, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7c_numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_v_ra));
  __pyx_v_ra = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "_region_filter.pyx":259
 *                                    c_numpy.NPY_BOOL, 0)
 * 
 *         xd = <double *> c_numpy.PyArray_DATA(xa)             # <<<<<<<<<<<<<<
 *         yd = <double *> c_numpy.PyArray_DATA(ya)
 *         rd = <npy_bool *> c_numpy.PyArray_DATA(ra)
 */
  __pyx_v_xd = ((double *)PyArray_DATA(__pyx_v_xa));

  /* "_region_filter.pyx":260
 * 
 *         xd = <double *> c_numpy.PyArray_DATA(xa)
 *         yd = <double *> c_numpy.PyArray_DATA(ya)             # <<<<<<<<<<<<<<
 *         rd = <npy_bool *> c_numpy.PyArray_DATA(ra)
 * 
 */
  __pyx_v_yd = ((double *)PyArray_DATA(__pyx_v_ya));

  /* "_region_filter.pyx":261
 *         xd = <double *> c_numpy.PyArray_DATA(xa)
 *         yd = <double *> c_numpy.PyArray_DATA(ya)
 *         rd = <npy_bool *> c_numpy.PyArray_DATA(ra)             # <<<<<<<<<<<<<<
 * 
 *         n = c_numpy.PyArray_SIZE(xa)
 */
  __pyx_v_rd = ((npy_bool *)PyArray_DATA(__pyx_v_ra));

  /* "_region_filter.pyx":263
 *         rd = <npy_bool *> c_numpy.PyArray_DATA(ra)
 * 
 *         n = c_numpy.PyArray_SIZE(xa)             # <<<<<<<<<<<<<<
 *         #_inside_ptr = self._inside
 *         for i from 0 <= i < n:
 */
  __pyx_v_n = PyArray_SIZE(__pyx_v_xa);

  /* "_region_filter.pyx":265
 *         n = c_numpy.PyArray_SIZE(xa)
 *         #_inside_ptr = self._inside
 *         for i from 0 <= i < n:             # <<<<<<<<<<<<<<
 *             #self._inside(xd[0], yd[0])
 *             #rd[i] = _inside_ptr(self, xd[i], yd[i])
 */
  __pyx_t_2 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) {

    /* "_region_filter.pyx":268
 *             #self._inside(xd[0], yd[0])
 *             #rd[i] = _inside_ptr(self, xd[i], yd[i])
 *             rd[i] = self._inside(xd[i], yd[i])             # <<<<<<<<<<<<<<
 *             #rd[i] = _inside_ptr(self, xd[i], yd[i])
 *             #print xd[i], yd[i], rd[i]
 */
    (__pyx_v_rd[__pyx_v_i]) = ((struct __pyx_vtabstruct_14_region_filter_RegionBase *)((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self)->__pyx_vtab)->_inside(((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self), (__pyx_v_xd[__pyx_v_i]), (__pyx_v_yd[__pyx_v_i]));
  }

  /* "_region_filter.pyx":271
 *             #rd[i] = _inside_ptr(self, xd[i], yd[i])
 *             #print xd[i], yd[i], rd[i]
 *         return ra             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)__pyx_v_ra));
  __pyx_r = ((PyObject *)__pyx_v_ra);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("_region_filter.RegionBase.inside_x_y");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF((PyObject *)__pyx_v_xa);
  __Pyx_DECREF((PyObject *)__pyx_v_ya);
  __Pyx_DECREF((PyObject *)__pyx_v_ra);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":316
 *     cdef RegionBase child_region
 * 
 *     def __init__(self, RegionBase child_region):             # <<<<<<<<<<<<<<
 *         self.child_region = child_region
 * 
 */

static int __pyx_pf_14_region_filter_9RegionNot___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_14_region_filter_9RegionNot___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14_region_filter_RegionBase *__pyx_v_child_region = 0;
  int __pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__child_region,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__child_region);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_child_region = ((struct __pyx_obj_14_region_filter_RegionBase *)values[0]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_child_region = ((struct __pyx_obj_14_region_filter_RegionBase *)PyTuple_GET_ITEM(__pyx_args, 0));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("_region_filter.RegionNot.__init__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_child_region), __pyx_ptype_14_region_filter_RegionBase, 1, "child_region", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "_region_filter.pyx":317
 * 
 *     def __init__(self, RegionBase child_region):
 *         self.child_region = child_region             # <<<<<<<<<<<<<<
 * 
 *     cdef npy_bool _inside(self, double x, double y):
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_child_region));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_child_region));
  __Pyx_GOTREF(((struct __pyx_obj_14_region_filter_RegionNot *)__pyx_v_self)->child_region);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_14_region_filter_RegionNot *)__pyx_v_self)->child_region));
  ((struct __pyx_obj_14_region_filter_RegionNot *)__pyx_v_self)->child_region = __pyx_v_child_region;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("_region_filter.RegionNot.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":319
 *         self.child_region = child_region
 * 
 *     cdef npy_bool _inside(self, double x, double y):             # <<<<<<<<<<<<<<
 *         return not(self.child_region._inside(x, y))
 * 
 */

static  npy_bool __pyx_f_14_region_filter_9RegionNot__inside(struct __pyx_obj_14_region_filter_RegionNot *__pyx_v_self, double __pyx_v_x, double __pyx_v_y) {
  npy_bool __pyx_r;
  __Pyx_RefNannySetupContext("_inside");

  /* "_region_filter.pyx":320
 * 
 *     cdef npy_bool _inside(self, double x, double y):
 *         return not(self.child_region._inside(x, y))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = (!((struct __pyx_vtabstruct_14_region_filter_RegionBase *)__pyx_v_self->child_region->__pyx_vtab)->_inside(__pyx_v_self->child_region, __pyx_v_x, __pyx_v_y));
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":326
 *     cdef object child_regions
 * 
 *     def _check_type_of_list(self, kl):             # <<<<<<<<<<<<<<
 *         for k in kl:
 *             if not isinstance(k, RegionBase):
 */

static PyObject *__pyx_pf_14_region_filter_10RegionList__check_type_of_list(PyObject *__pyx_v_self, PyObject *__pyx_v_kl); /*proto*/
static PyObject *__pyx_pf_14_region_filter_10RegionList__check_type_of_list(PyObject *__pyx_v_self, PyObject *__pyx_v_kl) {
  PyObject *__pyx_v_k;
  PyObject *__pyx_r = NULL;
  Py_ssize_t __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  __Pyx_RefNannySetupContext("_check_type_of_list");
  __pyx_v_k = Py_None; __Pyx_INCREF(Py_None);

  /* "_region_filter.pyx":327
 * 
 *     def _check_type_of_list(self, kl):
 *         for k in kl:             # <<<<<<<<<<<<<<
 *             if not isinstance(k, RegionBase):
 *                 raise TypeError("All elements should be subclass of RegionBase type: %s" % k)
 */
  if (PyList_CheckExact(__pyx_v_kl) || PyTuple_CheckExact(__pyx_v_kl)) {
    __pyx_t_1 = 0; __pyx_t_2 = __pyx_v_kl; __Pyx_INCREF(__pyx_t_2);
  } else {
    __pyx_t_1 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_kl); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
  }
  for (;;) {
    if (likely(PyList_CheckExact(__pyx_t_2))) {
      if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++;
    } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
      if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++;
    } else {
      __pyx_t_3 = PyIter_Next(__pyx_t_2);
      if (!__pyx_t_3) {
        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
        break;
      }
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_DECREF(__pyx_v_k);
    __pyx_v_k = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "_region_filter.pyx":328
 *     def _check_type_of_list(self, kl):
 *         for k in kl:
 *             if not isinstance(k, RegionBase):             # <<<<<<<<<<<<<<
 *                 raise TypeError("All elements should be subclass of RegionBase type: %s" % k)
 * 
 */
    __pyx_t_4 = __Pyx_TypeCheck(__pyx_v_k, ((PyObject*)__pyx_ptype_14_region_filter_RegionBase)); 
    __pyx_t_5 = (!__pyx_t_4);
    if (__pyx_t_5) {

      /* "_region_filter.pyx":329
 *         for k in kl:
 *             if not isinstance(k, RegionBase):
 *                 raise TypeError("All elements should be subclass of RegionBase type: %s" % k)             # <<<<<<<<<<<<<<
 * 
 *     def __init__(self, *kl):
 */
      __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_8), __pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_3));
      __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
      __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
      __Pyx_Raise(__pyx_t_3, 0, 0);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      goto __pyx_L7;
    }
    __pyx_L7:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("_region_filter.RegionList._check_type_of_list");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_k);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":331
 *                 raise TypeError("All elements should be subclass of RegionBase type: %s" % k)
 * 
 *     def __init__(self, *kl):             # <<<<<<<<<<<<<<
 *         self._check_type_of_list(kl)
 *         self.child_regions = list(kl)
 */

static int __pyx_pf_14_region_filter_10RegionList_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_14_region_filter_10RegionList_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_kl = 0;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
  __Pyx_INCREF(__pyx_args);
  __pyx_v_kl = __pyx_args;

  /* "_region_filter.pyx":332
 * 
 *     def __init__(self, *kl):
 *         self._check_type_of_list(kl)             # <<<<<<<<<<<<<<
 *         self.child_regions = list(kl)
 * 
 */
  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___check_type_of_list); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(((PyObject *)__pyx_v_kl));
  PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_kl));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_kl));
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "_region_filter.pyx":333
 *     def __init__(self, *kl):
 *         self._check_type_of_list(kl)
 *         self.child_regions = list(kl)             # <<<<<<<<<<<<<<
 * 
 *     def __len__(self):
 */
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(((PyObject *)__pyx_v_kl));
  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_kl));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_kl));
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __Pyx_GOTREF(((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions);
  __Pyx_DECREF(((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions);
  ((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions = __pyx_t_2;
  __pyx_t_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("_region_filter.RegionList.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_kl);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":335
 *         self.child_regions = list(kl)
 * 
 *     def __len__(self):             # <<<<<<<<<<<<<<
 *         return len(self.child_regions)
 * 
 */

static Py_ssize_t __pyx_pf_14_region_filter_10RegionList_2__len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_pf_14_region_filter_10RegionList_2__len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  __Pyx_RefNannySetupContext("__len__");

  /* "_region_filter.pyx":336
 * 
 *     def __len__(self):
 *         return len(self.child_regions)             # <<<<<<<<<<<<<<
 * 
 *     def __getitem__(self, Py_ssize_t x):
 */
  __pyx_t_1 = ((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("_region_filter.RegionList.__len__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":338
 *         return len(self.child_regions)
 * 
 *     def __getitem__(self, Py_ssize_t x):             # <<<<<<<<<<<<<<
 *         return self.child_regions[x]
 * 
 */

static PyObject *__pyx_pf_14_region_filter_10RegionList_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static PyObject *__pyx_pf_14_region_filter_10RegionList_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  Py_ssize_t __pyx_v_x;
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  __Pyx_RefNannySetupContext("__getitem__");
  assert(__pyx_arg_x); {
    __pyx_v_x = __Pyx_PyIndex_AsSsize_t(__pyx_arg_x); if (unlikely((__pyx_v_x == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("_region_filter.RegionList.__getitem__");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;

  /* "_region_filter.pyx":339
 * 
 *     def __getitem__(self, Py_ssize_t x):
 *         return self.child_regions[x]             # <<<<<<<<<<<<<<
 * 
 *     def __setitem__(self, Py_ssize_t x, RegionBase y):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_GetItemInt(((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions, __pyx_v_x, sizeof(Py_ssize_t), PyInt_FromSsize_t); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("_region_filter.RegionList.__getitem__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":341
 *         return self.child_regions[x]
 * 
 *     def __setitem__(self, Py_ssize_t x, RegionBase y):             # <<<<<<<<<<<<<<
 *         self.child_regions[x] = y
 * 
 */

static int __pyx_pf_14_region_filter_10RegionList_4__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x, PyObject *__pyx_v_y); /*proto*/
static int __pyx_pf_14_region_filter_10RegionList_4__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x, PyObject *__pyx_v_y) {
  Py_ssize_t __pyx_v_x;
  int __pyx_r;
  __Pyx_RefNannySetupContext("__setitem__");
  assert(__pyx_arg_x); {
    __pyx_v_x = __Pyx_PyIndex_AsSsize_t(__pyx_arg_x); if (unlikely((__pyx_v_x == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("_region_filter.RegionList.__setitem__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_14_region_filter_RegionBase, 1, "y", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "_region_filter.pyx":342
 * 
 *     def __setitem__(self, Py_ssize_t x, RegionBase y):
 *         self.child_regions[x] = y             # <<<<<<<<<<<<<<
 * 
 *     def __delitem__(self, Py_ssize_t x):
 */
  if (__Pyx_SetItemInt(((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions, __pyx_v_x, __pyx_v_y, sizeof(Py_ssize_t), PyInt_FromSsize_t) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("_region_filter.RegionList.__setitem__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":344
 *         self.child_regions[x] = y
 * 
 *     def __delitem__(self, Py_ssize_t x):             # <<<<<<<<<<<<<<
 *         del self.child_regions[x]
 * 
 */

static int __pyx_pf_14_region_filter_10RegionList_5__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_pf_14_region_filter_10RegionList_5__delitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  Py_ssize_t __pyx_v_x;
  int __pyx_r;
  __Pyx_RefNannySetupContext("__delitem__");
  assert(__pyx_arg_x); {
    __pyx_v_x = __Pyx_PyIndex_AsSsize_t(__pyx_arg_x); if (unlikely((__pyx_v_x == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  __Pyx_AddTraceback("_region_filter.RegionList.__delitem__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;

  /* "_region_filter.pyx":345
 * 
 *     def __delitem__(self, Py_ssize_t x):
 *         del self.child_regions[x]             # <<<<<<<<<<<<<<
 * 
 *     # def __getslice__(self, Py_ssize_t i, Py_ssize_t j):
 */
  if (__Pyx_DelItemInt(((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions, __pyx_v_x, sizeof(Py_ssize_t), PyInt_FromSsize_t) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("_region_filter.RegionList.__delitem__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":357
 *     #     del self.child_regions[i:j]
 * 
 *     def __contains__(self, RegionBase x):             # <<<<<<<<<<<<<<
 *         return x in self.child_regions
 * 
 */

static int __pyx_pf_14_region_filter_10RegionList_6__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_pf_14_region_filter_10RegionList_6__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("__contains__");
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_14_region_filter_RegionBase, 1, "x", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "_region_filter.pyx":358
 * 
 *     def __contains__(self, RegionBase x):
 *         return x in self.child_regions             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_t_1 = ((PySequence_Contains(((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions, __pyx_v_x))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_r = __pyx_t_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("_region_filter.RegionList.__contains__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":360
 *         return x in self.child_regions
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return repr(self.child_regions)
 * 
 */

static PyObject *__pyx_pf_14_region_filter_10RegionList_7__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_14_region_filter_10RegionList_7__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__repr__");

  /* "_region_filter.pyx":361
 * 
 *     def __repr__(self):
 *         return repr(self.child_regions)             # <<<<<<<<<<<<<<
 * 
 *     def asList(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("_region_filter.RegionList.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":363
 *         return repr(self.child_regions)
 * 
 *     def asList(self):             # <<<<<<<<<<<<<<
 *         return self.child_regions
 * 
 */

static PyObject *__pyx_pf_14_region_filter_10RegionList_8asList(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyObject *__pyx_pf_14_region_filter_10RegionList_8asList(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("asList");

  /* "_region_filter.pyx":364
 * 
 *     def asList(self):
 *         return self.child_regions             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions);
  __pyx_r = ((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":371
 *     >>> r = RegionOrList(r1, r2, r3, r4, ...)
 *     """
 *     cdef npy_bool _inside(self, double x, double y):             # <<<<<<<<<<<<<<
 *         cdef c_python.PyListObject *child_regions
 *         cdef int i, n
 */

static  npy_bool __pyx_f_14_region_filter_12RegionOrList__inside(struct __pyx_obj_14_region_filter_RegionOrList *__pyx_v_self, double __pyx_v_x, double __pyx_v_y) {
  PyListObject *__pyx_v_child_regions;
  int __pyx_v_i;
  int __pyx_v_n;
  npy_bool __pyx_r;
  int __pyx_t_1;
  void *__pyx_t_2;
  npy_bool __pyx_t_3;
  __Pyx_RefNannySetupContext("_inside");

  /* "_region_filter.pyx":375
 *         cdef int i, n
 * 
 *         child_regions = <c_python.PyListObject *> self.child_regions             # <<<<<<<<<<<<<<
 *         n = c_python.PyList_GET_SIZE(child_regions)
 *         for i from 0 <= i < n:
 */
  __pyx_v_child_regions = ((PyListObject *)__pyx_v_self->__pyx_base.child_regions);

  /* "_region_filter.pyx":376
 * 
 *         child_regions = <c_python.PyListObject *> self.child_regions
 *         n = c_python.PyList_GET_SIZE(child_regions)             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < n:
 *             if (<RegionBase> c_python.PyList_GET_ITEM(child_regions, i))._inside(x, y):
 */
  __pyx_v_n = PyList_GET_SIZE(__pyx_v_child_regions);

  /* "_region_filter.pyx":377
 *         child_regions = <c_python.PyListObject *> self.child_regions
 *         n = c_python.PyList_GET_SIZE(child_regions)
 *         for i from 0 <= i < n:             # <<<<<<<<<<<<<<
 *             if (<RegionBase> c_python.PyList_GET_ITEM(child_regions, i))._inside(x, y):
 *                 return 1
 */
  __pyx_t_1 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "_region_filter.pyx":378
 *         n = c_python.PyList_GET_SIZE(child_regions)
 *         for i from 0 <= i < n:
 *             if (<RegionBase> c_python.PyList_GET_ITEM(child_regions, i))._inside(x, y):             # <<<<<<<<<<<<<<
 *                 return 1
 *         return 0
 */
    __pyx_t_2 = PyList_GET_ITEM(__pyx_v_child_regions, __pyx_v_i);
    __pyx_t_3 = ((struct __pyx_vtabstruct_14_region_filter_RegionBase *)((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_t_2)->__pyx_vtab)->_inside(((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_t_2), __pyx_v_x, __pyx_v_y);
    if (__pyx_t_3) {

      /* "_region_filter.pyx":379
 *         for i from 0 <= i < n:
 *             if (<RegionBase> c_python.PyList_GET_ITEM(child_regions, i))._inside(x, y):
 *                 return 1             # <<<<<<<<<<<<<<
 *         return 0
 * 
 */
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "_region_filter.pyx":380
 *             if (<RegionBase> c_python.PyList_GET_ITEM(child_regions, i))._inside(x, y):
 *                 return 1
 *         return 0             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":383
 * 
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "Or"+repr(self.child_regions)
 * 
 */

static PyObject *__pyx_pf_14_region_filter_12RegionOrList___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_14_region_filter_12RegionOrList___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__repr__");

  /* "_region_filter.pyx":384
 * 
 *     def __repr__(self):
 *         return "Or"+repr(self.child_regions)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_obj_14_region_filter_RegionOrList *)__pyx_v_self)->__pyx_base.child_regions;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_n_s__Or), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("_region_filter.RegionOrList.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":393
 *     """
 * 
 *     cdef npy_bool _inside(self, double x, double y):             # <<<<<<<<<<<<<<
 *         cdef c_python.PyListObject *child_regions
 *         cdef int i, n
 */

static  npy_bool __pyx_f_14_region_filter_13RegionAndList__inside(struct __pyx_obj_14_region_filter_RegionAndList *__pyx_v_self, double __pyx_v_x, double __pyx_v_y) {
  PyListObject *__pyx_v_child_regions;
  int __pyx_v_i;
  int __pyx_v_n;
  npy_bool __pyx_r;
  int __pyx_t_1;
  void *__pyx_t_2;
  int __pyx_t_3;
  __Pyx_RefNannySetupContext("_inside");

  /* "_region_filter.pyx":397
 *         cdef int i, n
 * 
 *         child_regions = <c_python.PyListObject *> self.child_regions             # <<<<<<<<<<<<<<
 *         n = c_python.PyList_GET_SIZE(child_regions)
 *         for i from 0 <= i < n:
 */
  __pyx_v_child_regions = ((PyListObject *)__pyx_v_self->__pyx_base.child_regions);

  /* "_region_filter.pyx":398
 * 
 *         child_regions = <c_python.PyListObject *> self.child_regions
 *         n = c_python.PyList_GET_SIZE(child_regions)             # <<<<<<<<<<<<<<
 *         for i from 0 <= i < n:
 *             if not (<RegionBase> c_python.PyList_GET_ITEM(child_regions, i))._inside(x, y):
 */
  __pyx_v_n = PyList_GET_SIZE(__pyx_v_child_regions);

  /* "_region_filter.pyx":399
 *         child_regions = <c_python.PyListObject *> self.child_regions
 *         n = c_python.PyList_GET_SIZE(child_regions)
 *         for i from 0 <= i < n:             # <<<<<<<<<<<<<<
 *             if not (<RegionBase> c_python.PyList_GET_ITEM(child_regions, i))._inside(x, y):
 *                 return 0
 */
  __pyx_t_1 = __pyx_v_n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "_region_filter.pyx":400
 *         n = c_python.PyList_GET_SIZE(child_regions)
 *         for i from 0 <= i < n:
 *             if not (<RegionBase> c_python.PyList_GET_ITEM(child_regions, i))._inside(x, y):             # <<<<<<<<<<<<<<
 *                 return 0
 *         return 1
 */
    __pyx_t_2 = PyList_GET_ITEM(__pyx_v_child_regions, __pyx_v_i);
    __pyx_t_3 = (!((struct __pyx_vtabstruct_14_region_filter_RegionBase *)((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_t_2)->__pyx_vtab)->_inside(((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_t_2), __pyx_v_x, __pyx_v_y));
    if (__pyx_t_3) {

      /* "_region_filter.pyx":401
 *         for i from 0 <= i < n:
 *             if not (<RegionBase> c_python.PyList_GET_ITEM(child_regions, i))._inside(x, y):
 *                 return 0             # <<<<<<<<<<<<<<
 *         return 1
 * 
 */
      __pyx_r = 0;
      goto __pyx_L0;
      goto __pyx_L5;
    }
    __pyx_L5:;
  }

  /* "_region_filter.pyx":402
 *             if not (<RegionBase> c_python.PyList_GET_ITEM(child_regions, i))._inside(x, y):
 *                 return 0
 *         return 1             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":405
 * 
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "And"+repr(self.child_regions)
 * 
 */

static PyObject *__pyx_pf_14_region_filter_13RegionAndList___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_14_region_filter_13RegionAndList___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  __Pyx_RefNannySetupContext("__repr__");

  /* "_region_filter.pyx":406
 * 
 *     def __repr__(self):
 *         return "And"+repr(self.child_regions)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = ((struct __pyx_obj_14_region_filter_RegionAndList *)__pyx_v_self)->__pyx_base.child_regions;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_n_s__And), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("_region_filter.RegionAndList.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":409
 * 
 * 
 * def RegionAnd(RegionBase region1, RegionBase region2):             # <<<<<<<<<<<<<<
 *     """
 *     >>> r = RegionAnd(reg1, reg2)
 */

static PyObject *__pyx_pf_14_region_filter_RegionAnd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_14_region_filter_RegionAnd[] = "\n    >>> r = RegionAnd(reg1, reg2)\n    ";
static PyMethodDef __pyx_mdef_14_region_filter_RegionAnd = {__Pyx_NAMESTR("RegionAnd"), (PyCFunction)__pyx_pf_14_region_filter_RegionAnd, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_14_region_filter_RegionAnd)};
static PyObject *__pyx_pf_14_region_filter_RegionAnd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14_region_filter_RegionBase *__pyx_v_region1 = 0;
  struct __pyx_obj_14_region_filter_RegionBase *__pyx_v_region2 = 0;
  PyObject *__pyx_v_region1_list;
  PyObject *__pyx_v_region2_list;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__region1,&__pyx_n_s__region2,0};
  __Pyx_RefNannySetupContext("RegionAnd");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region1);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region2);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RegionAnd", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "RegionAnd") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_region1 = ((struct __pyx_obj_14_region_filter_RegionBase *)values[0]);
    __pyx_v_region2 = ((struct __pyx_obj_14_region_filter_RegionBase *)values[1]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_region1 = ((struct __pyx_obj_14_region_filter_RegionBase *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_region2 = ((struct __pyx_obj_14_region_filter_RegionBase *)PyTuple_GET_ITEM(__pyx_args, 1));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("RegionAnd", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("_region_filter.RegionAnd");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_region1_list = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_region2_list = Py_None; __Pyx_INCREF(Py_None);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_region1), __pyx_ptype_14_region_filter_RegionBase, 1, "region1", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_region2), __pyx_ptype_14_region_filter_RegionBase, 1, "region2", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "_region_filter.pyx":413
 *     >>> r = RegionAnd(reg1, reg2)
 *     """
 *     if isinstance(region1, RegionAndList):             # <<<<<<<<<<<<<<
 *         region1_list = region1.asList()
 *     else:
 */
  __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_region1), ((PyObject*)__pyx_ptype_14_region_filter_RegionAndList)); 
  if (__pyx_t_1) {

    /* "_region_filter.pyx":414
 *     """
 *     if isinstance(region1, RegionAndList):
 *         region1_list = region1.asList()             # <<<<<<<<<<<<<<
 *     else:
 *         region1_list = [region1]
 */
    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_region1), __pyx_n_s__asList); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_v_region1_list);
    __pyx_v_region1_list = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "_region_filter.pyx":416
 *         region1_list = region1.asList()
 *     else:
 *         region1_list = [region1]             # <<<<<<<<<<<<<<
 * 
 *     if isinstance(region2, RegionAndList):
 */
    __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_INCREF(((PyObject *)__pyx_v_region1));
    PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_region1));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_region1));
    __Pyx_DECREF(__pyx_v_region1_list);
    __pyx_v_region1_list = ((PyObject *)__pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L6:;

  /* "_region_filter.pyx":418
 *         region1_list = [region1]
 * 
 *     if isinstance(region2, RegionAndList):             # <<<<<<<<<<<<<<
 *         region2_list = region2.asList()
 *     else:
 */
  __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_region2), ((PyObject*)__pyx_ptype_14_region_filter_RegionAndList)); 
  if (__pyx_t_1) {

    /* "_region_filter.pyx":419
 * 
 *     if isinstance(region2, RegionAndList):
 *         region2_list = region2.asList()             # <<<<<<<<<<<<<<
 *     else:
 *         region2_list = [region2]
 */
    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_region2), __pyx_n_s__asList); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_v_region2_list);
    __pyx_v_region2_list = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L7;
  }
  /*else*/ {

    /* "_region_filter.pyx":421
 *         region2_list = region2.asList()
 *     else:
 *         region2_list = [region2]             # <<<<<<<<<<<<<<
 * 
 *     return RegionAndList(*(region1_list + region2_list))
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_INCREF(((PyObject *)__pyx_v_region2));
    PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_region2));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_region2));
    __Pyx_DECREF(__pyx_v_region2_list);
    __pyx_v_region2_list = ((PyObject *)__pyx_t_2);
    __pyx_t_2 = 0;
  }
  __pyx_L7:;

  /* "_region_filter.pyx":423
 *         region2_list = [region2]
 * 
 *     return RegionAndList(*(region1_list + region2_list))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyNumber_Add(__pyx_v_region1_list, __pyx_v_region2_list); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PySequence_Tuple(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14_region_filter_RegionAndList)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("_region_filter.RegionAnd");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_region1_list);
  __Pyx_DECREF(__pyx_v_region2_list);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":426
 * 
 * 
 * def RegionOr(RegionBase region1, RegionBase region2):             # <<<<<<<<<<<<<<
 *     """
 *     >>> r = RegionOr(reg1, reg2)
 */

static PyObject *__pyx_pf_14_region_filter_1RegionOr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_14_region_filter_1RegionOr[] = "\n    >>> r = RegionOr(reg1, reg2)\n    ";
static PyMethodDef __pyx_mdef_14_region_filter_1RegionOr = {__Pyx_NAMESTR("RegionOr"), (PyCFunction)__pyx_pf_14_region_filter_1RegionOr, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_14_region_filter_1RegionOr)};
static PyObject *__pyx_pf_14_region_filter_1RegionOr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14_region_filter_RegionBase *__pyx_v_region1 = 0;
  struct __pyx_obj_14_region_filter_RegionBase *__pyx_v_region2 = 0;
  PyObject *__pyx_v_region1_list;
  PyObject *__pyx_v_region2_list;
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__region1,&__pyx_n_s__region2,0};
  __Pyx_RefNannySetupContext("RegionOr");
  __pyx_self = __pyx_self;
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[2] = {0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region1);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region2);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("RegionOr", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "RegionOr") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_region1 = ((struct __pyx_obj_14_region_filter_RegionBase *)values[0]);
    __pyx_v_region2 = ((struct __pyx_obj_14_region_filter_RegionBase *)values[1]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_region1 = ((struct __pyx_obj_14_region_filter_RegionBase *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_region2 = ((struct __pyx_obj_14_region_filter_RegionBase *)PyTuple_GET_ITEM(__pyx_args, 1));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("RegionOr", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("_region_filter.RegionOr");
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_v_region1_list = Py_None; __Pyx_INCREF(Py_None);
  __pyx_v_region2_list = Py_None; __Pyx_INCREF(Py_None);
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_region1), __pyx_ptype_14_region_filter_RegionBase, 1, "region1", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_region2), __pyx_ptype_14_region_filter_RegionBase, 1, "region2", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "_region_filter.pyx":430
 *     >>> r = RegionOr(reg1, reg2)
 *     """
 *     if isinstance(region1, RegionOrList):             # <<<<<<<<<<<<<<
 *         region1_list = region1.asList()
 *     else:
 */
  __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_region1), ((PyObject*)__pyx_ptype_14_region_filter_RegionOrList)); 
  if (__pyx_t_1) {

    /* "_region_filter.pyx":431
 *     """
 *     if isinstance(region1, RegionOrList):
 *         region1_list = region1.asList()             # <<<<<<<<<<<<<<
 *     else:
 *         region1_list = [region1]
 */
    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_region1), __pyx_n_s__asList); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_v_region1_list);
    __pyx_v_region1_list = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L6;
  }
  /*else*/ {

    /* "_region_filter.pyx":433
 *         region1_list = region1.asList()
 *     else:
 *         region1_list = [region1]             # <<<<<<<<<<<<<<
 * 
 *     if isinstance(region2, RegionOrList):
 */
    __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
    __Pyx_INCREF(((PyObject *)__pyx_v_region1));
    PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_region1));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_region1));
    __Pyx_DECREF(__pyx_v_region1_list);
    __pyx_v_region1_list = ((PyObject *)__pyx_t_3);
    __pyx_t_3 = 0;
  }
  __pyx_L6:;

  /* "_region_filter.pyx":435
 *         region1_list = [region1]
 * 
 *     if isinstance(region2, RegionOrList):             # <<<<<<<<<<<<<<
 *         region2_list = region2.asList()
 *     else:
 */
  __pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_region2), ((PyObject*)__pyx_ptype_14_region_filter_RegionOrList)); 
  if (__pyx_t_1) {

    /* "_region_filter.pyx":436
 * 
 *     if isinstance(region2, RegionOrList):
 *         region2_list = region2.asList()             # <<<<<<<<<<<<<<
 *     else:
 *         region2_list = [region2]
 */
    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_region2), __pyx_n_s__asList); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_v_region2_list);
    __pyx_v_region2_list = __pyx_t_2;
    __pyx_t_2 = 0;
    goto __pyx_L7;
  }
  /*else*/ {

    /* "_region_filter.pyx":438
 *         region2_list = region2.asList()
 *     else:
 *         region2_list = [region2]             # <<<<<<<<<<<<<<
 * 
 *     return RegionOrList(*(region1_list + region2_list))
 */
    __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
    __Pyx_INCREF(((PyObject *)__pyx_v_region2));
    PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_region2));
    __Pyx_GIVEREF(((PyObject *)__pyx_v_region2));
    __Pyx_DECREF(__pyx_v_region2_list);
    __pyx_v_region2_list = ((PyObject *)__pyx_t_2);
    __pyx_t_2 = 0;
  }
  __pyx_L7:;

  /* "_region_filter.pyx":440
 *         region2_list = [region2]
 * 
 *     return RegionOrList(*(region1_list + region2_list))             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyNumber_Add(__pyx_v_region1_list, __pyx_v_region2_list); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PySequence_Tuple(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14_region_filter_RegionOrList)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("_region_filter.RegionOr");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_DECREF(__pyx_v_region1_list);
  __Pyx_DECREF(__pyx_v_region2_list);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":526
 *     cdef RegionBase child_region
 * 
 *     def __init__(self, RegionBase child_region):             # <<<<<<<<<<<<<<
 *         self.child_region = child_region
 * 
 */

static int __pyx_pf_14_region_filter_9Transform___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_14_region_filter_9Transform___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14_region_filter_RegionBase *__pyx_v_child_region = 0;
  int __pyx_r;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__child_region,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[1] = {0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__child_region);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_child_region = ((struct __pyx_obj_14_region_filter_RegionBase *)values[0]);
  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_child_region = ((struct __pyx_obj_14_region_filter_RegionBase *)PyTuple_GET_ITEM(__pyx_args, 0));
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("_region_filter.Transform.__init__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_child_region), __pyx_ptype_14_region_filter_RegionBase, 1, "child_region", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "_region_filter.pyx":527
 * 
 *     def __init__(self, RegionBase child_region):
 *         self.child_region = child_region             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_INCREF(((PyObject *)__pyx_v_child_region));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_child_region));
  __Pyx_GOTREF(((struct __pyx_obj_14_region_filter_Transform *)__pyx_v_self)->child_region);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_14_region_filter_Transform *)__pyx_v_self)->child_region));
  ((struct __pyx_obj_14_region_filter_Transform *)__pyx_v_self)->child_region = __pyx_v_child_region;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_AddTraceback("_region_filter.Transform.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":531
 * 
 *     property child:
 *         def __get__(self):             # <<<<<<<<<<<<<<
 *             return self.child_region
 * 
 */

static PyObject *__pyx_pf_14_region_filter_9Transform_5child___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_14_region_filter_9Transform_5child___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("__get__");

  /* "_region_filter.pyx":532
 *     property child:
 *         def __get__(self):
 *             return self.child_region             # <<<<<<<<<<<<<<
 * 
 *         #def __del__(self):
 */
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_14_region_filter_Transform *)__pyx_v_self)->child_region));
  __pyx_r = ((PyObject *)((struct __pyx_obj_14_region_filter_Transform *)__pyx_v_self)->child_region);
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":538
 * 
 * 
 *     cdef int _transform(self, double x, double y, double *xp, double *yp):             # <<<<<<<<<<<<<<
 *         xp[0] = x
 *         yp[0] = y
 */

static  int __pyx_f_14_region_filter_9Transform__transform(struct __pyx_obj_14_region_filter_Transform *__pyx_v_self, double __pyx_v_x, double __pyx_v_y, double *__pyx_v_xp, double *__pyx_v_yp) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("_transform");

  /* "_region_filter.pyx":539
 * 
 *     cdef int _transform(self, double x, double y, double *xp, double *yp):
 *         xp[0] = x             # <<<<<<<<<<<<<<
 *         yp[0] = y
 * 
 */
  (__pyx_v_xp[0]) = __pyx_v_x;

  /* "_region_filter.pyx":540
 *     cdef int _transform(self, double x, double y, double *xp, double *yp):
 *         xp[0] = x
 *         yp[0] = y             # <<<<<<<<<<<<<<
 * 
 *     cdef npy_bool _inside(self, double x, double y):
 */
  (__pyx_v_yp[0]) = __pyx_v_y;

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":542
 *         yp[0] = y
 * 
 *     cdef npy_bool _inside(self, double x, double y):             # <<<<<<<<<<<<<<
 *         cdef double xp, yp
 *         cdef npy_bool r
 */

static  npy_bool __pyx_f_14_region_filter_9Transform__inside(struct __pyx_obj_14_region_filter_Transform *__pyx_v_self, double __pyx_v_x, double __pyx_v_y) {
  double __pyx_v_xp;
  double __pyx_v_yp;
  npy_bool __pyx_v_r;
  npy_bool __pyx_r;
  __Pyx_RefNannySetupContext("_inside");

  /* "_region_filter.pyx":546
 *         cdef npy_bool r
 * 
 *         self._transform(x, y, &xp, &yp)             # <<<<<<<<<<<<<<
 *         r = self.child_region._inside(xp, yp)
 * 
 */
  ((struct __pyx_vtabstruct_14_region_filter_Transform *)__pyx_v_self->__pyx_base.__pyx_vtab)->_transform(__pyx_v_self, __pyx_v_x, __pyx_v_y, (&__pyx_v_xp), (&__pyx_v_yp));

  /* "_region_filter.pyx":547
 * 
 *         self._transform(x, y, &xp, &yp)
 *         r = self.child_region._inside(xp, yp)             # <<<<<<<<<<<<<<
 * 
 *         return r
 */
  __pyx_v_r = ((struct __pyx_vtabstruct_14_region_filter_RegionBase *)__pyx_v_self->child_region->__pyx_vtab)->_inside(__pyx_v_self->child_region, __pyx_v_xp, __pyx_v_yp);

  /* "_region_filter.pyx":549
 *         r = self.child_region._inside(xp, yp)
 * 
 *         return r             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_r;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":574
 *     cdef double origin_x, origin_y
 * 
 *     def __init__(self, RegionBase child_region,             # <<<<<<<<<<<<<<
 *                  double degree, double origin_x, double origin_y):
 *         cdef double theta
 */

static int __pyx_pf_14_region_filter_7Rotated___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_14_region_filter_7Rotated___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14_region_filter_RegionBase *__pyx_v_child_region = 0;
  double __pyx_v_degree;
  double __pyx_v_origin_x;
  double __pyx_v_origin_y;
  double __pyx_v_theta;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__child_region,&__pyx_n_s__degree,&__pyx_n_s__origin_x,&__pyx_n_s__origin_y,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[4] = {0,0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__child_region);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__degree);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__origin_x);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__origin_y);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_child_region = ((struct __pyx_obj_14_region_filter_RegionBase *)values[0]);
    __pyx_v_degree = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_degree == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_origin_x = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_origin_x == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_origin_y = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_origin_y == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_child_region = ((struct __pyx_obj_14_region_filter_RegionBase *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_degree = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_degree == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_origin_x = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_origin_x == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_origin_y = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_origin_y == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("_region_filter.Rotated.__init__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_child_region), __pyx_ptype_14_region_filter_RegionBase, 1, "child_region", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "_region_filter.pyx":578
 *         cdef double theta
 * 
 *         Transform.__init__(self, child_region)             # <<<<<<<<<<<<<<
 * 
 *         theta = degree / 180. * M_PI #3.1415926
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_14_region_filter_Transform)), __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  __Pyx_INCREF(((PyObject *)__pyx_v_child_region));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_child_region));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_child_region));
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "_region_filter.pyx":580
 *         Transform.__init__(self, child_region)
 * 
 *         theta = degree / 180. * M_PI #3.1415926             # <<<<<<<<<<<<<<
 *         self.sin_theta = sin(theta)
 *         self.cos_theta = cos(theta)
 */
  __pyx_v_theta = ((__pyx_v_degree / 180.) * M_PI);

  /* "_region_filter.pyx":581
 * 
 *         theta = degree / 180. * M_PI #3.1415926
 *         self.sin_theta = sin(theta)             # <<<<<<<<<<<<<<
 *         self.cos_theta = cos(theta)
 * 
 */
  ((struct __pyx_obj_14_region_filter_Rotated *)__pyx_v_self)->sin_theta = sin(__pyx_v_theta);

  /* "_region_filter.pyx":582
 *         theta = degree / 180. * M_PI #3.1415926
 *         self.sin_theta = sin(theta)
 *         self.cos_theta = cos(theta)             # <<<<<<<<<<<<<<
 * 
 *         self.origin_x = origin_x
 */
  ((struct __pyx_obj_14_region_filter_Rotated *)__pyx_v_self)->cos_theta = cos(__pyx_v_theta);

  /* "_region_filter.pyx":584
 *         self.cos_theta = cos(theta)
 * 
 *         self.origin_x = origin_x             # <<<<<<<<<<<<<<
 *         self.origin_y = origin_y
 * 
 */
  ((struct __pyx_obj_14_region_filter_Rotated *)__pyx_v_self)->origin_x = __pyx_v_origin_x;

  /* "_region_filter.pyx":585
 * 
 *         self.origin_x = origin_x
 *         self.origin_y = origin_y             # <<<<<<<<<<<<<<
 * 
 * 
 */
  ((struct __pyx_obj_14_region_filter_Rotated *)__pyx_v_self)->origin_y = __pyx_v_origin_y;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("_region_filter.Rotated.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":588
 * 
 * 
 *     cdef int _transform(self, double x, double y, double *xp, double *yp):             # <<<<<<<<<<<<<<
 *         cdef double x1, x2, y1, y2
 *         cdef double st, ct, ox, oy
 */

static  int __pyx_f_14_region_filter_7Rotated__transform(struct __pyx_obj_14_region_filter_Rotated *__pyx_v_self, double __pyx_v_x, double __pyx_v_y, double *__pyx_v_xp, double *__pyx_v_yp) {
  double __pyx_v_x1;
  double __pyx_v_x2;
  double __pyx_v_y1;
  double __pyx_v_y2;
  double __pyx_v_st;
  double __pyx_v_ct;
  double __pyx_v_ox;
  double __pyx_v_oy;
  int __pyx_r;
  __Pyx_RefNannySetupContext("_transform");

  /* "_region_filter.pyx":592
 *         cdef double st, ct, ox, oy
 * 
 *         st = self.sin_theta             # <<<<<<<<<<<<<<
 *         ct = self.cos_theta
 *         ox = self.origin_x
 */
  __pyx_v_st = __pyx_v_self->sin_theta;

  /* "_region_filter.pyx":593
 * 
 *         st = self.sin_theta
 *         ct = self.cos_theta             # <<<<<<<<<<<<<<
 *         ox = self.origin_x
 *         oy = self.origin_y
 */
  __pyx_v_ct = __pyx_v_self->cos_theta;

  /* "_region_filter.pyx":594
 *         st = self.sin_theta
 *         ct = self.cos_theta
 *         ox = self.origin_x             # <<<<<<<<<<<<<<
 *         oy = self.origin_y
 * 
 */
  __pyx_v_ox = __pyx_v_self->origin_x;

  /* "_region_filter.pyx":595
 *         ct = self.cos_theta
 *         ox = self.origin_x
 *         oy = self.origin_y             # <<<<<<<<<<<<<<
 * 
 *         x1 = x - ox
 */
  __pyx_v_oy = __pyx_v_self->origin_y;

  /* "_region_filter.pyx":597
 *         oy = self.origin_y
 * 
 *         x1 = x - ox             # <<<<<<<<<<<<<<
 *         y1 = y - oy
 * 
 */
  __pyx_v_x1 = (__pyx_v_x - __pyx_v_ox);

  /* "_region_filter.pyx":598
 * 
 *         x1 = x - ox
 *         y1 = y - oy             # <<<<<<<<<<<<<<
 * 
 *         x2 =  ct*x1 + st*y1
 */
  __pyx_v_y1 = (__pyx_v_y - __pyx_v_oy);

  /* "_region_filter.pyx":600
 *         y1 = y - oy
 * 
 *         x2 =  ct*x1 + st*y1             # <<<<<<<<<<<<<<
 *         y2 = -st*x1 + ct*y1
 * 
 */
  __pyx_v_x2 = ((__pyx_v_ct * __pyx_v_x1) + (__pyx_v_st * __pyx_v_y1));

  /* "_region_filter.pyx":601
 * 
 *         x2 =  ct*x1 + st*y1
 *         y2 = -st*x1 + ct*y1             # <<<<<<<<<<<<<<
 * 
 *         xp[0] = x2 + ox
 */
  __pyx_v_y2 = (((-__pyx_v_st) * __pyx_v_x1) + (__pyx_v_ct * __pyx_v_y1));

  /* "_region_filter.pyx":603
 *         y2 = -st*x1 + ct*y1
 * 
 *         xp[0] = x2 + ox             # <<<<<<<<<<<<<<
 *         yp[0] = y2 + oy
 * 
 */
  (__pyx_v_xp[0]) = (__pyx_v_x2 + __pyx_v_ox);

  /* "_region_filter.pyx":604
 * 
 *         xp[0] = x2 + ox
 *         yp[0] = y2 + oy             # <<<<<<<<<<<<<<
 * 
 * 
 */
  (__pyx_v_yp[0]) = (__pyx_v_y2 + __pyx_v_oy);

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":618
 *     cdef double dy
 * 
 *     def __init__(self, RegionBase child_region,             # <<<<<<<<<<<<<<
 *                  double dx, double dy):
 * 
 */

static int __pyx_pf_14_region_filter_10Translated___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_14_region_filter_10Translated___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14_region_filter_RegionBase *__pyx_v_child_region = 0;
  double __pyx_v_dx;
  double __pyx_v_dy;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__child_region,&__pyx_n_s__dx,&__pyx_n_s__dy,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__child_region);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dx);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dy);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_child_region = ((struct __pyx_obj_14_region_filter_RegionBase *)values[0]);
    __pyx_v_dx = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_dx == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_dy = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_dy == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
    goto __pyx_L5_argtuple_error;
  } else {
    __pyx_v_child_region = ((struct __pyx_obj_14_region_filter_RegionBase *)PyTuple_GET_ITEM(__pyx_args, 0));
    __pyx_v_dx = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_dx == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_dy = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_dy == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("_region_filter.Translated.__init__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_child_region), __pyx_ptype_14_region_filter_RegionBase, 1, "child_region", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "_region_filter.pyx":621
 *                  double dx, double dy):
 * 
 *         Transform.__init__(self, child_region)             # <<<<<<<<<<<<<<
 * 
 *         self.dx = dx
 */
  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_14_region_filter_Transform)), __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self);
  __Pyx_GIVEREF(__pyx_v_self);
  __Pyx_INCREF(((PyObject *)__pyx_v_child_region));
  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_child_region));
  __Pyx_GIVEREF(((PyObject *)__pyx_v_child_region));
  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "_region_filter.pyx":623
 *         Transform.__init__(self, child_region)
 * 
 *         self.dx = dx             # <<<<<<<<<<<<<<
 *         self.dy = dy
 * 
 */
  ((struct __pyx_obj_14_region_filter_Translated *)__pyx_v_self)->dx = __pyx_v_dx;

  /* "_region_filter.pyx":624
 * 
 *         self.dx = dx
 *         self.dy = dy             # <<<<<<<<<<<<<<
 * 
 *     cdef int _transform(self, double x, double y, double *xp, double *yp):
 */
  ((struct __pyx_obj_14_region_filter_Translated *)__pyx_v_self)->dy = __pyx_v_dy;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("_region_filter.Translated.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":626
 *         self.dy = dy
 * 
 *     cdef int _transform(self, double x, double y, double *xp, double *yp):             # <<<<<<<<<<<<<<
 *         xp[0] = x - self.dx
 *         yp[0] = y - self.dy
 */

static  int __pyx_f_14_region_filter_10Translated__transform(struct __pyx_obj_14_region_filter_Translated *__pyx_v_self, double __pyx_v_x, double __pyx_v_y, double *__pyx_v_xp, double *__pyx_v_yp) {
  int __pyx_r;
  __Pyx_RefNannySetupContext("_transform");

  /* "_region_filter.pyx":627
 * 
 *     cdef int _transform(self, double x, double y, double *xp, double *yp):
 *         xp[0] = x - self.dx             # <<<<<<<<<<<<<<
 *         yp[0] = y - self.dy
 * 
 */
  (__pyx_v_xp[0]) = (__pyx_v_x - __pyx_v_self->dx);

  /* "_region_filter.pyx":628
 *     cdef int _transform(self, double x, double y, double *xp, double *yp):
 *         xp[0] = x - self.dx
 *         yp[0] = y - self.dy             # <<<<<<<<<<<<<<
 * 
 * 
 */
  (__pyx_v_yp[0]) = (__pyx_v_y - __pyx_v_self->dy);

  __pyx_r = 0;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":652
 * 
 * 
 *     cdef _set_v(self, double xc, double yc, double radius):             # <<<<<<<<<<<<<<
 *         self.xc = xc
 *         self.yc = yc
 */

static  PyObject *__pyx_f_14_region_filter_6Circle__set_v(struct __pyx_obj_14_region_filter_Circle *__pyx_v_self, double __pyx_v_xc, double __pyx_v_yc, double __pyx_v_radius) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannySetupContext("_set_v");

  /* "_region_filter.pyx":653
 * 
 *     cdef _set_v(self, double xc, double yc, double radius):
 *         self.xc = xc             # <<<<<<<<<<<<<<
 *         self.yc = yc
 *         self.radius = radius
 */
  __pyx_v_self->xc = __pyx_v_xc;

  /* "_region_filter.pyx":654
 *     cdef _set_v(self, double xc, double yc, double radius):
 *         self.xc = xc
 *         self.yc = yc             # <<<<<<<<<<<<<<
 *         self.radius = radius
 *         self.radius2 = radius*radius
 */
  __pyx_v_self->yc = __pyx_v_yc;

  /* "_region_filter.pyx":655
 *         self.xc = xc
 *         self.yc = yc
 *         self.radius = radius             # <<<<<<<<<<<<<<
 *         self.radius2 = radius*radius
 * 
 */
  __pyx_v_self->radius = __pyx_v_radius;

  /* "_region_filter.pyx":656
 *         self.yc = yc
 *         self.radius = radius
 *         self.radius2 = radius*radius             # <<<<<<<<<<<<<<
 * 
 *     cdef _get_v(self):
 */
  __pyx_v_self->radius2 = (__pyx_v_radius * __pyx_v_radius);

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":658
 *         self.radius2 = radius*radius
 * 
 *     cdef _get_v(self):             # <<<<<<<<<<<<<<
 *         return (self.xc, self.yc, self.radius)
 * 
 */

static  PyObject *__pyx_f_14_region_filter_6Circle__get_v(struct __pyx_obj_14_region_filter_Circle *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("_get_v");

  /* "_region_filter.pyx":659
 * 
 *     cdef _get_v(self):
 *         return (self.xc, self.yc, self.radius)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->xc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->yc); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(__pyx_v_self->radius); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_r = ((PyObject *)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("_region_filter.Circle._get_v");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":662
 * 
 * 
 *     def __init__(self, double xc, double yc, double radius,             # <<<<<<<<<<<<<<
 *                  RegionContext c=None):
 *         """
 */

static int __pyx_pf_14_region_filter_6Circle___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_14_region_filter_6Circle___init__[] = "\n        ";
struct wrapperbase __pyx_wrapperbase_14_region_filter_6Circle___init__;
static int __pyx_pf_14_region_filter_6Circle___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_xc;
  double __pyx_v_yc;
  double __pyx_v_radius;
  struct __pyx_obj_14_region_filter_RegionContext *__pyx_v_c = 0;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__xc,&__pyx_n_s__yc,&__pyx_n_s__radius,&__pyx_n_s__c,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[4] = {0,0,0,0};

    /* "_region_filter.pyx":663
 * 
 *     def __init__(self, double xc, double yc, double radius,
 *                  RegionContext c=None):             # <<<<<<<<<<<<<<
 *         """
 *         """
 */
    values[3] = (PyObject *)((struct __pyx_obj_14_region_filter_RegionContext *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__xc);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__yc);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__radius);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__c);
        if (value) { values[3] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_xc = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_xc == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_yc = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_yc == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_radius = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_radius == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_c = ((struct __pyx_obj_14_region_filter_RegionContext *)values[3]);
  } else {
    __pyx_v_c = ((struct __pyx_obj_14_region_filter_RegionContext *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  4:
      __pyx_v_c = ((struct __pyx_obj_14_region_filter_RegionContext *)PyTuple_GET_ITEM(__pyx_args, 3));
      case  3:
      __pyx_v_radius = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_radius == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_yc = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_yc == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_xc = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_xc == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("_region_filter.Circle.__init__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_c), __pyx_ptype_14_region_filter_RegionContext, 1, "c", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "_region_filter.pyx":668
 *         #if c:
 *         #    self.c = c
 *         self.metric_set_origin(xc, yc, c)             # <<<<<<<<<<<<<<
 *         self._set_v(xc, yc, radius)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_14_region_filter_Circle *)((struct __pyx_obj_14_region_filter_Circle *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.metric_set_origin(((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self), __pyx_v_xc, __pyx_v_yc, __pyx_v_c); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "_region_filter.pyx":669
 *         #    self.c = c
 *         self.metric_set_origin(xc, yc, c)
 *         self._set_v(xc, yc, radius)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_14_region_filter_Circle *)((struct __pyx_obj_14_region_filter_Circle *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_set_v(((struct __pyx_obj_14_region_filter_Circle *)__pyx_v_self), __pyx_v_xc, __pyx_v_yc, __pyx_v_radius); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("_region_filter.Circle.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":672
 * 
 * 
 *     cdef npy_bool _inside(self, double x, double y):             # <<<<<<<<<<<<<<
 *         cdef double dist2
 * 
 */

static  npy_bool __pyx_f_14_region_filter_6Circle__inside(struct __pyx_obj_14_region_filter_Circle *__pyx_v_self, double __pyx_v_x, double __pyx_v_y) {
  double __pyx_v_dist2;
  npy_bool __pyx_r;
  __Pyx_RefNannySetupContext("_inside");

  /* "_region_filter.pyx":675
 *         cdef double dist2
 * 
 *         dist2 = ((x-self.xc)*self.m.g_x)**2 + ((y-self.yc)*self.m.g_y)**2             # <<<<<<<<<<<<<<
 *         return (dist2 <= self.radius2)
 * 
 */
  __pyx_v_dist2 = (pow(((__pyx_v_x - __pyx_v_self->xc) * __pyx_v_self->__pyx_base.m.g_x), 2.0) + pow(((__pyx_v_y - __pyx_v_self->yc) * __pyx_v_self->__pyx_base.m.g_y), 2.0));

  /* "_region_filter.pyx":676
 * 
 *         dist2 = ((x-self.xc)*self.m.g_x)**2 + ((y-self.yc)*self.m.g_y)**2
 *         return (dist2 <= self.radius2)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_r = (__pyx_v_dist2 <= __pyx_v_self->radius2);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":678
 *         return (dist2 <= self.radius2)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "Circle(%f, %f, %f)" % (self.xc, self.yc, self.radius)
 * 
 */

static PyObject *__pyx_pf_14_region_filter_6Circle_1__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_14_region_filter_6Circle_1__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  __Pyx_RefNannySetupContext("__repr__");

  /* "_region_filter.pyx":679
 * 
 *     def __repr__(self):
 *         return "Circle(%f, %f, %f)" % (self.xc, self.yc, self.radius)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_Circle *)__pyx_v_self)->xc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_Circle *)__pyx_v_self)->yc); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_Circle *)__pyx_v_self)->radius); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
  __pyx_r = ((PyObject *)__pyx_t_3);
  __pyx_t_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("_region_filter.Circle.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":700
 * 
 * 
 *     def __init__(self, double xc, double yc,             # <<<<<<<<<<<<<<
 *                  double radius_major, double radius_minor,
 *                  RegionContext c=None):
 */

static int __pyx_pf_14_region_filter_7Ellipse___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_14_region_filter_7Ellipse___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_xc;
  double __pyx_v_yc;
  double __pyx_v_radius_major;
  double __pyx_v_radius_minor;
  struct __pyx_obj_14_region_filter_RegionContext *__pyx_v_c = 0;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__xc,&__pyx_n_s__yc,&__pyx_n_s__radius_major,&__pyx_n_s__radius_minor,&__pyx_n_s__c,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[5] = {0,0,0,0,0};

    /* "_region_filter.pyx":702
 *     def __init__(self, double xc, double yc,
 *                  double radius_major, double radius_minor,
 *                  RegionContext c=None):             # <<<<<<<<<<<<<<
 * 
 *         # check inside
 */
    values[4] = (PyObject *)((struct __pyx_obj_14_region_filter_RegionContext *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__xc);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__yc);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__radius_major);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__radius_minor);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__c);
        if (value) { values[4] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_xc = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_xc == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_yc = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_yc == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_radius_major = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_radius_major == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_radius_minor = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_radius_minor == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_c = ((struct __pyx_obj_14_region_filter_RegionContext *)values[4]);
  } else {
    __pyx_v_c = ((struct __pyx_obj_14_region_filter_RegionContext *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5:
      __pyx_v_c = ((struct __pyx_obj_14_region_filter_RegionContext *)PyTuple_GET_ITEM(__pyx_args, 4));
      case  4:
      __pyx_v_radius_minor = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_radius_minor == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_radius_major = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_radius_major == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_yc = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_yc == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_xc = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_xc == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("_region_filter.Ellipse.__init__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_c), __pyx_ptype_14_region_filter_RegionContext, 1, "c", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "_region_filter.pyx":708
 *         # radius_minor**2*(x-xc)**2 + radius_major**2*(y-yc)**2 < (radius_major*radius_minor)**2
 * 
 *         self.xc = xc             # <<<<<<<<<<<<<<
 *         self.yc = yc
 *         self.radius_major = radius_major
 */
  ((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->xc = __pyx_v_xc;

  /* "_region_filter.pyx":709
 * 
 *         self.xc = xc
 *         self.yc = yc             # <<<<<<<<<<<<<<
 *         self.radius_major = radius_major
 *         self.radius_minor = radius_minor
 */
  ((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->yc = __pyx_v_yc;

  /* "_region_filter.pyx":710
 *         self.xc = xc
 *         self.yc = yc
 *         self.radius_major = radius_major             # <<<<<<<<<<<<<<
 *         self.radius_minor = radius_minor
 *         self.radius_major_2 = radius_major**2
 */
  ((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->radius_major = __pyx_v_radius_major;

  /* "_region_filter.pyx":711
 *         self.yc = yc
 *         self.radius_major = radius_major
 *         self.radius_minor = radius_minor             # <<<<<<<<<<<<<<
 *         self.radius_major_2 = radius_major**2
 *         self.radius_minor_2 = radius_minor**2
 */
  ((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->radius_minor = __pyx_v_radius_minor;

  /* "_region_filter.pyx":712
 *         self.radius_major = radius_major
 *         self.radius_minor = radius_minor
 *         self.radius_major_2 = radius_major**2             # <<<<<<<<<<<<<<
 *         self.radius_minor_2 = radius_minor**2
 *         self.radius_major_2_radius_minor_2 = self.radius_major_2 * self.radius_minor_2
 */
  ((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->radius_major_2 = pow(__pyx_v_radius_major, 2.0);

  /* "_region_filter.pyx":713
 *         self.radius_minor = radius_minor
 *         self.radius_major_2 = radius_major**2
 *         self.radius_minor_2 = radius_minor**2             # <<<<<<<<<<<<<<
 *         self.radius_major_2_radius_minor_2 = self.radius_major_2 * self.radius_minor_2
 * 
 */
  ((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->radius_minor_2 = pow(__pyx_v_radius_minor, 2.0);

  /* "_region_filter.pyx":714
 *         self.radius_major_2 = radius_major**2
 *         self.radius_minor_2 = radius_minor**2
 *         self.radius_major_2_radius_minor_2 = self.radius_major_2 * self.radius_minor_2             # <<<<<<<<<<<<<<
 * 
 *         self.metric_set_origin(xc, yc, c)
 */
  ((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->radius_major_2_radius_minor_2 = (((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->radius_major_2 * ((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->radius_minor_2);

  /* "_region_filter.pyx":716
 *         self.radius_major_2_radius_minor_2 = self.radius_major_2 * self.radius_minor_2
 * 
 *         self.metric_set_origin(xc, yc, c)             # <<<<<<<<<<<<<<
 *         #MetricInit(&(self.m), xc, yc)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_14_region_filter_Ellipse *)((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.metric_set_origin(((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self), __pyx_v_xc, __pyx_v_yc, __pyx_v_c); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("_region_filter.Ellipse.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":720
 * 
 * 
 *     cdef npy_bool _inside(self, double x, double y):             # <<<<<<<<<<<<<<
 *         cdef double dist2
 * 
 */

static  npy_bool __pyx_f_14_region_filter_7Ellipse__inside(struct __pyx_obj_14_region_filter_Ellipse *__pyx_v_self, double __pyx_v_x, double __pyx_v_y) {
  double __pyx_v_dist2;
  npy_bool __pyx_r;
  __Pyx_RefNannySetupContext("_inside");

  /* "_region_filter.pyx":723
 *         cdef double dist2
 * 
 *         dist2 = self.radius_minor_2*(x-self.xc)**2 + self.radius_major_2*(y-self.yc)**2             # <<<<<<<<<<<<<<
 *         return (dist2 <= self.radius_major_2_radius_minor_2)
 * 
 */
  __pyx_v_dist2 = ((__pyx_v_self->radius_minor_2 * pow((__pyx_v_x - __pyx_v_self->xc), 2.0)) + (__pyx_v_self->radius_major_2 * pow((__pyx_v_y - __pyx_v_self->yc), 2.0)));

  /* "_region_filter.pyx":724
 * 
 *         dist2 = self.radius_minor_2*(x-self.xc)**2 + self.radius_major_2*(y-self.yc)**2
 *         return (dist2 <= self.radius_major_2_radius_minor_2)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_r = (__pyx_v_dist2 <= __pyx_v_self->radius_major_2_radius_minor_2);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":726
 *         return (dist2 <= self.radius_major_2_radius_minor_2)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "Ellipse(%f, %f, %f, %f)" % (self.xc, self.yc, self.radius_major, self.radius_minor)
 * 
 */

static PyObject *__pyx_pf_14_region_filter_7Ellipse_1__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_14_region_filter_7Ellipse_1__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__repr__");

  /* "_region_filter.pyx":727
 * 
 *     def __repr__(self):
 *         return "Ellipse(%f, %f, %f, %f)" % (self.xc, self.yc, self.radius_major, self.radius_minor)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->xc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->yc); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->radius_major); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->radius_minor); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __pyx_r = ((PyObject *)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("_region_filter.Ellipse.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":744
 * 
 * 
 *     def __init__(self, double xc, double yc, double width, double height,             # <<<<<<<<<<<<<<
 *                  RegionContext c=None):
 *         cdef double halfwidth
 */

static int __pyx_pf_14_region_filter_3Box___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_14_region_filter_3Box___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_xc;
  double __pyx_v_yc;
  double __pyx_v_width;
  double __pyx_v_height;
  struct __pyx_obj_14_region_filter_RegionContext *__pyx_v_c = 0;
  double __pyx_v_halfwidth;
  double __pyx_v_halfheight;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__xc,&__pyx_n_s__yc,&__pyx_n_s__width,&__pyx_n_s__height,&__pyx_n_s__c,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[5] = {0,0,0,0,0};

    /* "_region_filter.pyx":745
 * 
 *     def __init__(self, double xc, double yc, double width, double height,
 *                  RegionContext c=None):             # <<<<<<<<<<<<<<
 *         cdef double halfwidth
 *         cdef double halfheight
 */
    values[4] = (PyObject *)((struct __pyx_obj_14_region_filter_RegionContext *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__xc);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__yc);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__width);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__height);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__c);
        if (value) { values[4] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_xc = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_xc == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_yc = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_yc == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_width = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_width == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_height = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_height == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_c = ((struct __pyx_obj_14_region_filter_RegionContext *)values[4]);
  } else {
    __pyx_v_c = ((struct __pyx_obj_14_region_filter_RegionContext *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5:
      __pyx_v_c = ((struct __pyx_obj_14_region_filter_RegionContext *)PyTuple_GET_ITEM(__pyx_args, 4));
      case  4:
      __pyx_v_height = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_height == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_width = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_width == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_yc = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_yc == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_xc = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_xc == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("_region_filter.Box.__init__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_c), __pyx_ptype_14_region_filter_RegionContext, 1, "c", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "_region_filter.pyx":749
 *         cdef double halfheight
 * 
 *         halfwidth = width*.5             # <<<<<<<<<<<<<<
 *         halfheight = height*.5
 * 
 */
  __pyx_v_halfwidth = (__pyx_v_width * .5);

  /* "_region_filter.pyx":750
 * 
 *         halfwidth = width*.5
 *         halfheight = height*.5             # <<<<<<<<<<<<<<
 * 
 *         self.x1 = xc - halfwidth
 */
  __pyx_v_halfheight = (__pyx_v_height * .5);

  /* "_region_filter.pyx":752
 *         halfheight = height*.5
 * 
 *         self.x1 = xc - halfwidth             # <<<<<<<<<<<<<<
 *         self.x2 = xc + halfwidth
 *         self.y1 = yc - halfheight
 */
  ((struct __pyx_obj_14_region_filter_Box *)__pyx_v_self)->x1 = (__pyx_v_xc - __pyx_v_halfwidth);

  /* "_region_filter.pyx":753
 * 
 *         self.x1 = xc - halfwidth
 *         self.x2 = xc + halfwidth             # <<<<<<<<<<<<<<
 *         self.y1 = yc - halfheight
 *         self.y2 = yc + halfheight
 */
  ((struct __pyx_obj_14_region_filter_Box *)__pyx_v_self)->x2 = (__pyx_v_xc + __pyx_v_halfwidth);

  /* "_region_filter.pyx":754
 *         self.x1 = xc - halfwidth
 *         self.x2 = xc + halfwidth
 *         self.y1 = yc - halfheight             # <<<<<<<<<<<<<<
 *         self.y2 = yc + halfheight
 * 
 */
  ((struct __pyx_obj_14_region_filter_Box *)__pyx_v_self)->y1 = (__pyx_v_yc - __pyx_v_halfheight);

  /* "_region_filter.pyx":755
 *         self.x2 = xc + halfwidth
 *         self.y1 = yc - halfheight
 *         self.y2 = yc + halfheight             # <<<<<<<<<<<<<<
 * 
 *         self.metric_set_origin(xc, yc, c)
 */
  ((struct __pyx_obj_14_region_filter_Box *)__pyx_v_self)->y2 = (__pyx_v_yc + __pyx_v_halfheight);

  /* "_region_filter.pyx":757
 *         self.y2 = yc + halfheight
 * 
 *         self.metric_set_origin(xc, yc, c)             # <<<<<<<<<<<<<<
 *         #MetricInit(&(self.m), xc, yc)
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_14_region_filter_Box *)((struct __pyx_obj_14_region_filter_Box *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.metric_set_origin(((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self), __pyx_v_xc, __pyx_v_yc, __pyx_v_c); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("_region_filter.Box.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":761
 * 
 * 
 *     cdef npy_bool _inside(self, double x, double y):             # <<<<<<<<<<<<<<
 *         return (self.x1 <= x) & (x <= self.x2) & (self.y1 <= y) & (y <= self.y2)
 * 
 */

static  npy_bool __pyx_f_14_region_filter_3Box__inside(struct __pyx_obj_14_region_filter_Box *__pyx_v_self, double __pyx_v_x, double __pyx_v_y) {
  npy_bool __pyx_r;
  __Pyx_RefNannySetupContext("_inside");

  /* "_region_filter.pyx":762
 * 
 *     cdef npy_bool _inside(self, double x, double y):
 *         return (self.x1 <= x) & (x <= self.x2) & (self.y1 <= y) & (y <= self.y2)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = ((((__pyx_v_self->x1 <= __pyx_v_x) & (__pyx_v_x <= __pyx_v_self->x2)) & (__pyx_v_self->y1 <= __pyx_v_y)) & (__pyx_v_y <= __pyx_v_self->y2));
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":784
 * 
 * 
 *     def __init__(self, x, y,             # <<<<<<<<<<<<<<
 *                  RegionContext c=None):
 *         self.xa = c_numpy.PyArray_CopyFromObject(x, c_numpy.NPY_DOUBLE, 1, 1)
 */

static int __pyx_pf_14_region_filter_7Polygon___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_14_region_filter_7Polygon___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_x = 0;
  PyObject *__pyx_v_y = 0;
  struct __pyx_obj_14_region_filter_RegionContext *__pyx_v_c = 0;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__x,&__pyx_n_s__y,&__pyx_n_s__c,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[3] = {0,0,0};

    /* "_region_filter.pyx":785
 * 
 *     def __init__(self, x, y,
 *                  RegionContext c=None):             # <<<<<<<<<<<<<<
 *         self.xa = c_numpy.PyArray_CopyFromObject(x, c_numpy.NPY_DOUBLE, 1, 1)
 *         self.ya = c_numpy.PyArray_CopyFromObject(y, c_numpy.NPY_DOUBLE, 1, 1)
 */
    values[2] = (PyObject *)((struct __pyx_obj_14_region_filter_RegionContext *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__x);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__y);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__c);
        if (value) { values[2] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_x = values[0];
    __pyx_v_y = values[1];
    __pyx_v_c = ((struct __pyx_obj_14_region_filter_RegionContext *)values[2]);
  } else {
    __pyx_v_c = ((struct __pyx_obj_14_region_filter_RegionContext *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  3:
      __pyx_v_c = ((struct __pyx_obj_14_region_filter_RegionContext *)PyTuple_GET_ITEM(__pyx_args, 2));
      case  2:
      __pyx_v_y = PyTuple_GET_ITEM(__pyx_args, 1);
      __pyx_v_x = PyTuple_GET_ITEM(__pyx_args, 0);
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 784; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("_region_filter.Polygon.__init__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_c), __pyx_ptype_14_region_filter_RegionContext, 1, "c", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "_region_filter.pyx":786
 *     def __init__(self, x, y,
 *                  RegionContext c=None):
 *         self.xa = c_numpy.PyArray_CopyFromObject(x, c_numpy.NPY_DOUBLE, 1, 1)             # <<<<<<<<<<<<<<
 *         self.ya = c_numpy.PyArray_CopyFromObject(y, c_numpy.NPY_DOUBLE, 1, 1)
 * 
 */
  __pyx_t_1 = PyArray_CopyFromObject(__pyx_v_x, NPY_DOUBLE, 1, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7c_numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->xa);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->xa));
  ((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->xa = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "_region_filter.pyx":787
 *                  RegionContext c=None):
 *         self.xa = c_numpy.PyArray_CopyFromObject(x, c_numpy.NPY_DOUBLE, 1, 1)
 *         self.ya = c_numpy.PyArray_CopyFromObject(y, c_numpy.NPY_DOUBLE, 1, 1)             # <<<<<<<<<<<<<<
 * 
 *         self.n = c_numpy.PyArray_SIZE(self.xa)
 */
  __pyx_t_1 = PyArray_CopyFromObject(__pyx_v_y, NPY_DOUBLE, 1, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_7c_numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GIVEREF(__pyx_t_1);
  __Pyx_GOTREF(((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->ya);
  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->ya));
  ((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->ya = ((PyArrayObject *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "_region_filter.pyx":789
 *         self.ya = c_numpy.PyArray_CopyFromObject(y, c_numpy.NPY_DOUBLE, 1, 1)
 * 
 *         self.n = c_numpy.PyArray_SIZE(self.xa)             # <<<<<<<<<<<<<<
 * 
 *         self.x = <double *> c_numpy.PyArray_DATA(self.xa)
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->xa);
  __Pyx_INCREF(__pyx_t_1);
  ((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->n = PyArray_SIZE(((PyArrayObject *)__pyx_t_1));
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "_region_filter.pyx":791
 *         self.n = c_numpy.PyArray_SIZE(self.xa)
 * 
 *         self.x = <double *> c_numpy.PyArray_DATA(self.xa)             # <<<<<<<<<<<<<<
 *         self.y = <double *> c_numpy.PyArray_DATA(self.ya)
 * 
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->xa);
  __Pyx_INCREF(__pyx_t_1);
  ((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->x = ((double *)PyArray_DATA(((PyArrayObject *)__pyx_t_1)));
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "_region_filter.pyx":792
 * 
 *         self.x = <double *> c_numpy.PyArray_DATA(self.xa)
 *         self.y = <double *> c_numpy.PyArray_DATA(self.ya)             # <<<<<<<<<<<<<<
 * 
 *         self.metric_set_origin(self.x[0], self.y[0], c)
 */
  __pyx_t_1 = ((PyObject *)((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->ya);
  __Pyx_INCREF(__pyx_t_1);
  ((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->y = ((double *)PyArray_DATA(((PyArrayObject *)__pyx_t_1)));
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "_region_filter.pyx":794
 *         self.y = <double *> c_numpy.PyArray_DATA(self.ya)
 * 
 *         self.metric_set_origin(self.x[0], self.y[0], c)             # <<<<<<<<<<<<<<
 *         #MetricInit(&(self.m), )
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_14_region_filter_Polygon *)((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.metric_set_origin(((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self), (((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->x[0]), (((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->y[0]), __pyx_v_c); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("_region_filter.Polygon.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":797
 *         #MetricInit(&(self.m), )
 * 
 *     cdef npy_bool _inside(self, double x, double y):             # <<<<<<<<<<<<<<
 *         cdef int i, j
 *         cdef npy_bool r
 */

static  npy_bool __pyx_f_14_region_filter_7Polygon__inside(struct __pyx_obj_14_region_filter_Polygon *__pyx_v_self, double __pyx_v_x, double __pyx_v_y) {
  int __pyx_v_i;
  int __pyx_v_j;
  npy_bool __pyx_v_r;
  double *__pyx_v_xp;
  double *__pyx_v_yp;
  double __pyx_v__t;
  double __pyx_v_y_yp_i;
  double __pyx_v_y_yp_j;
  npy_bool __pyx_r;
  int __pyx_t_1;
  int __pyx_t_2;
  double __pyx_t_3;
  __Pyx_RefNannySetupContext("_inside");

  /* "_region_filter.pyx":806
 * 
 * 
 *         j = self.n - 1             # <<<<<<<<<<<<<<
 *         r = 0
 *         xp = self.x
 */
  __pyx_v_j = (__pyx_v_self->n - 1);

  /* "_region_filter.pyx":807
 * 
 *         j = self.n - 1
 *         r = 0             # <<<<<<<<<<<<<<
 *         xp = self.x
 *         yp = self.y
 */
  __pyx_v_r = 0;

  /* "_region_filter.pyx":808
 *         j = self.n - 1
 *         r = 0
 *         xp = self.x             # <<<<<<<<<<<<<<
 *         yp = self.y
 * 
 */
  __pyx_v_xp = __pyx_v_self->x;

  /* "_region_filter.pyx":809
 *         r = 0
 *         xp = self.x
 *         yp = self.y             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_v_yp = __pyx_v_self->y;

  /* "_region_filter.pyx":822
 * 
 *         #stable version, but would require more time
 *         for i from 0 <= i < self.n:             # <<<<<<<<<<<<<<
 *             y_yp_i = y - yp[i]
 *             y_yp_j = y - yp[j]
 */
  __pyx_t_1 = __pyx_v_self->n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) {

    /* "_region_filter.pyx":823
 *         #stable version, but would require more time
 *         for i from 0 <= i < self.n:
 *             y_yp_i = y - yp[i]             # <<<<<<<<<<<<<<
 *             y_yp_j = y - yp[j]
 * 
 */
    __pyx_v_y_yp_i = (__pyx_v_y - (__pyx_v_yp[__pyx_v_i]));

    /* "_region_filter.pyx":824
 *         for i from 0 <= i < self.n:
 *             y_yp_i = y - yp[i]
 *             y_yp_j = y - yp[j]             # <<<<<<<<<<<<<<
 * 
 *             if (y_yp_i == 0.) & (y_yp_j == 0.): # special case for horizontal line
 */
    __pyx_v_y_yp_j = (__pyx_v_y - (__pyx_v_yp[__pyx_v_j]));

    /* "_region_filter.pyx":826
 *             y_yp_j = y - yp[j]
 * 
 *             if (y_yp_i == 0.) & (y_yp_j == 0.): # special case for horizontal line             # <<<<<<<<<<<<<<
 *                 if (xp[i]-x)*(xp[j]-x) <= 0.:
 *                     return 1
 */
    __pyx_t_2 = ((__pyx_v_y_yp_i == 0.) & (__pyx_v_y_yp_j == 0.));
    if (__pyx_t_2) {

      /* "_region_filter.pyx":827
 * 
 *             if (y_yp_i == 0.) & (y_yp_j == 0.): # special case for horizontal line
 *                 if (xp[i]-x)*(xp[j]-x) <= 0.:             # <<<<<<<<<<<<<<
 *                     return 1
 * 
 */
      __pyx_t_2 = ((((__pyx_v_xp[__pyx_v_i]) - __pyx_v_x) * ((__pyx_v_xp[__pyx_v_j]) - __pyx_v_x)) <= 0.);
      if (__pyx_t_2) {

        /* "_region_filter.pyx":828
 *             if (y_yp_i == 0.) & (y_yp_j == 0.): # special case for horizontal line
 *                 if (xp[i]-x)*(xp[j]-x) <= 0.:
 *                     return 1             # <<<<<<<<<<<<<<
 * 
 *             if ((0<=y_yp_i) & (0>y_yp_j) | (0<=y_yp_j) & (0>y_yp_i)):
 */
        __pyx_r = 1;
        goto __pyx_L0;
        goto __pyx_L6;
      }
      __pyx_L6:;
      goto __pyx_L5;
    }
    __pyx_L5:;

    /* "_region_filter.pyx":830
 *                     return 1
 * 
 *             if ((0<=y_yp_i) & (0>y_yp_j) | (0<=y_yp_j) & (0>y_yp_i)):             # <<<<<<<<<<<<<<
 *                 _t = xp[i]+y_yp_i/(yp[j]-yp[i])*(xp[j]-xp[i])
 *                 if _t == x: # return true immediately if point over the poly-edge
 */
    __pyx_t_2 = (((0.0 <= __pyx_v_y_yp_i) & (0.0 > __pyx_v_y_yp_j)) | ((0.0 <= __pyx_v_y_yp_j) & (0.0 > __pyx_v_y_yp_i)));
    if (__pyx_t_2) {

      /* "_region_filter.pyx":831
 * 
 *             if ((0<=y_yp_i) & (0>y_yp_j) | (0<=y_yp_j) & (0>y_yp_i)):
 *                 _t = xp[i]+y_yp_i/(yp[j]-yp[i])*(xp[j]-xp[i])             # <<<<<<<<<<<<<<
 *                 if _t == x: # return true immediately if point over the poly-edge
 *                     return 1
 */
      __pyx_t_3 = ((__pyx_v_yp[__pyx_v_j]) - (__pyx_v_yp[__pyx_v_i]));
      if (unlikely(__pyx_t_3 == 0)) {
        PyErr_Format(PyExc_ZeroDivisionError, "float division");
        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
      }
      __pyx_v__t = ((__pyx_v_xp[__pyx_v_i]) + ((__pyx_v_y_yp_i / __pyx_t_3) * ((__pyx_v_xp[__pyx_v_j]) - (__pyx_v_xp[__pyx_v_i]))));

      /* "_region_filter.pyx":832
 *             if ((0<=y_yp_i) & (0>y_yp_j) | (0<=y_yp_j) & (0>y_yp_i)):
 *                 _t = xp[i]+y_yp_i/(yp[j]-yp[i])*(xp[j]-xp[i])
 *                 if _t == x: # return true immediately if point over the poly-edge             # <<<<<<<<<<<<<<
 *                     return 1
 *                 # but above does not catch horizontal line
 */
      __pyx_t_2 = (__pyx_v__t == __pyx_v_x);
      if (__pyx_t_2) {

        /* "_region_filter.pyx":833
 *                 _t = xp[i]+y_yp_i/(yp[j]-yp[i])*(xp[j]-xp[i])
 *                 if _t == x: # return true immediately if point over the poly-edge
 *                     return 1             # <<<<<<<<<<<<<<
 *                 # but above does not catch horizontal line
 *                 if (_t<x):
 */
        __pyx_r = 1;
        goto __pyx_L0;
        goto __pyx_L8;
      }
      __pyx_L8:;

      /* "_region_filter.pyx":835
 *                     return 1
 *                 # but above does not catch horizontal line
 *                 if (_t<x):             # <<<<<<<<<<<<<<
 *                     r = not r
 *             j=i
 */
      __pyx_t_2 = (__pyx_v__t < __pyx_v_x);
      if (__pyx_t_2) {

        /* "_region_filter.pyx":836
 *                 # but above does not catch horizontal line
 *                 if (_t<x):
 *                     r = not r             # <<<<<<<<<<<<<<
 *             j=i
 * 
 */
        __pyx_v_r = (!__pyx_v_r);
        goto __pyx_L9;
      }
      __pyx_L9:;
      goto __pyx_L7;
    }
    __pyx_L7:;

    /* "_region_filter.pyx":837
 *                 if (_t<x):
 *                     r = not r
 *             j=i             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_v_j = __pyx_v_i;
  }

  /* "_region_filter.pyx":841
 * 
 * 
 *         return r             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_r = __pyx_v_r;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_WriteUnraisable("_region_filter.Polygon._inside");
  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":860
 * 
 * 
 *     def __init__(self, double xc, double yc,             # <<<<<<<<<<<<<<
 *                  double degree1, double degree2,
 *                  RegionContext c=None):
 */

static int __pyx_pf_14_region_filter_10AngleRange___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_pf_14_region_filter_10AngleRange___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_xc;
  double __pyx_v_yc;
  double __pyx_v_degree1;
  double __pyx_v_degree2;
  struct __pyx_obj_14_region_filter_RegionContext *__pyx_v_c = 0;
  int __pyx_r;
  PyObject *__pyx_t_1 = NULL;
  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__xc,&__pyx_n_s__yc,&__pyx_n_s__degree1,&__pyx_n_s__degree2,&__pyx_n_s__c,0};
  __Pyx_RefNannySetupContext("__init__");
  if (unlikely(__pyx_kwds)) {
    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
    PyObject* values[5] = {0,0,0,0,0};

    /* "_region_filter.pyx":862
 *     def __init__(self, double xc, double yc,
 *                  double degree1, double degree2,
 *                  RegionContext c=None):             # <<<<<<<<<<<<<<
 * 
 *         self.xc = xc
 */
    values[4] = (PyObject *)((struct __pyx_obj_14_region_filter_RegionContext *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
      case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
      case  0: break;
      default: goto __pyx_L5_argtuple_error;
    }
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  0:
      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__xc);
      if (likely(values[0])) kw_args--;
      else goto __pyx_L5_argtuple_error;
      case  1:
      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__yc);
      if (likely(values[1])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  2:
      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__degree1);
      if (likely(values[2])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  3:
      values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__degree2);
      if (likely(values[3])) kw_args--;
      else {
        __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      }
      case  4:
      if (kw_args > 0) {
        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__c);
        if (value) { values[4] = value; kw_args--; }
      }
    }
    if (unlikely(kw_args > 0)) {
      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    }
    __pyx_v_xc = __pyx_PyFloat_AsDouble(values[0]); if (unlikely((__pyx_v_xc == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_yc = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_yc == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_degree1 = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_degree1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_degree2 = __pyx_PyFloat_AsDouble(values[3]); if (unlikely((__pyx_v_degree2 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
    __pyx_v_c = ((struct __pyx_obj_14_region_filter_RegionContext *)values[4]);
  } else {
    __pyx_v_c = ((struct __pyx_obj_14_region_filter_RegionContext *)Py_None);
    switch (PyTuple_GET_SIZE(__pyx_args)) {
      case  5:
      __pyx_v_c = ((struct __pyx_obj_14_region_filter_RegionContext *)PyTuple_GET_ITEM(__pyx_args, 4));
      case  4:
      __pyx_v_degree2 = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_degree2 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_degree1 = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_degree1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_yc = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_yc == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      __pyx_v_xc = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_xc == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
      break;
      default: goto __pyx_L5_argtuple_error;
    }
  }
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
  __pyx_L3_error:;
  __Pyx_AddTraceback("_region_filter.AngleRange.__init__");
  __Pyx_RefNannyFinishContext();
  return -1;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_c), __pyx_ptype_14_region_filter_RegionContext, 1, "c", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}

  /* "_region_filter.pyx":864
 *                  RegionContext c=None):
 * 
 *         self.xc = xc             # <<<<<<<<<<<<<<
 *         self.yc = yc
 *         self.degree1 = degree1
 */
  ((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->xc = __pyx_v_xc;

  /* "_region_filter.pyx":865
 * 
 *         self.xc = xc
 *         self.yc = yc             # <<<<<<<<<<<<<<
 *         self.degree1 = degree1
 *         self.degree2 = degree2
 */
  ((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->yc = __pyx_v_yc;

  /* "_region_filter.pyx":866
 *         self.xc = xc
 *         self.yc = yc
 *         self.degree1 = degree1             # <<<<<<<<<<<<<<
 *         self.degree2 = degree2
 * 
 */
  ((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->degree1 = __pyx_v_degree1;

  /* "_region_filter.pyx":867
 *         self.yc = yc
 *         self.degree1 = degree1
 *         self.degree2 = degree2             # <<<<<<<<<<<<<<
 * 
 *         # theta in radian
 */
  ((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->degree2 = __pyx_v_degree2;

  /* "_region_filter.pyx":870
 * 
 *         # theta in radian
 *         self.radian1 = degree1/180.*M_PI#3.1415926             # <<<<<<<<<<<<<<
 *         self.radian2 = self._fix_angle(degree2/180.*M_PI)
 * 
 */
  ((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->radian1 = ((__pyx_v_degree1 / 180.) * M_PI);

  /* "_region_filter.pyx":871
 *         # theta in radian
 *         self.radian1 = degree1/180.*M_PI#3.1415926
 *         self.radian2 = self._fix_angle(degree2/180.*M_PI)             # <<<<<<<<<<<<<<
 * 
 *         self.metric_set_origin(xc, yc, c)
 */
  ((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->radian2 = ((struct __pyx_vtabstruct_14_region_filter_AngleRange *)((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->__pyx_base.__pyx_vtab)->_fix_angle(((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self), ((__pyx_v_degree2 / 180.) * M_PI));

  /* "_region_filter.pyx":873
 *         self.radian2 = self._fix_angle(degree2/180.*M_PI)
 * 
 *         self.metric_set_origin(xc, yc, c)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_14_region_filter_AngleRange *)((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.metric_set_origin(((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self), __pyx_v_xc, __pyx_v_yc, __pyx_v_c); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("_region_filter.AngleRange.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":876
 * 
 * 
 *     cdef double _fix_angle(self, double a):             # <<<<<<<<<<<<<<
 *         if a > self.radian1:
 *             return self.radian1 + fmod((a-self.radian1), 2*M_PI)
 */

static  double __pyx_f_14_region_filter_10AngleRange__fix_angle(struct __pyx_obj_14_region_filter_AngleRange *__pyx_v_self, double __pyx_v_a) {
  double __pyx_r;
  int __pyx_t_1;
  __Pyx_RefNannySetupContext("_fix_angle");

  /* "_region_filter.pyx":877
 * 
 *     cdef double _fix_angle(self, double a):
 *         if a > self.radian1:             # <<<<<<<<<<<<<<
 *             return self.radian1 + fmod((a-self.radian1), 2*M_PI)
 *         else:
 */
  __pyx_t_1 = (__pyx_v_a > __pyx_v_self->radian1);
  if (__pyx_t_1) {

    /* "_region_filter.pyx":878
 *     cdef double _fix_angle(self, double a):
 *         if a > self.radian1:
 *             return self.radian1 + fmod((a-self.radian1), 2*M_PI)             # <<<<<<<<<<<<<<
 *         else:
 *             return self.radian1 + 2.*M_PI - fmod((self.radian1-a), 2*M_PI)
 */
    __pyx_r = (__pyx_v_self->radian1 + fmod((__pyx_v_a - __pyx_v_self->radian1), (2.0 * M_PI)));
    goto __pyx_L0;
    goto __pyx_L3;
  }
  /*else*/ {

    /* "_region_filter.pyx":880
 *             return self.radian1 + fmod((a-self.radian1), 2*M_PI)
 *         else:
 *             return self.radian1 + 2.*M_PI - fmod((self.radian1-a), 2*M_PI)             # <<<<<<<<<<<<<<
 * 
 * 
 */
    __pyx_r = ((__pyx_v_self->radian1 + (2. * M_PI)) - fmod((__pyx_v_self->radian1 - __pyx_v_a), (2.0 * M_PI)));
    goto __pyx_L0;
  }
  __pyx_L3:;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":883
 * 
 * 
 *     cdef npy_bool _inside(self, double x, double y):             # <<<<<<<<<<<<<<
 *         cdef double dx, dy, theta
 * 
 */

static  npy_bool __pyx_f_14_region_filter_10AngleRange__inside(struct __pyx_obj_14_region_filter_AngleRange *__pyx_v_self, double __pyx_v_x, double __pyx_v_y) {
  double __pyx_v_dx;
  double __pyx_v_dy;
  double __pyx_v_theta;
  npy_bool __pyx_r;
  __Pyx_RefNannySetupContext("_inside");

  /* "_region_filter.pyx":886
 *         cdef double dx, dy, theta
 * 
 *         dx = x - self.xc             # <<<<<<<<<<<<<<
 *         dy = y - self.yc
 * 
 */
  __pyx_v_dx = (__pyx_v_x - __pyx_v_self->xc);

  /* "_region_filter.pyx":887
 * 
 *         dx = x - self.xc
 *         dy = y - self.yc             # <<<<<<<<<<<<<<
 * 
 *         theta = atan2(dy, dx)
 */
  __pyx_v_dy = (__pyx_v_y - __pyx_v_self->yc);

  /* "_region_filter.pyx":889
 *         dy = y - self.yc
 * 
 *         theta = atan2(dy, dx)             # <<<<<<<<<<<<<<
 * 
 *         #if theta < self.radian1:
 */
  __pyx_v_theta = atan2(__pyx_v_dy, __pyx_v_dx);

  /* "_region_filter.pyx":893
 *         #if theta < self.radian1:
 *         #    theta += 2.*M_PI
 *         theta = self._fix_angle(theta)             # <<<<<<<<<<<<<<
 *         return (theta < self.radian2)
 * 
 */
  __pyx_v_theta = ((struct __pyx_vtabstruct_14_region_filter_AngleRange *)__pyx_v_self->__pyx_base.__pyx_vtab)->_fix_angle(__pyx_v_self, __pyx_v_theta);

  /* "_region_filter.pyx":894
 *         #    theta += 2.*M_PI
 *         theta = self._fix_angle(theta)
 *         return (theta < self.radian2)             # <<<<<<<<<<<<<<
 * 
 *     def __repr__(self):
 */
  __pyx_r = (__pyx_v_theta < __pyx_v_self->radian2);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "_region_filter.pyx":896
 *         return (theta < self.radian2)
 * 
 *     def __repr__(self):             # <<<<<<<<<<<<<<
 *         return "AngleRange(%f, %f, %f, %f)" % (self.xc, self.yc, self.degree1, self.degree2)
 */

static PyObject *__pyx_pf_14_region_filter_10AngleRange_1__repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_pf_14_region_filter_10AngleRange_1__repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  __Pyx_RefNannySetupContext("__repr__");

  /* "_region_filter.pyx":897
 * 
 *     def __repr__(self):
 *         return "AngleRange(%f, %f, %f, %f)" % (self.xc, self.yc, self.degree1, self.degree2)             # <<<<<<<<<<<<<<
 */
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->xc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->yc); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->degree1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->degree2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
  __Pyx_GIVEREF(__pyx_t_2);
  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_1 = 0;
  __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
  __pyx_r = ((PyObject *)__pyx_t_4);
  __pyx_t_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("_region_filter.AngleRange.__repr__");
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static struct __pyx_vtabstruct_14_region_filter_RegionContext __pyx_vtable_14_region_filter_RegionContext;

static PyObject *__pyx_tp_new_14_region_filter_RegionContext(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_14_region_filter_RegionContext *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_RegionContext *)o);
  p->__pyx_vtab = __pyx_vtabptr_14_region_filter_RegionContext;
  return o;
}

static void __pyx_tp_dealloc_14_region_filter_RegionContext(PyObject *o) {
  (*Py_TYPE(o)->tp_free)(o);
}

static PyMethodDef __pyx_methods_14_region_filter_RegionContext[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_RegionContext = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_RegionContext = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_RegionContext = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_RegionContext = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_14_region_filter_RegionContext = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("_region_filter.RegionContext"), /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_RegionContext), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_RegionContext, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_RegionContext, /*tp_as_number*/
  &__pyx_tp_as_sequence_RegionContext, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_RegionContext, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_RegionContext, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
  0, /*tp_doc*/
  0, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_14_region_filter_RegionContext, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_14_region_filter_13RegionContext___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_14_region_filter_RegionContext, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_14_region_filter_RegionBase __pyx_vtable_14_region_filter_RegionBase;

static PyObject *__pyx_tp_new_14_region_filter_RegionBase(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_14_region_filter_RegionBase *p;
  PyObject *o = (*t->tp_alloc)(t, 0);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_RegionBase *)o);
  p->__pyx_vtab = __pyx_vtabptr_14_region_filter_RegionBase;
  p->c = ((struct __pyx_obj_14_region_filter_RegionContext *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_14_region_filter_RegionBase(PyObject *o) {
  struct __pyx_obj_14_region_filter_RegionBase *p = (struct __pyx_obj_14_region_filter_RegionBase *)o;
  Py_XDECREF(((PyObject *)p->c));
  (*Py_TYPE(o)->tp_free)(o);
}

static int __pyx_tp_traverse_14_region_filter_RegionBase(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_14_region_filter_RegionBase *p = (struct __pyx_obj_14_region_filter_RegionBase *)o;
  if (p->c) {
    e = (*v)(((PyObject*)p->c), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_14_region_filter_RegionBase(PyObject *o) {
  struct __pyx_obj_14_region_filter_RegionBase *p = (struct __pyx_obj_14_region_filter_RegionBase *)o;
  PyObject* tmp;
  tmp = ((PyObject*)p->c);
  p->c = ((struct __pyx_obj_14_region_filter_RegionContext *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_14_region_filter_RegionBase[] = {
  {__Pyx_NAMESTR("set_context"), (PyCFunction)__pyx_pf_14_region_filter_10RegionBase_1set_context, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("mask"), (PyCFunction)__pyx_pf_14_region_filter_10RegionBase_5mask, METH_O, __Pyx_DOCSTR(__pyx_doc_14_region_filter_10RegionBase_5mask)},
  {__Pyx_NAMESTR("inside1"), (PyCFunction)__pyx_pf_14_region_filter_10RegionBase_6inside1, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_14_region_filter_10RegionBase_6inside1)},
  {__Pyx_NAMESTR("inside"), (PyCFunction)__pyx_pf_14_region_filter_10RegionBase_7inside, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("inside_xy"), (PyCFunction)__pyx_pf_14_region_filter_10RegionBase_8inside_xy, METH_O, __Pyx_DOCSTR(__pyx_doc_14_region_filter_10RegionBase_8inside_xy)},
  {__Pyx_NAMESTR("inside_x_y"), (PyCFunction)__pyx_pf_14_region_filter_10RegionBase_9inside_x_y, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_14_region_filter_10RegionBase_9inside_x_y)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_RegionBase = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  __pyx_pf_14_region_filter_10RegionBase_2__invert__, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  __pyx_pf_14_region_filter_10RegionBase_3__and__, /*nb_and*/
  0, /*nb_xor*/
  __pyx_pf_14_region_filter_10RegionBase_4__or__, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_RegionBase = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_RegionBase = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_RegionBase = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_14_region_filter_RegionBase = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("_region_filter.RegionBase"), /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_RegionBase), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_RegionBase, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_RegionBase, /*tp_as_number*/
  &__pyx_tp_as_sequence_RegionBase, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_RegionBase, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_RegionBase, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_14_region_filter_RegionBase, /*tp_traverse*/
  __pyx_tp_clear_14_region_filter_RegionBase, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_14_region_filter_RegionBase, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_14_region_filter_10RegionBase___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_14_region_filter_RegionBase, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_14_region_filter_RegionNot __pyx_vtable_14_region_filter_RegionNot;

static PyObject *__pyx_tp_new_14_region_filter_RegionNot(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_14_region_filter_RegionNot *p;
  PyObject *o = __pyx_tp_new_14_region_filter_RegionBase(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_RegionNot *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_14_region_filter_RegionBase*)__pyx_vtabptr_14_region_filter_RegionNot;
  p->child_region = ((struct __pyx_obj_14_region_filter_RegionBase *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_14_region_filter_RegionNot(PyObject *o) {
  struct __pyx_obj_14_region_filter_RegionNot *p = (struct __pyx_obj_14_region_filter_RegionNot *)o;
  Py_XDECREF(((PyObject *)p->child_region));
  __pyx_tp_dealloc_14_region_filter_RegionBase(o);
}

static int __pyx_tp_traverse_14_region_filter_RegionNot(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_14_region_filter_RegionNot *p = (struct __pyx_obj_14_region_filter_RegionNot *)o;
  e = __pyx_tp_traverse_14_region_filter_RegionBase(o, v, a); if (e) return e;
  if (p->child_region) {
    e = (*v)(((PyObject*)p->child_region), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_14_region_filter_RegionNot(PyObject *o) {
  struct __pyx_obj_14_region_filter_RegionNot *p = (struct __pyx_obj_14_region_filter_RegionNot *)o;
  PyObject* tmp;
  __pyx_tp_clear_14_region_filter_RegionBase(o);
  tmp = ((PyObject*)p->child_region);
  p->child_region = ((struct __pyx_obj_14_region_filter_RegionBase *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_14_region_filter_RegionNot[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_RegionNot = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_RegionNot = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_RegionNot = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_RegionNot = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_14_region_filter_RegionNot = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("_region_filter.RegionNot"), /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_RegionNot), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_RegionNot, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_RegionNot, /*tp_as_number*/
  &__pyx_tp_as_sequence_RegionNot, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_RegionNot, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_RegionNot, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("\n    >>> r = RegionNot(r2)\n    "), /*tp_doc*/
  __pyx_tp_traverse_14_region_filter_RegionNot, /*tp_traverse*/
  __pyx_tp_clear_14_region_filter_RegionNot, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_14_region_filter_RegionNot, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_14_region_filter_9RegionNot___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_14_region_filter_RegionNot, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_14_region_filter_RegionList __pyx_vtable_14_region_filter_RegionList;

static PyObject *__pyx_tp_new_14_region_filter_RegionList(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_14_region_filter_RegionList *p;
  PyObject *o = __pyx_tp_new_14_region_filter_RegionBase(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_RegionList *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_14_region_filter_RegionBase*)__pyx_vtabptr_14_region_filter_RegionList;
  p->child_regions = Py_None; Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_14_region_filter_RegionList(PyObject *o) {
  struct __pyx_obj_14_region_filter_RegionList *p = (struct __pyx_obj_14_region_filter_RegionList *)o;
  Py_XDECREF(p->child_regions);
  __pyx_tp_dealloc_14_region_filter_RegionBase(o);
}

static int __pyx_tp_traverse_14_region_filter_RegionList(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_14_region_filter_RegionList *p = (struct __pyx_obj_14_region_filter_RegionList *)o;
  e = __pyx_tp_traverse_14_region_filter_RegionBase(o, v, a); if (e) return e;
  if (p->child_regions) {
    e = (*v)(p->child_regions, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_14_region_filter_RegionList(PyObject *o) {
  struct __pyx_obj_14_region_filter_RegionList *p = (struct __pyx_obj_14_region_filter_RegionList *)o;
  PyObject* tmp;
  __pyx_tp_clear_14_region_filter_RegionBase(o);
  tmp = ((PyObject*)p->child_regions);
  p->child_regions = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
static PyObject *__pyx_sq_item_14_region_filter_RegionList(PyObject *o, Py_ssize_t i) {
  PyObject *r;
  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
  Py_DECREF(x);
  return r;
}

static int __pyx_mp_ass_subscript_14_region_filter_RegionList(PyObject *o, PyObject *i, PyObject *v) {
  if (v) {
    return __pyx_pf_14_region_filter_10RegionList_4__setitem__(o, i, v);
  }
  else {
    return __pyx_pf_14_region_filter_10RegionList_5__delitem__(o, i);
  }
}

static PyMethodDef __pyx_methods_14_region_filter_RegionList[] = {
  {__Pyx_NAMESTR("_check_type_of_list"), (PyCFunction)__pyx_pf_14_region_filter_10RegionList__check_type_of_list, METH_O, __Pyx_DOCSTR(0)},
  {__Pyx_NAMESTR("asList"), (PyCFunction)__pyx_pf_14_region_filter_10RegionList_8asList, METH_NOARGS, __Pyx_DOCSTR(0)},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_RegionList = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_RegionList = {
  __pyx_pf_14_region_filter_10RegionList_2__len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_14_region_filter_RegionList, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  __pyx_pf_14_region_filter_10RegionList_6__contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_RegionList = {
  __pyx_pf_14_region_filter_10RegionList_2__len__, /*mp_length*/
  __pyx_pf_14_region_filter_10RegionList_3__getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_14_region_filter_RegionList, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_RegionList = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_14_region_filter_RegionList = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("_region_filter.RegionList"), /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_RegionList), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_RegionList, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pf_14_region_filter_10RegionList_7__repr__, /*tp_repr*/
  &__pyx_tp_as_number_RegionList, /*tp_as_number*/
  &__pyx_tp_as_sequence_RegionList, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_RegionList, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_RegionList, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_14_region_filter_RegionList, /*tp_traverse*/
  __pyx_tp_clear_14_region_filter_RegionList, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_14_region_filter_RegionList, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_14_region_filter_10RegionList_1__init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_14_region_filter_RegionList, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_14_region_filter_RegionOrList __pyx_vtable_14_region_filter_RegionOrList;

static PyObject *__pyx_tp_new_14_region_filter_RegionOrList(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_14_region_filter_RegionOrList *p;
  PyObject *o = __pyx_tp_new_14_region_filter_RegionList(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_RegionOrList *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_14_region_filter_RegionBase*)__pyx_vtabptr_14_region_filter_RegionOrList;
  return o;
}

static PyMethodDef __pyx_methods_14_region_filter_RegionOrList[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_RegionOrList = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_RegionOrList = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_RegionOrList = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_RegionOrList = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_14_region_filter_RegionOrList = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("_region_filter.RegionOrList"), /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_RegionOrList), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_RegionList, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pf_14_region_filter_12RegionOrList___repr__, /*tp_repr*/
  &__pyx_tp_as_number_RegionOrList, /*tp_as_number*/
  &__pyx_tp_as_sequence_RegionOrList, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_RegionOrList, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_RegionOrList, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("\n    >>> r = RegionOrList(r1, r2, r3, r4, ...)\n    "), /*tp_doc*/
  __pyx_tp_traverse_14_region_filter_RegionList, /*tp_traverse*/
  __pyx_tp_clear_14_region_filter_RegionList, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_14_region_filter_RegionOrList, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_14_region_filter_RegionOrList, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_14_region_filter_RegionAndList __pyx_vtable_14_region_filter_RegionAndList;

static PyObject *__pyx_tp_new_14_region_filter_RegionAndList(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_14_region_filter_RegionAndList *p;
  PyObject *o = __pyx_tp_new_14_region_filter_RegionList(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_RegionAndList *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_14_region_filter_RegionBase*)__pyx_vtabptr_14_region_filter_RegionAndList;
  return o;
}

static PyMethodDef __pyx_methods_14_region_filter_RegionAndList[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_RegionAndList = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_RegionAndList = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_RegionAndList = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_RegionAndList = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_14_region_filter_RegionAndList = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("_region_filter.RegionAndList"), /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_RegionAndList), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_RegionList, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pf_14_region_filter_13RegionAndList___repr__, /*tp_repr*/
  &__pyx_tp_as_number_RegionAndList, /*tp_as_number*/
  &__pyx_tp_as_sequence_RegionAndList, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_RegionAndList, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_RegionAndList, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("\n    >>> r = RegionAndList(r1, r2, r3, r4, ...)\n    "), /*tp_doc*/
  __pyx_tp_traverse_14_region_filter_RegionList, /*tp_traverse*/
  __pyx_tp_clear_14_region_filter_RegionList, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_14_region_filter_RegionAndList, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_14_region_filter_RegionAndList, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_14_region_filter_Transform __pyx_vtable_14_region_filter_Transform;

static PyObject *__pyx_tp_new_14_region_filter_Transform(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_14_region_filter_Transform *p;
  PyObject *o = __pyx_tp_new_14_region_filter_RegionBase(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_Transform *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_14_region_filter_RegionBase*)__pyx_vtabptr_14_region_filter_Transform;
  p->child_region = ((struct __pyx_obj_14_region_filter_RegionBase *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_14_region_filter_Transform(PyObject *o) {
  struct __pyx_obj_14_region_filter_Transform *p = (struct __pyx_obj_14_region_filter_Transform *)o;
  Py_XDECREF(((PyObject *)p->child_region));
  __pyx_tp_dealloc_14_region_filter_RegionBase(o);
}

static int __pyx_tp_traverse_14_region_filter_Transform(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_14_region_filter_Transform *p = (struct __pyx_obj_14_region_filter_Transform *)o;
  e = __pyx_tp_traverse_14_region_filter_RegionBase(o, v, a); if (e) return e;
  if (p->child_region) {
    e = (*v)(((PyObject*)p->child_region), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_14_region_filter_Transform(PyObject *o) {
  struct __pyx_obj_14_region_filter_Transform *p = (struct __pyx_obj_14_region_filter_Transform *)o;
  PyObject* tmp;
  __pyx_tp_clear_14_region_filter_RegionBase(o);
  tmp = ((PyObject*)p->child_region);
  p->child_region = ((struct __pyx_obj_14_region_filter_RegionBase *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyObject *__pyx_getprop_14_region_filter_9Transform_child(PyObject *o, void *x) {
  return __pyx_pf_14_region_filter_9Transform_5child___get__(o);
}

static PyMethodDef __pyx_methods_14_region_filter_Transform[] = {
  {0, 0, 0, 0}
};

static struct PyGetSetDef __pyx_getsets_14_region_filter_Transform[] = {
  {(char *)"child", __pyx_getprop_14_region_filter_9Transform_child, 0, 0, 0},
  {0, 0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Transform = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Transform = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Transform = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Transform = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_14_region_filter_Transform = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("_region_filter.Transform"), /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_Transform), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_Transform, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_Transform, /*tp_as_number*/
  &__pyx_tp_as_sequence_Transform, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Transform, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Transform, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_14_region_filter_Transform, /*tp_traverse*/
  __pyx_tp_clear_14_region_filter_Transform, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_14_region_filter_Transform, /*tp_methods*/
  0, /*tp_members*/
  __pyx_getsets_14_region_filter_Transform, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_14_region_filter_9Transform___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_14_region_filter_Transform, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_14_region_filter_Rotated __pyx_vtable_14_region_filter_Rotated;

static PyObject *__pyx_tp_new_14_region_filter_Rotated(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_14_region_filter_Rotated *p;
  PyObject *o = __pyx_tp_new_14_region_filter_Transform(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_Rotated *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_14_region_filter_RegionBase*)__pyx_vtabptr_14_region_filter_Rotated;
  return o;
}

static PyMethodDef __pyx_methods_14_region_filter_Rotated[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Rotated = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Rotated = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Rotated = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Rotated = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_14_region_filter_Rotated = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("_region_filter.Rotated"), /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_Rotated), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_Transform, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_Rotated, /*tp_as_number*/
  &__pyx_tp_as_sequence_Rotated, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Rotated, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Rotated, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("\n    Rotated\n\n     >>> reg = Rotated(child_region, degree, origin_x, origin_y)\n\n\n    Rotate the region by degree in anti-colockwise direction.\n    "), /*tp_doc*/
  __pyx_tp_traverse_14_region_filter_Transform, /*tp_traverse*/
  __pyx_tp_clear_14_region_filter_Transform, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_14_region_filter_Rotated, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_14_region_filter_7Rotated___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_14_region_filter_Rotated, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_14_region_filter_Translated __pyx_vtable_14_region_filter_Translated;

static PyObject *__pyx_tp_new_14_region_filter_Translated(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_14_region_filter_Translated *p;
  PyObject *o = __pyx_tp_new_14_region_filter_Transform(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_Translated *)o);
  p->__pyx_base.__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_14_region_filter_RegionBase*)__pyx_vtabptr_14_region_filter_Translated;
  return o;
}

static PyMethodDef __pyx_methods_14_region_filter_Translated[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Translated = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Translated = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Translated = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Translated = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_14_region_filter_Translated = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("_region_filter.Translated"), /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_Translated), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_Transform, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_Translated, /*tp_as_number*/
  &__pyx_tp_as_sequence_Translated, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Translated, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Translated, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("\n    Translated region\n\n     >>> Translate(child_region, dx, dy)\n    "), /*tp_doc*/
  __pyx_tp_traverse_14_region_filter_Transform, /*tp_traverse*/
  __pyx_tp_clear_14_region_filter_Transform, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_14_region_filter_Translated, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_14_region_filter_10Translated___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_14_region_filter_Translated, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_14_region_filter_Circle __pyx_vtable_14_region_filter_Circle;

static PyObject *__pyx_tp_new_14_region_filter_Circle(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_14_region_filter_Circle *p;
  PyObject *o = __pyx_tp_new_14_region_filter_RegionBase(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_Circle *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_14_region_filter_RegionBase*)__pyx_vtabptr_14_region_filter_Circle;
  return o;
}

static PyMethodDef __pyx_methods_14_region_filter_Circle[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Circle = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Circle = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Circle = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Circle = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_14_region_filter_Circle = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("_region_filter.Circle"), /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_Circle), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_RegionBase, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pf_14_region_filter_6Circle_1__repr__, /*tp_repr*/
  &__pyx_tp_as_number_Circle, /*tp_as_number*/
  &__pyx_tp_as_sequence_Circle, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Circle, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Circle, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("\n    Circle\n\n      >>> cir = Circle(xc, yc, radius, RegionContext c=None)\n\n    "), /*tp_doc*/
  __pyx_tp_traverse_14_region_filter_RegionBase, /*tp_traverse*/
  __pyx_tp_clear_14_region_filter_RegionBase, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_14_region_filter_Circle, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_14_region_filter_6Circle___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_14_region_filter_Circle, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_14_region_filter_Ellipse __pyx_vtable_14_region_filter_Ellipse;

static PyObject *__pyx_tp_new_14_region_filter_Ellipse(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_14_region_filter_Ellipse *p;
  PyObject *o = __pyx_tp_new_14_region_filter_RegionBase(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_Ellipse *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_14_region_filter_RegionBase*)__pyx_vtabptr_14_region_filter_Ellipse;
  return o;
}

static PyMethodDef __pyx_methods_14_region_filter_Ellipse[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Ellipse = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Ellipse = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Ellipse = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Ellipse = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_14_region_filter_Ellipse = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("_region_filter.Ellipse"), /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_Ellipse), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_RegionBase, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pf_14_region_filter_7Ellipse_1__repr__, /*tp_repr*/
  &__pyx_tp_as_number_Ellipse, /*tp_as_number*/
  &__pyx_tp_as_sequence_Ellipse, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Ellipse, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Ellipse, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("\n    Ellipse\n\n      >>> shape = Ellipse(xc, yc, radius_major, radius_minor)\n\n    "), /*tp_doc*/
  __pyx_tp_traverse_14_region_filter_RegionBase, /*tp_traverse*/
  __pyx_tp_clear_14_region_filter_RegionBase, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_14_region_filter_Ellipse, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_14_region_filter_7Ellipse___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_14_region_filter_Ellipse, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_14_region_filter_Box __pyx_vtable_14_region_filter_Box;

static PyObject *__pyx_tp_new_14_region_filter_Box(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_14_region_filter_Box *p;
  PyObject *o = __pyx_tp_new_14_region_filter_RegionBase(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_Box *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_14_region_filter_RegionBase*)__pyx_vtabptr_14_region_filter_Box;
  return o;
}

static PyMethodDef __pyx_methods_14_region_filter_Box[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Box = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Box = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Box = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Box = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_14_region_filter_Box = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("_region_filter.Box"), /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_Box), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_RegionBase, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_Box, /*tp_as_number*/
  &__pyx_tp_as_sequence_Box, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Box, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Box, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("\n    Box\n\n    >>> shape = Box(xc, yc, width, height)\n\n    "), /*tp_doc*/
  __pyx_tp_traverse_14_region_filter_RegionBase, /*tp_traverse*/
  __pyx_tp_clear_14_region_filter_RegionBase, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_14_region_filter_Box, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_14_region_filter_3Box___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_14_region_filter_Box, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_14_region_filter_Polygon __pyx_vtable_14_region_filter_Polygon;

static PyObject *__pyx_tp_new_14_region_filter_Polygon(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_14_region_filter_Polygon *p;
  PyObject *o = __pyx_tp_new_14_region_filter_RegionBase(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_Polygon *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_14_region_filter_RegionBase*)__pyx_vtabptr_14_region_filter_Polygon;
  p->xa = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  p->ya = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  return o;
}

static void __pyx_tp_dealloc_14_region_filter_Polygon(PyObject *o) {
  struct __pyx_obj_14_region_filter_Polygon *p = (struct __pyx_obj_14_region_filter_Polygon *)o;
  Py_XDECREF(((PyObject *)p->xa));
  Py_XDECREF(((PyObject *)p->ya));
  __pyx_tp_dealloc_14_region_filter_RegionBase(o);
}

static int __pyx_tp_traverse_14_region_filter_Polygon(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_14_region_filter_Polygon *p = (struct __pyx_obj_14_region_filter_Polygon *)o;
  e = __pyx_tp_traverse_14_region_filter_RegionBase(o, v, a); if (e) return e;
  if (p->xa) {
    e = (*v)(((PyObject*)p->xa), a); if (e) return e;
  }
  if (p->ya) {
    e = (*v)(((PyObject*)p->ya), a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_14_region_filter_Polygon(PyObject *o) {
  struct __pyx_obj_14_region_filter_Polygon *p = (struct __pyx_obj_14_region_filter_Polygon *)o;
  PyObject* tmp;
  __pyx_tp_clear_14_region_filter_RegionBase(o);
  tmp = ((PyObject*)p->xa);
  p->xa = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  tmp = ((PyObject*)p->ya);
  p->ya = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}

static PyMethodDef __pyx_methods_14_region_filter_Polygon[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_Polygon = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_Polygon = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_Polygon = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_Polygon = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_14_region_filter_Polygon = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("_region_filter.Polygon"), /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_Polygon), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_Polygon, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  0, /*tp_repr*/
  &__pyx_tp_as_number_Polygon, /*tp_as_number*/
  &__pyx_tp_as_sequence_Polygon, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_Polygon, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_Polygon, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("\n    Polygon\n\n     >>> shape = Polygon(x, y)\n\n     x, y : list of floats\n    "), /*tp_doc*/
  __pyx_tp_traverse_14_region_filter_Polygon, /*tp_traverse*/
  __pyx_tp_clear_14_region_filter_Polygon, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_14_region_filter_Polygon, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_14_region_filter_7Polygon___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_14_region_filter_Polygon, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};
static struct __pyx_vtabstruct_14_region_filter_AngleRange __pyx_vtable_14_region_filter_AngleRange;

static PyObject *__pyx_tp_new_14_region_filter_AngleRange(PyTypeObject *t, PyObject *a, PyObject *k) {
  struct __pyx_obj_14_region_filter_AngleRange *p;
  PyObject *o = __pyx_tp_new_14_region_filter_RegionBase(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_AngleRange *)o);
  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_14_region_filter_RegionBase*)__pyx_vtabptr_14_region_filter_AngleRange;
  return o;
}

static PyMethodDef __pyx_methods_14_region_filter_AngleRange[] = {
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_AngleRange = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_divide*/
  #endif
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  0, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  0, /*nb_and*/
  0, /*nb_xor*/
  0, /*nb_or*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_coerce*/
  #endif
  0, /*nb_int*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_long*/
  #else
  0, /*reserved*/
  #endif
  0, /*nb_float*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_oct*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*nb_hex*/
  #endif
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  #if PY_MAJOR_VERSION < 3
  0, /*nb_inplace_divide*/
  #endif
  0, /*nb_inplace_remainder*/
  0, /*nb_inplace_power*/
  0, /*nb_inplace_lshift*/
  0, /*nb_inplace_rshift*/
  0, /*nb_inplace_and*/
  0, /*nb_inplace_xor*/
  0, /*nb_inplace_or*/
  0, /*nb_floor_divide*/
  0, /*nb_true_divide*/
  0, /*nb_inplace_floor_divide*/
  0, /*nb_inplace_true_divide*/
  #if PY_VERSION_HEX >= 0x02050000
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_AngleRange = {
  0, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  0, /*sq_item*/
  0, /*sq_slice*/
  0, /*sq_ass_item*/
  0, /*sq_ass_slice*/
  0, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_AngleRange = {
  0, /*mp_length*/
  0, /*mp_subscript*/
  0, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_AngleRange = {
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getreadbuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getwritebuffer*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getsegcount*/
  #endif
  #if PY_MAJOR_VERSION < 3
  0, /*bf_getcharbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_getbuffer*/
  #endif
  #if PY_VERSION_HEX >= 0x02060000
  0, /*bf_releasebuffer*/
  #endif
};

static PyTypeObject __pyx_type_14_region_filter_AngleRange = {
  PyVarObject_HEAD_INIT(0, 0)
  __Pyx_NAMESTR("_region_filter.AngleRange"), /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_AngleRange), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_RegionBase, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  #if PY_MAJOR_VERSION < 3
  0, /*tp_compare*/
  #else
  0, /*reserved*/
  #endif
  __pyx_pf_14_region_filter_10AngleRange_1__repr__, /*tp_repr*/
  &__pyx_tp_as_number_AngleRange, /*tp_as_number*/
  &__pyx_tp_as_sequence_AngleRange, /*tp_as_sequence*/
  &__pyx_tp_as_mapping_AngleRange, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  &__pyx_tp_as_buffer_AngleRange, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  __Pyx_DOCSTR("\n    AngleRange\n\n      >>> shape = Ellipse(xc, yc, degree1, degree2)\n\n    "), /*tp_doc*/
  __pyx_tp_traverse_14_region_filter_RegionBase, /*tp_traverse*/
  __pyx_tp_clear_14_region_filter_RegionBase, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  __pyx_methods_14_region_filter_AngleRange, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  0, /*tp_dictoffset*/
  __pyx_pf_14_region_filter_10AngleRange___init__, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_14_region_filter_AngleRange, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  #if PY_VERSION_HEX >= 0x02060000
  0, /*tp_version_tag*/
  #endif
};

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef __pyx_moduledef = {
    PyModuleDef_HEAD_INIT,
    __Pyx_NAMESTR("_region_filter"),
    0, /* m_doc */
    -1, /* m_size */
    __pyx_methods /* m_methods */,
    NULL, /* m_reload */
    NULL, /* m_traverse */
    NULL, /* m_clear */
    NULL /* m_free */
};
#endif

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 1},
  {&__pyx_n_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 1},
  {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
  {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
  {&__pyx_kp_u_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 1, 0, 0},
  {&__pyx_kp_u_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 1, 0, 0},
  {&__pyx_kp_u_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 1, 0, 0},
  {&__pyx_kp_u_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 1, 0, 0},
  {&__pyx_n_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 1},
  {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
  {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
  {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
  {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
  {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
  {&__pyx_n_s__And, __pyx_k__And, sizeof(__pyx_k__And), 0, 0, 1, 1},
  {&__pyx_n_s__Exception, __pyx_k__Exception, sizeof(__pyx_k__Exception), 0, 0, 1, 1},
  {&__pyx_n_s__NotYetImplemented, __pyx_k__NotYetImplemented, sizeof(__pyx_k__NotYetImplemented), 0, 0, 1, 1},
  {&__pyx_n_s__Or, __pyx_k__Or, sizeof(__pyx_k__Or), 0, 0, 1, 1},
  {&__pyx_n_s__RegionAnd, __pyx_k__RegionAnd, sizeof(__pyx_k__RegionAnd), 0, 0, 1, 1},
  {&__pyx_n_s__RegionOr, __pyx_k__RegionOr, sizeof(__pyx_k__RegionOr), 0, 0, 1, 1},
  {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
  {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
  {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 0, 0, 1, 1},
  {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
  {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
  {&__pyx_n_s___check_type_of_list, __pyx_k___check_type_of_list, sizeof(__pyx_k___check_type_of_list), 0, 0, 1, 1},
  {&__pyx_n_s___fix_angle, __pyx_k___fix_angle, sizeof(__pyx_k___fix_angle), 0, 0, 1, 1},
  {&__pyx_n_s___inside, __pyx_k___inside, sizeof(__pyx_k___inside), 0, 0, 1, 1},
  {&__pyx_n_s___mask, __pyx_k___mask, sizeof(__pyx_k___mask), 0, 0, 1, 1},
  {&__pyx_n_s___region_filter, __pyx_k___region_filter, sizeof(__pyx_k___region_filter), 0, 0, 1, 1},
  {&__pyx_n_s___set_v, __pyx_k___set_v, sizeof(__pyx_k___set_v), 0, 0, 1, 1},
  {&__pyx_n_s___transform, __pyx_k___transform, sizeof(__pyx_k___transform), 0, 0, 1, 1},
  {&__pyx_n_s__asList, __pyx_k__asList, sizeof(__pyx_k__asList), 0, 0, 1, 1},
  {&__pyx_n_s__c, __pyx_k__c, sizeof(__pyx_k__c), 0, 0, 1, 1},
  {&__pyx_n_s__child_region, __pyx_k__child_region, sizeof(__pyx_k__child_region), 0, 0, 1, 1},
  {&__pyx_n_s__child_regions, __pyx_k__child_regions, sizeof(__pyx_k__child_regions), 0, 0, 1, 1},
  {&__pyx_n_s__cos_theta, __pyx_k__cos_theta, sizeof(__pyx_k__cos_theta), 0, 0, 1, 1},
  {&__pyx_n_s__degree, __pyx_k__degree, sizeof(__pyx_k__degree), 0, 0, 1, 1},
  {&__pyx_n_s__degree1, __pyx_k__degree1, sizeof(__pyx_k__degree1), 0, 0, 1, 1},
  {&__pyx_n_s__degree2, __pyx_k__degree2, sizeof(__pyx_k__degree2), 0, 0, 1, 1},
  {&__pyx_n_s__dimensions, __pyx_k__dimensions, sizeof(__pyx_k__dimensions), 0, 0, 1, 1},
  {&__pyx_n_s__dx, __pyx_k__dx, sizeof(__pyx_k__dx), 0, 0, 1, 1},
  {&__pyx_n_s__dy, __pyx_k__dy, sizeof(__pyx_k__dy), 0, 0, 1, 1},
  {&__pyx_n_s__g_x, __pyx_k__g_x, sizeof(__pyx_k__g_x), 0, 0, 1, 1},
  {&__pyx_n_s__g_y, __pyx_k__g_y, sizeof(__pyx_k__g_y), 0, 0, 1, 1},
  {&__pyx_n_s__height, __pyx_k__height, sizeof(__pyx_k__height), 0, 0, 1, 1},
  {&__pyx_n_s__inside_x_y, __pyx_k__inside_x_y, sizeof(__pyx_k__inside_x_y), 0, 0, 1, 1},
  {&__pyx_n_s__inside_xy, __pyx_k__inside_xy, sizeof(__pyx_k__inside_xy), 0, 0, 1, 1},
  {&__pyx_n_s__m, __pyx_k__m, sizeof(__pyx_k__m), 0, 0, 1, 1},
  {&__pyx_n_s__metric_set_origin, __pyx_k__metric_set_origin, sizeof(__pyx_k__metric_set_origin), 0, 0, 1, 1},
  {&__pyx_n_s__n, __pyx_k__n, sizeof(__pyx_k__n), 0, 0, 1, 1},
  {&__pyx_n_s__nd, __pyx_k__nd, sizeof(__pyx_k__nd), 0, 0, 1, 1},
  {&__pyx_n_s__origin_x, __pyx_k__origin_x, sizeof(__pyx_k__origin_x), 0, 0, 1, 1},
  {&__pyx_n_s__origin_y, __pyx_k__origin_y, sizeof(__pyx_k__origin_y), 0, 0, 1, 1},
  {&__pyx_n_s__radian1, __pyx_k__radian1, sizeof(__pyx_k__radian1), 0, 0, 1, 1},
  {&__pyx_n_s__radian2, __pyx_k__radian2, sizeof(__pyx_k__radian2), 0, 0, 1, 1},
  {&__pyx_n_s__radius, __pyx_k__radius, sizeof(__pyx_k__radius), 0, 0, 1, 1},
  {&__pyx_n_s__radius2, __pyx_k__radius2, sizeof(__pyx_k__radius2), 0, 0, 1, 1},
  {&__pyx_n_s__radius_major, __pyx_k__radius_major, sizeof(__pyx_k__radius_major), 0, 0, 1, 1},
  {&__pyx_n_s__radius_major_2, __pyx_k__radius_major_2, sizeof(__pyx_k__radius_major_2), 0, 0, 1, 1},
  {&__pyx_n_s__radius_minor, __pyx_k__radius_minor, sizeof(__pyx_k__radius_minor), 0, 0, 1, 1},
  {&__pyx_n_s__radius_minor_2, __pyx_k__radius_minor_2, sizeof(__pyx_k__radius_minor_2), 0, 0, 1, 1},
  {&__pyx_n_s__region1, __pyx_k__region1, sizeof(__pyx_k__region1), 0, 0, 1, 1},
  {&__pyx_n_s__region2, __pyx_k__region2, sizeof(__pyx_k__region2), 0, 0, 1, 1},
  {&__pyx_n_s__set_context, __pyx_k__set_context, sizeof(__pyx_k__set_context), 0, 0, 1, 1},
  {&__pyx_n_s__set_update_func, __pyx_k__set_update_func, sizeof(__pyx_k__set_update_func), 0, 0, 1, 1},
  {&__pyx_n_s__shape, __pyx_k__shape, sizeof(__pyx_k__shape), 0, 0, 1, 1},
  {&__pyx_n_s__sin_theta, __pyx_k__sin_theta, sizeof(__pyx_k__sin_theta), 0, 0, 1, 1},
  {&__pyx_n_s__update_metric, __pyx_k__update_metric, sizeof(__pyx_k__update_metric), 0, 0, 1, 1},
  {&__pyx_n_s__width, __pyx_k__width, sizeof(__pyx_k__width), 0, 0, 1, 1},
  {&__pyx_n_s__x, __pyx_k__x, sizeof(__pyx_k__x), 0, 0, 1, 1},
  {&__pyx_n_s__x0, __pyx_k__x0, sizeof(__pyx_k__x0), 0, 0, 1, 1},
  {&__pyx_n_s__x1, __pyx_k__x1, sizeof(__pyx_k__x1), 0, 0, 1, 1},
  {&__pyx_n_s__x2, __pyx_k__x2, sizeof(__pyx_k__x2), 0, 0, 1, 1},
  {&__pyx_n_s__xa, __pyx_k__xa, sizeof(__pyx_k__xa), 0, 0, 1, 1},
  {&__pyx_n_s__xc, __pyx_k__xc, sizeof(__pyx_k__xc), 0, 0, 1, 1},
  {&__pyx_n_s__y, __pyx_k__y, sizeof(__pyx_k__y), 0, 0, 1, 1},
  {&__pyx_n_s__y0, __pyx_k__y0, sizeof(__pyx_k__y0), 0, 0, 1, 1},
  {&__pyx_n_s__y1, __pyx_k__y1, sizeof(__pyx_k__y1), 0, 0, 1, 1},
  {&__pyx_n_s__y2, __pyx_k__y2, sizeof(__pyx_k__y2), 0, 0, 1, 1},
  {&__pyx_n_s__ya, __pyx_k__ya, sizeof(__pyx_k__ya), 0, 0, 1, 1},
  {&__pyx_n_s__yc, __pyx_k__yc, sizeof(__pyx_k__yc), 0, 0, 1, 1},
  {0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
  __pyx_builtin_Exception = __Pyx_GetName(__pyx_b, __pyx_n_s__Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  return 0;
  __pyx_L1_error:;
  return -1;
}

static int __Pyx_InitCachedConstants(void) {
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants");

  /* "_region_filter.pyx":158
 *             shape = img_or_shape
 *         else:
 *             raise RegionFilterException("the inut needs to be a numpy 2-d array or a tuple of two integers")             # <<<<<<<<<<<<<<
 * 
 *         if c_python.PySequence_Length(shape) != 2:
 */
  __pyx_k_tuple_4 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_4));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
  PyTuple_SET_ITEM(__pyx_k_tuple_4, 0, ((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_4));

  /* "_region_filter.pyx":205
 *                 return self.inside_xy(x)
 *             else:
 *                 raise ValueError("input array has a wrong shape")             # <<<<<<<<<<<<<<
 *         else:
 *             return self.inside_x_y(x, y)
 */
  __pyx_k_tuple_7 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_7));
  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
  PyTuple_SET_ITEM(__pyx_k_tuple_7, 0, ((PyObject *)__pyx_kp_s_6));
  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_7));
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_InitGlobals(void) {
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  return 0;
  __pyx_L1_error:;
  return -1;
}

#if PY_MAJOR_VERSION < 3
PyMODINIT_FUNC init_region_filter(void); /*proto*/
PyMODINIT_FUNC init_region_filter(void)
#else
PyMODINIT_FUNC PyInit__region_filter(void); /*proto*/
PyMODINIT_FUNC PyInit__region_filter(void)
#endif
{
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  #if CYTHON_REFNANNY
  void* __pyx_refnanny = NULL;
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
      PyErr_Clear();
      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
      if (!__Pyx_RefNanny)
          Py_FatalError("failed to import 'refnanny' module");
  }
  __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit__region_filter(void)", __LINE__, __FILE__);
  #endif
  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #ifdef __pyx_binding_PyCFunctionType_USED
  if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  #endif
  /*--- Library function declarations ---*/
  /*--- Threads initialization code ---*/
  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
  #ifdef WITH_THREAD /* Python build with threading support? */
  PyEval_InitThreads();
  #endif
  #endif
  /*--- Module creation code ---*/
  #if PY_MAJOR_VERSION < 3
  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_region_filter"), __pyx_methods, 0, 0, PYTHON_API_VERSION);
  #else
  __pyx_m = PyModule_Create(&__pyx_moduledef);
  #endif
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  #if PY_MAJOR_VERSION < 3
  Py_INCREF(__pyx_m);
  #endif
  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  /*--- Initialize various global constants etc. ---*/
  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__pyx_module_is_main__region_filter) {
    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
  }
  /*--- Builtin init code ---*/
  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Constants init code ---*/
  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Global init code ---*/
  __pyx_v_14_region_filter_metric_wcs = ((struct __pyx_obj_14_region_filter_RegionContext *)Py_None); Py_INCREF(Py_None);
  /*--- Function export code ---*/
  /*--- Type init code ---*/
  __pyx_vtabptr_14_region_filter_RegionContext = &__pyx_vtable_14_region_filter_RegionContext;
  __pyx_vtable_14_region_filter_RegionContext.set_update_func = (PyObject *(*)(struct __pyx_obj_14_region_filter_RegionContext *, int (*)(struct __pyx_t_14_region_filter_Metric *)))__pyx_f_14_region_filter_13RegionContext_set_update_func;
  if (PyType_Ready(&__pyx_type_14_region_filter_RegionContext) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_14_region_filter_RegionContext.tp_dict, __pyx_vtabptr_14_region_filter_RegionContext) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "RegionContext", (PyObject *)&__pyx_type_14_region_filter_RegionContext) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_14_region_filter_RegionContext = &__pyx_type_14_region_filter_RegionContext;
  __pyx_vtabptr_14_region_filter_RegionBase = &__pyx_vtable_14_region_filter_RegionBase;
  __pyx_vtable_14_region_filter_RegionBase.update_metric = (PyObject *(*)(struct __pyx_obj_14_region_filter_RegionBase *))__pyx_f_14_region_filter_10RegionBase_update_metric;
  __pyx_vtable_14_region_filter_RegionBase.metric_set_origin = (PyObject *(*)(struct __pyx_obj_14_region_filter_RegionBase *, double, double, struct __pyx_obj_14_region_filter_RegionContext *))__pyx_f_14_region_filter_10RegionBase_metric_set_origin;
  __pyx_vtable_14_region_filter_RegionBase._inside = (npy_bool (*)(struct __pyx_obj_14_region_filter_RegionBase *, double, double))__pyx_f_14_region_filter_10RegionBase__inside;
  __pyx_vtable_14_region_filter_RegionBase._mask = (PyArrayObject *(*)(struct __pyx_obj_14_region_filter_RegionBase *, npy_intp, npy_intp))__pyx_f_14_region_filter_10RegionBase__mask;
  if (PyType_Ready(&__pyx_type_14_region_filter_RegionBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_14_region_filter_RegionBase.tp_dict, __pyx_vtabptr_14_region_filter_RegionBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "RegionBase", (PyObject *)&__pyx_type_14_region_filter_RegionBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_14_region_filter_RegionBase = &__pyx_type_14_region_filter_RegionBase;
  __pyx_vtabptr_14_region_filter_RegionNot = &__pyx_vtable_14_region_filter_RegionNot;
  __pyx_vtable_14_region_filter_RegionNot.__pyx_base = *__pyx_vtabptr_14_region_filter_RegionBase;
  __pyx_vtable_14_region_filter_RegionNot.__pyx_base._inside = (npy_bool (*)(struct __pyx_obj_14_region_filter_RegionBase *, double, double))__pyx_f_14_region_filter_9RegionNot__inside;
  __pyx_type_14_region_filter_RegionNot.tp_base = __pyx_ptype_14_region_filter_RegionBase;
  if (PyType_Ready(&__pyx_type_14_region_filter_RegionNot) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_14_region_filter_RegionNot.tp_dict, __pyx_vtabptr_14_region_filter_RegionNot) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "RegionNot", (PyObject *)&__pyx_type_14_region_filter_RegionNot) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_14_region_filter_RegionNot = &__pyx_type_14_region_filter_RegionNot;
  __pyx_vtabptr_14_region_filter_RegionList = &__pyx_vtable_14_region_filter_RegionList;
  __pyx_vtable_14_region_filter_RegionList.__pyx_base = *__pyx_vtabptr_14_region_filter_RegionBase;
  __pyx_type_14_region_filter_RegionList.tp_base = __pyx_ptype_14_region_filter_RegionBase;
  if (PyType_Ready(&__pyx_type_14_region_filter_RegionList) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_14_region_filter_RegionList.tp_dict, __pyx_vtabptr_14_region_filter_RegionList) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "RegionList", (PyObject *)&__pyx_type_14_region_filter_RegionList) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_14_region_filter_RegionList = &__pyx_type_14_region_filter_RegionList;
  __pyx_vtabptr_14_region_filter_RegionOrList = &__pyx_vtable_14_region_filter_RegionOrList;
  __pyx_vtable_14_region_filter_RegionOrList.__pyx_base = *__pyx_vtabptr_14_region_filter_RegionList;
  __pyx_vtable_14_region_filter_RegionOrList.__pyx_base.__pyx_base._inside = (npy_bool (*)(struct __pyx_obj_14_region_filter_RegionBase *, double, double))__pyx_f_14_region_filter_12RegionOrList__inside;
  __pyx_type_14_region_filter_RegionOrList.tp_base = __pyx_ptype_14_region_filter_RegionList;
  if (PyType_Ready(&__pyx_type_14_region_filter_RegionOrList) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_14_region_filter_RegionOrList.tp_dict, __pyx_vtabptr_14_region_filter_RegionOrList) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "RegionOrList", (PyObject *)&__pyx_type_14_region_filter_RegionOrList) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_14_region_filter_RegionOrList = &__pyx_type_14_region_filter_RegionOrList;
  __pyx_vtabptr_14_region_filter_RegionAndList = &__pyx_vtable_14_region_filter_RegionAndList;
  __pyx_vtable_14_region_filter_RegionAndList.__pyx_base = *__pyx_vtabptr_14_region_filter_RegionList;
  __pyx_vtable_14_region_filter_RegionAndList.__pyx_base.__pyx_base._inside = (npy_bool (*)(struct __pyx_obj_14_region_filter_RegionBase *, double, double))__pyx_f_14_region_filter_13RegionAndList__inside;
  __pyx_type_14_region_filter_RegionAndList.tp_base = __pyx_ptype_14_region_filter_RegionList;
  if (PyType_Ready(&__pyx_type_14_region_filter_RegionAndList) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_14_region_filter_RegionAndList.tp_dict, __pyx_vtabptr_14_region_filter_RegionAndList) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "RegionAndList", (PyObject *)&__pyx_type_14_region_filter_RegionAndList) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_14_region_filter_RegionAndList = &__pyx_type_14_region_filter_RegionAndList;
  __pyx_vtabptr_14_region_filter_Transform = &__pyx_vtable_14_region_filter_Transform;
  __pyx_vtable_14_region_filter_Transform.__pyx_base = *__pyx_vtabptr_14_region_filter_RegionBase;
  __pyx_vtable_14_region_filter_Transform.__pyx_base._inside = (npy_bool (*)(struct __pyx_obj_14_region_filter_RegionBase *, double, double))__pyx_f_14_region_filter_9Transform__inside;
  __pyx_vtable_14_region_filter_Transform._transform = (int (*)(struct __pyx_obj_14_region_filter_Transform *, double, double, double *, double *))__pyx_f_14_region_filter_9Transform__transform;
  __pyx_type_14_region_filter_Transform.tp_base = __pyx_ptype_14_region_filter_RegionBase;
  if (PyType_Ready(&__pyx_type_14_region_filter_Transform) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_14_region_filter_Transform.tp_dict, __pyx_vtabptr_14_region_filter_Transform) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Transform", (PyObject *)&__pyx_type_14_region_filter_Transform) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_14_region_filter_Transform = &__pyx_type_14_region_filter_Transform;
  __pyx_vtabptr_14_region_filter_Rotated = &__pyx_vtable_14_region_filter_Rotated;
  __pyx_vtable_14_region_filter_Rotated.__pyx_base = *__pyx_vtabptr_14_region_filter_Transform;
  __pyx_vtable_14_region_filter_Rotated.__pyx_base._transform = (int (*)(struct __pyx_obj_14_region_filter_Transform *, double, double, double *, double *))__pyx_f_14_region_filter_7Rotated__transform;
  __pyx_type_14_region_filter_Rotated.tp_base = __pyx_ptype_14_region_filter_Transform;
  if (PyType_Ready(&__pyx_type_14_region_filter_Rotated) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_14_region_filter_Rotated.tp_dict, __pyx_vtabptr_14_region_filter_Rotated) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Rotated", (PyObject *)&__pyx_type_14_region_filter_Rotated) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_14_region_filter_Rotated = &__pyx_type_14_region_filter_Rotated;
  __pyx_vtabptr_14_region_filter_Translated = &__pyx_vtable_14_region_filter_Translated;
  __pyx_vtable_14_region_filter_Translated.__pyx_base = *__pyx_vtabptr_14_region_filter_Transform;
  __pyx_vtable_14_region_filter_Translated.__pyx_base._transform = (int (*)(struct __pyx_obj_14_region_filter_Transform *, double, double, double *, double *))__pyx_f_14_region_filter_10Translated__transform;
  __pyx_type_14_region_filter_Translated.tp_base = __pyx_ptype_14_region_filter_Transform;
  if (PyType_Ready(&__pyx_type_14_region_filter_Translated) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_14_region_filter_Translated.tp_dict, __pyx_vtabptr_14_region_filter_Translated) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Translated", (PyObject *)&__pyx_type_14_region_filter_Translated) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_14_region_filter_Translated = &__pyx_type_14_region_filter_Translated;
  __pyx_vtabptr_14_region_filter_Circle = &__pyx_vtable_14_region_filter_Circle;
  __pyx_vtable_14_region_filter_Circle.__pyx_base = *__pyx_vtabptr_14_region_filter_RegionBase;
  __pyx_vtable_14_region_filter_Circle.__pyx_base._inside = (npy_bool (*)(struct __pyx_obj_14_region_filter_RegionBase *, double, double))__pyx_f_14_region_filter_6Circle__inside;
  __pyx_vtable_14_region_filter_Circle._set_v = (PyObject *(*)(struct __pyx_obj_14_region_filter_Circle *, double, double, double))__pyx_f_14_region_filter_6Circle__set_v;
  __pyx_vtable_14_region_filter_Circle._get_v = (PyObject *(*)(struct __pyx_obj_14_region_filter_Circle *))__pyx_f_14_region_filter_6Circle__get_v;
  __pyx_type_14_region_filter_Circle.tp_base = __pyx_ptype_14_region_filter_RegionBase;
  if (PyType_Ready(&__pyx_type_14_region_filter_Circle) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  {
    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_14_region_filter_Circle, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
      __pyx_wrapperbase_14_region_filter_6Circle___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
      __pyx_wrapperbase_14_region_filter_6Circle___init__.doc = __pyx_doc_14_region_filter_6Circle___init__;
      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_14_region_filter_6Circle___init__;
    }
  }
  if (__Pyx_SetVtable(__pyx_type_14_region_filter_Circle.tp_dict, __pyx_vtabptr_14_region_filter_Circle) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Circle", (PyObject *)&__pyx_type_14_region_filter_Circle) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_14_region_filter_Circle = &__pyx_type_14_region_filter_Circle;
  __pyx_vtabptr_14_region_filter_Ellipse = &__pyx_vtable_14_region_filter_Ellipse;
  __pyx_vtable_14_region_filter_Ellipse.__pyx_base = *__pyx_vtabptr_14_region_filter_RegionBase;
  __pyx_vtable_14_region_filter_Ellipse.__pyx_base._inside = (npy_bool (*)(struct __pyx_obj_14_region_filter_RegionBase *, double, double))__pyx_f_14_region_filter_7Ellipse__inside;
  __pyx_type_14_region_filter_Ellipse.tp_base = __pyx_ptype_14_region_filter_RegionBase;
  if (PyType_Ready(&__pyx_type_14_region_filter_Ellipse) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_14_region_filter_Ellipse.tp_dict, __pyx_vtabptr_14_region_filter_Ellipse) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Ellipse", (PyObject *)&__pyx_type_14_region_filter_Ellipse) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_14_region_filter_Ellipse = &__pyx_type_14_region_filter_Ellipse;
  __pyx_vtabptr_14_region_filter_Box = &__pyx_vtable_14_region_filter_Box;
  __pyx_vtable_14_region_filter_Box.__pyx_base = *__pyx_vtabptr_14_region_filter_RegionBase;
  __pyx_vtable_14_region_filter_Box.__pyx_base._inside = (npy_bool (*)(struct __pyx_obj_14_region_filter_RegionBase *, double, double))__pyx_f_14_region_filter_3Box__inside;
  __pyx_type_14_region_filter_Box.tp_base = __pyx_ptype_14_region_filter_RegionBase;
  if (PyType_Ready(&__pyx_type_14_region_filter_Box) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_14_region_filter_Box.tp_dict, __pyx_vtabptr_14_region_filter_Box) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Box", (PyObject *)&__pyx_type_14_region_filter_Box) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_14_region_filter_Box = &__pyx_type_14_region_filter_Box;
  __pyx_vtabptr_14_region_filter_Polygon = &__pyx_vtable_14_region_filter_Polygon;
  __pyx_vtable_14_region_filter_Polygon.__pyx_base = *__pyx_vtabptr_14_region_filter_RegionBase;
  __pyx_vtable_14_region_filter_Polygon.__pyx_base._inside = (npy_bool (*)(struct __pyx_obj_14_region_filter_RegionBase *, double, double))__pyx_f_14_region_filter_7Polygon__inside;
  __pyx_type_14_region_filter_Polygon.tp_base = __pyx_ptype_14_region_filter_RegionBase;
  if (PyType_Ready(&__pyx_type_14_region_filter_Polygon) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_14_region_filter_Polygon.tp_dict, __pyx_vtabptr_14_region_filter_Polygon) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "Polygon", (PyObject *)&__pyx_type_14_region_filter_Polygon) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_14_region_filter_Polygon = &__pyx_type_14_region_filter_Polygon;
  __pyx_vtabptr_14_region_filter_AngleRange = &__pyx_vtable_14_region_filter_AngleRange;
  __pyx_vtable_14_region_filter_AngleRange.__pyx_base = *__pyx_vtabptr_14_region_filter_RegionBase;
  __pyx_vtable_14_region_filter_AngleRange.__pyx_base._inside = (npy_bool (*)(struct __pyx_obj_14_region_filter_RegionBase *, double, double))__pyx_f_14_region_filter_10AngleRange__inside;
  __pyx_vtable_14_region_filter_AngleRange._fix_angle = (double (*)(struct __pyx_obj_14_region_filter_AngleRange *, double))__pyx_f_14_region_filter_10AngleRange__fix_angle;
  __pyx_type_14_region_filter_AngleRange.tp_base = __pyx_ptype_14_region_filter_RegionBase;
  if (PyType_Ready(&__pyx_type_14_region_filter_AngleRange) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetVtable(__pyx_type_14_region_filter_AngleRange.tp_dict, __pyx_vtabptr_14_region_filter_AngleRange) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (__Pyx_SetAttrString(__pyx_m, "AngleRange", (PyObject *)&__pyx_type_14_region_filter_AngleRange) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_14_region_filter_AngleRange = &__pyx_type_14_region_filter_AngleRange;
  /*--- Type import code ---*/
  __pyx_ptype_7c_numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr), 0); if (unlikely(!__pyx_ptype_7c_numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7c_numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject), 0); if (unlikely(!__pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7c_numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject), 0); if (unlikely(!__pyx_ptype_7c_numpy_flatiter)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __pyx_ptype_7c_numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject), 0); if (unlikely(!__pyx_ptype_7c_numpy_broadcast)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  /*--- Function import code ---*/
  /*--- Execution code ---*/

  /* "_region_filter.pyx":25
 * 
 * 
 * c_numpy.import_array()             # <<<<<<<<<<<<<<
 * #c_numpy.import_ufunc()
 * 
 */
  import_array();

  /* "_region_filter.pyx":31
 * 
 * 
 * class NotYetImplemented(Exception):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_builtin_Exception);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_Exception);
  __Pyx_GIVEREF(__pyx_builtin_Exception);
  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1), __pyx_n_s__NotYetImplemented, __pyx_n_s___region_filter); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__NotYetImplemented, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "_region_filter.pyx":34
 *     pass
 * 
 * class RegionFilterException(Exception):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
  __Pyx_INCREF(__pyx_builtin_Exception);
  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_builtin_Exception);
  __Pyx_GIVEREF(__pyx_builtin_Exception);
  __pyx_t_2 = __Pyx_CreateClass(((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_1), __pyx_n_s_2, __pyx_n_s___region_filter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_2, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "_region_filter.pyx":84
 * 
 * cdef RegionContext metric_wcs
 * metric_wcs = RegionContext()             # <<<<<<<<<<<<<<
 * metric_wcs.set_update_func(_update_metric_wcs)
 * 
 */
  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_14_region_filter_RegionContext)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GOTREF(((PyObject *)__pyx_v_14_region_filter_metric_wcs));
  __Pyx_DECREF(((PyObject *)__pyx_v_14_region_filter_metric_wcs));
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_v_14_region_filter_metric_wcs = ((struct __pyx_obj_14_region_filter_RegionContext *)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "_region_filter.pyx":85
 * cdef RegionContext metric_wcs
 * metric_wcs = RegionContext()
 * metric_wcs.set_update_func(_update_metric_wcs)             # <<<<<<<<<<<<<<
 * 
 * 
 */
  __pyx_t_1 = ((struct __pyx_vtabstruct_14_region_filter_RegionContext *)__pyx_v_14_region_filter_metric_wcs->__pyx_vtab)->set_update_func(__pyx_v_14_region_filter_metric_wcs, __pyx_f_14_region_filter__update_metric_wcs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "_region_filter.pyx":89
 * 
 * 
 * class BaseClassInitException(Exception):             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
  __Pyx_INCREF(__pyx_builtin_Exception);
  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_Exception);
  __Pyx_GIVEREF(__pyx_builtin_Exception);
  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1), __pyx_n_s_1, __pyx_n_s___region_filter); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s_1, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "_region_filter.pyx":409
 * 
 * 
 * def RegionAnd(RegionBase region1, RegionBase region2):             # <<<<<<<<<<<<<<
 *     """
 *     >>> r = RegionAnd(reg1, reg2)
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_14_region_filter_RegionAnd, NULL, __pyx_n_s___region_filter); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__RegionAnd, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "_region_filter.pyx":426
 * 
 * 
 * def RegionOr(RegionBase region1, RegionBase region2):             # <<<<<<<<<<<<<<
 *     """
 *     >>> r = RegionOr(reg1, reg2)
 */
  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_14_region_filter_1RegionOr, NULL, __pyx_n_s___region_filter); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(__pyx_t_1);
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__RegionOr, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "_region_filter.pyx":2
 * 
 * cdef extern from "stdio.h":             # <<<<<<<<<<<<<<
 *     pass
 * 
 */
  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_13), ((PyObject *)__pyx_kp_u_14)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_15), ((PyObject *)__pyx_kp_u_16)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;

  /* "c_python.pxd":1
 * # -*- Mode: Python -*-  Not really, but close enough             # <<<<<<<<<<<<<<
 * 
 * # Expose as much of the Python C API as we need here
 */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  if (__pyx_m) {
    __Pyx_AddTraceback("init _region_filter");
    Py_DECREF(__pyx_m); __pyx_m = 0;
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init _region_filter");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if PY_MAJOR_VERSION < 3
  return;
  #else
  return __pyx_m;
  #endif
}

/* Runtime support code */

static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
    PyObject *result;
    result = PyObject_GetAttr(dict, name);
    if (!result)
        PyErr_SetObject(PyExc_NameError, name);
    return result;
}

static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *number, *more_or_less;

    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    number = (num_expected == 1) ? "" : "s";
    PyErr_Format(PyExc_TypeError,
        #if PY_VERSION_HEX < 0x02050000
            "%s() takes %s %d positional argument%s (%d given)",
        #else
            "%s() takes %s %zd positional argument%s (%zd given)",
        #endif
        func_name, more_or_less, num_expected, number, num_found);
}

static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
    PyObject *kwdict,
    const char* function_name,
    int kw_allowed)
{
    PyObject* key = 0;
    Py_ssize_t pos = 0;
    while (PyDict_Next(kwdict, &pos, &key, 0)) {
        #if PY_MAJOR_VERSION < 3
        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
        #else
        if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key)))
        #endif
            goto invalid_keyword_type;
    }
    if ((!kw_allowed) && unlikely(key))
        goto invalid_keyword;
    return 1;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    return 0;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
    return 0;
}

static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyThreadState *tstate = PyThreadState_GET();

    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
}

static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
    PyThreadState *tstate = PyThreadState_GET();
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;

    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
}


#if PY_MAJOR_VERSION < 3
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    Py_XINCREF(type);
    Py_XINCREF(value);
    Py_XINCREF(tb);
    /* First, check the traceback argument, replacing None with NULL. */
    if (tb == Py_None) {
        Py_DECREF(tb);
        tb = 0;
    }
    else if (tb != NULL && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto raise_error;
    }
    /* Next, replace a missing value with None */
    if (value == NULL) {
        value = Py_None;
        Py_INCREF(value);
    }
    #if PY_VERSION_HEX < 0x02050000
    if (!PyClass_Check(type))
    #else
    if (!PyType_Check(type))
    #endif
    {
        /* Raising an instance.  The value should be a dummy. */
        if (value != Py_None) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto raise_error;
        }
        /* Normalize to raise <class>, <instance> */
        Py_DECREF(value);
        value = type;
        #if PY_VERSION_HEX < 0x02050000
            if (PyInstance_Check(type)) {
                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
                Py_INCREF(type);
            }
            else {
                type = 0;
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception must be an old-style class or instance");
                goto raise_error;
            }
        #else
            type = (PyObject*) Py_TYPE(type);
            Py_INCREF(type);
            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception class must be a subclass of BaseException");
                goto raise_error;
            }
        #endif
    }

    __Pyx_ErrRestore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}

#else /* Python 3+ */

static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;

    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (!PyExceptionClass_Check(type)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }

    PyErr_SetObject(type, value);

    if (tb) {
        PyThreadState *tstate = PyThreadState_GET();
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
    }

bad:
    return;
}
#endif

static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
    const char *name, int exact)
{
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (none_allowed && obj == Py_None) return 1;
    else if (exact) {
        if (Py_TYPE(obj) == type) return 1;
    }
    else {
        if (PyObject_TypeCheck(obj, type)) return 1;
    }
    PyErr_Format(PyExc_TypeError,
        "Argument '%s' has incorrect type (expected %s, got %s)",
        name, type->tp_name, Py_TYPE(obj)->tp_name);
    return 0;
}

static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (unlikely(!type)) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (likely(PyObject_TypeCheck(obj, type)))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
                 Py_TYPE(obj)->tp_name, type->tp_name);
    return 0;
}

static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        #if PY_MAJOR_VERSION >= 3
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
        #else
        "%s() got multiple values for keyword argument '%s'", func_name,
        PyString_AS_STRING(kw_name));
        #endif
}

static int __Pyx_ParseOptionalKeywords(
    PyObject *kwds,
    PyObject **argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject *key = 0, *value = 0;
    Py_ssize_t pos = 0;
    PyObject*** name;
    PyObject*** first_kw_arg = argnames + num_pos_args;

    while (PyDict_Next(kwds, &pos, &key, &value)) {
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            values[name-argnames] = value;
        } else {
            #if PY_MAJOR_VERSION < 3
            if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
            #else
            if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
            #endif
                goto invalid_keyword_type;
            } else {
                for (name = first_kw_arg; *name; name++) {
                    #if PY_MAJOR_VERSION >= 3
                    if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                        PyUnicode_Compare(**name, key) == 0) break;
                    #else
                    if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                        _PyString_Eq(**name, key)) break;
                    #endif
                }
                if (*name) {
                    values[name-argnames] = value;
                } else {
                    /* unexpected keyword found */
                    for (name=argnames; name != first_kw_arg; name++) {
                        if (**name == key) goto arg_passed_twice;
                        #if PY_MAJOR_VERSION >= 3
                        if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
                            PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
                        #else
                        if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
                            _PyString_Eq(**name, key)) goto arg_passed_twice;
                        #endif
                    }
                    if (kwds2) {
                        if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
                    } else {
                        goto invalid_keyword;
                    }
                }
            }
        }
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, **name);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%s() keywords must be strings", function_name);
    goto bad;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
    #if PY_MAJOR_VERSION < 3
        "%s() got an unexpected keyword argument '%s'",
        function_name, PyString_AsString(key));
    #else
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    #endif
bad:
    return -1;
}




static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) {
    PyObject *metaclass;
    /* Default metaclass */
#if PY_MAJOR_VERSION < 3
    if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
        PyObject *base = PyTuple_GET_ITEM(bases, 0);
        metaclass = PyObject_GetAttrString(base, "__class__");
        if (!metaclass) {
            PyErr_Clear();
            metaclass = (PyObject*) Py_TYPE(base);
        }
    } else {
        metaclass = (PyObject *) &PyClass_Type;
    }
#else
    if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
        PyObject *base = PyTuple_GET_ITEM(bases, 0);
        metaclass = (PyObject*) Py_TYPE(base);
    } else {
        metaclass = (PyObject *) &PyType_Type;
    }
#endif
    Py_INCREF(metaclass);
    return metaclass;
}

static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
                                   PyObject *modname) {
    PyObject *result;
    PyObject *metaclass;

    if (PyDict_SetItemString(dict, "__module__", modname) < 0)
        return NULL;

    /* Python2 __metaclass__ */
    metaclass = PyDict_GetItemString(dict, "__metaclass__");
    if (metaclass) {
        Py_INCREF(metaclass);
    } else {
        metaclass = __Pyx_FindPy2Metaclass(bases);
    }
    result = PyObject_CallFunctionObjArgs(metaclass, name, bases, dict, NULL);
    Py_DECREF(metaclass);
    return result;
}

static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_npy_bool(npy_bool val) {
    const npy_bool neg_one = (npy_bool)-1, const_zero = (npy_bool)0;
    const int is_unsigned = const_zero < neg_one;
    if ((sizeof(npy_bool) == sizeof(char))  ||
        (sizeof(npy_bool) == sizeof(short))) {
        return PyInt_FromLong((long)val);
    } else if ((sizeof(npy_bool) == sizeof(int)) ||
               (sizeof(npy_bool) == sizeof(long))) {
        if (is_unsigned)
            return PyLong_FromUnsignedLong((unsigned long)val);
        else
            return PyInt_FromLong((long)val);
    } else if (sizeof(npy_bool) == sizeof(PY_LONG_LONG)) {
        if (is_unsigned)
            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
        else
            return PyLong_FromLongLong((PY_LONG_LONG)val);
    } else {
        int one = 1; int little = (int)*(unsigned char *)&one;
        unsigned char *bytes = (unsigned char *)&val;
        return _PyLong_FromByteArray(bytes, sizeof(npy_bool), 
                                     little, !is_unsigned);
    }
}

static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
    const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned char" :
                    "value too large to convert to unsigned char");
            }
            return (unsigned char)-1;
        }
        return (unsigned char)val;
    }
    return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
    const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned short" :
                    "value too large to convert to unsigned short");
            }
            return (unsigned short)-1;
        }
        return (unsigned short)val;
    }
    return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
    const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(unsigned int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(unsigned int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to unsigned int" :
                    "value too large to convert to unsigned int");
            }
            return (unsigned int)-1;
        }
        return (unsigned int)val;
    }
    return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
}

static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
    const char neg_one = (char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to char" :
                    "value too large to convert to char");
            }
            return (char)-1;
        }
        return (char)val;
    }
    return (char)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
    const short neg_one = (short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to short" :
                    "value too large to convert to short");
            }
            return (short)-1;
        }
        return (short)val;
    }
    return (short)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
    const signed char neg_one = (signed char)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed char) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed char)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed char" :
                    "value too large to convert to signed char");
            }
            return (signed char)-1;
        }
        return (signed char)val;
    }
    return (signed char)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
    const signed short neg_one = (signed short)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed short) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed short)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed short" :
                    "value too large to convert to signed short");
            }
            return (signed short)-1;
        }
        return (signed short)val;
    }
    return (signed short)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
    const signed int neg_one = (signed int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(signed int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(signed int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to signed int" :
                    "value too large to convert to signed int");
            }
            return (signed int)-1;
        }
        return (signed int)val;
    }
    return (signed int)__Pyx_PyInt_AsSignedLong(x);
}

static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
    const int neg_one = (int)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
    if (sizeof(int) < sizeof(long)) {
        long val = __Pyx_PyInt_AsLong(x);
        if (unlikely(val != (long)(int)val)) {
            if (!unlikely(val == -1 && PyErr_Occurred())) {
                PyErr_SetString(PyExc_OverflowError,
                    (is_unsigned && unlikely(val < 0)) ?
                    "can't convert negative value to int" :
                    "value too large to convert to int");
            }
            return (int)-1;
        }
        return (int)val;
    }
    return (int)__Pyx_PyInt_AsLong(x);
}

static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
    const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned long");
            return (unsigned long)-1;
        }
        return (unsigned long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned long");
                return (unsigned long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        unsigned long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned long)-1;
        val = __Pyx_PyInt_AsUnsignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
    const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to unsigned PY_LONG_LONG");
            return (unsigned PY_LONG_LONG)-1;
        }
        return (unsigned PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to unsigned PY_LONG_LONG");
                return (unsigned PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        unsigned PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (unsigned PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
    const long neg_one = (long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to long");
            return (long)-1;
        }
        return (long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to long");
                return (long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (long)-1;
        val = __Pyx_PyInt_AsLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
    const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to PY_LONG_LONG");
            return (PY_LONG_LONG)-1;
        }
        return (PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to PY_LONG_LONG");
                return (PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
    const signed long neg_one = (signed long)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed long");
            return (signed long)-1;
        }
        return (signed long)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed long");
                return (signed long)-1;
            }
            return PyLong_AsUnsignedLong(x);
        } else {
            return PyLong_AsLong(x);
        }
    } else {
        signed long val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed long)-1;
        val = __Pyx_PyInt_AsSignedLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
    const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
    const int is_unsigned = neg_one > const_zero;
#if PY_VERSION_HEX < 0x03000000
    if (likely(PyInt_Check(x))) {
        long val = PyInt_AS_LONG(x);
        if (is_unsigned && unlikely(val < 0)) {
            PyErr_SetString(PyExc_OverflowError,
                            "can't convert negative value to signed PY_LONG_LONG");
            return (signed PY_LONG_LONG)-1;
        }
        return (signed PY_LONG_LONG)val;
    } else
#endif
    if (likely(PyLong_Check(x))) {
        if (is_unsigned) {
            if (unlikely(Py_SIZE(x) < 0)) {
                PyErr_SetString(PyExc_OverflowError,
                                "can't convert negative value to signed PY_LONG_LONG");
                return (signed PY_LONG_LONG)-1;
            }
            return PyLong_AsUnsignedLongLong(x);
        } else {
            return PyLong_AsLongLong(x);
        }
    } else {
        signed PY_LONG_LONG val;
        PyObject *tmp = __Pyx_PyNumber_Int(x);
        if (!tmp) return (signed PY_LONG_LONG)-1;
        val = __Pyx_PyInt_AsSignedLongLong(tmp);
        Py_DECREF(tmp);
        return val;
    }
}

static void __Pyx_WriteUnraisable(const char *name) {
    PyObject *old_exc, *old_val, *old_tb;
    PyObject *ctx;
    __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
    #if PY_MAJOR_VERSION < 3
    ctx = PyString_FromString(name);
    #else
    ctx = PyUnicode_FromString(name);
    #endif
    __Pyx_ErrRestore(old_exc, old_val, old_tb);
    if (!ctx) {
        PyErr_WriteUnraisable(Py_None);
    } else {
        PyErr_WriteUnraisable(ctx);
        Py_DECREF(ctx);
    }
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
    PyObject *ob = PyCapsule_New(vtable, 0, 0);
#else
    PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
#endif
    if (!ob)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
        goto bad;
    Py_DECREF(ob);
    return 0;
bad:
    Py_XDECREF(ob);
    return -1;
}

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
    long size, int strict)
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    PyObject *py_name = 0;
    char warning[200];

    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(class_name);
    #else
    py_name = PyUnicode_FromString(class_name);
    #endif
    if (!py_name)
        goto bad;
    result = PyObject_GetAttr(py_module, py_name);
    Py_DECREF(py_name);
    py_name = 0;
    Py_DECREF(py_module);
    py_module = 0;
    if (!result)
        goto bad;
    if (!PyType_Check(result)) {
        PyErr_Format(PyExc_TypeError,
            "%s.%s is not a type object",
            module_name, class_name);
        goto bad;
    }
    if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
        PyOS_snprintf(warning, sizeof(warning),
            "%s.%s size changed, may indicate binary incompatibility",
            module_name, class_name);
        #if PY_VERSION_HEX < 0x02050000
        PyErr_Warn(NULL, warning);
        #else
        PyErr_WarnEx(NULL, warning, 0);
        #endif
    }
    else if (((PyTypeObject *)result)->tp_basicsize != size) {
        PyErr_Format(PyExc_ValueError,
            "%s.%s has the wrong size, try recompiling",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(py_module);
    Py_XDECREF(result);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(const char *name) {
    PyObject *py_name = 0;
    PyObject *py_module = 0;

    #if PY_MAJOR_VERSION < 3
    py_name = PyString_FromString(name);
    #else
    py_name = PyUnicode_FromString(name);
    #endif
    if (!py_name)
        goto bad;
    py_module = PyImport_Import(py_name);
    Py_DECREF(py_name);
    return py_module;
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

#include "compile.h"
#include "frameobject.h"
#include "traceback.h"

static void __Pyx_AddTraceback(const char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;

    #if PY_MAJOR_VERSION < 3
    py_srcfile = PyString_FromString(__pyx_filename);
    #else
    py_srcfile = PyUnicode_FromString(__pyx_filename);
    #endif
    if (!py_srcfile) goto bad;
    if (__pyx_clineno) {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #else
        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
        #endif
    }
    else {
        #if PY_MAJOR_VERSION < 3
        py_funcname = PyString_FromString(funcname);
        #else
        py_funcname = PyUnicode_FromString(funcname);
        #endif
    }
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        #if PY_MAJOR_VERSION >= 3
        0,            /*int kwonlyargcount,*/
        #endif
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        __pyx_empty_bytes, /*PyObject *code,*/
        __pyx_empty_tuple,  /*PyObject *consts,*/
        __pyx_empty_tuple,  /*PyObject *names,*/
        __pyx_empty_tuple,  /*PyObject *varnames,*/
        __pyx_empty_tuple,  /*PyObject *freevars,*/
        __pyx_empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        #if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 11
        __pyx_empty_bytes,  /*PyObject *lnotab*/
        __pyx_empty_bytes,  /* PyObject *exceptiontable */
        __pyx_empty_bytes
        #else
        __pyx_empty_bytes  /*PyObject *lnotab*/
        #endif
    );
    #if !(PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 11)
    if (!py_code) goto bad;
    py_frame = PyFrame_New(
        PyThreadState_GET(), /*PyThreadState *tstate,*/
        py_code,             /*PyCodeObject *code,*/
        py_globals,          /*PyObject *globals,*/
        0                    /*PyObject *locals*/
    );
    if (!py_frame) goto bad;
    py_frame->f_lineno = __pyx_lineno;
    PyTraceBack_Here(py_frame);
    #endif
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        #if PY_MAJOR_VERSION < 3
        if (t->is_unicode) {
            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
        } else if (t->intern) {
            *t->p = PyString_InternFromString(t->s);
        } else {
            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        }
        #else  /* Python 3+ has unicode identifiers */
        if (t->is_unicode | t->is_str) {
            if (t->intern) {
                *t->p = PyUnicode_InternFromString(t->s);
            } else if (t->encoding) {
                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
            } else {
                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
            }
        } else {
            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
        }
        #endif
        if (!*t->p)
            return -1;
        ++t;
    }
    return 0;
}

/* Type Conversion Functions */

static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}

static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
  PyNumberMethods *m;
  const char *name = NULL;
  PyObject *res = NULL;
#if PY_VERSION_HEX < 0x03000000
  if (PyInt_Check(x) || PyLong_Check(x))
#else
  if (PyLong_Check(x))
#endif
    return Py_INCREF(x), x;
  m = Py_TYPE(x)->tp_as_number;
#if PY_VERSION_HEX < 0x03000000
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Int(x);
  }
  else if (m && m->nb_long) {
    name = "long";
    res = PyNumber_Long(x);
  }
#else
  if (m && m->nb_int) {
    name = "int";
    res = PyNumber_Long(x);
  }
#endif
  if (res) {
#if PY_VERSION_HEX < 0x03000000
    if (!PyInt_Check(res) && !PyLong_Check(res)) {
#else
    if (!PyLong_Check(res)) {
#endif
      PyErr_Format(PyExc_TypeError,
                   "__%s__ returned non-%s (type %.200s)",
                   name, name, Py_TYPE(res)->tp_name);
      Py_DECREF(res);
      return NULL;
    }
  }
  else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_TypeError,
                    "an integer is required");
  }
  return res;
}

static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject* x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyInt_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}

static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
#if PY_VERSION_HEX < 0x02050000
   if (ival <= LONG_MAX)
       return PyInt_FromLong((long)ival);
   else {
       unsigned char *bytes = (unsigned char *) &ival;
       int one = 1; int little = (int)*(unsigned char*)&one;
       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
   }
#else
   return PyInt_FromSize_t(ival);
#endif
}

static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
   unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
   if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
       return (size_t)-1;
   } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
       PyErr_SetString(PyExc_OverflowError,
                       "value too large to convert to size_t");
       return (size_t)-1;
   }
   return (size_t)val;
}


#endif /* Py_PYTHON_H */
