function [ne , nk , xy , km , kr] = TorsnetD6 (b , h , nhh , nvh)

ne =  nhh * nvh * 8 ;
nk = (nhh * 4 + 1) * (nvh * 4 + 1) ;

xy = zeros (nk,2) ;
km = zeros (ne,6) ;
kr = zeros (nk,1) ;

xstep = b / (nhh * 4) ;
ystep = h / (nvh * 4) ;

y  = 0. ;
ij = 1 ;
for j = 1:nvh*4+1
    x = 0. ;
    for i = 1:nhh*4+1
        xy(ij,1) = x ;
        xy(ij,2) = y ;
        x  = x + xstep ;
        ij = ij + 1 ;
    end
    y = y + ystep ;
end

ii1 = 1 ;
iel = 1 ;
m2  = nhh * 4 ;

for j = 1:nvh
    i1 = ii1 ;
    for i = 1:nhh
        km(iel,1) = i1 ;
        km(iel,2) = i1+(m2+1)*2+2 ;
        km(iel,3) = i1+(m2+1)*2 ;
        km(iel,4) = i1+m2+2 ;
        km(iel,5) = i1+(m2+1)*2+1 ;
        km(iel,6) = i1+m2+1 ;
        iel = iel+1 ;
        km(iel,1) = i1 ;
        km(iel,2) = i1+2 ;
        km(iel,3) = i1+(m2+1)*2+2 ;
        km(iel,4) = i1+1 ;
        km(iel,5) = i1+m2+3 ;
        km(iel,6) = i1+m2+2 ;
        i1  = i1  + 2 ;
        iel = iel + 1 ;
    end
    i1 = ii1 + nhh*2 ;
    for i = 1:nhh
        km(iel,1) = i1 ;
        km(iel,2) = i1+2 ;
        km(iel,3) = i1+(m2+1)*2 ;
        km(iel,4) = i1+1 ;
        km(iel,5) = i1+m2+2 ;
        km(iel,6) = i1+m2+1 ;
        iel = iel+1 ;
        km(iel,1) = i1+2 ;
        km(iel,2) = i1+(m2+1)*2+2 ;
        km(iel,3) = i1+(m2+1)*2 ;
        km(iel,4) = i1+m2+3 ;
        km(iel,5) = i1+(m2+1)*2+1 ;
        km(iel,6) = i1+m2+2 ;
        i1  = i1  + 2 ;
        iel = iel + 1 ;
    end
    ii1 = ii1 + (m2 + 1) * 2 ;
end

ii1 = (m2 + 1) * nvh * 2 + 1 ;
for j = 1:nvh
    i1 = ii1 ;
    for i = 1:nhh
        km(iel,1) = i1 ;
        km(iel,2) = i1+2 ;
        km(iel,3) = i1+(m2+1)*2 ;
        km(iel,4) = i1+1 ;
        km(iel,5) = i1+m2+2 ;
        km(iel,6) = i1+m2+1 ;
        iel = iel + 1 ;
        km(iel,1) = i1+2 ;
        km(iel,2) = i1+(m2+1)*2+2 ;
        km(iel,3) = i1+(m2+1)*2 ;
        km(iel,4) = i1+m2+3 ;
        km(iel,5) = i1+(m2+1)*2+1 ;
        km(iel,6) = i1+m2+2 ;
        i1  = i1 + 2 ;
        iel = iel + 1 ;
    end
    i1 = ii1 + nhh*2 ;
    for i = 1:nhh
        km(iel,1) = i1 ;
        km(iel,2) = i1+(m2+1)*2+2 ;
        km(iel,3) = i1+(m2+1)*2 ;
        km(iel,4) = i1+m2+2 ;
        km(iel,5) = i1+(m2+1)*2+1 ;
        km(iel,6) = i1+m2+1 ;
        iel = iel + 1 ;
        km(iel,1) = i1 ;
        km(iel,2) = i1+2 ;
        km(iel,3) = i1+(m2+1)*2+2 ;
        km(iel,4) = i1+1 ;
        km(iel,5) = i1+m2+3 ;
        km(iel,6) = i1+m2+2 ;
        i1  = i1 + 2 ;
        iel = iel + 1 ;
    end
    ii1 = ii1 + (m2 + 1) * 2 ;
end

for i = 1:m2+1
    kr (i) = 1 ;
    kr (nk-i+1) = 1 ;
end

for i = 1:m2+1:nk
    kr (i) = 1  ;
    kr (i+m2) = 1 ;
end