Skip to content
This repository was archived by the owner on Dec 30, 2023. It is now read-only.

Commit b12f641

Browse files
committed
some more type-safety and exception handling in pcl_defs.pxd
XXX the at() members of PointCloud[T] can also throw: >>> a = np.random.randn(10000, 3).astype(np.float32) >>> p = PointCloud() >>> p.from_array(a) >>> p[10000] terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check Aborted ... but a bug in Cython's code generator prevents "except+" from working with a function returning a reference.
1 parent 3832971 commit b12f641

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pcl_defs.pxd

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from libc.stddef cimport size_t
2+
13
from libcpp.vector cimport vector
24
from libcpp.string cimport string
35
from libcpp cimport bool
@@ -7,15 +9,15 @@ from vector cimport vector as vector2
79

810
cdef extern from "pcl/point_cloud.h" namespace "pcl":
911
cdef cppclass PointCloud[T]:
10-
PointCloud()
11-
PointCloud(int, int)
12+
PointCloud() except +
13+
PointCloud(unsigned int, unsigned int) except +
1214
unsigned int width
1315
unsigned int height
1416
bool is_dense
15-
void resize(int)
16-
int size()
17-
T& operator[](int)
18-
T& at(int)
17+
void resize(size_t) except +
18+
size_t size()
19+
T& operator[](size_t)
20+
T& at(size_t)
1921
T& at(int, int)
2022
shared_ptr[PointCloud[T]] makeShared()
2123

@@ -200,4 +202,3 @@ cdef extern from "pcl/kdtree/kdtree_flann.h" namespace "pcl":
200202
int, int, vector[int], vector[float])
201203

202204
ctypedef KdTreeFLANN[PointXYZ] KdTreeFLANN_t
203-

0 commit comments

Comments
 (0)