1818
1919#include " path_converters.h"
2020#include " _backend_agg_basic_types.h"
21+ #include " numpy_cpp.h"
2122
2223struct XY
2324{
@@ -112,7 +113,7 @@ void point_in_path_impl(PointArray &points, PathIterator &path, ResultArray &ins
112113 sy = vty0 = vty1 = y;
113114
114115 for (i = 0 ; i < n; ++i) {
115- ty = points[i][ 1 ] ;
116+ ty = points (i, 1 ) ;
116117
117118 if (std::isfinite (ty)) {
118119 // get test bit for above/below X axis
@@ -135,8 +136,8 @@ void point_in_path_impl(PointArray &points, PathIterator &path, ResultArray &ins
135136 }
136137
137138 for (i = 0 ; i < n; ++i) {
138- tx = points[i][ 0 ] ;
139- ty = points[i][ 1 ] ;
139+ tx = points (i, 0 ) ;
140+ ty = points (i, 1 ) ;
140141
141142 if (!(std::isfinite (tx) && std::isfinite (ty))) {
142143 continue ;
@@ -183,8 +184,8 @@ void point_in_path_impl(PointArray &points, PathIterator &path, ResultArray &ins
183184
184185 all_done = true ;
185186 for (i = 0 ; i < n; ++i) {
186- tx = points[i][ 0 ] ;
187- ty = points[i][ 1 ] ;
187+ tx = points (i, 0 ) ;
188+ ty = points (i, 1 ) ;
188189
189190 if (!(std::isfinite (tx) && std::isfinite (ty))) {
190191 continue ;
@@ -242,11 +243,10 @@ template <class PathIterator>
242243inline bool point_in_path (
243244 double x, double y, const double r, PathIterator &path, agg::trans_affine &trans)
244245{
245- std::vector<double > point;
246- std::vector<std::vector<double > > points;
247- point.push_back (x);
248- point.push_back (y);
249- points.push_back (point);
246+ npy_intp shape[] = {1 , 2 };
247+ numpy::array_view<double , 2 > points (shape);
248+ points (0 , 0 ) = x;
249+ points (0 , 1 ) = y;
250250
251251 int result[1 ];
252252 result[0 ] = 0 ;
@@ -285,11 +285,10 @@ template <class PathIterator>
285285inline bool point_on_path (
286286 double x, double y, const double r, PathIterator &path, agg::trans_affine &trans)
287287{
288- std::vector<double > point;
289- std::vector<std::vector<double > > points;
290- point.push_back (x);
291- point.push_back (y);
292- points.push_back (point);
288+ npy_intp shape[] = {1 , 2 };
289+ numpy::array_view<double , 2 > points (shape);
290+ points (0 , 0 ) = x;
291+ points (0 , 1 ) = y;
293292
294293 int result[1 ];
295294 result[0 ] = 0 ;
0 commit comments