-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathKdTree.lua
95 lines (78 loc) · 2.39 KB
/
KdTree.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
local ffi = require 'ffi'
local torch = require 'torch'
local utils = require 'pcl.utils'
local pcl = require 'pcl.PointTypes'
local KdTree = torch.class('pcl.KdTree', pcl)
local func_by_type = {}
local function init()
local KdTreeFLANN_method_names = {
'new',
'clone',
'delete',
'setInputCloud',
'getEpsilon',
'setEpsilon',
'setMinPts',
'getMinPts',
'setSortedResults',
'assign',
'nearestKSearch',
'radiusSearch'
}
for k,v in pairs(utils.type_key_map) do
func_by_type[k] = utils.create_typed_methods("pcl_KdTreeFLANN_TYPE_KEY_", KdTreeFLANN_method_names, v)
end
func_by_type[pcl.FPFHSignature33] = utils.create_typed_methods("pcl_KdTreeFLANN_TYPE_KEY_", KdTreeFLANN_method_names, 'FPFHSignature33')
func_by_type[pcl.VFHSignature308] = utils.create_typed_methods("pcl_KdTreeFLANN_TYPE_KEY_", KdTreeFLANN_method_names, 'VFHSignature308')
end
init()
function KdTree:__init(pointType, sorted)
if type(pointType) == 'boolean' then
sorted = pointType
pointType = pcl.PointXYZ
end
sorted = sorted or true
pointType = pcl.pointType(pointType)
rawset(self, 'f', func_by_type[pointType])
self.pointType = pointType
if type(sorted) == 'boolean' then
self.o = self.f.new(sorted)
elseif type(sorted) == 'cdata' then
self.o = sorted
end
end
function KdTree:cdata()
return self.o
end
function KdTree:clone()
local clone = self.f.clone(self.o)
return KdTree.new(self.pointType, clone)
end
function KdTree:setInputCloud(cloud, indices)
self.f.setInputCloud(self.o, cloud:cdata(), utils.cdata(indices))
end
function KdTree:getEpsilon()
return self.f.getEpsilon(self.o)
end
function KdTree:setEpsilon(eps)
self.f.setEpsilon(self.o, eps)
end
function KdTree:setMinPts(value)
self.f.setMinPts(self.o, value)
end
function KdTree:getMinPts()
return self.f.getMinPts(self.o)
end
function KdTree:setSortedResults(sorted)
self.f.setSortedResults(self.o, sorted)
end
function KdTree:set(other)
self.f.assign(self.o, other:cdata())
return self
end
function KdTree:nearestKSearch(point, k, indices, squaredDistances)
return self.f.nearestKSearch(self.o, point, k, utils.cdata(indices), utils.cdata(squaredDistances))
end
function KdTree:radiusSearch(point, radius, indices, squaredDistances, max_nn)
return self.f.radiusSearch(self.o, point, radius, utils.cdata(indices), utils.cdata(squaredDistances), max_nn or 0)
end