本文整理汇总了C++中vtkSmartPointer::AllocateScalars方法的典型用法代码示例。如果您正苦于以下问题:C++ vtkSmartPointer::AllocateScalars方法的具体用法?C++ vtkSmartPointer::AllocateScalars怎么用?C++ vtkSmartPointer::AllocateScalars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vtkSmartPointer
的用法示例。
在下文中一共展示了vtkSmartPointer::AllocateScalars方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createItkAndVtkImages
void ItkAndVtkImageTestHelper::createItkAndVtkImages(int dimensions[3], int startIndex[3], double spacing[3], double origin[3],
VolumePixelData::ItkImageTypePointer &itkImage, vtkSmartPointer<vtkImageData> &vtkImage)
{
VolumePixelData::ItkImageType::SizeType size = { dimensions[0], dimensions[1], dimensions[2] };
VolumePixelData::ItkImageType::IndexType index = { startIndex[0], startIndex[1], startIndex[2] };
VolumePixelData::ItkImageType::RegionType region;
region.SetSize(size);
region.SetIndex(index);
itkImage = VolumePixelData::ItkImageType::New();
itkImage->SetRegions(region);
itkImage->SetSpacing(spacing);
itkImage->SetOrigin(origin);
itkImage->Allocate();
vtkImage = vtkSmartPointer<vtkImageData>::New();
vtkImage->SetDimensions(dimensions);
int extent[6] = { startIndex[0], startIndex[0] + dimensions[0] - 1, startIndex[1], startIndex[1] + dimensions[1] - 1, startIndex[2],
startIndex[2] + dimensions[2] - 1 };
vtkImage->SetExtent(extent);
vtkImage->SetSpacing(spacing);
vtkImage->SetOrigin(origin);
vtkImage->AllocateScalars(VTK_SHORT, 1);
itk::ImageRegionIterator<VolumePixelData::ItkImageType> itkIterator(itkImage, itkImage->GetLargestPossibleRegion());
itkIterator.GoToBegin();
VolumePixelData::ItkPixelType *vtkPointer = static_cast<VolumePixelData::ItkPixelType*>(vtkImage->GetScalarPointer());
VolumePixelData::ItkPixelType value = 0;
while (!itkIterator.IsAtEnd())
{
itkIterator.Set(value);
*vtkPointer = value;
++itkIterator;
++vtkPointer;
++value;
}
}