#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 "vtkTriangle.h"
#include <vtkInteractorStyleTrackballCamera.h>
void myShow(vtkUnstructuredGrid* aGrid)
{
    vtkSmartPointer<vtkDataSetMapper> aMapper=vtkSmartPointer<vtkDataSetMapper>::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);

    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> trianglePoints=vtkSmartPointer<vtkPoints>::New();
    trianglePoints->SetNumberOfPoints(3);
    trianglePoints->InsertPoint(0,0,0,0);
    trianglePoints->InsertPoint(1,1,0,0);
    trianglePoints->InsertPoint(2,1,1,1);
    //属性数据
    vtkSmartPointer<vtkFloatArray> triangleScalars=vtkSmartPointer<vtkFloatArray>::New();
    triangleScalars->SetNumberOfTuples(3);
    triangleScalars->InsertValue(0,0);
    triangleScalars->InsertValue(1,0);
    triangleScalars->InsertValue(2,1);
    //拓扑结构
    vtkSmartPointer<vtkTriangle> aTriangle=vtkSmartPointer<vtkTriangle>::New();
    aTriangle->GetPointIds()->SetNumberOfIds(3);
    aTriangle->GetPointIds()->SetId(0,0);
    aTriangle->GetPointIds()->SetId(1,1);
    aTriangle->GetPointIds()->SetId(2,2);
    //将以上三部分组装成一个结构
    vtkSmartPointer<vtkUnstructuredGrid> aTriangleGrid=vtkSmartPointer<vtkUnstructuredGrid>::New();
    aTriangleGrid->Allocate(1,1);
    aTriangleGrid->SetPoints(trianglePoints);
    aTriangleGrid->GetPointData()->SetScalars(triangleScalars);
    aTriangleGrid->InsertNextCell(aTriangle->GetCellType(),aTriangle->GetPointIds());
    //显示triangle
    myShow(aTriangleGrid);
    return 0;
}

												

VTK初学一,e_Triangle三角形的绘制的更多相关文章

  1. VTK初学一,e_Triangle_CellArray三角形的另一种方法绘制

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

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

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

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

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

  4. VTK初学一,b_PolyVertex_CellArray多个点的绘制

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

  5. VTK初学一,b_PolyVertex多个图形点的绘制

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

  6. IOS 绘制基本图形( 画圆、画线、画圆弧、绘制三角形、绘制四边形)

    // 当自定义view第一次显示出来的时候就会调用drawRect方法- (void)drawRect:(CGRect)rect { // 1.获取上下文 CGContextRef ctx = UIG ...

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

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

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

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

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

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

随机推荐

  1. Windows Directory ACL Security Check By ACL Baseline

    catalog . Windows NTFS ACL(MAC) Permission . How the System Uses ACLs . 服务器不安全ACL配置带来的攻击向量 . NTFS AC ...

  2. lua的corroutine学习

    lua的corroutine学习 function receive (prod) local status, value = coroutine.resume(prod) return value e ...

  3. 使用convert来批量处理图片

    这是个神奇的工具,居然使用命令行就可以这么方便的处理图片.功能有待挖掘. 这个是把图片批量进行 resize 的脚本. #!/bin/sh counter= root=mypict resolutio ...

  4. fabric note

    #!/usr/bin/env python # -*- coding:utf-8 -*- from fabric.api import * from fabric.context_managers i ...

  5. C# 获取当前,相对,绝对路径

    一.C#获取当前路径的方法: 1. System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName -获取模块的完整路径. 2. ...

  6. Linux安装配置sun-java

    一(不推荐) 1. 下载源码与解压 将下载的源码包,移动到/opt目录下: $ sudo mv ~/Downloads/jdk-8u65-linux-x64.tar.gz  /opt/ 解压: $ s ...

  7. python学习笔记-(八)装饰器、生成器&迭代器

    本节课程内容概览: 1.装饰器 2.列表生成式&迭代器&生成器 3.json&pickle数据序列化 1. 装饰器 1.1 定义: 本质上是个函数,功能是装饰其他函数—就是为其 ...

  8. SMTP邮箱验证错误解决

    开始报错,是因为权限设置问题,谷歌对第三方应用登录默认关闭,需要开通后python才能自动访问邮件 SMTPAuthenticationError: (502, b'5.5.1 Unrecognize ...

  9. 为什么可以用while(cin)?

    为什么可以用while(cin)?   /** * @brief The quick-and-easy status check. * * This allows you to write const ...

  10. wordpress后台404页面

    就在刚刚,boss需要看公司网站后台,网站是用wordpress搭的,发现全是404,蛋疼,于是google,下面是解决办法: location / { if (-f $request_filenam ...