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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
include "iralign.h"
# IR_INDICES -- Given the number in the list for a missing subraster and
# information about how the subrasters were written return the i and j
# indices of the specified subrasters.
procedure ir_indices (num, i, j, nxsub, nysub, corner, raster, order)
int num # number of the subraster
int i,j # indices of the subraster
int nxsub,nysub # number of subrasters in x and y
int corner # starting corner
int raster # raster order
int order # column or row order
begin
switch (corner) {
case IR_LL:
if (order == IR_ROW) {
if (mod (num, nxsub) == 0) {
j = num / nxsub
if (raster == YES && mod (j,2) == 0)
i = 1
else
i = nxsub
} else {
j = num / nxsub + 1
if (raster == YES && mod (j,2) == 0)
i = nxsub - mod (num, nxsub) + 1
else
i = mod (num, nxsub)
}
} else if (order == IR_COLUMN) {
if (mod (num, nysub) == 0) {
i = num / nysub
if (raster == YES && mod (i,2) == 0)
j = 1
else
j = nysub
} else {
i = num / nysub + 1
if (raster == YES && mod (i,2) == 0)
j = nysub - mod (num, nysub) + 1
else
j = mod (num, nysub)
}
}
case IR_LR:
if (order == IR_ROW) {
if (mod (num, nxsub) == 0) {
j = num / nxsub
if (raster == YES && mod (j,2) == 0)
i = nxsub
else
i = 1
} else {
j = num / nxsub + 1
if (raster == YES && mod (j,2) == 0)
i = mod (num, nxsub)
else
i = nxsub - mod (num, nxsub) + 1
}
} else if (order == IR_COLUMN) {
if (mod (num, nysub) == 0) {
i = nxsub - num / nysub + 1
if (raster == YES && mod (i,2) != 0)
j = 1
else
j = nysub
} else {
i = nxsub - num / nysub
if (raster == YES && mod (i,2) != 0)
j = nysub - mod (num, nysub) + 1
else
j = mod (num, nysub)
}
}
case IR_UL:
if (order == IR_ROW) {
if (mod (num, nxsub) == 0) {
j = nysub - num / nxsub + 1
if (raster == YES && mod (j,2) != 0)
i = 1
else
i = nxsub
} else {
j = nysub - num / nxsub
if (raster == YES && mod (j,2) != 0)
i = nxsub - mod (num, nxsub) + 1
else
i = mod (num, nxsub)
}
} else if (order == IR_COLUMN) {
if (mod (num, nysub) == 0) {
i = num / nysub
if (raster == YES && mod (i,2) == 0)
j = nysub
else
j = 1
} else {
i = num / nysub + 1
if (raster == YES && mod (i,2) == 0)
j = mod (num, nysub)
else
j = nysub - mod (num, nysub) + 1
}
}
case IR_UR:
if (order == IR_ROW) {
if (mod (num, nxsub) == 0) {
j = nysub - num / nxsub + 1
if (raster == YES && mod (j,2) != 0)
i = nxsub
else
i = 1
} else {
j = nysub - num / nxsub
if (raster == YES && mod (j,2) != 0)
i = mod (num, nxsub)
else
i = nxsub - mod (num, nxsub) + 1
}
} else if (order == IR_COLUMN) {
if (mod (num, nysub) == 0) {
i = nxsub - num / nysub + 1
if (raster == YES && mod (i,2) != 0)
j = nysub
else
j = 1
} else {
i = nxsub - num / nysub
if (raster == YES && mod (i,2) != 0)
j = mod (num, nysub)
else
j = nysub - mod (num, nysub) + 1
}
}
}
end
|