Ejemplo n.º 1
0
void Image::Resize(const Extent3D& extent, const ColorRGBAd& fillColor, const Offset3D& offset)
{
    if (extent != GetExtent())
    {
        /* Store ownership of current image buffer in temporary image */
        Image prevImage;

        prevImage.extent_   = GetExtent();
        prevImage.format_   = GetFormat();
        prevImage.dataType_ = GetDataType();
        prevImage.data_     = std::move(data_);

        if ( extent.width  > GetExtent().width  ||
             extent.height > GetExtent().height ||
             extent.depth  > GetExtent().depth )
        {
            /* Resize image buffer with fill color */
            extent_ = extent;
            data_   = GenerateImageBuffer(GetFormat(), GetDataType(), GetNumPixels(), fillColor);
        }
        else
        {
            /* Resize image buffer with uninitialized image buffer */
            extent_ = extent;
            data_   = GenerateEmptyByteBuffer(GetDataSize(), false);
        }

        /* Copy previous image into new image */
        Blit(offset, prevImage, { 0, 0, 0 }, prevImage.GetExtent());
    }
}
Ejemplo n.º 2
0
 void
   PlaneGeometry::SetSizeInUnits(mitk::ScalarType width, mitk::ScalarType height)
 {
   ScalarType bounds[6]={0, width, 0, height, 0, 1};
   ScalarType extent, newextentInMM;
   if(GetExtent(0)>0)
   {
     extent = GetExtent(0);
     if(width>extent)
       newextentInMM = GetExtentInMM(0)/width*extent;
     else
       newextentInMM = GetExtentInMM(0)*extent/width;
     SetExtentInMM(0, newextentInMM);
   }
   if(GetExtent(1)>0)
   {
     extent = GetExtent(1);
     if(width>extent)
       newextentInMM = GetExtentInMM(1)/height*extent;
     else
       newextentInMM = GetExtentInMM(1)*extent/height;
     SetExtentInMM(1, newextentInMM);
   }
   SetBounds(bounds);
 }
Ejemplo n.º 3
0
 void PlaneGeometry::PrintSelf( std::ostream& os, itk::Indent indent ) const
 {
   Superclass::PrintSelf(os,indent);
   os << indent << " ScaleFactorMMPerUnitX: "
     << GetExtentInMM(0) / GetExtent(0) << std::endl;
   os << indent << " ScaleFactorMMPerUnitY: "
     << GetExtentInMM(1) / GetExtent(1) << std::endl;
   os << indent << " Normal: " << GetNormal() << std::endl;
 }
Ejemplo n.º 4
0
void Image::ClampRegion(Offset3D& offset, Extent3D& extent) const
{
    offset.x        = std::max(offset.x, 0);
    offset.y        = std::max(offset.y, 0);
    offset.z        = std::max(offset.z, 0);

    extent.width    = std::min(extent.width, GetExtent().width);
    extent.height   = std::min(extent.height, GetExtent().height);
    extent.depth    = std::min(extent.depth, GetExtent().depth);
}
Ejemplo n.º 5
0
std::size_t Image::GetDataPtrOffset(const Offset3D& offset) const
{
    const auto bpp  = static_cast<std::size_t>(GetBytesPerPixel());
    const auto x    = static_cast<std::size_t>(offset.x);
    const auto y    = static_cast<std::size_t>(offset.y);
    const auto z    = static_cast<std::size_t>(offset.z);
    const auto w    = static_cast<std::size_t>(GetExtent().width);
    const auto h    = static_cast<std::size_t>(GetExtent().height);
    return (bpp * (x + (y + z * h) * w));
}
Ejemplo n.º 6
0
  bool PlaneGeometry::Map(const mitk::Point3D &pt3d_mm, mitk::Point2D &pt2d_mm) const
  {
    assert(this->IsBoundingBoxNull()==false);

    Point3D pt3d_units;
    Superclass::WorldToIndex(pt3d_mm, pt3d_units);
    pt2d_mm[0] = pt3d_units[0] * GetExtentInMM(0) / GetExtent(0);
    pt2d_mm[1] = pt3d_units[1] * GetExtentInMM(1) / GetExtent(1);
    pt3d_units[2]=0;
    return const_cast<BoundingBox*>(this->GetBoundingBox())->IsInside(pt3d_units);
  }
Ejemplo n.º 7
0
void 
mitk::Geometry2D::SetExtentInMM(int direction, ScalarType extentInMM)
{
  Superclass::SetExtentInMM(direction, extentInMM);

  m_ScaleFactorMMPerUnitX=GetExtentInMM(0)/GetExtent(0);
  m_ScaleFactorMMPerUnitY=GetExtentInMM(1)/GetExtent(1);  

  assert(m_ScaleFactorMMPerUnitX<ScalarTypeNumericTraits::infinity());
  assert(m_ScaleFactorMMPerUnitY<ScalarTypeNumericTraits::infinity());
}
Ejemplo n.º 8
0
void CairoFont::GetExtent( const char * s, int charCount, float * outWidth, float * outHeight, VGDevice * dev ) const
{
	if (s[charCount] == 0)
		GetExtent (s, outWidth, outHeight, (cairo_t *)dev->GetNativeContext());
	else {
		char* str = new char[charCount+1];
		memcpy (str, s, charCount);
		str[charCount] = 0;
		GetExtent (str, outWidth, outHeight, (cairo_t *)dev->GetNativeContext());
		delete str;
	}
}
Ejemplo n.º 9
0
void 
mitk::Geometry2D::SetIndexToWorldTransform(
  mitk::AffineTransform3D* transform)
{
  Superclass::SetIndexToWorldTransform(transform);
  
  m_ScaleFactorMMPerUnitX=GetExtentInMM(0)/GetExtent(0);
  m_ScaleFactorMMPerUnitY=GetExtentInMM(1)/GetExtent(1);  

  assert(m_ScaleFactorMMPerUnitX<ScalarTypeNumericTraits::infinity());
  assert(m_ScaleFactorMMPerUnitY<ScalarTypeNumericTraits::infinity());
}
Ejemplo n.º 10
0
 void
   PlaneGeometry::Map(const mitk::Point2D &pt2d_mm, mitk::Point3D &pt3d_mm) const
 {
   //pt2d_mm is measured from the origin of the world geometry (at leats it called form BaseRendere::Mouse...Event)
   Point3D pt3d_units;
   pt3d_units[0] = pt2d_mm[0] / (GetExtentInMM(0) / GetExtent(0));
   pt3d_units[1] = pt2d_mm[1] / (GetExtentInMM(1) / GetExtent(1));
   pt3d_units[2]=0;
   //pt3d_units is a continuos index. We divided it with the Scale Factor (= spacing in x and y) to convert it from mm to index units.
   //
   pt3d_mm = GetIndexToWorldTransform()->TransformPoint(pt3d_units);
   //now we convert the 3d index to a 3D world point in mm. We could have used IndexToWorld as well as GetITW->Transform...
 }
Ejemplo n.º 11
0
BOOL CDrawItem::OnChangeItemPosition(const CRect& rectPos)
{
	ASSERT_VALID(this);

	CDrawView* pView = GetActiveView();
	ASSERT_VALID(pView);
	CRect rect = rectPos;
	pView->ClientToDoc(rect);

	if (rect != m_pDrawObj->m_position)
	{
		// invalidate old rectangle
		m_pDrawObj->Invalidate();

		// update to new rectangle
		m_pDrawObj->m_position = rect;
		GetExtent(&m_pDrawObj->m_extent);

		// and invalidate new rectangle
		m_pDrawObj->Invalidate();

		// mark document as dirty
		GetDocument()->SetModifiedFlag();
	}
	return COleClientItem::OnChangeItemPosition(rectPos);
}
Ejemplo n.º 12
0
BOOL CDrawItem::UpdateExtent()
{
	CSize size;
	if (!GetExtent(&size) || size == m_pDrawObj->m_extent)
		return FALSE;       // blank

	// if new object (i.e. m_extent is empty) setup position
	if (m_pDrawObj->m_extent == CSize(0, 0))
	{
		m_pDrawObj->m_position.right =
			m_pDrawObj->m_position.left + MulDiv(size.cx, 10, 254);
		m_pDrawObj->m_position.bottom =
			m_pDrawObj->m_position.top - MulDiv(size.cy, 10, 254);
	}
	// else data changed so scale up rect as well
	else if (!IsInPlaceActive() && size != m_pDrawObj->m_extent)
	{
		m_pDrawObj->m_position.right = m_pDrawObj->m_position.left +
			MulDiv(m_pDrawObj->m_position.Width(), size.cx, m_pDrawObj->m_extent.cx);
		m_pDrawObj->m_position.bottom = m_pDrawObj->m_position.top +
			MulDiv(m_pDrawObj->m_position.Height(), size.cy, m_pDrawObj->m_extent.cy);
	}

	m_pDrawObj->m_extent = size;
	m_pDrawObj->Invalidate();   // redraw to the new size/position
	return TRUE;
}
Ejemplo n.º 13
0
void CairoFont::GetExtent( unsigned char c, float * outWidth, float * outHeight, VGDevice * dev ) const
{
	extern const char* to_utf8 (int n, int& outcount);
	int n;
	const char * str = to_utf8(c, n);
	return GetExtent (str, outWidth, outHeight, (cairo_t *)dev->GetNativeContext());
}
Ejemplo n.º 14
0
int OGRS57Layer::TestCapability( const char * pszCap )

