Commit a34b66dd authored by js9's avatar js9

Adding support for array variables (at least those created with

array_compose).  Fixed hard-to-replicate crash.



git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@3168 18c085ea-50e0-402c-830e-de6fd14e8384
parent 46647a68
......@@ -43,6 +43,16 @@
#include <ParallelCoordinatesPluginInfo.h>
#include <avtParallelCoordinatesPlot.h>
#include <ViewerPlot.h>
#include <ParsingExprList.h>
#include <Expression.h>
#include <ColorAttribute.h>
#include <ExprNode.h>
#include <InvalidVariableException.h>
#include <ImproperUseException.h>
#include <DebugStream.h>
#if defined(__APPLE__)
#define GetViewerInfo ParallelCoordinates_GetViewerInfo
#endif
......@@ -195,16 +205,139 @@ ParallelCoordinatesViewerPluginInfo::AllocAvtPlot()
// md The metadata used to initialize.
// atts The variable name used to initialize.
//
// Programmer: js9 -- generated by xml2info
// Creation: Thu Jan 31 13:07:49 PST 2008
// Programmer: Jeremy Meredith
// Creation: February 6, 2008
//
// ****************************************************************************
void
ParallelCoordinatesViewerPluginInfo::InitializePlotAtts(AttributeSubject *atts,
ViewerPlot *)
ViewerPlot *plot)
{
//
// Copy over the default atts
//
*(ParallelCoordinatesAttributes*)atts = *defaultAtts;
//
// If it's not an array expression, we initalized the attributes
// from the wizard.
//
Expression *exp = ParsingExprList::GetExpression(plot->GetVariableName());
if (exp == NULL || exp->GetType() != Expression::ArrayMeshVar)
{
// Nothing to do; it's not an array expression
return;
}
//
// It is an array expression. Get the variable names and
// ranges from it.
//
vector<string> names;
vector<double> values;
// Make sure it's a function...
ExprNode *root = ParsingExprList::GetExpressionTree(exp);
if (root->GetTypeName() != "Function")
{
EXCEPTION1(ImproperUseException,
"Variable was not an array_compose expression.");
}
// ... that that function is one of the array_compose functions ...
FunctionExpr *fn = dynamic_cast<FunctionExpr*>(root);
if (fn->GetName() != "array_compose" &&
fn->GetName() != "array_compose_with_bins")
{
EXCEPTION1(ImproperUseException,
"Variable was not an array_compose expression.");
}
// ... and that it has some arguments.
ArgsExpr *argsExpr = fn->GetArgsExpr();
vector<ArgExpr*> *args = argsExpr ? argsExpr->GetArgs() : NULL;
if (!args)
{
EXCEPTION1(ImproperUseException,
"Variable was not an valid array_compose expression.");
}
// Okay, now walk the arguments. It should be, in order:
// (var1, var2, ..., varN, [bin1, bin2, ..., binM])
int state = 0; //0==vars are being parsed, 1==the list has been parsed
for (int i=0; i<args->size(); i++)
{
if (state==1)
{
EXCEPTION1(ImproperUseException,
"Unknown array_compose syntax: "
"the list should be at the end of the argument list");
}
ExprNode *arg = (ExprNode*)((*args)[i]->GetExpr());
if (arg->GetTypeName() == "List")
{
if (fn->GetName() != "array_compose_with_bins")
{
EXCEPTION1(ImproperUseException,
"Unknown array_compose syntax: "
"only array_compose_with_bins supports a bin list");
}
vector<ListElemExpr*> *list = ((ListExpr*)arg)->GetElems();
for (int j=0; j<list->size(); j++)
{
if ((*list)[j]->GetEnd() || (*list)[j]->GetSkip())
{
EXCEPTION1(ImproperUseException,
"Unknown array_compose syntax: "
"bin list can not have ranges");
}
ExprNode *elem = (*list)[j]->GetItem();
if (elem->GetTypeName() == "IntegerConst")
{
IntegerConstExpr *i = dynamic_cast<IntegerConstExpr*>(elem);
values.push_back(i->GetValue());
}
else if (elem->GetTypeName() == "FloatConst")
{
FloatConstExpr *f = dynamic_cast<FloatConstExpr*>(elem);
values.push_back(f->GetValue());
}
else
{
EXCEPTION1(ImproperUseException,
"Unknown array_compose syntax: "
"only floats and ints are allowed in bin list");
}
}
state = 1; // the list has been parsed; this better be the end!
}
else if (arg->GetTypeName() == "Var")
{
// Got a variable; just add its full path string
VarExpr *var = dynamic_cast<VarExpr*>(arg);
names.push_back(var->GetVar()->GetFullpath());
}
else
{
// Not a variable or a list
EXCEPTION1(ImproperUseException,
"Bad array_compose syntax.");
}
}
if (values.size() > 0 && values.size() != names.size())
{
EXCEPTION1(ImproperUseException,
"There must be as many bins in the list as variables.");
}
int axisCount = names.size();
vector<double> extMin(axisCount, -1e+37);
vector<double> extMax(axisCount, +1e+37);
((ParallelCoordinatesAttributes*)atts)->SetOrderedAxisNames(names);
((ParallelCoordinatesAttributes*)atts)->SetExtentMinima(extMin);
((ParallelCoordinatesAttributes*)atts)->SetExtentMaxima(extMax);
}
// ****************************************************************************
......
......@@ -212,12 +212,16 @@ avtParallelCoordinatesFilter::PerformRestriction(avtPipelineSpecification_p in_s
// Jeremy Meredith, Mon Feb 4 15:46:42 EST 2008
// Some more distillation and related cleanup.
//
// Jeremy Meredith, Wed Feb 6 16:13:17 EST 2008
// Initialize axisCount to zero right away, just in case we error out.
//
// *****************************************************************************
void
avtParallelCoordinatesFilter::PreExecute(void)
{
avtDatasetToDatasetFilter::PreExecute();
axisCount = 0;
if (!parCoordsAtts.AttributesAreConsistent())
{
......@@ -290,12 +294,17 @@ avtParallelCoordinatesFilter::PreExecute(void)
// Adapted from Parallel Axis plot and repurposed into this new
// Parallel Coordinates plot.
//
// Jeremy Meredith, Wed Feb 6 16:13:34 EST 2008
// About early in the case of earlier errors.
//
// ****************************************************************************
void
avtParallelCoordinatesFilter::PostExecute(void)
{
avtDatasetToDatasetFilter::PostExecute();
if (sendNullOutput)
return;
avtDataAttributes &inAtts = GetInput()->GetInfo().GetAttributes();
avtDataAttributes &outAtts = GetOutput()->GetInfo().GetAttributes();
......@@ -694,12 +703,17 @@ avtParallelCoordinatesFilter::ReleaseData(void)
// Jeremy Meredith, Mon Feb 4 15:46:42 EST 2008
// Some more distillation and related cleanup.
//
// Jeremy Meredith, Wed Feb 6 16:14:05 EST 2008
// Resize axisMinima and axisMaxima early, just in case.
//
// ****************************************************************************
void
avtParallelCoordinatesFilter::ComputeCurrentDataExtentsOverAllDomains()
{
stringVector curAxisVarNames = parCoordsAtts.GetOrderedAxisNames();
axisMinima.resize(axisCount);
axisMaxima.resize(axisCount);
if (varTupleIndices.size() != curAxisVarNames.size())
{
......@@ -709,9 +723,6 @@ avtParallelCoordinatesFilter::ComputeCurrentDataExtentsOverAllDomains()
return;
}
axisMinima.resize(axisCount);
axisMaxima.resize(axisCount);
int axisNum;
for (axisNum = 0; axisNum < axisCount; axisNum++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment