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;
}
相关推荐
眠りたいです4 分钟前
现代C++:C++11并发支持库
开发语言·c++·多线程·c++11·c++并发支持库
小灰灰搞电子10 分钟前
Rust可以取代C++么?
开发语言·c++·rust
一个没有感情的程序猿36 分钟前
前端实现人体骨架检测与姿态对比:基于 MediaPipe 的完整方案
机器学习·计算机视觉·前端框架·开源
微笑倾城1 小时前
Windows平台下CMake工程中使用protobuf
c++·cmake
AA陈超1 小时前
枚举类 `ETriggerEvent`
开发语言·c++·笔记·学习·ue5
C语言小火车1 小时前
【C++】学生管理系统设计与实现丨SQLite数据库版本
开发语言·c++
ccLianLian1 小时前
计算机视觉·LaVG
人工智能·计算机视觉
charlie1145141912 小时前
AVX 指令集系列深度介绍:领域、意义、以及 AVX AVX2 的基本用法与样例
开发语言·c++·人工智能·软件工程·并行计算·avx
曼巴UE52 小时前
UE C++ UI的折叠动画,隐藏收缩经验分享
c++·ue5