本文主要是介绍vtk中画几何图形存储为vtk文件并在窗口显示,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
几何结构&拓扑结构
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);#include <iostream>
#include <vtkSmartPointer.h>
#include <vtkPoints.h>
#include <vtkCellArray.h>
#include <vtkPolyData.h>
#include <vtkPolyDataWriter.h>
#include <vtkLine.h> //构建两个端点的连线
//建立窗口
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkInteractorStyleTrackballCamera.h"
#include "vtkCylinderSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include"vtkProperty.h"
#include"vtkConeSource.h"int main()
{//*************方法1***************//将几何结构点和拓扑结构线加入到数据集//vtkSmartPointer<vtkPoints>points =// vtkSmartPointer<vtkPoints>::New();创建五点坐标//points->InsertNextPoint(0.0, 0.0,0.0); //ID=0//points->InsertNextPoint(0.0, 50.0,0.0); //ID=1//points->InsertNextPoint(50.0, 50.0, 0.0); //2//points->InsertNextPoint(50.0, 0.0, 0.0); //3//points->InsertNextPoint(25.0, 25.0, 25.0);//4点之间使用线连接//连线的时候给个连续的顺序,顺时针或逆时针//vtkSmartPointer<vtkLine>line0 =// vtkSmartPointer<vtkLine>::New();//line0->GetPointIds()->SetId(0,0);//line0->GetPointIds()->SetId(1,1);//vtkSmartPointer<vtkLine>line1 =// vtkSmartPointer<vtkLine>::New();
这篇关于vtk中画几何图形存储为vtk文件并在窗口显示的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!