function shapeDisplacements = designMap(Ishape,p)

% shapeDisplacements = designMap(Ishape,p)
%                It evaluates the design-to-shape mapping
%                using the Bezier parametrization.

%sprintf('%s','designMap')

% number of nodes on the symmetric part of shape design boundary
nSymmetryShapeNodes = max(size(Ishape));

% number of design variables
nSymmetryDesign = max(size(p));

% total number of design control nodes
nDesign = 2*nSymmetryDesign+1;

shapeDisplacements = zeros(2,nSymmetryShapeNodes);

d = 0.5/(nSymmetryShapeNodes-1);

for i=1:nSymmetryShapeNodes
    shapeDisplacements(1,i) = p(1)*bezier(nSymmetryDesign+1,nDesign,0.5+(i-1)*d);
    
    for j=2:nSymmetryDesign
        shapeDisplacements(1,i) = shapeDisplacements(1,i) + p(j)*bezier(nSymmetryDesign+1+(j-1),nDesign,0.5+(i-1)*d);
        shapeDisplacements(1,i) = shapeDisplacements(1,i) + p(j)*bezier(nSymmetryDesign+1-(j-1),nDesign,0.5+(i-1)*d);
    end
end


%plot(0.5:d:1,shapeDisplacements(1,:),'bx',0.5:(0.5/nSymmetryDesign):1,[p;0],'r+');
