Commit 69fa2dc8 authored by js9's avatar js9

Allow negative values in enumeration value destination map.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@5836 18c085ea-50e0-402c-830e-de6fd14e8384
parent 43e3fe38
......@@ -181,6 +181,10 @@ avtApplyEnumerationExpression::DeriveVariable(vtkDataSet *in_ds)
// Programmer: Jeremy Meredith
// Creation: February 13, 2008
//
// Modifications:
// Jeremy Meredith, Mon Dec 15 12:52:34 EST 2008
// Account for negative values in the enumeration list.
//
// ****************************************************************************
void
......@@ -219,15 +223,30 @@ avtApplyEnumerationExpression::ProcessArguments(ArgsExpr *args,
}
ExprNode *item = (*elems)[i]->GetItem();
// We interpret negative values as unary minus + positive value.
// So keep inspecting down here.
double scale = +1;
while (item->GetTypeName() == "Unary")
{
UnaryExpr *u = dynamic_cast<UnaryExpr*>(item);
if (u->GetOp() != '-')
EXCEPTION2(ExpressionException, outputVariableName,
"got an unexpected unary operator "
"which wasn't '-'.");
scale *= -1;
item = u->GetExpr();
}
if (item->GetTypeName() == "FloatConst")
{
ConstExpr *c = dynamic_cast<ConstExpr*>(item);
enumeratedValues[i] = dynamic_cast<FloatConstExpr*>(c)->GetValue();
enumeratedValues[i] = scale * dynamic_cast<FloatConstExpr*>(c)->GetValue();
}
else if (item->GetTypeName() == "IntegerConst")
{
ConstExpr *c = dynamic_cast<ConstExpr*>(item);
enumeratedValues[i] = dynamic_cast<IntegerConstExpr*>(c)->GetValue();
enumeratedValues[i] = scale * dynamic_cast<IntegerConstExpr*>(c)->GetValue();
}
else
{
......
......@@ -108,6 +108,9 @@ class Pos;
// Jeremy Meredith, Thu Aug 7 16:21:59 EDT 2008
// Reorder initializers to match true order.
//
// Jeremy Meredith, Mon Dec 15 12:50:38 EST 2008
// Added GetOp to MathExpr.
//
// ****************************************************************************
class EXPR_API ExprNode : public ExprParseTreeNode
{
......@@ -194,6 +197,7 @@ class EXPR_API MathExpr : public virtual ExprNode
: ExprNode(p), op(o) {}
virtual ~MathExpr() { }
virtual const std::string GetTypeName() { return "Math"; }
char GetOp() const { return op; }
protected:
char op;
};
......
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