如何在vtk项目中读取vtp文件?

时间:2013-09-14 08:08:53

标签: visual-studio-2010 vtk

我有vtk示例可以读取vtk文件,如果它存在,但我不知道我把vtp文件放在哪里?

2 个答案:

答案 0 :(得分:1)

如果只将文件名传递给阅读器,它应该查看当前工作目录(创建可执行文件的目录)。

答案 1 :(得分:0)

要读取.vtp文件并将其打印成视频,请使用如下代码:

return ListTile(
          leading:GestureDetector(
                    child: //add the text here,
                    onTap: () { 
                      //here handle the onclick for text

                     } ,
           ) ,
          trailing://here add the radio button with onchanged normally,

                  );

显然用“ .vtp”文件名替换“文件名”,就像这样

filename = 'filename'
reader = vtk.vtkXMLPolyDataReader()
reader.setFileName(filename)
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection(reader.GetOutputPort())
actor = vtkActor()
actor.SetMapper(mapper)
renderer = vtkRenderer()
renderer.AddActor(actor)
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderer.ResetCamera()
renderWindow.Render()
renderWindowInteractor.Initialize()
renderWindowInteractor.Start()