vtk多维数组


开发环境

  1. Windows 11 家庭中文版
  2. Microsoft Visual Studio Community 2019
  3. VTK-9.3.0.rc0
  4. vtk-example
  5. 参考代码

demo解决问题 :N维数组,类似于numpy; 主要感受下调用接口功能: GetExtents() getBegin() getEnd()

参考:vtkInteractorStyle详细介绍


cpp 复制代码
#include <vtkDenseArray.h>
#include <vtkNew.h>

int main(int, char*[])
{
  vtkNew<vtkDenseArray<double>> array;

  array->Resize(5, 5);

  array->SetValue(4, 4, 5.0);

  std::cout << array->GetValue(4, 4) << std::endl;

  return EXIT_SUCCESS;
}
cpp 复制代码
#include <vtkDenseArray.h>
#include <vtkNew.h>

int main(int, char*[])
{
  // Create an N-D array
  vtkNew<vtkDenseArray<double>> array;

  // Resize the array to 4x5x3
  array->Resize(4, 5, 3);

  // Set a value
  int i = 0;
  int j = 0;
  int k = 0;
  double value = 3.0;
  array->SetValue(i, j, k, value);

  // Get a value
  std::cout << array->GetValue(i, j, k) << std::endl;

  //Returns the extents (the number of dimensions and size along each dimension) of the array.
  // Get size (bounds) of whole array
  cout << array->GetExtents() << endl;//[0,4)x[0,5)x[0,3)

  // Get size (bounds) of array dimensions
  std::cout << array->GetExtents()[0] << std::endl;//[0, 4)
  std::cout << array->GetExtents()[1] << std::endl;//[0, 5)
  std::cout << array->GetExtents()[2] << std::endl;//[0, 3)

  // Get the bounds of the 0th dimension
  std::cout << array->GetExtents()[0].GetBegin() << std::endl;//0
  std::cout << array->GetExtents()[0].GetEnd() << std::endl;//4

  return EXIT_SUCCESS;
}
相关推荐
从零开始的代码生活_5 分钟前
C++ list 原理与实践:双向链表、迭代器与简化实现
开发语言·c++·后端·学习·算法·链表·list
charlie11451419116 分钟前
现代C++工程实践——WeakPtr 第二关:核心骨架与控制块
开发语言·c++
2401_8697695942 分钟前
内容9 string 1
c++
XH华2 小时前
C++语言第二章类和对象(下)
开发语言·c++
从零开始的代码生活_2 小时前
C++ stack、queue 与 priority_queue:容器适配器原理与实战
开发语言·c++·后端·学习·算法
AA陈超4 小时前
003 XiYou 西游 — P0 阶段实施计划
c++·笔记·学习·ue5
黑不溜秋的4 小时前
C++ STL 容器使用的底层数据结构
c++
灵晔君4 小时前
【C++】标准模板库STL——set /multiset/map /multimap
开发语言·c++
noipp5 小时前
推荐题目:洛谷 P13554 【MX-X15-T1】奶龙龙
c语言·数据结构·c++·算法·编程·洛谷
库玛西6 小时前
深入剖析 Linux 线程机制与分页式存储管理
linux·服务器·c++·笔记