惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
有赞技术团队
有赞技术团队
H
Help Net Security
V
Visual Studio Blog
F
Fortinet All Blogs
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 司徒正美
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
腾讯CDC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Stack Overflow Blog
Stack Overflow Blog
I
InfoQ
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
L
LangChain Blog
N
Netflix TechBlog - Medium
罗磊的独立博客
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
Hugging Face - Blog
Hugging Face - Blog
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
Recent Announcements
Recent Announcements

博客园 - 上位机

wkhtmltopdf chart.js 浏览器打开html是正常的,输出pdf时,图表时无法显示问题 opencv 4.x 静态编译后 录像视频保存为h264 Qt 5 QFormLayout 隐藏一行 或 重新布局 opencv imshow 大图片显示,拖动显示 Qt QTtoolButton 鼠标移动到按钮上时,弹出菜单后,按钮的hover状态无法恢复的问题 std的map或者set中,比较浮点类型二维三维数据 Qt 子窗口 隐藏标题栏的图标,在任务栏上的不显示 windbg 调试 c++ std::exception VS C++ 出现debug assertion failed弹框,怎么定位代码 QTabWidget的高度取决于当前选项卡的高度 Qt tr 无法翻译 Qt 窗口随控件变换大小 vtkCellLocator IntersectWithLine 返回不是最近的交点 设置QToolBar的Action图标之间的间隔 Visual Studio 2017 rc 资源文件 预处理 宏 无效 Qt No Target Architecture vtkDelaunay2D 错误 Edge not recovered, polygon fill suspect VTK vtkAssembly 拾取 Qt 在线程中invokeMethod采用QueuedConnection模式,调用带指针参数槽,实际不会调用
vtkImageData的GetScalarPointer参数范围和SetExtent的范围相关
上位机 · 2025-09-04 · via 博客园 - 上位机

根据VTK源码的

vtkIdType vtkImageData::GetTupleIndex(vtkDataArray* array, int coordinate[3])
{
  vtkIdType incs[3];
  vtkIdType idx;

  if (array == nullptr)
  {
    return -1;
  }

  const int* extent = this->Extent;
  // error checking: since most accesses will be from pointer arithmetic.
  // this should not waste much time.
  for (idx = 0; idx < 3; ++idx)
  {
    if (coordinate[idx] < extent[idx * 2] || coordinate[idx] > extent[idx * 2 + 1])
    {
      vtkErrorMacro(<< "GetPointer: Pixel (" << coordinate[0] << ", " << coordinate[1] << ", "
                    << coordinate[2] << ") not in current extent: (" << extent[0] << ", "
                    << extent[1] << ", " << extent[2] << ", " << extent[3] << ", " << extent[4]
                    << ", " << extent[5] << ")");
      return -1;
    }
  }

  // compute the index of the vector.

  // Array increments incorporate the number of components, which is not how
  // vtkDataArrays are indexed. Instead, compute the tuple increments.
  {
    incs[0] = 1;
    incs[1] = (extent[1] - extent[0] + 1);
    incs[2] = incs[1] * (extent[3] - extent[2] + 1);
  }

  idx = ((coordinate[0] - extent[0]) * incs[0] + (coordinate[1] - extent[2]) * incs[1] +
    (coordinate[2] - extent[4]) * incs[2]);
  // I could check to see if the array has the correct number
  // of tuples for the extent, but that would be an extra multiply.
  if (idx < 0 || idx > array->GetMaxId())
  {
    vtkErrorMacro("Coordinate (" << coordinate[0] << ", " << coordinate[1] << ", " << coordinate[2]
                                 << ") out side of array (max = " << array->GetMaxId());
    return -1;
  }

  return idx;
}

最后idx索引的计算需要减去extent后,计算得到。