首页 技术 正文
技术 2022年11月19日
0 收藏 418 点赞 4,734 浏览 2560 个字

系统:Win8.1

QT版本:2.4.2,Mingw

VTK版本:6.3

2. main.cpp
#ifndef INITIAL_OPENGL
#define INITIAL_OPENGL
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL)
VTK_MODULE_INIT(vtkInteractionStyle)
#endif

#include <iostream>
using namespace std;
#include "vtkPolyDataMapper.h"
#include "vtkWin32OpenGLRenderWindow.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkPoints.h"
#include "vtkWin32RenderWindowInteractor.h"
#include "vtkProperty.h"
#include "vtkFloatArray.h"
#include "vtkPolyData.h"
#include "vtkDataSetMapper.h"
#include "vtkActor2D.h"
#include "vtkContourFilter.h"
#include "vtkContourValues.h"
#include "vtkUnstructuredGrid.h"
#include "vtkPointData.h"
#include "vtkVertex.h"
#include "vtkInteractorStyleTrackballCamera.h"

void myShow(vtkSmartPointer<vtkUnstructuredGrid> aGrid);

int  main()
{

    // create a scene with one of each cell type
//Vertex
    vtkPoints *vertexPoints=vtkPoints::New();
    vertexPoints-> SetNumberOfPoints (1);
    vertexPoints-> InsertPoint( 0, 0, 0, 0);
    vtkFloatArray *vertexScalars=vtkFloatArray::New();
    vertexScalars-> SetNumberOfTuples (1);
    vertexScalars-> InsertValue (0, 1);
    vtkVertex *aVertex=vtkVertex::New();
    aVertex-> GetPointIds()-> SetId (0, 0);
    vtkUnstructuredGrid *aVertexGrid=vtkUnstructuredGrid::New();
    aVertexGrid-> Allocate (1, 1);
    aVertexGrid-> InsertNextCell (aVertex-> GetCellType(), aVertex ->GetPointIds());
    aVertexGrid ->SetPoints (vertexPoints);
    aVertexGrid-> GetPointData() ->SetScalars (vertexScalars);

    myShow(aVertexGrid);

    return 0;
}
void myShow(vtkSmartPointer<vtkUnstructuredGrid> aGrid)
{
    //设置映射器
    vtkSmartPointer<vtkDataSetMapper> aMapper=vtkSmartPointer<vtkDataSetMapper>::New();
    aMapper->SetInputData(aGrid);
    aMapper->ScalarVisibilityOn();

    vtkSmartPointer<vtkActor> anActor=vtkSmartPointer<vtkActor>::New();
    anActor->SetMapper(aMapper);
    anActor->GetProperty()->SetRepresentationToPoints();
//    anActor->GetProperty()->SetRepresentationToWireframe();
    anActor->GetProperty()->SetDiffuseColor(1,0,0);
//    anActor->GetProperty()->SetLineWidth(5);
//    anActor->GetProperty()->SetEdgeColor(1,0,0);
    anActor->GetProperty()->SetPointSize(10);
 //创建显示窗口
    vtkSmartPointer<vtkRenderer> ren1=vtkSmartPointer<vtkRenderer>::New();
    vtkSmartPointer<vtkRenderWindow> renWin=vtkSmartPointer<vtkRenderWindow>::New();
    ren1->AddActor(anActor);
    renWin->AddRenderer(ren1);

    vtkSmartPointer<vtkRenderWindowInteractor> iren=vtkSmartPointer<vtkRenderWindowInteractor>::New();
    vtkSmartPointer<vtkInteractorStyleTrackballCamera> style=vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
    iren->SetInteractorStyle(style);
    iren->SetRenderWindow(renWin);

    renWin->SetSize(700,700);
    ren1->ResetCamera();
    renWin->Render();
    iren->Start();
}

VTK初学一,a_Vertex图形点的绘制



    					
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,488
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,903
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,736
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,487
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,127
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,289