• 11


    VTK6 引入了许多不兼容的变。这其中就包括关于vtkImageData中元数据管理及内存分配的方法。这些方法有些直接改变了行为或者能加了额外的参数。

    • 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);
  • 相关阅读:
    iOS 获取当前界面所在的视图控制器
    the executable was signed with invalid 解决方法
    iOS 中一些代码规范
    In order to validate a domain name for self signed certificates, you MUST use pinning,AFNetWorking使用自签证书时出现问题。
    IOS -- SQLite数据库判断表是否存在
    如何解决 iOS The document “(null)” requires Xcode 8.0 or later. 不能编译的问题
    iOS开发 如何适配iOS10
    更新cocoapods之后,出现Undefined symbols for architecture arm64
    新的一天
    css布局之弹性布局
  • 原文地址:https://www.cnblogs.com/ankier/p/3170827.html
Copyright © 2020-2023  润新知