#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多个点的绘制的更多相关文章

  1. VTK初学一,c_Line_CellArray线段的CellArray绘制

    VTK窗口默认坐标方向: #ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> VTK_MODULE ...

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

    系统:Win8.1 QT版本:2.4.2,Mingw VTK版本:6.3 2. main.cpp #ifndef INITIAL_OPENGL #define INITIAL_OPENGL #incl ...

  3. VTK初学一,比较常见的错误2

    我的开发环境: 系统:win8.1 QT:5.4.2MinGW版 VTK:6.3 按照教程生成一个球体显示在,Qt的QVTKWidget控件中,出现如下ERROR: ERROR: In D:\VTK6 ...

  4. VTK初学一,动画加AVI录制终于做出来了

      #ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> VTK_MODULE_INIT(vtkRe ...

  5. VTK初学一,vtkDelaunay2D创建球冠曲面

    #ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> VTK_MODULE_INIT(vtkRend ...

  6. VTK初学一,比较常见的错误1

      错误原因: 通常是在文件头部没有初始化 #ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> V ...

  7. VTK初学一,a Mesh from vtkImageData—球冠

    #ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> VTK_MODULE_INIT(vtkRend ...

  8. VTK初学一,a Mesh from vtkImageData

    #ifndef INITIAL_OPENGL #define INITIAL_OPENGL #include <vtkAutoInit.h> VTK_MODULE_INIT(vtkRend ...

  9. VTK初学一,Pro文件的配置

    1. pro文件的配置 TEMPLATE = app CONFIG += console CONFIG -= app_bundle CONFIG += qt QT += core gui greate ...

随机推荐

  1. ubuntu下gedit中文乱码

    gsettings set org.gnome.gedit.preferences.encodings auto-detected "['GB18030', 'GB2312', 'GBK', ...

  2. rfc2616 HTTP Protocl Analysis

    catalog . Introduction . Protocol Parameters . HTTP Message . Request . Response . HTTP Method.Conte ...

  3. 使用dnsmasq来提升CentOS上网速度

    1. 安装dnsmasq dnsmasq的官方网址是:http://www.thekelleys.org.uk/dnsmasq/doc.html.利用里面的下载链接下载dnsmasq-2.72.tar ...

  4. checking for tgetent()... configure: error: NOT FOUND!

    今天centos出现了下面的异常: checking for tgetent()... configure: error: NOT FOUND! You need to install a termi ...

  5. django数据库时间存储格式问题

    http://blog.csdn.net/ichuzhen/article/details/38555645 一般建议用datefield 关于从数据库读取出来格式问题可以看 http://stack ...

  6. BZOJ1691: [Usaco2007 Dec]挑剔的美食家

    传送门: 一句话题解:贪心+treap 好几天前刚学的treap,然后真到了考treap又写不出来,这么辣鸡还搞什么OI 先按$A_i$递减排序,然后把$C_i$也递减排序,然后用一个指针指向$M$序 ...

  7. 电脑技巧:Win8/Win10无法打开这个应用|无法使用内置管理员账户的完美解决方法

    现在装win10系统的同伴越来越多了,相比于win7,win10在某些设置方面也有些变化,比如我们在使用win8或者win10时,会碰到如图所示的对话框: Windows10/Windows8无法使用 ...

  8. linq 之 Distinct的使用

    public class Product { public string Name { get;set;} public int Code { get; set; } } class ProductC ...

  9. 初识Hadoop一,配置及启动服务

    一.Hadoop简介: Hadoop是由Apache基金会所开发的分布式系统基础架构,实现了一个分布式文件系统(Hadoop Distributed File System),简称HDFS:Hadoo ...

  10. mvc-1