Commit 897bda0e authored by hrchilds's avatar hrchilds
Browse files

Update from September 15, 2004

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@324 18c085ea-50e0-402c-830e-de6fd14e8384
parent 3fc2c6a4
......@@ -1277,6 +1277,9 @@ PluginManager::PluginOpen(const string &pluginFile)
// return value to throw an exception without calling PluginError themselves.
// That prevents useful information from being printed to the debug logs.
//
// Brad Whitlock, Tue Sep 14 13:27:35 PST 2004
// I made the debug output go to debug5.
//
// ****************************************************************************
void *
......@@ -1317,7 +1320,7 @@ PluginManager::PluginSymbol(const string &symbol)
// If the symbol was not found, print the error message.
if(retval == 0)
debug4 << PluginError() << endl;
debug5 << PluginError() << endl;
return retval;
}
......
......@@ -6,6 +6,7 @@
#include <string>
#include <vtkCellType.h>
#include <vtkFloatArray.h>
#include <vtkDoubleArray.h>
#include <vtkIntArray.h>
......@@ -21,7 +22,6 @@
#include <InvalidTimeStepException.h>
#include <snprintf.h>
using std::string;
#define MAKE_SURE_THE_FILE_IS_NOT_TETRAD
......@@ -34,10 +34,12 @@ using std::string;
// ****************************************************************************
avtPixieFileFormat::avtPixieFileFormat(const char *filename)
: avtMTSDFileFormat(&filename, 1), variables(), meshes()
: avtMTSDFileFormat(&filename, 1), variables(), meshes(),
timeStatePrefix("/Timestep ")
{
fileId = -1;
nTimeStates = 0;
haveMeshCoords = false;
#ifdef MAKE_SURE_THE_FILE_IS_NOT_TETRAD
// This sucks to have to call this here but it's the only way to
......@@ -159,7 +161,9 @@ avtPixieFileFormat::FreeUpResources(void)
// Creation: Fri Aug 13 15:21:08 PST 2004
//
// Modifications:
//
// Brad Whitlock, Wed Sep 15 17:45:41 PST 2004
// Added better support for determining whether arrays have coordinates.
//
// ****************************************************************************
void
......@@ -205,6 +209,10 @@ avtPixieFileFormat::Initialize()
info.This = this;
info.level = 0;
info.path = "/";
info.hasCoords = false;
info.coordX = "";
info.coordY = "";
info.coordZ = "";
H5Giterate(fileId, "/", NULL, GetVariableList, (void*)&info);
H5Gclose(gid);
......@@ -212,10 +220,12 @@ avtPixieFileFormat::Initialize()
for(VarInfoMap::const_iterator it = variables.begin();
it != variables.end(); ++it)
{
const char *mNames[] = {"mesh", "curvemesh"};
char tmp[100];
SNPRINTF(tmp, 100, "mesh_%dx%dx%d", int(it->second.dims[0]),
SNPRINTF(tmp, 100, "%s_%dx%dx%d", mNames[it->second.hasCoords?1:0],
int(it->second.dims[2]),
int(it->second.dims[1]),
int(it->second.dims[2]));
int(it->second.dims[0]));
meshes[std::string(tmp)] = it->second;
}
......@@ -228,6 +238,154 @@ avtPixieFileFormat::Initialize()
}
}
// ****************************************************************************
// Method: avtPixieFileFormat::ActivateTimestep
//
// Purpose:
// This method is called each time we change to a new time state. Make
// sure that the file has been initialized.
//
// Programmer: Brad Whitlock
// Creation: Tue Sep 14 12:53:08 PDT 2004
//
// Modifications:
//
// ****************************************************************************
void
avtPixieFileFormat::ActivateTimestep(int ts)
{
//
// Initialize the file if it has not been initialized.
//
debug4 << "avtPixieFileFormat::ActivateTimestep: ts=" << ts << endl;
Initialize();
}
// ****************************************************************************
// Method: avtPixieFileFormat::DetermineVarDimensions
//
// Purpose:
// Gets the dimensions of a variable.
//
// Arguments:
//
// Returns:
//
// Note:
//
// Programmer: Brad Whitlock
// Creation: Thu Aug 19 10:57:09 PDT 2004
//
// Modifications:
//
// ****************************************************************************
void
avtPixieFileFormat::DetermineVarDimensions(const VarInfo &info, int *dims,
int &nSpatialDims) const
{
// Determine the number of spatial dimensions.
nSpatialDims = 0;
if(info.dims[0] > 1) ++nSpatialDims;
if(info.dims[1] > 1) ++nSpatialDims;
if(info.dims[2] > 1) ++nSpatialDims;
//
// Determine the dimensions for the mesh.
//
if(dims != 0)
{
if(nSpatialDims < 3)
{
int d[3] = {1,1,1}, di = 0;
if(info.dims[0] > 1)
d[di++] = int(info.dims[0]);
if(info.dims[1] > 1)
d[di++] = int(info.dims[1]);
if(info.dims[2] > 1)
d[di++] = int(info.dims[2]);
dims[0] = d[0];
dims[1] = d[1];
dims[2] = 1;
}
else
{
dims[0] = int(info.dims[0]);
dims[1] = int(info.dims[1]);
dims[2] = int(info.dims[2]);
}
}
}
// ****************************************************************************
// Method: avtPixieFileFormat::MeshIsCurvilinear
//
// Purpose:
// Returns whether the named mesh is curvilinear.
//
// Arguments:
//
// Returns:
//
// Note:
//
// Programmer: Brad Whitlock
// Creation: Wed Sep 15 08:45:29 PDT 2004
//
// Modifications:
// Brad Whitlock, Wed Sep 15 17:06:28 PST 2004
// I changed how the support for mesh coordinates is handled.
//
// ****************************************************************************
bool
avtPixieFileFormat::MeshIsCurvilinear(const std::string &name) const
{
bool retval = false;
if (haveMeshCoords)
{
VarInfoMap::const_iterator mesh = meshes.find(name);
if (mesh != meshes.end() && mesh->second.hasCoords)
{
VarInfoMap::const_iterator xvar = variables.find(
mesh->second.coordX);
VarInfoMap::const_iterator yvar = variables.find(
mesh->second.coordY);
VarInfoMap::const_iterator zvar = variables.find(
mesh->second.coordZ);
int dims[3], nSpatialDims = 1;
DetermineVarDimensions(mesh->second, dims, nSpatialDims);
int xDims[3], nXDims = 1;
DetermineVarDimensions(xvar->second, xDims, nXDims);
int yDims[3], nYDims = 1;
DetermineVarDimensions(yvar->second, yDims, nYDims);
int zDims[3], nZDims = 1;
DetermineVarDimensions(zvar->second, zDims, nZDims);
bool same = true;
for(int i = 0; i < nSpatialDims && same; ++i)
{
same &= (xDims[i] == yDims[i]);
same &= (yDims[i] == zDims[i]);
// The Pixie mesh's coordinate arrays have a
// (nx+1)*(ny+1)*(nz+1) values compared to the
// mesh size. This is somewhat weird but check
// for it.
same &= (xvar->second.dims[i] == (mesh->second.dims[i] + 1));
}
retval = same;
}
}
return retval;
}
// ****************************************************************************
// Method: avtPixieFileFormat::PopulateDatabaseMetaData
//
......@@ -239,27 +397,28 @@ avtPixieFileFormat::Initialize()
// Programmer: Brad Whitlock
// Creation: Fri Aug 13 14:31:43 PST 2004
//
// Modifications:
// Brad Whitlock, Mon Aug 16 13:50:41 PST 2004
// Added support for a curvilinear mesh and an optional point mesh for
// debugging.
//
// ****************************************************************************
void
avtPixieFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md)
{
#ifndef MAKE_SURE_THE_FILE_IS_NOT_TETRAD
//
// Initialize the file if it has not been initialized.
//
Initialize();
#endif
//#define ADD_POINT_MESH
VarInfoMap::const_iterator it;
#ifdef ADD_POINT_MESH
int pmnDims = -1;
VarInfo pm;
#endif
for(it = meshes.begin();
it != meshes.end(); ++it)
{
// Determine the number of spatial dimensions.
int nSpatialDims = 0;
if(it->second.dims[0] > 1) ++nSpatialDims;
if(it->second.dims[1] > 1) ++nSpatialDims;
if(it->second.dims[2] > 1) ++nSpatialDims;
DetermineVarDimensions(it->second, 0, nSpatialDims);
if(nSpatialDims == 0)
continue;
......@@ -268,10 +427,42 @@ avtPixieFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md)
mmd->name = it->first;
mmd->spatialDimension = nSpatialDims;
mmd->topologicalDimension = nSpatialDims;
mmd->meshType = AVT_RECTILINEAR_MESH;
// Determine the mesh type. Usually it will be rectilinear but
// sometimes, if we have the right kind of coordinate arrays, it
// could be curvilinear.
mmd->meshType = MeshIsCurvilinear(it->first) ? AVT_CURVILINEAR_MESH :
AVT_RECTILINEAR_MESH;
mmd->cellOrigin = 1;
md->Add(mmd);
#ifdef ADD_POINT_MESH
// If we had a curvilinear mesh, add a point mesh to aid in debugging.
if(mmd->meshType == AVT_CURVILINEAR_MESH)
{
pmnDims = nSpatialDims;
pm.dims[0] = it->second.dims[0];
pm.dims[1] = it->second.dims[1];
pm.dims[2] = it->second.dims[2];
}
#endif
}
#ifdef ADD_POINT_MESH
if(pmnDims != -1)
{
meshes["pointmesh"] = pm;
avtMeshMetaData *mmd = new avtMeshMetaData;
mmd->name = "pointmesh";
mmd->spatialDimension = pmnDims;
mmd->topologicalDimension = 0;
mmd->meshType = AVT_POINT_MESH;
mmd->cellOrigin = 1;
md->Add(mmd);
}
#endif
// If we have more than 5 meshes, enable catchall mesh.
if(meshes.size() > 5)
......@@ -282,16 +473,25 @@ avtPixieFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md)
it != variables.end(); ++it)
{
// Determine the mesh name based on the variable mesh size.
const char *mNames[] = {"mesh", "curvemesh"};
char tmp[100];
SNPRINTF(tmp, 100, "mesh_%dx%dx%d", int(it->second.dims[0]),
SNPRINTF(tmp, 100, "%s_%dx%dx%d", mNames[it->second.hasCoords?1:0],
int(it->second.dims[2]),
int(it->second.dims[1]),
int(it->second.dims[2]));
int(it->second.dims[0]));
// Add a zonal scalar to the metadata.
AddScalarVarToMetaData(md, it->first, tmp, AVT_ZONECENT);
AddScalarVarToMetaData(md, it->first, tmp, AVT_ZONECENT);
}
}
#ifdef ADD_POINT_MESH
if(pmnDims != -1)
{
variables["pointvar"] = pm;
AddScalarVarToMetaData(md, "pointvar", "pointmesh", AVT_NODECENT);
}
#endif
}
// ****************************************************************************
// Method: avtPixieFileFormat::GetMesh
......@@ -310,6 +510,14 @@ avtPixieFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md)
// Programmer: Brad Whitlock
// Creation: Fri Aug 13 14:31:43 PST 2004
//
// Modifications:
// Brad Whitlock, Tue Aug 24 12:42:07 PDT 2004
// Added support for a curvilinear mesh.
//
// Brad Whitlock, Wed Sep 15 22:09:24 PST 2004
// I reversed the dimensions for the 3D rectilinear mesh so the variables
// would display correctly on it.
//
// ****************************************************************************
vtkDataSet *
......@@ -325,83 +533,301 @@ avtPixieFileFormat::GetMesh(int timestate, const char *meshname)
}
// Check the mesh name.
string meshNameString(meshname);
std::string meshNameString(meshname);
VarInfoMap::const_iterator it = meshes.find(meshNameString);
if(it == meshes.end())
{
EXCEPTION1(InvalidVariableException, meshNameString);
}
// Determine the number of spatial dimensions.
int nSpatialDims = 0;
if(it->second.dims[0] > 1) ++nSpatialDims;
if(it->second.dims[1] > 1) ++nSpatialDims;
if(it->second.dims[2] > 1) ++nSpatialDims;
if(nSpatialDims < 2)
int originalDims[3] = {it->second.dims[0],
it->second.dims[1],
it->second.dims[2]};
debug4 << "avtPixieFileFormat::GetMesh: 0: "
<< "originalDims={" << originalDims[0]
<< ", " << originalDims[1]
<< ", " << originalDims[2] << "}" << endl;
//
// Determine the number of cells in each dimension. Note that
// DetermineVarDimensions throws out dimensions with 1 so we
// 1x33x33 could become 33x33. When we use ndims hereafter,
// it will contain the reduced number of dimensions if any
// reduction has been done.
//
int dims[3] = {1, 1, 1};
int ndims = 2;
DetermineVarDimensions(it->second, dims, ndims);
if(ndims < 2)
{
EXCEPTION1(InvalidVariableException, meshNameString);
}
//
// Create a rectilinear grid for now. Curvlinear can come later
// once the convention is determined...
// Add 1 so we have the number of nodes instead of #cells.
//
vtkRectilinearGrid *rgrid = vtkRectilinearGrid::New();
int XDIMS = 1, YDIMS = 1, ZDIMS = 1;
if(nSpatialDims == 2)
++dims[0];
++dims[1];
if(ndims == 3)
++dims[2];
debug4 << "avtPixieFileFormat::GetMesh: 1: ndims=" << ndims
<< ", dims={" << dims[0] << ", " << dims[1] << ", "
<< dims[2] << "}" << endl;
// Try and create a curvilinear mesh.
vtkDataSet *retval = 0;
if(meshNameString == "pointmesh")
retval = CreatePointMesh(timestate, it->second, ndims);
else if(MeshIsCurvilinear(meshname))
retval = CreateCurvilinearMesh(timestate, it->second, dims, ndims);
// Create a rectilinear mesh.
if(retval == 0)
{
int d[3], di = 0;
if(it->second.dims[0] > 1)
d[di++] = int(it->second.dims[0]);
if(it->second.dims[1] > 1)
d[di++] = int(it->second.dims[1]);
if(it->second.dims[2] > 1)
d[di++] = int(it->second.dims[2]);
XDIMS = d[0]+1;
YDIMS = d[1]+1;
// Reverse X,Z dimensions so the mesh is drawn properly.
if(ndims == 3)
{
int tmp = dims[0];
dims[0] = dims[2];
dims[2] = tmp;
}
vtkRectilinearGrid *rgrid = vtkRectilinearGrid::New();
vtkFloatArray *coords[3];
for (int i = 0 ; i < 3 ; i++)
{
// Default number of components for an array is 1.
coords[i] = vtkFloatArray::New();
if (i < ndims)
{
coords[i]->SetNumberOfTuples(dims[i]);
for (int j = 0; j < dims[i]; j++)
coords[i]->SetComponent(j, 0, j);
}
else
{
dims[i] = 1;
coords[i]->SetNumberOfTuples(1);
coords[i]->SetComponent(0, 0, 0.);
}
}
rgrid->SetDimensions(dims);
rgrid->SetXCoordinates(coords[0]);
coords[0]->Delete();
rgrid->SetYCoordinates(coords[1]);
coords[1]->Delete();
rgrid->SetZCoordinates(coords[2]);
coords[2]->Delete();
retval = rgrid;
}
else if(nSpatialDims == 3)
return retval;
}
// ****************************************************************************
// Method: avtPixieFileFormat::CreatePointMesh
//
// Purpose:
// Creates a point mesh.
//
// Arguments:
//
// Returns:
//
// Note:
//
// Programmer: Brad Whitlock
// Creation: Wed Sep 15 08:43:28 PDT 2004
//
// Modifications:
// Brad Whitlock, Wed Sep 15 17:18:31 PST 2004
// Added support for reading custom coordinate arrays.
//
// ****************************************************************************
vtkDataSet *
avtPixieFileFormat::CreatePointMesh(int timestate, const VarInfo &info,
int nDims) const
{
vtkDataSet *ds = 0;
float *coords[3] = {0,0,0};
int dims[3] = {0, 0, 0};
//
// Try and read the coordinate fields.
//
if(ReadCoordinateFields(timestate, info, coords, dims, nDims))
{
XDIMS = int(it->second.dims[0])+1;
YDIMS = int(it->second.dims[1])+1;
ZDIMS = int(it->second.dims[2])+1;
//
// Populate the coordinates. Put in 3D points with z=0 if the mesh
// is 2D.
//
int i, nPoints = dims[0] * dims[1] * ((nDims > 2) ? dims[2] : 1);
vtkPoints *points = vtkPoints::New();
points->SetNumberOfPoints(nPoints);
float *pts = (float *) points->GetVoidPointer(0);
for(i = 0; i < 3; ++i)
{
float *tmp = pts + i;
if(nDims > 2)
{
float *coord = coords[i];
for(int j = 0; j < nPoints; ++j)
{
*tmp = *coord++;
tmp += 3;
}
}
else
{
for (int j = 0; j < nPoints; ++j)
{
*tmp = 0.f;
tmp += 3;
}
}
}
//
// Create the VTK objects and connect them up.
//
vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::New();
ugrid->SetPoints(points);
ugrid->Allocate(nPoints);
vtkIdType onevertex;
for(i = 0; i < nPoints; ++i)
{
onevertex = i;
ugrid->InsertNextCell(VTK_VERTEX, 1, &onevertex);
}
points->Delete();
ds = ugrid;
}
int dims[3] = {XDIMS, YDIMS, ZDIMS};
int ndims = nSpatialDims;
vtkFloatArray *coords[3];
for (int i = 0 ; i < 3 ; i++)
return ds;
}
// ****************************************************************************
// Method: avtPixieFileFormat::CreateCurvilinearMesh
//
// Purpose:
// Returns a curvilinear mesh.
//
// Arguments:
//
// Returns:
//
// Note:
//
// Programmer: Brad Whitlock
// Creation: Wed Sep 15 08:38:31 PDT 2004
//
// Modifications:
// Brad Whitlock, Wed Sep 15 17:19:05 PST 2004
// Added support for custom coordinate arrays.
//
// ****************************************************************************
vtkDataSet *
avtPixieFileFormat::CreateCurvilinearMesh(int timestate, const VarInfo &info,
int nnodes[3], int nDims)
{
vtkDataSet *retval = 0;
//
// Try and read the coordinate fields.
//
float *coords[3] = {0,0,0};
int coordDims[3];
if(ReadCoordinateFields(timestate, info, coords, coordDims, nDims))
{
// Default number of components for an array is 1.