Commit 850b71ac authored by hrchilds's avatar hrchilds
Browse files

Fix performance problems with Histogram plot:

1) Don't recenter data when doing frequency counting
2) Don't apply verdict filter when doing frequency counting


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@3415 18c085ea-50e0-402c-830e-de6fd14e8384
parent 33c04ca8
...@@ -128,6 +128,9 @@ avtHistogramFilter::SetAttributes(const HistogramAttributes &h_atts) ...@@ -128,6 +128,9 @@ avtHistogramFilter::SetAttributes(const HistogramAttributes &h_atts)
// Dave Pugmire, Thu Nov 01 12:39:07 EDT 2007 // Dave Pugmire, Thu Nov 01 12:39:07 EDT 2007
// Support for log, sqrt scaling. // Support for log, sqrt scaling.
// //
// Hank Childs, Wed Mar 5 09:54:20 PST 2008
// Don't get the data range if the min and max are already specified.
//
// **************************************************************************** // ****************************************************************************
void void
...@@ -140,12 +143,13 @@ avtHistogramFilter::PreExecute(void) ...@@ -140,12 +143,13 @@ avtHistogramFilter::PreExecute(void)
if (atts.GetBasedOn() == HistogramAttributes::ManyZonesForSingleVar) if (atts.GetBasedOn() == HistogramAttributes::ManyZonesForSingleVar)
{ {
bool extentsSpecified = atts.GetSpecifyRange(); bool extentsSpecified = atts.GetSpecifyRange();
if (extentsSpecified)
GetDataExtents(dataValueRange, pipelineVariable);
GetDataExtents( dataValueRange, pipelineVariable); SetWorkingMin( (extentsSpecified ? atts.GetMin() : dataValueRange[0]) );
SetWorkingMin( (extentsSpecified ? atts.GetMin() : dataValueRange[0]) ); SetWorkingMax( (extentsSpecified ? atts.GetMax() : dataValueRange[1]) );
SetWorkingMax( (extentsSpecified ? atts.GetMax() : dataValueRange[1]) ); SetWorkingNumBins( atts.GetNumBins() );
SetWorkingNumBins( atts.GetNumBins() );
if (bins != NULL) if (bins != NULL)
delete [] bins; delete [] bins;
bins = new float[workingNumBins]; bins = new float[workingNumBins];
...@@ -237,8 +241,8 @@ avtHistogramFilter::PostExecute(void) ...@@ -237,8 +241,8 @@ avtHistogramFilter::PostExecute(void)
for (i = 0 ; i < workingNumBins ; i++) for (i = 0 ; i < workingNumBins ; i++)
bins[i] = 0.; bins[i] = 0.;
} }
workingRange[0] = 0.; workingRange[0] = 0.;
workingRange[1] = (float)workingNumBins; workingRange[1] = (float)workingNumBins;
} }
float *newBins = new float[workingNumBins]; float *newBins = new float[workingNumBins];
...@@ -439,28 +443,28 @@ avtHistogramFilter::PostExecute(void) ...@@ -439,28 +443,28 @@ avtHistogramFilter::PostExecute(void)
{ {
if(GetInput()->GetInfo().GetAttributes().GetVariableUnits() != "") if(GetInput()->GetInfo().GetAttributes().GetVariableUnits() != "")
{ {
string xlabel = ""; string xlabel = "";
if ( atts.GetDataScale() == HistogramAttributes::Linear ) if ( atts.GetDataScale() == HistogramAttributes::Linear )
xlabel = string( "Variable " ) + pipelineVariable; xlabel = string( "Variable " ) + pipelineVariable;
else if ( atts.GetDataScale() == HistogramAttributes::Log ) else if ( atts.GetDataScale() == HistogramAttributes::Log )
xlabel = string( "Variable log10(" ) + pipelineVariable + string(") "); xlabel = string( "Variable log10(" ) + pipelineVariable + string(") ");
if ( atts.GetDataScale() == HistogramAttributes::SquareRoot ) if ( atts.GetDataScale() == HistogramAttributes::SquareRoot )
xlabel = string( "Variable sqrt(" ) + pipelineVariable + string(") "); xlabel = string( "Variable sqrt(" ) + pipelineVariable + string(") ");
outAtts.SetXLabel( xlabel ); outAtts.SetXLabel( xlabel );
outAtts.SetXUnits(GetInput()->GetInfo().GetAttributes().GetVariableUnits()); outAtts.SetXUnits(GetInput()->GetInfo().GetAttributes().GetVariableUnits());
} }
else else
{ {
string str = ""; string str = "";
if ( atts.GetDataScale() == HistogramAttributes::Linear ) if ( atts.GetDataScale() == HistogramAttributes::Linear )
str = pipelineVariable; str = pipelineVariable;
else if ( atts.GetDataScale() == HistogramAttributes::Log ) else if ( atts.GetDataScale() == HistogramAttributes::Log )
str = string( "log10(" ) + pipelineVariable + string(") "); str = string( "log10(" ) + pipelineVariable + string(") ");
if ( atts.GetDataScale() == HistogramAttributes::SquareRoot ) if ( atts.GetDataScale() == HistogramAttributes::SquareRoot )
str = string( "sqrt(" ) + pipelineVariable + string(") "); str = string( "sqrt(" ) + pipelineVariable + string(") ");
outAtts.SetXUnits(str ); outAtts.SetXUnits(str );
} }
} }
if (atts.GetBasedOn() == HistogramAttributes::ManyVarsForSingleZone) if (atts.GetBasedOn() == HistogramAttributes::ManyVarsForSingleZone)
...@@ -505,11 +509,11 @@ avtHistogramFilter::PostExecute(void) ...@@ -505,11 +509,11 @@ avtHistogramFilter::PostExecute(void)
else else
yunits = atts.GetWeightVariable(); yunits = atts.GetWeightVariable();
} }
string str = yunits; string str = yunits;
if ( atts.GetBinScale() == HistogramAttributes::Log ) if ( atts.GetBinScale() == HistogramAttributes::Log )
str = "log10(" + yunits + ") "; str = "log10(" + yunits + ") ";
else if ( atts.GetBinScale() == HistogramAttributes::SquareRoot ) else if ( atts.GetBinScale() == HistogramAttributes::SquareRoot )
str = "sqrt(" + yunits + ") "; str = "sqrt(" + yunits + ") ";
outAtts.SetYUnits(str); outAtts.SetYUnits(str);
} }
...@@ -592,6 +596,9 @@ avtHistogramFilter::ExecuteData(vtkDataSet *inDS, int chunk, std::string) ...@@ -592,6 +596,9 @@ avtHistogramFilter::ExecuteData(vtkDataSet *inDS, int chunk, std::string)
// Dave Pugmire, Thu Nov 01 12:39:07 EDT 2007 // Dave Pugmire, Thu Nov 01 12:39:07 EDT 2007
// Support for log, sqrt scaling. // Support for log, sqrt scaling.
// //
// Hank Childs, Wed Mar 5 10:17:00 PST 2008
// Don't recenter nodal data to be zonal.
//
// **************************************************************************** // ****************************************************************************
void void
...@@ -601,41 +608,9 @@ avtHistogramFilter::FreqzExecute(vtkDataSet *inDS) ...@@ -601,41 +608,9 @@ avtHistogramFilter::FreqzExecute(vtkDataSet *inDS)
// Get the variable that we are binning by. // Get the variable that we are binning by.
// //
const char *var = pipelineVariable; const char *var = pipelineVariable;
vtkDataArray *bin_arr = NULL; vtkDataArray *bin_arr = inDS->GetPointData()->GetArray(var);
bool ownBinArr = false; if (bin_arr == NULL)
// if we have points obtain point data
if (GetInput()->GetInfo().GetAttributes().GetTopologicalDimension() == 0)
{
// in the point case, get point date
bin_arr = inDS->GetPointData()->GetArray(var);
}
else if (inDS->GetPointData()->GetArray(var) != NULL)
{
// in the 2d or 3d case make sure to get zone centered data
vtkDataSet *new_in_ds = (vtkDataSet *) inDS->NewInstance();
// convert to zone centered
new_in_ds->CopyStructure(inDS);
new_in_ds->GetPointData()->AddArray(
inDS->GetPointData()->GetArray(var));
vtkPointDataToCellData *pd2cd = vtkPointDataToCellData::New();
pd2cd->SetInput(new_in_ds);
pd2cd->Update();
bin_arr = pd2cd->GetOutput()->GetCellData()->GetArray(var);
bin_arr->Register(NULL);
ownBinArr = true;
new_in_ds->Delete();
pd2cd->Delete();
}
else
{
// otherwise simply use zone data
bin_arr = inDS->GetCellData()->GetArray(var); bin_arr = inDS->GetCellData()->GetArray(var);
}
if (bin_arr == NULL) if (bin_arr == NULL)
EXCEPTION0(ImproperUseException); EXCEPTION0(ImproperUseException);
...@@ -657,17 +632,14 @@ avtHistogramFilter::FreqzExecute(vtkDataSet *inDS) ...@@ -657,17 +632,14 @@ avtHistogramFilter::FreqzExecute(vtkDataSet *inDS)
if (ghosts != NULL && ghosts[i] != '\0') if (ghosts != NULL && ghosts[i] != '\0')
continue; continue;
float val = bin_arr->GetTuple1(i); float val = bin_arr->GetTuple1(i);
int index = ComputeBinIndex( val ); int index = ComputeBinIndex( val );
if ( index < 0 ) if ( index < 0 )
continue; continue;
if (index >= workingNumBins) if (index >= workingNumBins)
index = workingNumBins-1; index = workingNumBins-1;
bins[index] += 1; bins[index] += 1;
} }
if (ownBinArr)
bin_arr->Delete();
} }
...@@ -760,10 +732,10 @@ avtHistogramFilter::WeightedExecute(vtkDataSet *inDS) ...@@ -760,10 +732,10 @@ avtHistogramFilter::WeightedExecute(vtkDataSet *inDS)
{ {
if (ghosts != NULL && ghosts[i] != '\0') if (ghosts != NULL && ghosts[i] != '\0')
continue; continue;
float val = bin_arr->GetTuple1(i); float val = bin_arr->GetTuple1(i);
int index = ComputeBinIndex( val ); int index = ComputeBinIndex( val );
if ( index < 0 ) if ( index < 0 )
continue; continue;
if (index >= workingNumBins) if (index >= workingNumBins)
index = workingNumBins-1; index = workingNumBins-1;
float amount = amount_arr->GetTuple1(i); float amount = amount_arr->GetTuple1(i);
...@@ -882,10 +854,10 @@ avtHistogramFilter::VariableExecute(vtkDataSet *inDS) ...@@ -882,10 +854,10 @@ avtHistogramFilter::VariableExecute(vtkDataSet *inDS)
{ {
if (ghosts != NULL && ghosts[i] != '\0') if (ghosts != NULL && ghosts[i] != '\0')
continue; continue;
float val = histIndexVar->GetTuple1(i); float val = histIndexVar->GetTuple1(i);
int index = ComputeBinIndex( val ); int index = ComputeBinIndex( val );
if ( index < 0 ) if ( index < 0 )
continue; continue;
if (index >= workingNumBins) if (index >= workingNumBins)
index = workingNumBins-1; index = workingNumBins-1;
float amount = weightVar->GetTuple1(i); float amount = weightVar->GetTuple1(i);
...@@ -1080,28 +1052,28 @@ avtHistogramFilter::ComputeBinIndex( const float &value ) const ...@@ -1080,28 +1052,28 @@ avtHistogramFilter::ComputeBinIndex( const float &value ) const
{ {
// Value out of bounds, just return. // Value out of bounds, just return.
if ( value < workingRange[0] || value > workingRange[1] ) if ( value < workingRange[0] || value > workingRange[1] )
return -1; return -1;
// If we have a zero range, return 0 // If we have a zero range, return 0
if ( workingRange[0] == workingRange[1] ) if ( workingRange[0] == workingRange[1] )
return 0; return 0;
int index = 0; int index = 0;
if ( atts.GetDataScale() == HistogramAttributes::Linear ) if ( atts.GetDataScale() == HistogramAttributes::Linear )
{ {
index = (int)((value - workingRange[0]) / binStep); index = (int)((value - workingRange[0]) / binStep);
} }
else if ( atts.GetDataScale() == HistogramAttributes::SquareRoot ) else if ( atts.GetDataScale() == HistogramAttributes::SquareRoot )
{ {
float sign = (value < 0 ? -1.0 : 1.0); float sign = (value < 0 ? -1.0 : 1.0);
float x = sign * sqrt( fabs(value) ); float x = sign * sqrt( fabs(value) );
index = (int)((x - sqrtWorkingRange[0]) / sqrtBinStep); index = (int)((x - sqrtWorkingRange[0]) / sqrtBinStep);
} }
else if ( atts.GetDataScale() == HistogramAttributes::Log ) else if ( atts.GetDataScale() == HistogramAttributes::Log )
{ {
float sign = (value < 0 ? -1.0 : 1.0); float sign = (value < 0 ? -1.0 : 1.0);
float x = sign * log10( fabs( value ) + 1.0 ); float x = sign * log10( fabs( value ) + 1.0 );
index = (int)((x - logWorkingRange[0]) / logBinStep); index = (int)((x - logWorkingRange[0]) / logBinStep);
} }
return index; return index;
...@@ -1122,21 +1094,21 @@ void ...@@ -1122,21 +1094,21 @@ void
avtHistogramFilter::ScaleBins() avtHistogramFilter::ScaleBins()
{ {
if ( atts.GetBinScale() == HistogramAttributes::Linear ) if ( atts.GetBinScale() == HistogramAttributes::Linear )
return; return;
else if ( atts.GetBinScale() == HistogramAttributes::Log ) else if ( atts.GetBinScale() == HistogramAttributes::Log )
{ {
for ( int i = 0; i < workingNumBins; i++ ) for ( int i = 0; i < workingNumBins; i++ )
{ {
float x = bins[i]; float x = bins[i];
if ( x > 0.0 ) if ( x > 0.0 )
x = log10(x); x = log10(x);
bins[i] = x; bins[i] = x;
} }
} }
else if ( atts.GetBinScale() == HistogramAttributes::SquareRoot ) else if ( atts.GetBinScale() == HistogramAttributes::SquareRoot )
{ {
for ( int i = 0; i < workingNumBins; i++ ) for ( int i = 0; i < workingNumBins; i++ )
bins[i] = sqrt( bins[i] ); bins[i] = sqrt( bins[i] );
} }
} }
...@@ -1182,11 +1154,11 @@ avtHistogramFilter::GetWorkingMin() const ...@@ -1182,11 +1154,11 @@ avtHistogramFilter::GetWorkingMin() const
switch ( atts.GetDataScale() ) switch ( atts.GetDataScale() )
{ {
case HistogramAttributes::Linear: case HistogramAttributes::Linear:
return workingRange[0]; return workingRange[0];
case HistogramAttributes::Log: case HistogramAttributes::Log:
return logWorkingRange[0]; return logWorkingRange[0];
case HistogramAttributes::SquareRoot: case HistogramAttributes::SquareRoot:
return sqrtWorkingRange[0]; return sqrtWorkingRange[0];
default: default:
return workingRange[0]; return workingRange[0];
} }
...@@ -1235,11 +1207,11 @@ avtHistogramFilter::GetWorkingMax() const ...@@ -1235,11 +1207,11 @@ avtHistogramFilter::GetWorkingMax() const
switch ( atts.GetDataScale() ) switch ( atts.GetDataScale() )
{ {
case HistogramAttributes::Linear: case HistogramAttributes::Linear:
return workingRange[1]; return workingRange[1];
case HistogramAttributes::Log: case HistogramAttributes::Log:
return logWorkingRange[1]; return logWorkingRange[1];
case HistogramAttributes::SquareRoot: case HistogramAttributes::SquareRoot:
return sqrtWorkingRange[1]; return sqrtWorkingRange[1];
default : default :
return workingRange[1]; return workingRange[1];
} }
......
...@@ -204,6 +204,9 @@ avtHistogramPlot::GetMapper(void) ...@@ -204,6 +204,9 @@ avtHistogramPlot::GetMapper(void)
// Hank Childs, Wed Dec 12 11:00:20 PST 2007 // Hank Childs, Wed Dec 12 11:00:20 PST 2007
// Retire 2D amount ... it is now captured by mesh coord type. // Retire 2D amount ... it is now captured by mesh coord type.
// //
// Hank Childs, Tue Mar 4 16:39:04 PST 2008
// Do not insert a volume weighting for frequency counts.
//
// **************************************************************************** // ****************************************************************************
avtDataObject_p avtDataObject_p
...@@ -240,7 +243,10 @@ avtHistogramPlot::ApplyOperators(avtDataObject_p input) ...@@ -240,7 +243,10 @@ avtHistogramPlot::ApplyOperators(avtDataObject_p input)
HistogramFilter = new avtHistogramFilter; HistogramFilter = new avtHistogramFilter;
HistogramFilter->SetAttributes(atts); HistogramFilter->SetAttributes(atts);
HistogramFilter->SetInput(af->GetOutput()); if (atts.GetHistogramType() != HistogramAttributes::Frequency)
HistogramFilter->SetInput(af->GetOutput());
else
HistogramFilter->SetInput(input);
return HistogramFilter->GetOutput(); return HistogramFilter->GetOutput();
#endif #endif
return input; return input;
......
Markdown is supported
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