{
    if( EQUAL(pszCap,OLCRandomRead) )
        return FALSE;

    else if( EQUAL(pszCap,OLCSequentialWrite) )
        return TRUE;

    else if( EQUAL(pszCap,OLCRandomWrite) )
        return FALSE;

    else if( EQUAL(pszCap,OLCFastFeatureCount) )
        return !(m_poFilterGeom != NULL || m_poAttrQuery != NULL 
                 || nFeatureCount == -1 ||
                 ( EQUAL(poFeatureDefn->GetName(), "SOUNDG") &&
                   poDS->GetModule(0) != NULL &&
                   (poDS->GetModule(0)->GetOptionFlags() & S57M_SPLIT_MULTIPOINT)));

    else if( EQUAL(pszCap,OLCFastGetExtent) )
    {
        OGREnvelope oEnvelope;

        return GetExtent( &oEnvelope, FALSE ) == OGRERR_NONE;
    }
    else if( EQUAL(pszCap,OLCFastSpatialFilter) )
        return FALSE;

    else 
        return FALSE;
}
Ejemplo n.º 15
0
bool CachedExtentRenderer::GetExtent(const Transform &inTransform,Extent2DF &ioExtent,bool inIncludeStroke)
{
   Matrix test = *inTransform.mMatrix;
   /*
   Do not normalize for scale ...
   double norm = test.m00*test.m00 + test.m01*test.m01 +
                 test.m10*test.m10 + test.m11*test.m11;
   if (norm<=0)
      return true;
   norm = 1.0/sqrt(norm);
   test.m00 *= norm;
   test.m01 *= norm;
   test.m10 *= norm;
   test.m11 *= norm;
   */
   test.mtx = 0;
   test.mty = 0;

   int smallest = mExtentCache[0].mID;
   int slot = 0;
   for(int i=0;i<3;i++)
   {
      CachedExtent &cache = mExtentCache[i];
      if (cache.mIsSet && test==cache.mTestMatrix &&
            *inTransform.mScale9==cache.mScale9 && cache.mIncludeStroke==inIncludeStroke)
      {
         // Maybe set but not valid - ie, 0 size
         if (cache.mExtent.Valid())
            ioExtent.Add(cache.Get(inTransform));
         return true;
      }
      if (cache.mID<gCachedExtentID)
         cache.mID = gCachedExtentID;

      if (cache.mID<smallest)
      {
         smallest = cache.mID;
         slot = i;
      }
   }

   // Not in cache - fill slot
   CachedExtent &cache = mExtentCache[slot];
   cache.mMatrix = *inTransform.mMatrix;
   cache.mTestMatrix = test;
   cache.mScale9 = *inTransform.mScale9;
   cache.mTransform = inTransform;
   cache.mTransform.mMatrix = &cache.mMatrix;
   cache.mTransform.mMatrix3D = &cache.mMatrix;
   cache.mTransform.mScale9 = &cache.mScale9;
   cache.mIncludeStroke = inIncludeStroke;
   cache.mIsSet = true;
   GetExtent(cache);

   cache.Get(inTransform);

   ioExtent.Add(cache.mExtent);

   return true;
}
Ejemplo n.º 16
0
mitk::Vector3D mitk::BaseGeometry::GetAxisVector(unsigned int direction) const
{
  Vector3D frontToBack;
  frontToBack.SetVnlVector(this->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(direction));
  frontToBack *= GetExtent(direction);
  return frontToBack;
}
Ejemplo n.º 17
0
HICON CXTPIconHandle::ScaleToFit(HICON hIcon, CSize desiredExtent)
{
	if (desiredExtent == CSize(0))
	{
		// invalid arg
		return NULL;
	}

	CSize realExtent = GetExtent(hIcon);
	if (realExtent == CSize(0))
	{
		// icon destroyed or not created yet
		return NULL;
	}


	// ensure icon retains aspect after scaling
	int delta = desiredExtent.cx * realExtent.cy - desiredExtent.cy * realExtent.cx;
	if (delta < 0)
	{
		desiredExtent.cy = MulDiv(realExtent.cy, desiredExtent.cx, realExtent.cx);
	}
	else
	if (delta > 0)
	{
		desiredExtent.cx = MulDiv(realExtent.cx, desiredExtent.cy, realExtent.cy);
	}

	// scale the icon
	CImageList images;
	VERIFY(images.Create(desiredExtent.cx, desiredExtent.cy, ILC_COLOR32 | ILC_MASK, 1, 1));
	images.Add(hIcon);
	return images.ExtractIcon(0);
}
Ejemplo n.º 18
0
void Image::ReadPixels(const Offset3D& offset, const Extent3D& extent, const DstImageDescriptor& imageDesc, std::size_t threadCount) const
{
    if (imageDesc.data && IsRegionInside(offset, extent))
    {
        /* Validate required size */
        ValidateImageDataSize(extent, imageDesc);

        /* Get source image parameters */
        const auto  bpp             = GetBytesPerPixel();
        const auto  srcRowStride    = bpp * GetExtent().width;
        const auto  srcDepthStride  = srcRowStride * GetExtent().height;
        auto        src             = data_.get() + GetDataPtrOffset(offset);

        if (GetFormat() == imageDesc.format && GetDataType() == imageDesc.dataType)
        {
            /* Get destination image parameters */
            const auto  dstRowStride    = bpp * extent.width;
            const auto  dstDepthStride  = dstRowStride * extent.height;
            auto        dst             = reinterpret_cast<char*>(imageDesc.data);

            /* Blit region into destination image */
            BitBlit(
                extent, bpp,
                dst, dstRowStride, dstDepthStride,
                src, srcRowStride, srcDepthStride
            );
        }
        else
        {
            /* Copy region into temporary sub-image */
            Image subImage { extent, GetFormat(), GetDataType() };

            BitBlit(
                extent, bpp,
                reinterpret_cast<char*>(subImage.GetData()), subImage.GetRowStride(), subImage.GetDepthStride(),
                src, srcRowStride, srcDepthStride
            );

            /* Convert sub-image */
            subImage.Convert(imageDesc.format, imageDesc.dataType, threadCount);

            /* Copy sub-image into output data */
            ::memcpy(imageDesc.data, subImage.GetData(), imageDesc.dataSize);
        }
    }
}
Ejemplo n.º 19
0
void TextShape::BoundingBox(Point& bottemLeft, Point& topRight) const
{
    Coord bottem , left , width , height;
    GetOrigin(bottem, left);
    GetExtent(width, height);
    bottemLeft = Point(bottem , left);
    topRight = Point(bottem+height, left+width);
}
Ejemplo n.º 20
0
gui_ord GUIGetExtentX( gui_window * wnd, const char * text, size_t length )
{
    gui_coord coord;

    if( GetExtent( wnd, text, length, &coord ) ) {
        return( coord.x );
    }
    return( 0 );
}
Ejemplo n.º 21
0
gui_ord GUIGetExtentY( gui_window * wnd, const char * text )
{
    gui_coord coord;

    if( GetExtent( wnd, text, (size_t)-1, &coord ) ) {
        return( coord.y );
    }
    return( 0 );
}
        virtual void BoundingBox(
            Point& bottomLeft, Point& topRight) const override 
        {
            Coord bottom, left, width, height;

            GetOrigin(bottom, left);
            GetExtent(width, height);

            bottomLeft = Point(bottom, left);
        }
