-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCorrespondences.lua
121 lines (100 loc) · 2.38 KB
/
Correspondences.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
local ffi = require 'ffi'
local torch = require 'torch'
local utils = require 'pcl.utils'
local pcl = require 'pcl.PointTypes'
local Correspondences = torch.class('pcl.Correspondences', pcl)
local methods = {}
local function init()
local Correspondences_method_names = {
'new',
'clone',
'delete',
'size',
'getAt',
'setAt',
'push_back',
'pop_back',
'clear',
'insert',
'erase',
'empty'
}
-- use utility function to automatically register new/clone results for GC delete
methods = utils.create_typed_methods("pcl_Correspondences_", Correspondences_method_names, '')
end
init()
function Correspondences:__init()
rawset(self, 'f', methods)
rawset(self, 'o', self.f.new())
end
function Correspondences:cdata()
return self.o
end
function Correspondences:clone()
return self.f.clone(self.o)
end
function Correspondences:size()
return self.f.size(self.o)
end
function Correspondences:__len()
return self:size()
end
function Correspondences:__index(idx)
local v = rawget(self, idx)
if not v then
v = Correspondences[idx]
if not v and type(idx) == 'number' then
local f, o = rawget(self, 'f'), rawget(self, 'o')
v = f.getAt(o, idx-1)
end
end
return v
end
function Correspondences:__newindex(idx, v)
local f, o = rawget(self, 'f'), rawget(self, 'o')
if type(idx) == 'number' then
f.setAt(o, idx-1, v)
else
rawset(self, idx, v)
end
end
function Correspondences:push_back(value)
self.f.push_back(self.o, value)
end
function Correspondences:pop_back()
return self.f.pop_back(self.o)
end
function Correspondences:clear()
self.f.clear(self.o)
end
function Correspondences:insert(pos, value)
self.f.insert(self.o, pos-1, value)
end
function Correspondences:erase(begin_pos, end_pos)
self.f.erase(self.o, begin_pos-1, (end_pos or begin_pos + 1)-1)
end
function Correspondences:empty()
return self.f.empty(self.o)
end
function Correspondences:__pairs()
return function (t, k)
local i = k or 1
if i > #t then
return nil
else
local v = t[i]
return i+1, v
end
end, self, nil
end
function Correspondences:__ipairs()
return self:__pairs()
end
function Correspondences:__tostring()
local t = {}
for i,v in ipairs(self) do
table.insert(t, tostring(v))
end
table.insert(t, string.format("[pcl.Correspondences of size %d]", #self))
return table.concat(t, '\n')
end