function [segment length n_nodes nodes] = read_bom(filenm)

cmd = ['grep -e ^[0-9][0-9][0-9][0-9] ' filenm '.bom > foo'];
system(cmd);

data = dlmread('foo');

data

N = size(data)(1)
length = data(:,3);
n_nodes = data(:,4);
nodes = data(:,7);

fid = fopen('foo','r');

for n = 1:N
 line = fgetl(fid)
 [seg remain] = strtok(line);
 segment{n} = strtok(remain);
end
fclose(fid);

