Commit 84f360f7 authored by miller86's avatar miller86
Browse files

fixing minor issues reading mat-restricted variables from Silo

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@12789 18c085ea-50e0-402c-830e-de6fd14e8384
parent f4380a8f
......@@ -628,5 +628,21 @@ avtVarMetaData::Print(ostream &out, int indent) const
Indent(out, indent);
out << "The extents are not set." << endl;
}
if (matRestricted.size())
{
Indent(out, indent);
out << "Restricted to material indices: " << matRestricted[0];
for (int i = 1; i < matRestricted.size(); i++)
{
out << ", " << matRestricted[i];
if (i%20 == 0)
{
out << endl;
Indent(out, indent);
}
}
out << endl;
}
}
......@@ -166,6 +166,8 @@ Definition:
// Jeremy Meredith, Fri Aug 25 17:16:38 EDT 2006
// Added enumerated scalars.
//
// Mark C. Miller, Thu Oct 21 17:15:46 PDT 2010
// Added mat-restricted information.
// ****************************************************************************
inline void
Indent(ostream &out, int indent)
......@@ -218,5 +220,21 @@ avtVarMetaData::Print(ostream &out, int indent) const
Indent(out, indent);
out << "The extents are not set." << endl;
}
if (matRestricted.size())
{
Indent(out, indent);
out << "Restricted to material indices: " << matRestricted[0];
for (int i = 1; i < matRestricted.size(); i++)
{
out << ", " << matRestricted[i];
if (i%20 == 0)
{
out << endl;
Indent(out, indent);
}
}
out << endl;
}
}
......@@ -2451,7 +2451,7 @@ avtSiloFileFormat::ReadCSGmeshes(DBfile *dbfile,
//
// ****************************************************************************
static int
static bool
GetRestrictedMaterialIndices(const avtDatabaseMetaData *md, const char *const varname,
const char *const meshname, const char *const *const region_pnames,
vector<int>* restrictToMats)
......@@ -2469,14 +2469,18 @@ GetRestrictedMaterialIndices(const avtDatabaseMetaData *md, const char *const va
int i, j;
bool regionNamesButMaterialNumbers = true;
debug3 << "For mat-restricted variable \"" << varname << "\"..." << endl;
for (i = 0; region_pnames[i]; i++)
{
debug3 << " Looking for materials matching region_pname[" << i
<< "] = \"" << region_pnames[i] << "\"..." << endl;
int rnlen = strlen(region_pnames[i]);
int rnspn = strspn(region_pnames[i], "0123456789");
if (rnlen == rnspn) // Must be just a number
{
int regno = strtol(region_pnames[i], 0, 10);
regionNamesButMaterialNumbers = false;
debug3 << " Comparing using regno=" << regno << "..." << endl;
for (j = 0; j < mmd->numMaterials; j++)
{
// The 'materialNames' Silo plugin creates are either
......@@ -2484,25 +2488,44 @@ GetRestrictedMaterialIndices(const avtDatabaseMetaData *md, const char *const va
// strtol should convert the number part correctly.
errno = 0;
int matno = strtol(mmd->materialNames[j].c_str(), 0, 10);
debug3 << " for \"" << mmd->materialNames[j]
<< "\" got matno=" << matno;
if (errno == 0 && regno == matno)
{
restrictToMats->push_back(j);
debug3 << " matched" << endl;
}
else
{
debug3 << " DID NOT match" << endl;
}
}
}
else // Not just a number (a name?)
{
debug3 << " Comparing using region name..." << endl;
for (j = 0; j < mmd->numMaterials; j++)
{
int mnlen = strlen(mmd->materialNames[j].c_str());
int mnspn = strspn(mmd->materialNames[j].c_str(), "0123456789");
if (mnlen == mnspn) // Must be just a number
int matno;
char matname[256];
int nmatches = sscanf(mmd->materialNames[j].c_str(), "%d %s", &matno, &matname);
debug3 << " matno=" << matno << ", matname=\"" << matname << "\"";
if (nmatches == 1) // have matno only
{
debug3 << " CANNOT match matno alone" << endl;
continue;
}
else // Not just a number (a name?)
else
{
regionNamesButMaterialNumbers = false;
if (strcmp(region_pnames[i], &(mmd->materialNames[j].c_str()[mnspn])))
if (!strcmp(region_pnames[i], matname))
{
debug3 << " matched" << endl;
restrictToMats->push_back(j);
}
else
{
debug3 << " DID NOT match" << endl;
}
}
}
}
......@@ -2643,6 +2666,9 @@ avtSiloFileFormat::ReadMultivars(DBfile *dbfile,
}
centering = (uv->centering == DB_ZONECENT ? AVT_ZONECENT
: AVT_NODECENT);
if (uv->region_pnames)
valid_var = GetRestrictedMaterialIndices(md, name_w_dir,
meshname.c_str(), uv->region_pnames, &selectedMats);
nvals = uv->nvals;
treatAsASCII = (uv->ascii_labels);
if(uv->units != 0)
......@@ -2661,6 +2687,9 @@ avtSiloFileFormat::ReadMultivars(DBfile *dbfile,
}
centering = (qv->align[0] == 0. ? AVT_NODECENT
: AVT_ZONECENT);
if (qv->region_pnames)
valid_var = GetRestrictedMaterialIndices(md, name_w_dir,
meshname.c_str(), qv->region_pnames, &selectedMats);
nvals = qv->nvals;
treatAsASCII = (qv->ascii_labels);
if(qv->units != 0)
......@@ -2678,6 +2707,9 @@ avtSiloFileFormat::ReadMultivars(DBfile *dbfile,
valid_var = false;
break;
}
if (pv->region_pnames)
valid_var = GetRestrictedMaterialIndices(md, name_w_dir,
meshname.c_str(), pv->region_pnames, &selectedMats);
nvals = pv->nvals;
treatAsASCII = (pv->ascii_labels);
if(pv->units != 0)
......@@ -2698,6 +2730,9 @@ avtSiloFileFormat::ReadMultivars(DBfile *dbfile,
valid_var = false;
break;
}
if (csgv->region_pnames)
valid_var = GetRestrictedMaterialIndices(md, name_w_dir,
meshname.c_str(), csgv->region_pnames, &selectedMats);
nvals = csgv->nvals;
treatAsASCII = (csgv->ascii_labels);
if(csgv->units != 0)
......@@ -2921,7 +2956,6 @@ avtSiloFileFormat::ReadUcdvars(DBfile *dbfile,
if (uv->region_pnames)
valid_var = GetRestrictedMaterialIndices(md, name_w_dir,
meshname_w_dir, uv->region_pnames, &selectedMats);
//
// Get the dimension of the variable.
//
......
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