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);
  • 相关阅读:
    [python学习篇][python工具使用篇][1] 编辑,设置等
    [python学习篇][廖雪峰][1]高级特性--创建生成器 方法2 yield
    [python学习篇][廖雪峰][1]高级特性--创建生成器 方法1 a = (x for x in range(1,3))
    [python学习篇][廖雪峰][1]高级特性--列表生成式
    [python学习篇][廖雪峰][1]高级特性 ---迭代
    自定义Sharepoint的登陆页面
    SharePoint 2010 使用自定义aspx页面替换列表默认的新建(NewForm.aspx),查看(DispForm.aspx)和编辑(EditForm.aspx)页面
    SharePoint2010新特性:InfoPath定义创建列表的界面
    SharePoint 2010 获取列表中所有数据(包括文件夹内)的方法
    SharePoint 2013中修改windows 活动目录(AD)域用户密码的WebPart(免费下载)
  • 原文地址:https://www.cnblogs.com/ankier/p/3170827.html
Copyright © 2011-2022 走看看