Hi everyone!
I’m looking at this example as a basis for drawing streamlines based on an existing .vti image.
As far as I understand, creating the vecSource
function is necessary for drawing streamlines and there is no way I can get it from ImageReader
or ImageSource
, right?
So, if creating the vecSource
function is necessary, then we can get the spacing
and extent
from an existing image:
const spacing = imageSource.getSpacing()
const extent = imageSource.getExtent()
Then the question is, what is dims
and how we can get it from the .vti image:
const dims = [10, 10, 10];
And what needs to be inserted into this triple loop instead of 0
, 9
and 0.1
values?
let i = 0;
for (let z = 0; z <= 9; z++) {
for (let y = 0; y <= 9; y++) {
for (let x = 0; x <= 9; x++) {
newArray[i++] = 0.1 * x;
const v = 0.1 * y;
newArray[i++] = v * v;
newArray[i++] = 0;
}
}
}
And is it necessary to keep this expression at the end?
const da = vtkDataArray.newInstance({
numberOfComponents: 3,
values: newArray,
});
da.setName('vectors');
const cpd = id.getPointData();
cpd.setVectors(da);
// Update output
outData[0] = id;
Regarding this piece of code:
planeSource.setOrigin(0.05, 0.05, 0.05);
planeSource.setPoint1(0.05, 0.85, 0.05);
planeSource.setPoint2(0.05, 0.05, 0.85);
I assume that the following entry is suitable, right?
const origin = imageSource.getOrigin()
const bds = imageSource.getBounds()
planeSource.setOrigin(origin[0], origin[1], origin[2])
planeSource.setPoint1(bds[0], bds[2], bds[4])
planeSource.setPoint2(bds[1], bds[3], bds[5])
Besides this, if you have any tips, please share them.
Thank you in advance!