/* Generated by Pyrex 0.9.8.5 on Tue Aug 18 01:03:19 2009 */

#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "structmember.h"
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#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 PyInt_FromSsize_t(z) PyInt_FromLong(z)
  #define PyInt_AsSsize_t(o)	PyInt_AsLong(o)
#endif
#if !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
#endif
#ifdef __cplusplus
#define __PYX_EXTERN_C extern "C"
#else
#define __PYX_EXTERN_C extern
#endif
#include <math.h>
#include "stdio.h"
#include "stdlib.h"
#include "math.h"
#include "numpy/arrayobject.h"


typedef struct {PyObject **p; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/

static PyObject *__pyx_m;
static PyObject *__pyx_b;
static int __pyx_lineno;
static char *__pyx_filename;
static char **__pyx_f;

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

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

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

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

static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[],     Py_ssize_t nargs, PyObject **args2, PyObject **kwds2, char rqd_kwds[]); /*proto*/

static PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i); /*proto*/

static int __Pyx_SetItemInt(PyObject *o, Py_ssize_t i, PyObject *v); /*proto*/

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/

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

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

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

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

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

/* 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;

/* Declarations from c_python */


/* Declarations from _region_filter */


/* Declarations from implementation of _region_filter */

typedef int __pyx_t_14_region_filter_Py_ssize_t;

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

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

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;
};

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;
};

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;
};

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

struct __pyx_obj_14_region_filter_RegionOrList {
  struct __pyx_obj_14_region_filter_RegionList __pyx_base;
};

struct __pyx_obj_14_region_filter_RegionAndList {
  struct __pyx_obj_14_region_filter_RegionList __pyx_base;
};

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;
};

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;
};

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

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

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;
};

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

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;
};

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;
};


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;


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;


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;


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;


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;


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;


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;


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;


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;


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;


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;


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;


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;


struct __pyx_vtabstruct_14_region_filter_AngleRange {
  struct __pyx_vtabstruct_14_region_filter_RegionBase __pyx_base;
};
static struct __pyx_vtabstruct_14_region_filter_AngleRange *__pyx_vtabptr_14_region_filter_AngleRange;

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;
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*/

static char __pyx_k1[] = "BaseClassInitException";
static char __pyx_k2[] = "set_context";
static char __pyx_k3[] = "RegionAnd";
static char __pyx_k4[] = "RegionOr";
static char __pyx_k5[] = "shape";
static char __pyx_k6[] = "shape of the inut image must be 2d";
static char __pyx_k7[] = "All elements should be subclass of RegionBase type: %s";
static char __pyx_k8[] = "_check_type_of_list";
static char __pyx_k9[] = "__class__";
static char __pyx_k10[] = "y";
static char __pyx_k11[] = "Or";
static char __pyx_k12[] = "And";
static char __pyx_k13[] = "asList";
static char __pyx_k14[] = "__init__";
static char __pyx_k15[] = "Circle(%f, %f, %f)";
static char __pyx_k16[] = "Ellipse(%f, %f, %f, %f)";
static char __pyx_k17[] = "AngleRange(%f, %f, %f, %f)";
static char __pyx_k18[] = "NotYetImplemented";

static PyObject *__pyx_n_And;
static PyObject *__pyx_n_BaseClassInitException;
static PyObject *__pyx_n_NotYetImplemented;
static PyObject *__pyx_n_Or;
static PyObject *__pyx_n_RegionAnd;
static PyObject *__pyx_n_RegionOr;
static PyObject *__pyx_n___class__;
static PyObject *__pyx_n___init__;
static PyObject *__pyx_n__check_type_of_list;
static PyObject *__pyx_n_asList;
static PyObject *__pyx_n_set_context;
static PyObject *__pyx_n_shape;
static PyObject *__pyx_n_y;

static PyObject *__pyx_k6p;
static PyObject *__pyx_k7p;
static PyObject *__pyx_k15p;
static PyObject *__pyx_k16p;
static PyObject *__pyx_k17p;

static __Pyx_StringTabEntry __pyx_string_tab[] = {
  {&__pyx_n_And, 1, __pyx_k12, sizeof(__pyx_k12)},
  {&__pyx_n_BaseClassInitException, 1, __pyx_k1, sizeof(__pyx_k1)},
  {&__pyx_n_NotYetImplemented, 1, __pyx_k18, sizeof(__pyx_k18)},
  {&__pyx_n_Or, 1, __pyx_k11, sizeof(__pyx_k11)},
  {&__pyx_n_RegionAnd, 1, __pyx_k3, sizeof(__pyx_k3)},
  {&__pyx_n_RegionOr, 1, __pyx_k4, sizeof(__pyx_k4)},
  {&__pyx_n___class__, 1, __pyx_k9, sizeof(__pyx_k9)},
  {&__pyx_n___init__, 1, __pyx_k14, sizeof(__pyx_k14)},
  {&__pyx_n__check_type_of_list, 1, __pyx_k8, sizeof(__pyx_k8)},
  {&__pyx_n_asList, 1, __pyx_k13, sizeof(__pyx_k13)},
  {&__pyx_n_set_context, 1, __pyx_k2, sizeof(__pyx_k2)},
  {&__pyx_n_shape, 1, __pyx_k5, sizeof(__pyx_k5)},
  {&__pyx_n_y, 1, __pyx_k10, sizeof(__pyx_k10)},
  {&__pyx_k6p, 0, __pyx_k6, sizeof(__pyx_k6)},
  {&__pyx_k7p, 0, __pyx_k7, sizeof(__pyx_k7)},
  {&__pyx_k15p, 0, __pyx_k15, sizeof(__pyx_k15)},
  {&__pyx_k16p, 0, __pyx_k16, sizeof(__pyx_k16)},
  {&__pyx_k17p, 0, __pyx_k17, sizeof(__pyx_k17)},
  {0, 0, 0, 0}
};

static struct __pyx_obj_14_region_filter_RegionContext *__pyx_d1;
static struct __pyx_obj_14_region_filter_RegionContext *__pyx_d2;
static struct __pyx_obj_14_region_filter_RegionContext *__pyx_d3;
static struct __pyx_obj_14_region_filter_RegionContext *__pyx_d4;
static struct __pyx_obj_14_region_filter_RegionContext *__pyx_d5;


/* Implementation of _region_filter */

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;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":44 */
  __pyx_v_m->x0 = __pyx_v_x0;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":45 */
  __pyx_v_m->y0 = __pyx_v_y0;

  __pyx_r = 0;
  return __pyx_r;
}

static int __pyx_f_14_region_filter_13RegionContext___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_14_region_filter_13RegionContext___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return -1;
  Py_INCREF(__pyx_v_self);

  __pyx_r = 0;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

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;
  Py_INCREF(__pyx_v_self);
  __pyx_v_self->c.update_metric = __pyx_v_update_metric;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

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

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":65 */
  __pyx_v_m->g_x = 1.;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":66 */
  __pyx_v_m->g_y = 1.;

  __pyx_r = 0;
  return __pyx_r;
}

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;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":71 */
  __pyx_v_theta = ((__pyx_v_m->y0 / 180.) * 3.1415926);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":73 */
  __pyx_v_m->g_x = cos(__pyx_v_theta);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":74 */
  __pyx_v_m->g_y = 1.;

  __pyx_r = 0;
  return __pyx_r;
}

