VTK初学一,b_PolyVertex_CellArray多个点的绘制
#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 "vtkPolyVertex.h"
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkCellArray.h>
void myShow(vtkPolyData* aGrid)
{
vtkSmartPointer<vtkPolyDataMapper> aMapper=vtkSmartPointer<vtkPolyDataMapper>::New();
aMapper->SetInputData(aGrid);
aMapper->ScalarVisibilityOn();
vtkSmartPointer<vtkActor> anActor=vtkSmartPointer<vtkActor>::New();
anActor->SetMapper(aMapper);
anActor->GetProperty()->SetRepresentationToWireframe();
anActor->GetProperty()->SetDiffuseColor(1,1,1);
anActor->GetProperty()->SetLineWidth(10);
anActor->GetProperty()->SetPointSize(30);
vtkSmartPointer<vtkRenderer> ren1=vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renWin=vtkSmartPointer<vtkRenderWindow>::New();
ren1->AddActor(anActor);
ren1->ResetCamera();
renWin->AddRenderer(ren1);
renWin->SetSize(512,512);
vtkSmartPointer<vtkRenderWindowInteractor> iren=vtkSmartPointer<vtkRenderWindowInteractor>::New();
vtkSmartPointer<vtkInteractorStyleTrackballCamera> style=vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
iren->SetRenderWindow(renWin);
iren->SetInteractorStyle(style);
iren->Start();
}
int main()
{
//几何数据
vtkSmartPointer<vtkPoints> points=vtkSmartPointer<vtkPoints>::New();
points->SetNumberOfPoints(5);
points->InsertPoint(0,0,0,0);
points->InsertPoint(1,0.5,0.5,0);
points->InsertPoint(2,-0.3,-0.2,0);
points->InsertPoint(3,0.8,-0.5,0);
points->InsertPoint(4,1,0.5,0.3);
//拓扑结构数据
vtkSmartPointer<vtkPolyVertex> polyVertex=vtkSmartPointer<vtkPolyVertex>::New();
polyVertex->GetPointIds()->SetNumberOfIds(5);//必须设置Id个数,否则可以编译,不能运行
polyVertex->GetPointIds()->SetId(0,0);//第一个参数是几何point的ID号,第2个参数是拓扑中的Id号
polyVertex->GetPointIds()->SetId(1,1);
polyVertex->GetPointIds()->SetId(2,2);
polyVertex->GetPointIds()->SetId(3,3);
polyVertex->GetPointIds()->SetId(4,4);
//以上数据形成单元数组
vtkSmartPointer<vtkCellArray> vertexCells=vtkSmartPointer<vtkCellArray>::New();
vertexCells->InsertNextCell(polyVertex);
//点的属性数据
vtkSmartPointer<vtkFloatArray> pointsScalars=vtkSmartPointer<vtkFloatArray>::New();
pointsScalars->SetNumberOfTuples(5);
pointsScalars->SetValue(0,0);
pointsScalars->SetValue(1,1);
pointsScalars->SetValue(2,0);
pointsScalars->SetValue(3,0);
pointsScalars->SetValue(4,0);
//以上数据组装成PolyData
vtkSmartPointer<vtkPolyData> polydata=vtkSmartPointer<vtkPolyData>::New();
polydata->SetPoints(points);
polydata->SetVerts(vertexCells);
polydata->GetPointData()->SetScalars(pointsScalars);
//在窗口中显示
myShow(polydata);
return 0;
}

VTK初学一,b_PolyVertex_CellArray多个点的绘制的更多相关文章
- VTK初学一,c_Line_CellArray线段的CellArray绘制
VTK窗口默认坐标方向: #ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> VTK_MODULE ...
- VTK初学一,a_Vertex图形点的绘制
系统:Win8.1 QT版本:2.4.2,Mingw VTK版本:6.3 2. main.cpp #ifndef INITIAL_OPENGL #define INITIAL_OPENGL #incl ...
- VTK初学一,比较常见的错误2
我的开发环境: 系统:win8.1 QT:5.4.2MinGW版 VTK:6.3 按照教程生成一个球体显示在,Qt的QVTKWidget控件中,出现如下ERROR: ERROR: In D:\VTK6 ...
- VTK初学一,动画加AVI录制终于做出来了
#ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> VTK_MODULE_INIT(vtkRe ...
- VTK初学一,vtkDelaunay2D创建球冠曲面
#ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> VTK_MODULE_INIT(vtkRend ...
- VTK初学一,比较常见的错误1
错误原因: 通常是在文件头部没有初始化 #ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> V ...
- VTK初学一,a Mesh from vtkImageData—球冠
#ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> VTK_MODULE_INIT(vtkRend ...
- VTK初学一,a Mesh from vtkImageData
#ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> VTK_MODULE_INIT(vtkRend ...
- VTK初学一,Pro文件的配置
1. pro文件的配置 TEMPLATE = app CONFIG += console CONFIG -= app_bundle CONFIG += qt QT += core gui greate ...
随机推荐
- POJ2195 Going Home
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22091 Accepted: 11156 Description On ...
- [NOIP2012] 提高组 洛谷P1079 Vigenère 密码
题目描述 16 世纪法国外交家 Blaise de Vigenère 设计了一种多表密码加密算法――Vigenère 密 码.Vigenère 密码的加密解密算法简单易用,且破译难度比较高,曾在美国南 ...
- python——代码编码格式转换
最近刚换工作不久,没太多的时间去整理工作中的东西,大部分时间都在用来熟悉新公司的业务,熟悉他们的代码框架了,最主要的是还有很多新东西要学,我之前主要是做php后台开发的,来这边之后还要把我半路出家的前 ...
- UEditor上传图片到七牛云储存(java)
我们的网站一般放在虚拟空间或者服务器上,图片如果存在本地目录,会占用很多空间和流量,还增加了负担,好的办法是把图片存放到云储存服务里面,平时用url去拿 云储存:普遍说又拍云和七牛比较好,看到七牛免费 ...
- HTML5系列二(标签元素、FileReader、拖放)
nav元素的使用场合 页面中可以包含多个nav元素,通常情况下头部和尾部都会包含导航,这样提高了可访问性,访客能够清晰的将其辨认出来.nav元素是一个可以用来作为页面导航的链接组:其中的导航元素链接到 ...
- 【转载】Linux 与 BSD 有什么不同?
原创:Linux中国 https://linux.cn/article-3186-1.html 原创:LCTT https://linux.cn/article-3186-1.html 本文地址:ht ...
- wcf第2步之服务端标准配置文件
服务端app.config <?xml version="1.0" encoding="utf-8" ?><configuration> ...
- 电脑中的Bois是什么
电脑中的Bois是什么 BOIS= Basic Input/Output System,基本输入输出系统,全称是ROM-BOIS,是只读存储器基本输入/输出系统的简写,它实际是一组被固化到电脑中,为电 ...
- PL/SQL 中查询CLOB字段内容
oracle中的clob类型字段不能直接显示出来,需要借助Oracle系统dbms_lob中substr方法处理,如select dbms_lob.substr(clobField) from tab ...
- HDU 1326 Box of Bricks(水~平均高度求最少移动砖)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1326 题目大意: 给n堵墙,每个墙的高度不同,求最少移动多少块转使得墙的的高度相同. 解题思路: 找到 ...