@@ -1530,18 +1530,41 @@ PyObject *_affine_transform(PyObject *self, PyObject *_args)
15301530// _path_module::count_bboxes_overlapping_bbox(const Py::Tuple& args)
15311531PyObject *_count_bboxes_overlapping_bbox (PyObject *self, PyObject *_args)
15321532{
1533+ PyObject *_bbox, *_bboxes;
1534+ if (!PyArg_ParseTuple (_args, " OO" , &_bbox, &_bboxes)) {
1535+ return NULL ;
1536+ }
1537+
1538+ double ax0, ay0, ax1, ay1;
1539+ if (!py_convert_bbox (_bbox, ax0, ay0, ax1, ay1))
1540+ {
1541+ PyErr_SetString (PyExc_ValueError,
1542+ " First argument to count_bboxes_overlapping_bbox must be a Bbox object." );
1543+ return NULL ;
1544+ }
1545+
1546+ PyObject* __bboxes = PySequence_Fast (_bboxes, " bboxes must be a sequence" );
1547+ if (__bboxes == NULL )
1548+ {
1549+ return NULL ;
1550+ }
1551+ PyObject** bboxes = PySequence_Fast_ITEMS (__bboxes);
1552+ size_t num_bboxes = PySequence_Fast_GET_SIZE (__bboxes);
1553+
1554+ /*
15331555 const Py::Tuple args(_args);
15341556 args.verify_length(2);
15351557
15361558 Py::Object bbox = args[0];
15371559 Py::SeqBase<Py::Object> bboxes = args[1];
1538-
1539- double ax0, ay0, ax1, ay1;
1560+ */
15401561 double bx0, by0, bx1, by1;
15411562 long count = 0 ;
15421563
1564+ /*
15431565 if (py_convert_bbox(bbox.ptr(), ax0, ay0, ax1, ay1))
15441566 {
1567+ */
15451568 if (ax1 < ax0)
15461569 {
15471570 std::swap (ax0, ax1);
@@ -1551,11 +1574,12 @@ PyObject *_count_bboxes_overlapping_bbox(PyObject *self, PyObject *_args)
15511574 std::swap (ay0, ay1);
15521575 }
15531576
1554- size_t num_bboxes = bboxes.size ();
1577+ // size_t num_bboxes = bboxes.size();
15551578 for (size_t i = 0 ; i < num_bboxes; ++i)
15561579 {
1557- Py::Object bbox_b = bboxes[i];
1558- if (py_convert_bbox (bbox_b.ptr (), bx0, by0, bx1, by1))
1580+ if (py_convert_bbox (bboxes[i], bx0, by0, bx1, by1))
1581+ // Py::Object bbox_b = bboxes[i];
1582+ // if (py_convert_bbox(bbox_b.ptr(), bx0, by0, bx1, by1))
15591583 {
15601584 if (bx1 < bx0)
15611585 {
@@ -1575,14 +1599,20 @@ PyObject *_count_bboxes_overlapping_bbox(PyObject *self, PyObject *_args)
15751599 }
15761600 else
15771601 {
1578- throw Py::ValueError (" Non-bbox object in bboxes list" );
1602+ PyErr_SetString (PyExc_ValueError, " Non-bbox object in bboxes list" );
1603+ Py_DECREF (__bboxes);
1604+ return NULL ;
1605+ // throw Py::ValueError("Non-bbox object in bboxes list");
15791606 }
15801607 }
1608+ /*
15811609 }
15821610 else
15831611 {
15841612 throw Py::ValueError("First argument to count_bboxes_overlapping_bbox must be a Bbox object.");
15851613 }
1614+ */
1615+ Py_DECREF (__bboxes);
15861616
15871617 // return Py::Int(count);
15881618 return PyInt_FromLong (count);
0 commit comments