static int __pyx_f_14_region_filter_10RegionBase___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_14_region_filter_10RegionBase___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return -1;
  Py_INCREF(__pyx_v_self);
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_BaseClassInitException); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; goto __pyx_L1;}
  __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __Pyx_Raise(__pyx_2, 0, 0);
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_region_filter.RegionBase.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_10RegionBase_update_metric(struct __pyx_obj_14_region_filter_RegionBase *__pyx_v_self) {
  PyObject *__pyx_r;
  int __pyx_1;
  Py_INCREF(__pyx_v_self);
  __pyx_1 = PyObject_IsTrue(((PyObject *)__pyx_v_self->c)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; goto __pyx_L1;}
  if (__pyx_1) {
    __pyx_v_self->c->c.update_metric((&__pyx_v_self->m));
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_f_14_region_filter__update_metric_default((&__pyx_v_self->m));
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_region_filter.RegionBase.update_metric");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_10RegionBase_set_context(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_14_region_filter_10RegionBase_set_context(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  struct __pyx_obj_14_region_filter_RegionContext *__pyx_v_cnt = 0;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"cnt",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_cnt)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_cnt);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cnt), __pyx_ptype_14_region_filter_RegionContext, 1, "cnt")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; goto __pyx_L1;}

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":114 */
  Py_INCREF(((PyObject *)__pyx_v_cnt));
  Py_DECREF(((PyObject *)((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self)->c));
  ((struct __pyx_obj_14_region_filter_RegionBase *)__pyx_v_self)->c = __pyx_v_cnt;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":115 */
  __pyx_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 (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_region_filter.RegionBase.set_context");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_cnt);
  return __pyx_r;
}

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;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_cnt);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":121 */
  __pyx_f_14_region_filter_MetricSetOrigin((&__pyx_v_self->m),__pyx_v_xc,__pyx_v_yc);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":122 */
  __pyx_1 = PyObject_IsTrue(((PyObject *)__pyx_v_cnt)); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; goto __pyx_L1;}
  if (__pyx_1) {
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_set_context); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; goto __pyx_L1;}
    __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; goto __pyx_L1;}
    Py_INCREF(((PyObject *)__pyx_v_cnt));
    PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_cnt));
    __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_4); __pyx_4 = 0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = ((struct __pyx_vtabstruct_14_region_filter_RegionBase *)__pyx_v_self->__pyx_vtab)->update_metric(__pyx_v_self); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
  }
  __pyx_L2:;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_region_filter.RegionBase.metric_set_origin");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_cnt);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_10RegionBase___invert__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_14_region_filter_10RegionBase___invert__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF(__pyx_v_self);
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self);
  __pyx_2 = PyObject_CallObject(((PyObject *)__pyx_ptype_14_region_filter_RegionNot), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_region_filter.RegionBase.__invert__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_10RegionBase___and__(PyObject *__pyx_v_self, PyObject *__pyx_v_o); /*proto*/
static PyObject *__pyx_f_14_region_filter_10RegionBase___and__(PyObject *__pyx_v_self, PyObject *__pyx_v_o) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_o);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_o), __pyx_ptype_14_region_filter_RegionBase, 1, "o")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; goto __pyx_L1;}
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_RegionAnd); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_o);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_o);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_region_filter.RegionBase.__and__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_o);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_10RegionBase___or__(PyObject *__pyx_v_self, PyObject *__pyx_v_o); /*proto*/
static PyObject *__pyx_f_14_region_filter_10RegionBase___or__(PyObject *__pyx_v_self, PyObject *__pyx_v_o) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_o);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_o), __pyx_ptype_14_region_filter_RegionBase, 1, "o")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; goto __pyx_L1;}
  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_RegionOr); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; goto __pyx_L1;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF(__pyx_v_o);
  PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_o);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_r = __pyx_3;
  __pyx_3 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_region_filter.RegionBase.__or__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_o);
  return __pyx_r;
}

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;
  Py_INCREF(__pyx_v_self);
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_10RegionBase_mask(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_14_region_filter_10RegionBase_mask[] = "\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_f_14_region_filter_10RegionBase_mask(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_img = 0;
  int __pyx_v_nx;
  int __pyx_v_ny;
  PyObject *__pyx_v_shape;
  PyObject *__pyx_r;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  static char *__pyx_argnames[] = {"img",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_img)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_img);
  __pyx_v_shape = Py_None; Py_INCREF(Py_None);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":151 */
  __pyx_1 = PyObject_HasAttr(__pyx_v_img,__pyx_n_shape); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; goto __pyx_L1;}
  if (__pyx_1) {
    __pyx_2 = PyObject_GetAttr(__pyx_v_img, __pyx_n_shape); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; goto __pyx_L1;}
    Py_DECREF(__pyx_v_shape);
    __pyx_v_shape = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L2;
  }
  __pyx_1 = PyObject_IsInstance(__pyx_v_img,((PyObject *)(&PyTuple_Type))); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; goto __pyx_L1;}
  if (__pyx_1) {
    Py_INCREF(__pyx_v_img);
    Py_DECREF(__pyx_v_shape);
    __pyx_v_shape = __pyx_v_img;
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":156 */
  __pyx_1 = (PySequence_Length(__pyx_v_shape) != 2);
  if (__pyx_1) {
    __Pyx_Raise(__pyx_k6p, 0, 0);
    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; goto __pyx_L1;}
    goto __pyx_L3;
  }
  __pyx_L3:;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":159 */
  __pyx_2 = PySequence_GetItem(__pyx_v_shape,0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}
  __pyx_1 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_v_ny = __pyx_1;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":160 */
  __pyx_2 = PySequence_GetItem(__pyx_v_shape,1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L1;}
  __pyx_1 = PyInt_AsLong(__pyx_2); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_v_nx = __pyx_1;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":162 */
  __pyx_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 (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; goto __pyx_L1;}
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_region_filter.RegionBase.mask");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_shape);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_img);
  return __pyx_r;
}

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;
  PyObject *__pyx_1 = 0;
  Py_INCREF(__pyx_v_self);
  __pyx_v_ra = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":171 */
  (__pyx_v_ny_nx[0]) = __pyx_v_ny;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":172 */
  (__pyx_v_ny_nx[1]) = __pyx_v_nx;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":174 */
  __pyx_1 = PyArray_EMPTY(2,__pyx_v_ny_nx,NPY_BOOL,0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_ra));
  __pyx_v_ra = ((PyArrayObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":177 */
  __pyx_v_rd = ((npy_bool *)PyArray_DATA(__pyx_v_ra));

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":179 */
  for (__pyx_v_iy = 0; __pyx_v_iy < __pyx_v_ny; ++__pyx_v_iy) {
    for (__pyx_v_ix = 0; __pyx_v_ix < __pyx_v_nx; ++__pyx_v_ix) {

      /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":184 */
      (__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);

      /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":185 */
      __pyx_v_rd = (__pyx_v_rd + 1);
    }
  }

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":187 */
  Py_INCREF(((PyObject *)__pyx_v_ra));
  __pyx_r = __pyx_v_ra;
  goto __pyx_L0;

  __pyx_r = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_region_filter.RegionBase._mask");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_ra);
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_10RegionBase_inside1(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_14_region_filter_10RegionBase_inside1[] = "\n        inside1(x, y) : returns True if the point (x,y) is inside the filter.\n        ";
static PyObject *__pyx_f_14_region_filter_10RegionBase_inside1(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  double __pyx_v_x;
  double __pyx_v_y;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"x","y",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "dd", __pyx_argnames, &__pyx_v_x, &__pyx_v_y)) return 0;
  Py_INCREF(__pyx_v_self);
  __pyx_1 = PyInt_FromLong(((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 (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_region_filter.RegionBase.inside1");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_10RegionBase_inside(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_14_region_filter_10RegionBase_inside[] = "\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_f_14_region_filter_10RegionBase_inside(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;
  PyObject *__pyx_1 = 0;
  static char *__pyx_argnames[] = {"x","y",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_x, &__pyx_v_y)) return 0;
  Py_INCREF(__pyx_v_self);
  Py_INCREF(__pyx_v_x);
  Py_INCREF(__pyx_v_y);
  __pyx_v_xa = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  __pyx_v_ya = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  __pyx_v_ra = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":213 */
  __pyx_1 = PyArray_ContiguousFromAny(__pyx_v_x,NPY_DOUBLE,1,0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_xa));
  __pyx_v_xa = ((PyArrayObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":214 */
  __pyx_1 = PyArray_ContiguousFromAny(__pyx_v_y,NPY_DOUBLE,1,0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 214; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_ya));
  __pyx_v_ya = ((PyArrayObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":216 */
  __pyx_1 = PyArray_EMPTY(__pyx_v_xa->nd,__pyx_v_xa->dimensions,NPY_BOOL,0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_ra));
  __pyx_v_ra = ((PyArrayObject *)__pyx_1);
  __pyx_1 = 0;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":219 */
  __pyx_v_xd = ((double *)PyArray_DATA(__pyx_v_xa));

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":220 */
  __pyx_v_yd = ((double *)PyArray_DATA(__pyx_v_ya));

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":221 */
  __pyx_v_rd = ((npy_bool *)PyArray_DATA(__pyx_v_ra));

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":223 */
  __pyx_v_n = PyArray_SIZE(__pyx_v_xa);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":225 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_n; ++__pyx_v_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]));
  }

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":231 */
  Py_INCREF(((PyObject *)__pyx_v_ra));
  __pyx_r = ((PyObject *)__pyx_v_ra);
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_region_filter.RegionBase.inside");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_xa);
  Py_DECREF(__pyx_v_ya);
  Py_DECREF(__pyx_v_ra);
  Py_DECREF(__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  Py_DECREF(__pyx_v_y);
  return __pyx_r;
}

static int __pyx_f_14_region_filter_9RegionNot___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_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 char *__pyx_argnames[] = {"child_region",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_child_region)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_child_region);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_child_region), __pyx_ptype_14_region_filter_RegionBase, 1, "child_region")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; goto __pyx_L1;}
  Py_INCREF(((PyObject *)__pyx_v_child_region));
  Py_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:;
  __Pyx_AddTraceback("_region_filter.RegionNot.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_child_region);
  return __pyx_r;
}

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;
  Py_INCREF((PyObject *)__pyx_v_self);
  __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:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_10RegionList__check_type_of_list(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_14_region_filter_10RegionList__check_type_of_list(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_kl = 0;
  PyObject *__pyx_v_k;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  int __pyx_3;
  int __pyx_4;
  PyObject *__pyx_5 = 0;
  static char *__pyx_argnames[] = {"kl",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_kl)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_kl);
  __pyx_v_k = Py_None; Py_INCREF(Py_None);
  __pyx_1 = PyObject_GetIter(__pyx_v_kl); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;}
  for (;;) {
    __pyx_2 = PyIter_Next(__pyx_1);
    if (!__pyx_2) {
      if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; goto __pyx_L1;}
      break;
    }
    Py_DECREF(__pyx_v_k);
    __pyx_v_k = __pyx_2;
    __pyx_2 = 0;
    __pyx_3 = PyObject_IsInstance(__pyx_v_k,((PyObject *)__pyx_ptype_14_region_filter_RegionBase)); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; goto __pyx_L1;}
    __pyx_4 = (!__pyx_3);
    if (__pyx_4) {
      __pyx_2 = PyNumber_Remainder(__pyx_k7p, __pyx_v_k); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}
      __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}
      PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2);
      __pyx_2 = 0;
      __pyx_2 = PyObject_CallObject(PyExc_TypeError, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}
      Py_DECREF(__pyx_5); __pyx_5 = 0;
      __Pyx_Raise(__pyx_2, 0, 0);
      Py_DECREF(__pyx_2); __pyx_2 = 0;
      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; goto __pyx_L1;}
      goto __pyx_L4;
    }
    __pyx_L4:;
  }
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_region_filter.RegionList._check_type_of_list");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_k);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_kl);
  return __pyx_r;
}

static int __pyx_f_14_region_filter_10RegionList___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_14_region_filter_10RegionList___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_v_kl = 0;
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {0};
  if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_kl, 0, 0) < 0) return -1;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) {
    Py_XDECREF(__pyx_args);
    Py_XDECREF(__pyx_kwds);
    Py_XDECREF(__pyx_v_kl);
    return -1;
  }
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":292 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n__check_type_of_list); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;}
  Py_INCREF(__pyx_v_kl);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_kl);
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":293 */
  __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;}
  Py_INCREF(__pyx_v_kl);
  PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_kl);
  __pyx_2 = PyObject_CallObject(((PyObject *)(&PyList_Type)), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_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_2;
  __pyx_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_region_filter.RegionList.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_XDECREF(__pyx_v_kl);
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_XDECREF(__pyx_args);
  Py_XDECREF(__pyx_kwds);
  return __pyx_r;
}

