71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
port_coord(i,1)/scale, port_coord(i,2)/scale, \
deblank(port_name(i,:))));
endif
## The (signed) bond corresponding to the ith port label
port_bond(i) = near_bond(1) * sign(1.5 - near_bond(2));
endfor
port_bond
## Now have (signed) bond (port_bond(i)) corresponding to the ith port
## Create inverse mapping
for i = 1:n_bonds
eval(sprintf('bond_port_head%i = "[]"', i))
eval(sprintf('bond_port_tail%i = "[]"', i))
endfor
for i = 1:n_ports
|
<
>
|
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
port_coord(i,1)/scale, port_coord(i,2)/scale, \
deblank(port_name(i,:))));
endif
## The (signed) bond corresponding to the ith port label
port_bond(i) = near_bond(1) * sign(1.5 - near_bond(2));
endfor
port_bond
## Now have (signed) bond (port_bond(i)) corresponding to the ith port
## Create inverse mapping
for i = 1:n_bonds
eval(sprintf('bond_port_head%i = "[]"', i))
eval(sprintf('bond_port_tail%i = "[]"', i))
endfor
for i = 1:n_ports
|
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
## Locate the components at the ends of each bond
## col 1 of comp_near_bond contains component nearest to the arrow end
## col 2 of comp_near_bond contains component nearest other end
for i = 1:n_bonds
comp_near_bond(i,:) = adjcomp(arrow_end(i,:), other_end(i,:), \
rcomponents);
[hc_type, hc_name] = eval([name, '_cmp(comp_near_bond(i,1))']);
[tc_type, tc_name] = eval([name, '_cmp(comp_near_bond(i,2))']);
endfor
## Deduce causality from the strokes (if any)
causality = zeros(n_bonds,2);
if (n_strokes > 0)
## Find location of centre and ends of stroke
stroke_end_1 = [rstrokes(:,1), rstrokes(:,2)];
stroke_end_2 = [rstrokes(:,3), rstrokes(:,4)];
|
<
<
>
|
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
## Locate the components at the ends of each bond
## col 1 of comp_near_bond contains component nearest to the arrow end
## col 2 of comp_near_bond contains component nearest other end
for i = 1:n_bonds
comp_near_bond(i,:) = adjcomp(arrow_end(i,:), other_end(i,:), \
rcomponents);
endfor
comp_near_bond
## Deduce causality from the strokes (if any)
causality = zeros(n_bonds,2);
if (n_strokes > 0)
## Find location of centre and ends of stroke
stroke_end_1 = [rstrokes(:,1), rstrokes(:,2)];
stroke_end_2 = [rstrokes(:,3), rstrokes(:,4)];
|
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
else # bi-causal stroke
stroke_direction = stroke(1,:) - stroke(stroke_index(1),:);
flow_side = stroke_direction * arrow_vector(j,:)' > 0;
causality(j,1+flow_side) = 2 * which_end - 1;
endif
endfor
endif
## Return data
for i = 1:n_bonds
eval(sprintf("bonds.bond%i.head.component\t= '%s:%s'", i, hc_type, \
hc_name));
eval(sprintf("bonds.bond%i.tail.component\t= '%s:%s'", i, tc_type, \
tc_name));
eval(sprintf("bonds.bond%i.head.ports\t= bond_port_head%i", i, i));
eval(sprintf("bonds.bond%i.tail.ports\t= bond_port_tail%i", i, i));
endfor
endfunction
|
>
|
>
>
>
>
>
>
>
>
>
>
>
|
|
>
>
>
>
>
>
>
|
>
>
>
|
|
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
else # bi-causal stroke
stroke_direction = stroke(1,:) - stroke(stroke_index(1),:);
flow_side = stroke_direction * arrow_vector(j,:)' > 0;
causality(j,1+flow_side) = 2 * which_end - 1;
endif
endfor
endif
causality
## Write data
for i = 1:n_bonds
[hc_type, hc_name] = eval([name, '_cmp(comp_near_bond(i,1))']);
[tc_type, tc_name] = eval([name, '_cmp(comp_near_bond(i,2))']);
## components
eval(sprintf("bonds.bond%i.head.component\t= '%s:%s'", i, hc_type, \
hc_name));
eval(sprintf("bonds.bond%i.tail.component\t= '%s:%s'", i, tc_type, \
tc_name));
## ports
eval(sprintf("bonds.bond%i.head.ports\t= bond_port_head%i", i, i));
eval(sprintf("bonds.bond%i.tail.ports\t= bond_port_tail%i", i, i));
## causality
if (causality(i,1) == 1)
effort_causality = "head"
elseif (causality(i,1) == -1)
effort_causality = "tail"
else
effort_causality = "none"
endif
if (causality(i,2) == 1)
flow_causality = "tail"
elseif (causality(i,2) == -1)
flow_causality = "head"
else
flow_causality = "none"
endif
eval(sprintf("bonds.bond%i.causality.effort\t= '%s'", i, effort_causality));
eval(sprintf("bonds.bond%i.causality.flow\t= '%s'", i, flow_causality));
endfor
endfunction
|