Exemplo n.º 1
0
//*******************************************************************
// Public Method:
//*******************************************************************
bool ossimDrect::intersects(const ossimDrect& rect) const
{
    if(rect.hasNans() || hasNans())
    {
        return false;
    }
    if (theOrientMode != rect.theOrientMode)
        return false;

    ossim_float64  ulx = ossim::max(rect.ul().x,ul().x);
    ossim_float64  lrx = ossim::min(rect.lr().x,lr().x);
    ossim_float64  uly, lry;
    bool rtn=false;
    if (theOrientMode == OSSIM_LEFT_HANDED)
    {
        uly  = ossim::max(rect.ul().y,ul().y);
        lry  = ossim::min(rect.lr().y,lr().y);
        rtn = ((ulx <= lrx) && (uly <= lry));
    }
    else
    {
        uly  = ossim::max(rect.ll().y,ll().y);
        lry  = ossim::min(rect.ur().y,ur().y);
        rtn = ((ulx <= lrx) && (uly <= lry));
    }

    return (rtn);
}
Exemplo n.º 2
0
//*******************************************************************
// Public Method: ossimDrect::completely_within
//*******************************************************************
bool ossimDrect::completely_within(const ossimDrect& rect) const
{
    if(hasNans() || rect.hasNans())
    {
        return false;
    }
    if (theOrientMode != rect.theOrientMode)
        return false;

    /*  --------------
        |     1      |
        | ---------- |
        | |        | |
        | |        | |
        | |   2    | |
        | |        | |
        | |        | |
        | ---------- |
        |            |
        --------------  */

    bool rtn = true;

    if (theUlCorner.x < rect.ul().x)
        rtn = false;

    else if (theLrCorner.x > rect.lr().x)
        rtn = false;

    else if (theOrientMode == OSSIM_LEFT_HANDED)
    {
        if (theUlCorner.y < rect.ul().y)
            rtn = false;

        else if (theLrCorner.y > rect.lr().y)
            rtn = false;
    }

    else
    {
        if (theUlCorner.y > rect.ul().y)
            rtn = false;

        else if (theLrCorner.y < rect.lr().y)
            rtn = false;
    }

    return rtn;
}
bool ossimAnnotationMultiPolyObject::intersects(const ossimDrect& rect)const
{
    // do the quick checks first
    //
    if(rect.hasNans()) return false;
    if(!rect.intersects(theBoundingRect)) return false;
    if(theMultiPolygon.size()<1) return false;

    for(ossim_uint32 i =0; i < theMultiPolygon.size(); ++i)
    {
        vector<ossimPolygon> result;

        if(theMultiPolygon[i].clipToRect(result, rect))
        {
            return true;
        }
    }

    return false;
}
Exemplo n.º 4
0
//*******************************************************************
// Public Method: ossimDrect::clipToRect
//*******************************************************************
ossimDrect ossimDrect::clipToRect(const ossimDrect& rect)const
{
    ossimDrect result;
    result.makeNan();
    if(rect.hasNans() || hasNans())
    {

        return result;
    }

    if (theOrientMode != rect.theOrientMode)
        return (*this);

    double x0 = ossim::max(rect.ul().x, ul().x);
    double x1 = ossim::min(rect.lr().x, lr().x);
    double y0, y1;

    if (theOrientMode == OSSIM_LEFT_HANDED)
    {
        y0 = ossim::max(rect.ll().y, ll().y);
        y1 = ossim::min(rect.ur().y, ur().y);

        if( (x1 < x0) || (y1 < y0) )
            return result;
        else
            result = ossimDrect(x0, y0, x1, y1, theOrientMode);
    }
    else
    {
        y0 = ossim::max(rect.ll().y,ll().y);
        y1 = ossim::min(rect.ur().y,ur().y);
        if((x0 <= x1) && (y0 <= y1))
        {
            result = ossimDrect(x0, y1, x1, y0, theOrientMode);
        }
    }
    return result;
}
void ossimImageViewTransform::getScaleChangeImageToView(ossimDpt& result,
        const ossimDrect& imageRect)
{
    result.makeNan();
    if(!imageRect.hasNans())
    {
        ossimDpt vul;
        ossimDpt vur;
        ossimDpt vlr;
        ossimDpt vll;

        imageToView(imageRect.ul(),
                    vul);
        imageToView(imageRect.ur(),
                    vur);
        imageToView(imageRect.lr(),
                    vlr);
        imageToView(imageRect.ll(),
                    vll);

        if(!vul.hasNans()&&
                !vur.hasNans()&&
                !vlr.hasNans()&&
                !vll.hasNans())
        {

            double deltaTop    = (vul - vur).length();
            double deltaBottom = (vll - vlr).length();
            double deltaRight  = (vur - vlr).length();

            double w = imageRect.width();
            double h = imageRect.height();
            result.x = (deltaTop/w + deltaBottom/w)*.5;
            result.y = (deltaRight/h + deltaRight/h)*.5;
        }
    }
}
void ossimImageViewTransform::getScaleChangeViewToImage(ossimDpt& result,
        const ossimDrect& viewRect)
{
    result.makeNan();
    if(!viewRect.hasNans())
    {
        ossimDpt iul;
        ossimDpt iur;
        ossimDpt ilr;
        ossimDpt ill;

        imageToView(viewRect.ul(),
                    iul);
        imageToView(viewRect.ur(),
                    iur);
        imageToView(viewRect.lr(),
                    ilr);
        imageToView(viewRect.ll(),
                    ill);

        if(!iul.hasNans()&&
                !iur.hasNans()&&
                !ilr.hasNans()&&
                !ill.hasNans())
        {

            double deltaTop    = (iul - iur).length();
            double deltaBottom = (ill - ilr).length();
            double deltaRight  = (iur - ilr).length();

            double w = viewRect.width();
            double h = viewRect.height();
            result.x = (deltaTop/w + deltaBottom/w)*.5;
            result.y = (deltaRight/h + deltaRight/h)*.5;
        }
    }
}