static Py_ssize_t __pyx_f_14_region_filter_10RegionList___len__(PyObject *__pyx_v_self); /*proto*/
static Py_ssize_t __pyx_f_14_region_filter_10RegionList___len__(PyObject *__pyx_v_self) {
  Py_ssize_t __pyx_r;
  Py_ssize_t __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_1 = PyObject_Length(((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_region_filter.RegionList.__len__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_10RegionList___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static PyObject *__pyx_f_14_region_filter_10RegionList___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  Py_ssize_t __pyx_v_x;
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsSsize_t(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; goto __pyx_L1;}
  __pyx_1 = __Pyx_GetItemInt(((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions, __pyx_v_x); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_region_filter.RegionList.__getitem__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_14_region_filter_10RegionList___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x, PyObject *__pyx_v_y); /*proto*/
static int __pyx_f_14_region_filter_10RegionList___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x, PyObject *__pyx_v_y) {
  Py_ssize_t __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_y);
  __pyx_v_x = PyInt_AsSsize_t(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_14_region_filter_RegionBase, 1, "y")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; goto __pyx_L1;}
  if (__Pyx_SetItemInt(((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions, __pyx_v_x, __pyx_v_y) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_region_filter.RegionList.__setitem__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_y);
  return __pyx_r;
}

static int __pyx_f_14_region_filter_10RegionList___delitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x); /*proto*/
static int __pyx_f_14_region_filter_10RegionList___delitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_x) {
  Py_ssize_t __pyx_v_x;
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_v_x = PyInt_AsSsize_t(__pyx_arg_x); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; goto __pyx_L1;}
  if (PySequence_DelItem(((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions, __pyx_v_x) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_region_filter.RegionList.__delitem__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_10RegionList___getslice__(PyObject *__pyx_v_self, Py_ssize_t __pyx_v_i, Py_ssize_t __pyx_v_j); /*proto*/
static PyObject *__pyx_f_14_region_filter_10RegionList___getslice__(PyObject *__pyx_v_self, Py_ssize_t __pyx_v_i, Py_ssize_t __pyx_v_j) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n___class__); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; goto __pyx_L1;}
  __pyx_2 = PySequence_GetSlice(((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions, __pyx_v_i, __pyx_v_j); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; goto __pyx_L1;}
  __pyx_3 = PySequence_Tuple(__pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_region_filter.RegionList.__getslice__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_14_region_filter_10RegionList___setslice__(PyObject *__pyx_v_self, Py_ssize_t __pyx_v_i, Py_ssize_t __pyx_v_j, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_14_region_filter_10RegionList___setslice__(PyObject *__pyx_v_self, Py_ssize_t __pyx_v_i, Py_ssize_t __pyx_v_j, PyObject *__pyx_v_x) {
  int __pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":311 */
  __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n__check_type_of_list); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; goto __pyx_L1;}
  __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_y); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; goto __pyx_L1;}
  __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2);
  __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":312 */
  if (PySequence_SetSlice(((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions, __pyx_v_i, __pyx_v_j, __pyx_v_x) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_region_filter.RegionList.__setslice__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static int __pyx_f_14_region_filter_10RegionList___delslice__(PyObject *__pyx_v_self, Py_ssize_t __pyx_v_i, Py_ssize_t __pyx_v_j); /*proto*/
static int __pyx_f_14_region_filter_10RegionList___delslice__(PyObject *__pyx_v_self, Py_ssize_t __pyx_v_i, Py_ssize_t __pyx_v_j) {
  int __pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  if (PySequence_DelSlice(((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions, __pyx_v_i, __pyx_v_j) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; goto __pyx_L1;}

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_region_filter.RegionList.__delslice__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_14_region_filter_10RegionList___contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
static int __pyx_f_14_region_filter_10RegionList___contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
  int __pyx_r;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_14_region_filter_RegionBase, 1, "x")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; goto __pyx_L1;}
  __pyx_1 = PySequence_Contains(((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions, __pyx_v_x); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  goto __pyx_L0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  __Pyx_AddTraceback("_region_filter.RegionList.__contains__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_10RegionList___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_14_region_filter_10RegionList___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_1 = PyObject_Repr(((struct __pyx_obj_14_region_filter_RegionList *)__pyx_v_self)->child_regions); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; goto __pyx_L1;}
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_region_filter.RegionList.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_10RegionList_asList(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static PyObject *__pyx_f_14_region_filter_10RegionList_asList(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
  PyObject *__pyx_r;
  static char *__pyx_argnames[] = {0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_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; Py_INCREF(Py_None);
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

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;
  npy_bool __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":335 */
  __pyx_v_child_regions = ((PyListObject *)__pyx_v_self->__pyx_base.child_regions);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":336 */
  __pyx_v_n = PyList_GET_SIZE(__pyx_v_child_regions);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":337 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_n; ++__pyx_v_i) {
    __pyx_1 = ((struct __pyx_vtabstruct_14_region_filter_RegionBase *)((struct __pyx_obj_14_region_filter_RegionBase *)PyList_GET_ITEM(__pyx_v_child_regions,__pyx_v_i))->__pyx_vtab)->_inside(((struct __pyx_obj_14_region_filter_RegionBase *)PyList_GET_ITEM(__pyx_v_child_regions,__pyx_v_i)),__pyx_v_x,__pyx_v_y);
    if (__pyx_1) {
      __pyx_r = 1;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":340 */
  __pyx_r = 0;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_12RegionOrList___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_14_region_filter_12RegionOrList___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_1 = PyObject_Repr(((struct __pyx_obj_14_region_filter_RegionOrList *)__pyx_v_self)->__pyx_base.child_regions); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; goto __pyx_L1;}
  __pyx_2 = PyNumber_Add(__pyx_n_Or, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 344; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_region_filter.RegionOrList.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

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_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":357 */
  __pyx_v_child_regions = ((PyListObject *)__pyx_v_self->__pyx_base.child_regions);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":358 */
  __pyx_v_n = PyList_GET_SIZE(__pyx_v_child_regions);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":359 */
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_n; ++__pyx_v_i) {
    __pyx_1 = (!((struct __pyx_vtabstruct_14_region_filter_RegionBase *)((struct __pyx_obj_14_region_filter_RegionBase *)PyList_GET_ITEM(__pyx_v_child_regions,__pyx_v_i))->__pyx_vtab)->_inside(((struct __pyx_obj_14_region_filter_RegionBase *)PyList_GET_ITEM(__pyx_v_child_regions,__pyx_v_i)),__pyx_v_x,__pyx_v_y));
    if (__pyx_1) {
      __pyx_r = 0;
      goto __pyx_L0;
      goto __pyx_L4;
    }
    __pyx_L4:;
  }

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":362 */
  __pyx_r = 1;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_13RegionAndList___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_14_region_filter_13RegionAndList___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_1 = PyObject_Repr(((struct __pyx_obj_14_region_filter_RegionAndList *)__pyx_v_self)->__pyx_base.child_regions); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;}
  __pyx_2 = PyNumber_Add(__pyx_n_And, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_region_filter.RegionAndList.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_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 PyObject *__pyx_f_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;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"region1","region2",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_region1, &__pyx_v_region2)) return 0;
  Py_INCREF(__pyx_v_region1);
  Py_INCREF(__pyx_v_region2);
  __pyx_v_region1_list = Py_None; Py_INCREF(Py_None);
  __pyx_v_region2_list = Py_None; Py_INCREF(Py_None);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_region1), __pyx_ptype_14_region_filter_RegionBase, 1, "region1")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_region2), __pyx_ptype_14_region_filter_RegionBase, 1, "region2")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; goto __pyx_L1;}

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":373 */
  __pyx_1 = PyObject_IsInstance(((PyObject *)__pyx_v_region1),((PyObject *)__pyx_ptype_14_region_filter_RegionAndList)); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; goto __pyx_L1;}
  if (__pyx_1) {
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_region1), __pyx_n_asList); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_v_region1_list);
    __pyx_v_region1_list = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; goto __pyx_L1;}
    Py_INCREF(((PyObject *)__pyx_v_region1));
    PyList_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_region1));
    Py_DECREF(__pyx_v_region1_list);
    __pyx_v_region1_list = __pyx_2;
    __pyx_2 = 0;
  }
  __pyx_L2:;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":378 */
  __pyx_1 = PyObject_IsInstance(((PyObject *)__pyx_v_region2),((PyObject *)__pyx_ptype_14_region_filter_RegionAndList)); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 378; goto __pyx_L1;}
  if (__pyx_1) {
    __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_region2), __pyx_n_asList); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; goto __pyx_L1;}
    __pyx_2 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 379; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_v_region2_list);
    __pyx_v_region2_list = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L3;
  }
  /*else*/ {
    __pyx_3 = PyList_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 381; goto __pyx_L1;}
    Py_INCREF(((PyObject *)__pyx_v_region2));
    PyList_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_region2));
    Py_DECREF(__pyx_v_region2_list);
    __pyx_v_region2_list = __pyx_3;
    __pyx_3 = 0;
  }
  __pyx_L3:;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":383 */
  __pyx_2 = PyNumber_Add(__pyx_v_region1_list, __pyx_v_region2_list); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; goto __pyx_L1;}
  __pyx_3 = PySequence_Tuple(__pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(((PyObject *)__pyx_ptype_14_region_filter_RegionAndList), __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 383; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_region_filter.RegionAnd");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_region1_list);
  Py_DECREF(__pyx_v_region2_list);
  Py_DECREF(__pyx_v_region1);
  Py_DECREF(__pyx_v_region2);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_RegionOr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static char __pyx_doc_14_region_filter_RegionOr[] = "\n    >>> r = RegionOr(reg1, reg2)\n    ";
static PyObject *__pyx_f_14_region_filter_RegionOr(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;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"region1","region2",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_region1, &__pyx_v_region2)) return 0;
  Py_INCREF(__pyx_v_region1);
  Py_INCREF(__pyx_v_region2);
  __pyx_v_region1_list = Py_None; Py_INCREF(Py_None);
  __pyx_v_region2_list = Py_None; Py_INCREF(Py_None);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_region1), __pyx_ptype_14_region_filter_RegionBase, 1, "region1")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; goto __pyx_L1;}
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_region2), __pyx_ptype_14_region_filter_RegionBase, 1, "region2")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; goto __pyx_L1;}

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":390 */
  __pyx_1 = PyObject_IsInstance(((PyObject *)__pyx_v_region1),((PyObject *)__pyx_ptype_14_region_filter_RegionOrList)); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; goto __pyx_L1;}
  if (__pyx_1) {
    __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_region1), __pyx_n_asList); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; goto __pyx_L1;}
    __pyx_3 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 391; goto __pyx_L1;}
    Py_DECREF(__pyx_2); __pyx_2 = 0;
    Py_DECREF(__pyx_v_region1_list);
    __pyx_v_region1_list = __pyx_3;
    __pyx_3 = 0;
    goto __pyx_L2;
  }
  /*else*/ {
    __pyx_2 = PyList_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 393; goto __pyx_L1;}
    Py_INCREF(((PyObject *)__pyx_v_region1));
    PyList_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_region1));
    Py_DECREF(__pyx_v_region1_list);
    __pyx_v_region1_list = __pyx_2;
    __pyx_2 = 0;
  }
  __pyx_L2:;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":395 */
  __pyx_1 = PyObject_IsInstance(((PyObject *)__pyx_v_region2),((PyObject *)__pyx_ptype_14_region_filter_RegionOrList)); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 395; goto __pyx_L1;}
  if (__pyx_1) {
    __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_region2), __pyx_n_asList); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}
    __pyx_2 = PyObject_CallObject(__pyx_3, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 396; goto __pyx_L1;}
    Py_DECREF(__pyx_3); __pyx_3 = 0;
    Py_DECREF(__pyx_v_region2_list);
    __pyx_v_region2_list = __pyx_2;
    __pyx_2 = 0;
    goto __pyx_L3;
  }
  /*else*/ {
    __pyx_3 = PyList_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; goto __pyx_L1;}
    Py_INCREF(((PyObject *)__pyx_v_region2));
    PyList_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_region2));
    Py_DECREF(__pyx_v_region2_list);
    __pyx_v_region2_list = __pyx_3;
    __pyx_3 = 0;
  }
  __pyx_L3:;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":400 */
  __pyx_2 = PyNumber_Add(__pyx_v_region1_list, __pyx_v_region2_list); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; goto __pyx_L1;}
  __pyx_3 = PySequence_Tuple(__pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  __pyx_2 = PyObject_CallObject(((PyObject *)__pyx_ptype_14_region_filter_RegionOrList), __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 400; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  __pyx_r = __pyx_2;
  __pyx_2 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_region_filter.RegionOr");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF(__pyx_v_region1_list);
  Py_DECREF(__pyx_v_region2_list);
  Py_DECREF(__pyx_v_region1);
  Py_DECREF(__pyx_v_region2);
  return __pyx_r;
}

static int __pyx_f_14_region_filter_9Transform___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_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 char *__pyx_argnames[] = {"child_region",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_child_region)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_child_region);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_child_region), __pyx_ptype_14_region_filter_RegionBase, 1, "child_region")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; goto __pyx_L1;}
  Py_INCREF(((PyObject *)__pyx_v_child_region));
  Py_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:;
  __Pyx_AddTraceback("_region_filter.Transform.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_child_region);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_9Transform_5child___get__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_14_region_filter_9Transform_5child___get__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_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; Py_INCREF(Py_None);
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

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;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":499 */
  (__pyx_v_xp[0]) = __pyx_v_x;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":500 */
  (__pyx_v_yp[0]) = __pyx_v_y;

  __pyx_r = 0;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_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;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":506 */
  ((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));

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":507 */
  __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);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":509 */
  __pyx_r = __pyx_v_r;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_14_region_filter_7Rotated___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_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_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"child_region","degree","origin_x","origin_y",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Oddd", __pyx_argnames, &__pyx_v_child_region, &__pyx_v_degree, &__pyx_v_origin_x, &__pyx_v_origin_y)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_child_region);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_child_region), __pyx_ptype_14_region_filter_RegionBase, 1, "child_region")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 534; goto __pyx_L1;}

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":538 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_ptype_14_region_filter_Transform), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF(((PyObject *)__pyx_v_child_region));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_child_region));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":540 */
  __pyx_v_theta = ((__pyx_v_degree / 180.) * M_PI);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":541 */
  ((struct __pyx_obj_14_region_filter_Rotated *)__pyx_v_self)->sin_theta = sin(__pyx_v_theta);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":542 */
  ((struct __pyx_obj_14_region_filter_Rotated *)__pyx_v_self)->cos_theta = cos(__pyx_v_theta);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":544 */
  ((struct __pyx_obj_14_region_filter_Rotated *)__pyx_v_self)->origin_x = __pyx_v_origin_x;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":545 */
  ((struct __pyx_obj_14_region_filter_Rotated *)__pyx_v_self)->origin_y = __pyx_v_origin_y;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_region_filter.Rotated.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_child_region);
  return __pyx_r;
}

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;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":552 */
  __pyx_v_st = __pyx_v_self->sin_theta;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":553 */
  __pyx_v_ct = __pyx_v_self->cos_theta;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":554 */
  __pyx_v_ox = __pyx_v_self->origin_x;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":555 */
  __pyx_v_oy = __pyx_v_self->origin_y;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":557 */
  __pyx_v_x1 = (__pyx_v_x - __pyx_v_ox);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":558 */
  __pyx_v_y1 = (__pyx_v_y - __pyx_v_oy);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":560 */
  __pyx_v_x2 = ((__pyx_v_ct * __pyx_v_x1) + (__pyx_v_st * __pyx_v_y1));

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":561 */
  __pyx_v_y2 = (((-__pyx_v_st) * __pyx_v_x1) + (__pyx_v_ct * __pyx_v_y1));

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":563 */
  (__pyx_v_xp[0]) = (__pyx_v_x2 + __pyx_v_ox);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":564 */
  (__pyx_v_yp[0]) = (__pyx_v_y2 + __pyx_v_oy);

  __pyx_r = 0;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_14_region_filter_10Translated___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_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_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  static char *__pyx_argnames[] = {"child_region","dx","dy",0};
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Odd", __pyx_argnames, &__pyx_v_child_region, &__pyx_v_dx, &__pyx_v_dy)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_child_region);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_child_region), __pyx_ptype_14_region_filter_RegionBase, 1, "child_region")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; goto __pyx_L1;}

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":581 */
  __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_ptype_14_region_filter_Transform), __pyx_n___init__); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; goto __pyx_L1;}
  Py_INCREF(__pyx_v_self);
  PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_self);
  Py_INCREF(((PyObject *)__pyx_v_child_region));
  PyTuple_SET_ITEM(__pyx_2, 1, ((PyObject *)__pyx_v_child_region));
  __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":583 */
  ((struct __pyx_obj_14_region_filter_Translated *)__pyx_v_self)->dx = __pyx_v_dx;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":584 */
  ((struct __pyx_obj_14_region_filter_Translated *)__pyx_v_self)->dy = __pyx_v_dy;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_region_filter.Translated.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_child_region);
  return __pyx_r;
}

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;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":587 */
  (__pyx_v_xp[0]) = (__pyx_v_x - __pyx_v_self->dx);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":588 */
  (__pyx_v_yp[0]) = (__pyx_v_y - __pyx_v_self->dy);

  __pyx_r = 0;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

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;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":613 */
  __pyx_v_self->xc = __pyx_v_xc;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":614 */
  __pyx_v_self->yc = __pyx_v_yc;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":615 */
  __pyx_v_self->radius = __pyx_v_radius;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":616 */
  __pyx_v_self->radius2 = (__pyx_v_radius * __pyx_v_radius);

  __pyx_r = Py_None; Py_INCREF(Py_None);
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_6Circle__get_v(struct __pyx_obj_14_region_filter_Circle *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_1 = PyFloat_FromDouble(__pyx_v_self->xc); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(__pyx_v_self->yc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(__pyx_v_self->radius); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 2, __pyx_3);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_r = __pyx_4;
  __pyx_4 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_region_filter.Circle._get_v");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_14_region_filter_6Circle___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_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_1 = 0;
  static char *__pyx_argnames[] = {"xc","yc","radius","c",0};
  __pyx_v_c = __pyx_d1;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "ddd|O", __pyx_argnames, &__pyx_v_xc, &__pyx_v_yc, &__pyx_v_radius, &__pyx_v_c)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_c);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_c), __pyx_ptype_14_region_filter_RegionContext, 1, "c")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; goto __pyx_L1;}

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":628 */
  __pyx_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 (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":629 */
  __pyx_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 (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 629; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_region_filter.Circle.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_c);
  return __pyx_r;
}

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;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":635 */
  __pyx_v_dist2 = (pow(((__pyx_v_x - __pyx_v_self->xc) * __pyx_v_self->__pyx_base.m.g_x), 2) + pow(((__pyx_v_y - __pyx_v_self->yc) * __pyx_v_self->__pyx_base.m.g_y), 2));

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":636 */
  __pyx_r = (__pyx_v_dist2 <= __pyx_v_self->radius2);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_6Circle___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_14_region_filter_6Circle___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_Circle *)__pyx_v_self)->xc); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_Circle *)__pyx_v_self)->yc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_Circle *)__pyx_v_self)->radius); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; goto __pyx_L1;}
  __pyx_4 = PyTuple_New(3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_4, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_4, 2, __pyx_3);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_1 = PyNumber_Remainder(__pyx_k15p, __pyx_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; goto __pyx_L1;}
  Py_DECREF(__pyx_4); __pyx_4 = 0;
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  __Pyx_AddTraceback("_region_filter.Circle.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_14_region_filter_7Ellipse___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_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_1 = 0;
  static char *__pyx_argnames[] = {"xc","yc","radius_major","radius_minor","c",0};
  __pyx_v_c = __pyx_d2;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "dddd|O", __pyx_argnames, &__pyx_v_xc, &__pyx_v_yc, &__pyx_v_radius_major, &__pyx_v_radius_minor, &__pyx_v_c)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_c);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_c), __pyx_ptype_14_region_filter_RegionContext, 1, "c")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; goto __pyx_L1;}

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":668 */
  ((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->xc = __pyx_v_xc;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":669 */
  ((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->yc = __pyx_v_yc;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":670 */
  ((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->radius_major = __pyx_v_radius_major;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":671 */
  ((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->radius_minor = __pyx_v_radius_minor;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":672 */
  ((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->radius_major_2 = pow(__pyx_v_radius_major, 2);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":673 */
  ((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->radius_minor_2 = pow(__pyx_v_radius_minor, 2);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":674 */
  ((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);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":676 */
  __pyx_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 (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_region_filter.Ellipse.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_c);
  return __pyx_r;
}

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;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":683 */
  __pyx_v_dist2 = ((__pyx_v_self->radius_minor_2 * pow((__pyx_v_x - __pyx_v_self->xc), 2)) + (__pyx_v_self->radius_major_2 * pow((__pyx_v_y - __pyx_v_self->yc), 2)));

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":684 */
  __pyx_r = (__pyx_v_dist2 <= __pyx_v_self->radius_major_2_radius_minor_2);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_7Ellipse___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_14_region_filter_7Ellipse___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->xc); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->yc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->radius_major); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_Ellipse *)__pyx_v_self)->radius_minor); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_1 = PyNumber_Remainder(__pyx_k16p, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_region_filter.Ellipse.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_14_region_filter_3Box___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_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_1 = 0;
  static char *__pyx_argnames[] = {"xc","yc","width","height","c",0};
  __pyx_v_c = __pyx_d3;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "dddd|O", __pyx_argnames, &__pyx_v_xc, &__pyx_v_yc, &__pyx_v_width, &__pyx_v_height, &__pyx_v_c)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_c);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_c), __pyx_ptype_14_region_filter_RegionContext, 1, "c")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; goto __pyx_L1;}

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":709 */
  __pyx_v_halfwidth = (__pyx_v_width * .5);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":710 */
  __pyx_v_halfheight = (__pyx_v_height * .5);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":712 */
  ((struct __pyx_obj_14_region_filter_Box *)__pyx_v_self)->x1 = (__pyx_v_xc - __pyx_v_halfwidth);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":713 */
  ((struct __pyx_obj_14_region_filter_Box *)__pyx_v_self)->x2 = (__pyx_v_xc + __pyx_v_halfwidth);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":714 */
  ((struct __pyx_obj_14_region_filter_Box *)__pyx_v_self)->y1 = (__pyx_v_yc - __pyx_v_halfheight);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":715 */
  ((struct __pyx_obj_14_region_filter_Box *)__pyx_v_self)->y2 = (__pyx_v_yc + __pyx_v_halfheight);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":717 */
  __pyx_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 (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_region_filter.Box.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_c);
  return __pyx_r;
}

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;
  Py_INCREF((PyObject *)__pyx_v_self);
  __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:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_14_region_filter_7Polygon___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_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_1 = 0;
  static char *__pyx_argnames[] = {"x","y","c",0};
  __pyx_v_c = __pyx_d4;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO|O", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_c)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_x);
  Py_INCREF(__pyx_v_y);
  Py_INCREF(__pyx_v_c);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_c), __pyx_ptype_14_region_filter_RegionContext, 1, "c")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; goto __pyx_L1;}

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":746 */
  __pyx_1 = PyArray_CopyFromObject(__pyx_v_x,NPY_DOUBLE,1,1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; goto __pyx_L1;}
  Py_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_1);
  __pyx_1 = 0;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":747 */
  __pyx_1 = PyArray_CopyFromObject(__pyx_v_y,NPY_DOUBLE,1,1); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;}
  if (!__Pyx_TypeTest(__pyx_1, __pyx_ptype_7c_numpy_ndarray)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; goto __pyx_L1;}
  Py_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_1);
  __pyx_1 = 0;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":749 */
  ((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->n = PyArray_SIZE(((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->xa);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":751 */
  ((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->x = ((double *)PyArray_DATA(((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->xa));

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":752 */
  ((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->y = ((double *)PyArray_DATA(((struct __pyx_obj_14_region_filter_Polygon *)__pyx_v_self)->ya));

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":754 */
  __pyx_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 (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; goto __pyx_L1;}
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  __Pyx_AddTraceback("_region_filter.Polygon.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_x);
  Py_DECREF(__pyx_v_y);
  Py_DECREF(__pyx_v_c);
  return __pyx_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_1;
  int __pyx_2;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":766 */
  __pyx_v_j = (__pyx_v_self->n - 1);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":767 */
  __pyx_v_r = 0;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":768 */
  __pyx_v_xp = __pyx_v_self->x;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":769 */
  __pyx_v_yp = __pyx_v_self->y;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":782 */
  __pyx_1 = __pyx_v_self->n;
  for (__pyx_v_i = 0; __pyx_v_i < __pyx_1; ++__pyx_v_i) {

    /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":783 */
    __pyx_v_y_yp_i = (__pyx_v_y - (__pyx_v_yp[__pyx_v_i]));

    /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":784 */
    __pyx_v_y_yp_j = (__pyx_v_y - (__pyx_v_yp[__pyx_v_j]));

    /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":786 */
    __pyx_2 = ((__pyx_v_y_yp_i == 0.) & (__pyx_v_y_yp_j == 0.));
    if (__pyx_2) {
      __pyx_2 = ((((__pyx_v_xp[__pyx_v_i]) - __pyx_v_x) * ((__pyx_v_xp[__pyx_v_j]) - __pyx_v_x)) <= 0.);
      if (__pyx_2) {
        __pyx_r = 1;
        goto __pyx_L0;
        goto __pyx_L5;
      }
      __pyx_L5:;
      goto __pyx_L4;
    }
    __pyx_L4:;

    /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":790 */
    __pyx_2 = (((0 <= __pyx_v_y_yp_i) & (0 > __pyx_v_y_yp_j)) | ((0 <= __pyx_v_y_yp_j) & (0 > __pyx_v_y_yp_i)));
    if (__pyx_2) {

      /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":791 */
      __pyx_v__t = ((__pyx_v_xp[__pyx_v_i]) + ((__pyx_v_y_yp_i / ((__pyx_v_yp[__pyx_v_j]) - (__pyx_v_yp[__pyx_v_i]))) * ((__pyx_v_xp[__pyx_v_j]) - (__pyx_v_xp[__pyx_v_i]))));

      /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":792 */
      __pyx_2 = (__pyx_v__t == __pyx_v_x);
      if (__pyx_2) {
        __pyx_r = 1;
        goto __pyx_L0;
        goto __pyx_L7;
      }
      __pyx_L7:;

      /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":795 */
      __pyx_2 = (__pyx_v__t < __pyx_v_x);
      if (__pyx_2) {
        __pyx_v_r = (!__pyx_v_r);
        goto __pyx_L8;
      }
      __pyx_L8:;
      goto __pyx_L6;
    }
    __pyx_L6:;

    /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":797 */
    __pyx_v_j = __pyx_v_i;
  }

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":801 */
  __pyx_r = __pyx_v_r;
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static int __pyx_f_14_region_filter_10AngleRange___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
static int __pyx_f_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;
  int __pyx_1;
  PyObject *__pyx_2 = 0;
  static char *__pyx_argnames[] = {"xc","yc","degree1","degree2","c",0};
  __pyx_v_c = __pyx_d5;
  if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "dddd|O", __pyx_argnames, &__pyx_v_xc, &__pyx_v_yc, &__pyx_v_degree1, &__pyx_v_degree2, &__pyx_v_c)) return -1;
  Py_INCREF((PyObject *)__pyx_v_self);
  Py_INCREF(__pyx_v_c);
  if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_c), __pyx_ptype_14_region_filter_RegionContext, 1, "c")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; goto __pyx_L1;}

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":824 */
  ((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->xc = __pyx_v_xc;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":825 */
  ((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->yc = __pyx_v_yc;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":826 */
  ((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->degree1 = __pyx_v_degree1;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":827 */
  ((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->degree2 = __pyx_v_degree2;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":830 */
  ((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->radian1 = (((fmod((__pyx_v_degree1 + 180),360.) - 180) / 180.) * M_PI);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":831 */
  ((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->radian2 = (((fmod((__pyx_v_degree2 + 180),360.) - 180) / 180.) * M_PI);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":836 */
  __pyx_1 = (((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->radian2 < ((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->radian1);
  if (__pyx_1) {
    ((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->radian2 += (2. * M_PI);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":839 */
  __pyx_2 = ((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 (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;

  __pyx_r = 0;
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_2);
  __Pyx_AddTraceback("_region_filter.AngleRange.__init__");
  __pyx_r = -1;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  Py_DECREF(__pyx_v_c);
  return __pyx_r;
}

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;
  int __pyx_1;
  Py_INCREF((PyObject *)__pyx_v_self);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":845 */
  __pyx_v_dx = (__pyx_v_x - __pyx_v_self->xc);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":846 */
  __pyx_v_dy = (__pyx_v_y - __pyx_v_self->yc);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":848 */
  __pyx_v_theta = atan2(__pyx_v_dy,__pyx_v_dx);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":850 */
  __pyx_1 = (__pyx_v_theta < __pyx_v_self->radian1);
  if (__pyx_1) {
    __pyx_v_theta += (2. * M_PI);
    goto __pyx_L2;
  }
  __pyx_L2:;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":852 */
  __pyx_r = (__pyx_v_theta < __pyx_v_self->radian2);
  goto __pyx_L0;

  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  return __pyx_r;
}

static PyObject *__pyx_f_14_region_filter_10AngleRange___repr__(PyObject *__pyx_v_self); /*proto*/
static PyObject *__pyx_f_14_region_filter_10AngleRange___repr__(PyObject *__pyx_v_self) {
  PyObject *__pyx_r;
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  PyObject *__pyx_4 = 0;
  PyObject *__pyx_5 = 0;
  Py_INCREF((PyObject *)__pyx_v_self);
  __pyx_1 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->xc); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; goto __pyx_L1;}
  __pyx_2 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->yc); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; goto __pyx_L1;}
  __pyx_3 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->degree1); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; goto __pyx_L1;}
  __pyx_4 = PyFloat_FromDouble(((struct __pyx_obj_14_region_filter_AngleRange *)__pyx_v_self)->degree2); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; goto __pyx_L1;}
  __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; goto __pyx_L1;}
  PyTuple_SET_ITEM(__pyx_5, 0, __pyx_1);
  PyTuple_SET_ITEM(__pyx_5, 1, __pyx_2);
  PyTuple_SET_ITEM(__pyx_5, 2, __pyx_3);
  PyTuple_SET_ITEM(__pyx_5, 3, __pyx_4);
  __pyx_1 = 0;
  __pyx_2 = 0;
  __pyx_3 = 0;
  __pyx_4 = 0;
  __pyx_1 = PyNumber_Remainder(__pyx_k17p, __pyx_5); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; goto __pyx_L1;}
  Py_DECREF(__pyx_5); __pyx_5 = 0;
  __pyx_r = __pyx_1;
  __pyx_1 = 0;
  goto __pyx_L0;

  __pyx_r = Py_None; Py_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  Py_XDECREF(__pyx_4);
  Py_XDECREF(__pyx_5);
  __Pyx_AddTraceback("_region_filter.AngleRange.__repr__");
  __pyx_r = 0;
  __pyx_L0:;
  Py_DECREF((PyObject *)__pyx_v_self);
  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);
  *(struct __pyx_vtabstruct_14_region_filter_RegionContext **)&p->__pyx_vtab = __pyx_vtabptr_14_region_filter_RegionContext;
  return o;
}

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

static struct 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*/
  0, /*nb_divide*/
  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*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  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_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  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 = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_14_region_filter_RegionContext = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_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*/
  0, /*tp_compare*/
  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_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_f_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*/
};
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);
  *(struct __pyx_vtabstruct_14_region_filter_RegionBase **)&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));
  (*o->ob_type->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 *t;
  t = ((PyObject *)p->c); 
  p->c = ((struct __pyx_obj_14_region_filter_RegionContext *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(t);
  return 0;
}

static struct PyMethodDef __pyx_methods_14_region_filter_RegionBase[] = {
  {"set_context", (PyCFunction)__pyx_f_14_region_filter_10RegionBase_set_context, METH_VARARGS|METH_KEYWORDS, 0},
  {"mask", (PyCFunction)__pyx_f_14_region_filter_10RegionBase_mask, METH_VARARGS|METH_KEYWORDS, __pyx_doc_14_region_filter_10RegionBase_mask},
  {"inside1", (PyCFunction)__pyx_f_14_region_filter_10RegionBase_inside1, METH_VARARGS|METH_KEYWORDS, __pyx_doc_14_region_filter_10RegionBase_inside1},
  {"inside", (PyCFunction)__pyx_f_14_region_filter_10RegionBase_inside, METH_VARARGS|METH_KEYWORDS, __pyx_doc_14_region_filter_10RegionBase_inside},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_RegionBase = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  0, /*nb_remainder*/
  0, /*nb_divmod*/
  0, /*nb_power*/
  0, /*nb_negative*/
  0, /*nb_positive*/
  0, /*nb_absolute*/
  0, /*nb_nonzero*/
  __pyx_f_14_region_filter_10RegionBase___invert__, /*nb_invert*/
  0, /*nb_lshift*/
  0, /*nb_rshift*/
  __pyx_f_14_region_filter_10RegionBase___and__, /*nb_and*/
  0, /*nb_xor*/
  __pyx_f_14_region_filter_10RegionBase___or__, /*nb_or*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  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_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  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 = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_14_region_filter_RegionBase = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_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*/
  0, /*tp_compare*/
  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_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_f_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*/
};
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_ptype_14_region_filter_RegionBase->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_RegionNot *)o);
  *(struct __pyx_vtabstruct_14_region_filter_RegionNot **)&p->__pyx_base.__pyx_vtab = __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_ptype_14_region_filter_RegionBase->tp_dealloc(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;
  traverseproc t;
  if ((t = __pyx_ptype_14_region_filter_RegionBase->tp_traverse)) {
    e = t(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 *t;
  inquiry c;
  if ((c = __pyx_ptype_14_region_filter_RegionBase->tp_clear)) {
    c(o);
  }
  t = ((PyObject *)p->child_region); 
  p->child_region = ((struct __pyx_obj_14_region_filter_RegionBase *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(t);
  return 0;
}

static struct 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*/
  0, /*nb_divide*/
  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*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  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_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  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 = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_14_region_filter_RegionNot = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_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*/
  0, /*tp_compare*/
  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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\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_f_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*/
};
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_ptype_14_region_filter_RegionBase->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_RegionList *)o);
  *(struct __pyx_vtabstruct_14_region_filter_RegionList **)&p->__pyx_base.__pyx_vtab = __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_ptype_14_region_filter_RegionBase->tp_dealloc(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;
  traverseproc t;
  if ((t = __pyx_ptype_14_region_filter_RegionBase->tp_traverse)) {
    e = t(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 *t;
  inquiry c;
  if ((c = __pyx_ptype_14_region_filter_RegionBase->tp_clear)) {
    c(o);
  }
  t = p->child_regions; 
  p->child_regions = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(t);
  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 = o->ob_type->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_f_14_region_filter_10RegionList___setitem__(o, i, v);
  }
  else {
    return __pyx_f_14_region_filter_10RegionList___delitem__(o, i);
  }
}

static int __pyx_sq_ass_slice_14_region_filter_RegionList(PyObject *o, Py_ssize_t i, Py_ssize_t j, PyObject *v) {
  if (v) {
    return __pyx_f_14_region_filter_10RegionList___setslice__(o, i, j, v);
  }
  else {
    return __pyx_f_14_region_filter_10RegionList___delslice__(o, i, j);
  }
}

static struct PyMethodDef __pyx_methods_14_region_filter_RegionList[] = {
  {"_check_type_of_list", (PyCFunction)__pyx_f_14_region_filter_10RegionList__check_type_of_list, METH_VARARGS|METH_KEYWORDS, 0},
  {"asList", (PyCFunction)__pyx_f_14_region_filter_10RegionList_asList, METH_VARARGS|METH_KEYWORDS, 0},
  {0, 0, 0, 0}
};

static PyNumberMethods __pyx_tp_as_number_RegionList = {
  0, /*nb_add*/
  0, /*nb_subtract*/
  0, /*nb_multiply*/
  0, /*nb_divide*/
  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*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  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_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  0, /*nb_index*/
  #endif
};

static PySequenceMethods __pyx_tp_as_sequence_RegionList = {
  __pyx_f_14_region_filter_10RegionList___len__, /*sq_length*/
  0, /*sq_concat*/
  0, /*sq_repeat*/
  __pyx_sq_item_14_region_filter_RegionList, /*sq_item*/
  __pyx_f_14_region_filter_10RegionList___getslice__, /*sq_slice*/
  0, /*sq_ass_item*/
  __pyx_sq_ass_slice_14_region_filter_RegionList, /*sq_ass_slice*/
  __pyx_f_14_region_filter_10RegionList___contains__, /*sq_contains*/
  0, /*sq_inplace_concat*/
  0, /*sq_inplace_repeat*/
};

static PyMappingMethods __pyx_tp_as_mapping_RegionList = {
  __pyx_f_14_region_filter_10RegionList___len__, /*mp_length*/
  __pyx_f_14_region_filter_10RegionList___getitem__, /*mp_subscript*/
  __pyx_mp_ass_subscript_14_region_filter_RegionList, /*mp_ass_subscript*/
};

static PyBufferProcs __pyx_tp_as_buffer_RegionList = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_14_region_filter_RegionList = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_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*/
  0, /*tp_compare*/
  __pyx_f_14_region_filter_10RegionList___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_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_f_14_region_filter_10RegionList___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*/
};
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_ptype_14_region_filter_RegionList->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_RegionOrList *)o);
  *(struct __pyx_vtabstruct_14_region_filter_RegionOrList **)&p->__pyx_base.__pyx_base.__pyx_vtab = __pyx_vtabptr_14_region_filter_RegionOrList;
  return o;
}

static void __pyx_tp_dealloc_14_region_filter_RegionOrList(PyObject *o) {
  __pyx_ptype_14_region_filter_RegionList->tp_dealloc(o);
}

static struct 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*/
  0, /*nb_divide*/
  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*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  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_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  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 = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_14_region_filter_RegionOrList = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_region_filter.RegionOrList", /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_RegionOrList), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_RegionOrList, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_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_BASETYPE, /*tp_flags*/
  "\n    >>> r = RegionOrList(r1, r2, r3, r4, ...)\n    ", /*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_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*/
};
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_ptype_14_region_filter_RegionList->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_RegionAndList *)o);
  *(struct __pyx_vtabstruct_14_region_filter_RegionAndList **)&p->__pyx_base.__pyx_base.__pyx_vtab = __pyx_vtabptr_14_region_filter_RegionAndList;
  return o;
}

static void __pyx_tp_dealloc_14_region_filter_RegionAndList(PyObject *o) {
  __pyx_ptype_14_region_filter_RegionList->tp_dealloc(o);
}

static struct 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*/
  0, /*nb_divide*/
  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*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  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_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  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 = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_14_region_filter_RegionAndList = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_region_filter.RegionAndList", /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_RegionAndList), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_RegionAndList, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_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_BASETYPE, /*tp_flags*/
  "\n    >>> r = RegionAndList(r1, r2, r3, r4, ...)\n    ", /*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_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*/
};
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_ptype_14_region_filter_RegionBase->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_Transform *)o);
  *(struct __pyx_vtabstruct_14_region_filter_Transform **)&p->__pyx_base.__pyx_vtab = __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_ptype_14_region_filter_RegionBase->tp_dealloc(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;
  traverseproc t;
  if ((t = __pyx_ptype_14_region_filter_RegionBase->tp_traverse)) {
    e = t(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 *t;
  inquiry c;
  if ((c = __pyx_ptype_14_region_filter_RegionBase->tp_clear)) {
    c(o);
  }
  t = ((PyObject *)p->child_region); 
  p->child_region = ((struct __pyx_obj_14_region_filter_RegionBase *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(t);
  return 0;
}

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

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

static struct PyGetSetDef __pyx_getsets_14_region_filter_Transform[] = {
  {"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*/
  0, /*nb_divide*/
  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*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  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_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  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 = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_14_region_filter_Transform = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_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*/
  0, /*tp_compare*/
  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_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_f_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*/
};
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_ptype_14_region_filter_Transform->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_Rotated *)o);
  *(struct __pyx_vtabstruct_14_region_filter_Rotated **)&p->__pyx_base.__pyx_base.__pyx_vtab = __pyx_vtabptr_14_region_filter_Rotated;
  return o;
}

static void __pyx_tp_dealloc_14_region_filter_Rotated(PyObject *o) {
  __pyx_ptype_14_region_filter_Transform->tp_dealloc(o);
}

static struct 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*/
  0, /*nb_divide*/
  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*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  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_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  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 = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_14_region_filter_Rotated = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_region_filter.Rotated", /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_Rotated), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_Rotated, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  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_BASETYPE, /*tp_flags*/
  "\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*/
  0, /*tp_traverse*/
  0, /*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_f_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*/
};
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_ptype_14_region_filter_Transform->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_Translated *)o);
  *(struct __pyx_vtabstruct_14_region_filter_Translated **)&p->__pyx_base.__pyx_base.__pyx_vtab = __pyx_vtabptr_14_region_filter_Translated;
  return o;
}

