Commit 3175ffa3 authored by Bob Obara's avatar Bob Obara
Browse files

BUG:Removed the assumption of Active Scalars

The mapper was written to assume there was an active scalar
field set instead of using the GetScalars Method

Change-Id: Ib7288948660d59e77e009926448330b7b94e88c5
parent b1759c02
......@@ -81,7 +81,7 @@ void vtkVolumeTextureMapper3DComputeScalars( T *dataPtr,
me->GetVolumeDimensions( outputDimensions );
me->GetVolumeSpacing( outputSpacing );
int components = input->GetNumberOfScalarComponents();
int components = me->GetNumberOfScalarComponents(input);
double wx, wy, wz;
double fx, fy, fz;
......@@ -434,7 +434,7 @@ void vtkVolumeTextureMapper3DComputeGradients( T *dataPtr,
sampleRate[1] = outputSpacing[1] / static_cast<double>(spacing[1]);
sampleRate[2] = outputSpacing[2] / static_cast<double>(spacing[2]);
int components = input->GetNumberOfScalarComponents();
int components = me->GetNumberOfScalarComponents(input);
int dim[3];
input->GetDimensions(dim);
......@@ -1035,8 +1035,26 @@ int vtkVolumeTextureMapper3D::UpdateVolumes(vtkVolume *vtkNotUsed(vol))
// How big does the Volume need to be?
int dim[3];
input->GetDimensions(dim);
int cellFlag;
vtkDataArray *scalarArray = this->GetScalars(input,this->ScalarMode,
this->ArrayAccessMode,
this->ArrayId,
this->ArrayName,
cellFlag);
if (!scalarArray)
{
vtkErrorMacro("No scalars found on input.");
return 0;
}
int components = input->GetNumberOfScalarComponents();
if (cellFlag)
{
vtkErrorMacro("Can not process Cell Data.");
return 0;
}
int components = scalarArray->GetNumberOfComponents();
int powerOfTwoDim[3];
......@@ -1116,7 +1134,7 @@ int vtkVolumeTextureMapper3D::UpdateVolumes(vtkVolume *vtkNotUsed(vol))
// Find the scalar range
double scalarRange[2];
input->GetPointData()->GetScalars()->GetRange(scalarRange, components-1);
scalarArray->GetRange(scalarRange, components-1);
// Is the difference between max and min less than 4096? If so, and if
// the data is not of float or double type, use a simple offset mapping.
......@@ -1129,7 +1147,7 @@ int vtkVolumeTextureMapper3D::UpdateVolumes(vtkVolume *vtkNotUsed(vol))
int arraySizeNeeded;
int scalarType = input->GetScalarType();
int scalarType = scalarArray->GetDataType();
if ( scalarType == VTK_FLOAT ||
scalarType == VTK_DOUBLE ||
......@@ -1165,7 +1183,7 @@ int vtkVolumeTextureMapper3D::UpdateVolumes(vtkVolume *vtkNotUsed(vol))
// Transfer the input volume to the RGBA volume
void *dataPtr = input->GetScalarPointer();
void *dataPtr = scalarArray->GetVoidPointer(0);
switch ( scalarType )
......@@ -1223,7 +1241,7 @@ int vtkVolumeTextureMapper3D::UpdateColorLookup( vtkVolume *vol )
}
// How many components?
int components = input->GetNumberOfScalarComponents();
int components = this->GetNumberOfScalarComponents(input);
// Has the sample distance changed?
if ( this->SavedSampleDistance != this->ActualSampleDistance )
......@@ -1317,7 +1335,18 @@ int vtkVolumeTextureMapper3D::UpdateColorLookup( vtkVolume *vol )
// Find the scalar range
double scalarRange[2];
input->GetPointData()->GetScalars()->GetRange(scalarRange, components-1);
int cellFlag;
vtkDataArray *scalarArray = this->GetScalars(input,this->ScalarMode,
this->ArrayAccessMode,
this->ArrayId,
this->ArrayName,
cellFlag);
if (!scalarArray)
{
vtkErrorMacro("No scalars found on input.");
return 0;
}
scalarArray->GetRange(scalarRange, components-1);
int arraySizeNeeded = this->ColorTableSize;
......@@ -1497,5 +1526,22 @@ void vtkVolumeTextureMapper3D::PrintSelf(ostream& os, vtkIndent indent)
<< endl;
}
//-----------------------------------------------------------------------------
int vtkVolumeTextureMapper3D::GetNumberOfScalarComponents(vtkImageData *input)
{
int cellFlag;
vtkDataArray *scalarArray = this->GetScalars(input,this->ScalarMode,
this->ArrayAccessMode,
this->ArrayId,
this->ArrayName,
cellFlag);
if (!scalarArray)
{
vtkErrorMacro("No scalars found on input.");
return 0;
}
return scalarArray->GetNumberOfComponents();
}
//-----------------------------------------------------------------------------
......@@ -140,6 +140,10 @@ public:
ATI_METHOD=2,
NO_METHOD=3
};
// Description:
// Returns the number of components of the point scalar field
int GetNumberOfScalarComponents(vtkImageData *input);
//ETX
// Description:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment