1//  Scicos
2//
3//  Copyright (C) INRIA - METALAU Project <scicos@inria.fr>
4//                      - Alan Layec <alan.layec@inria.fr>
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 2 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19//
20// See the file ../license.txt
21//
22
23function [lnksz,lnktyp]=lnkptrcomp(bllst,inpptr,outptr,inplnk,outlnk)
24
25    lnkbsz=[];ptlnk=[];lnksz=[];lnktyp=[];
26    for blkout=1:length(bllst)
27        for portout=1:outptr(blkout+1)-outptr(blkout)
28            ptlnk=outlnk(outptr(blkout)+portout-1)
29            lnkbsz(outlnk(outptr(blkout)+portout-1))=bllst(blkout).out(portout);
30            lnksz(ptlnk,1)=bllst(blkout).out(portout);
31            lnksz(ptlnk,2)=bllst(blkout).out2(portout);
32            lnktyp(ptlnk)=bllst(blkout).outtyp(portout);
33        end
34    end
35
36    //27/09/07 Alan's patch : do test here for unconnected inputs
37    if inplnk<>[] | outlnk<>[] then
38        unco=find(inplnk>max(outlnk))
39        for j=unco
40            m=max(find(inpptr<=j))
41            n=j-inpptr(m)+1
42            lnksz($+1,1)=bllst(m).in(n);
43            lnksz($,2)=bllst(m).in2(n);
44            lnktyp($+1)=bllst(m).intyp(n);
45        end
46    end
47
48    //lnkptr=cumsum([1;lnkbsz])
49endfunction
50
51