Updates will be applied April 15th at 12pm EDT (UTC-0400). GitLab could be a little slow between 12 - 12:45pm EDT.

Commit a0473940 authored by hrchilds's avatar hrchilds

Update from January 12, 2007

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@794 18c085ea-50e0-402c-830e-de6fd14e8384
parent 8e0d6d6a
......@@ -74,13 +74,100 @@ InvalidFilesException::InvalidFilesException(int numfiles)
// Brad Whitlock, Thu Feb 7 11:45:26 PDT 2002
// Added a little to the error message.
//
// Hank Childs, Fri Jan 12 09:08:30 PST 2007
// Remove reference to database, since that is just confusing the issue
// for users.
//
// ****************************************************************************
InvalidFilesException::InvalidFilesException(const char *filename)
{
char str[1024];
sprintf(str, "The database had an error opening %s. It may be an "
"invalid file.", filename);
sprintf(str, "There was an error opening %s. It may be an invalid file.",
filename);
msg = str;
}
// ****************************************************************************
// Method: InvalidFilesException constructor
//
// Arguments:
// filename The name of an invalid file.
// plugins A vector of strings of the plugin types used.
//
// Programmer: Hank Childs
// Creation: January 11, 2007
//
// ****************************************************************************
InvalidFilesException::InvalidFilesException(const char *filename,
std::vector<std::string> &plugins)
{
char str[1024];
sprintf(str, "There was an error opening %s. It may be an "
"invalid file. VisIt tried using the following file format "
"readers to open the file: ", filename);
for (int i = 0 ; i < plugins.size() ; i++)
{
if (i != plugins.size()-1)
sprintf(strlen(str)+str, "%s, ", plugins[i].c_str());
else
sprintf(strlen(str)+str, "%s", plugins[i].c_str());
}
if (plugins.size() == 0)
{
sprintf(strlen(str)+str, "<No suitable plugins were identified>");
}
msg = str;
}
// ****************************************************************************
// Method: InvalidFilesException constructor
//
// Arguments:
// filename The name of an invalid file.
// plugins A vector of strings of the plugin types used.
// msg The message from opening the file.
//
// Programmer: Hank Childs
// Creation: January 12, 2007
//
// ****************************************************************************
InvalidFilesException::InvalidFilesException(const char *filename,
std::vector<std::string> &plugins,
const char *msg2)
{
char str[1024];
sprintf(str, "There was an error opening %s. It may be an "
"invalid file. VisIt tried using the following file format "
"readers to open the file: ", filename);
for (int i = 0 ; i < plugins.size() ; i++)
{
if (i != plugins.size()-1)
sprintf(strlen(str)+str, "%s, ", plugins[i].c_str());
else
sprintf(strlen(str)+str, "%s", plugins[i].c_str());
}
if (plugins.size() == 0)
{
sprintf(strlen(str)+str, "<No suitable plugins were identified>");
}
//
// Only append the plugin thrown by the file format if it gave a useful
// message. Otherwise, it is just redundant.
//
if (strstr(msg2, "It may be an invalid file") == NULL)
{
sprintf(strlen(str)+str, "\n\nThe file format reader issued the "
"following error message, which may (or may not) be "
"indicative of the problem:\n%s", msg2);
}
msg = str;
}
......@@ -98,13 +185,17 @@ InvalidFilesException::InvalidFilesException(const char *filename)
//
// Modifications:
//
// Hank Childs, Fri Jan 12 09:08:30 PST 2007
// Remove reference to database, since that is just confusing the issue
// for users.
//
// ****************************************************************************
InvalidFilesException::InvalidFilesException(const std::string &filename,
const std::string &message)
{
char str[2048];
sprintf(str, "The database had an error opening %s: %s", filename.c_str(),
sprintf(str, "There was an error opening %s: %s", filename.c_str(),
message.c_str());
msg = str;
......@@ -121,12 +212,18 @@ InvalidFilesException::InvalidFilesException(const std::string &filename,
// Programmer: Hank Childs
// Creation: September 13, 2000
//
// Modifications:
//
// Hank Childs, Fri Jan 12 09:08:30 PST 2007
// Remove reference to database, since that is just confusing the issue
// for users.
//
// ****************************************************************************
InvalidFilesException::InvalidFilesException(const char * const * list,
int listN)
{
msg = "The database had an error opening one of the following files:\n";
msg = "There was an error opening one of the following files:\n";
for (int i = 0 ; i < listN ; i++)
{
msg += "\t";
......
......@@ -41,11 +41,13 @@
#ifndef INVALID_FILES_EXCEPTION_H
#define INVALID_FILES_EXCEPTION_H
#include <avtexception_exports.h>
#include <DatabaseException.h>
#include <string>
#include <vector>
// ****************************************************************************
......@@ -65,12 +67,20 @@
// Jeremy Meredith, Wed Aug 11 16:27:32 PDT 2004
// Adding a new constructor that allows a more informative message.
//
// Hank Childs, Thu Jan 11 15:49:54 PST 2007
// Add a new constructor for the plugin types tried.
//
// ****************************************************************************
class AVTEXCEPTION_API InvalidFilesException : public DatabaseException
{
public:
InvalidFilesException(const char *);
InvalidFilesException(const char *,
std::vector<std::string> &);
InvalidFilesException(const char *,
std::vector<std::string> &,
const char *);
InvalidFilesException(const char * const *, int);
InvalidFilesException(const std::string&,
const std::string&);
......
......@@ -126,6 +126,7 @@ avtDatabaseFactory::SetDefaultFormat(const char *f)
// filelist A list of files.
// filelistN The number of files in `filelist'.
// timestep The timestep to open to.
// plugins The plugins types that were tried (output argument)
// format The format to try first.
//
// Returns: An avtDatabase object that is correctly typed for the filelist.
......@@ -175,11 +176,15 @@ avtDatabaseFactory::SetDefaultFormat(const char *f)
// Mark C. Miller, Tue May 31 20:12:42 PDT 2005
// Added bool arg to forceReadAllCyclesTimes
//
// Hank Childs, Thu Jan 11 15:56:53 PST 2007
// Added argument for which plugin types were tried.
//
// ****************************************************************************
avtDatabase *
avtDatabaseFactory::FileList(const char * const * filelist, int filelistN,
int timestep, const char *format,
int timestep, vector<string> &plugins,
const char *format,
bool forceReadAllCyclesAndTimes)
{
int i, j;
......@@ -259,6 +264,7 @@ avtDatabaseFactory::FileList(const char * const * filelist, int filelistN,
}
CommonDatabasePluginInfo *info =
dbmgr->GetCommonPluginInfo(formatid);
plugins.push_back(info->GetName());
rv = SetupDatabase(info, filelist, filelistN, timestep, fileIndex,
nBlocks, forceReadAllCyclesAndTimes);
......@@ -326,6 +332,7 @@ avtDatabaseFactory::FileList(const char * const * filelist, int filelistN,
{
TRY
{
plugins.push_back(info->GetName());
rv = SetupDatabase(info, filelist, filelistN, timestep,
fileIndex, nBlocks, forceReadAllCyclesAndTimes);
}
......@@ -349,6 +356,7 @@ avtDatabaseFactory::FileList(const char * const * filelist, int filelistN,
string defaultid = dbmgr->GetAllID(defaultindex);
CommonDatabasePluginInfo *info =
dbmgr->GetCommonPluginInfo(defaultid);
plugins.push_back(info->GetName());
rv = SetupDatabase(info, filelist, filelistN, timestep, fileIndex,
nBlocks, forceReadAllCyclesAndTimes);
}
......@@ -435,6 +443,7 @@ avtDatabaseFactory::SetupDatabase(CommonDatabasePluginInfo *info,
// Arguments:
// visitFile The name of the .visit file.
// timestep The timestep to open at.
// plugins The plugins types that were tried (output argument)
// format The file format type (optional).
//
// Returns: An avtDatabase object that is correctly typed for the .visit
......@@ -472,10 +481,14 @@ avtDatabaseFactory::SetupDatabase(CommonDatabasePluginInfo *info,
// Brad Whitlock, Tue Jan 31 14:55:35 PST 2006
// Fixed a problem that lead to !NBLOCKS failing on win32.
//
// Hank Childs, Thu Jan 11 15:56:53 PST 2007
// Added an argument for which plugins were tried.
//
// ****************************************************************************
avtDatabase *
avtDatabaseFactory::VisitFile(const char *visitFile, int timestep,
vector<string> &plugins,
const char *format, bool forceReadAllCyclesAndTimes)
{
//
......@@ -531,7 +544,7 @@ avtDatabaseFactory::VisitFile(const char *visitFile, int timestep,
//
// Create a database using the list of files.
//
avtDatabase *rv = FileList(reallist, listcount, timestep, format,
avtDatabase *rv = FileList(reallist, listcount, timestep, plugins, format,
forceReadAllCyclesAndTimes);
//
......
......@@ -46,6 +46,8 @@
#include <stdlib.h> // For NULL
#include <string>
#include <vector>
class avtDatabase;
class CommonDatabasePluginInfo;
......@@ -78,14 +80,20 @@ class CommonDatabasePluginInfo;
//
// Mark C. Miller, Tue May 31 20:12:42 PDT 2005
// Added bool args for forcing reading of all cycles/times
//
// Hank Childs, Thu Jan 11 15:56:53 PST 2007
// Added argument for list of plugins attempted.
//
// ****************************************************************************
class DATABASE_API avtDatabaseFactory
{
public:
static avtDatabase *FileList(const char * const *, int, int,
std::vector<std::string> &,
const char * = NULL, bool = false);
static avtDatabase *VisitFile(const char *, int,
std::vector<std::string> &,
const char * = NULL, bool = false);
static void SetDefaultFormat(const char *);
......
/*****************************************************************************
*
* Copyright (c) 2000 - 2006, The Regents of the University of California
* Produced at the Lawrence Livermore National Laboratory
* All rights reserved.
*
* This file is part of VisIt. For details, see http://www.llnl.gov/visit/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or materials provided with the distribution.
* - Neither the name of the UC/LLNL nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OF THE UNIVERSITY OF
* CALIFORNIA, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
// ************************************************************************* //
// avtArrayComposeWithBinsFilter.C //
// ************************************************************************* //
#include <avtArrayComposeWithBinsFilter.h>
#include <math.h>
#include <vtkCellData.h>
#include <vtkDataArray.h>
#include <vtkDataSet.h>
#include <vtkFloatArray.h>
#include <vtkPointData.h>
#include <vtkUnsignedIntArray.h>
#include <ExprToken.h>
#include <avtExprNode.h>
#include <avtCallback.h>
#include <avtMaterial.h>
#include <avtMetaData.h>
#include <avtSpecies.h>
#include <DebugStream.h>
#include <ExpressionException.h>
#include <ImproperUseException.h>
// ****************************************************************************
// Method: avtArrayComposeWithBinsFilter constructor
//
// Purpose:
// Defines the constructor. Note: this should not be inlined in the
// header because it causes problems for certain compilers.
//
// Programmer: Hank Childs
// Creation: January 12, 2007
//
// ****************************************************************************
avtArrayComposeWithBinsFilter::avtArrayComposeWithBinsFilter()
{
nvars = 0;
}
// ****************************************************************************
// Method: avtArrayComposeWithBinsFilter destructor
//
// Purpose:
// Defines the destructor. Note: this should not be inlined in the header
// because it causes problems for certain compilers.
//
// Programmer: Hank Childs
// Creation: January 12, 2007
//
// ****************************************************************************
avtArrayComposeWithBinsFilter::~avtArrayComposeWithBinsFilter()
{
}
// ****************************************************************************
// Method: avtArrayComposeWithBinsFilter::DeriveVariable
//
// Purpose:
// Creates an array.
//
// Arguments:
// inDS The input dataset.
//
// Returns: The derived variable. The calling class must free this
// memory.
//
// Programmer: Hank Childs
// Creation: January 12, 2007
//
// ****************************************************************************
vtkDataArray *
avtArrayComposeWithBinsFilter::DeriveVariable(vtkDataSet *in_ds)
{
int i, j;
if (varnames.size() == 0)
EXCEPTION0(ImproperUseException);
int nvars = varnames.size();
vtkDataArray **vars = new vtkDataArray*[nvars];
avtCentering *centering = new avtCentering[nvars];
for (i = 0 ; i < nvars ; i++)
{
vars[i] = in_ds->GetPointData()->GetArray(varnames[i]);
centering[i] = AVT_NODECENT;
if (vars[i] == NULL)
{
vars[i] = in_ds->GetCellData()->GetArray(varnames[i]);
centering[i] = AVT_ZONECENT;
}
}
for (i = 0 ; i < nvars ; i++)
{
if (vars[i] == NULL)
EXCEPTION1(ExpressionException,
"Cannot create array because: cannot locate all variables");
if (vars[i]->GetNumberOfComponents() != 1)
EXCEPTION1(ExpressionException,
"Cannot create array because: all inputs must be scalars");
if (centering[i] != centering[0])
EXCEPTION1(ExpressionException,
"Cannot create array because: the centering of the "
"variables does not agree.");
}
vtkFloatArray *rv = vtkFloatArray::New();
rv->SetNumberOfComponents(nvars);
int nvals = vars[0]->GetNumberOfTuples();
rv->SetNumberOfTuples(nvals);
for (i = 0 ; i < nvals ; i++)
for (j = 0 ; j < nvars ; j++)
rv->SetComponent(i, j, vars[j]->GetTuple1(i));
delete [] vars;
delete [] centering;
return rv;
}
// ****************************************************************************
// Method: avtArrayComposeWithBinsFilter::ProcessArguments
//
// Purpose:
// Tells the first argument to go generate itself. Parses the second
// argument into a list of material names.
//
// Arguments:
// inDS The input dataset.
//
// Returns: The derived variable. The calling class must free this
// memory.
//
// Programmer: Hank Childs
// Creation: January 12, 2007
//
// ****************************************************************************
void
avtArrayComposeWithBinsFilter::ProcessArguments(ArgsExpr *args,
ExprPipelineState *state)
{
// Check the number of arguments
std::vector<ArgExpr*> *arguments = args->GetArgs();
nvars = arguments->size()-1;
int idx_of_list = arguments->size()-1;
ArgExpr *listarg = (*arguments)[idx_of_list];
ExprParseTreeNode *listTree = listarg->GetExpr();
if (listTree->GetTypeName() != "List")
{
debug1 << "avtArrayComposeWithBinsFilter: second arg is not a list: "
<< listTree->GetTypeName() << endl;
EXCEPTION1(ExpressionException, "the last argument to array_compose_"
"with_bins must be a list");
}
ListExpr *list = dynamic_cast<ListExpr*>(listTree);
std::vector<ListElemExpr*> *elems = list->GetElems();
binRanges.resize(elems->size());
if (elems->size() != nvars+1)
{
EXCEPTION1(ExpressionException, "the list for array_compose_with_bins"
" must have one more number than there are variables. "
" For two variables (V1 and V2), there should be a list of"
" size 3: [L0, L1, L2]. V1's bin goes from L0 to L1, "
"and V2's bin goes from L1 to L2.");
}
for (int i = 0 ; i < elems->size() ; i++)
{
if ((*elems)[i]->GetEnd())
{
EXCEPTION1(ExpressionException, "the list for array_compose_with"
"_bins expression cannot contain ranges.");
}
ExprNode *item = (*elems)[i]->GetItem();
if (item->GetTypeName() == "FloatConst")
{
ConstExpr *c = dynamic_cast<ConstExpr*>(item);
binRanges[i] = dynamic_cast<FloatConstExpr*>(c)->GetValue();
}
else if (item->GetTypeName() == "IntegerConst")
{
ConstExpr *c = dynamic_cast<ConstExpr*>(item);
binRanges[i] = dynamic_cast<IntegerConstExpr*>(c)->GetValue();
}
else
{
EXCEPTION1(ExpressionException, "the list for the array_compose"
"_with_bins expression may contain only numbers.");
}
}
// Let the base class do this processing. We only had to over-ride this
// function to determine the number of arguments.
avtMultipleInputExpressionFilter::ProcessArguments(args, state);
}
// ****************************************************************************
// Method: avtArrayComposeWithBinsFilter::RefashionDataObjectInfo
//
// Purpose:
// Tell the output what the component names are.
//
// Programmer: Hank Childs
// Creation: January 12, 2007
//
// ****************************************************************************
void
avtArrayComposeWithBinsFilter::RefashionDataObjectInfo(void)
{
avtMultipleInputExpressionFilter::RefashionDataObjectInfo();
// If we don't know the name of the variable, we can't set it up in the
// output.
if (outputVariableName == NULL)
return;
std::vector<std::string> subnames(varnames.size());
for (int i = 0 ; i < varnames.size() ; i++)
subnames[i] = varnames[i];
avtDataAttributes &outAtts = GetOutput()->GetInfo().GetAttributes();
outAtts.SetVariableSubnames(subnames, outputVariableName);
outAtts.SetVariableBinRanges(binRanges, outputVariableName);
}
/*****************************************************************************
*
* Copyright (c) 2000 - 2006, The Regents of the University of California
* Produced at the Lawrence Livermore National Laboratory
* All rights reserved.
*
* This file is part of VisIt. For details, see http://www.llnl.gov/visit/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,