Commit 98cbd963 authored by js9's avatar js9
Browse files

merge from 2.1RC: support new tecplot varlocation format. This fixes #414.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@12825 18c085ea-50e0-402c-830e-de6fd14e8384
parent cd5c753f
......@@ -168,6 +168,11 @@ avtTecplotFileFormat::PushBackToken(const string &tok)
// Jeremy Meredith, Thu May 22 10:25:12 EDT 2008
// Support DOS format text files.
//
// Jeremy Meredith, Tue Oct 26 17:23:53 EDT 2010
// Change the scanner to allow any of []()= as single-character
// tokens. This allows us to parse some of the more complex patterns
// such as FOO=([4-6,8]=A,[5,12]=B).
//
// ****************************************************************************
string
avtTecplotFileFormat::GetNextToken()
......@@ -204,9 +209,6 @@ avtTecplotFileFormat::GetNextToken()
next_char == '\n' ||
next_char == '\r' ||
next_char == '\t' ||
next_char == '=' ||
next_char == '(' ||
next_char == ')' ||
next_char == ','))
{
if (next_char == '\n' || next_char == '\r')
......@@ -250,6 +252,20 @@ avtTecplotFileFormat::GetNextToken()
next_char_eof = true;
}
}
else if (next_char == '=' ||
next_char == '(' ||
next_char == ')' ||
next_char == '[' ||
next_char == ']')
{
// simple one-character tokens
retval += next_char;
next_char = file.get();
if (!file)
{
next_char_eof = true;
}
}
else
{
// do a normal token
......@@ -261,6 +277,8 @@ avtTecplotFileFormat::GetNextToken()
next_char != '=' &&
next_char != '(' &&
next_char != ')' &&
next_char != '[' &&
next_char != ']' &&
next_char != ','))
{
if (next_char >= 'a' && next_char <= 'z')
......@@ -280,9 +298,6 @@ avtTecplotFileFormat::GetNextToken()
next_char == '\n' ||
next_char == '\r' ||
next_char == '\t' ||
next_char == '=' ||
next_char == '(' ||
next_char == ')' ||
next_char == ','))
{
if (next_char == '\n' || next_char == '\r')
......@@ -901,6 +916,11 @@ avtTecplotFileFormat::ParsePOINT(int numI, int numJ, int numK)
// Jeremy Meredith, Tue Oct 26 17:13:39 EDT 2010
// Don't be quite to restrictive about what constitutes an FE-style ZONE.
//
// Jeremy Meredith, Tue Oct 26 17:26:00 EDT 2010
// The parser now returns parens, brackets, and equals as tokens.
// Added code to skip over these when needed. Also added parsing
// support for complex version of VARLOCATION parameter.
//
// ****************************************************************************
void
......@@ -931,6 +951,7 @@ avtTecplotFileFormat::ReadFile()
else if (tok == "TITLE")
{
// it's a title
GetNextToken(); // skip the equals sign
title = GetNextToken();
}
else if (tok == "GEOMETRY")
......@@ -976,6 +997,7 @@ avtTecplotFileFormat::ReadFile()
int guessedZindex = -1;
// variable lists
GetNextToken(); // skip the equals sign
tok = GetNextToken();
while (token_was_string)
{
......@@ -1115,6 +1137,7 @@ avtTecplotFileFormat::ReadFile()
{
if (tok == "T")
{
GetNextToken(); // skip the equals sign
zoneTitle = GetNextToken();
if (!token_was_string)
{
......@@ -1124,52 +1147,125 @@ avtTecplotFileFormat::ReadFile()
}
else if (tok == "I")
{
GetNextToken(); // skip the equals sign
numI = atoi(GetNextToken().c_str());
}
else if (tok == "J")
{
GetNextToken(); // skip the equals sign
numJ = atoi(GetNextToken().c_str());
}
else if (tok == "K")
{
GetNextToken(); // skip the equals sign
numK = atoi(GetNextToken().c_str());
}
else if (tok == "N" || tok == "NODES")
{
GetNextToken(); // skip the equals sign
numNodes = atoi(GetNextToken().c_str());
}
else if (tok == "E" || tok == "ELEMENTS")
{
GetNextToken(); // skip the equals sign
numElements = atoi(GetNextToken().c_str());
}
else if (tok == "ET" || tok == "ZONETYPE")
{
GetNextToken(); // skip the equals sign
elemType = GetNextToken();
}
else if (tok == "F" || tok == "DATAPACKING")
{
GetNextToken(); // skip the equals sign
format = GetNextToken();
}
else if (tok == "SOLUTIONTIME")
{
GetNextToken(); // skip the equals sign
solTime = strtod(GetNextToken().c_str(),0);
}
else if (tok == "VARLOCATION")
{
string centering;
variableCellCentered.clear();
variableCellCentered.resize(numTotalVars, 0);
for (int i=0; i<numTotalVars; i++)
GetNextToken(); // skip the equals sign
GetNextToken(); // skip the open paren
string c;
c = GetNextToken();
if (c == "[")
{
centering = GetNextToken();
if (centering == "CELLCENTERED")
variableCellCentered[i] = 1;
// complex version
// e.g. VARLOCATION=([2-3,5]=CELLCENTERED,[4]=NODAL)
while (c != ")")
{
// c == "["
vector<int> varindices;
c = GetNextToken();
while (c != "]")
{
string::size_type pos = c.find("-");
if (pos != string::npos)
{
// Okay, we got something like "4-6".
// Note, this scans as a single token
// because we haven't gone all-out on
// a scanner rewrite. So just separate
// it into a "4 through 6" here.
// ALSO NOTE: THIS WILL NOT WORK
// WITH ANY WHITESPACE IN HERE.
// The examples don't have any, but
// the tecplot manual doesn't actually
// specify what's really allowed, so
// given past history, someone may
// eventually do something like that....
string first = c.substr(0,pos);
string last = c.substr(pos+1);
int beg = atoi(first.c_str());
int end = atoi(last.c_str());
for (int ind=beg; ind<=end; ind++)
varindices.push_back(ind);
}
else
{
varindices.push_back(atoi(c.c_str()));
}
c = GetNextToken();
}
GetNextToken(); // skip the equals sign
c = GetNextToken(); // that's the centering keyword
if (c == "CELLCENTERED")
{
for (int i=0; i<varindices.size(); i++)
variableCellCentered[varindices[i]-1] = 1;
}
// next....
c = GetNextToken();
}
}
else
{
// simple version
// e.g. VARLOCATION=(NODAL,CELLCENTERED,CELLCENTERED)
for (int i=0; i<numTotalVars; i++)
{
if (c == "CELLCENTERED")
variableCellCentered[i] = 1;
c = GetNextToken();
// after the last var this picks up the close paren
}
}
}
else if (tok == "DT")
{
GetNextToken(); // skip the equals sign
GetNextToken(); // skip the open paren
for (int i=0; i<numTotalVars; i++)
GetNextToken();
GetNextToken(); // skip the close paren
}
else if (tok == "D")
{
......@@ -1247,6 +1343,10 @@ avtTecplotFileFormat::ReadFile()
haveVectorExpr = (tok == "VECTOR");
}
else if(tokIndex == 1)
{
// skip the equals sign
}
else if(tokIndex == 2)
{
if(haveVectorExpr)
{
......
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