Commit e42507c6 authored by hrchilds's avatar hrchilds

Update from February 20, 2006

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@621 18c085ea-50e0-402c-830e-de6fd14e8384
parent 2cc76127
This diff is collapsed.
#ifndef CONSTRUCTDDFATTRIBUTES_H
#define CONSTRUCTDDFATTRIBUTES_H
#include <string>
#include <AttributeSubject.h>
// ****************************************************************************
// Class: ConstructDDFAttributes
//
// Purpose:
// Attributes for constructing DDFs
//
// Notes: Autogenerated by xml2atts.
//
// Programmer: xml2atts
// Creation: Mon Feb 20 10:41:51 PDT 2006
//
// Modifications:
//
// ****************************************************************************
class ConstructDDFAttributes : public AttributeSubject
{
public:
enum BinningScheme
{
Uniform,
Unknown
};
enum StatisticalOperator
{
Average,
Minimum,
Maximum,
StandardDeviation,
Variance,
Percentile,
Median,
InterquartileRange,
Mode,
Sum
};
ConstructDDFAttributes();
ConstructDDFAttributes(const ConstructDDFAttributes &obj);
virtual ~ConstructDDFAttributes();
virtual ConstructDDFAttributes& operator = (const ConstructDDFAttributes &obj);
virtual bool operator == (const ConstructDDFAttributes &obj) const;
virtual bool operator != (const ConstructDDFAttributes &obj) const;
virtual const std::string TypeName() const;
virtual bool CopyAttributes(const AttributeGroup *);
virtual AttributeSubject *CreateCompatible(const std::string &) const;
virtual AttributeSubject *NewInstance(bool) const;
// Property selection methods
virtual void SelectAll();
void SelectDdfName();
void SelectVarnames();
void SelectRanges();
void SelectCodomainName();
void SelectNumSamples();
// Property setting methods
void SetDdfName(const std::string &ddfName_);
void SetVarnames(const stringVector &varnames_);
void SetRanges(const doubleVector &ranges_);
void SetCodomainName(const std::string &codomainName_);
void SetStatisticalOperator(StatisticalOperator statisticalOperator_);
void SetPercentile(double percentile_);
void SetUndefinedValue(double undefinedValue_);
void SetBinningScheme(BinningScheme binningScheme_);
void SetNumSamples(const intVector &numSamples_);
// Property getting methods
const std::string &GetDdfName() const;
std::string &GetDdfName();
const stringVector &GetVarnames() const;
stringVector &GetVarnames();
const doubleVector &GetRanges() const;
doubleVector &GetRanges();
const std::string &GetCodomainName() const;
std::string &GetCodomainName();
StatisticalOperator GetStatisticalOperator() const;
double GetPercentile() const;
double GetUndefinedValue() const;
BinningScheme GetBinningScheme() const;
const intVector &GetNumSamples() const;
intVector &GetNumSamples();
// Persistence methods
virtual bool CreateNode(DataNode *node, bool completeSave, bool forceAdd);
virtual void SetFromNode(DataNode *node);
// Enum conversion functions
static std::string BinningScheme_ToString(BinningScheme);
static bool BinningScheme_FromString(const std::string &, BinningScheme &);
protected:
static std::string BinningScheme_ToString(int);
public:
static std::string StatisticalOperator_ToString(StatisticalOperator);
static bool StatisticalOperator_FromString(const std::string &, StatisticalOperator &);
protected:
static std::string StatisticalOperator_ToString(int);
public:
// Keyframing methods
virtual std::string GetFieldName(int index) const;
virtual AttributeGroup::FieldType GetFieldType(int index) const;
virtual std::string GetFieldTypeName(int index) const;
virtual bool FieldsEqual(int index, const AttributeGroup *rhs) const;
private:
std::string ddfName;
stringVector varnames;
doubleVector ranges;
std::string codomainName;
int statisticalOperator;
double percentile;
double undefinedValue;
int binningScheme;
intVector numSamples;
};
#endif
<?xml version="1.0"?>
<Attribute name="ConstructDDFAttributes" purpose="Attributes for constructing DDFs" persistent="true" exportAPI="" exportInclude="">
<Enum name="BinningScheme">
Uniform
Unknown
</Enum>
<Enum name="StatisticalOperator">
Average
Minimum
Maximum
StandardDeviation
Variance
Percentile
Median
InterquartileRange
Mode
Sum
</Enum>
<Field name="ddfName" label="ddfName" type="string">
</Field>
<Field name="varnames" label="varnames" type="stringVector">
</Field>
<Field name="ranges" label="ranges" type="doubleVector">
</Field>
<Field name="codomainName" label="codomainName" type="string">
</Field>
<Field name="statisticalOperator" label="Statistical Operator" type="enum" subtype="StatisticalOperator">
Average
</Field>
<Field name="percentile" label="Percentile" type="double">
90.000000
</Field>
<Field name="undefinedValue" label="Undefined Value" type="double">
0.000000
</Field>
<Field name="binningScheme" label="Binning Scheme" type="enum" subtype="BinningScheme">
Uniform
</Field>
<Field name="numSamples" label="numSamples" type="intVector">
</Field>
</Attribute>
......@@ -247,6 +247,9 @@
# Mark C. Miller, Wed Nov 16 10:46:36 PST 2005
# Added MeshManagementAttributes
#
# Hank Childs, Mon Feb 13 21:11:20 PST 2006
# Added ConstructDDFAttributes.
#
##############################################################################
##
......@@ -281,6 +284,7 @@ SRC= AnimationAttributes.C \
ColorTableManager.C \
CompactSILRestrictionAttributes.C \
ConfigManager.C \
ConstructDDFAttributes.C \
ContourOpAttributes.C \
DatabaseAttributes.C \
DatabaseCorrelation.C \
......
......@@ -5544,7 +5544,8 @@ avtDatabaseMetaData::GetNDomains(std::string var) const
// Determines the type of the variable argument.
//
// Arguments:
// var_in A variable name.
// var_in A variable name.
// do_expr Whether or not to do expressions.
//
// Returns: The type of var.
//
......@@ -5576,20 +5577,26 @@ avtDatabaseMetaData::GetNDomains(std::string var) const
// Hank Childs, Tue Jul 19 13:24:19 PDT 2005
// Added support for arrays.
//
// Hank Childs, Sun Feb 19 10:57:47 PST 2006
// Only get information from expressions based on argument value.
//
// ****************************************************************************
avtVarType
avtDatabaseMetaData::DetermineVarType(std::string var_in) const
avtDatabaseMetaData::DetermineVarType(std::string var_in, bool do_expr) const
{
int i;
// If the variable is an expression, we need to find a "real" variable
// name to work with.
ExprNode *tree = ParsingExprList::GetExpressionTree(var_in);
while (tree != NULL)
if (do_expr)
{
var_in = *tree->GetVarLeaves().begin();
tree = ParsingExprList::GetExpressionTree(var_in);
ExprNode *tree = ParsingExprList::GetExpressionTree(var_in);
while (tree != NULL)
{
var_in = *tree->GetVarLeaves().begin();
tree = ParsingExprList::GetExpressionTree(var_in);
}
}
std::string var;
......
......@@ -529,6 +529,10 @@ public:
// Hank Childs, Tue Jul 19 11:04:49 PDT 2005
// Add array variables.
//
// Hank Childs, Sun Feb 19 10:57:47 PST 2006
// Add a Boolean array to "DetermineVarType", since the database does not
// want results from expressions.
//
//----------------------------------------------------------------------------
class DBATTS_API avtDatabaseMetaData : public AttributeSubject
......@@ -716,7 +720,7 @@ public:
int GetNumberOfExpressions(void) const;
int GetNDomains(std::string) const;
avtVarType DetermineVarType(std::string) const;
avtVarType DetermineVarType(std::string, bool = true) const;
avtSubsetType DetermineSubsetType(const std::string &) const;
std::string MeshForVar(std::string) const;
std::string MaterialOnMesh(std::string) const;
......
# Copyright 1991 - 2005
# The Regents of the University of California.
# All rights reserved.
#
# This work was produced at the University of California, Lawrence Livermore
# National Laboratory (UC LLNL) under contract no. W-7405-ENG-48 (Contract
# 48) between the U.S. Department of Energy (DOE) and The Regents of the
# University of California (University) for the operation of UC LLNL.
# Copyright is reserved to the University for purposes of controlled
# dissemination, commercialization through formal licensing, or other
# disposition under terms of Contract 48; DOE policies, regulations and
# orders; and U.S. statutes. The rights of the Federal Government are
# reserved under Contract 48 subject to the restrictions agreed upon by DOE
# and University.
#
# DISCLAIMER
#
# This software was prepared as an account of work sponsored by an agency of
# the United States Government. Neither the United States Government nor the
# University of California nor any of their employees, makes any warranty,
# express or implied, or assumes any liability or responsiblity for the
# accuracy, completeness, or usefullness of any information, apparatus,
# product, or process disclosed, or represents that its use would not infringe
# privately owned rights. Reference herein to any specific commercial
# products, process, or service by trade name, trademark, manufacturer, or
# otherwise, does not necessarily constitute or imply its endorsement,
# recommendation, or favoring by the United States Government or the
# University of California. The views and opinions of authors expressed herein
# do not necessarily state or reflect those of the United States Government or
# the University of California, and shall not be used for advertising or
# product endorsement purposes.
#
# Modifications:
# Hank Childs, Sun Feb 12 14:14:09 PST 2006
# Created.
#
##############################################################################
##
## Programs and options...
##
@SET_MAKE@
@VARIABLES@
##
## Files...
##
SRC=avtBinningScheme.C avtDDF.C avtDDFConstructor.C avtDDFFunctionInfo.C \
avtR2Faverage.C avtR2Fmaximum.C avtR2Fminimum.C avtR2Foperator.C \
avtUniformBinningScheme.C
CPPFLAGS=-I../../include/visit @COMPONENT_CPPFLAGS@ @CPPFLAGS@
SEROBJ=$(SRC:.C=.o)
PAROBJ=$(SRC:.C=_par.o)
LIB=libavtddf
SERLIBS=-ldbatts -lpipeline_ser -lavtmath_ser -lavtexceptions -lvisit_vtk -llightweight_visit_vtk -lmisc -lstate -lcomm -lexpr -lparser -lutility $(VTK_LIBS) $(X_LIBS)
PARLIBS=-ldbatts -lpipeline_par -lavtmath_par -lavtexceptions -lvisit_vtk -llightweight_visit_vtk -lmisc -lstate -lcomm -lexpr -lparser -lutility $(VTK_LIBS) $(X_LIBS)
##
## Standard targets...
##
all: $(LIBSHAREDSER) @LIBSHAREDPAR@
clean:
$(RM) $(LIBSHAREDSER) @LIBSHAREDPAR@
$(RM) $(SEROBJ) $(PAROBJ)
##
## Automatic dependency stuff
##
@TARGETS@
@PARLIBTARGETS@
// ************************************************************************* //
// avtBinningScheme.C //
// ************************************************************************* //
#include <avtBinningScheme.h>
// ****************************************************************************
// Method: avtBinningScheme 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: February 12, 2006
//
// ****************************************************************************
avtBinningScheme::avtBinningScheme()
{
;
}
// ****************************************************************************
// Method: avtBinningScheme 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: February 12, 2006
//
// ****************************************************************************
avtBinningScheme::~avtBinningScheme()
{
;
}
// ************************************************************************* //
// avtBinningScheme.h //
// ************************************************************************* //
#ifndef AVT_BINNING_SCHEME_H
#define AVT_BINNING_SCHEME_H
#include <ddf_exports.h>
class vtkDataSet;
// ****************************************************************************
// Class: avtBinningScheme
//
// Purpose:
// This module creates a binning that can be used for neighborhood
// information when constructing a DDR or a DDF.
//
// Programmer: Hank Childs
// Creation: February 12, 2006
//
// ****************************************************************************
class AVTDDF_API avtBinningScheme
{
public:
avtBinningScheme();
virtual ~avtBinningScheme();
virtual int GetBinId(const float *) const = 0;
virtual int GetNumberOfBins(void) const = 0;
virtual vtkDataSet *CreateGrid(void) const = 0;
};
#endif
// ************************************************************************* //
// avtDDF.C //
// ************************************************************************* //
#include <avtDDF.h>
#include <vtkCell.h>
#include <vtkCellData.h>
#include <vtkDataSet.h>
#include <vtkFloatArray.h>
#include <vtkPointData.h>
#include <avtBinningScheme.h>
#include <avtDDFFunctionInfo.h>
#include <BadIndexException.h>
#include <DebugStream.h>
#include <ImproperUseException.h>
using std::string;
using std::vector;
// ****************************************************************************
// Method: avtDDF constructor
//
// Programmer: Hank Childs
// Creation: February 12, 2006
//
// ****************************************************************************
avtDDF::avtDDF(avtDDFFunctionInfo *info, float *v)
{
functionInfo = info;
vals = v;
}
// ****************************************************************************
// Method: avtDDF destructor
//
// Programmer: Hank Childs
// Creation: February 12, 2006
//
// ****************************************************************************
avtDDF::~avtDDF()
{
delete [] vals;
delete functionInfo;
}
// ****************************************************************************
// Method: avtDDF::CreateGrid
//
// Purpose:
// Creates a grid so the DDF can be visualized.
//
// Programmer: Hank Childs
// Creation: February 12, 2006
//
// ****************************************************************************
vtkDataSet *
avtDDF::CreateGrid(void)
{
avtBinningScheme *bs = functionInfo->GetBinningScheme();
vtkDataSet *rv = bs->CreateGrid();
int nCells = rv->GetNumberOfCells();
vtkFloatArray *arr = vtkFloatArray::New();
arr->SetName(functionInfo->GetCodomainName().c_str());
arr->SetNumberOfTuples(nCells);
for (int i = 0 ; i < nCells ; i++)
{
vtkCell *cell = rv->GetCell(i);
float bbox[6];
cell->GetBounds(bbox);
// Note the assumption here that the X-axis corresponds to tuple 0,
// the Y-axis to tuple 1, etc.
float center[3];
center[0] = (bbox[0] + bbox[1]) / 2.;
center[1] = (bbox[2] + bbox[3]) / 2.;
center[2] = (bbox[4] + bbox[5]) / 2.;
int binId = bs->GetBinId(center);
arr->SetValue(i, vals[binId]);
}
rv->GetCellData()->AddArray(arr);
arr->Delete();
return rv;
}
// ****************************************************************************
// Method: avtDDF::ApplyFunction
//
// Purpose:
// Applies the DDF to a data set.
//
// Programmer: Hank Childs
// Creation: February 12, 2006
//
// ****************************************************************************
vtkDataArray *
avtDDF::ApplyFunction(vtkDataSet *ds)
{
int i, j, k;
int nvars = functionInfo->GetDomainNumberOfTuples();
bool hasError = false;
bool isNodal = true;
const char *varname0 = functionInfo->GetCodomainName().c_str();
vtkDataArray *arr0 = ds->GetPointData()->GetArray(varname0);
if (arr0 == NULL)
{
arr0 = ds->GetCellData()->GetArray(varname0);
if (arr0 == NULL)
hasError = true;
isNodal = false;
}
vtkDataArray **arr = new vtkDataArray*[nvars];
for (k = 0 ; k < nvars ; k++)
{
const char *varname = functionInfo->GetDomainTupleName(k).c_str();
arr[k] = (isNodal ? ds->GetPointData()->GetArray(varname)
: ds->GetCellData()->GetArray(varname));
if (arr == NULL)
hasError = true;
}
if (hasError)
{
debug1 << "Could not locate one of the tuples from the "
<< "domain. Or the variables have different centerings."
<< endl;
// Put burden caller to issue better error message.
return NULL;
}
int nvals = (isNodal ? ds->GetNumberOfPoints() : ds->GetNumberOfCells());
vtkFloatArray *rv = vtkFloatArray::New();
rv->SetName(functionInfo->GetCodomainName().c_str());
rv->SetNumberOfTuples(nvals);
float *v = new float[nvars];
avtBinningScheme *bs = functionInfo->GetBinningScheme();
for (i = 0 ; i < nvals ; i++)
{
for (j = 0 ; j < nvars ; j++)
v[j] = arr[j]->GetTuple1(i);
int binId = bs->GetBinId(v);
rv->SetValue(i, vals[binId]);
}
delete [] arr;
delete [] v;
return rv;
}
// ************************************************************************* //
// avtDDF.h //
// ************************************************************************* //
#ifndef AVT_DDF_H
#define AVT_DDF_H
#include <ddf_exports.h>
#include <vector>
#include <string>
class vtkDataArray;
class vtkDataSet;
class avtBinningScheme;
class avtDDFFunctionInfo;
// ****************************************************************************
// Class: avtDDF
//
// Purpose:
// This class represents a derived data function, which allows for data
// to be represented on new sampling spaces. Further documentation about
// DDFs can be found in the document: ...
//
// Programmer: Hank Childs
// Creation: February 12, 2006
//
// ****************************************************************************
class AVTDDF_API avtDDF
{
public:
avtDDF(avtDDFFunctionInfo *, float *);
virtual ~avtDDF();
avtDDFFunctionInfo *GetFunctionInfo(void) { return functionInfo; };
vtkDataArray *ApplyFunction(vtkDataSet *);
vtkDataSet *CreateGrid(void);
protected:
avtDDFFunctionInfo *functionInfo;
float *vals;
};
#endif
This diff is collapsed.
// ************************************************************************* //
// avtDDFConstructor.h //
// ************************************************************************* //
#ifndef AVT_DDF_CONSTRUCTOR_H
#define AVT_DDF_CONSTRUCTOR_H
#include <ddf_exports.h>
#include <avtOriginatingDatasetSink.h>
#include <vector>
#include <string>
class ConstructDDFAttributes;
class avtDDF;
// ****************************************************************************
// Class: avtDDFConstructor
//
// Purpose:
// This is a data set sink that will generate a DDF.
//
// Programmer: Hank Childs
// Creation: February 12, 2006
//
// ****************************************************************************
class AVTDDF_API avtDDFConstructor : public virtual avtOriginatingDatasetSink
{
public:
avtDDFConstructor();
virtual ~avtDDFConstructor();
avtDDF *ConstructDDF(ConstructDDFAttributes *,
avtPipelineSpecification_p);
};
#endif
// ************************************************************************* //
// avtDDFFunctionInfo.C //
// ************************************************************************* //
#include <avtDDFFunctionInfo.h>
#include <avtBinningScheme.h>
#include <BadIndexException.h>
#include <ImproperUseException.h>
using std::string;
using std::vector;
// ****************************************************************************
// Method: avtDDFFunctionInfo constructor
//
// Programmer: Hank Childs
// Creation: February 12, 2006
//
// ****************************************************************************
avtDDFFunctionInfo::avtDDFFunctionInfo(avtBinningScheme *bs,
const vector<string> &tn, const string &cv)
{
if (tn.size() <= 0)
{
EXCEPTION0(ImproperUseException);
}
binningScheme = bs;
tupleNames = tn;
codomainVariable = cv;
}
// ****************************************************************************