visit icon indicating copy to clipboard operation
visit copied to clipboard

Wrong max and min in vtkDataSet->GetScalarRange()

Open JustinPrivitera opened this issue 1 year ago • 4 comments

See the min and max for this pseudocolor plot: image

When I go to write this data out as obj, the texture coordinates are wrong because the data range given by vtkDataSet->GetScalarRange() is wrong. See the following code snippet and printouts:

Code from here: https://github.com/visit-dav/visit/blob/develop/src/avt/FileWriter/avtDatasetFileWriter.C#L378

vtkDataSet *activeDS = ds;
...
double range[2];
activeDS->GetScalarRange(range);

std::cout << "range[0]: " << range[0] << std::endl;
std::cout << "range[1]: " << range[1] << std::endl;

Yields:

range[0]: 0
range[1]: 4.9557

The max looks right, but the min is wrong. Does anyone know how to fix this, or why this might be happening?

JustinPrivitera avatar Nov 03 '23 22:11 JustinPrivitera

On further inspection, it looks like the scalar range it gives is correct, as there are data values in the vtkDataSet that are 0. That is the problem that should be addressed, as variable d of curv3d.silo should not have any values that are 0.

JustinPrivitera avatar Nov 04 '23 01:11 JustinPrivitera

@markcmiller86 looked the silo file and it doesn't contain any zeroes, so it must be getting added during processing in VisIt.

brugger1 avatar Nov 07 '23 23:11 brugger1

This looks to be a bug with VTK. vtkCellDataToPointData is used to convert the zonal variable d to a nodal variable to write it to OBJ; after the transformation, zeros are present. This should be investigated inside of VTK.

JustinPrivitera avatar Nov 22 '23 22:11 JustinPrivitera

Taking out of reviewed state so we can discuss whether or not to keep this open now that the downstream issue this caused has been addressed in #19301

JustinPrivitera avatar Feb 12 '24 23:02 JustinPrivitera

@JustinPrivitera I just tried with 3.4RC and develop, added logic to avtDatasetFileWriter::WriteOBJFile to call GetScalarRange both before the use of vtkCellDataToPointData and after, and it, and got the same values for both: range before c2dpd: 2.03471 4.9557 range after c2dpd: 2.03471 4.9557

I opened curv3d.silo, created a Pseudocolor plot of 'd' , Clicked Draw, then exported database as WavefrontOBJ. (didn't enable any of the write options).

I didn't check if the export was correct, but the range looks good.

Is there another way to reproduce?

biagas avatar Jul 26 '24 18:07 biagas

I'm seeing the same thing. That is fascinating. I wonder if things have changed with VTK since last November? I think we can close this ticket then.

If you'd like I can remove this note in the code:

// Compute the range here since VTK cannot be trusted to get the extents
// right after transforming from cell data to point data.
// See https://github.com/visit-dav/visit/issues/19028

or you can, just let me know.

JustinPrivitera avatar Jul 26 '24 19:07 JustinPrivitera

If you'd like I can remove this note in the code:

Be my guest

biagas avatar Jul 26 '24 19:07 biagas

removing the note here #19705

closing as discussed

JustinPrivitera avatar Jul 26 '24 20:07 JustinPrivitera