コード例 #1
0
ファイル: ossimDrect.cpp プロジェクト: whztt07/star_ossim
//*******************************************************************
// Public Method: ossimDrect::getCode
//*******************************************************************
long ossimDrect::getCode(const ossimDpt& aPoint,
                         const ossimDrect& clipRect)
{
    long result=NONE; // initialize to inside rect

    if( (aPoint.x > clipRect.lr().x) )
        result |= RIGHT;
    else if( (aPoint.x < clipRect.ul().x) )
        result |= LEFT;

    if (clipRect.theOrientMode == OSSIM_LEFT_HANDED)
    {
        if( (aPoint.y < clipRect.ul().y) )
            result |= TOP;
        else if( (aPoint.y > clipRect.lr().y) )
            result |= BOTTOM;
    }
    else
    {
        if( (aPoint.y > clipRect.ul().y) )
            result |= TOP;
        else if( (aPoint.y < clipRect.lr().y) )
            result |= BOTTOM;
    }

    return result;
}
コード例 #2
0
void oms::SingleImageChain::setViewCut(const ossimDrect& rect, bool imageSpaceFlag)
{
   if(!imageSpaceFlag)
   {
      
      const ossimProjection* proj = getViewProjection();
      
      if(proj)
      {
         std::vector<ossimGpt> pointList(4);
         proj->lineSampleToWorld(rect.ul(), pointList[0]);
         proj->lineSampleToWorld(rect.ur(), pointList[1]);
         proj->lineSampleToWorld(rect.lr(), pointList[2]);
         proj->lineSampleToWorld(rect.ll(), pointList[3]);
         setViewCut(pointList);
      }
   }
   else
   {
      std::vector<ossimDpt> pointList(4);
      pointList[0] = rect.ul();
      pointList[1] = rect.ur();
      pointList[2] = rect.lr();
      pointList[3] = rect.ll();
      theViewCutter->setEnableFlag(false);
      theViewImageCutter->setEnableFlag(true);
      theViewImageCutter->setPolygon(pointList);
      theViewImageCutter->initialize();
      ossimPropertyEvent evt(theViewImageCutter);
      theViewImageCutter->propagateEventToOutputs(evt);
   }
}
コード例 #3
0
ファイル: ossimDrect.cpp プロジェクト: whztt07/star_ossim
//*******************************************************************
// 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);
}
コード例 #4
0
ファイル: ossimDrect.cpp プロジェクト: whztt07/star_ossim
//*******************************************************************
// 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;
}
コード例 #5
0
void ossimQuadTreeWarp::create(const ossimDrect& boundingRect,
                               const ossimDpt& ulShift,
                               const ossimDpt& urShift,
                               const ossimDpt& lrShift,
                               const ossimDpt& llShift)
{
   clear();

   theTree = new ossimQuadTreeWarpNode(boundingRect);

   ossimQuadTreeWarpVertex* ul = new ossimQuadTreeWarpVertex(boundingRect.ul(),
                                                             ulShift);
   ossimQuadTreeWarpVertex* ur = new ossimQuadTreeWarpVertex(boundingRect.ur(),
                                                             urShift);
   ossimQuadTreeWarpVertex* lr = new ossimQuadTreeWarpVertex(boundingRect.lr(),
                                                             lrShift);
   ossimQuadTreeWarpVertex* ll = new ossimQuadTreeWarpVertex(boundingRect.ll(),
                                                             llShift);
   ul->addSharedNode(theTree);
   ur->addSharedNode(theTree);
   lr->addSharedNode(theTree);
   ll->addSharedNode(theTree);

   theVertexList.push_back(ul);
   theVertexList.push_back(ur);
   theVertexList.push_back(lr);
   theVertexList.push_back(ll);
   
   theTree->theUlVertex = ul;
   theTree->theUrVertex = ur;
   theTree->theLrVertex = lr;
   theTree->theLlVertex = ll;
   
}
コード例 #6
0
bool ossimPolygon::isInsideEdge(const ossimDpt& pt,
                                const ossimDrect& rect,
                                int edge)const
{
   switch(edge)
   {
   case RECT_LEFT_EDGE:
   {
      return (pt.x>rect.ul().x);
      break;
   }
   case RECT_TOP_EDGE:
   {
      if(rect.orientMode() == OSSIM_LEFT_HANDED)
      {
         return (pt.y > rect.ul().y);
      }
      else
      {
         return (pt.y < rect.ul().y);
      }
      break;
   }
   case RECT_RIGHT_EDGE:
   {
      return (pt.x<rect.lr().x);
      
      break;
   }
   case RECT_BOTTOM_EDGE:
   {
      if(rect.orientMode() == OSSIM_LEFT_HANDED)
      {
         return (pt.y < rect.lr().y);
      }
      else
      {
         return (pt.y > rect.lr().y);
      }
      break;
   }
   }
   return false;
}
コード例 #7
0
void oms::SingleImageChain::setImageCut(const ossimDrect& rect)
{
   std::vector<ossimDpt> pointList(4);
   pointList[0] = rect.ul();
   pointList[1] = rect.ur();
   pointList[2] = rect.lr();
   pointList[3] = rect.ll();
   
   setImageCut(pointList);
}
コード例 #8
0
ossimPolygon::ossimPolygon(const ossimDrect& rect)
   : theVertexList(4),
     theCurrentVertex(0),
     theOrderingType(OSSIM_CLOCKWISE_ORDER)
{
   theVertexList[0] = rect.ul();
   theVertexList[1] = rect.ur();
   theVertexList[2] = rect.lr();
   theVertexList[3] = rect.ll();
}
コード例 #9
0
bool ossimPolygon::clipToRect(vector<ossimPolygon>& result,
                              const ossimDrect& rect)const
{
   result.clear();
   ossimPolyArea2d p1(*this);
   ossimPolyArea2d p2(rect.ul(), rect.ur(), rect.lr(), rect.ll());
   
   p1&=p2;

   p1.getVisiblePolygons(result);

   return (result.size() > 0);
}   
コード例 #10
0
ossimDrect ossimImageViewTransform::getImageToViewBounds(const ossimDrect& imageRect)const
{
    ossimDpt p1;
    ossimDpt p2;
    ossimDpt p3;
    ossimDpt p4;

    imageToView(imageRect.ul(), p1);
    imageToView(imageRect.ur(), p2);
    imageToView(imageRect.lr(), p3);
    imageToView(imageRect.ll(), p4);

    return ossimDrect(p1, p2, p3, p4);
}
コード例 #11
0
void ossimPolygon::intersectEdge(ossimDpt& result,
                                 const ossimLine& segment,
                                 const ossimDrect& rect,
                                 int edge)
{
   ossimLine edgeLine;
   switch(edge)
   {
   case RECT_LEFT_EDGE:
   {
      edgeLine.theP1 = rect.ll();
      edgeLine.theP2 = rect.ul();
      break;
   }
   case RECT_TOP_EDGE:
   {
      edgeLine.theP1 = rect.ul();
      edgeLine.theP2 = rect.ur();
      break;
   }
   case RECT_RIGHT_EDGE:
   {
      edgeLine.theP1 = rect.ur();
      edgeLine.theP2 = rect.lr();
      break;
   }
   case RECT_BOTTOM_EDGE:
   {
      edgeLine.theP1 = rect.lr();
      edgeLine.theP2 = rect.ll();
      break;
   }
   }
   
   result = segment.intersectInfinite(edgeLine);
}
コード例 #12
0
//**************************************************************************************************
// Converts the local image space rect into bounding view-space rect
//**************************************************************************************************
ossimDrect ossimImageViewProjectionTransform::getImageToViewBounds(const ossimDrect& imageRect)const
{
    // Let base class try:
   ossimDrect result = ossimImageViewTransform::getImageToViewBounds(imageRect);

   // If not successful, compute using input and output geometries:
   if (result.hasNans() && m_imageGeometry.valid() && m_viewGeometry.valid() &&
       m_imageGeometry->hasProjection() && m_viewGeometry->hasProjection())
   {
      ossimGeoPolygon viewClip;
      m_viewGeometry->getProjection()->getGroundClipPoints(viewClip);
      if(viewClip.size())
      {
         std::vector<ossimGpt> imageGpts(4);
         m_imageGeometry->localToWorld(imageRect.ul(), imageGpts[0]);
         m_imageGeometry->localToWorld(imageRect.ur(), imageGpts[1]);
         m_imageGeometry->localToWorld(imageRect.lr(), imageGpts[2]);
         m_imageGeometry->localToWorld(imageRect.ll(), imageGpts[3]);

         const ossimDatum* viewDatum = m_viewGeometry->getProjection()->origin().datum();
         imageGpts[0].changeDatum(viewDatum);
         imageGpts[1].changeDatum(viewDatum);
         imageGpts[2].changeDatum(viewDatum);
         imageGpts[3].changeDatum(viewDatum);
         
         ossimPolyArea2d viewPolyArea(viewClip.getVertexList());
         ossimPolyArea2d imagePolyArea(imageGpts);
         viewPolyArea &= imagePolyArea;
         std::vector<ossimPolygon> visiblePolygons;
         viewPolyArea.getVisiblePolygons(visiblePolygons);
         if(visiblePolygons.size())
         {
            std::vector<ossimDpt> vpts;
            ossim_uint32 idx = 0;
            for(idx=0; idx<visiblePolygons[0].getNumberOfVertices();++idx)
            {
               ossimDpt tempPt;
               ossimGpt gpt(visiblePolygons[0][idx].lat, visiblePolygons[0][idx].lon, 0.0,  viewDatum);
               m_viewGeometry->worldToLocal(gpt, tempPt);
               vpts.push_back(tempPt);
            }
            result = ossimDrect(vpts);
         }
      }
   }
   return result;
}
コード例 #13
0
ファイル: ossimDrect.cpp プロジェクト: whztt07/star_ossim
//*******************************************************************
// 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;
}
コード例 #14
0
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;
        }
    }
}
コード例 #15
0
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;
        }
    }
}
コード例 #16
0
void ossimQuadTreeWarp::getNewQuads(ossimQuadTreeWarpNode* parent,
                                    const ossimDrect& ul,
                                    const ossimDrect& ur,
                                    const ossimDrect& lr,
                                    const ossimDrect& ll,
                                    ossimQuadTreeWarpNode*& ulNode,
                                    ossimQuadTreeWarpNode*& urNode,
                                    ossimQuadTreeWarpNode*& lrNode,
                                    ossimQuadTreeWarpNode*& llNode)
{
   ossimDpt midShift;
   getShift(midShift,
            parent,
            ul.lr());
   
   ossimQuadTreeWarpVertex* midV = new ossimQuadTreeWarpVertex(ul.lr(),
                                                               midShift);

   ulNode = new ossimQuadTreeWarpNode(ul,
                                      parent);
   urNode = new ossimQuadTreeWarpNode(ur,
                                      parent);
   lrNode = new ossimQuadTreeWarpNode(lr,
                                      parent);
   llNode = new ossimQuadTreeWarpNode(ll,
                                      parent);

   midV->addSharedNode(ulNode);
   midV->addSharedNode(urNode);
   midV->addSharedNode(lrNode);
   midV->addSharedNode(llNode);
   
   // get the shared vertices first.  We will add ourself
   // to the pointer list. when we construct
   // the quad nodes.  Note the mid point will be shared
   // by all quads and will be marked as adjustable
   //
   ossimQuadTreeWarpVertex* ulSharedV = getVertex(ul.ul());
   ossimQuadTreeWarpVertex* urSharedV = getVertex(ur.ur());
   ossimQuadTreeWarpVertex* lrSharedV = getVertex(lr.lr());
   ossimQuadTreeWarpVertex* llSharedV = getVertex(ll.ll());
   
   if(!ulSharedV||
      !urSharedV||
      !lrSharedV||
      !llSharedV)
   {
      ossimNotify(ossimNotifyLevel_FATAL) << "FATAL: " << "ossimQuadTreeWarp::split, can't locating shared vertices.  This Shouldn't happen!!!\n";
      return;
   }

   // we know that the midpoint is new and is shared by all quads
   // so we have 2 more to check
   ossimQuadTreeWarpVertex* topSharedV    = getVertex(ul.ur());
   ossimQuadTreeWarpVertex* bottomSharedV = getVertex(lr.ll());

   ossimQuadTreeWarpVertex* leftSharedV   = getVertex(ul.ll());
   ossimQuadTreeWarpVertex* rightSharedV  = getVertex(ur.lr());
   
   ossimDpt tempShift;
   
   if(!topSharedV)
   {
      getShift(tempShift, parent, ul.ur());
      topSharedV = new ossimQuadTreeWarpVertex(ul.ur(),
                                               tempShift);
      theVertexList.push_back(topSharedV);
   }
   if(!bottomSharedV)
   {
      getShift(tempShift, parent, ll.lr());
      bottomSharedV = new ossimQuadTreeWarpVertex(ll.lr(),
                                                  tempShift);
      
      theVertexList.push_back(bottomSharedV);
   }
   if(!leftSharedV)
   {
      getShift(tempShift, parent, ul.ll());
      leftSharedV = new ossimQuadTreeWarpVertex(ul.ll(),
                                               tempShift);
      theVertexList.push_back(leftSharedV);
   }
   if(!rightSharedV)
   {
      getShift(tempShift, parent, ur.lr());
      rightSharedV = new ossimQuadTreeWarpVertex(ur.lr(),
                                               tempShift);
      theVertexList.push_back(rightSharedV);
   }
   theVertexList.push_back(midV);

   topSharedV->addSharedNode(ulNode);
   topSharedV->addSharedNode(urNode);
   
   bottomSharedV->addSharedNode(llNode);
   bottomSharedV->addSharedNode(lrNode);
   leftSharedV->addSharedNode(ulNode);
   leftSharedV->addSharedNode(llNode);
   rightSharedV->addSharedNode(urNode);
   rightSharedV->addSharedNode(lrNode);

   ulSharedV->addSharedNode(ulNode); 
   urSharedV->addSharedNode(urNode);
   lrSharedV->addSharedNode(lrNode);
   llSharedV->addSharedNode(llNode);
  
   ulNode->theUlVertex = ulSharedV;
   ulNode->theUrVertex = topSharedV;
   ulNode->theLrVertex = midV;
   ulNode->theLlVertex = leftSharedV;

   urNode->theUlVertex = topSharedV;
   urNode->theUrVertex = urSharedV;
   urNode->theLrVertex = rightSharedV;
   urNode->theLlVertex = midV;

   lrNode->theUlVertex = midV;
   lrNode->theUrVertex = rightSharedV;
   lrNode->theLrVertex = lrSharedV;
   lrNode->theLlVertex = bottomSharedV;

   llNode->theUlVertex = leftSharedV;
   llNode->theUrVertex = midV;
   llNode->theLrVertex = bottomSharedV;
   llNode->theLlVertex = llSharedV;   
}