static void __pyx_tp_dealloc_14_region_filter_Translated(PyObject *o) {
  __pyx_ptype_14_region_filter_Transform->tp_dealloc(o);
}

static struct 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*/
  0, /*nb_divide*/
  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*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  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_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  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 = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_14_region_filter_Translated = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_region_filter.Translated", /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_Translated), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_Translated, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  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_BASETYPE, /*tp_flags*/
  "\n    Translated region\n\n     >>> Translate(child_region, dx, dy)\n    ", /*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_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_f_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*/
};
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_ptype_14_region_filter_RegionBase->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_Circle *)o);
  *(struct __pyx_vtabstruct_14_region_filter_Circle **)&p->__pyx_base.__pyx_vtab = __pyx_vtabptr_14_region_filter_Circle;
  return o;
}

static void __pyx_tp_dealloc_14_region_filter_Circle(PyObject *o) {
  __pyx_ptype_14_region_filter_RegionBase->tp_dealloc(o);
}

static struct 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*/
  0, /*nb_divide*/
  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*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  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_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  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 = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_14_region_filter_Circle = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_region_filter.Circle", /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_Circle), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_Circle, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_14_region_filter_6Circle___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_BASETYPE, /*tp_flags*/
  "\n    Circle\n\n      >>> cir = Circle(xc, yc, radius, RegionContext c=None)\n\n    ", /*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_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_f_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*/
};
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_ptype_14_region_filter_RegionBase->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_Ellipse *)o);
  *(struct __pyx_vtabstruct_14_region_filter_Ellipse **)&p->__pyx_base.__pyx_vtab = __pyx_vtabptr_14_region_filter_Ellipse;
  return o;
}

