0

We are trying to associate scalars values to cells/points from a VTK mesh read from file. We know that is possible to do something like using FreeSurfer different curvature files - CRV (as shown in example 12 -http://lessons.goxtk.com/12/ )

Our question is how to set the scalars values from the vtk files (blocks PointData and CellData)? If this is not possible, is there a way of directly setting the the scalar array to the X.mesh (any examples) ?

Thanks and sorry for the bad english :-)

Paulo

2 Answers2

0

Try with VtkProbeFiler. With this filter you can associate scalars values to points.

Eric
  • 1
0

I managed to add some scalars as mentioned on L15 of the js of XTK lesson 12. Something like:

var mesh = new X.mesh();
mesh.file = 'mesh.vtk';
renderer.onShowtime = function () {
    var scalarsArray = new Float32Array(mesh.points.length);
    // fill array...
    mesh.scalars.array = scalarsArray ;
    mesh.scalars.lowerThreshold = min;
    mesh.scalars.upperThreshold = max;
}

The scalars array stores 3 times the values to match the points (see parserCRV.js#L213).

Now it seems the scalars min/max are not recalculated when the mesh is rendered, so I added the following code on L1152 of X\visualization\renderer3D.js:

var scalarsMin = Infinity;
var scalarsMax = -Infinity;
var value = 0;
for ( var i = 0; i < scalarsArray.length; ++i ) {
    value = scalarsArray[i];
    if ( !isNaN(value) ) {
        scalarsMin = Math.min(scalarsMin, value);
        scalarsMax = Math.max(scalarsMax, value);
    }
}
scalars._min = scalarsMin;
scalars._max = scalarsMax;

I'm not sure of this, can anybody confirm?

ivmartel
  • 74
  • 4