Extents
The extent of a dataset is a set of 6 integers. It says what the first and last pixel indices are in each of the three directions. E.g.
int extent[6] = { i_min, i_max, j_min, j_max, k_min, k_max };
VTK images (and grids) do not always start at (i,j,k) = (0,0,0). They can start anywhere. They can even start at negative indices. One of the beautiful things about the VTK streaming pipeline is that VTK can take just one slice of an image e.g. at k=10 and pass just that one slice along the pipeline.
一个Dataset的Extent是一组6个整数。它指的是三个方向中每个方向的第一个和最后一个像素的索引。
VTK图像(和网格)并不总是从(i,j,k)=(0,0,0)开始。它们可以从任何地方开始,甚至可以从负数的索引开始。VTK流水线管道的一个优点之处在于,VTK可以只取图像的一个Slice,例如,在k=10时,只将这一个Slice沿着流水线管道传递。
Bounds
The Bounds of an image are
double bounds[6] = { i_min*Spacing[0] + Origin[0], i_max*Spacing[0] + Origin[0],
j_min*Spacing[1] + Origin[1], j_max*Spacing[1] + Origin[1],
k_min*Spacing[2] + Origin[2], k_max*Spacing[2] + Origin[2] };
You can't directly set the bounds. First you need to decide how many pixels across your image will be (i.e. what the extent should be), and then you must find the origin and spacing that will produce the bounds that you need from the extent that you have. This is simple algebra.
In general, always set the extent to start at zero, e.g. [0, 9, 0, 9, 0, 9] for a 10x10x10 image. Calling SetDimensions(10,10,10) does exactly the same thing as SetExtent(0,9,0,9,0,9) but you should always do the latter to be explicit about where your extent starts.
你不能直接设置Bounds。首先你需要决定你的图像将有多少像素(即Extent应该是多少),然后你必须找到Origin(原点)和Spacing(间隔),以便从你的Extent中产生你需要的Bounds。
一般来说,总是将Extent设置为从0开始,例如,对于一个10x10x10的图像,Extent为[0, 9, 0, 9, 0, 9]。调用SetDimensions(10,10,10)和SetExtent(0,9,0,9,0,9)的作用完全一样,但你应该总是使用后者(即SetExtent)来明确你的Extent从哪里开始。