|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
下面是我的代码,附件中有数据,但是我运行的时候总要报错(语法没有错误!),完全看不到结果,请各位高手指点一下,非常感谢!!!
#include <vtkSmartPointer.h>
#include <vtkHAVSVolumeMapper.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkUnstructuredGridReader.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkStructuredPointsReader.h>
#include <vtkSLCReader.h>
#include <vtkStructuredPoints.h>
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetTriangleFilter.h>
#include <vtkPiecewiseFunction.h>
#include <vtkColorTransferFunction.h>
#include <vtkVolumeProperty.h>
#include <vtkVolume.h>
#include <vtkContourFilter.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkStdString.h>
#include <vtkTesting.h>
#include <vtkPLOT3DReader.h>
#include <vtkXMLUnstructuredGridReader.h>
#include <vtkStructuredGridOutlineFilter.h>
#include <vtkPlaneSource.h>
#include <vtkStreamLine.h>
#include <vtkProperty.h>
#include <vtkXMLRectilinearGridReader.h>
#include <vtkRectilinearGridReader.h>
#include <vtkAssignAttribute.h>
#include <vtkPointSource.h>
int main(int, char*[])
{
vtkSmartPointer<vtkRenderer> ren1 =vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New();
renWin->AddRenderer(ren1);
vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
iren->SetRenderWindow(renWin);
// 建立读数据类,读入数据
std::string dataRoot = "E:\\vtkdata-5.4.2\\VTKData";
std::string filename = dataRoot + "/Data/hj.vtu";
//创建非结构化读数据类,读入数据
vtkSmartPointer<vtkXMLUnstructuredGridReader> reader = vtkSmartPointer<vtkXMLUnstructuredGridReader>::New();
reader->SetFileName(filename.c_str());
reader->Update();
// 建立流线种子
vtkSmartPointer<vtkPointSource> seeds = vtkSmartPointer<vtkPointSource>::New();
seeds->SetCentral(0,0,0);
seeds->SetRadius(2);
seeds->SetNumberOfPoints(20);
// 建立流线类
vtkSmartPointer<vtkStreamLine> streamLine = vtkSmartPointer<vtkStreamLine>::New();
streamLine->SetInputConnection(reader->GetOutputPort());
streamLine->SetSource(seeds->GetOutput());
//设置流线参数
streamLine->SetMaximumPropagationTime(200);
streamLine->SetIntegrationStepLength(.2);
streamLine->SetStepLength(.001);
streamLine->SetNumberOfThreads(1);
streamLine->SetIntegrationDirectionToForward();
streamLine->VorticityOn();
//建立mapper
vtkSmartPointer<vtkPolyDataMapper> streamLineMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
streamLineMapper->SetInputConnection(streamLine->GetOutputPort());
//建立actor
vtkSmartPointer<vtkActor> streamLineActor = vtkSmartPointer<vtkActor>::New();
streamLineActor->SetMapper(streamLineMapper);
streamLineActor->VisibilityOn();
ren1->AddViewProp(streamLineActor);
renWin->Render();
iren->Start();
return EXIT_SUCCESS;
} |
|