static void __pyx_tp_dealloc_14_region_filter_Ellipse(PyObject *o) {
  __pyx_ptype_14_region_filter_RegionBase->tp_dealloc(o);
}

static struct 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*/
  0, /*nb_divide*/
  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*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  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_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  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 = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_14_region_filter_Ellipse = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_region_filter.Ellipse", /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_Ellipse), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_Ellipse, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_14_region_filter_7Ellipse___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_BASETYPE, /*tp_flags*/
  "\n    Ellipse\n\n      >>> shape = Ellipse(xc, yc, radius_major, radius_minor)\n\n    ", /*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_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_f_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*/
};
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_ptype_14_region_filter_RegionBase->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_Box *)o);
  *(struct __pyx_vtabstruct_14_region_filter_Box **)&p->__pyx_base.__pyx_vtab = __pyx_vtabptr_14_region_filter_Box;
  return o;
}

static void __pyx_tp_dealloc_14_region_filter_Box(PyObject *o) {
  __pyx_ptype_14_region_filter_RegionBase->tp_dealloc(o);
}

static struct 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*/
  0, /*nb_divide*/
  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*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  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_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  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 = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_14_region_filter_Box = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_region_filter.Box", /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_Box), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_Box, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  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_BASETYPE, /*tp_flags*/
  "\n    Box\n\n    >>> shape = Box(xc, yc, width, height)\n\n    ", /*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_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_f_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*/
};
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_ptype_14_region_filter_RegionBase->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_Polygon *)o);
  *(struct __pyx_vtabstruct_14_region_filter_Polygon **)&p->__pyx_base.__pyx_vtab = __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_ptype_14_region_filter_RegionBase->tp_dealloc(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;
  traverseproc t;
  if ((t = __pyx_ptype_14_region_filter_RegionBase->tp_traverse)) {
    e = t(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 *t;
  inquiry c;
  if ((c = __pyx_ptype_14_region_filter_RegionBase->tp_clear)) {
    c(o);
  }
  t = ((PyObject *)p->xa); 
  p->xa = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(t);
  t = ((PyObject *)p->ya); 
  p->ya = ((PyArrayObject *)Py_None); Py_INCREF(Py_None);
  Py_XDECREF(t);
  return 0;
}

static struct 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*/
  0, /*nb_divide*/
  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*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  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_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  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 = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_14_region_filter_Polygon = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_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*/
  0, /*tp_compare*/
  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_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  "\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_f_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*/
};
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_ptype_14_region_filter_RegionBase->tp_new(t, a, k);
  if (!o) return 0;
  p = ((struct __pyx_obj_14_region_filter_AngleRange *)o);
  *(struct __pyx_vtabstruct_14_region_filter_AngleRange **)&p->__pyx_base.__pyx_vtab = __pyx_vtabptr_14_region_filter_AngleRange;
  return o;
}

