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;
}
相关推荐
骄傲的心别枯萎41 分钟前
RV1126 NO.16:通过多线程同时获取H264和H265码流
linux·c++·音视频·rv1126
落羽的落羽1 小时前
【C++】特别的程序错误处理方式——异常机制
开发语言·c++
空山新雨(大队长)1 小时前
C 语言第一课:hello word c
c++·c·exe
张子夜 iiii1 小时前
实战项目-----在图片 hua.png 中,用红色画出花的外部轮廓,用绿色画出其简化轮廓(ε=周长×0.005),并在同一窗口显示
人工智能·pytorch·python·opencv·计算机视觉
春蕾夏荷_7282977251 小时前
c++ 第三方库与个人封装库
c++·三方库
牵牛老人1 小时前
Qt C++ 复杂界面处理:巧用覆盖层突破复杂界面处理难题之一
数据库·c++·qt
离越词2 小时前
C++day8作业
开发语言·c++·windows
MMjeaty2 小时前
deque容器
c++
CYRUS_STUDIO2 小时前
如何防止 so 文件被轻松逆向?精准控制符号导出 + JNI 动态注册
android·c++·安全
CYRUS_STUDIO2 小时前
C&C++ 代码安全再升级:用 OLLVM 给 so 加上字符串加密保护
c++·安全·llvm