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;
}
相关推荐
-dzk-7 小时前
【代码随想录】LC 59.螺旋矩阵 II
c++·线性代数·算法·矩阵·模拟
大山同学7 小时前
图片补全-Context Encoder
人工智能·机器学习·计算机视觉
m0_706653238 小时前
C++编译期数组操作
开发语言·c++·算法
qq_423233908 小时前
C++与Python混合编程实战
开发语言·c++·算法
m0_715575349 小时前
分布式任务调度系统
开发语言·c++·算法
CSDN_RTKLIB9 小时前
简化版unique_ptr说明其本质
c++
naruto_lnq9 小时前
泛型编程与STL设计思想
开发语言·c++·算法
m0_7487080510 小时前
C++中的观察者模式实战
开发语言·c++·算法
时光找茬10 小时前
【瑞萨AI挑战赛-FPB-RA6E2】+ 从零开始:FPB-RA6E2 开箱测评与 e2 studio 环境配置
c++·单片机·边缘计算
qq_5375626710 小时前
跨语言调用C++接口
开发语言·c++·算法