Logo Search packages:      
Sourcecode: sailcut version File versions  Download package

CSail CSailWorker::LayoutVertical ( CSail flatsail,
CSail dispsail 
) [protected]

Creates a VERTICAL cut sail.

Parameters:
flatsail the CSail object that will hold the developed sail
dispsail the CSail object that will hold the display version of the developed sail
Returns:
CSail
Author:
Robert Lain

begin the loop for optimising the seam position to fit cloth width

Now we develop the current panel

Now we compute the deviation of top edge of developed panel and straighten this top edge except if this is the top panel

Now we add the seam and hems allowance

Now we check the width of developed panel

loop DO as long as the excess of width is positive AND counter <9

Now we reposition the developed panel such that bottom left is X=0 Y=0

check if peak has been reached to break off

loop FOR next seam

copying the developed sail into flatsail

preparing the displays version of the developed sail

Definition at line 883 of file sailworker.cpp.

References CSailDef::clothW, FootIntersect(), GaffIntersect(), CSubSpace::getp(), CSubSpace::intersect(), LeechIntersect(), LuffIntersect(), CVector::matrix(), CSail::panel, CMatrix::rot3d(), CSailDef::seamW, CVector::unit(), CVector3d::x(), CVector3d::y(), and Zpoint().

Referenced by makeSail().