static void __pyx_tp_dealloc_14_region_filter_AngleRange(PyObject *o) {
  __pyx_ptype_14_region_filter_RegionBase->tp_dealloc(o);
}

static struct 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*/
  0, /*nb_divide*/
  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*/
  0, /*nb_coerce*/
  0, /*nb_int*/
  0, /*nb_long*/
  0, /*nb_float*/
  0, /*nb_oct*/
  0, /*nb_hex*/
  0, /*nb_inplace_add*/
  0, /*nb_inplace_subtract*/
  0, /*nb_inplace_multiply*/
  0, /*nb_inplace_divide*/
  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_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
  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 = {
  0, /*bf_getreadbuffer*/
  0, /*bf_getwritebuffer*/
  0, /*bf_getsegcount*/
  0, /*bf_getcharbuffer*/
};

PyTypeObject __pyx_type_14_region_filter_AngleRange = {
  PyObject_HEAD_INIT(0)
  0, /*ob_size*/
  "_region_filter.AngleRange", /*tp_name*/
  sizeof(struct __pyx_obj_14_region_filter_AngleRange), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_14_region_filter_AngleRange, /*tp_dealloc*/
  0, /*tp_print*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_compare*/
  __pyx_f_14_region_filter_10AngleRange___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_BASETYPE, /*tp_flags*/
  "\n    AngleRange\n\n      >>> shape = Ellipse(xc, yc, degree1, degree2)\n\n    ", /*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_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_f_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*/
};

