[vtkusers] Thresholding Bug?
Chris Scharver
scharver at evl.uic.edu
Sun Feb 16 17:48:51 EST 2003
Hello,
I'm having a strange experience trying to threshold some data. I cannot seem to get a threshold above 0.0. I always get an empty data set. I read the data into a structured grid. The scalar range is (-0.0767 0.0824), and I can confirm that reading the output from the vtkAssignAttribute operation (aa->GetOutput()->GetScalarRange()). Any points with scalars above 0.0 are ignored by the thresholding. Am I not assigning something properly? I'm using the current cvs version.
// Filter that data from the data object to a data set.
vtkDataObjectToDataSetFilter* dods = vtkDataObjectToDataSetFilter::New();
dods->SetInput(dataReader->GetOutput());
dods->SetDataSetTypeToStructuredGrid();
//dods->SetDataSetTypeToRectilinearGrid();
dods->DefaultNormalizeOn();
dods->SetPointComponent(0, "latitude", 0);
dods->SetPointComponent(1, "longitude", 0);
dods->SetPointComponent(2, "depth", 0);
dods->SetDimensions(dataReader->GetDimensions());
// Move the velocity field to the data.
vtkRearrangeFields* rf = vtkRearrangeFields::New();
rf->SetInput(dods->GetOutput());
rf->AddOperation(vtkRearrangeFields::MOVE, "velocity",
vtkRearrangeFields::DATA_OBJECT,
vtkRearrangeFields::POINT_DATA);
// Assign the velocity field as the scalar value.
vtkAssignAttribute* aa = vtkAssignAttribute::New();
aa->SetInput(rf->GetOutput());
aa->Assign("velocity", vtkDataSetAttributes::SCALARS,
vtkAssignAttribute::POINT_DATA);
aa->Update();
// Create the lower threshold.
float* rng = aa->GetOutput()->GetScalarRange();
cerr << "aa scalar range: " << rng[0] << " " << rng[1] << endl;
vtkThresholdPoints* lowThresh = vtkThresholdPoints::New();
// this works: lowThresh->ThresholdByUpper(0.0f);
lowThresh->ThresholdByLower(0.0f); // this does not!
lowThresh->SetInput(aa->GetOutput());
// This splatter complains that there is no data!
vtkGaussianSplatter* lowSplat = vtkGaussianSplatter::New();
lowSplat->SetInput(lowThresh->GetOutput());
lowSplat->SetSampleDimensions(dimsize, dimsize, dimsize);
lowSplat->SetRadius(0.02f);
lowSplat->ScalarWarpingOff();
The threshold seems to calculate the results incorrectly. I can confirm that the data has scalars both above and less than 0. If I skip the threshold altogether (ie. sending the data directly to the splatter) than all points are represented.
Chris
--
Chris Scharver
Electronic Visualization Laboratory
The University of Illinois at Chicago
Ph: 312-996-3002 FAX: 312-413-7585
<http://www.evl.uic.edu/scharver/>
More information about the vtkusers
mailing list