@@ -174,7 +174,7 @@ cdef class PointCloud:
174174
175175 cdef cpp.PointXYZ * p
176176 for i in range (npts):
177- p = & self .thisptr.at( i)
177+ p = cpp.getptr( self .thisptr, i)
178178 p.x, p.y, p.z = arr[i, 0 ], arr[i, 1 ], arr[i, 2 ]
179179
180180 @ cython.boundscheck (False )
@@ -190,7 +190,7 @@ cdef class PointCloud:
190190 result = np.empty((n, 3 ), dtype = np.float32)
191191
192192 for i in range (n):
193- p = & self .thisptr.at( i)
193+ p = cpp.getptr( self .thisptr, i)
194194 result[i, 0 ] = p.x
195195 result[i, 1 ] = p.y
196196 result[i, 2 ] = p.z
@@ -206,8 +206,8 @@ cdef class PointCloud:
206206 self .resize(npts)
207207 self .thisptr.width = npts
208208 self .thisptr.height = 1
209- for i,l in enumerate (_list):
210- p = & self .thisptr.at( i)
209+ for i, l in enumerate (_list):
210+ p = cpp.getptr( self .thisptr, i)
211211 p.x, p.y, p.z = l
212212
213213 def to_list (self ):
@@ -223,11 +223,11 @@ cdef class PointCloud:
223223 """
224224 Return a point (3-tuple) at the given row/column
225225 """
226- cdef cpp.PointXYZ * p = & self .thisptr.at( row, col)
226+ cdef cpp.PointXYZ * p = cpp.getptr_at( self .thisptr, row, col)
227227 return p.x, p.y, p.z
228228
229229 def __getitem__ (self , cnp.npy_intp idx ):
230- cdef cpp.PointXYZ * p = & self .thisptr.at( idx)
230+ cdef cpp.PointXYZ * p = cpp.getptr_at( self .thisptr, idx)
231231 return p.x, p.y, p.z
232232
233233 def from_file (self , char *f ):
@@ -566,15 +566,21 @@ cdef class OctreePointCloud:
566566 Octree pointcloud
567567 """
568568 cdef cpp.OctreePointCloud_t * me
569-
569+
570570 def __cinit__ (self , double resolution ):
571+ self .me = NULL
572+ if resolution <= 0. :
573+ raise ValueError (" Expected resolution > 0., got %r " % resolution)
574+
575+ def __init__ (self , double resolution ):
571576 """
572577 Constructs octree pointcloud with given resolution at lowest octree level
573578 """
574579 self .me = new cpp.OctreePointCloud_t(resolution)
575-
580+
576581 def __dealloc__ (self ):
577582 del self .me
583+ self .me = NULL # just to be sure
578584
579585 def set_input_cloud (self , PointCloud pc ):
580586 """
@@ -637,9 +643,6 @@ cdef class OctreePointCloudSearch(OctreePointCloud):
637643 """
638644 self .me = < cpp.OctreePointCloud_t* > new cpp.OctreePointCloudSearch_t(resolution)
639645
640- def __dealloc__ (self ):
641- del self .me
642-
643646 def radius_search (self , point , double radius , unsigned int max_nn = 0 ):
644647 """
645648 Search for all neighbors of query point that are within a given radius.
0 commit comments