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

void CPanel::addHems ( const real &  lw,
const real &  tw,
const real &  rw,
const real &  bw 
)

Add the cloth for stitching to the edges of the panel. This create the panel to be cut (outside the basic panel) lw = width to be added on left side tw = width to be added on top side rw = width to be added on right side bw = width to be added on bottom side

Move the basic left edge points to the cut line

Move the basic right edge points to the cut line

Move the basic bottom edge points to the cut line

Move the basic top edge points to the cut line

Now we rejoin the 4 corners of the cut panel the case were all sides are nuls need to be handled

Rejoining the bottom corners

Rejoining the upper corners

Definition at line 480 of file sail.cpp.

References bottom, cutBottom, cutLeft, cutRight, cutTop, CSubSpace::getp(), hasHems, CSubSpace::intersect(), left, CVector::matrix(), CSide::nbpoints(), CSide::point, right, CMatrix::rot3d(), top, and CVector::unit().

{
    // the panel will have hems added to its edges
    hasHems = true;

    CPoint3d pt = CPoint3d(0,0,0);
    CVector3d v = CVector3d(0,0,0);
    CVector3d v0=v, v1=v, v2=v, v3=v, v4=v, v5=v, v6=v;
    CSubSpace l1, l2;
    real dw;
    unsigned int i=0, npl=left.nbpoints(), npb=bottom.nbpoints();

    /** Move the basic left edge points to the cut line */
    // left lower part
    v1 = CVector3d(left.point[npl/2] - left.point[0]);
    if (v1.norm()>0.1)
    { // side is not a point
        for (i=0; i<(npl/2 +1); i++)
        {
            if (i==0)
                v = CVector3d(left.point[1] - left.point[0]);
            else
                v = CVector3d(left.point[i] - left.point[i-1]);

            cutLeft.point[i] = left.point[i] + CMatrix::rot3d(2,PI/2) * v.unit() *lw;
        }
    }
    else
    { // lower left cut is same as basic edge
        for (i=0; i<npl/2+1; i++)
            cutLeft.point[i] = left.point[i];
    }

    // left upper part
    v2 = CVector3d(left.point[npl-1] - left.point[npl/2]);
    if (v2.norm()>0.1 )
    { // left side is not a point and width of material is not small
        for (i=npl/2; i<npl; i++)
        {
            if (i==npl/2)
            { // mid side break point
                v0 = CVector3d(left.point[npl/2+1]-left.point[npl/2]).unit();
                v = v0 + CVector3d(left.point[npl/2]-left.point[npl/2-1]).unit();
                dw = lw /(v.unit() * v0.unit());
                cutLeft.point[i] = left.point[i] + CMatrix::rot3d(2,PI/2) * v.unit() *dw;
            }
            else
            {
                v = CVector3d(left.point[i] - left.point[i-1]);
                cutLeft.point[i] = left.point[i] + CMatrix::rot3d(2,PI/2) * v.unit() *lw;
            }
        }
    }
    else
    { // upper left cut is same as basic edge
        for (i=npl/2+1; i<npl; i++)
            cutLeft.point[i] = left.point[i];
    }

    /** Move the basic right edge points to the cut line */
    // right lower part
    v3 = CVector3d(right.point[npl/2] - right.point[0]);
    if (v3.norm()>0.1 )
    { // side is not a point and width of material is not small
        for (i=0; i<(npl/2 +1); i++)
        {
            if (i==0)
                v = CVector3d(right.point[1] - right.point[0]);
            else
                v = CVector3d(right.point[i] - right.point[i-1]);

            cutRight.point[i] = right.point[i] + CMatrix::rot3d(2,-PI/2) * v.unit() *rw;
        }
    }
    else
    { // lower right cut is same as basic edge
        for (i=0; i<npl/2+1; i++)
            cutRight.point[i] = right.point[i];
    }

    // right upper part
    v4 = CVector3d(right.point[npl-1] - right.point[npl/2]);
    if (v4.norm()>0.1 )
    { // side is not a point and width of material is not small
        for (i=npl/2; i<npl; i++)
        {
            if (i==npl/2)
            {
                v0 = CVector3d(right.point[npl/2+1] - right.point[npl/2]).unit();
                v = v0 + CVector3d(right.point[npl/2] - right.point[npl/2-1]).unit();
                dw = rw /(v.unit() * v0.unit());
                cutRight.point[i] = right.point[i] + CMatrix::rot3d(2,-PI/2) * v.unit() *dw;
            }
            else
            {
                v = CVector3d(right.point[i] - right.point[i-1]);
                cutRight.point[i] = right.point[i] + CMatrix::rot3d(2,-PI/2) * v.unit() *rw;
            }
        }
    }
    else
    { // upper right cut is same as basic edge
        for (i=npl/2; i<npl; i++)
            cutRight.point[i] = right.point[i];
    }

    /** Move the basic bottom edge points to the cut line */
    v5 = CVector3d(bottom.point[npb-1] - bottom.point[0]);
    if (v5.norm()>1 && bw>0)
    { // side is not a point and width of material is not small
        for (i=0; i<npb; i++)
        {
            if (i==0)
                v = CVector3d(bottom.point[1] - bottom.point[0]);
            else
                v = CVector3d(bottom.point[i] - bottom.point[i-1]);

            cutBottom.point[i] = bottom.point[i] + CMatrix::rot3d(2,-PI/2) * v.unit() *bw;
        }
    }
    else
    { // bottom cut is same as basic edge
        for (i=0; i<npb; i++)
            cutBottom.point[i] = bottom.point[i];
    }

    /** Move the basic top edge points to the cut line */
    v6 = CVector3d(top.point[npb-1] - top.point[0]);
    if (v6.norm()>1 && tw>0)
    { // side is not a point and width of material is not small
        for (i=0; i<npb; i++)
        {
            if (i==0)
                v = CVector3d(top.point[1] - top.point[0]);
            else
                v = CVector3d(top.point[i] - top.point[i-1]);

            cutTop.point[i] = top.point[i] + CMatrix::rot3d(2,PI/2) * v.unit() *tw;
        }
    }
    else
    { // top cut is same as basic edge
        for (i=0; i<npb; i++)
            cutTop.point[i] = top.point[i];
    }

    /** Now we rejoin the 4 corners of the cut panel
     * the case were all sides are nuls need to be handled
     */
    /** Rejoining the bottom corners */ //////////////////////
    if (v5.norm()>1)
    {
        // lower left
        v = CVector3d(cutBottom.point[1]-cutBottom.point[0]);
        l1= CSubSpace(cutBottom.point[0],v.matrix(),GEOCPP_FROM_BASE);
        if (v1.norm()>.1)
        {
            v = CVector3d(cutLeft.point[1]-cutLeft.point[0]);
            l2= CSubSpace(cutLeft.point[0],v.matrix(),GEOCPP_FROM_BASE);
        }
        else if (v2.norm()>.1)
        {
            v = CVector3d(cutLeft.point[npl/2+1]-cutLeft.point[npl/2]);
            l2= CSubSpace(cutLeft.point[npl/2],v.matrix(),GEOCPP_FROM_BASE);
        }
        else
        {
            if (v6.norm()>1)
            {
                v = CVector3d(cutTop.point[1]-cutTop.point[0]);
                l2= CSubSpace(cutTop.point[0],v.matrix(),GEOCPP_FROM_BASE);
            }
        }

        /* Compute the lower left intersection point of the cut edges */
        pt = l1.intersect(l2).getp();
        /* Adjust the lower left point [0] to be at intersection */
        cutBottom.point[0]=pt;
        cutLeft.point[0]=pt;
        if ((v1+v2).norm()<1)
        {
            for (i=1; i<npl;i++)
                cutLeft.point[i]=pt;
        }
        /* Scan the first few points of the cut edges to make sure
           * that they are not on the wrong side of the point pt
           */
        for (i=1; i<npl/2; i++)
        {
            if ((CVector3d(cutLeft.point[i] - pt) * v1) <=0)
                CVector3d(cutLeft.point[i])=pt;

            if ((CVector3d(cutBottom.point[i] - pt) * v5) <=0)
                CVector3d(cutBottom.point[i])=pt;
        }

        // lower right
        v = CVector3d(cutBottom.point[npb-1]-cutBottom.point[npb-2]);
        l1= CSubSpace(cutBottom.point[npb-1],v.matrix(),GEOCPP_FROM_BASE);
        if (v3.norm()>.1)
        {
            v = CVector3d(cutRight.point[1]-cutRight.point[0]);
            l2= CSubSpace(cutRight.point[0],v.matrix(),GEOCPP_FROM_BASE);
        }
        else if (v4.norm()>.1)
        {
            v = CVector3d(cutRight.point[npl/2+1]-cutRight.point[npl/2]);
            l2= CSubSpace(cutRight.point[npl/2],v.matrix(),GEOCPP_FROM_BASE);
        }
        else
        {
            if (v6.norm()>1)
            {
                v = CVector3d(cutTop.point[npb-1]-cutTop.point[npb-2]);
                l2= CSubSpace(cutTop.point[npb-1],v.matrix(),GEOCPP_FROM_BASE);
            }
        }

        /* Compute the intersection point of the cut edges */
        pt = l1.intersect(l2).getp();
        /* Adjust the lower right point to be at intersection */
        cutBottom.point[npb-1]=pt;
        cutRight.point[0]=pt;
        if ((v3+v4).norm()<1)
        {
            for (i=1; i<npl; i++)
                cutRight.point[i]=pt;
        }
        /* Scan the first few points of the cut edges to make sure
           * that they are not on the wrong side of the point pt
           */
        for (i=1; i<npl/2; i++)
        {
            if ((CVector3d(cutRight.point[i] - pt) * v3) <=0)
                CVector3d(cutRight.point[i])=pt;

            if ((CVector3d(cutBottom.point[npb-1-i] - pt) * v5) >=0)
                CVector3d(cutBottom.point[npb-1-i])=pt;
        }
    }
    else
    { // bottom edge is a point
        if (v1.norm()>.1)
        {
            v = CVector3d(cutLeft.point[1]-cutLeft.point[0]);
            l1= CSubSpace(cutLeft.point[0],v.matrix(),GEOCPP_FROM_BASE);
        }
        else if (v2.norm()>.1)
        {
            v = CVector3d(cutLeft.point[npl/2+1]-cutLeft.point[npl/2]);
            l1= CSubSpace(cutLeft.point[npl/2],v.matrix(),GEOCPP_FROM_BASE);
        }

        if (v3.norm()>.1)
        {
            v = CVector3d(cutRight.point[1]-cutRight.point[0]);
            l2= CSubSpace(cutRight.point[0],v.matrix(),GEOCPP_FROM_BASE);
        }
        else if (v4.norm()>.1)
        {
            v = CVector3d(cutRight.point[npl/2+1]-cutRight.point[npl/2]);
            l2= CSubSpace(cutRight.point[npl/2],v.matrix(),GEOCPP_FROM_BASE);
        }

        /* Compute the intersection point of the 2 side edges */
        pt = l1.intersect(l2).getp();

        for (i=0; i<npb; i++)
        { /* Adjust the bottom edge to be at intersection */
            cutBottom.point[i]=pt;
        }

        /* Adjust the lower left point [0] to be at intersection */
        cutLeft.point[0]=pt;
        for (i=1; i<npl/2; i++)
        { /* Scan the first few points of the cut edges to make sure
                      * that they are not on the wrong side of the intersect point pt
                      */
            if ((CVector3d(cutLeft.point[i] - pt) * v1) <=0)
                CVector3d(cutLeft.point[i])=pt;
        }

        /* Adjust the lower right point to be at intersection */
        cutRight.point[0]=pt;
        /* Scan the first few points of the cut edges to make sure
           * that they are not on the wrong side of the intersect point pt
           */
        for (i=1; i<npl/2; i++)
        {
            if ((CVector3d(cutRight.point[i] - pt) * v3) <=0)
                CVector3d(cutRight.point[i])=pt;
        }

    } // end else bottom is a point


    /** Rejoining the upper corners */ //////////////////////
    if (v6.norm()>1)
    {
        // upper left
        v = CVector3d(cutTop.point[1]-cutTop.point[0]);
        l1= CSubSpace(cutTop.point[0],v.matrix(),GEOCPP_FROM_BASE);
        if (v2.norm()>.1)
        {
            v = CVector3d(cutLeft.point[npl-1]-cutLeft.point[npl-2]);
            l2= CSubSpace(cutLeft.point[npl-1],v.matrix(),GEOCPP_FROM_BASE);
        }
        else if (v1.norm()>.1)
        {
            v = CVector3d(cutLeft.point[npl/2]-cutLeft.point[npl/2 -1]);
            l2= CSubSpace(cutLeft.point[npl/2],v.matrix(),GEOCPP_FROM_BASE);
        }
        else
        {
            if (v5.norm()>1)
            {
                v = CVector3d(cutBottom.point[1]-cutBottom.point[0]);
                l2= CSubSpace(cutBottom.point[npb-1],v.matrix(),GEOCPP_FROM_BASE);
            }
        }

        /* Compute the intersection point of the cut edges */
        pt = l1.intersect(l2).getp();
        /* Adjust the upper left point to be at intersection */
        cutTop.point[0]=pt;
        cutLeft.point[npl-1]=pt;

        /* Scan the first few points of the cut edges to make sure
           * that they are not on the wrong side of the intersect point pt
           */
        for (i=1; i<npl/2; i++)
        {
            if ((CVector3d(cutLeft.point[npl-1-i] - pt) * v2) >=0)
                CVector3d(cutLeft.point[npl-1-i])=pt;
            if ((CVector3d(cutTop.point[i] - pt) * v6) <=0)
                CVector3d(cutTop.point[i])=pt;
        }

        // upper right
        v = CVector3d(cutTop.point[npb-1]-cutTop.point[npb-2]);
        l1= CSubSpace(cutTop.point[npb-1],v.matrix(),GEOCPP_FROM_BASE);
        if (v4.norm()>.1)
        {
            v = CVector3d(cutRight.point[npl-1]-cutRight.point[npl-2]);
            l2= CSubSpace(cutRight.point[npl-1],v.matrix(),GEOCPP_FROM_BASE);
        }
        else if (v3.norm()>.1)
        {
            v = CVector3d(cutRight.point[npl/2]-cutRight.point[npl/2-1]);
            l2= CSubSpace(cutRight.point[npl/2],v.matrix(),GEOCPP_FROM_BASE);
        }
        else
        {
            if (v5.norm()>1)
            {
                v = CVector3d(cutBottom.point[npb-1]-cutBottom.point[npb-2]);
                l2= CSubSpace(cutBottom.point[npb-1],v.matrix(),GEOCPP_FROM_BASE);
            }
        }

        /* Compute the intersection point of the cut edges */
        pt = l1.intersect(l2).getp();
        /* Adjust the upper right point to be at intersection */
        cutTop.point[npb-1]=pt;
        cutRight.point[npl-1]=pt;

        /* Scan the first few points of the cut edges to make sure
           * that they are not on the wrong side of the intersect point pt
           */
        for (i=1; i<npl/2; i++)
        {
            if ((CVector3d(cutRight.point[npl-1-i] - pt) * v4) >=0)
                CVector3d(cutRight.point[npl-1-i])=pt;

            if ((CVector3d(cutTop.point[npb-1-i] - pt) * v6) >=0)
                CVector3d(cutTop.point[npb-1-i])=pt;
        }
    }
    else
    { // top edge is a point
        if (v2.norm()>.1)
        {
            v = CVector3d(cutLeft.point[npl-1]-cutLeft.point[npl-2]);
            l1= CSubSpace(cutLeft.point[npl-1],v.matrix(),GEOCPP_FROM_BASE);
        }
        else if (v1.norm()>.1)
        {
            v = CVector3d(cutLeft.point[npl/2]-cutLeft.point[npl/2 -1]);
            l1= CSubSpace(cutLeft.point[npl/2],v.matrix(),GEOCPP_FROM_BASE);
        }

        if (v4.norm()>.1)
        {
            v = CVector3d(cutRight.point[npl-1]-cutRight.point[npl-2]);
            l2= CSubSpace(cutRight.point[npl-1],v.matrix(),GEOCPP_FROM_BASE);
        }
        else if (v3.norm()>.1)
        {
            v = CVector3d(cutRight.point[npl/2]-cutRight.point[npl/2-1]);
            l2= CSubSpace(cutRight.point[npl/2],v.matrix(),GEOCPP_FROM_BASE);
        }

        /* Compute the intersection point of the 2 side edges */
        pt = l1.intersect(l2).getp();

        /* Adjust the top edge to be at intersection */
        for (i=0; i<npb; i++)
        {
            cutTop.point[i]=pt;
        }

        /* Adjust the upper left point to be at intersection */
        cutTop.point[0]=pt;
        cutLeft.point[npl-1]=pt;

        /* Scan the first few points of the cut edges to make sure
           * that they are not on the wrong side of the intersect point pt
           */
        for (i=1; i<npl/2; i++)
        {
            if ((CVector3d(cutLeft.point[npl-1-i] - pt) * v2) >=0)
                CVector3d(cutLeft.point[npl-1-i])=pt;
        }

        /* Adjust the upper right point to be at intersection */
        cutTop.point[npb-1]=pt;
        cutRight.point[npl-1]=pt;

        /* Scan the first few points of the cut edges to make sure
           * that they are not on the wrong side of the intersect point pt
           */
        for (i=1; i<npl/2; i++)
        {
            if ((CVector3d(cutRight.point[npl-1-i] - pt) * v4) >=0)
                CVector3d(cutRight.point[npl-1-i])=pt;
        }
    } // end else top edge is a point
} //// end addHems ////////////////////////////////////////


Generated by  Doxygen 1.6.0   Back to index