Commit 97570a96 authored by hrchilds's avatar hrchilds

Update from March 22, 2004

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@202 18c085ea-50e0-402c-830e-de6fd14e8384
parent 1627a5da
......@@ -54,6 +54,8 @@ void CheckPermissions(const char *);
// Arguments:
// filelist A list of files.
// filelistN The number of files in `filelist'.
// timestep The timestep to open to.
// format The format to try first.
//
// Returns: An avtDatabase object that is correctly typed for the filelist.
//
......@@ -83,11 +85,14 @@ void CheckPermissions(const char *);
// Mark C. Miller, Tue Mar 16 09:38:19 PST 2004
// Just prior to calls to GetMetaData, added calls to ActivateTimestep.
//
// Hank Childs, Mon Mar 22 09:43:33 PST 2004
// Added the ability for a format to be specified.
//
// ****************************************************************************
avtDatabase *
avtDatabaseFactory::FileList(const char * const * filelist, int filelistN,
int timestep)
int timestep, const char *format)
{
int i, j;
......@@ -136,12 +141,37 @@ avtDatabaseFactory::FileList(const char * const * filelist, int filelistN,
int start = lastSlash+1;
string file(fap + start);
string defaultDatabaseType("Silo");
DatabasePluginManager *dbmgr = DatabasePluginManager::Instance();
//
// If we were specifically told which format to use, then try that now.
//
if (format != NULL)
{
int formatindex = dbmgr->GetAllIndex(format);
if (formatindex != -1)
{
string formatid = dbmgr->GetAllID(formatindex);
CommonDatabasePluginInfo *info =
dbmgr->GetCommonPluginInfo(formatid);
rv = SetupDatabase(info, filelist, filelistN, timestep, fileIndex,
nBlocks);
}
if (formatindex < 0 || rv == NULL)
{
char msg[1000];
sprintf(msg,
"The DB factory was told to open a file of type %s, but "
"that format is not a match for file %s",
format, filelist[0]);
EXCEPTION1(ImproperUseException, msg);
}
}
//
// Try each database type looking for a match to the given extensions
//
DatabasePluginManager *dbmgr = DatabasePluginManager::Instance();
for (i=0; i<dbmgr->GetNEnabledPlugins() && rv == NULL; i++)
{
string id = dbmgr->GetEnabledID(i);
......@@ -184,24 +214,8 @@ avtDatabaseFactory::FileList(const char * const * filelist, int filelistN,
{
TRY
{
rv = info->SetupDatabase(filelist+fileIndex,
filelistN-fileIndex, nBlocks);
//
// By policy, the plugin doesn't do much work to set up the
// database. So there is a chance that a format did not
// throw an exception, but is the wrong type. To make
// sure we have the correct plugin, force it to read
// in its metadata. This does not cause extra work,
// because the metadata is cached and we are going to
// ask for it in a bit anyway.
//
if (rv != NULL)
{
rv->ActivateTimestep(timestep);
avtDatabaseMetaData *md = rv->GetMetaData(timestep);
md->SetFileFormat(info->GetID());
}
rv = SetupDatabase(info, filelist, filelistN, timestep,
fileIndex, nBlocks);
}
CATCH2(InvalidDBTypeException, e)
{
......@@ -214,6 +228,7 @@ avtDatabaseFactory::FileList(const char * const * filelist, int filelistN,
//
// If no file extension match, then we default to the given database type
//
string defaultDatabaseType("Silo");
if (rv == NULL)
{
int defaultindex = dbmgr->GetAllIndexFromName(defaultDatabaseType);
......@@ -222,20 +237,8 @@ avtDatabaseFactory::FileList(const char * const * filelist, int filelistN,
string defaultid = dbmgr->GetAllID(defaultindex);
CommonDatabasePluginInfo *info =
dbmgr->GetCommonPluginInfo(defaultid);
rv = info->SetupDatabase(filelist+fileIndex, filelistN-fileIndex,
nBlocks);
//
// If we match an extension or an exact filename, we call get the
// database metadata to make sure we have the right plugin. We
// make the same call here to be consistent.
//
if (rv != NULL)
{
rv->ActivateTimestep(timestep);
avtDatabaseMetaData *md = rv->GetMetaData(timestep);
md->SetFileFormat(info->GetID());
}
rv = SetupDatabase(info, filelist, filelistN, timestep, fileIndex,
nBlocks);
}
else
{
......@@ -251,6 +254,59 @@ avtDatabaseFactory::FileList(const char * const * filelist, int filelistN,
}
// ****************************************************************************
// Method: avtDatabaseFactory::SetupDatabase
//
// Purpose:
// Setups the avtDatabase. There are several spots where we want to do
// this, so this provides a "single point of source" that all routines
// can call.
//
// Arguments:
// info The CommonDatabasePluginInfo that can instantiate a DB.
// filelist A list of files.
// filelistN The number of files in filelist.
// timestep The current timestep.
//
// Returns: A database. This may very well be NULL.
//
// Notes: If the format type is not correct, there is a strong
// possibility that the exception InvalidDBTypeException
// will be thrown.
//
// Programmer: Hank Childs
// Creation: March 22, 2004
//
// ****************************************************************************
avtDatabase *
avtDatabaseFactory::SetupDatabase(CommonDatabasePluginInfo *info,
const char * const *filelist, int filelistN,
int timestep, int fileIndex, int nBlocks)
{
avtDatabase *rv = info->SetupDatabase(filelist+fileIndex,
filelistN-fileIndex, nBlocks);
//
// By policy, the plugin doesn't do much work to set up the
// database. So there is a chance that a format did not
// throw an exception, but is the wrong type. To make
// sure we have the correct plugin, force it to read
// in its metadata. This does not cause extra work,
// because the metadata is cached and we are going to
// ask for it in a bit anyway.
//
if (rv != NULL)
{
rv->ActivateTimestep(timestep);
avtDatabaseMetaData *md = rv->GetMetaData(timestep);
md->SetFileFormat(info->GetID());
}
return rv;
}
// ****************************************************************************
// Method: avtDatabaseFactory::VisitFile
//
......@@ -259,6 +315,8 @@ avtDatabaseFactory::FileList(const char * const * filelist, int filelistN,
//
// Arguments:
// visitFile The name of the .visit file.
// timestep The timestep to open at.
// format The file format type (optional).
//
// Returns: An avtDatabase object that is correctly typed for the .visit
// file.
......@@ -286,10 +344,14 @@ avtDatabaseFactory::FileList(const char * const * filelist, int filelistN,
// Hank Childs, Mon Mar 1 08:56:52 PST 2004
// Allow for the time to be specified.
//
// Hank Childs, Mon Mar 22 11:01:05 PST 2004
// Added format argument.
//
// ****************************************************************************
avtDatabase *
avtDatabaseFactory::VisitFile(const char *visitFile, int timestep)
avtDatabaseFactory::VisitFile(const char *visitFile, int timestep,
const char *format)
{
//
// Make sure we can read the file before we proceed.
......@@ -343,7 +405,7 @@ avtDatabaseFactory::VisitFile(const char *visitFile, int timestep)
//
// Create a database using the list of files.
//
avtDatabase *rv = FileList(reallist, listcount, timestep);
avtDatabase *rv = FileList(reallist, listcount, timestep, format);
//
// Clean up memory
......
......@@ -4,10 +4,14 @@
#ifndef AVT_DATABASE_FACTORY_H
#define AVT_DATABASE_FACTORY_H
#include <database_exports.h>
#include <stdlib.h> // For NULL
class avtDatabase;
class CommonDatabasePluginInfo;
// ****************************************************************************
......@@ -22,37 +26,30 @@ class avtDatabase;
//
// Modifications:
//
// Hank Childs, Fri Mar 2 11:24:48 PST 2001
// Reflected changes in database and removed SiloObj. Added VTK.
//
// Hank Childs, Wed Feb 13 16:36:58 PST 2002
// Added better support for multiple blocks with STSD file formats.
//
// Hank Childs, Fri Feb 15 17:28:01 PST 2002
// Add support for time-varying Exodus files.
//
// Hank Childs, Fri May 3 16:04:43 PDT 2002
// Add support for PLOT3D.
//
// Hank Childs, Fri May 24 16:32:28 PDT 2002
// Add support for STL.
//
// Hank Childs, Tue May 28 14:53:04 PDT 2002
// Add support for curve files.
//
// Jeremy Meredith, Tue Aug 27 15:08:29 PDT 2002
// Removed all formats and placed them in database plugins.
//
// Hank Childs, Mon Mar 1 08:48:26 PST 2004
// Added the timestep as an argument.
//
// Hank Childs, Mon Mar 22 09:41:34 PST 2004
// Added string specifying format type. Also removed outdated comments
// from the era when the DB factory knew about specific formats.
//
// ****************************************************************************
class DATABASE_API avtDatabaseFactory
{
public:
static avtDatabase *FileList(const char * const *, int, int);
static avtDatabase *VisitFile(const char *, int);
static avtDatabase *FileList(const char * const *, int, int,
const char * = NULL);
static avtDatabase *VisitFile(const char *, int,
const char * = NULL);
protected:
static avtDatabase *SetupDatabase(CommonDatabasePluginInfo *,
const char * const *, int,
int, int, int);
};
......
......@@ -7,7 +7,8 @@
#include <pipeline_exports.h>
class ostream;
#include <iostream.h>
class avtDataObjectString;
class avtDataObjectWriter;
class vtkMatrix4x4;
......
<?xml version="1.0"?>
<Plugin name="KullLite" label="KullLite" type="database" dbtype="STMD" version="1.0">
<Extensions> pdb </Extensions>
<Extensions> pdb mkf </Extensions>
<CXXFLAGS> $(PDB_FLAGS) </CXXFLAGS>
<LIBS> $(PDB_LIBS) </LIBS>
</Plugin>
......@@ -11,7 +11,7 @@
// Returns the type of a KullLite database.
//
// Programmer: childs -- generated by xml2info
// Creation: Mon Oct 14 09:53:07 PDT 2002
// Creation: Mon Mar 22 09:17:37 PDT 2004
//
// ****************************************************************************
DatabaseType
......@@ -27,7 +27,7 @@ KullLiteCommonPluginInfo::GetDatabaseType()
// Returns the default extensions for a KullLite database.
//
// Programmer: childs -- generated by xml2info
// Creation: Mon Oct 14 09:53:07 PDT 2002
// Creation: Mon Mar 22 09:17:37 PDT 2004
//
// ****************************************************************************
std::vector<std::string>
......@@ -35,10 +35,29 @@ KullLiteCommonPluginInfo::GetDefaultExtensions()
{
std::vector<std::string> defaultExtensions;
defaultExtensions.push_back("pdb");
defaultExtensions.push_back("mkf");
return defaultExtensions;
}
// ****************************************************************************
// Method: KullLiteCommonPluginInfo::GetWriter
//
// Purpose:
// Sets up a KullLite writer.
//
// Returns: A KullLite writer.
//
// Programmer: childs -- generated by xml2info
// Creation: Mon Mar 22 09:17:37 PDT 2004
//
// ****************************************************************************
avtDatabaseWriter *
KullLiteCommonPluginInfo::GetWriter(void)
{
return NULL;
}
// ****************************************************************************
// Method: KullLiteCommonPluginInfo::SetUpKullLiteDatabase
//
......@@ -53,7 +72,7 @@ KullLiteCommonPluginInfo::GetDefaultExtensions()
// Returns: A KullLite database from list.
//
// Programmer: childs -- generated by xml2info
// Creation: Mon Oct 14 09:53:07 PDT 2002
// Creation: Mon Mar 22 09:17:37 PDT 2004
//
// Modifications:
// Brad Whitlock, Thu Oct 9 14:25:58 PST 2003
......
......@@ -15,7 +15,7 @@
// Return a new GeneralPluginInfo for the KullLite database.
//
// Programmer: childs -- generated by xml2info
// Creation: Mon Oct 14 09:53:07 PDT 2002
// Creation: Mon Mar 22 09:19:36 PDT 2004
//
// ****************************************************************************
extern "C" GeneralDatabasePluginInfo* GetGeneralInfo()
......@@ -32,7 +32,7 @@ extern "C" GeneralDatabasePluginInfo* GetGeneralInfo()
// Returns: A pointer to the name of the database plugin.
//
// Programmer: childs -- generated by xml2info
// Creation: Mon Oct 14 09:53:07 PDT 2002
// Creation: Mon Mar 22 09:19:36 PDT 2004
//
// ****************************************************************************
......@@ -51,7 +51,7 @@ KullLiteGeneralPluginInfo::GetName() const
// Returns: A pointer to the version of the database plugin.
//
// Programmer: childs -- generated by xml2info
// Creation: Mon Oct 14 09:53:07 PDT 2002
// Creation: Mon Mar 22 09:19:36 PDT 2004
//
// ****************************************************************************
......@@ -70,7 +70,7 @@ KullLiteGeneralPluginInfo::GetVersion() const
// Returns: A pointer to the id of the database plugin.
//
// Programmer: childs -- generated by xml2info
// Creation: Mon Oct 14 09:53:07 PDT 2002
// Creation: Mon Mar 22 09:19:36 PDT 2004
//
// ****************************************************************************
......@@ -79,3 +79,21 @@ KullLiteGeneralPluginInfo::GetID() const
{
return "KullLite_1.0";
}
// ****************************************************************************
// Method: KullLiteGeneralPluginInfo::EnabledByDefault
//
// Purpose:
// Return true if this plugin should be enabled by default; false otherwise.
//
// Returns: true/false
//
// Programmer: childs -- generated by xml2info
// Creation: Mon Mar 22 09:19:36 PDT 2004
//
// ****************************************************************************
bool
KullLiteGeneralPluginInfo::EnabledByDefault() const
{
return true;
}
......@@ -8,6 +8,7 @@
#include <database_plugin_exports.h>
class avtDatabase;
class avtDatabaseWriter;
// ****************************************************************************
// Class: KullLiteDatabasePluginInfo
......@@ -18,7 +19,7 @@ class avtDatabase;
// components of VisIt.
//
// Programmer: childs -- generated by xml2info
// Creation: Mon Oct 14 09:53:07 PDT 2002
// Creation: Mon Mar 22 09:18:32 PDT 2004
//
// Modifications:
//
......@@ -30,6 +31,7 @@ class KullLiteGeneralPluginInfo : public virtual GeneralDatabasePluginInfo
virtual char *GetName() const;
virtual char *GetVersion() const;
virtual char *GetID() const;
virtual bool EnabledByDefault() const;
};
class KullLiteCommonPluginInfo : public virtual CommonDatabasePluginInfo, public virtual KullLiteGeneralPluginInfo
......@@ -39,6 +41,7 @@ class KullLiteCommonPluginInfo : public virtual CommonDatabasePluginInfo, public
virtual std::vector<std::string> GetDefaultExtensions();
virtual avtDatabase *SetupDatabase(const char * const *list,
int nList, int nBlock);
virtual avtDatabaseWriter *GetWriter(void);
};
class KullLiteMDServerPluginInfo : public virtual MDServerDatabasePluginInfo, public virtual KullLiteCommonPluginInfo
......
......@@ -110,7 +110,7 @@ MILI=Mili
PDB=KullLite PDB
SAF=SAF
SAMPLES=Rect Hex
REQUIRED=ANALYZE BOV Curve2D EnSight Lines PLOT2D PLOT3D Point3D STL Silo Spheral VTK WavefrontOBJ
REQUIRED=ANALYZE BOV Curve2D EnSight Lines PLOT2D PLOT3D Point3D STL Silo Spheral VTK WavefrontOBJ Vista
OPTIONAL=
......
#include <StringHelpers.h>
#include <stdlib.h>
#include <string>
#include <vector>
using std::string;
using std::vector;
static string IGNORE_CHARS = "`~!@#$%^&*()-_=+{[}]|\\:;\"'<,>.?/0123456789";
string RelevantString(string inStr)
{
string outStr;
string::size_type n;
n = inStr.find_first_not_of(IGNORE_CHARS);
while (n != string::npos)
{
outStr += inStr[n];
n = inStr.find_first_not_of(IGNORE_CHARS, n+1);
}
return outStr;
}
static int CompareRelevantStrings(const void *arg1, const void *arg2)
{
string str1 = RelevantString(*((char **) arg1));
string str2 = RelevantString(*((char **) arg2));
return strcmp(str1.c_str(),str2.c_str());
}
void
StringHelpers::GroupStrings(vector<string> stringList,
vector<vector<string> > &stringGroups,
vector<string> &groupNames)
{
int i;
int nStrings = stringList.size();
// first, we need to sort the strings. Well, we don't really sort the
// strings. Instead we sort an array of pointers to the strings. We
// build that array here.
const char **stringPtrs = new const char*[nStrings];
for (i = 0; i < nStrings; i++)
stringPtrs[i] = stringList[i].c_str();
// now, call qsort for this array of string pointers
qsort(stringPtrs, nStrings, sizeof(char *), CompareRelevantStrings);
// now, scan the sorted list of strings for value transitions
// in first three chars. Each such transition indicates the end of
// one group and the beginning of the next. The 'first 3' criterion
// is arbitrary but seems to work well.
string lastVal;
lastVal += stringPtrs[0][0];
lastVal += stringPtrs[0][1];
lastVal += stringPtrs[0][2];
groupNames.push_back(RelevantString(stringPtrs[0]));
vector<string> curGroup;
curGroup.push_back(stringPtrs[0]);
for (i = 1; i < nStrings; i++)
{
string thisVal;
thisVal += stringPtrs[i][0];
thisVal += stringPtrs[i][1];
thisVal += stringPtrs[i][2];
if (thisVal != lastVal)
{
lastVal = thisVal;
groupNames.push_back(RelevantString(stringPtrs[i]));
stringGroups.push_back(curGroup);
curGroup.clear();
curGroup.push_back(stringPtrs[i]);
}
else
{
curGroup.push_back(stringPtrs[i]);
}
}
stringGroups.push_back(curGroup);
delete [] stringPtrs;
}
// ************************************************************************* //
// StringHelpers.h //
// ************************************************************************* //
#ifndef STRINGHELPERS_H
#define STRINGHELPERS_H
#include <string>
#include <vector>
using std::string;
using std::vector;
namespace StringHelpers
{
void GroupStrings(vector<string> stringList,
vector<vector<string> > &stringGroups,
vector<string> &groupNames);
}
#endif
This diff is collapsed.
<?xml version="1.0"?>
<Plugin name="Vista" type="database" label="Vista" version="1.0" dbtype="STMD">
<Extensions> vista </Extensions>
<Files components="E,M">avtVistaFileFormat.C StringHelpers.C</Files>
<CXXFLAGS> $(SILO_INCLUDE) $(HDF5_INCLUDE) </CXXFLAGS>
<LIBS> $(SILO_LIB) $(HDF5_LIB) </LIBS>
</Plugin>
#include <VistaPluginInfo.h>
#include <avtVistaFileFormat.h>
#include <avtSTMDFileFormatInterface.h>
#include <avtGenericDatabase.h>
// ****************************************************************************
// Method: VistaCommonPluginInfo::GetDatabaseType
//
// Purpose:
// Returns the type of a Vista database.
//
// Programmer: miller -- generated by xml2info
// Creation: Tue Feb 17 19:19:06 PST 2004
//
// ****************************************************************************
DatabaseType
VistaCommonPluginInfo::GetDatabaseType()
{
return DB_TYPE_STMD;
}
// ****************************************************************************
// Method: VistaCommonPluginInfo::GetDefaultExtensions
//
// Purpose:
// Returns the default extensions for a Vista database.
//
// Programmer: miller -- generated by xml2info
// Creation: Tue Feb 17 19:19:06 PST 2004
//
// ****************************************************************************
std::vector<std::string>
VistaCommonPluginInfo::GetDefaultExtensions()
{
std::vector<std::string> defaultExtensions;
defaultExtensions.push_back("vista");
return defaultExtensions;
}
// ****************************************************************************
// Method: VistaCommonPluginInfo::GetWriter
//
// Purpose:
// Sets up a Vista writer.
//
// Returns: A Vista writer.
//
// Programmer: miller -- generated by xml2info
// Creation: Tue Feb 17 19:19:06 PST 2004
//
// ****************************************************************************
avtDatabaseWriter *
VistaCommonPluginInfo::GetWriter(void)
{
return NULL;
}
// ****************************************************************************
// Method: VistaCommonPluginInfo::SetUpVistaDatabase
//
// Purpose:
// Sets up a Vista 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 Vista database from list.
//
// Programmer: miller -- generated by xml2info
// Creation: Tue Feb 17 19:19:06 PST 2004
//
// ****************************************************************************
avtDatabase *
VistaCommonPluginInfo::SetupDatabase(const char *const *list,
int nList, int nBlock)
{
avtSTMDFileFormat **ffl = new avtSTMDFileFormat*[nList];
for (int i = 0 ; i < nList ; i++)
{
ffl[i] = new avtVistaFileFormat(list[i]);
}
avtSTMDFileFormatInterface *inter
= new avtSTMDFileFormatInterface(ffl, nList);
return new avtGenericDatabase(inter);
}
#include <VistaPluginInfo.h>
#if defined(__APPLE__)
#define GetEngineInfo Vista_GetEngineInfo
#endif
// ****************************************************************************
// Function: GetEngineInfo
//
// Purpose:
// Return a new EnginePluginInfo for the Vista database.
//
// Programmer: miller -- generated by xml2info
// Creation: Tue Feb 17 19:19:06 PST 2004
//
// ****************************************************************************
extern "C" EngineDatabasePluginInfo* GetEngineInfo()
{
return new VistaEnginePluginInfo;
}
// this makes compilers happy... remove if we ever have functions here
void VistaEnginePluginInfo::dummy()
{
}
#include <VistaPluginInfo.h>
#if defined(__APPLE__)
#define GetMDServerInfo Vista_GetMDServerInfo
#endif
// ****************************************************************************
// Function: GetMDServerInfo
//
// Purpose:
// Return a new MDServerPluginInfo for the Vista database.
//
// Programmer: miller -- generated by xml2info
// Creation: Tue Feb 17 19:19:06 PST 2004
//
// ****************************************************************************
extern "C" MDServerDatabasePluginInfo* GetMDServerInfo()
{
return new VistaMDServerPluginInfo;
}
// this makes compilers happy... remove if we ever have functions here
void VistaMDServerPluginInfo::dummy()
{
}
// ************************************************************************* //
// File: VistaPluginInfo.C
// ************************************************************************* //