<a target=_blank href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/InfoVis/XGMLReader" target="_blank"><a target=_blank href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/InfoVis/XGMLReader" target="_blank" style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">参考网址</a></a>
CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
PROJECT(XGMLReader)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
add_executable(XGMLReader MACOSX_BUNDLE XGMLReader)
if(VTK_LIBRARIES)
target_link_libraries(XGMLReader ${VTK_LIBRARIES})
else()
target_link_libraries(XGMLReader vtkHybrid vtkWidgets)
endif()
C++源代码
/************************************************************************/
/* 本示例为从一个.gml文件中读取和显示图像 */
/* 测试的数据为 VTKData/Data/Infovis/fsm.gml */
/************************************************************************/
#include "stdafx.h"
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);
#include <vtkPolyData.h>
#include <vtkXGMLReader.h>
#include <vtkSmartPointer.h>
#include <vtkUndirectedGraph.h>
#include <vtkGraphLayoutView.h>
#include <vtkGraphLayoutStrategy.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkSimple2DLayoutStrategy.h>
int _tmain(int argc, _TCHAR* argv[])
{
std::string inputfilename = "F:/ZYHWorkspace/Data/Infovis/fsm.gml";
vtkSmartPointer<vtkXGMLReader> reader = vtkXGMLReader::New();
reader->SetFileName(inputfilename.c_str());
reader->Update();
vtkSmartPointer<vtkUndirectedGraph> graph = vtkUndirectedGraph::New();
graph = reader->GetOutput();
vtkSmartPointer<vtkGraphLayoutView> graphLayoutView = vtkGraphLayoutView::New();
graphLayoutView->AddRepresentationFromInput(graph);
graphLayoutView->SetLayoutStrategy("Simple 2D");
graphLayoutView->ResetCamera();
graphLayoutView->Render();
graphLayoutView->GetInteractor()->Start();
return 0;
}
但是有ERROR出现,简单来讲就是么有实例化render(不知道是不是VTK7.0的原因)
应该是可以解决的,但是由于我自己了解的不是很多,暂时先不弄了。。。。