@@ -73,9 +73,10 @@ static inline void flush() { std::cout << std::endl; };
7373 * @return the geometric features associated with each point's neighborhood in a (num_points, features_count) nd::array.
7474 */
7575template <typename real_t = float , const size_t feature_count = 11 >
76- static nb::ndarray<nb::numpy, real_t , nb::shape<nb::any, feature_count>> compute_geometric_features (
77- RefCloud<real_t > xyz, nb::ndarray<const uint32_t , nb::ndim<1 >> nn, nb::ndarray<const uint32_t , nb::ndim<1 >> nn_ptr,
78- const size_t k_min, const bool verbose)
76+ static nb::ndarray<nb::numpy, real_t , nb::shape<-1 , static_cast <nb::ssize_t >(feature_count)>>
77+ compute_geometric_features (
78+ RefCloud<real_t > xyz, nb::ndarray<const uint32_t , nb::ndim<1 >> nn,
79+ nb::ndarray<const uint32_t , nb::ndim<1 >> nn_ptr, const size_t k_min, const bool verbose)
7980{
8081 if (k_min < 1 ) { throw std::invalid_argument (" k_min should be > 1" ); }
8182 // Each point can be treated in parallel
@@ -111,7 +112,8 @@ static nb::ndarray<nb::numpy, real_t, nb::shape<nb::any, feature_count>> compute
111112 // Final print to start on a new line
112113 if (verbose) log::flush ();
113114 const size_t shape[2 ] = {n_points, feature_count};
114- return nb::ndarray<nb::numpy, real_t , nb::shape<nb::any, feature_count>>(features, 2 , shape, owner_features);
115+ return nb::ndarray<nb::numpy, real_t , nb::shape<-1 , static_cast <nb::ssize_t >(feature_count)>>(
116+ features, 2 , shape, owner_features);
115117}
116118/* *
117119 * Convenience function that check that scales are well ordered in increasing order.
@@ -155,9 +157,10 @@ static bool check_scales(const std::vector<uint32_t>& k_scales)
155157 * nd::array
156158 */
157159template <typename real_t , const size_t feature_count = 11 >
158- static nb::ndarray<nb::numpy, real_t , nb::shape<nb::any, nb::any, feature_count>> compute_geometric_features_multiscale (
159- RefCloud<real_t > xyz, nb::ndarray<const uint32_t , nb::ndim<1 >> nn, nb::ndarray<const uint32_t , nb::ndim<1 >> nn_ptr,
160- const std::vector<uint32_t >& k_scales, const bool verbose)
160+ static nb::ndarray<nb::numpy, real_t , nb::shape<-1 , -1 , static_cast <nb::ssize_t >(feature_count)>>
161+ compute_geometric_features_multiscale (
162+ RefCloud<real_t > xyz, nb::ndarray<const uint32_t , nb::ndim<1 >> nn,
163+ nb::ndarray<const uint32_t , nb::ndim<1 >> nn_ptr, const std::vector<uint32_t >& k_scales, const bool verbose)
161164{
162165 if (!check_scales (k_scales))
163166 {
@@ -203,7 +206,7 @@ static nb::ndarray<nb::numpy, real_t, nb::shape<nb::any, nb::any, feature_count>
203206 if (verbose) log::flush ();
204207
205208 const size_t shape[3 ] = {n_points, n_scales, feature_count};
206- return nb::ndarray<nb::numpy, real_t , nb::shape<nb::any, nb::any, feature_count>>(
209+ return nb::ndarray<nb::numpy, real_t , nb::shape<- 1 , - 1 , static_cast < nb::ssize_t >( feature_count) >>(
207210 features, 3 , shape, owner_features);
208211}
209212
@@ -238,9 +241,11 @@ static nb::ndarray<nb::numpy, real_t, nb::shape<nb::any, nb::any, feature_count>
238241 * @return Geometric features associated with each point's neighborhood in a (num_points, features_count) nd::array
239242 */
240243template <typename real_t , const size_t feature_count = 12 >
241- static nb::ndarray<nb::numpy, real_t , nb::shape<nb::any, feature_count>> compute_geometric_features_optimal (
242- RefCloud<real_t > xyz, nb::ndarray<const uint32_t , nb::ndim<1 >> nn, nb::ndarray<const uint32_t , nb::ndim<1 >> nn_ptr,
243- const uint32_t k_min, const uint32_t k_step, const uint32_t k_min_search, const bool verbose)
244+ static nb::ndarray<nb::numpy, real_t , nb::shape<-1 , static_cast <nb::ssize_t >(feature_count)>>
245+ compute_geometric_features_optimal (
246+ RefCloud<real_t > xyz, nb::ndarray<const uint32_t , nb::ndim<1 >> nn,
247+ nb::ndarray<const uint32_t , nb::ndim<1 >> nn_ptr, const uint32_t k_min, const uint32_t k_step,
248+ const uint32_t k_min_search, const bool verbose)
244249{
245250 if (k_min < 1 && k_min_search < 1 ) { throw std::invalid_argument (" k_min and k_min_search should be > 1" ); }
246251 // Each point can be treated in parallel
@@ -300,7 +305,8 @@ static nb::ndarray<nb::numpy, real_t, nb::shape<nb::any, feature_count>> compute
300305 if (verbose) log::flush ();
301306
302307 const size_t shape[2 ] = {n_points, feature_count};
303- return nb::ndarray<nb::numpy, real_t , nb::shape<nb::any, feature_count>>(features, 2 , shape, owner_features);
308+ return nb::ndarray<nb::numpy, real_t , nb::shape<-1 , static_cast <nb::ssize_t >(feature_count)>>(
309+ features, 2 , shape, owner_features);
304310}
305311
306312/* *
@@ -317,14 +323,14 @@ static nb::ndarray<nb::numpy, real_t, nb::shape<nb::any, feature_count>> compute
317323 * @return Geometric features associated with each point's neighborhood in a (num_points, features_count) nd::array
318324 */
319325template <typename real_t >
320- static nb::ndarray<nb::numpy, real_t , nb::shape<nb::any, nb::any >> compute_geometric_features_selected (
326+ static nb::ndarray<nb::numpy, real_t , nb::shape<- 1 , - 1 >> compute_geometric_features_selected (
321327 RefCloud<real_t > xyz, const real_t search_radius, const uint32_t max_knn,
322328 const std::vector<EFeatureID>& selected_features)
323329{
324330 using kd_tree_t = nanoflann::KDTreeEigenMatrixAdaptor<RefCloud<real_t >, 3 , nanoflann::metric_L2_Simple>;
325331 // TODO: where knn < num of points
326332
327- kd_tree_t kd_tree (3 , xyz, 10 );
333+ kd_tree_t kd_tree (3 , xyz, 10 , 0 );
328334 const size_t feature_count = selected_features.size ();
329335 const Eigen::Index n_points = xyz.rows ();
330336 real_t sq_search_radius = search_radius * search_radius;
@@ -364,6 +370,7 @@ static nb::ndarray<nb::numpy, real_t, nb::shape<nb::any, nb::any>> compute_geome
364370 });
365371 executor.run (taskflow).get ();
366372
367- return nb::ndarray<nb::numpy, real_t , nb::shape<nb::any, nb::any>>(features, {static_cast <size_t >(n_points), feature_count}, owner_features);
373+ return nb::ndarray<nb::numpy, real_t , nb::shape<-1 , -1 >>(
374+ features, {static_cast <size_t >(n_points), feature_count}, owner_features);
368375}
369376} // namespace pgeof
0 commit comments