VTK初学一,b_PolyVertex多个图形点的绘制
#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 "vtkPolyVertex.h"
#include "vtkInteractorStyleTrackballCamera.h"
void myShow(vtkSmartPointer<vtkUnstructuredGrid> aGrid);
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<vtkFloatArray>pointsScalars=vtkSmartPointer<vtkFloatArray>::New();
pointsScalars->SetNumberOfTuples(5);//此行可有可无
pointsScalars->InsertValue(0,0);//第1个参数是points点的Id,第2个参数是该点的属性值
pointsScalars->InsertValue(1,0);//第1个参数是points点的Id,第2个参数是该点的属性值
pointsScalars->InsertValue(2,0);//第1个参数是points点的Id,第2个参数是该点的属性值
pointsScalars->InsertValue(3,0);//第1个参数是points点的Id,第2个参数是该点的属性值
pointsScalars->InsertValue(4,0);//第1个参数是points点的Id,第2个参数是该点的属性值
//将以上三部分数据组合成一个结构vtkUnstructureGrid
vtkSmartPointer<vtkUnstructuredGrid> aGrid=vtkSmartPointer<vtkUnstructuredGrid>::New();
aGrid->Allocate(1,1);
aGrid->SetPoints(points);
aGrid->GetPointData()->SetScalars(pointsScalars);
aGrid->InsertNextCell(polyVertex->GetCellType(),polyVertex->GetPointIds());
//在窗口中显示多个Vertex
myShow(aGrid);
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()->SetDiffuseColor(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初学一,b_PolyVertex多个图形点的绘制的更多相关文章
- VTK初学一,b_PolyVertex_CellArray多个点的绘制
#ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> VTK_MODULE_INIT(vtkRend ...
- 借助Photoshop,Illustrator等设计软件进行WPF图形图像的绘制
原文:借助Photoshop,Illustrator等设计软件进行WPF图形图像的绘制 本文所示例子是借助第三方设计软件,制作复杂的矢量图形,转成与XAML酷似的SVG,再转换成xaml而实现的. 这 ...
- 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初学一,c_Line_CellArray线段的CellArray绘制
VTK窗口默认坐标方向: #ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> VTK_MODULE ...
- 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 ...
随机推荐
- 数组内部对象排序(sort)
1.数组排序有很多方法比如for,while循环去进行冒泡排序或者快速看.排序等多种排序方法 而我在这里要说的是苹果API提供的几个系统方法 a.迭代器 Descriptor b.方法比较 ...
- 判断请求是不是ajax
public static bool IsAjaxRequest(HttpRequest request) { if (request == null) { throw new ArgumentNul ...
- 分布式ID生成器
最近会写一篇分布式的ID生成器的文章,先占位.借鉴Mongodb的ObjectId的生成: 4byte时间戳 + 3byte机器标识 + 2byte PID + 3byte自增id 简单代码: imp ...
- (转载)最长递增子序列 O(NlogN)算法
原博文:传送门 最长递增子序列(Longest Increasing Subsequence) 下面我们简记为 LIS. 定义d[k]:长度为k的上升子序列的最末元素,若有多个长度为k的上升子序列,则 ...
- Beta版本——第二次冲刺博客
我说的都队 031402304 陈燊 031402342 许玲玲 031402337 胡心颖 03140241 王婷婷 031402203 陈齐民 031402209 黄伟炜 031402233 郑扬 ...
- 王高利:Linux__apache,安装,报错解决
今日编译apache时出错:#./configure --prefix--检查编辑环境时出现:checking for APR... noconfigure: error: APR not found ...
- hibernate......1、2级缓存
1.什么是缓存? 缓存是介于物理数据源与应用程序之间,是对数据库中的数据复制一份临时放在内存中的容器,其作用是为了减少应用程序对物理数据源访问的次数,从而提高了应用程序的运行性能.Hibernate在 ...
- JavaWeb---总结(九)通过Servlet生成验证码图片
一.BufferedImage类介绍 生成验证码图片主要用到了一个BufferedImage类,如下: 创建一个DrawImage Servlet,用来生成验证码图片 1 package gacl. ...
- json的解释
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.JSON采用完全独立于语言的文本格式,这些特性使JSON成为理想的数据交换语言.易于人阅读和编写,同时也易 ...
- js020-JSON
js020-JSON 20.1 语法 JSON的语法可以表示为一下三种类型的值. 简单值 使用与JS相同的语法,可以在JSON中表示字符串.数值.布尔值和null,但是JSON不支持JS中的特殊性Un ...