Differences From Artifact [c4467a3093]:

To Artifact [605d25d1b2]:


1
2
3
4
5
6
7
8
9




10
11
12
13
14
15
16
function [bonds,components,n_vector_bonds] = rbg2abg(name,rbonds,rstrokes,rcomponents,\
				      port_coord,port_name,\
				      infofile,errorfile)

  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$




  ## ## Revision 1.42  1999/08/25 21:45:03  peterg
  ## ## Spurious start to vector 0 and 1
  ## ##
  ## ## Revision 1.41  1999/08/19 21:12:33  peterg
  ## ## Tidied and started implementaation of vector junctions
  ## ##
  ## ## Revision 1.40  1999/08/19 05:39:55  peterg









>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function [bonds,components,n_vector_bonds] = rbg2abg(name,rbonds,rstrokes,rcomponents,\
				      port_coord,port_name,\
				      infofile,errorfile)

  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$
  ## ## Revision 1.43  1999/10/18 04:08:46  peterg
  ## ## Now computes n_vector_bonds -- number apparent (maybe vector) bonds per component.
  ## ## Neeeded to vectorise junctions.
  ## ##
  ## ## Revision 1.42  1999/08/25 21:45:03  peterg
  ## ## Spurious start to vector 0 and 1
  ## ##
  ## ## Revision 1.41  1999/08/19 21:12:33  peterg
  ## ## Tidied and started implementaation of vector junctions
  ## ##
  ## ## Revision 1.40  1999/08/19 05:39:55  peterg
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
  ## Also expand aliases using the alias list for each component
  components = []; 
  i_vector=0;			# Counter for vector components
  for i = 1:n_components
    ##Get component type
    eval(['[comp_type, comp_name] = ', name, '_cmp(i)']);

#     ## Vector 0 and 1
#     n_vector = 1;		# Default to scalar component
#     if (comp_type(1)=='0')||(comp_type(1)=='1')
#       n_name = length(comp_type);
#       if n_name>1
# 	n_vector = str2num(comp_type(2:n_name));
#       endif
#     endif
#     n_vector

#     ## Create scalar versions of vector components
#     for new_comp=2:n_vector
#       i_vector++;
#     endfor
    
    ## There are n_comp_bonds bonds on this component with corresponding index
    [index,n_comp_bonds] = getindex(comp_near_bond,i);

    if index(1,1)==0
      mtt_error(sprintf("Component %s (%s) has no bonds", comp_name,
			comp_type),errorfile);







<
<
<
<
<
<
<
<
<
<
<
<
<
<







245
246
247
248
249
250
251














252
253
254
255
256
257
258
  ## Also expand aliases using the alias list for each component
  components = []; 
  i_vector=0;			# Counter for vector components
  for i = 1:n_components
    ##Get component type
    eval(['[comp_type, comp_name] = ', name, '_cmp(i)']);















    
    ## There are n_comp_bonds bonds on this component with corresponding index
    [index,n_comp_bonds] = getindex(comp_near_bond,i);

    if index(1,1)==0
      mtt_error(sprintf("Component %s (%s) has no bonds", comp_name,
			comp_type),errorfile);
283
284
285
286
287
288
289
290
291
292
293






















294

295
296
297
298
299
300
301

    ## which end of bond at component?
    bond_end = index(:,2); 
    direction = -sign(bond_end-1.5*one);
    signed_bond_list = bond_list.*direction;
    components = add_bond(components,signed_bond_list',i);
    
				# Unalias all the ports on this component - if not a junction
    unlabelled_ports = 0;  
    in_bonds = 0;
    out_bonds = 0;






















    if ((comp_type!="0")&&(comp_type!="1")) # Don't do junctions

      for j=1:n_comp_bonds
	signed_bond = signed_bond_list(j);
	port_name_index = getindex(port_bond,signed_bond);
	port_direction = sign(signed_bond);
	
	if port_name_index==0	# There is no port on this bond - so try
				# to default







|



>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>







273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314

    ## which end of bond at component?
    bond_end = index(:,2); 
    direction = -sign(bond_end-1.5*one);
    signed_bond_list = bond_list.*direction;
    components = add_bond(components,signed_bond_list',i);
    
    ## Unalias and/or default all the ports on this componen
    unlabelled_ports = 0;  
    in_bonds = 0;
    out_bonds = 0;
    if ((comp_type=="0")||(comp_type=="1")) # A junction
      disp("---- default junctions ---- ");
      junction_names = 0;
      for j=1:n_comp_bonds
	port_name_index = getindex(port_bond,signed_bond_list(j));
	if port_name_index>0
	  junction_port_name = port_name(port_name_index,:);
	  junction_names++;
	endif
      endfor
      junction_names, junction_port_name
      if junction_names==1	# one named port
	mtt_info(sprintf("Defaulting all ports on junction %s to %s", comp_name, junction_port_name));
	## Make the other n-1 names the same.
	for j=1:n_comp_bonds-1;
	  port_name = [port_name; ["[" junction_port_name "]"]]; # add to list
	  [port_name_index,junk] = size(port_name); # the corresponding index
	  port_bond(port_name_index,:) = signed_bond_list(j); # add to port bond
	endfor
      elseif (junction_names!=0)&&(junction_names!=n_comp_bonds) # not allowed
	mtt_error(sprintf("Junction %s must have 0, 1 or %i port labels", comp_name,n_comp_bonds),errorfile);
      endif
      
    else			# Not a junction
      for j=1:n_comp_bonds
	signed_bond = signed_bond_list(j);
	port_name_index = getindex(port_bond,signed_bond);
	port_direction = sign(signed_bond);
	
	if port_name_index==0	# There is no port on this bond - so try
				# to default

MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]