Ejemplo n.º 23
0
void Image::Blit(Offset3D dstRegionOffset, const Image& srcImage, Offset3D srcRegionOffset, Extent3D srcRegionExtent)
{
    if (GetFormat() == srcImage.GetFormat() && GetDataType() == srcImage.GetDataType())
    {
        /* First clamp source region to source image dimension */
        srcImage.ClampRegion(srcRegionOffset, srcRegionExtent);

        /* Then shift negative destination region */
        if ( ShiftNegative1DRegion(dstRegionOffset.x, GetExtent().width,  srcRegionOffset.x, srcRegionExtent.width ) &&
             ShiftNegative1DRegion(dstRegionOffset.y, GetExtent().height, srcRegionOffset.y, srcRegionExtent.height) &&
             ShiftNegative1DRegion(dstRegionOffset.z, GetExtent().depth,  srcRegionOffset.z, srcRegionExtent.depth ) )
        {
            /* Check if a temporary copy of the source image must be allocated */
            Image srcImageTemp;
            const Image* srcImageRef = &srcImage;

            if (srcImageRef == this && Overlap3DRegion(dstRegionOffset, srcRegionOffset, srcRegionExtent))
            {
                /* Copy source image */
                srcImageTemp = *this;
                srcImageRef = &srcImageTemp;
            }

            /* Get destination image parameters */
            const auto  bpp             = GetBytesPerPixel();
            const auto  dstRowStride    = bpp * GetExtent().width;
            const auto  dstDepthStride  = dstRowStride * GetExtent().height;
            auto        dst             = data_.get() + GetDataPtrOffset(dstRegionOffset);

            /* Get source image parameters */
            const auto  srcRowStride    = bpp * srcImageRef->GetExtent().width;
            const auto  srcDepthStride  = srcRowStride * srcImageRef->GetExtent().height;
            auto        src             = srcImageRef->data_.get() + srcImageRef->GetDataPtrOffset(srcRegionOffset);

            /* Blit source image into region */
            BitBlit(
                srcRegionExtent, bpp,
                dst, dstRowStride, dstDepthStride,
                src, srcRowStride, srcDepthStride
            );
        }
    }
}
OGRErr OGRMSSQLSpatialTableLayer::CreateSpatialIndex()
{
    GetLayerDefn();

    CPLODBCStatement oStatement( poDS->GetSession() );

    if (nGeomColumnType == MSSQLCOLTYPE_GEOMETRY)
    {
        OGREnvelope oExt;
        if (GetExtent(&oExt, TRUE) != OGRERR_NONE)
        {
            CPLError( CE_Failure, CPLE_AppDefined, 
                          "Failed to get extent for spatial index." );
            return OGRERR_FAILURE;
        }

        oStatement.Appendf("CREATE SPATIAL INDEX [ogr_%s_sidx] ON [dbo].[%s] ( [%s] ) "
            "USING GEOMETRY_GRID WITH (BOUNDING_BOX =(%.15g, %.15g, %.15g, %.15g))",
                           pszGeomColumn, poFeatureDefn->GetName(), pszGeomColumn, 
                           oExt.MinX, oExt.MinY, oExt.MaxX, oExt.MaxY );
    }
    else if (nGeomColumnType == MSSQLCOLTYPE_GEOGRAPHY)
    {
        oStatement.Appendf("CREATE SPATIAL INDEX [ogr_%s_sidx] ON [dbo].[%s] ( [%s] ) "
            "USING GEOGRAPHY_GRID",
                           pszGeomColumn, poFeatureDefn->GetName(), pszGeomColumn );
    }
    else
    {
        CPLError( CE_Failure, CPLE_AppDefined, 
            "Spatial index is not supported on the geometry column '%s'", pszGeomColumn);
        return OGRERR_FAILURE;
    }

    //poDS->GetSession()->BeginTransaction();
    
    if( !oStatement.ExecuteSQL() )
    {
        CPLError( CE_Failure, CPLE_AppDefined, 
                      "Failed to create the spatial index, %s.", 
                      poDS->GetSession()->GetLastError());
        return OGRERR_FAILURE;
    } 

    //poDS->GetSession()->CommitTransaction();

    return OGRERR_NONE;
}
FBoxSphereBounds UParametricSurfaceComponent::CalcBounds(const FTransform& LocalToWorld) const
{
	const auto Radius = 100.0f;
	const auto PosMax = FVector(Radius, Radius, Radius);
	const auto PosMin = -PosMax;
	const auto Center = (PosMin + PosMax) * 0.5f;
	const auto Extent = PosMax - PosMin;
#if 0
	const auto BSB = FBoxSphereBounds(Center, Extent, Extent.Size()).TransformBy(LocalToWorld);
	const auto Box = BSB.GetBox();
	DrawDebugBox(GetWorld(), Box.GetCenter(), Box.GetExtent(), FColor::Green, true);
	return BSB;
#else
	return FBoxSphereBounds(Center, Extent, Extent.Size()).TransformBy(LocalToWorld);
#endif
}
Ejemplo n.º 26
0
void JuiTabBook::OnChildAdded( JuiControl *child )
{
	JuiTabPage *page = dynamic_cast<JuiTabPage*>(child);
	if(page != NULL)
	{
		m_lsPages.PushBack(page);

		JPoint2I pagePos = GetPosition();
		pagePos.y += m_nTabHeight;

		JPoint2I pageExtent = GetExtent();
		pageExtent.y -= m_nTabHeight;

		page->SetBounds(pagePos, pageExtent);
		page->SetVisible(false);

		if(m_pActivePage == NULL)
		{
			m_pActivePage = page;
			m_pActivePage->SetVisible(true);
		}
	}
}
Ejemplo n.º 27
0
void vtElevLayer::DrawLayerOutline(wxDC *pDC, vtScaledView *pView)
{
	DRECT ext;
	GetExtent(ext);
	wxRect screenrect = pView->WorldToCanvas(ext);

	if (m_pGrid && !m_pGrid->HasData())
	{
		// draw darker, dotted lines for a grid not in memory
		wxPen Pen1(wxColor(0x00, 0x40, 0x00), 1, wxDOT);
		pDC->SetPen(Pen1);
	}
	else
	{
		// draw a simple crossed box with green lines
		wxPen Pen1(wxColor(0x00, 0x80, 0x00), 1, wxSOLID);
		pDC->SetPen(Pen1);
	}

	pDC->SetLogicalFunction(wxCOPY);

	DrawRectangle(pDC, screenrect, true);
}
Ejemplo n.º 28
0
void	CTListBox::Draw()
{
	if(!IsVision() || m_pFontMgr == NULL || m_bOwnerDraw ) return ;

	int iValue = GetValue();///첫번째 찍을 라인
	int iExtent = GetExtent();///화면에 보여줄수 있는 최대 라인수
	
	if( iValue + iExtent >= (int)m_ITM.size() )///리스트의 최대범위밖으로 안나가도록 수정 
		iExtent = (int)m_ITM.size() - iValue;

	m_pFontMgr->SetTransformSprite( (float)m_sPosition.x, (float)m_sPosition.y );

	D3DCOLOR	dwColor ;
	
	int iPosY = 0 ;

	for( int i = iValue; i < iValue + iExtent ; ++i )
	{
		if( i >= (int)m_ITM.size() || i < 0 )
			break;

		if( m_iSelectedItem == i )
			dwColor = D3DCOLOR_ARGB( 255, 255, 128, 0);
		else
			dwColor = m_ITM[i].m_dwColor;

		if( m_ITM[i].m_szTxt )
		{
			m_ITM[i].m_bDrawn = true;
			if( strlen( m_ITM[i].m_szTxt ) > 0 )
				m_pFontMgr->Draw( m_iFont, true, 0, iPosY, dwColor, m_ITM[i].m_szTxt );		
			else
				m_pFontMgr->Draw( m_iFont, true, 0, iPosY, dwColor, " " );		
			iPosY += m_iCharHeight + m_iLineSpace;
		}
	}
}
Ejemplo n.º 29
0
mitk::ScalarType mitk::BaseGeometry::GetExtentInMM(int direction) const
{
  return this->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(direction).magnitude() *
         GetExtent(direction);
}
Ejemplo n.º 30
0
OGRErr OGRUnionLayer::GetExtent( OGREnvelope *psExtent, int bForce )
{
    return GetExtent(0, psExtent, bForce);
}