zoukankan      html  css  js  c++  java
  • VTK初学一,e_Triangle_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 "vtkTriangle.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> 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> pointsScalars=vtkSmartPointer<vtkFloatArray>::New();
        pointsScalars->SetNumberOfTuples(3);
        pointsScalars->SetValue(0,0);
        pointsScalars->SetValue(1,1);
        pointsScalars->SetValue(2,0);
        //形成组元数据
        vtkSmartPointer<vtkCellArray> lines=vtkSmartPointer<vtkCellArray>::New();
        lines->InsertNextCell(4);
        lines->InsertCellPoint(0);
        lines->InsertCellPoint(1);
        lines->InsertCellPoint(2);
        lines->InsertCellPoint(0);
        //几何轮廓
        vtkSmartPointer<vtkPolyData> profile=vtkSmartPointer<vtkPolyData>::New();
        profile->SetPoints(trianglePoints);
        profile->SetLines(lines);
        profile->GetPointData()->SetScalars(pointsScalars);
        myShow(profile);
        return 0;
    }

    
    
  • 相关阅读:
    ubuntu,day1基础命令,shutdown,man,touch,rm,mv,cp,stat,locale,apt,date,tzselect,cal,快捷方式,echo,查看文件
    day 7 编码
    NO.6 appium-网络设置
    NO.5 appium-滑动和点击
    NO.4 appium-定位
    NO.3 appium-退出/启动
    NO.2 appium-安装和卸载
    NO.1 appium-关于输入法
    Springboot框架搭建
    遍历Map的四种方法
  • 原文地址:https://www.cnblogs.com/phoenixdsg/p/6116452.html
Copyright © 2011-2022 走看看