zoukankan      html  css  js  c++  java
  • VTK初学一,比较常见的错误2

    我的开发环境:

    系统:win8.1

    QT:5.4.2MinGW版

    VTK:6.3

    按照教程生成一个球体显示在,Qt的QVTKWidget控件中,出现如下ERROR:

    ERROR: In D:VTK6.3VTK-srcRenderingCorevtkTextActor.cxx, line 110
    vtkTextActor (0509BA90): Failed getting the TextRenderer instance!

    解决办法:

    在头文件中加入VTK_MODULE_INIT(vtkRenderingFreeType),

    我估计可能还需要在VTK源文件cmake编译的时候,将VTK_USE_SYSTEM_FREETYPE设置为ON。

    再有,要将类似含有***Actor或含有***Widget类的代码,比如下面

    /***************坐标互动窗件儿开始***************************************/
        vtkSmartPointer<vtkAxesActor> axes =vtkSmartPointer<vtkAxesActor>::New();
        vtkSmartPointer<vtkOrientationMarkerWidget> widget =vtkSmartPointer<vtkOrientationMarkerWidget>::New();
        widget->SetOutlineColor( 0.9300, 0.5700, 0.1300 );
        widget->SetOrientationMarker( axes );
        //注意style的设置要在axes设置之前
        widget->SetInteractor( iren );
        widget->SetViewport( 0.0, 0.0, 0.4, 0.4 );
        widget->SetEnabled( 1 );
        widget->InteractiveOn();
    /***************坐标互动窗件儿结束***************************************/

    放置在renderWindowInteractor之后设置。比如,在下面的为场景添加坐标窗件儿的程序:

    #ifndef INITIAL_OPENGL
    #define INITIAL_OPENGL
    #include <vtkAutoInit.h>
    VTK_MODULE_INIT(vtkRenderingOpenGL)
    VTK_MODULE_INIT(vtkInteractionStyle)
    VTK_MODULE_INIT(vtkRenderingFreeType)
    #endif
    #include <iostream>
    
    using namespace std;
    #include <vtkVersion.h>
    #include <vtkPolyDataMapper.h>
    #include <vtkActor.h>
    #include <vtkRenderWindow.h>
    #include <vtkRenderer.h>
    #include <vtkRenderWindowInteractor.h>
    #include <vtkPolyData.h>
    #include <vtkSphereSource.h>
    #include <vtkOrientationMarkerWidget.h>
    #include <vtkAxesActor.h>
    #include <vtkPropAssembly.h>
    #include <vtkSmartPointer.h>
    #include <vtkProperty.h>
    #include <vtkInteractorStyleTrackballCamera.h>
    
    void myShow(vtkPolyData* aGrid)
    {
        vtkSmartPointer<vtkPolyDataMapper> aMapper=vtkSmartPointer<vtkPolyDataMapper>::New();
        aMapper->SetInputData(aGrid);
        aMapper->ScalarVisibilityOn();
    
        vtkSmartPointer<vtkActor> anActor=vtkSmartPointer<vtkActor>::New();
        anActor->SetMapper(aMapper);
        //    anActor->GetProperty()->SetRepresentationToWireframe();
        anActor->GetProperty()->SetDiffuseColor(1,1,1);
        anActor->GetProperty()->SetLineWidth(10);
        anActor->GetProperty()->SetPointSize(10);
    
        vtkSmartPointer<vtkRenderer> ren1=vtkSmartPointer<vtkRenderer>::New();
        vtkSmartPointer<vtkRenderWindow> renWin=vtkSmartPointer<vtkRenderWindow>::New();
        ren1->AddActor(anActor);
        ren1->ResetCamera();
        renWin->AddRenderer(ren1);
        renWin->SetSize(512,512);
    
        vtkSmartPointer<vtkRenderWindowInteractor> iren=vtkSmartPointer<vtkRenderWindowInteractor>::New();
        iren->SetRenderWindow(renWin);
        vtkSmartPointer<vtkInteractorStyleTrackballCamera> style=vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
        iren->SetInteractorStyle(style);
    /***************坐标互动窗件儿***************************************/
        vtkSmartPointer<vtkAxesActor> axes =vtkSmartPointer<vtkAxesActor>::New();
        vtkSmartPointer<vtkOrientationMarkerWidget> widget =vtkSmartPointer<vtkOrientationMarkerWidget>::New();
        widget->SetOutlineColor( 0.9300, 0.5700, 0.1300 );
        widget->SetOrientationMarker( axes );
        //注意style的设置要在axes设置之前
        widget->SetInteractor( iren );
        widget->SetViewport( 0.0, 0.0, 0.4, 0.4 );
        widget->SetEnabled( 1 );
        widget->InteractiveOn();
    /***************坐标互动窗件儿***************************************/
        iren->Start();
    }
    int main()
    {
        vtkSmartPointer<vtkSphereSource> sphereSource = vtkSmartPointer<vtkSphereSource>::New();
        sphereSource->SetCenter(0.0, 0.0, 0.0);
        sphereSource->SetRadius(1.0);
        sphereSource->Update();
    
        vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
        polydata=sphereSource->GetOutput();
        myShow(polydata);
        return 0;
    }

  • 相关阅读:
    LinuxPerformance
    MySQL事务
    vi字体太暗的配置
    几种语言的日期格式,Oracle,Java,MySQL,Python
    Oracle RAC JDBC connection string
    docker问题解决
    elasticesearch弱密码漏洞
    apt源更新
    android学习笔记二:Intent
    mars android视频学习笔记一:Activity生命周期
  • 原文地址:https://www.cnblogs.com/phoenixdsg/p/6130264.html
Copyright © 2011-2022 走看看