Differences From Artifact [605d25d1b2]:

To Artifact [2c59585cdf]:


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.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
  ## ##









>
>
>







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

  ## ###############################################################
  ## ## Version control history
  ## ###############################################################
  ## ## $Id$
  ## ## $Log$
  ## ## Revision 1.44  1999/10/19 00:05:44  peterg
  ## ## Now defaults junction ports when only one specified (for vector junctions)
  ## ##
  ## ## 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
  ## ##
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
    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







>



<



>
|
>
|
|
|
>




|







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
315
316
317
318
319
    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,:);
	  named_bond_index = j;
	  junction_names++;
	endif
      endfor

      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.
	junction_port_name = mtt_strip_name(junction_port_name);
	for j=1:n_comp_bonds;
	  if j!=named_bond_index
	    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
	  endif
	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
      port_name = port_name
    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
347
348
349
350
351
352
353

354
355
356
357
358
359
360
361
362
	  mtt_info(["Defaulting port name [" port_name_i "]\t on component " \
		    comp_name " (" comp_type ")" ],infofile);
	  port_name = [port_name; ["[" port_name_i "]"]];	# add to list
	  [port_name_index,junk] = size(port_name); # the corresponding
				# index
	  port_bond(port_name_index,:) = signed_bond; # add to port bond
	else  

      	  port_name_i = deblank(port_name(port_name_index,:));
	  port_name_i = port_name_i(2:length(port_name_i)-1) # strip []
	endif
	
	
	## Replace by alias -- if any
    	eval( ["alias = ", comp_type, '_alias';]); # Get aliases
    	if is_struct(alias)		# are there any aliases
          if struct_contains(alias,port_name_i) # Is this an alias?







>
|
|







353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
	  mtt_info(["Defaulting port name [" port_name_i "]\t on component " \
		    comp_name " (" comp_type ")" ],infofile);
	  port_name = [port_name; ["[" port_name_i "]"]];	# add to list
	  [port_name_index,junk] = size(port_name); # the corresponding
				# index
	  port_bond(port_name_index,:) = signed_bond; # add to port bond
	else  
	  port_name_i = mtt_strip_name(port_name(port_name_index,:));
	  ## port_name_i = deblank(port_name(port_name_index,:));
	  ## port_name_i = port_name_i(2:length(port_name_i)-1) # strip []
	endif
	
	
	## Replace by alias -- if any
    	eval( ["alias = ", comp_type, '_alias';]); # Get aliases
    	if is_struct(alias)		# are there any aliases
          if struct_contains(alias,port_name_i) # Is this an alias?

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