zoukankan      html  css  js  c++  java
  • 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);
  • 相关阅读:
    前后台$.post交互并返回JSON对象
    Hello World
    Jquery表单插件使用
    MyBatis插入语句返回主键值
    $ is not defined与SpringMVC访问静态资源
    MySql查询数据令某字段显示固定值
    更改我的网页默认的暴风影音播放器
    adodb.stream对象的方法/属性
    【顶】Asp无组件生成缩略图 (3)
    关于MD5的加解密
  • 原文地址:https://www.cnblogs.com/ankier/p/3170827.html
Copyright © 2011-2022 走看看