11 - 改变vtkImageData中的Manipulation 方法 VTK 6.0 迁移
2013-07-04 08:47
686 查看
VTK6 引入了许多不兼容的变。这其中就包括关于vtkImageData中元数据管理及内存分配的方法。这些方法有些直接改变了行为或者能加了额外的参数。
GetScalarTypeMin()
GetScalarTypeMax()
GetScalarType()
SetScalarType(int scalar_type)
GetNumberOfScalarComponents()
SetNumberOfScalarComponents(int n)
AllocateScalars()
例子1:
替换成:
例子1:
例子1:
替换成:
例子1:
替换成:
替换成:
GetScalarTypeMin()
GetScalarTypeMax()
GetScalarType()
SetScalarType(int scalar_type)
GetNumberOfScalarComponents()
SetNumberOfScalarComponents(int n)
AllocateScalars()
GetNumberOfScalarComponents(), GetScalarType(), GetScalarTypeMin() and GetScalarTypeMax()
这些方法被用来返回vtkImageData中灰度组件的个数、灰度值类型、灰度值的最小/最大值。在灰度内存被分配之前,这些方法无法返回正确的信息(例如在RequestInformation)。如果想要在RequestData(分配内存之前)获得灰度类型,你可以给GetScalarType()方法的参数中传入 管道信息(vtkInformation)就可以取得。
例子1:
int vtkMyAlg::RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector* outInfoVec) { vtkImageData* output = this->GetOutput(); output->GetScalarType(); output->GetNumberOfScalarComponents();
替换成:
int vtkMyAlg::RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector* outInfoVec) { vtkInformation* outInfo = outInfoVec->GetInformationObject(0); vtkImageData::GetScalarType(outInfo); vtkImageData::GetNumberOfScalarComponents(outInfo);
例子1:
int vtkMyAlg::RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector* outInfoVec) { vtkImageData* output = vtkImageData::GetData(outInfoVec); // Allocate output scalars here output->GetScalarType(); output->GetNumberOfScalarComponents();
SetScalarType() and SetNumberOfScalarComponents()
SetScalarType() and SetNumberOfScalarComponets()先前被用来设置管道信息中的灰度值元数据。在 VTK6 中,SetPointDataActiveScalarInfo()可以做同样的事情。例子1:
int vtkMyAlg::RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector* outInfoVec) { vtkImageData* output = this->GetOutput(); output->SetScalarType(VTK_UNSIGNED_CHAR); output->SetNumberOfScalarComponents(3); return 1; }
替换成:
int vtkMyAlg::RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector* outInfoVec) { vtkInformation* outInfo = outInfoVec->GetInformationObject(0); vtkDataObject::SetPointDataActiveScalarInfo( outInfo, VTK_UNSIGNED_CHAR, 3); return 1; }
AllocateScalars()
在VTK6 之前,AllocateScalars()配合SetScalarType() and SetNumberOfScalarComponents()一起使用。但是在VTK6 中,AllocateScalars()不再访问管道信息,需要传入灰度类型及灰度个数去分配内存。例子1:
// set the extent of the image data first imageData->SetScalarTypeToFloat(); imageData->SetNumberOfScalarComponents(3); imageData->AllocateScalars();
替换成:
// set the extent of the image data first imageData->AllocateScalars(VTK_FLOAT, 3);
int vtkMyAlg::RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector* outInfoVec) { vtkImageData* output = this->GetOutput(); output->SetScalarType(VTK_UNSIGNED_CHAR); output->SetNumberOfScalarComponents(3); return 1; }
int vtkMyAlg::RequestData(vtkInformation*, vtkInformationVector**,
vtkInformationVector* outInfoVec)
{
vtkImageData* output = this->GetOutput();
output->AllocateScalars();
替换成:
int vtkMyAlg::RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector* outInfoVec) { vtkInformation* outInfo = outInfoVec->GetInformationObject(0); vtkDataObject::SetPointDataActiveScalarInfo( outInfo, VTK_UNSIGNED_CHAR, 3); return 1; }
int vtkMyAlg::RequestData(vtkInformation*, vtkInformationVector**,
vtkInformationVector* outInfoVec)
{
vtkInformation* outInfo = outInfoVec->GetInformationObject(0);
vtkImageData* output = vtkImageData::GetData(outInfoVec);
output->AllocateScalars(outInfo);
相关文章推荐
- 04 - 替换vtkDataObject中的GetPipelineInformation 和GetExecutive 方法 VTK 6.0 迁移
- 05 - 替换vtkDataObject中的Update方法 VTK 6.0 迁移
- 08 - 删除vtkDataObject中的SetWholeExtent() 方法 VTK 6.0 迁移
- 09 - 删除vtkDataObject中的ShouldIReleaseData() and ReleaseDataFlag 方法 VTK 6.0 迁移
- 10 - 删除vtkDataObject中的Update Extent方法 VTK 6.0 迁移
- 03 - 替换vtkDataObject中的GetProducerPort()方法 VTK 6.0 迁移
- 07 - 删除vtkDataObject中的SetExtentTranslator 和 GetExtentTranslator方法 VTK 6.0 迁移
- 02 - 替换SetInput方法 VTK 6.0 迁移 (2013-06-30 16:22)
- Html5之高级-11 拖放API (拖放事件、dataTransfer对象、setDragImage方法)
- VTK利用点云高程渲染点云(方法三:vtkPoltData)
- Oracle 单实例 从32位 迁移到 64位 方法(一)-- 直接 copy datafiles
- 不要试图直接用jquery改变knockoutjs的data-bind方法绑定的值
- no override found for vtkpolydatamapper解决方法
- 解决方法!:getImageData on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.
- 基于DataFrame改变列类型的方法
- tableviewcell imageview改变图片大小方法
- Oracle 单实例 从32位 迁移到 64位 方法(一)-- 直接 copy datafiles
- ERROR: the user data image is used by another emulator. aborting错误解决方法
- Oracle 单实例 从32位 迁移到 64位 方法(一)-- 直接 copy datafiles
- ERROR: the user data image is used by another emulator. aborting 的错误解决方法