size 21.5 12.0

set cap round
set arrowsize 0.3

lineWidth = 0.06

xFigureCentre = 9
yFigureCentre = 6

begin object rectangle width height lwidth nobox
	! Draw a rectangle
	! width, height: the width and height of the rectangle
	default width 2.0
	default height 1.6
	default lwidth 0.04
	default nobox 1
	set lwidth lwidth
	if nobox = 0 then set fill white
	box width height round round
end object

begin texpreamble
	\usepackage{amsmath}
	\usepackage{amssymb}
end texpreamble

!g function

xgCentre = xFigureCentre-4.6
ygCentre = yFigureCentre+2.6

amove xgCentre ygCentre
draw rectangle.cc name g

amove xgCentre ygCentre+0.6+height(g)/2
save gFunctionNameInput
set lwidth lineWidth
join g.tc <- gFunctionNameInput

amove xgCentre-1.7-width(g)/2 ygCentre
save gFunctionInput
set lwidth lineWidth
join gFunctionInput -> g.lc

!amove xgCentre+0.6+width(g)/2 ygCentre
!save gFunctionOutput
!set lwidth lineWidth
!join g.rc - gFunctionOutput

amove xgCentre+0.8+width(g)/2 ygCentre+0.4
set hei 0.4
set just cc
tex "$g(i)$"

amove ptx(gFunctionNameInput)+0.47 pty(gFunctionNameInput)-0.1
set hei 0.4
set just cc
tex "$g: I \rightarrow S$"

amove xgCentre ygCentre-0.3-height(g)/2
set hei 0.4
set just cc
tex "distribuidor"
rmove 0 -0.4
tex "espacial"

!g function - end

!e function

xeCentre = xgCentre+4.4
yeCentre = ygCentre

amove xeCentre yeCentre
draw rectangle.cc name e

amove xeCentre yeCentre+0.6+height(e)/2
save eFunctionNameInput
set lwidth lineWidth
join e.tc <- eFunctionNameInput

!amove xeCentre-1.2-width(e)/2 yeCentre
!save eFunctionInput
!set lwidth lineWidth
!join e.lc - eFunctionInput

!amove xeCentre+0.6+width(e)/2 yeCentre
!save eFunctionOutput
!set lwidth lineWidth
!join e.rc - eFunctionOutput

amove ptx(eFunctionNameInput)+0.62 pty(eFunctionNameInput)-0.1
set hei 0.4
set just cc
tex "$e: S \rightarrow C^2$"

amove xeCentre yeCentre-0.3-height(e)/2
set hei 0.4
set just cc
tex "instalador"

!e function - end

set lwidth lineWidth
join g.rc -> e.lc

!a function

xaCentre = xeCentre+3.4
yaCentre = ygCentre

amove xaCentre yaCentre
draw rectangle.cc name a

amove xaCentre yaCentre+0.6+height(a)/2
save aFunctionNameInput
set lwidth lineWidth
join a.tc <- aFunctionNameInput

!amove xaCentre-1.2-width(a)/2 yaCentre
!save aFunctionInput
!set lwidth lineWidth
!join a.lc - aFunctionInput

amove xaCentre+1.8+width(a)/2 yaCentre
save aFunctionOutput
set lwidth lineWidth
join a.rc - aFunctionOutput

rmove 0.9 0.4
set hei 0.4
set just cc
tex "$f(g(i))$ (prefixo)"

amove ptx(aFunctionNameInput)+0.7 pty(aFunctionNameInput)-0.1
set hei 0.4
set just cc
tex "$a: C^2 \rightarrow R_1$"

amove xaCentre yaCentre-0.3-height(a)/2
set hei 0.4
set just cc
tex "gerador de"
rmove 0 -0.4
tex "r\'otulo"

amove xaCentre yaCentre
set hei 0.4
set just cc
tex "Alg. 1/5"

!a function - end

set lwidth lineWidth
join e.rc -> a.lc

! f

xfCentre = (ptx(eFunctionNameInput)+ptx(aFunctionNameInput))/2
width = ptx(aFunctionNameInput)-ptx(eFunctionNameInput)+2.0+2.0
height = 1.6+2.2
amove xfCentre yeCentre
draw rectangle.cc width height name f

amove xfCentre yeCentre+0.6+height(f)/2
save fFunctionNameInput
set lwidth lineWidth	
rline 0 0	! round end line
set cap butt
join f.tc <- fFunctionNameInput
set cap round

amove ptx(fFunctionNameInput)+0.58 pty(fFunctionNameInput)-0.1
set hei 0.4
set just cc
tex "$f: S \rightarrow R_1$"

amove xfCentre yeCentre-0.3-height(f)/2
set hei 0.4
set just cc
tex "sistema de identifica\c{c}\~ao"
rmove 0 -0.4
tex "dos subsistemas"

! f - end

begin name giHorizontalLine
set lwidth lineWidth
join g.rc - f.lc
end name

!t function

xtCentre = xFigureCentre-4.6
ytCentre = yFigureCentre-2.6

amove xtCentre ytCentre
draw rectangle.cc name t

amove xtCentre ytCentre+0.6+height(t)/2
save tFunctionNameInput
set lwidth lineWidth
join t.tc <- tFunctionNameInput

amove xtCentre-1.7-width(t)/2 ytCentre
save tFunctionInput
set lwidth lineWidth
join tFunctionInput -> t.lc

!amove xtCentre+0.6+width(t)/2 ytCentre
!save tFunctionOutput
!set lwidth lineWidth
!join t.rc - tFunctionOutput

