Commit 586e50de authored by hrchilds's avatar hrchilds
Browse files

Update from June 17, 2005

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@486 18c085ea-50e0-402c-830e-de6fd14e8384
parent 8b65d830
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0"?>
<Plugin name="AUXFile" label="AUX" type="database" dbtype="STSD" version="1.0">
<Extensions> aux </Extensions>
</Plugin>
#include <AUXFilePluginInfo.h>
#include <avtAUXFileFileFormat.h>
#include <avtSTSDFileFormatInterface.h>
#include <avtGenericDatabase.h>
// ****************************************************************************
// Method: AUXFileCommonPluginInfo::GetDatabaseType
//
// Purpose:
// Returns the type of a AUXFile database.
//
// Programmer: miller -- generated by xml2info
// Creation: Wed May 25 15:17:20 PST 2005
//
// ****************************************************************************
DatabaseType
AUXFileCommonPluginInfo::GetDatabaseType()
{
return DB_TYPE_STSD;
}
// ****************************************************************************
// Method: AUXFileCommonPluginInfo::GetDefaultExtensions
//
// Purpose:
// Returns the default extensions for a AUXFile database.
//
// Programmer: miller -- generated by xml2info
// Creation: Wed May 25 15:17:20 PST 2005
//
// ****************************************************************************
std::vector<std::string>
AUXFileCommonPluginInfo::GetDefaultExtensions()
{
std::vector<std::string> defaultExtensions;
defaultExtensions.push_back("aux");
return defaultExtensions;
}
// ****************************************************************************
// Method: AUXFileCommonPluginInfo::SetUpAUXFileDatabase
//
// Purpose:
// Sets up a AUXFile database.
//
// Arguments:
// list A list of file names.
// nList The number of timesteps in list.
// nBlocks The number of blocks in the list.
//
// Returns: A AUXFile database from list.
//
// Programmer: miller -- generated by xml2info
// Creation: Wed May 25 15:17:20 PST 2005
//
// ****************************************************************************
avtDatabase *
AUXFileCommonPluginInfo::SetupDatabase(const char *const *list,
int nList, int nBlock)
{
avtSTSDFileFormat ***ffl = new avtSTSDFileFormat**[nList];
int nTimestep = nList / nBlock;
for (int i = 0 ; i < nTimestep ; i++)
{
ffl[i] = new avtSTSDFileFormat*[nBlock];
for (int j = 0 ; j < nBlock ; j++)
{
ffl[i][j] = new avtAUXFileFileFormat(list[i*nBlock + j]);
}
}
avtSTSDFileFormatInterface *inter
= new avtSTSDFileFormatInterface(ffl, nTimestep, nBlock);
return new avtGenericDatabase(inter);
}
#include <AUXFilePluginInfo.h>
#if defined(__APPLE__)
#define GetEngineInfo AUXFile_GetEngineInfo
#endif
// ****************************************************************************
// Function: GetEngineInfo
//
// Purpose:
// Return a new EnginePluginInfo for the AUXFile database.
//
// Programmer: miller -- generated by xml2info
// Creation: Wed May 25 15:17:20 PST 2005
//
// ****************************************************************************
extern "C" EngineDatabasePluginInfo* GetEngineInfo()
{
return new AUXFileEnginePluginInfo;
}
// ****************************************************************************
// Method: AUXFileCommonPluginInfo::GetWriter
//
// Purpose:
// Sets up a AUXFile writer.
//
// Returns: A AUXFile writer.
//
// Programmer: miller -- generated by xml2info
// Creation: Wed May 25 15:17:20 PST 2005
//
// ****************************************************************************
avtDatabaseWriter *
AUXFileEnginePluginInfo::GetWriter(void)
{
return NULL;
}
#include <AUXFilePluginInfo.h>
#if defined(__APPLE__)
#define GetMDServerInfo AUXFile_GetMDServerInfo
#endif
// ****************************************************************************
// Function: GetMDServerInfo
//
// Purpose:
// Return a new MDServerPluginInfo for the AUXFile database.
//
// Programmer: miller -- generated by xml2info
// Creation: Wed May 25 15:17:20 PST 2005
//
// ****************************************************************************
extern "C" MDServerDatabasePluginInfo* GetMDServerInfo()
{
return new AUXFileMDServerPluginInfo;
}
// this makes compilers happy... remove if we ever have functions here
void AUXFileMDServerPluginInfo::dummy()
{
}
// ************************************************************************* //
// File: AUXFilePluginInfo.C
// ************************************************************************* //
#include <AUXFilePluginInfo.h>
#include <visit-config.h>
#if defined(__APPLE__)
extern "C" const char *AUXFileVisItPluginVersion = VERSION;
#else
extern "C" const char *VisItPluginVersion = VERSION;
#endif
#if defined(__APPLE__)
#define GetGeneralInfo AUXFile_GetGeneralInfo
#endif
// ****************************************************************************
// Function: GetGeneralInfo
//
// Purpose:
// Return a new GeneralPluginInfo for the AUXFile database.
//
// Programmer: miller -- generated by xml2info
// Creation: Wed May 25 15:17:20 PST 2005
//
// ****************************************************************************
extern "C" GeneralDatabasePluginInfo* GetGeneralInfo()
{
return new AUXFileGeneralPluginInfo;
}
// ****************************************************************************
// Method: AUXFileGeneralPluginInfo::GetName
//
// Purpose:
// Return the name of the database plugin.
//
// Returns: A pointer to the name of the database plugin.
//
// Programmer: miller -- generated by xml2info
// Creation: Wed May 25 15:17:20 PST 2005
//
// ****************************************************************************
char *
AUXFileGeneralPluginInfo::GetName() const
{
return "AUXFile";
}
// ****************************************************************************
// Method: AUXFileGeneralPluginInfo::GetVersion
//
// Purpose:
// Return the version of the database plugin.
//
// Returns: A pointer to the version of the database plugin.
//
// Programmer: miller -- generated by xml2info
// Creation: Wed May 25 15:17:20 PST 2005
//
// ****************************************************************************
char *
AUXFileGeneralPluginInfo::GetVersion() const
{
return "1.0";
}
// ****************************************************************************
// Method: AUXFileGeneralPluginInfo::GetID
//
// Purpose:
// Return the id of the database plugin.
//
// Returns: A pointer to the id of the database plugin.
//
// Programmer: miller -- generated by xml2info
// Creation: Wed May 25 15:17:20 PST 2005
//
// ****************************************************************************
char *
AUXFileGeneralPluginInfo::GetID() const
{
return "AUXFile_1.0";
}
// ****************************************************************************
// Method: AUXFileGeneralPluginInfo::EnabledByDefault
//
// Purpose:
// Return true if this plugin should be enabled by default; false otherwise.
//
// Returns: true/false
//
// Programmer: miller -- generated by xml2info
// Creation: Wed May 25 15:17:20 PST 2005
//
// ****************************************************************************
bool
AUXFileGeneralPluginInfo::EnabledByDefault() const
{
return true;
}
// ****************************************************************************
// Method: AUXFileGeneralPluginInfo::HasWriter
//
// Purpose:
// Return true if this plugin has a database writer.
//
// Returns: true/false
//
// Programmer: miller -- generated by xml2info
// Creation: Wed May 25 15:17:20 PST 2005
//
// ****************************************************************************
bool
AUXFileGeneralPluginInfo::HasWriter() const
{
return false;
}
// ****************************************************************************
// AUXFilePluginInfo.h
// ****************************************************************************
#ifndef AUXFile_PLUGIN_INFO_H
#define AUXFile_PLUGIN_INFO_H
#include <DatabasePluginInfo.h>
#include <database_plugin_exports.h>
class avtDatabase;
class avtDatabaseWriter;
// ****************************************************************************
// Class: AUXFileDatabasePluginInfo
//
// Purpose:
// Classes that provide all the information about the AUXFile plugin.
// Portions are separated into pieces relevant to the appropriate
// components of VisIt.
//
// Programmer: miller -- generated by xml2info
// Creation: Wed May 25 15:17:20 PST 2005
//
// Modifications:
//
// ****************************************************************************
class AUXFileGeneralPluginInfo : public virtual GeneralDatabasePluginInfo
{
public:
virtual char *GetName() const;
virtual char *GetVersion() const;
virtual char *GetID() const;
virtual bool EnabledByDefault() const;
virtual bool HasWriter() const;
};
class AUXFileCommonPluginInfo : public virtual CommonDatabasePluginInfo, public virtual AUXFileGeneralPluginInfo
{
public:
virtual DatabaseType GetDatabaseType();
virtual std::vector<std::string> GetDefaultExtensions();
virtual avtDatabase *SetupDatabase(const char * const *list,
int nList, int nBlock);
};
class AUXFileMDServerPluginInfo : public virtual MDServerDatabasePluginInfo, public virtual AUXFileCommonPluginInfo
{
public:
// this makes compilers happy... remove if we ever have functions here
virtual void dummy();
};
class AUXFileEnginePluginInfo : public virtual EngineDatabasePluginInfo, public virtual AUXFileCommonPluginInfo
{
public:
virtual avtDatabaseWriter *GetWriter(void);
};
#endif
// ************************************************************************* //
// avtAUXFileFileFormat.C //
// ************************************************************************* //
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <fcntl.h>
#include <avtAUXFileFileFormat.h>
#include <string>
#include <vtkFloatArray.h>
#include <vtkRectilinearGrid.h>
#include <avtDatabaseMetaData.h>
#include <Expression.h>
#include <InvalidVariableException.h>
#include <InvalidFilesException.h>
using std::string;
// ****************************************************************************
// Method: avtAUXFile constructor
//
// Programmer: miller -- generated by xml2avt
// Creation: Tue Mar 15 08:29:20 PDT 2005
//
// ****************************************************************************
avtAUXFileFileFormat::avtAUXFileFileFormat(const char *filename)
: avtSTSDFileFormat(filename)
{
fileName = filename;
fileBuf = 0;
sizeX = -1;
sizeY = -1;
fluence = 0;
}
// ****************************************************************************
// Method: avtAUXFileFileFormat::FreeUpResources
//
// Purpose:
// When VisIt is done focusing on a particular timestep, it asks that
// timestep to free up any resources (memory, file descriptors) that
// it has associated with it. This method is the mechanism for doing
// that.
//
// Programmer: miller -- generated by xml2avt
// Creation: Tue Mar 15 08:29:20 PDT 2005
//
// ****************************************************************************
void
avtAUXFileFileFormat::FreeUpResources(void)
{
if (fileBuf)
{
delete [] fileBuf;
fileBuf = 0;
}
if (fluence)
{
fluence->Delete();
fluence = 0;
}
}
// ****************************************************************************
// Method: avtAUXFileFileFormat::PopulateDatabaseMetaData
//
// Purpose:
// This database meta-data object is like a table of contents for the
// file. By populating it, you are telling the rest of VisIt what
// information it can request from you.
//
// Programmer: miller -- generated by xml2avt
// Creation: Tue Mar 15 08:29:20 PDT 2005
//
// ****************************************************************************
void
avtAUXFileFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md)
{
AddMeshToMetaData(md, "mesh", AVT_RECTILINEAR_MESH, NULL, 1, 0, 2, 2);
AddScalarVarToMetaData(md, "fluence", "mesh", AVT_NODECENT);
}
// ****************************************************************************
// Method: avtAUXFileFileFormat::GetMesh
//
// Purpose:
// Gets the mesh associated with this file. The mesh is returned as a
// derived type of vtkDataSet (ie vtkRectilinearGrid, vtkStructuredGrid,
// vtkUnstructuredGrid, etc).
//
// Arguments:
// meshname The name of the mesh of interest. This can be ignored if
// there is only one mesh.
//
// Programmer: miller -- generated by xml2avt
// Creation: Tue Mar 15 08:29:20 PDT 2005
//
// Modifications:
// Brad Whitlock, Fri Jun 17 14:53:02 PST 2005
// Modified so it works on Windows.
//
// ****************************************************************************
vtkDataSet *
avtAUXFileFileFormat::GetMesh(const char *meshname)
{
int i, j;
char dummyChar;
int dummyInt;
vtkFloatArray *coords[3];
//
// Read the whole file's contents into a buffer
//
#if defined(_WIN32)
struct _stat statbuf;
_stat(fileName.c_str(), &statbuf);
off_t fileSize = statbuf.st_size;
#else
struct stat statbuf;
stat(fileName.c_str(), &statbuf);
off_t fileSize = statbuf.st_size;
#endif
FILE *fd = fopen(fileName.c_str(), "r");
if(fd == 0)
{
EXCEPTION1(InvalidFilesException, fileName.c_str());
}
fileBuf = new char[fileSize];
if (fread((void *)fileBuf, 1, fileSize, fd) != fileSize)
{
fclose(fd);
delete [] fileBuf;
fileBuf = 0;
EXCEPTION1(InvalidFilesException, fileName.c_str());
}
fclose(fd);
const char *p = fileBuf;
//
// Line 1: scan size information
//
if (sscanf(p, "%d %d %d %d %d %d %d \n", &sizeX, &sizeY,
&dummyInt, &dummyInt, &dummyInt, &dummyInt, &dummyInt) != 7)
{
EXCEPTION1(InvalidFilesException, fileName.c_str());
}
while (*p != '\n')
p++;
p++;
//
// Line 2: scan 'X='
//
if ((sscanf(p, "X%c\n", &dummyChar) != 1) || (dummyChar != '='))
{
EXCEPTION1(InvalidFilesException, fileName.c_str());
}
while (*p != '\n')
p++;
p++;
//
// scan X values
//
coords[0] = vtkFloatArray::New();
coords[0]->SetNumberOfTuples(sizeX);
for (i = 0; i < sizeX; i++)
{
float xVal;
if (sscanf(p, "%f", &xVal) != 1)
{
EXCEPTION1(InvalidFilesException, fileName.c_str());
}
coords[0]->SetComponent(i, 0, xVal);
while (isspace(*p))
p++;
while (!isspace(*p))
p++;
}
while (*p != '\n')
p++;
p++;
//
// Loop to scan y values
//
coords[1] = vtkFloatArray::New();
coords[1]->SetNumberOfTuples(sizeY);
fluence = vtkFloatArray::New();
fluence->SetNumberOfTuples(sizeX * sizeY);
for (i = 0; i < sizeY; i++)
{
//
// Line i'th Y entry: scan 'Y='
//
float yVal;
if (sscanf(p, " Y= %f\n", &yVal) != 1)
{
EXCEPTION1(InvalidFilesException, fileName.c_str());
}
coords[1]->SetComponent(i, 0, yVal);
while (*p != '\n')
p++;
p++;
//
// scan fluence values for this Y entry
//
for (j = 0; j < sizeX; j++)
{
float tmp;
if (sscanf(p, "%f", &tmp) != 1)
{
EXCEPTION1(InvalidFilesException, fileName.c_str());
}
fluence->SetComponent(i * sizeX + j, 0, tmp);
while (isspace(*p))
p++;
while (!isspace(*p))
p++;
}
while (*p != '\n')
p++;
p++;
}
//
// Deal with the z coordinate
//
coords[2] = vtkFloatArray::New();
coords[2]->SetNumberOfTuples(1);
coords[2]->SetComponent(0, 0, 0.0);
//
// Build rectilinear grid
//
vtkRectilinearGrid *rgrid = vtkRectilinearGrid::New();
int dims[3] = {sizeX, sizeY, 1};
rgrid->SetDimensions(dims);
rgrid->SetXCoordinates(coords[0]);
coords[0]->Delete();
rgrid->SetYCoordinates(coords[1]);
coords[1]->Delete();
rgrid->SetZCoordinates(coords[2]);
coords[2]->Delete();