本文整理汇总了C++中TImage::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ TImage::begin方法的具体用法?C++ TImage::begin怎么用?C++ TImage::begin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TImage
的用法示例。
在下文中一共展示了TImage::begin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateMask
void CExtractRegion::updateMask( TImage& mask, TImage& work, uint index )
{
TImage::iterator in = work.begin();
TImage::iterator out = mask.begin();
while( in != work.end() )
{
if ( (*in) > 0 ) (*out) = index;
++in; ++out;
}
}
示例2: load
vtkImageData* CImageLoader::load( std::string sFilename, TImagePtr& imagePtr )
{
cerr << "Loading data... ";
TDataFile theData = getFileServer().loadDataSet( sFilename );
if ( theData.first->getType() == typeid( short ) )
{
imagePtr = static_pointer_cast<TImage>( theData.first );
cerr << "Correct" << endl;
}
else
cerr << theData.first->getType().name() << endl;
cerr << "done" << endl;
cerr << "Starting conversion... ";
// Create vtk structured points structure
vtkImageData* sp = vtkImageData::New();
sp->SetDimensions( theData.first->getExtent(0), theData.first->getExtent(1), theData.first->getExtent(2) );
sp->AllocateScalars();
// Assign dataset to structured points
vtkPointData *p=sp->GetPointData();
vtkShortArray* sArray = NULL;
vtkDoubleArray* fArray = NULL;
TField* floatSet = dynamic_cast<TField*>( theData.first.get() );
if ( floatSet != NULL )
{
fArray = vtkDoubleArray::New();
fArray->SetArray(floatSet->getArray(),
theData.first->getExtent(0)*theData.first->getExtent(1)*theData.first->getExtent(2), 1 );
p->SetScalars( fArray );
sp->SetScalarTypeToDouble();
}
else
{
TImage* shortSet = dynamic_cast<TImage*>( theData.first.get() );
if ( shortSet != NULL )
{
short* sA = new short[theData.first->getExtent(0)*theData.first->getExtent(1)*theData.first->getExtent(2)];
short* sAs = sA;
for( TImage::iterator it = shortSet->begin(); it != shortSet->end(); ++it, ++sAs )
*sAs = *it;
sArray = vtkShortArray::New();
sArray->SetArray( sA,
theData.first->getExtent(0)*theData.first->getExtent(1)*theData.first->getExtent(2), 1 );
p->SetScalars( sArray );
sp->SetScalarTypeToShort();
}
else
{
sp->Delete();
throw( FileException( "CVTkHandler - Unknown image format in dataset. Image was not saved" ) );
}
}
sp->UpdateData();
sp->SetSpacing( 1.0, 1.0, 1.0 );
sp->SetOrigin( static_cast<double>( theData.first->getExtent(0) )/ 2.0,
static_cast<double>( theData.first->getExtent(1) )/ 2.0,
static_cast<double>( theData.first->getExtent(2) )/ 2.0 );
cerr << sp->GetNumberOfScalarComponents() << endl;
cerr << "done" << endl;
return sp;
}
示例3: computeSize
ulong CExtractRegion::computeSize( TImage& region )
{
ulong size = 0;
TImage::iterator in = region.begin();
while( in != region.end() )
{
if ( (*in) > 0 ) size++;
++in;
}
return size;
}