Skip to content

Commit 072342d

Browse files
committed
add create position/extent for multitag
1 parent cffca54 commit 072342d

File tree

5 files changed

+81
-1
lines changed

5 files changed

+81
-1
lines changed

+nix/MultiTag.m

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,16 @@
102102
retObj = nix.DataArray(handle);
103103
end;
104104
end;
105-
105+
106+
function [] = add_positions(obj, add_this)
107+
if(strcmp(class(add_this), 'nix.DataArray'))
108+
addID = add_this.id;
109+
else
110+
addID = add_this;
111+
end;
112+
nix_mx('MultiTag::addPositions', obj.nix_handle, addID);
113+
end;
114+
106115
% ------------------
107116
% Extents methods
108117
% ------------------
@@ -115,5 +124,14 @@
115124
end;
116125
end;
117126

127+
function [] = add_extents(obj, add_this)
128+
if(strcmp(class(add_this), 'nix.DataArray'))
129+
addID = add_this.id;
130+
else
131+
addID = add_this;
132+
end;
133+
nix_mx('MultiTag::addExtents', obj.nix_handle, addID);
134+
end;
135+
118136
end;
119137
end

nix_mx.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ void mexFunction(int nlhs,
178178
methods->add("MultiTag::addReference", nixmultitag::add_reference);
179179
methods->add("MultiTag::addSource", nixmultitag::add_source);
180180
methods->add("MultiTag::createFeature", nixmultitag::create_feature);
181+
methods->add("MultiTag::addPositions", nixmultitag::add_positions);
182+
methods->add("MultiTag::addExtents", nixmultitag::add_extents);
181183

182184
classdef<nix::Section>("Section", methods)
183185
.desc(&nixsection::describe)

src/nixmultitag.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,18 @@ namespace nixmultitag {
6464
output.set(0, data);
6565
}
6666

67+
void add_positions(const extractor &input, infusor &output)
68+
{
69+
nix::MultiTag currObj = input.entity<nix::MultiTag>(1);
70+
currObj.positions(input.str(2));
71+
}
72+
73+
void add_extents(const extractor &input, infusor &output)
74+
{
75+
nix::MultiTag currObj = input.entity<nix::MultiTag>(1);
76+
currObj.extents(input.str(2));
77+
}
78+
79+
void remove_extents(const extractor &input, infusor &output);
80+
6781
} // namespace nixmultitag

src/nixmultitag.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ namespace nixmultitag {
1717

1818
void retrieve_feature_data(const extractor &input, infusor &output);
1919

20+
void add_positions(const extractor &input, infusor &output);
21+
22+
void add_extents(const extractor &input, infusor &output);
23+
2024
} // namespace nixmultitag
2125

2226
#endif

tests/TestMultiTag.m

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
funcs{end+1} = @test_open_source;
1616
funcs{end+1} = @test_open_feature;
1717
funcs{end+1} = @test_open_reference;
18+
funcs{end+1} = @test_add_positions;
1819
funcs{end+1} = @test_has_positions;
1920
funcs{end+1} = @test_open_positions;
21+
funcs{end+1} = @test_add_extents;
2022
funcs{end+1} = @test_open_extents;
2123
funcs{end+1} = @test_open_metadata;
2224
funcs{end+1} = @test_retrieve_data;
@@ -244,6 +246,23 @@
244246
assert(isempty(getRef));
245247
end
246248

249+
%% Test: Add positions by entity and id
250+
function [] = test_add_positions ( varargin )
251+
test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);
252+
b = test_file.createBlock('positionsTest', 'nixBlock');
253+
tmp = b.create_data_array('positionsTestDataArray', 'nixDataArray', 'double', [1 2 3 4 5 6]);
254+
getMTag = b.create_multi_tag('positionstest', 'nixMultiTag', b.dataArrays{1});
255+
256+
tmp = b.create_data_array('positionsTest1', 'nixDataArray', 'double', [0 1]);
257+
tmp = b.create_data_array('positionsTest2', 'nixDataArray', 'double', [2 4]);
258+
259+
getMTag.add_positions(b.dataArrays{2}.id);
260+
assert(strcmp(getMTag.open_positions.name, 'positionsTest1'));
261+
262+
getMTag.add_positions(b.dataArrays{3});
263+
assert(strcmp(getMTag.open_positions.name, 'positionsTest2'));
264+
end
265+
247266
%% Test: Has positions
248267
function [] = test_has_positions( varargin )
249268
test_file = nix.File(fullfile(pwd, 'tests', 'test.h5'), nix.FileMode.ReadOnly);
@@ -272,6 +291,29 @@
272291
assert(~isempty(getMultiTag.open_positions));
273292
end
274293

294+
%% Test: Add extents by entity and id
295+
function [] = test_add_extents ( varargin )
296+
test_file = nix.File(fullfile(pwd, 'tests', 'testRW.h5'), nix.FileMode.Overwrite);
297+
b = test_file.createBlock('extentsTest', 'nixBlock');
298+
% tmp = b.create_data_array('extentsTestDataArray', 'nixDataArray', 'double', [1 2 3 4 5 6; 1 2 3 4 5 6]);
299+
% getMTag = b.create_multi_tag('extentstest', 'nixMultiTag', b.dataArrays{1});
300+
301+
% tmp = b.create_data_array('positionsTest1', 'nixDataArray', 'double', [1, 1]);
302+
% tmp = b.create_data_array('positionsTest2', 'nixDataArray', 'double', [1, 3]);
303+
304+
% tmp = b.create_data_array('extentsTest1', 'nixDataArray', 'double', [1, 1]);
305+
% tmp = b.create_data_array('extentsTest2', 'nixDataArray', 'double', [1, 1]);
306+
307+
% getMTag.add_positions(b.dataArrays{2});
308+
% getMTag.add_extents(b.dataArrays{4}.id);
309+
% assert(strcmp(getMTag.open_extents.name, 'extentsTest1'));
310+
311+
% getMTag.add_positions(b.dataArrays{3});
312+
% getMTag.add_extents(b.dataArrays{5});
313+
% assert(strcmp(getMTag.open_extents.name, 'extentsTest2'));
314+
disp('Test MultiTag: add extents ... TODO (add dimensions required)');
315+
end
316+
275317
%% Test: Open extents
276318
function [] = test_open_extents( varargin )
277319
test_file = nix.File(fullfile(pwd, 'tests', 'test.h5'), nix.FileMode.ReadOnly);

0 commit comments

Comments
 (0)