Commit cf8eea2b authored by hrchilds's avatar hrchilds
Browse files

Update from February 19, 2004

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@180 18c085ea-50e0-402c-830e-de6fd14e8384
parent 5cceade5
......@@ -42,6 +42,9 @@ class avtDatabaseWriter;
// Jeremy Meredith, Wed Nov 5 10:28:29 PST 2003
// Added ability to disable plugins by default.
//
// Hank Childs, Thu Feb 19 10:01:47 PST 2004
// Added GetFilenames. Made GetDefaultExtensions not be pure virtual.
//
// ****************************************************************************
class PLUGIN_API GeneralDatabasePluginInfo
......@@ -57,7 +60,10 @@ class PLUGIN_API CommonDatabasePluginInfo : public virtual GeneralDatabasePlugin
{
public:
virtual DatabaseType GetDatabaseType() = 0;
virtual std::vector<std::string> GetDefaultExtensions() = 0;
virtual std::vector<std::string> GetDefaultExtensions()
{ std::vector<std::string> rv; return rv; };
virtual std::vector<std::string> GetFilenames()
{ std::vector<std::string> rv; return rv; };
virtual avtDatabase *SetupDatabase(const char * const *list,
int nList, int nBlock) = 0;
virtual avtDatabaseWriter *GetWriter(void) { return NULL; };
......
......@@ -8,6 +8,8 @@
#include <vector>
#include <string>
#include <visit-config.h>
#include <avtDatabase.h>
#include <avtDatabaseFactory.h>
#include <avtGenericDatabase.h>
......@@ -66,11 +68,16 @@ void CheckPermissions(const char *);
// Allow for multiple formats to support the same extension. Blew away
// outdated comments.
//
// Hank Childs, Thu Feb 19 08:00:35 PST 2004
// Allow for exact filenames in addition to default extensions.
//
// ****************************************************************************
avtDatabase *
avtDatabaseFactory::FileList(const char * const * filelist, int filelistN)
{
int i, j;
if (filelistN <= 0)
{
EXCEPTION1(InvalidFilesException, filelistN);
......@@ -98,7 +105,23 @@ avtDatabaseFactory::FileList(const char * const * filelist, int filelistN)
//
CheckPermissions(filelist[fileIndex]);
string file = filelist[fileIndex];
//
// Parse out the path and get just the filename.
//
string file_and_path = filelist[fileIndex];
const char *fap = file_and_path.c_str();
int len = strlen(fap);
int lastSlash = -1;
for (i = len-1 ; i >= 0 ; i--)
{
if (fap[i] == SLASH_CHAR)
{
lastSlash = i;
break;
}
}
int start = lastSlash+1;
string file(fap + start);
string defaultDatabaseType("Silo");
......@@ -106,14 +129,18 @@ avtDatabaseFactory::FileList(const char * const * filelist, int filelistN)
// Try each database type looking for a match to the given extensions
//
DatabasePluginManager *dbmgr = DatabasePluginManager::Instance();
for (int i=0; i<dbmgr->GetNEnabledPlugins() && rv == NULL; i++)
for (i=0; i<dbmgr->GetNEnabledPlugins() && rv == NULL; i++)
{
string id = dbmgr->GetEnabledID(i);
CommonDatabasePluginInfo *info = dbmgr->GetCommonPluginInfo(id);
bool foundMatch = false;
//
// Check to see if there is an extension that matches.
//
vector<string> extensions = info->GetDefaultExtensions();
int nextensions = extensions.size();
for (int j=0; j<nextensions && rv == NULL; j++)
for (j=0; j<nextensions; j++)
{
string ext = extensions[j];
if (ext[0] != '.')
......@@ -123,18 +150,48 @@ avtDatabaseFactory::FileList(const char * const * filelist, int filelistN)
if (file.length() >= ext.length() &&
file.substr(file.length() - ext.length()) == ext)
{
TRY
{
rv = info->SetupDatabase(filelist+fileIndex,
filelistN-fileIndex, nBlocks);
}
CATCH2(InvalidDBTypeException, e)
{
rv = NULL;
}
ENDTRY
foundMatch = true;
}
}
//
// Check to see if there is an exact name that matches.
//
vector<string> filenames = info->GetFilenames();
int nfiles = filenames.size();
for (j=0; j<nfiles; j++)
{
if (filenames[j] == file)
{
foundMatch = true;
}
}
if (foundMatch)
{
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->GetMetaData(0);
}
CATCH2(InvalidDBTypeException, e)
{
rv = NULL;
}
ENDTRY
}
}
//
......@@ -150,6 +207,14 @@ avtDatabaseFactory::FileList(const char * const * filelist, int filelistN)
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->GetMetaData(0);
}
else
{
......
......@@ -14,6 +14,7 @@
#include <Token.h>
#include <EngineExprNode.h>
#include <avtCallback.h>
#include <avtMaterial.h>
#include <avtMetaData.h>
......@@ -58,6 +59,25 @@ avtMatvfFilter::~avtMatvfFilter()
}
// ****************************************************************************
// Method: avtMatvfFilter::PreExecute
//
// Purpose:
// Reset the "issuedWarning" flag.
//
// Programmer: Hank Childs
// Creation: February 18, 2004
//
// ****************************************************************************
void
avtMatvfFilter::PreExecute(void)
{
issuedWarning = false;
avtSingleInputExpressionFilter::PreExecute();
}
// ****************************************************************************
// Method: avtMatvfFilter::DeriveVariable
//
......@@ -82,6 +102,10 @@ avtMatvfFilter::~avtMatvfFilter()
// Jeremy Meredith, Mon Sep 29 12:13:04 PDT 2003
// Added support for integer material indices.
//
// Hank Childs, Wed Feb 18 09:26:33 PST 2004
// Issue a warning if we can't match up an argument with a material. Also
// fixed indexing bug.
//
// ****************************************************************************
vtkDataArray *
......@@ -119,21 +143,22 @@ avtMatvfFilter::DeriveVariable(vtkDataSet *in_ds)
//
// Try to match up the materials in the avtMaterial object with the
// materials requested by the users. Some of the materials requested
// by the user may not be there. This is probably okay -- there are
// tricks played by the avtMaterial object where it throws out
// materials that are not used in that domain.
// materials requested by the users.
//
int nmats = mat->GetNMaterials();
std::vector<bool> useMat(nmats, false);
std::vector<bool> matchedMatName(matNames.size(), false);
std::vector<bool> matchedMatIndex(matIndices.size(), false);
for (i = 0 ; i < nmats ; i++)
{
std::string currentMat = mat->GetMaterials()[i];
for (j = 0 ; j < matNames.size() ; j++)
{
if (currentMat == matNames[j])
{
useMat[i] = true;
matchedMatName[j] = true;
}
}
for (j = 0 ; j < matIndices.size() ; j++)
{
......@@ -146,6 +171,94 @@ avtMatvfFilter::DeriveVariable(vtkDataSet *in_ds)
currentMat.substr(0,matname.length() + 1) == (matname + " ")))
{
useMat[i] = true;
matchedMatIndex[j] = true;
}
}
}
//
// Make sure that we found every material requested. If not, issue
// a warning.
//
for (i = 0 ; i < matNames.size() ; i++)
{
if (!matchedMatName[i])
{
const std::vector<std::string> &all_mats =
mat->GetCompleteMaterialList();
bool matched = false;
for (j = 0 ; j < all_mats.size() ; j++)
{
if (matNames[i] == all_mats[j])
{
matched = true;
break;
}
}
if (!matched)
{
if (!issuedWarning)
{
char warningString[100000];
sprintf(warningString, "Could not match up \"%s\" with "
"any materials when doing the matvf expression."
"\nList of valid materials is: ",
matNames[i].c_str());
char *tmp = warningString + strlen(warningString);
for (j = 0 ; j < all_mats.size() ; j++)
{
if (j < (all_mats.size()-1))
sprintf(tmp, "\"%s\", ", all_mats[j].c_str());
else
sprintf(tmp, "\"%s\".", all_mats[j].c_str());
tmp += strlen(tmp);
}
avtCallback::IssueWarning(warningString);
issuedWarning = true;
}
}
}
}
for (i = 0 ; i < matIndices.size() ; i++)
{
char tmp[256];
sprintf(tmp, "%d", matIndices[i]);
std::string matname(tmp);
if (!matchedMatIndex[i])
{
const std::vector<std::string> &all_mats =
mat->GetCompleteMaterialList();
bool matched = false;
for (j = 0 ; j < all_mats.size() ; j++)
{
if (matname == all_mats[j])
{
matched = true;
break;
}
}
if (!matched)
{
if (!issuedWarning)
{
char warningString[100000];
sprintf(warningString, "Could not match up \"%s\" with "
"any materials when doing the matvf expression."
"\nList of valid materials is: ",
matname.c_str());
char *tmp = warningString + strlen(warningString);
for (j = 0 ; j < all_mats.size() ; j++)
{
if (j < (all_mats.size()-1))
sprintf(tmp, "\"%s\", ", all_mats[j].c_str());
else
sprintf(tmp, "\"%s\".", all_mats[j].c_str());
tmp += strlen(tmp);
}
avtCallback::IssueWarning(warningString);
issuedWarning = true;
}
}
}
}
......@@ -168,11 +281,23 @@ avtMatvfFilter::DeriveVariable(vtkDataSet *in_ds)
else
{
vf = 0.;
int start = -matlist[i]-1;
for (j = start ; j < mix_next[start] ; j++)
int current = -matlist[i]-1;
// iterations < 1000 just to prevent infinite loops if someone
// set this structure up wrong.
int iterations = 0;
bool stillMoreMats = true;
while (stillMoreMats && (iterations < 1000))
{
if (useMat[mixmat[j]])
vf += mixvf[j];
if (useMat[mixmat[current]])
{
vf += mixvf[current];
}
if (mix_next[current] == 0)
stillMoreMats = false;
else
current = mix_next[current]-1;
iterations++;
}
}
vf_for_orig_cells->SetTuple1(i, vf);
......
......@@ -36,6 +36,9 @@ class ConstExpr;
// Moved inlined constructor and destructor definitions to .C files
// because certain compilers have problems with them.
//
// Hank Childs, Wed Feb 18 09:15:23 PST 2004
// Issue a warning if we encounter a bad material name.
//
// ****************************************************************************
class EXPRESSION_API avtMatvfFilter : public avtSingleInputExpressionFilter
......@@ -50,11 +53,14 @@ class EXPRESSION_API avtMatvfFilter : public avtSingleInputExpressionFilter
virtual void ProcessArguments(ArgsExpr*, ExprPipelineState *);
protected:
bool issuedWarning;
virtual avtPipelineSpecification_p
PerformRestriction(avtPipelineSpecification_p);
virtual vtkDataArray *DeriveVariable(vtkDataSet *);
virtual bool IsPointVariable(void) { return false; };
virtual void PreExecute(void);
void AddMaterial(ConstExpr *);
std::vector<std::string> matNames;
......
......@@ -69,6 +69,9 @@ using namespace std;
// Do a better job of checking for bad materials and also issue a warning
// when they are encountered.
//
// Hank Childs, Wed Feb 18 09:36:38 PST 2004
// Added the "all materials" list to the Initialize call.
//
// ****************************************************************************
avtMaterial::avtMaterial(int nMats, const int *mats, char **names,
......@@ -284,8 +287,8 @@ avtMaterial::avtMaterial(int nMats, const int *mats, char **names,
{
nActualMats = nMats+1;
}
Initialize(nActualMats, matnames, matUsed, nzon, ndims, dims, major_order,
newml, mixl, newmixm, mixn, mixz, mixv);
Initialize(nActualMats, matnames, matnames, matUsed, nzon, ndims, dims,
major_order, newml, mixl, newmixm, mixn, mixz, mixv);
delete[] newml;
delete[] newmixm;
......@@ -325,6 +328,9 @@ avtMaterial::avtMaterial(int nMats, const int *mats, char **names,
// Hank Childs, Fri Dec 20 12:33:45 PST 2002
// Account for phoney materials.
//
// Hank Childs, Wed Feb 18 09:36:38 PST 2004
// Added the "all materials" list to the Initialize call.
//
// ****************************************************************************
avtMaterial::avtMaterial(int nMats, const vector<string> &mats, int nzon,
......@@ -347,8 +353,8 @@ avtMaterial::avtMaterial(int nMats, const vector<string> &mats, int nzon,
int nActualMats = (matUsed[nMats] ? nMats+1 : nMats);
Initialize(nActualMats, mats, matUsed, nzon, 1, &nzon, 0, ml, mixl, mixm,
mixn, mixz, mixv);
Initialize(nActualMats, mats, mats, matUsed, nzon, 1, &nzon, 0, ml, mixl,
mixm, mixn, mixz, mixv);
}
......@@ -366,6 +372,9 @@ avtMaterial::avtMaterial(int nMats, const vector<string> &mats, int nzon,
//
// Modifications:
//
// Hank Childs, Wed Feb 18 09:36:38 PST 2004
// Added the "all materials" list to the Initialize call.
//
// ****************************************************************************
avtMaterial::avtMaterial(const avtMaterial *mat,
......@@ -378,7 +387,7 @@ avtMaterial::avtMaterial(const avtMaterial *mat,
if (mat->nMaterials == nUsedMats)
{
// no packing can occur
Initialize(mat->nMaterials, mat->materials, matUsed,
Initialize(mat->nMaterials, mat->materials, mat->materials, matUsed,
mat->nZones, 1, &mat->nZones, 0,
mat->matlist, mat->mixlen, mat->mix_mat,
mat->mix_next, mat->mix_zone, mat->mix_vf);
......@@ -407,7 +416,7 @@ avtMaterial::avtMaterial(const avtMaterial *mat,
for (i=0; i<nUsedMats; i++)
materials[i] = mat->materials[mapUsedMatToMat[i]];
Initialize(nUsedMats, materials, matUsed,
Initialize(nUsedMats, materials, mat->materials, matUsed,
mat->nZones, 1, &mat->nZones, 0,
matlist, mat->mixlen, mix_mat,
mat->mix_next, mat->mix_zone, mat->mix_vf);
......@@ -504,6 +513,8 @@ avtMaterial::Destruct(void *p)
// Arguments:
// nMats The number of material in matnames.
// matnames The names of the materials.
// all_matnames The names of all the materials, including those discarded
// because they weren't present in this domain.
// nzon The number of zones in ml.
// ndims The number of entries in dims.
// dims The number of material entries in each direction.
......@@ -537,10 +548,14 @@ avtMaterial::Destruct(void *p)
// Hank Childs, Mon Apr 7 09:26:23 PDT 2003
// Do not assume mixz is non-NULL.
//
// Hank Childs, Wed Feb 18 09:36:38 PST 2004
// Add an argument for a list of all materials.
//
// ****************************************************************************
void
avtMaterial::Initialize(int nMats, const vector<string> &matnames,
const vector<string> &all_matnames,
const vector<bool> &matUsed, int nzon,
int ndims, const int *dims, int major_order,
const int *ml, int mixl, const int *mixm,
......@@ -562,6 +577,7 @@ avtMaterial::Initialize(int nMats, const vector<string> &matnames,
nMaterials = nMats;
materials = matnames;
all_materials = all_matnames;
nZones = nzon;
matlist = new int[nZones];
if (ndims <= 1 || major_order == 0)
......
......@@ -64,6 +64,9 @@ struct CellMatInfo
// Jeremy Meredith, Fri Aug 22 10:33:10 PDT 2003
// Added another helper function.
//
// Hank Childs, Wed Feb 18 09:30:12 PST 2004
// Keep around the original material names.
//
// ****************************************************************************
class PIPELINE_API avtMaterial
......@@ -80,12 +83,12 @@ class PIPELINE_API avtMaterial
const int *mixz,
const float *mixv,
const char *domain = NULL);
avtMaterial(int, const
std::vector<std::string>&,
int, const int *, int,
const int *, const int *,
const int *,
const float *);
avtMaterial(int,
const std::vector<std::string>&,
int, const int *, int,
const int *, const int *,
const int *,
const float *);
avtMaterial *CreatePackedMaterial() const;
......@@ -95,6 +98,8 @@ class PIPELINE_API avtMaterial
int GetNZones(void) { return nZones; };
int GetNMaterials(void) { return nMaterials;};
const std::vector<std::string> &GetMaterials(void) { return materials; };
const std::vector<std::string> &GetCompleteMaterialList(void)
{ return all_materials; };
const int *GetMatlist(void) { return matlist; };
int GetMixlen(void) { return mixlen; };
const int *GetMixMat(void) { return mix_mat; };
......@@ -115,6 +120,7 @@ class PIPELINE_API avtMaterial
protected:
int nMaterials;
std::vector<std::string> materials;
std::vector<std::string> all_materials;
int nZones;
int *matlist;
int mixlen;
......@@ -132,6 +138,7 @@ class PIPELINE_API avtMaterial
std::vector<int>);
void Initialize(int,
const std::vector<std::string> &,
const std::vector<std::string> &,
const std::vector<bool>&,
int, int, const int *, int,
......
......@@ -120,19 +120,25 @@ VisWinRenderingWithWindow::GetWindowSize(int &w, int &h)
// Brad Whitlock, Thu Sep 4 10:43:02 PDT 2003
// I made the window hide itself on MacOS X.
//
// Eric Brugger, Thu Feb 19 11:14:17 PST 2004
// I made the routine a noop if the window hasn't been realized.
//
// ****************************************************************************
void
VisWinRenderingWithWindow::Iconify(void)
{
if (realized)
{
#if defined(Q_WS_WIN) || defined(Q_WS_MACX)
renWin->hide();
renWin->hide();
#else
if (! renWin->isMinimized())
{
renWin->showMinimized();
}
if (! renWin->isMinimized())
{
renWin->showMinimized();
}
#endif
}
}
......@@ -146,16 +152,21 @@ VisWinRenderingWithWindow::Iconify(void)
// Creation: Tue Apr 16 12:45:50 PDT 2002
//
// Modifications:
//
// Hank Childs, Fri Apr 19 09:21:46 PDT 2002
// Moved from base class.
//
// Eric Brugger, Thu Feb 19 11:14:17 PST 2004
// I made the routine a noop if the window hasn't been realized.
//
// ****************************************************************************
void
VisWinRenderingWithWindow::Show()
{
renWin->show();
if (realized)
{
renWin->show();
}
}
// ****************************************************************************
......@@ -168,12 +179,17 @@ VisWinRenderingWithWindow::Show()
// Creation: Mon May 20 13:34:07 PDT 2002
//
// Modifications:
// Eric Brugger, Thu Feb 19 11:14:17 PST 2004
// I made the routine a noop if the window hasn't been realized.
//
// ****************************************************************************
void
VisWinRenderingWithWindow::Raise()
{
renWin->raise();
if (realized)
{
renWin->raise();
}
}