Update changelog
[Ale.git] / scripts / cpfmerge
blob8b5f233e21e2b52a139ddbccf445a25773eba009
1 #!/usr/bin/perl -w
3 # Copyright 2005 David Hilvert <dhilvert@auricle.dyndns.org>,
4 # <dhilvert@ugcs.caltech.edu>
6 # This file is part of the Anti-Lamenessing Engine.
8 # The Anti-Lamenessing Engine is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # The Anti-Lamenessing Engine is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Anti-Lamenessing Engine; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 # Script to merge ALE cpf files. Assumes that the first columns of all files
24 # refer to points in the first frame in the sequence. These are written as the
25 # first column in the output, followed by the first file's columns, and then
26 # the second file's columns, etc.
29 print "V 0\n";
31 $data_count = 0;
33 foreach (@ARGV) {
34 @file_lines = `cat $_`;
36 $first_data_line = 1;
37 $old_data_count = $data_count;
39 %used_keys = ();
41 foreach (@file_lines) {
42 /^A (\d+ \d+) (.*)$/ or next;
44 $key = $1;
45 $data = $2;
47 if ($first_data_line) {
48 $data_copy = $data;
49 while ($data_copy =~ s/^\d+ \d+(.*)$/$1/) {
50 $data_count++;
52 $first_data_line = 0;
55 next if ($used_keys{$key});
57 if (!defined($points{$key})) {
58 $points{$key} = " nan nan" x $old_data_count;
61 $points{$key} .= " $data";
62 $used_keys{$key} = 1;
65 foreach $key (keys %points) {
66 if (!defined($used_keys{$key})) {
67 $points{$key} .= " nan nan";
72 foreach $key (keys %points) {
73 print "A $key" . "$points{$key}\n";