static struct PyMethodDef __pyx_methods[] = {
  {"RegionAnd", (PyCFunction)__pyx_f_14_region_filter_RegionAnd, METH_VARARGS|METH_KEYWORDS, __pyx_doc_14_region_filter_RegionAnd},
  {"RegionOr", (PyCFunction)__pyx_f_14_region_filter_RegionOr, METH_VARARGS|METH_KEYWORDS, __pyx_doc_14_region_filter_RegionOr},
  {0, 0, 0, 0}
};

static void __pyx_init_filenames(void); /*proto*/

PyMODINIT_FUNC init_region_filter(void); /*proto*/
PyMODINIT_FUNC init_region_filter(void) {
  PyObject *__pyx_1 = 0;
  PyObject *__pyx_2 = 0;
  PyObject *__pyx_3 = 0;
  __pyx_init_filenames();
  __pyx_m = Py_InitModule4("_region_filter", __pyx_methods, 0, 0, PYTHON_API_VERSION);
  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;};
  Py_INCREF(__pyx_m);
  __pyx_b = PyImport_AddModule("__builtin__");
  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;};
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;};
  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;};
  __pyx_v_14_region_filter_metric_wcs = ((struct __pyx_obj_14_region_filter_RegionContext *)Py_None); Py_INCREF(Py_None);
  __pyx_vtabptr_14_region_filter_RegionContext = &__pyx_vtable_14_region_filter_RegionContext;
  *(void(**)(void))&__pyx_vtable_14_region_filter_RegionContext.set_update_func = (void(*)(void))__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 = 53; goto __pyx_L1;}
  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 = 53; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "RegionContext", (PyObject *)&__pyx_type_14_region_filter_RegionContext) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; goto __pyx_L1;}
  __pyx_ptype_14_region_filter_RegionContext = &__pyx_type_14_region_filter_RegionContext;
  __pyx_vtabptr_14_region_filter_RegionBase = &__pyx_vtable_14_region_filter_RegionBase;
  *(void(**)(void))&__pyx_vtable_14_region_filter_RegionBase.update_metric = (void(*)(void))__pyx_f_14_region_filter_10RegionBase_update_metric;
  *(void(**)(void))&__pyx_vtable_14_region_filter_RegionBase.metric_set_origin = (void(*)(void))__pyx_f_14_region_filter_10RegionBase_metric_set_origin;
  *(void(**)(void))&__pyx_vtable_14_region_filter_RegionBase._inside = (void(*)(void))__pyx_f_14_region_filter_10RegionBase__inside;
  *(void(**)(void))&__pyx_vtable_14_region_filter_RegionBase._mask = (void(*)(void))__pyx_f_14_region_filter_10RegionBase__mask;
  __pyx_type_14_region_filter_RegionBase.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_14_region_filter_RegionBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;}
  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 = 91; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "RegionBase", (PyObject *)&__pyx_type_14_region_filter_RegionBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; goto __pyx_L1;}
  __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;
  *(void(**)(void))&__pyx_vtable_14_region_filter_RegionNot.__pyx_base._inside = (void(*)(void))__pyx_f_14_region_filter_9RegionNot__inside;
  __pyx_type_14_region_filter_RegionNot.tp_base = __pyx_ptype_14_region_filter_RegionBase;
  __pyx_type_14_region_filter_RegionNot.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_14_region_filter_RegionNot) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; goto __pyx_L1;}
  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 = 270; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "RegionNot", (PyObject *)&__pyx_type_14_region_filter_RegionNot) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 270; goto __pyx_L1;}
  __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;
  __pyx_type_14_region_filter_RegionList.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_14_region_filter_RegionList) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; goto __pyx_L1;}
  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 = 283; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "RegionList", (PyObject *)&__pyx_type_14_region_filter_RegionList) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; goto __pyx_L1;}
  __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;
  *(void(**)(void))&__pyx_vtable_14_region_filter_RegionOrList.__pyx_base.__pyx_base._inside = (void(*)(void))__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 = 327; goto __pyx_L1;}
  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 = 327; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "RegionOrList", (PyObject *)&__pyx_type_14_region_filter_RegionOrList) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; goto __pyx_L1;}
  __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;
  *(void(**)(void))&__pyx_vtable_14_region_filter_RegionAndList.__pyx_base.__pyx_base._inside = (void(*)(void))__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 = 347; goto __pyx_L1;}
  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 = 347; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "RegionAndList", (PyObject *)&__pyx_type_14_region_filter_RegionAndList) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; goto __pyx_L1;}
  __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;
  *(void(**)(void))&__pyx_vtable_14_region_filter_Transform.__pyx_base._inside = (void(*)(void))__pyx_f_14_region_filter_9Transform__inside;
  *(void(**)(void))&__pyx_vtable_14_region_filter_Transform._transform = (void(*)(void))__pyx_f_14_region_filter_9Transform__transform;
  __pyx_type_14_region_filter_Transform.tp_base = __pyx_ptype_14_region_filter_RegionBase;
  __pyx_type_14_region_filter_Transform.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_14_region_filter_Transform) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}
  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 = 483; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Transform", (PyObject *)&__pyx_type_14_region_filter_Transform) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; goto __pyx_L1;}
  __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;
  *(void(**)(void))&__pyx_vtable_14_region_filter_Rotated.__pyx_base._transform = (void(*)(void))__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 = 520; goto __pyx_L1;}
  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 = 520; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Rotated", (PyObject *)&__pyx_type_14_region_filter_Rotated) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; goto __pyx_L1;}
  __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;
  *(void(**)(void))&__pyx_vtable_14_region_filter_Translated.__pyx_base._transform = (void(*)(void))__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 = 567; goto __pyx_L1;}
  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 = 567; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Translated", (PyObject *)&__pyx_type_14_region_filter_Translated) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; goto __pyx_L1;}
  __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;
  *(void(**)(void))&__pyx_vtable_14_region_filter_Circle.__pyx_base._inside = (void(*)(void))__pyx_f_14_region_filter_6Circle__inside;
  *(void(**)(void))&__pyx_vtable_14_region_filter_Circle._set_v = (void(*)(void))__pyx_f_14_region_filter_6Circle__set_v;
  *(void(**)(void))&__pyx_vtable_14_region_filter_Circle._get_v = (void(*)(void))__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 = 597; goto __pyx_L1;}
  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 = 597; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Circle", (PyObject *)&__pyx_type_14_region_filter_Circle) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; goto __pyx_L1;}
  __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;
  *(void(**)(void))&__pyx_vtable_14_region_filter_Ellipse.__pyx_base._inside = (void(*)(void))__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 = 643; goto __pyx_L1;}
  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 = 643; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Ellipse", (PyObject *)&__pyx_type_14_region_filter_Ellipse) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; goto __pyx_L1;}
  __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;
  *(void(**)(void))&__pyx_vtable_14_region_filter_Box.__pyx_base._inside = (void(*)(void))__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 = 691; goto __pyx_L1;}
  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 = 691; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Box", (PyObject *)&__pyx_type_14_region_filter_Box) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; goto __pyx_L1;}
  __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;
  *(void(**)(void))&__pyx_vtable_14_region_filter_Polygon.__pyx_base._inside = (void(*)(void))__pyx_f_14_region_filter_7Polygon__inside;
  __pyx_type_14_region_filter_Polygon.tp_base = __pyx_ptype_14_region_filter_RegionBase;
  __pyx_type_14_region_filter_Polygon.tp_free = _PyObject_GC_Del;
  if (PyType_Ready(&__pyx_type_14_region_filter_Polygon) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; goto __pyx_L1;}
  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 = 726; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "Polygon", (PyObject *)&__pyx_type_14_region_filter_Polygon) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 726; goto __pyx_L1;}
  __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;
  *(void(**)(void))&__pyx_vtable_14_region_filter_AngleRange.__pyx_base._inside = (void(*)(void))__pyx_f_14_region_filter_10AngleRange__inside;
  __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 = 804; goto __pyx_L1;}
  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 = 804; goto __pyx_L1;}
  if (PyObject_SetAttrString(__pyx_m, "AngleRange", (PyObject *)&__pyx_type_14_region_filter_AngleRange) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 804; goto __pyx_L1;}
  __pyx_ptype_14_region_filter_AngleRange = &__pyx_type_14_region_filter_AngleRange;
  __pyx_ptype_7c_numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr)); if (!__pyx_ptype_7c_numpy_dtype) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 78; goto __pyx_L1;}
  __pyx_ptype_7c_numpy_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject)); if (!__pyx_ptype_7c_numpy_ndarray) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 83; goto __pyx_L1;}
  __pyx_ptype_7c_numpy_flatiter = __Pyx_ImportType("numpy", "flatiter", sizeof(PyArrayIterObject)); if (!__pyx_ptype_7c_numpy_flatiter) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 92; goto __pyx_L1;}
  __pyx_ptype_7c_numpy_broadcast = __Pyx_ImportType("numpy", "broadcast", sizeof(PyArrayMultiIterObject)); if (!__pyx_ptype_7c_numpy_broadcast) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 98; goto __pyx_L1;}

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":26 */
  import_array();

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":31 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;}
  Py_INCREF(PyExc_Exception);
  PyTuple_SET_ITEM(__pyx_2, 0, PyExc_Exception);
  __pyx_3 = __Pyx_CreateClass(__pyx_2, __pyx_1, __pyx_n_NotYetImplemented, "_region_filter"); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_NotYetImplemented, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":82 */
  __pyx_2 = PyObject_CallObject(((PyObject *)__pyx_ptype_14_region_filter_RegionContext), 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; goto __pyx_L1;}
  Py_DECREF(((PyObject *)__pyx_v_14_region_filter_metric_wcs));
  __pyx_v_14_region_filter_metric_wcs = ((struct __pyx_obj_14_region_filter_RegionContext *)__pyx_2);
  __pyx_2 = 0;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":83 */
  __pyx_3 = ((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 (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":87 */
  __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;}
  __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;}
  Py_INCREF(PyExc_Exception);
  PyTuple_SET_ITEM(__pyx_2, 0, PyExc_Exception);
  __pyx_3 = __Pyx_CreateClass(__pyx_2, __pyx_1, __pyx_n_BaseClassInitException, "_region_filter"); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;}
  Py_DECREF(__pyx_2); __pyx_2 = 0;
  if (PyObject_SetAttr(__pyx_m, __pyx_n_BaseClassInitException, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; goto __pyx_L1;}
  Py_DECREF(__pyx_3); __pyx_3 = 0;
  Py_DECREF(__pyx_1); __pyx_1 = 0;

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":622 */
  Py_INCREF(Py_None);
  __pyx_d1 = ((struct __pyx_obj_14_region_filter_RegionContext *)Py_None);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":660 */
  Py_INCREF(Py_None);
  __pyx_d2 = ((struct __pyx_obj_14_region_filter_RegionContext *)Py_None);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":704 */
  Py_INCREF(Py_None);
  __pyx_d3 = ((struct __pyx_obj_14_region_filter_RegionContext *)Py_None);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":744 */
  Py_INCREF(Py_None);
  __pyx_d4 = ((struct __pyx_obj_14_region_filter_RegionContext *)Py_None);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":820 */
  Py_INCREF(Py_None);
  __pyx_d5 = ((struct __pyx_obj_14_region_filter_RegionContext *)Py_None);

  /* "/Users/jjlee/local/git/pyregion/src/_region_filter.pyx":854 */
  return;
  __pyx_L1:;
  Py_XDECREF(__pyx_1);
  Py_XDECREF(__pyx_2);
  Py_XDECREF(__pyx_3);
  __Pyx_AddTraceback("_region_filter");
}

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

