1 // This file is part of the Mussa source distribution.
2 // http://mussa.caltech.edu/
3 // Contact author: Tristan De Buysscher, tristan@caltech.edu
5 // This program and all associated source code files are Copyright (C) 2005
6 // the California Institute of Technology, Pasadena, CA, 91125 USA. It is
7 // under the GNU Public License; please see the included LICENSE.txt
8 // file for more information, or contact Tristan directly.
12 ExtendPathWindows(PathList raw_list)
14 // to keep track of everything, this function acts like a finite state
15 // automata: 3 bitfields: reset, extending, scanning - ie 8 states
16 int reset = 0, extending = 0, scanning = 0;
18 int species_num = raw_list.SpeciesNum();
19 int win_num = raw_list.WinNum();
21 int *cur_path, *next_path;
23 cur_path = new int[species_num];
24 next_path = new int[species_num];
26 raw_list.ResetIndex();
28 while (no more windows avaible)
30 //cur_indices[0] + ref_ext == next_indices[0] + 1:
32 // state 000 - start/nominal search
34 if !reset && !extending && !scanning
36 if cur_path[0] == next_path[0]
38 scanning = 1; // go to state 001
39 raw_list.IncreIndex();
41 else if cur_path[0] + 1 == next_path[0]
43 extending = 1; // go to state 010
46 raw_list.IncreIndex();
49 reset = 1; // go to state 100
52 // state 001 - scanning for ext window thru possible interleaving
54 else if !reset && !extending && scanning
56 if cur_path[0] == next_path[0]
57 raw_list.IncreIndex();
58 else if cur_path[0] + 1 == next_path[0]
60 extending = 1; // go to state 011
63 raw_list.IncreIndex();
66 reset = 1; // go to state 101
69 // state 010 - extending window with no interleaving
71 else if !reset && extending && !scanning
73 if (cur_path[0] + win_ext) == next_path[0]
75 extending = 1; // go to state 011
76 raw_list.IncreIndex();
78 else if (cur_path[0] + win_ext + 1) == next_path[0]
82 raw_list.IncreIndex();
85 reset = 1; // go to state 110
88 // state 011 - extending window with interleaving
90 else if !reset && extending && scanning
92 if (cur_path[0] + win_ext) == next_path[0]
93 raw_list.IncreIndex();
94 else if (cur_path[0] + win_ext + 1) == next_path[0]
98 raw_list.IncreIndex();
101 reset = 1; // go to state 111
105 // reset condition states, return to 000 after taking appropiate action
107 // state 100 - no extended window, no scanning happened
108 // save basic window to extended window list
109 if reset && !extending && !scanning
111 // return to start/nominal search state
115 // state 101 - no extended window, scanned for interleaving
116 // save basic window to extended window list, return to first clean
117 else if reset && !extending && scanning
119 // return to start/nominal search state
124 // state 110 - extended window, no interleaving
125 // calc extended window, save to extended window list
126 else if reset && extending && !scanning
128 // return to start/nominal search state
133 // state 111 - extended window, interleaved
134 // calc extended window, save to ext win list, return to first clean
135 else if reset && extending && scanning
137 // return to start/nominal search state