Commit 2bf47087 authored by hrchilds's avatar hrchilds

Update from March 2, 2006

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@628 18c085ea-50e0-402c-830e-de6fd14e8384
parent d6ad0a15
......@@ -649,6 +649,9 @@ avtContourFilter::ExecuteDataTree(vtkDataSet *in_ds, int domain, string label)
// Hank Childs, Thu Feb 26 09:05:34 PST 2004
// Do a better job of handling multiple variables.
//
// Kathleen Bonnell, Thu Mar 2 15:05:17 PST 2006
// Add ZonesSplit.
//
// ****************************************************************************
void
......@@ -678,6 +681,7 @@ avtContourFilter::RefashionDataObjectInfo(void)
}
GetOutput()->GetInfo().GetValidity().InvalidateZones();
GetOutput()->GetInfo().GetValidity().ZonesSplit();
}
......
......@@ -60,12 +60,16 @@ avtDataValidity::~avtDataValidity()
// Mark C. Miller, Thu Jan 29 16:40:25 PST 2004
// Added hasEverOwnedAnyDomain
//
// Kathleen Bonnell, Thu Mar 2 14:04:06 PST 2006
// Added originalZonesIntact.
//
// ****************************************************************************
void
avtDataValidity::Reset(void)
{
zonesPreserved = true;
originalZonesIntact = true;
dataMetaDataPreserved = true;
spatialMetaDataPreserved = true;
operationFailed = false;
......@@ -129,12 +133,16 @@ avtDataValidity::Reset(void)
// Mark C. Miller, Thu Jan 29 16:40:25 PST 2004
// Added hasEverOwnedAnyDomain
//
// Kathleen Bonnell, Thu Mar 2 14:04:06 PST 2006
// Added originalZonesIntact.
//
// ****************************************************************************
void
avtDataValidity::Copy(const avtDataValidity &di)
{
zonesPreserved = di.zonesPreserved;
originalZonesIntact = di.originalZonesIntact;
spatialMetaDataPreserved = di.spatialMetaDataPreserved;
dataMetaDataPreserved = di.dataMetaDataPreserved;
operationFailed = di.operationFailed;
......@@ -198,12 +206,16 @@ avtDataValidity::Copy(const avtDataValidity &di)
// Mark C. Miller, Thu Jan 29 16:40:25 PST 2004
// Added hasEverOwnedAnyDomain
//
// Kathleen Bonnell, Thu Mar 2 14:04:06 PST 2006
// Added originalZonesIntact.
//
// ****************************************************************************
void
avtDataValidity::Merge(const avtDataValidity &di)
{
zonesPreserved = zonesPreserved && di.zonesPreserved;
originalZonesIntact = originalZonesIntact && di.originalZonesIntact;
spatialMetaDataPreserved = spatialMetaDataPreserved
&& di.spatialMetaDataPreserved;
dataMetaDataPreserved = dataMetaDataPreserved
......@@ -298,32 +310,36 @@ avtDataValidity::Merge(const avtDataValidity &di)
// Mark C. Miller, Thu Jan 29 16:40:25 PST 2004
// Added hasEverOwnedAnyDomain
//
// Kathleen Bonnell, Thu Mar 2 14:04:06 PST 2006
// Added originalZonesIntact.
//
// ****************************************************************************
void
avtDataValidity::Write(avtDataObjectString &str,
const avtDataObjectWriter *wrtr)
{
const int numVals = 17;
const int numVals = 18;
int vals[numVals];
vals[0] = (zonesPreserved ? 1 : 0);
vals[1] = (dataMetaDataPreserved ? 1 : 0);
vals[2] = (spatialMetaDataPreserved ? 1 : 0);
vals[3] = (operationFailed ? 1 : 0);
vals[4] = (usingAllData ? 1 : 0);
vals[5] = (usingAllDomains ? 1 : 0);
vals[6] = (isThisDynamic ? 1 : 0);
vals[7] = (pointsWereTransformed ? 1 : 0);
vals[8] = (wireframeRenderingIsInappropriate ? 1 : 0);
vals[9] = (normalsAreInappropriate ? 1 : 0);
vals[10]= (subdivisionOccurred ? 1 : 0);
vals[11]= (notAllCellsSubdivided ? 1 : 0);
vals[12]= (disjointElements ? 1 : 0);
vals[13]= (queryable ? 1 : 0);
vals[14]= (hasEverOwnedAnyDomain ? 1 : 0);
vals[15]= (errorOccurred ? 1 : 0);
vals[16]= errorString.size();
vals[1] = (originalZonesIntact ? 1 : 0);
vals[2] = (dataMetaDataPreserved ? 1 : 0);
vals[3] = (spatialMetaDataPreserved ? 1 : 0);
vals[4] = (operationFailed ? 1 : 0);
vals[5] = (usingAllData ? 1 : 0);
vals[6] = (usingAllDomains ? 1 : 0);
vals[7] = (isThisDynamic ? 1 : 0);
vals[8] = (pointsWereTransformed ? 1 : 0);
vals[9] = (wireframeRenderingIsInappropriate ? 1 : 0);
vals[10] = (normalsAreInappropriate ? 1 : 0);
vals[11]= (subdivisionOccurred ? 1 : 0);
vals[12]= (notAllCellsSubdivided ? 1 : 0);
vals[13]= (disjointElements ? 1 : 0);
vals[14]= (queryable ? 1 : 0);
vals[15]= (hasEverOwnedAnyDomain ? 1 : 0);
vals[16]= (errorOccurred ? 1 : 0);
vals[17]= errorString.size();
wrtr->WriteInt(str, vals, numVals);
str.Append((char *) errorString.c_str(), errorString.size(),
......@@ -377,6 +393,9 @@ avtDataValidity::Write(avtDataObjectString &str,
// Mark C. Miller, Thu Jan 29 16:40:25 PST 2004
// Added hasEverOwnedAnyDomain, careful to put in right order in sequence
//
// Kathleen Bonnell, Thu Mar 2 14:04:06 PST 2006
// Added originalZonesIntact.
//
// ****************************************************************************
int
......@@ -393,6 +412,15 @@ avtDataValidity::Read(char *input)
InvalidateZones();
}
// read zones intact
int zi;
memcpy(&zi, input, sizeof(int));
input += sizeof(int); size += sizeof(int);
if (zi == 0)
{
ZonesSplit();
}
// read data extents preserved
int dep;
memcpy(&dep, input, sizeof(int));
......
......@@ -62,6 +62,9 @@ class avtDataObjectWriter;
// Moved inlined constructor and destructor definitions to .C files
// because certain compilers have problems with them.
//
// Kathleen Bonnell, Thu Mar 2 14:04:06 PST 2006
// Added ZonesSplit() and GetOriginalZonesIntact().
//
// ****************************************************************************
class PIPELINE_API avtDataValidity
......@@ -87,12 +90,25 @@ class PIPELINE_API avtDataValidity
{ dataMetaDataPreserved = false; };
bool GetDataMetaDataPreserved(void) const
{ return dataMetaDataPreserved; };
//
// This has more to do with zone-numbering than with
// the zones being subdivided, tetrahedralized, etc.
//
void InvalidateZones(void)
{ zonesPreserved = false; };
bool GetZonesPreserved(void) const
{ return zonesPreserved; };
//
// This has more to do with zone being split, by
// clipping, slicing, etc.
//
void ZonesSplit(void)
{ originalZonesIntact = false; };
bool GetOriginalZonesIntact(void) const
{ return originalZonesIntact; };
void InvalidateOperation(void)
{ operationFailed = true; };
bool GetOperationFailed(void) const
......@@ -164,6 +180,7 @@ class PIPELINE_API avtDataValidity
protected:
bool zonesPreserved;
bool originalZonesIntact;
bool spatialMetaDataPreserved;
bool dataMetaDataPreserved;
bool operationFailed;
......
......@@ -7,6 +7,7 @@
#include <vtkCellData.h>
#include <vtkDataSet.h>
#include <vtkIdList.h>
#include <vtkIntArray.h>
#include <vtkPointData.h>
#include <vtkUnsignedCharArray.h>
......@@ -16,8 +17,10 @@
#include <DebugStream.h>
#include <InvalidVariableException.h>
#include <snprintf.h>
#include <set>
using std::string;
using std::set;
// ****************************************************************************
......@@ -28,12 +31,17 @@ using std::string;
// Programmer: Kathleen Bonnell
// Creation: September 30, 2002
//
// Modifications:
// Kathleen Bonnell, Thu Mar 2 15:05:17 PST 2006
// Added sumFromOriginalElement.
//
// ****************************************************************************
avtSummationQuery::avtSummationQuery()
{
sumGhostValues = false;
sumOnlyPositiveValues = false;
sumFromOriginalElement = false;
sum = 0.;
sumType = "";
strcpy(descriptionBuffer, "Summing up variable");
......@@ -166,6 +174,28 @@ avtSummationQuery::SumOnlyPositiveValues(bool val)
}
// ****************************************************************************
// Method: avtSummationQuery::SumFromOriginalElement
//
// Purpose:
// Specifies whether or not original cell information should be considered,
// all values from the same original cell contribute only once to the sum.
//
// Arguments:
// val True if we should sum from original cells.
//
// Programmer: Kathleen Bonnell
// Creation: February 28, 2006
//
// ****************************************************************************
void
avtSummationQuery::SumFromOriginalElement(bool val)
{
sumFromOriginalElement = val;
}
// ****************************************************************************
// Method: avtSummationQuery::PreExecute
//
......@@ -267,6 +297,13 @@ avtSummationQuery::PostExecute(void)
// Kathleen Bonnell, Wed Dec 22 13:03:37 PST 2004
// Correct how ghostNodes are used with PointData.
//
// Kathleen Bonnell, Thu Mar 2 15:05:17 PST 2006
// Added logic so that if sumFromOriginalElement flag is set, will check
// OriginalCells/Nodes arrays, and use the value from the 'original' element
// only once in the sum, regardless of how many new sub-elements the original
// cell was split into -- because when that original cell was split, the
// variable's value was passed intact to the new cells.
//
// ****************************************************************************
void
......@@ -297,9 +334,45 @@ avtSummationQuery::Execute(vtkDataSet *ds, const int dom)
ghost_nodes = (vtkUnsignedCharArray *)
ds->GetPointData()->GetArray("avtGhostNodes");
}
int comp =0;
vtkIntArray *originalCells = NULL;
vtkIntArray *originalNodes = NULL;
if (sumFromOriginalElement)
{
if (pointData)
{
originalNodes = (vtkIntArray *)
ds->GetPointData()->GetArray("avtOriginalNodeNumbers");
if (originalNodes)
{
comp = originalNodes->GetNumberOfComponents() - 1;
}
else
{
debug3 << "Summation Query told to sum from original nodes but "
<< "could not find avtOriginalNodeNumbers array." << endl;
}
}
else
{
originalCells = (vtkIntArray *)
ds->GetCellData()->GetArray("avtOriginalCellNumbers");
if (originalCells)
{
comp = originalCells->GetNumberOfComponents() - 1;
}
else
{
debug3 << "Summation Query told to sum from original cells but "
<< "could not find avtOriginalCellNumbers array." << endl;
}
}
}
set<int> summedElements;
int nValues = arr->GetNumberOfTuples();
vtkIdList *list = vtkIdList::New();
for (int i = 0 ; i < nValues ; i++)
{
float val = arr->GetTuple1(i);
......@@ -335,6 +408,20 @@ avtSummationQuery::Execute(vtkDataSet *ds, const int dom)
}
if (sumOnlyPositiveValues && val < 0.)
continue;
if (originalCells)
{
int origCell = (int)originalCells->GetComponent(i, comp);
if (!(summedElements.insert(origCell)).second)
continue;
}
else if (originalNodes)
{
int origNode = (int)originalNodes->GetComponent(i, comp);
if (origNode == -1 || !(summedElements.insert(origNode)).second)
continue;
}
sum += val;
}
......
......@@ -39,6 +39,9 @@ class vtkDataSet;
// Hank Childs, Thu Jan 12 14:58:07 PST 2006
// Added qualifier.
//
// Kathleen Bonnell, Thu Mar 2 15:05:17 PST 2006
// Added sumFromOriginalElement.
//
// ****************************************************************************
class QUERY_API avtSummationQuery : public avtDatasetQuery
......@@ -58,6 +61,7 @@ class QUERY_API avtSummationQuery : public avtDatasetQuery
void SumGhostValues(bool);
void SumOnlyPositiveValues(bool);
void SumFromOriginalElement(bool);
protected:
double sum;
......@@ -67,6 +71,7 @@ class QUERY_API avtSummationQuery : public avtDatasetQuery
std::string qualifier;
bool sumGhostValues;
bool sumOnlyPositiveValues;
bool sumFromOriginalElement;
char descriptionBuffer[1024];
virtual void Execute(vtkDataSet *, const int);
......
......@@ -4,6 +4,7 @@
#include <avtVariableSummationQuery.h>
#include <avtCondenseDatasetFilter.h>
#include <avtTerminatingSource.h>
#include <BadIndexException.h>
......@@ -16,10 +17,17 @@ using std::string;
// Programmer: Hank Childs
// Creation: February 3, 2004
//
// Modifications:
// Kathleen Bonnell, Thu Mar 2 15:05:17 PST 2006
// Add condense filter.
//
// ****************************************************************************
avtVariableSummationQuery::avtVariableSummationQuery() : avtSummationQuery()
{
condense = new avtCondenseDatasetFilter;
condense->KeepAVTandVTK(true);
condense->BypassHeuristic(true);
}
......@@ -29,10 +37,19 @@ avtVariableSummationQuery::avtVariableSummationQuery() : avtSummationQuery()
// Programmer: Hank Childs
// Creation: February 3, 2004
//
// Modifications:
// Kathleen Bonnell, Thu Mar 2 15:05:17 PST 2006
// Add condense filter.
//
// ****************************************************************************
avtVariableSummationQuery::~avtVariableSummationQuery()
{
if (condense != NULL)
{
delete condense;
condense = NULL;
}
}
......@@ -83,3 +100,81 @@ avtVariableSummationQuery::VerifyInput(void)
}
// ****************************************************************************
// Method: avtVariableSummationQuery::ApplyFilters
//
// Purpose:
//
// Programmer: Kathleen Bonnell
// Creation: February 24, 2006
//
// Modifications:
//
// ****************************************************************************
avtDataObject_p
avtVariableSummationQuery::ApplyFilters(avtDataObject_p inData)
{
avtDataValidity &dval = GetInput()->GetInfo().GetValidity();
avtDataAttributes &datts = GetInput()->GetInfo().GetAttributes();
bool cellData = false;
avtCentering cent = AVT_UNKNOWN_CENT;
if (datts.ValidVariable(variableName))
{
cent = datts.GetCentering(variableName.c_str());
cellData = (cent != AVT_NODECENT);
}
else
{
// we can't determine the centering, assume zone-centered
cellData = true;
}
if (dval.SubdivisionOccurred() ||
(!dval.GetOriginalZonesIntact() && cellData))
{
// This will work for time-varying data, too.
// tell parent class to sum from original element values.
// e.g. each 'original' cell/node constributes only once to
// the sum.
SumFromOriginalElement(true);
// Need to request original cell and/or node numbers
avtDataSpecification_p oldSpec = inData->GetTerminatingSource()->
GetGeneralPipelineSpecification()->GetDataSpecification();
avtDataSpecification_p newDS = new
avtDataSpecification(oldSpec, querySILR);
newDS->SetTimestep(queryAtts.GetTimeStep());
if (cent == AVT_ZONECENT)
{
newDS->TurnZoneNumbersOn();
}
else if (cent == AVT_NODECENT)
{
newDS->TurnNodeNumbersOn();
}
else
{
newDS->TurnZoneNumbersOn();
newDS->TurnNodeNumbersOn();
}
avtPipelineSpecification_p pspec =
new avtPipelineSpecification(newDS, queryAtts.GetPipeIndex());
avtDataObject_p temp;
CopyTo(temp, inData);
condense->SetInput(temp);
avtDataObject_p rv = condense->GetOutput();
rv->Update(pspec);
return rv;
}
else
{
return avtSummationQuery::ApplyFilters(inData);
}
}
......@@ -9,6 +9,8 @@
#include <avtSummationQuery.h>
class avtCondenseDatasetFilter;
// ****************************************************************************
// Class: avtVariableSummationQuery
......@@ -19,6 +21,10 @@
// Programmer: Hank Childs
// Creation: February 3, 2004
//
// Modifications:
// Kathleen Bonnell, Thu Mar 2 15:05:17 PST 2006
// Add ApplyFilters() and condense filter.
//
// ****************************************************************************
class QUERY_API avtVariableSummationQuery : public avtSummationQuery
......@@ -31,7 +37,10 @@ class QUERY_API avtVariableSummationQuery : public avtSummationQuery
{ return "avtVariableSummationQuery"; };
protected:
avtCondenseDatasetFilter *condense;
virtual void VerifyInput(void);
virtual avtDataObject_p ApplyFilters(avtDataObject_p);
};
......
......@@ -17,6 +17,8 @@
#include <vtkFloatArray.h>
#include <vtkIdList.h>
#include <vtkIdTypeArray.h>
#include <vtkCharArray.h>
#include <vtkShortArray.h>
#include <vtkIntArray.h>
#include <vtkPointData.h>
#include <vtkPolyData.h>
......@@ -929,6 +931,9 @@ avtSiloFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md)
//
// Kathleen Bonnell, Wed Feb 8 09:41:45 PST 2006
// Set mmd->meshCoordType from coord_sys.
//
// Mark C. Miller, Thu Mar 2 00:03:40 PST 2006
// Added support for curve objects
//
// ****************************************************************************
......@@ -1075,6 +1080,13 @@ avtSiloFileFormat::ReadDir(DBfile *dbfile, const char *dirname,
strcpy(defvars_names[i], toc->defvars_names[i]);
}
#endif
int ncurves = toc->ncurve;
char **curve_names = new char*[ncurves];
for (i = 0 ; i < ncurves; i++)
{
curve_names[i] = new char[strlen(toc->curve_names[i])+1];
strcpy(curve_names[i], toc->curve_names[i]);
}
//
// The dbfile will probably change, so read in the meshtv_defvars and
......@@ -1646,6 +1658,36 @@ avtSiloFileFormat::ReadDir(DBfile *dbfile, const char *dirname,
DBFreePointmesh(pm);
}
//
// Curves
//
for (i = 0 ; i < ncurves; i++)
{
char *realvar;
DBfile *correctFile = dbfile;
DetermineFileAndDirectory(curve_names[i], correctFile, realvar);
DBcurve *cur = DBGetCurve(correctFile, realvar);
if (cur == NULL)
EXCEPTION1(InvalidFilesException, curve_names[i]);
char *name_w_dir = GenerateName(dirname, curve_names[i]);
avtCurveMetaData *cmd = new avtCurveMetaData(name_w_dir);
if (cur->xlabel != NULL)
cmd->xLabel = cur->xlabel;
if (cur->ylabel != NULL)
cmd->yLabel = cur->ylabel;
if (cur->xunits != NULL)
cmd->xUnits = cur->xunits;
if (cur->yunits != NULL)
cmd->yUnits = cur->yunits;
md->Add(cmd);
delete [] name_w_dir;
DBFreeCurve(cur);
}
#ifdef DBCSG_INNER // remove after silo-4.5 is released
//
// Csg-meshes
......@@ -2620,6 +2662,11 @@ avtSiloFileFormat::ReadDir(DBfile *dbfile, const char *dirname,
}
delete [] defvars_names;
#endif
for (i = 0 ; i < ncurves; i++)
{
delete [] curve_names[i];
}
delete [] curve_names;
}
// ****************************************************************************
......@@ -3960,6 +4007,9 @@ avtSiloFileFormat::GetPointVectorVar(DBfile *dbfile, const char *vname)
// Mark C. Miller, Mon Feb 14 20:28:47 PST 2005
// Added test for DB_QUAD_CURV/RECT for valid type
//
// Mark C. Miller, Thu Mar 2 00:03:40 PST 2006
// Added support for curves
//
// ****************************************************************************
vtkDataSet *
......@@ -3997,10 +4047,11 @@ avtSiloFileFormat::GetMesh(int domain, const char *m)
#ifdef DBCSG_INNER // remove after silo-4.5 is released
if (type != DB_UCDMESH && type != DB_QUADMESH && type != DB_QUAD_CURV &&
type != DB_QUAD_RECT && type != DB_POINTMESH && type != DB_MULTIMESH &&
type != DB_CSGMESH)
type != DB_CSGMESH && type != DB_CURVE)
#else
if (type != DB_UCDMESH && type != DB_QUADMESH && type != DB_QUAD_CURV &&
type != DB_QUAD_RECT && type != DB_POINTMESH && type != DB_MULTIMESH)
type != DB_QUAD_RECT && type != DB_POINTMESH && type != DB_MULTIMESH &&
type != DB_CURVE)
#endif
{
EXCEPTION1(InvalidVariableException, mesh);
......@@ -4066,6 +4117,10 @@ avtSiloFileFormat::GetMesh(int domain, const char *m)
rv = GetCSGMesh(domain_file, directory_mesh, domain);
}
#endif
else if (type == DB_CURVE)
{
rv = GetCurve(domain_file, directory_mesh);
}
else
{
EXCEPTION0(ImproperUseException);
......@@ -5285,6 +5340,120 @@ avtSiloFileFormat::VerifyQuadmesh(DBquadmesh *qm, const char *meshname)
}
}
// ****************************************************************************
// Method: avtSiloFileFormat::GetCurve
//
// Purpose: Read a Silo curve object and return a vtkDataSet for it
//
// Arguments:
// dbfile A handle to the file this variable lives in.
// mn The curve name.
//
// Returns: The vtkDataSet corresponding to mn.
//
// Programmer: Mark C. Miller
// Creation: March 1, 2006
//
// Modifications:
//
// ****************************************************************************
vtkDataSet *
avtSiloFileFormat::GetCurve(DBfile *dbfile, const char *cn)
{
int i;
//
// It's ridiculous, but Silo does not have all of the `const's in their
// library, so let's cast it away.
//
char *curvename = const_cast<char *>(cn);
//
// Get the Silo construct.
//
DBcurve *cur = DBGetCurve(dbfile, curvename);
if (cur == NULL)
{
EXCEPTION1(InvalidVariableException, curvename);
}
//
// Add all of the points to an array.
//
vtkPolyData *pd = vtkPolyData::New();
vtkPoints *pts = vtkPoints::New();
pd->SetPoints(pts);
// DBForceSingle assures that all double data is converted to float
// So, both are handled as float, here
if (cur->datatype == DB_FLOAT ||
cur->datatype == DB_DOUBLE)
{
vtkFloatArray *farr= vtkFloatArray::New();
farr->SetNumberOfComponents(3);
farr->SetNumberOfTuples(cur->npts);
for (i = 0 ; i < cur->npts; i++)
farr->SetTuple3(i, cur->x[i], cur->y[i], 0.0);
pts->SetData(farr);
farr->Delete();
}
else if (cur->datatype == DB_INT)
{
int *px = (int *) cur->x;
int *py = (int *) cur->y;
vtkIntArray *iarr= vtkIntArray::New();
iarr->SetNumberOfComponents(3);
iarr->SetNumberOfTuples(cur->npts);
for (i = 0 ; i < cur->npts; i++)
iarr->SetTuple3(i, px[i], py[i], 0);
pts->SetData(iarr);
iarr->Delete();
}
else if (cur->datatype == DB_SHORT)
{
short *px = (short *) cur->x;
short *py = (short *) cur->y;
vtkShortArray *sarr= vtkShortArray::New();
sarr->SetNumberOfComponents(3);
sarr->SetNumberOfTuples(cur->npts);
for (i = 0 ; i < cur->npts; i++)
sarr->SetTuple3(i, px[i], py[i], 0);
pts->SetData(sarr);
sarr->Delete();
}
else if (cur->datatype == DB_CHAR)
{
char *px = (char *) cur->x;
char *py = (char *) cur->y;
vtkCharArray *carr= vtkCharArray::New();
carr->SetNumberOfComponents(3);
carr->SetNumberOfTuples(cur->npts);