Commit f086563e authored by hrchilds's avatar hrchilds

Update from August 16, 2005

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@522 18c085ea-50e0-402c-830e-de6fd14e8384
parent b2ebb8f9
......@@ -801,12 +801,26 @@ PluginManager::LoadSinglePlugin(int index)
// Creation: February 6, 2003
//
// Modifications:
// Jeremy Meredith, Tue Aug 16 11:25:07 PDT 2005
// Enable all plugins when loading on demand. There is currently no path
// to inform the Engine which plugins are actually enabled (see '6489), but
// since we are loading plugins on demand, it is simpler and perfectly
// correct to blindly enable all plugins in this case.
//
// ****************************************************************************
void
PluginManager::LoadPluginsOnDemand()
{
loadOnDemand = true;
// If we are loading plugins on demand, there is no
// reason to leave any plugin disabled.
int nAllPlugins = ids.size();
for (int i=0; i<nAllPlugins; i++)
{
EnablePlugin(ids[i]);
}
}
// ****************************************************************************
......
......@@ -180,6 +180,9 @@ static void ConvertToType(oT *obuf, const iT* ibuf, int n)
// Jeremy Meredith, Tue Apr 5 11:49:30 PDT 2005
// Removed the templating. It was causing compiler errors.
//
// Mark C. Miller, Tue Aug 16 13:56:55 PDT 2005
// Eliminated attempt to print array's name using GetName()
//
// ****************************************************************************
static vtkDataArray *
......@@ -189,8 +192,7 @@ ConvertDataArrayToFloat(vtkDataArray *oldArr)
if (oldArr->GetDataType() != VTK_FLOAT)
{
debug5 << "avtGenericDatabase::Converting vktDataArray, \""
<< oldArr->GetName() << "\" from type \""
debug5 << "avtGenericDatabase::Converting vktDataArray from type \""
<< DataArrayTypeName(oldArr) << "\" to \"float\"" << endl;
newArr = vtkFloatArray::New();
......
......@@ -101,6 +101,9 @@ avtUnaryMathFilter::~avtUnaryMathFilter()
// Hank Childs, Thu Jan 6 13:32:50 PST 2005
// Create the correct sized array.
//
// Hank Childs, Tue Aug 16 09:05:03 PDT 2005
// Make cur_mesh accessible to derived types.
//
// ****************************************************************************
vtkDataArray *
......@@ -236,7 +239,9 @@ avtUnaryMathFilter::DeriveVariable(vtkDataSet *in_ds)
// If it did, it probably doesn't matter. If not, then it is the same
// number. So send in the input. Really doesn't matter.
//
cur_mesh = in_ds;
DoOperation(data, dv, ncomps, nvals);
cur_mesh = NULL;
return dv;
}
......
......@@ -26,6 +26,10 @@ class vtkDataArray;
// Moved inlined constructor and destructor definitions to .C files
// because certain compilers have problems with them.
//
// Hank Childs, Tue Aug 16 09:03:39 PDT 2005
// Add data member cur_mesh so derived types can access mesh when
// deriving variables.
//
// ****************************************************************************
class EXPRESSION_API avtUnaryMathFilter : public avtSingleInputExpressionFilter
......@@ -46,6 +50,7 @@ class EXPRESSION_API avtUnaryMathFilter : public avtSingleInputExpressionFilter
{ return numInInput; };
avtCentering centering;
vtkDataSet *cur_mesh;
};
......
# This is the makefile for a subdirectory of a library which is built
# from source files split across multiple subdirectories
#
# Modified:
# Jeremy Meredith, Wed Jul 3 14:05:25 PDT 2002
# Made it use braces for the PWD environment variable, helping portability.
#
DIR=`basename ${PWD}`
all:
(cd .. && $(MAKE) $(DIR)_obj)
(cd .. && $(MAKE) all)
// ************************************************************************* //
// avtConservativeSmoothingExpression.C //
// ************************************************************************* //
#include <avtConservativeSmoothingExpression.h>
#include <algorithm>
#include <vtkDataArray.h>
#include <vtkRectilinearGrid.h>
#include <vtkStructuredGrid.h>
#include <avtCallback.h>
#include <ExpressionException.h>
using std::sort;
// ****************************************************************************
// Method: avtConservativeSmoothingExpression constructor
//
// Purpose:
// Defines the constructor. Note: this should not be inlined in the
// header because it causes problems for certain compilers.
//
// Programmer: Hank Childs
// Creation: August 16, 2005
//
// ****************************************************************************
avtConservativeSmoothingExpression::avtConservativeSmoothingExpression()
{
haveIssuedWarning = false;
}
// ****************************************************************************
// Method: avtConservativeSmoothingExpression destructor
//
// Purpose:
// Defines the destructor. Note: this should not be inlined in the header
// because it causes problems for certain compilers.
//
// Programmer: Hank Childs
// Creation: August 16, 2005
//
// ****************************************************************************
avtConservativeSmoothingExpression::~avtConservativeSmoothingExpression()
{
;
}
// ****************************************************************************
// Method: avtConservativeSmoothingExpression::PreExecute
//
// Purpose:
// Initialize the haveIssuedWarning flag.
//
// Programmer: Hank Childs
// Creation: August 16, 2005
//
// ****************************************************************************
void
avtConservativeSmoothingExpression::PreExecute(void)
{
avtUnaryMathFilter::PreExecute();
haveIssuedWarning = false;
}
// ****************************************************************************
// Method: avtConservativeSmoothingExpression::DoOperation
//
// Purpose:
// Calculates the conservative smoothing of the input.
//
// Arguments:
// in1 The first input data array.
// out The output data array.
// ncomponents The number of components ('1' for scalar, '2' or '3' for
// vectors, etc.)
// ntuples The number of tuples (ie 'npoints' or 'ncells')
//
// Programmer: Hank Childs
// Creation: August 16, 2005
//
// ****************************************************************************
void
avtConservativeSmoothingExpression::DoOperation(vtkDataArray *in1, vtkDataArray *out,
int ncomponents,int ntuples)
{
int i;
if (cur_mesh->GetDataObjectType() != VTK_RECTILINEAR_GRID &&
cur_mesh->GetDataObjectType() != VTK_STRUCTURED_GRID)
{
if (!haveIssuedWarning)
{
avtCallback::IssueWarning("The mean filter expression only "
"operates on structured grids.");
haveIssuedWarning = true;
}
return;
}
int dims[3];
if (cur_mesh->GetDataObjectType() == VTK_RECTILINEAR_GRID)
{
vtkRectilinearGrid *rgrid = (vtkRectilinearGrid *) cur_mesh;
rgrid->GetDimensions(dims);
}
else
{
vtkStructuredGrid *sgrid = (vtkStructuredGrid *) cur_mesh;
sgrid->GetDimensions(dims);
}
bool nodeCentered = true;
if (dims[0]*dims[1]*dims[2] != ntuples)
nodeCentered = false;
if (!nodeCentered)
{
dims[0] -= 1;
dims[1] -= 1;
dims[2] -= 1;
}
if (dims[2] <= 1)
{
for (int i = 0 ; i < dims[0] ; i++)
{
for (int j = 0 ; j < dims[1] ; j++)
{
int idx = j*dims[0]+i;
float max = -FLT_MAX;
float min = +FLT_MAX;
for (int ii = i-1 ; ii <= i+1 ; ii++)
{
if (ii < 0 || ii >= dims[0])
continue;
for (int jj = j-1 ; jj <= j+1 ; jj++)
{
if (jj < 0 || jj >= dims[1])
continue;
if (ii == i && jj == j)
continue;
int idx2 = jj*dims[0] + ii;
float val = in1->GetTuple1(idx2);
max = (val > max ? val : max);
min = (val < min ? val : min);
}
}
float val = in1->GetTuple1(idx);
val = (val > max ? max : val);
val = (val < min ? min : val);
out->SetTuple1(idx, val);
}
}
}
else
{
for (int i = 0 ; i < dims[0] ; i++)
{
for (int j = 0 ; j < dims[1] ; j++)
{
for (int k = 0 ; k < dims[2] ; k++)
{
int idx = k*dims[0]*dims[1] + j*dims[0]+i;
float max = -FLT_MAX;
float min = +FLT_MAX;
for (int ii = i-1 ; ii <= i+1 ; ii++)
{
if (ii < 0 || ii >= dims[0])
continue;
for (int jj = j-1 ; jj <= j+1 ; jj++)
{
if (jj < 0 || jj >= dims[1])
continue;
for (int kk = k-1 ; kk <= k+1 ; kk++)
{
if (kk < 0 || kk >= dims[1])
continue;
if (ii == i && jj == j && kk == k)
continue;
int idx2 = kk*dims[1]*dims[0] + jj*dims[0] +ii;
float val = in1->GetTuple1(idx2);
max = (val > max ? val : max);
min = (val < min ? val : min);
}
}
}
float val = in1->GetTuple1(idx);
val = (val > max ? max : val);
val = (val < min ? min : val);
out->SetTuple1(idx, val);
}
}
}
}
}
// ************************************************************************* //
// avtConservativeSmoothingExpression.h //
// ************************************************************************* //
#ifndef AVT_CONSERVATIVE_SMOOTHING_EXPRESSION_H
#define AVT_CONSERVATIVE_SMOOTHING_EXPRESSION_H
#include <avtUnaryMathFilter.h>
class vtkDataArray;
// ****************************************************************************
// Class: avtConservativeSmoothingExpression
//
// Purpose:
// A filter that calculates the conservative smoothing of an input image.
// Conservative smoothing is the following:
// For each pixel, calculate the range of values from all of its
// neighbors (excluding the pixel itself). Then if the pixel (ie
// the center pixel), is outside of the range, clamp it to the range.
// This is for salt-and-pepper noise.
//
// Programmer: Hank Childs
// Creation: August 16, 2005
//
// ****************************************************************************
class EXPRESSION_API avtConservativeSmoothingExpression
: public avtUnaryMathFilter
{
public:
avtConservativeSmoothingExpression();
virtual ~avtConservativeSmoothingExpression();
virtual const char *GetType(void)
{ return "avtConservativeSmoothingExpression"; };
virtual const char *GetDescription(void)
{ return "Conservative smoothing"; };
protected:
bool haveIssuedWarning;
virtual void PreExecute(void);
virtual void DoOperation(vtkDataArray *in1, vtkDataArray *out,
int ncomps, int ntuples);
};
#endif
// ************************************************************************* //
// avtMeanFilterExpression.C //
// ************************************************************************* //
#include <avtMeanFilterExpression.h>
#include <vtkDataArray.h>
#include <vtkRectilinearGrid.h>
#include <vtkStructuredGrid.h>
#include <avtCallback.h>
#include <ExpressionException.h>
// ****************************************************************************
// Method: avtMeanFilterExpression constructor
//
// Purpose:
// Defines the constructor. Note: this should not be inlined in the
// header because it causes problems for certain compilers.
//
// Programmer: Hank Childs
// Creation: August 14, 2005
//
// ****************************************************************************
avtMeanFilterExpression::avtMeanFilterExpression()
{
haveIssuedWarning = false;
}
// ****************************************************************************
// Method: avtMeanFilterExpression destructor
//
// Purpose:
// Defines the destructor. Note: this should not be inlined in the header
// because it causes problems for certain compilers.
//
// Programmer: Hank Childs
// Creation: August 14, 2005
//
// ****************************************************************************
avtMeanFilterExpression::~avtMeanFilterExpression()
{
;
}
// ****************************************************************************
// Method: avtMeanFilterExpression::PreExecute
//
// Purpose:
// Initialize the haveIssuedWarning flag.
//
// Programmer: Hank Childs
// Creation: August 14, 2005
//
// ****************************************************************************
void
avtMeanFilterExpression::PreExecute(void)
{
avtUnaryMathFilter::PreExecute();
haveIssuedWarning = false;
}
// ****************************************************************************
// Method: avtMeanFilterExpression::DoOperation
//
// Purpose:
// Calculates the mean.
//
// Arguments:
// in1 The first input data array.
// out The output data array.
// ncomponents The number of components ('1' for scalar, '2' or '3' for
// vectors, etc.)
// ntuples The number of tuples (ie 'npoints' or 'ncells')
//
// Programmer: Hank Childs
// Creation: August 14, 2005
//
// ****************************************************************************
void
avtMeanFilterExpression::DoOperation(vtkDataArray *in1, vtkDataArray *out,
int ncomponents,int ntuples)
{
int i;
if (cur_mesh->GetDataObjectType() != VTK_RECTILINEAR_GRID &&
cur_mesh->GetDataObjectType() != VTK_STRUCTURED_GRID)
{
if (!haveIssuedWarning)
{
avtCallback::IssueWarning("The mean filter expression only "
"operates on structured grids.");
haveIssuedWarning = true;
}
return;
}
int dims[3];
if (cur_mesh->GetDataObjectType() == VTK_RECTILINEAR_GRID)
{
vtkRectilinearGrid *rgrid = (vtkRectilinearGrid *) cur_mesh;
rgrid->GetDimensions(dims);
}
else
{
vtkStructuredGrid *sgrid = (vtkStructuredGrid *) cur_mesh;
sgrid->GetDimensions(dims);
}
bool nodeCentered = true;
if (dims[0]*dims[1]*dims[2] != ntuples)
nodeCentered = false;
if (!nodeCentered)
{
dims[0] -= 1;
dims[1] -= 1;
dims[2] -= 1;
}
if (dims[2] <= 1)
{
for (int i = 0 ; i < dims[0] ; i++)
{
for (int j = 0 ; j < dims[1] ; j++)
{
int idx = j*dims[0]+i;
double sum = 0.;
int numSamps = 0;
for (int ii = i-1 ; ii <= i+1 ; ii++)
{
if (ii < 0 || ii >= dims[0])
continue;
for (int jj = j-1 ; jj <= j+1 ; jj++)
{
if (jj < 0 || jj >= dims[1])
continue;
int idx2 = jj*dims[0] + ii;
sum += in1->GetTuple1(idx2);
numSamps++;
}
}
out->SetTuple1(idx, sum/numSamps);
}
}
}
else
{
for (int i = 0 ; i < dims[0] ; i++)
{
for (int j = 0 ; j < dims[1] ; j++)
{
for (int k = 0 ; k < dims[2] ; k++)
{
int idx = k*dims[0]*dims[1] + j*dims[0]+i;
double sum = 0.;
int numSamps = 0;
for (int ii = i-1 ; ii <= i+1 ; ii++)
{
if (ii < 0 || ii >= dims[0])
continue;
for (int jj = j-1 ; jj <= j+1 ; jj++)
{
if (jj < 0 || jj >= dims[1])
continue;
for (int kk = k-1 ; kk <= k+1 ; kk++)
{
if (kk < 0 || kk >= dims[1])
continue;
int idx2 = kk*dims[1]*dims[0] + jj*dims[0] +ii;
sum += in1->GetTuple1(idx2);
numSamps++;
}
}
}
out->SetTuple1(idx, sum/numSamps);
}
}
}
}
}
// ************************************************************************* //
// avtMeanFilterExpression.h //
// ************************************************************************* //
#ifndef AVT_MEAN_FILTER_EXPRESSION_H
#define AVT_MEAN_FILTER_EXPRESSION_H
#include <avtUnaryMathFilter.h>
class vtkDataArray;
// ****************************************************************************
// Class: avtMeanFilterExpression
//
// Purpose:
// A filter that calculates the mean of a zone and its surrounding
// neighbors.
//
// Programmer: Hank Childs
// Creation: August 14, 2005
//
// ****************************************************************************
class EXPRESSION_API avtMeanFilterExpression : public avtUnaryMathFilter
{
public:
avtMeanFilterExpression();
virtual ~avtMeanFilterExpression();
virtual const char *GetType(void)
{ return "avtMeanFilterExpression"; };
virtual const char *GetDescription(void)
{ return "Taking mean filter"; };
protected:
bool haveIssuedWarning;
virtual void PreExecute(void);
virtual void DoOperation(vtkDataArray *in1, vtkDataArray *out,
int ncomps, int ntuples);
};
#endif
// ************************************************************************* //
// avtMedianFilterExpression.C //
// ************************************************************************* //
#include <avtMedianFilterExpression.h>
#include <algorithm>
#include <vtkDataArray.h>
#include <vtkRectilinearGrid.h>
#include <vtkStructuredGrid.h>
#include <avtCallback.h>
#include <ExpressionException.h>
using std::sort;
// ****************************************************************************
// Method: avtMedianFilterExpression constructor
//
// Purpose:
// Defines the constructor. Note: this should not be inlined in the
// header because it causes problems for certain compilers.
//
// Programmer: Hank Childs
// Creation: August 14, 2005
//
// ****************************************************************************
avtMedianFilterExpression::avtMedianFilterExpression()
{
haveIssuedWarning = false;
}
// ****************************************************************************
// Method: avtMedianFilterExpression destructor
//
// Purpose:
// Defines the destructor. Note: this should not be inlined in the header
// because it causes problems for certain compilers.
//
// Programmer: Hank Childs
// Creation: August 14, 2005
//
// ****************************************************************************
avtMedianFilterExpression::~avtMedianFilterExpression()
{
;
}
// ****************************************************************************
// Method: avtMedianFilterExpression::PreExecute