博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
VTK初学一,比较常见的错误2
阅读量:4709 次
发布时间:2019-06-10

本文共 3003 字,大约阅读时间需要 10 分钟。

我的开发环境:

系统:win8.1

QT:5.4.2MinGW版

VTK:6.3

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

 

ERROR: In D:\VTK6.3\VTK-src\Rendering\Core\vtkTextActor.cxx, line 110

vtkTextActor (0509BA90): Failed getting the TextRenderer instance!

解决办法:

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

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

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

/***************坐标互动窗件儿开始***************************************/    vtkSmartPointer
axes =vtkSmartPointer
::New(); vtkSmartPointer
widget =vtkSmartPointer
::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 
VTK_MODULE_INIT(vtkRenderingOpenGL)VTK_MODULE_INIT(vtkInteractionStyle)VTK_MODULE_INIT(vtkRenderingFreeType)#endif#include
using namespace std;#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
void myShow(vtkPolyData* aGrid){ vtkSmartPointer
aMapper=vtkSmartPointer
::New(); aMapper->SetInputData(aGrid); aMapper->ScalarVisibilityOn(); vtkSmartPointer
anActor=vtkSmartPointer
::New(); anActor->SetMapper(aMapper); // anActor->GetProperty()->SetRepresentationToWireframe(); anActor->GetProperty()->SetDiffuseColor(1,1,1); anActor->GetProperty()->SetLineWidth(10); anActor->GetProperty()->SetPointSize(10); vtkSmartPointer
ren1=vtkSmartPointer
::New(); vtkSmartPointer
renWin=vtkSmartPointer
::New(); ren1->AddActor(anActor); ren1->ResetCamera(); renWin->AddRenderer(ren1); renWin->SetSize(512,512); vtkSmartPointer
iren=vtkSmartPointer
::New(); iren->SetRenderWindow(renWin); vtkSmartPointer
style=vtkSmartPointer
::New(); iren->SetInteractorStyle(style);/***************坐标互动窗件儿***************************************/ vtkSmartPointer
axes =vtkSmartPointer
::New(); vtkSmartPointer
widget =vtkSmartPointer
::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
sphereSource = vtkSmartPointer
::New(); sphereSource->SetCenter(0.0, 0.0, 0.0); sphereSource->SetRadius(1.0); sphereSource->Update(); vtkSmartPointer
polydata = vtkSmartPointer
::New(); polydata=sphereSource->GetOutput(); myShow(polydata); return 0;}

 

转载于:https://www.cnblogs.com/phoenixdsg/p/6130264.html

你可能感兴趣的文章
【PAT】B1047 编程团体赛(20 分)
查看>>
iPad软件提交注意事项
查看>>
约束和异常处理
查看>>
css 布局
查看>>
RESTful风格化
查看>>
C# 多线程学习系列二
查看>>
如何将你的github仓库部署到github pages(转)
查看>>
几个重要的shell命令:diff patch tar find grep
查看>>
学习笔记
查看>>
JS ES6 -- let命令
查看>>
查找空座位问题
查看>>
几个简单规则改进你的SEO效果
查看>>
UVA10820 Send a Table
查看>>
主流css reset的讲解分析(转载)
查看>>
OpenCV4Android Tutorial0解析
查看>>
Oracle数据库(一)
查看>>
SVD与文本摘要
查看>>
HDU 5451 广义斐波那契数列
查看>>
mysql5.6配置文件my.ini位置
查看>>
[BZOJ4820][SDOI2017]硬币游戏(高斯消元+KMP)
查看>>