!amove xtCentre+0.8+width(t)/2 ytCentre+0.4
!set hei 0.4
!set just cc
!tex "$t(i)$"

amove ptx(tFunctionNameInput)+1.14 pty(tFunctionNameInput)-0.1
set hei 0.4
set just cc
tex "$t: g^*(g(i)) \rightarrow T_r$"

amove xtCentre ytCentre-0.3-height(t)/2
set hei 0.4
set just cc
tex "distribuidor"
rmove 0 -0.4
tex "temporal"

!t function - end

!b function

xbCentre = xtCentre+3.4
ybCentre = ytCentre

amove xbCentre ytCentre
draw rectangle.cc name b

amove xbCentre ybCentre+0.6+height(b)/2
save bFunctionNameInput
set lwidth lineWidth
join b.tc <- bFunctionNameInput

!amove xbCentre-1.2-width(b)/2 ybCentre
!save bFunctionInput
!set lwidth lineWidth
!join b.lc - bFunctionInput

amove ptx(aFunctionOutput) ybCentre
save bFunctionOutput
set lwidth lineWidth
join b.rc - bFunctionOutput

rmove -3.6 0.4
set hei 0.4
set just cc
tex "$g(i)(i)$ (sufixo)"

amove ptx(bFunctionNameInput)+0.68 pty(bFunctionNameInput)-0.1
set hei 0.4
set just cc
tex "$b: T_r \rightarrow R_2$"

amove xbCentre ybCentre-0.3-height(b)/2
set hei 0.4
set just cc
tex "gerador de"
rmove 0 -0.4
tex "r\'otulo"

amove xbCentre ybCentre
set hei 0.4
set just cc
tex "Alg. 2/6"

!b function - end

set lwidth lineWidth
join t.rc -> b.lc

! g(i)

xgiCentre = (ptx(tFunctionNameInput)+ptx(bFunctionNameInput))/2
width = ptx(bFunctionNameInput)-ptx(tFunctionNameInput)+2.0+2.0
height = 1.6+2.2
amove xgiCentre ytCentre
draw rectangle.cc width height name gi

set lwidth lineWidth
set cap butt
join gi.tc <- giHorizontalLine.v
set cap round

amove xgiCentre+0.92 ytCentre+0.4+height(gi)/2
set hei 0.4
set just cc
tex "$g(i): g^*(g(i)) \rightarrow R_2$"

amove xgiCentre ytCentre-0.3-height(gi)/2
set hei 0.4
set just cc
tex "subsistema de identifica\c{c}\~ao"
rmove 0 -0.4
tex "repons\'avel pela identifica\c{c}\~ao de $i$"

! input i
begin name iVerticalLine
set lwidth lineWidth
join gFunctionInput - tFunctionInput
end name

amove ptx(gFunctionInput)-1.0 yFigureCentre
save input
join input - tFunctionInput.h

amove ptx(input)+0.4 pty(input)+0.4
set hei 0.4
set just cc
tex "$i$"

! Cartesian product circle

xCartesianProduct = xFigureCentre+6.8

begin name product
	amove xCartesianProduct yFigureCentre
	set lwidth 0.04
	circle 0.4
end name

rmove 1.4 0
save productOutput
set lwidth lineWidth
!rline 0 0	! round end line

rmove -0.6 0.4
set hei 0.4
set just cc
tex "$h(i)$"
rmove 1.4 -2.8
tex "$h(i) = (f(g(i)), g(i)(i))$"

set lwidth lineWidth
join aFunctionOutput -> product.c
join bFunctionOutput -> product.c
!set cap butt
!join product.c - productOutput
!set cap round

! Cartesian product circle - end

!c function

xcCentre = xCartesianProduct+2.2
ycCentre = yFigureCentre

amove xcCentre ycCentre
draw rectangle.cc name c

amove xcCentre ycCentre+0.6+height(c)/2
save cFunctionNameInput
set lwidth lineWidth
join c.tc <- cFunctionNameInput

!amove xaCentre-1.2-width(a)/2 yaCentre
!save aFunctionInput
!set lwidth lineWidth
!join a.lc - aFunctionInput

amove xcCentre+1.0+width(c)/2 ycCentre
save cFunctionOutput
set lwidth lineWidth
join c.rc - cFunctionOutput

rmove -0.3 0.4
set hei 0.4
set just cc
tex "$c(h(i))$"
rmove -0.1 -0.8
tex "$s(i)$"

amove ptx(cFunctionNameInput)+1.14 pty(cFunctionNameInput)-0.1
set hei 0.4
set just cc
tex "$c: R_1 \times R_2 \rightarrow R$"

amove xcCentre ycCentre-0.3-height(c)/2
set hei 0.4
set just cc
tex "gerador de"
rmove 0 -0.4
tex "r\'otulo"

amove xcCentre ycCentre
set hei 0.4
set just cc
tex "Alg. 3/7"

!c function - end

set lwidth lineWidth
join product.c -> c.lc

amove xCartesianProduct yFigureCentre
set lwidth 0.04
set fill white
circle 0.4

set hei 0.4
set just cc
tex "$\times$"

amove xgCentre ygCentre
draw rectangle.cc nobox 0

amove xeCentre yeCentre
draw rectangle.cc nobox 0

amove xaCentre yaCentre
draw rectangle.cc nobox 0

amove xtCentre ytCentre
draw rectangle.cc nobox 0

amove xbCentre ybCentre
draw rectangle.cc nobox 0

amove xcCentre ycCentre
draw rectangle.cc nobox 0

