function [CombineShape PLIDX PRIDX] = BuildNewShape(PL,PR,IntersectionPoint)

    [V1 I1] = max(imag(IntersectionPoint));
    [Vend Iend] = min(imag(IntersectionPoint));
    
    PLIDX = [];
    PRIDX = [];
    
    %%%%%%%%%%%%%% Left Writing %%%%%%%%%%%%%%%%%%
    CombineShape = IntersectionPoint(I1);
    UpperIdx = [];
    for idx = 1:length(PL)
        if(imag(PL(idx))>V1)
            UpperIdx = [UpperIdx idx];
        else
        end
    end
    [VminDis IminDis] = min(abs(real(PL(UpperIdx))-ones(size(UpperIdx))*real(IntersectionPoint(I1))));
    LeftIdx = UpperIdx(IminDis);
    PLIDX = LeftIdx;
    flag = 1;
    while flag
        CombineShape = [CombineShape PL(LeftIdx)];
        LeftIdx = max([mod(LeftIdx+1,length(PL)) 1]);
        if ((imag(PL(LeftIdx))>imag(IntersectionPoint(I1))))||(((imag(PL(LeftIdx)))<(imag(IntersectionPoint(I1))))&&((real(PL(LeftIdx)))<(real(IntersectionPoint(Iend)))))
           PLIDX = [PLIDX LeftIdx]; 
           if length(PLIDX)>=length(PL)
               flag=0;
           else
           end
        else
           flag = 0; 
        end
    end
    
    %%%%%%%%%%%%%% Right Writing %%%%%%%%%%%%%%%%%%
    CombineShape = [CombineShape IntersectionPoint(Iend)];
    LowerIdx = [];
    for idx = 1:length(PR)
        if (imag(PR(idx))<Vend)
            LowerIdx = [LowerIdx idx];
        else
        end
    end
    [VminDis IminDisR] = min(abs((real(PR(LowerIdx)))-(ones(size(LowerIdx))*(IntersectionPoint(Iend)))));
    RightIdx = LowerIdx(IminDisR);
    PRIDX = RightIdx;
    flag = 1;
    while flag
        CombineShape = [CombineShape PR(RightIdx)];
        RightIdx = max([mod(RightIdx+1,length(PR)) 1]);
        if ((imag(PR(RightIdx)))<(imag(IntersectionPoint(Iend))))||(((imag(PR(RightIdx)))>(imag(IntersectionPoint(Iend))))&&((real(PR(RightIdx)))>(real(IntersectionPoint(I1)))))
            PRIDX = [PRIDX RightIdx];     
            if length(PRIDX)>=length(PR)
                flag = 0;
            else
            end
        else
            flag = 0;
        end
    end
    
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    CombineShape = [CombineShape IntersectionPoint(I1)];
end