/*=========================================================================
Program: Visualization Toolkit
Module: Cube.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// This example shows how to manually create vtkPolyData.
// For a python version, please see:
// [Cube](https://lorensen.github.io/VTKExamples/site/Python/DataManipulation/Cube/)
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);
#include <vtkActor.h>
#include <vtkCamera.h>
#include <vtkCellArray.h>
#include <vtkFloatArray.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkPointData.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <array>
int main()
{
vtkNew<vtkNamedColors> colors;
std::array<std::array<double, 3>, 8> pts = { {{{0, 0, 0}},
{{1, 0, 0}},
{{1, 1, 0}},
{{0, 1, 0}},
{{0, 0, 1}},
{{1, 0, 1}},
{{1, 1, 1}},
{{0, 1, 1}}} };
// The ordering of the corner points on each face.
std::array<std::array<vtkIdType, 4>, 6> ordering = { {{{0, 1, 2, 3}},
{{4, 5, 6, 7}},
{{0, 1, 5, 4}},
{{1, 2, 6, 5}},
{{2, 3, 7, 6}},
{{3, 0, 4, 7}}} };
// We'll create the building blocks of polydata including data attributes.
vtkNew<vtkPolyData> cube;
vtkNew<vtkPoints> points;
vtkNew<vtkCellArray> polys;
vtkNew<vtkFloatArray> scalars;
// Load the point, cell, and data attributes.
for (auto i = 0ul; i < pts.size(); ++i)
{
points->InsertPoint(i, pts[i].data());
scalars->InsertTuple1(i, i);
}
for (auto&& i : ordering)
{
polys->InsertNextCell(vtkIdType(i.size()), i.data());
}
// We now assign the pieces to the vtkPolyData.
cube->SetPoints(points);
cube->SetPolys(polys);
cube->GetPointData()->SetScalars(scalars);
// Now we'll look at it.
vtkNew<vtkPolyDataMapper> cubeMapper;
cubeMapper->SetInputData(cube);
cubeMapper->SetScalarRange(cube->GetScalarRange());
vtkNew<vtkActor> cubeActor;
cubeActor->SetMapper(cubeMapper);
// The usual rendering stuff.
vtkNew<vtkCamera> camera;
camera->SetPosition(1, 1, 1);
camera->SetFocalPoint(0, 0, 0);
vtkNew<vtkRenderer> renderer;
vtkNew<vtkRenderWindow> renWin;
renWin->AddRenderer(renderer);
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(renWin);
renderer->AddActor(cubeActor);
renderer->SetActiveCamera(camera);
renderer->ResetCamera();
renderer->SetBackground(colors->GetColor3d("Cornsilk").GetData());
renWin->SetSize(600, 600);
// interact with data
renWin->Render();
iren->Start();
return EXIT_SUCCESS;
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Win10下使用CMAKE+VS2017编译VTK8.2步骤带图文和测试源码 (156个子文件)
helloVtk.cpp 3KB
Browse.VC.db 28.36MB
vtkhdf5-8.2.dll 2.86MB
vtkFiltersCore-8.2.dll 2.83MB
vtkCommonDataModel-8.2.dll 2.79MB
vtkCommonCore-8.2.dll 2.76MB
vtkFiltersGeneral-8.2.dll 2.17MB
vtkRenderingVolume-8.2.dll 1.93MB
vtkInteractionWidgets-8.2.dll 1.56MB
vtkRenderingOpenGL2-8.2.dll 1.49MB
vtkRenderingCore-8.2.dll 1.47MB
vtkImagingCore-8.2.dll 1.24MB
vtklibxml2-8.2.dll 1.15MB
vtkIOGeometry-8.2.dll 979KB
vtkChartsCore-8.2.dll 871KB
vtkIOImage-8.2.dll 798KB
vtksqlite-8.2.dll 710KB
vtkRenderingAnnotation-8.2.dll 702KB
vtkFiltersHybrid-8.2.dll 693KB
vtkFiltersPoints-8.2.dll 690KB
vtkIOXML-8.2.dll 689KB
vtklibharu-8.2.dll 689KB
vtkFiltersExtraction-8.2.dll 661KB
vtkInfovisCore-8.2.dll 645KB
vtkRenderingFreeType-8.2.dll 643KB
vtkFiltersStatistics-8.2.dll 621KB
vtkNetCDF-8.2.dll 614KB
vtkImagingGeneral-8.2.dll 599KB
vtkFiltersParallel-8.2.dll 583KB
vtkIOExodus-8.2.dll 575KB
vtkCommonExecutionModel-8.2.dll 559KB
vtkmetaio-8.2.dll 542KB
vtkViewsInfovis-8.2.dll 532KB
vtkRenderingVolumeOpenGL2-8.2.dll 508KB
vtkIOLegacy-8.2.dll 469KB
vtkFiltersSources-8.2.dll 463KB
vtkRenderingLabel-8.2.dll 450KB
vtkfreetype-8.2.dll 440KB
vtkglew-8.2.dll 439KB
vtkIOEnSight-8.2.dll 409KB
vtkIOExport-8.2.dll 402KB
vtkFiltersModeling-8.2.dll 401KB
vtktiff-8.2.dll 392KB
vtkFiltersFlowPaths-8.2.dll 387KB
vtkIONetCDF-8.2.dll 374KB
vtkInfovisLayout-8.2.dll 371KB
vtkFiltersGeometry-8.2.dll 369KB
vtkIOParallel-8.2.dll 367KB
vtkIOCore-8.2.dll 341KB
vtkIOInfovis-8.2.dll 330KB
vtkImagingMorphological-8.2.dll 328KB
vtkGeovisCore-8.2.dll 324KB
vtkproj-8.2.dll 318KB
vtkjpeg-8.2.dll 313KB
vtkImagingHybrid-8.2.dll 310KB
vtkParallelCore-8.2.dll 309KB
vtkDomainsChemistry-8.2.dll 308KB
vtksys-8.2.dll 306KB
vtkexodusII-8.2.dll 304KB
vtkIOMINC-8.2.dll 301KB
vtkGUISupportQt-8.2.dll 282KB
vtkIOLSDyna-8.2.dll 274KB
vtkFiltersSMP-8.2.dll 270KB
vtkIOImport-8.2.dll 242KB
vtkIOSQL-8.2.dll 230KB
vtkIOAMR-8.2.dll 228KB
vtkImagingColor-8.2.dll 213KB
vtkjsoncpp-8.2.dll 212KB
vtktheora-8.2.dll 205KB
vtkRenderingContext2D-8.2.dll 203KB
vtkInteractionStyle-8.2.dll 195KB
vtkpng-8.2.dll 187KB
vtkImagingMath-8.2.dll 187KB
vtkpugixml-8.2.dll 173KB
vtkRenderingContextOpenGL2-8.2.dll 171KB
vtkImagingSources-8.2.dll 169KB
vtkViewsQt-8.2.dll 169KB
vtkCommonTransforms-8.2.dll 167KB
vtkverdict-8.2.dll 152KB
vtklzma-8.2.dll 150KB
vtkCommonComputationalGeometry-8.2.dll 148KB
vtkRenderingImage-8.2.dll 138KB
vtkFiltersGeneric-8.2.dll 137KB
vtkexpat-8.2.dll 137KB
vtkFiltersAMR-8.2.dll 133KB
vtkIOParallelXML-8.2.dll 131KB
vtkImagingStencil-8.2.dll 125KB
vtkFiltersHyperTree-8.2.dll 124KB
vtkCommonMath-8.2.dll 118KB
vtkhdf5_hl-8.2.dll 116KB
vtkImagingStatistics-8.2.dll 116KB
vtkViewsCore-8.2.dll 116KB
vtkCommonMisc-8.2.dll 114KB
vtkDICOMParser-8.2.dll 110KB
vtkImagingFourier-8.2.dll 107KB
vtkFiltersVerdict-8.2.dll 103KB
vtkCommonColor-8.2.dll 103KB
vtkIOCityGML-8.2.dll 101KB
vtkIOExportPDF-8.2.dll 99KB
vtkIOXMLParser-8.2.dll 94KB
共 156 条
- 1
- 2
资源评论
疾风铸境
- 粉丝: 594
- 资源: 78
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功