@@ -128,6 +128,7 @@ point_in_path_impl(const void* const points_, const size_t s0,
128128 npy_bool* const inside_flag)
129129{
130130 int *yflag0;
131+ int *subpath_flag;
131132 int yflag1;
132133 double vtx0, vty0, vtx1, vty1;
133134 double tx, ty;
@@ -138,6 +139,7 @@ point_in_path_impl(const void* const points_, const size_t s0,
138139 const char *const points = (const char * const )points_;
139140
140141 yflag0 = (int *)malloc (n * sizeof (int ));
142+ subpath_flag = (int *)malloc (n * sizeof (int ));
141143
142144 path.rewind (0 );
143145
@@ -151,6 +153,10 @@ point_in_path_impl(const void* const points_, const size_t s0,
151153 if (code != agg::path_cmd_move_to)
152154 {
153155 code = path.vertex (&x, &y);
156+ if (code == agg::path_cmd_stop ||
157+ (code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly) {
158+ continue ;
159+ }
154160 }
155161
156162 sx = vtx0 = vtx1 = x;
@@ -162,7 +168,7 @@ point_in_path_impl(const void* const points_, const size_t s0,
162168 // get test bit for above/below X axis
163169 yflag0[i] = (vty0 >= ty);
164170
165- inside_flag [i] = 0 ;
171+ subpath_flag [i] = 0 ;
166172 }
167173
168174 do
@@ -208,7 +214,7 @@ point_in_path_impl(const void* const points_, const size_t s0,
208214 // tests.
209215 if (((vty1 - ty) * (vtx0 - vtx1) >=
210216 (vtx1 - tx) * (vty0 - vty1)) == yflag1) {
211- inside_flag [i] ^= 1 ;
217+ subpath_flag [i] ^= 1 ;
212218 }
213219 }
214220
@@ -235,10 +241,10 @@ point_in_path_impl(const void* const points_, const size_t s0,
235241 if (yflag0[i] != yflag1) {
236242 if (((vty1 - ty) * (vtx0 - vtx1) >=
237243 (vtx1 - tx) * (vty0 - vty1)) == yflag1) {
238- inside_flag [i] ^= 1 ;
244+ subpath_flag [i] ^= 1 ;
239245 }
240246 }
241-
247+ inside_flag[i] |= subpath_flag[i];
242248 if (inside_flag[i] == 0 ) {
243249 all_done = 0 ;
244250 }
@@ -253,6 +259,7 @@ point_in_path_impl(const void* const points_, const size_t s0,
253259 exit:
254260
255261 free (yflag0);
262+ free (subpath_flag);
256263}
257264
258265inline void
@@ -699,7 +706,7 @@ _path_module::get_path_collection_extents(const Py::Tuple& args)
699706Py::Object
700707_path_module::point_in_path_collection (const Py::Tuple& args)
701708{
702- args.verify_length (9 );
709+ args.verify_length (10 );
703710
704711 // segments, trans, clipbox, colors, linewidths, antialiaseds
705712 double x = Py::Float (args[0 ]);
@@ -711,6 +718,9 @@ _path_module::point_in_path_collection(const Py::Tuple& args)
711718 Py::SeqBase<Py::Object> offsets_obj = args[6 ];
712719 agg::trans_affine offset_trans = py_to_agg_transformation_matrix (args[7 ].ptr ());
713720 bool filled = Py::Boolean (args[8 ]);
721+ std::string offset_position = Py::String (args[9 ]);
722+
723+ bool data_offsets = (offset_position == " data" );
714724
715725 PyArrayObject* offsets = (PyArrayObject*)PyArray_FromObject (
716726 offsets_obj.ptr (), PyArray_DOUBLE, 0 , 2 );
@@ -761,7 +771,11 @@ _path_module::point_in_path_collection(const Py::Tuple& args)
761771 double xo = *(double *)PyArray_GETPTR2 (offsets, i % Noffsets, 0 );
762772 double yo = *(double *)PyArray_GETPTR2 (offsets, i % Noffsets, 1 );
763773 offset_trans.transform (&xo, &yo);
764- trans *= agg::trans_affine_translation (xo, yo);
774+ if (data_offsets) {
775+ trans = agg::trans_affine_translation (xo, yo) * trans;
776+ } else {
777+ trans *= agg::trans_affine_translation (xo, yo);
778+ }
765779 }
766780
767781 if (filled)
0 commit comments