{
    /*  First create arrays p1 and p2 of points at the end of each seams
    *   located on the straight edge of the sail (no round)
    */
    CPoint3d p1[MAX_PANELS], p2[MAX_PANELS];

    /* Create two temporary sails lay and the corresponding dev */
    CSail lay(MAX_PANELS); // 3D sail
    CSail dev(MAX_PANELS); // developed sail

    /* create number of panels */
    unsigned int npanel=1;
    unsigned int npl= lay.panel[0].right.nbpoints();  // number of right/left points
    unsigned int npb= lay.panel[0].bottom.nbpoints(); // number of bottom/top points

    unsigned int j=0, k=0, cnt=0;
    bool flag=false;

    /* create arrays t1 and t2 of type of intersection
    *  respectively at points p1 on luff side and p2 on leech side
    *  t=1 seam intersect foot at point p1
    *  t=2 seam intersect luff
    *  t=3 seam intersect gaff
    *  t=4 seam intersect leech
    */
    int t1[MAX_PANELS], t2[MAX_PANELS];

    /* define point i for intersections */
    CPoint3d i;

    /* define seamV as the vector parrallel to the leech vector (peak-clew)*/
    CVector3d seamV = leechV.unit();

    CSubSpace seamSP;

    /* create variables for the development and edge corrections */
    CPoint3d pt  = CPoint3d (0,0,0); // test point
    CPoint3d top = CPoint3d (0,0,0);
    CPoint3d bot = CPoint3d (0,0,0);
    CVector3d v  = CVector3d (0,0,0);
    CVector3d vb = CVector3d (0,0,0);
    CVector3d vk = CVector3d (0,0,0);

    /* create variable for panel width correction */
    CVector3d deviation [30];
    CVector3d deviaPrev [30];
    for (k=0; k<29; k++)
    {
        deviation[k] = CVector3d (0,0,0); // set all deviations to zero
        deviaPrev[k] = deviation[k];
    }

    /* create variable to monitor excess over cloth width */
    real exb, exc=0, ymax=0;

    /* seam 0 is on the leech of the sail ending at the peak */
    p1[0] = clew; // initialised at tack point
    p2[0] = peak;
    t1[0] = 1;
    t2[0] = 3;    // type=4=leech intersection

    for (npanel = 1; npanel < MAX_PANELS-1; npanel++)
    {
        // printf(" ----- FOR panel = %d \n" , npanel);
        exb=0;
        exc =0;
        cnt =0;
        //if (npanel==3) flag=true;

        do
        {
            /** begin the loop for optimising the seam position to fit cloth width */
            cnt++;
            pt = p1[npanel-1] + (clothW-seamW-exb)* leechVP.unit();
            seamSP = CSubSpace(pt, seamV.matrix(), GEOCPP_FROM_BASE);
            p1[npanel] = seamSP.intersect(foot).getp();
            t1[npanel] = 1; // type1=1= foot intersection vertically cut panels

            if (p1[npanel].x() <= tack.x())
            { // last panel
                p1[npanel]=tack;
                t1[npanel]=1;
                p2[npanel]=tack;
                t2[npanel]=2;
                flag=true; // to get out of FOR
            }
            else
            {
                // printf ("normal panel \n");
                p2[npanel] = seamSP.intersect(gaff).getp();
                if (CVector3d(p2[npanel]-head)*gaffV > 0.00001)
                    t2[npanel] = 3;
                else
                {
                    p2[npanel] = seamSP.intersect(luff).getp();
                    t2[npanel] = 2;
                }
            }

            //// fill right side points
            if (t2[npanel-1]==2 && t2[npanel]==2)
            {
                // printf ("full luff \n");
                lay.panel[npanel-1].right.fill(p2[npanel-1], p2[npanel]);
                for (k=0; k<npl; k++)
                    lay.panel[npanel-1].right.point[k]=LuffIntersect(lay.panel[npanel-1].right.point[k], seamV);
            }
            else if ((t2[npanel-1]==3) && (t2[npanel]==2))
            {
                // printf ("gaff-head-luff \n");
                lay.panel[npanel-1].right.fill(p2[npanel-1], head, p2[npanel]);

                for (k=0; k<npl/2; k++)
                    lay.panel[npanel-1].right.point[k]=GaffIntersect(lay.panel[npanel-1].right.point[k], seamV);

                for (k=npl/2+1; k<npl; k++)
                    lay.panel[npanel-1].right.point[k]=LuffIntersect(lay.panel[npanel-1].right.point[k], seamV);
            }
            else
            {
                // printf ("full gaff \n");
                lay.panel[npanel-1].right.fill(p2[npanel-1], p2[npanel]);

                for (k=0; k<npl; k++)
                    lay.panel[npanel-1].right.point[k]=GaffIntersect(lay.panel[npanel-1].right.point[k], seamV);
            }
            //// fill left side points which are all on foot
            lay.panel[npanel-1].left.fill(p1[npanel-1], p1[npanel]);
            for (k=0; k<npl; k++)
                lay.panel[npanel-1].left.point[k]=FootIntersect(lay.panel[npanel-1].left.point[k], leechV);

            // fill bottom points
            lay.panel[npanel-1].bottom.fill(lay.panel[npanel-1].left.point[0], lay.panel[npanel-1].right.point[0]);
            if (npanel == 1)
            {
                // bottom is on the leech
                for (k=0; k<npb; k++)
                    lay.panel[npanel-1].bottom.point[k]=LeechIntersect(lay.panel[npanel-1].bottom.point[k], leechVP);
            }

            //// fill top side points on seam
            lay.panel[npanel-1].top.fill(lay.panel[npanel-1].left.point[npl-1], lay.panel[npanel-1].right.point[npl-1]);
            /* Now we go over all the points and calculate their z */
            for( k = 0; k < npl; k ++)
                lay.panel[npanel-1].left.point[k] = Zpoint(lay.panel[npanel-1].left.point[k]);
            for( k = 0; k < npl; k ++)
                lay.panel[npanel-1].right.point[k] = Zpoint(lay.panel[npanel-1].right.point[k]);
            for( k = 0; k < npb; k ++)
                lay.panel[npanel-1].top.point[k] = Zpoint(lay.panel[npanel-1].top.point[k]);
            for( k = 0; k < npb; k ++)
                lay.panel[npanel-1].bottom.point[k] = Zpoint(lay.panel[npanel-1].bottom.point[k]);

            /** Now we develop the current panel */
            if (npanel == 1)
                dev.panel[npanel-1] = lay.panel[npanel-1].develop(ALIGN_TOP);
            else
            {
                dev.panel[npanel-1] = lay.panel[npanel-1].develop(ALIGN_BOTTOM);
                // add deviation of previous panel top edge to bottom edge
                for( k = 1; k < npb-1; k ++)
                    dev.panel[npanel-1].bottom.point[k] = dev.panel[npanel-1].bottom.point[k] + deviaPrev[k];
            }

            /** Now we compute the deviation of top edge of developed panel
            *   and straighten this top edge except if this is the top panel
            */
            if (flag == false)
            {
                vb= CMatrix::rot3d(2,PI/2)*CVector3d(dev.panel[npanel-1].top.point[npb-1] -dev.panel[npanel-1].top.point[0]).unit();
                for( k = 1; k < npb-1; k ++)
                {
                    vk= CVector3d (dev.panel[npanel-1].top.point[k] - dev.panel[npanel-1].top.point[0]);
                    v= vb * -(vk*vb);
                    deviation[k] = v;
                    dev.panel[npanel-1].top.point[k] = dev.panel[npanel-1].top.point[k] + deviation[k];
                }
            }

            /** Now we add the seam and hems allowance */
            if (npanel == 1)
                dev.panel[npanel-1].addHems(hemsW, seamW, hemsW, leechHemW);
            else if(flag == true)
                dev.panel[npanel-1].addHems(hemsW, hemsW, hemsW, 0);
            else
                dev.panel[npanel-1].addHems(hemsW, seamW, hemsW, 0);

            /** Now we check the width of developed panel */
            ymax = dev.panel[npanel-1].height();
            exc= ymax-clothW; // current excess of width

            exb= exb + .8*exc +1; // sum previous correction + 80% of current excess of width +1mm

        }
        while ( exc > 0 && cnt<9);
        /** loop DO as long as the excess of width is positive  AND counter <9 */
        /////////////////////////////////////////

        for (k=0; k<npb; k++)
            deviaPrev[k] = deviation[k];

        /** Now we reposition the developed panel such that bottom left is X=0 Y=0 */
        dev.panel[npanel-1] = dev.panel[npanel-1].reframe(LOW_LEFT);

        /** check if peak has been reached to break off */
        if (flag == true)
            break;

    } /** loop FOR next seam */
    /////////////////////////////////////////

    if (npanel == MAX_PANELS-1)
        throw CException("CSailDef::Layout3 : got to MAX_PANELS without reaching tack, do increase cloth width ");

    /* copying the sails for display */
    CSail sail(npanel);
    for( j = 0; j < npanel; j ++)
        sail.panel[j] = lay.panel[j];

    /** copying the developed sail into flatsail */
    flatsail = CSail(npanel);

    for (j=0; j < npanel; j++)
        flatsail.panel[j] = dev.panel[j];

    /** preparing the displays version of the developed sail */
    dispsail = flatsail;

    for (j=1; j < npanel; j++)
    {
        top = dispsail.panel[j-1].top.point[0];
        bot = dispsail.panel[j].bottom.point[0];

        // translation v to align panel bottom edge origin to previous panel upper edge origin
        v = top;
        v.x() -= bot.x();
        v.y() += 2*seamW +10; // adding offset to separate panels vertically

        dispsail.panel[j] = dispsail.panel[j] + v;
    }

    return sail;
} ///////////// end layout vertical cut ////////////////////////////////


Generated by  Doxygen 1.6.0   Back to index