/* Runtime support code */

static void __pyx_init_filenames(void) {
  __pyx_f = __pyx_filenames;
}

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_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 {
                PyErr_SetString(PyExc_TypeError,
                    "raise: exception must be an old-style class or instance");
                goto raise_error;
            }
        #else
            type = (PyObject*) type->ob_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
    }
    PyErr_Restore(type, value, tb);
    return;
raise_error:
    Py_XDECREF(value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
    return;
}

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

static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
    if (!type) {
        PyErr_Format(PyExc_SystemError, "Missing type object");
        return 0;
    }
    if (obj == Py_None || PyObject_TypeCheck(obj, type))
        return 1;
    PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s",
        obj->ob_type->tp_name, type->tp_name);
    return 0;
}

static int __Pyx_GetStarArgs(
    PyObject **args, 
    PyObject **kwds,
    char *kwd_list[], 
    Py_ssize_t nargs,
    PyObject **args2, 
    PyObject **kwds2,
    char rqd_kwds[])
{
    PyObject *x = 0, *args1 = 0, *kwds1 = 0;
    int i;
    char **p;
    
    if (args2)
        *args2 = 0;
    if (kwds2)
        *kwds2 = 0;
    
    if (args2) {
        args1 = PyTuple_GetSlice(*args, 0, nargs);
        if (!args1)
            goto bad;
        *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_GET_SIZE(*args));
        if (!*args2)
            goto bad;
    }
    else if (PyTuple_GET_SIZE(*args) > nargs) {
        int m = nargs;
        int n = PyTuple_GET_SIZE(*args);
        PyErr_Format(PyExc_TypeError,
            "function takes at most %d positional arguments (%d given)",
                m, n);
        goto bad;
    }
    else {
        args1 = *args;
        Py_INCREF(args1);
    }
    
    if (rqd_kwds && !*kwds)
            for (i = 0, p = kwd_list; *p; i++, p++)
                if (rqd_kwds[i])
                    goto missing_kwarg;
    
    if (kwds2) {
        if (*kwds) {
            kwds1 = PyDict_New();
            if (!kwds1)
                goto bad;
            *kwds2 = PyDict_Copy(*kwds);
            if (!*kwds2)
                goto bad;
            for (i = 0, p = kwd_list; *p; i++, p++) {
                x = PyDict_GetItemString(*kwds, *p);
                if (x) {
                    if (PyDict_SetItemString(kwds1, *p, x) < 0)
                        goto bad;
                    if (PyDict_DelItemString(*kwds2, *p) < 0)
                        goto bad;
                }
                else if (rqd_kwds && rqd_kwds[i])
                    goto missing_kwarg;
            }
        }
        else {
            *kwds2 = PyDict_New();
            if (!*kwds2)
                goto bad;
        }
    }
    else {
        kwds1 = *kwds;
        Py_XINCREF(kwds1);
        if (rqd_kwds && *kwds)
            for (i = 0, p = kwd_list; *p; i++, p++)
                if (rqd_kwds[i] && !PyDict_GetItemString(*kwds, *p))
                        goto missing_kwarg;
    }
    
    *args = args1;
    *kwds = kwds1;
    return 0;
missing_kwarg:
    PyErr_Format(PyExc_TypeError,
        "required keyword argument '%s' is missing", *p);
bad:
    Py_XDECREF(args1);
    Py_XDECREF(kwds1);
    if (args2) {
        Py_XDECREF(*args2);
    }
    if (kwds2) {
        Py_XDECREF(*kwds2);
    }
    return -1;
}

static PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i) {
    PyTypeObject *t = o->ob_type;
    PyObject *r;
    if (t->tp_as_sequence && t->tp_as_sequence->sq_item)
        r = PySequence_GetItem(o, i);
    else {
        PyObject *j = PyInt_FromLong(i);
        if (!j)
            return 0;
        r = PyObject_GetItem(o, j);
        Py_DECREF(j);
    }
    return r;
}

static int __Pyx_SetItemInt(PyObject *o, Py_ssize_t i, PyObject *v) {
    PyTypeObject *t = o->ob_type;
    int r;
    if (t->tp_as_sequence && t->tp_as_sequence->sq_item)
        r = PySequence_SetItem(o, i, v);
    else {
        PyObject *j = PyInt_FromLong(i);
        if (!j)
            return -1;
        r = PyObject_SetItem(o, j, v);
        Py_DECREF(j);
    }
    return r;
}

static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
    while (t->p) {
        *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
        if (!*t->p)
            return -1;
        if (t->i)
            PyString_InternInPlace(t->p);
        ++t;
    }
    return 0;
}

static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
    PyObject *pycobj = 0;
    int result;
    
    pycobj = PyCObject_FromVoidPtr(vtable, 0);
    if (!pycobj)
        goto bad;
    if (PyDict_SetItemString(dict, "__pyx_vtable__", pycobj) < 0)
        goto bad;
    result = 0;
    goto done;

bad:
    result = -1;
done:
    Py_XDECREF(pycobj);
    return result;
}

#ifndef __PYX_HAVE_RT_ImportType
#define __PYX_HAVE_RT_ImportType
static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, 
    long size) 
{
    PyObject *py_module = 0;
    PyObject *result = 0;
    
    py_module = __Pyx_ImportModule(module_name);
    if (!py_module)
        goto bad;
    result = PyObject_GetAttrString(py_module, class_name);
    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 (((PyTypeObject *)result)->tp_basicsize != size) {
        PyErr_Format(PyExc_ValueError, 
            "%s.%s does not appear to be the correct type object",
            module_name, class_name);
        goto bad;
    }
    return (PyTypeObject *)result;
bad:
    Py_XDECREF(result);
    return 0;
}
#endif

#ifndef __PYX_HAVE_RT_ImportModule
#define __PYX_HAVE_RT_ImportModule
static PyObject *__Pyx_ImportModule(char *name) {
    PyObject *py_name = 0;
    
    py_name = PyString_FromString(name);
    if (!py_name)
        goto bad;
    return PyImport_Import(py_name);
bad:
    Py_XDECREF(py_name);
    return 0;
}
#endif

static PyObject *__Pyx_CreateClass(
    PyObject *bases, PyObject *dict, PyObject *name, char *modname)
{
    PyObject *py_modname;
    PyObject *result = 0;
    
    py_modname = PyString_FromString(modname);
    if (!py_modname)
        goto bad;
    if (PyDict_SetItemString(dict, "__module__", py_modname) < 0)
        goto bad;
    result = PyClass_New(bases, dict, name);
bad:
    Py_XDECREF(py_modname);
    return result;
}

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

static void __Pyx_AddTraceback(char *funcname) {
    PyObject *py_srcfile = 0;
    PyObject *py_funcname = 0;
    PyObject *py_globals = 0;
    PyObject *empty_tuple = 0;
    PyObject *empty_string = 0;
    PyCodeObject *py_code = 0;
    PyFrameObject *py_frame = 0;
    
    py_srcfile = PyString_FromString(__pyx_filename);
    if (!py_srcfile) goto bad;
    py_funcname = PyString_FromString(funcname);
    if (!py_funcname) goto bad;
    py_globals = PyModule_GetDict(__pyx_m);
    if (!py_globals) goto bad;
    empty_tuple = PyTuple_New(0);
    if (!empty_tuple) goto bad;
    empty_string = PyString_FromString("");
    if (!empty_string) goto bad;
    py_code = PyCode_New(
        0,            /*int argcount,*/
        0,            /*int nlocals,*/
        0,            /*int stacksize,*/
        0,            /*int flags,*/
        empty_string, /*PyObject *code,*/
        empty_tuple,  /*PyObject *consts,*/
        empty_tuple,  /*PyObject *names,*/
        empty_tuple,  /*PyObject *varnames,*/
        empty_tuple,  /*PyObject *freevars,*/
        empty_tuple,  /*PyObject *cellvars,*/
        py_srcfile,   /*PyObject *filename,*/
        py_funcname,  /*PyObject *name,*/
        __pyx_lineno,   /*int firstlineno,*/
        empty_string  /*PyObject *lnotab*/
    );
    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);
bad:
    Py_XDECREF(py_srcfile);
    Py_XDECREF(py_funcname);
    Py_XDECREF(empty_tuple);
    Py_XDECREF(empty_string);
    Py_XDECREF(py_code);
    Py_XDECREF(py_frame);
}
