Commit e49aa64c authored by hrchilds's avatar hrchilds
Browse files

Update from May 23, 2005

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@475 18c085ea-50e0-402c-830e-de6fd14e8384
parent 06cafc92
......@@ -561,7 +561,7 @@ avtFileFormat::GuessCycleOrTime(const char *fname, bool permitDot) const
//
// Example of atoi: atoi("1234str") = 1234.
//
if (lastDigit >= 0)
if (lastDigit >= 0 && (!permitDot || fname[lastDigit] != '.' || isdigit(fname[lastDigit+1])))
{
return atof(fname+lastDigit);
}
......
......@@ -310,7 +310,7 @@ void
avtSTMDFileFormatInterface::SetDatabaseMetaData(avtDatabaseMetaData *md,
int timeState, bool forceReadAllCyclesTimes)
{
int i, j;
int i;
//
// Throw an exception if an invalid time state was requested.
......@@ -349,6 +349,7 @@ avtSTMDFileFormatInterface::SetDatabaseMetaData(avtDatabaseMetaData *md,
timesteps[0]->FormatGetCycleFromFilename("") != -INT_MAX+1;
bool canGetGoodTimeFromFilename =
timesteps[0]->FormatGetTimeFromFilename("") != -DBL_MAX+1;
//
// We are going to obtain cycle information from Filenames or from
// the format itself depending on whether forceReadAllCyclesTimes is true.
......@@ -356,10 +357,6 @@ avtSTMDFileFormatInterface::SetDatabaseMetaData(avtDatabaseMetaData *md,
// either from the Filename or from the format itself, or if we get "invalid"
// values back from the plugin, we give up.
//
bool cyclesLookGood = true;
bool timesLookGood = true;
bool fallBackToCyclesFromFilename = false;
bool fallBackToTimesFromFilename = false;
vector<int> cycles;
vector<double> times;
vector<bool> cycleIsAccurate;
......@@ -367,92 +364,55 @@ avtSTMDFileFormatInterface::SetDatabaseMetaData(avtDatabaseMetaData *md,
for (i = 0 ; i < nTimesteps; i++)
{
int c = -INT_MAX;
double t = -DBL_MAX;
bool cIsAccurate = false;
if (md->IsCycleAccurate(i) != true && cyclesLookGood)
if (md->IsCycleAccurate(i) != true)
{
if (forceReadAllCyclesTimes && !fallBackToCyclesFromFilename &&
!canGetGoodCycleFromFilename)
if (forceReadAllCyclesTimes)
{
c = timesteps[i]->FormatGetCycle();
// If we get back -INT_MAX from GetCycle, this indicates the
// format was unable to return a valid cycle. So, we fall back
// to using the filenames.
if (c == -INT_MAX)
{
fallBackToCyclesFromFilename = true;
if (canGetGoodCycleFromFilename)
c = timesteps[i]->FormatGetCycleFromFilename(timesteps[i]->GetFilename());
cycleIsAccurate.push_back(false);
}
else
{
cycleIsAccurate.push_back(true);
}
}
else
{
c = timesteps[i]->FormatGetCycleFromFilename(timesteps[i]->GetFilename());
cycleIsAccurate.push_back(true);
c = timesteps[i]->FormatGetCycle();
}
cycles.push_back(c);
if ((c == -INT_MAX) || ((i != 0) && (cycles[i] <= cycles[i-1])))
cyclesLookGood = false;
if (c != -INT_MAX)
cIsAccurate = true;
}
else
{
if (cyclesLookGood)
{
cycles.push_back(md->GetCycles()[i]);
cycleIsAccurate.push_back(true);
}
c = md->GetCycles()[i];
cIsAccurate = true;
}
if (md->IsTimeAccurate(i) != true && timesLookGood)
cycles.push_back(c);
cycleIsAccurate.push_back(cIsAccurate);
double t = -DBL_MAX;
bool tIsAccurate = false;
if (md->IsTimeAccurate(i) != true)
{
if (forceReadAllCyclesTimes && !fallBackToTimesFromFilename &&
!canGetGoodTimeFromFilename)
if (forceReadAllCyclesTimes)
{
t = timesteps[i]->FormatGetTime();
// If we get back -DBL_MAX from FormatGetTime, this indicates the
// format was unable to return a valid time. So, we fall back
// to using the filenames.
if (t == -DBL_MAX)
{
fallBackToTimesFromFilename = true;
if (canGetGoodTimeFromFilename)
t = timesteps[i]->FormatGetTimeFromFilename(timesteps[i]->GetFilename());
timeIsAccurate.push_back(false);
}
else
{
timeIsAccurate.push_back(true);
}
t = timesteps[i]->FormatGetTime();
}
else
{
t = timesteps[i]->FormatGetTimeFromFilename(timesteps[i]->GetFilename());
timeIsAccurate.push_back(true);
}
times.push_back(t);
if ((t == -DBL_MAX) || ((i != 0) && (times[i] <= times[i-1])))
timesLookGood = false;
if (t != -DBL_MAX)
tIsAccurate = true;
}
else
{
if (timesLookGood)
{
times.push_back(md->GetTimes()[i]);
timeIsAccurate.push_back(true);
}
t = md->GetTimes()[i];
tIsAccurate = true;
}
if (cyclesLookGood == false && timesLookGood == false)
break;
times.push_back(t);
timeIsAccurate.push_back(tIsAccurate);
}
//
......@@ -460,21 +420,11 @@ avtSTMDFileFormatInterface::SetDatabaseMetaData(avtDatabaseMetaData *md,
//
if (md->AreAllCyclesAccurateAndValid() != true)
{
if (cyclesLookGood)
{
md->SetCycles(cycles);
for (i = 0 ; i < nTimesteps; i++)
md->SetCycleIsAccurate(cycleIsAccurate[i],i);
}
else
for (i = 0 ; i < nTimesteps; i++)
{
cycles.clear();
for (j = 0 ; j < nTimesteps ; j++)
{
cycles.push_back(j);
}
md->SetCycles(cycles);
md->SetCyclesAreAccurate(false);
md->SetCycleIsAccurate(cycleIsAccurate[i],i);
if (cycleIsAccurate[i])
md->SetCycle(i, cycles[i]);
}
}
......@@ -483,23 +433,14 @@ avtSTMDFileFormatInterface::SetDatabaseMetaData(avtDatabaseMetaData *md,
//
if (md->AreAllTimesAccurateAndValid() != true)
{
if (timesLookGood)
{
md->SetTimes(times);
for (i = 0 ; i < nTimesteps; i++)
md->SetTimeIsAccurate(timeIsAccurate[i],i);
md->SetTemporalExtents(times[0], times[times.size() - 1]);
}
else
for (i = 0 ; i < nTimesteps; i++)
{
times.clear();
for (int j = 0 ; j < nTimesteps ; j++)
{
times.push_back((double)j);
}
md->SetTimes(times);
md->SetTimesAreAccurate(false);
md->SetTimeIsAccurate(timeIsAccurate[i],i);
if (timeIsAccurate[i])
md->SetTime(i, times[i]);
}
if (timeIsAccurate[0] && timeIsAccurate[nTimesteps-1])
md->SetTemporalExtents(times[0], times[nTimesteps-1]);
}
}
......
......@@ -384,105 +384,61 @@ avtSTSDFileFormatInterface::SetDatabaseMetaData(avtDatabaseMetaData *md,
// either from the Filename or from the format itself, or if we get "invalid"
// values back from the plugin, we give up.
//
bool cyclesLookGood = true;
bool timesLookGood = true;
bool fallBackToCyclesFromFilename = false;
bool fallBackToTimesFromFilename = false;
vector<int> cycles;
vector<double> times;
vector<bool> cycleIsAccurate;
vector<bool> timeIsAccurate;
for (i = 0 ; i < nTimesteps; i++)
{
int c = -INT_MAX;
bool cIsAccurate = false;
if (md->IsCycleAccurate(i) != true && cyclesLookGood)
if (md->IsCycleAccurate(i) != true)
{
int c = -INT_MAX;
if (forceReadAllCyclesTimes && !fallBackToCyclesFromFilename &&
!canGetGoodCycleFromFilename)
if (forceReadAllCyclesTimes)
{
c = timesteps[i][0]->FormatGetCycle();
// If we get back -INT_MAX from FormatGetCycle, this indicates the
// format was unable to return a valid cycle. So, we fall back
// to using the filenames.
if (c == -INT_MAX)
{
fallBackToCyclesFromFilename = true;
if (canGetGoodCycleFromFilename)
c = timesteps[i][0]->FormatGetCycleFromFilename(timesteps[i][0]->GetFilename());
cycleIsAccurate.push_back(false);
}
else
{
cycleIsAccurate.push_back(true);
}
}
else
{
c = timesteps[i][0]->FormatGetCycleFromFilename(timesteps[i][0]->GetFilename());
cycleIsAccurate.push_back(true);
c = timesteps[i][0]->FormatGetCycle();
}
cycles.push_back(c);
if ((c == -INT_MAX) || ((i != 0) && (cycles[i] <= cycles[i-1])))
cyclesLookGood = false;
if (c != -INT_MAX)
cIsAccurate = true;
}
else
{
if (cyclesLookGood)
{
cycles.push_back(md->GetCycles()[i]);
cycleIsAccurate.push_back(true);
}
c = md->GetCycles()[i];
cIsAccurate = true;
}
if (md->IsTimeAccurate(i) != true && timesLookGood)
{
double t = -DBL_MAX;
cycles.push_back(c);
cycleIsAccurate.push_back(cIsAccurate);
if (forceReadAllCyclesTimes && !fallBackToTimesFromFilename &&
!canGetGoodTimeFromFilename)
{
t = timesteps[i][0]->FormatGetTime();
double t = -DBL_MAX;
bool tIsAccurate = false;
// If we get back -DBL_MAX from FormatGetTime, this indicates the
// format was unable to return a valid time. So, we fall back
// to using the filenames.
if (t == -DBL_MAX)
{
fallBackToTimesFromFilename = true;
if (md->IsTimeAccurate(i) != true)
{
if (forceReadAllCyclesTimes)
{
if (canGetGoodTimeFromFilename)
t = timesteps[i][0]->FormatGetTimeFromFilename(timesteps[i][0]->GetFilename());
timeIsAccurate.push_back(false);
}
else
{
timeIsAccurate.push_back(true);
}
t = timesteps[i][0]->FormatGetTime();
}
else
{
t = timesteps[i][0]->FormatGetTimeFromFilename(timesteps[i][0]->GetFilename());
timeIsAccurate.push_back(true);
}
times.push_back(t);
if ((t == -DBL_MAX) || ((i != 0) && (times[i] <= times[i-1])))
timesLookGood = false;
if (t != -DBL_MAX)
tIsAccurate = true;
}
else
{
if (timesLookGood)
{
times.push_back(md->GetTimes()[i]);
timeIsAccurate.push_back(true);
}
t = md->GetTimes()[i];
tIsAccurate = true;
}
if (cyclesLookGood == false && timesLookGood == false)
break;
times.push_back(t);
timeIsAccurate.push_back(tIsAccurate);
}
//
......@@ -490,43 +446,24 @@ avtSTSDFileFormatInterface::SetDatabaseMetaData(avtDatabaseMetaData *md,
//
if (md->AreAllCyclesAccurateAndValid(nTimesteps) != true)
{
if (cyclesLookGood)
for (i = 0 ; i < nTimesteps; i++)
{
md->SetCycles(cycles);
for (i = 0 ; i < nTimesteps; i++)
md->SetCycleIsAccurate(cycleIsAccurate[i],i);
}
else
{
cycles.clear();
for (j = 0 ; j < nTimesteps ; j++)
{
cycles.push_back(j);
}
md->SetCycles(cycles);
md->SetCyclesAreAccurate(false);
md->SetCycleIsAccurate(cycleIsAccurate[i],i);
if (cycleIsAccurate[i])
md->SetCycle(i, cycles[i]);
}
}
if (md->AreAllTimesAccurateAndValid(nTimesteps) != true)
{
if (timesLookGood)
{
md->SetTimes(times);
for (i = 0 ; i < nTimesteps; i++)
md->SetTimeIsAccurate(timeIsAccurate[i],i);
md->SetTemporalExtents(times[0], times[times.size() - 1]);
}
else
for (i = 0 ; i < nTimesteps; i++)
{
times.clear();
for (j = 0 ; j < nTimesteps ; j++)
{
times.push_back((double)j);
}
md->SetTimes(times);
md->SetTimesAreAccurate(false);
md->SetTimeIsAccurate(timeIsAccurate[i],i);
if (timeIsAccurate[i])
md->SetTime(i, times[i]);
}
if (timeIsAccurate[0] && timeIsAccurate[nTimesteps-1])
md->SetTemporalExtents(times[0], times[nTimesteps-1]);
}
}
......
......@@ -443,6 +443,9 @@ avtMaterial::avtMaterial(int nMats, const vector<string> &mats, int nzon,
// Mark C. Miller, Wed May 19 21:31:28 PDT 2004
// corrected off by one error in mixed traversals
//
// Kathleen Bonnell, Mon May 23 16:55:35 PDT 2005
// Fix memory leaks.
//
// ****************************************************************************
avtMaterial::avtMaterial(int nTotMats, const int *mats, const char **names,
......@@ -719,6 +722,16 @@ avtMaterial::avtMaterial(int nTotMats, const int *mats, const char **names,
}
if (mixl)
{
delete [] mixv;
delete [] mixm;
delete [] mixn;
delete [] mixz;
}
delete [] ml;
visitTimer->StopTimer(timerHandle, "Constructing avtMaterial object from "
"material map");
......@@ -746,6 +759,9 @@ avtMaterial::avtMaterial(int nTotMats, const int *mats, const char **names,
// Mark C. Miller, Wed May 19 21:31:28 PDT 2004
// corrected off by one error in mixed traversals
//
// Kathleen Bonnell, Mon May 23 16:55:35 PDT 2005
// Fix memory leaks.
//
// ****************************************************************************
avtMaterial::avtMaterial(int nTotMats, const int *mats, char **names,
......@@ -975,6 +991,11 @@ avtMaterial::avtMaterial(int nTotMats, const int *mats, char **names,
delete [] newmixm;
delete [] newmats;
}
delete [] mixv;
delete [] mixm;
delete [] mixz;
delete [] mixn;
delete [] ml;
visitTimer->StopTimer(timerHandle, "Constructing avtMaterial object from "
"dense vfrac arrays");
......
......@@ -314,6 +314,9 @@ avtLocateNodeQuery::DeterminePickedNode(vtkDataSet *ds, int foundCell, float *pp
// Kathleen Bonnell, Fri May 13 15:16:12 PDT 2005
// Fix memory leak.
//
// Kathleen Bonnell, Mon May 23 12:17:37 PDT 2005
// Arg origNode was not getting set.
//
// ****************************************************************************
int
......@@ -347,18 +350,18 @@ avtLocateNodeQuery::FindClosestPoint(vtkDataSet *ds, const int isectedCell,
vtkIdList *cellPts = vtkIdList::New();
ds->GetCellPoints(isectedCell, cellPts);
int comp = origNodes->GetNumberOfComponents()-1;
int oNode = -1;
for (int i = 0; i < ncp && oNode == -1; i++)
origNode = -1;
for (int i = 0; i < ncp && origNode == -1; i++)
{
id = closestPoints->GetId(i);
oNode = (int)origNodes->GetComponent(id, comp);
if (oNode != -1 && (cellPts->IsId(id) == -1))
origNode = (int)origNodes->GetComponent(id, comp);
if (origNode != -1 && (cellPts->IsId(id) == -1))
{
//
// We only want to consider nodes that are part of
// the isected cell.
//
oNode = -1;
origNode = -1;
}
}
cellPts->Delete();
......
......@@ -1182,6 +1182,9 @@ avtSAMRAIFileFormat::ReadMatSpecFractions(int patch, string mat_name,
// Modify the allocation of an array of float pointers so that it
// compiles on all platforms.
//
// Kathleen Bonnell, Mon May 23 16:55:35 PDT 2005
// Fix memory leaks.
//
// ****************************************************************************
avtMaterial *
......@@ -1305,6 +1308,7 @@ avtSAMRAIFileFormat::GetMaterial(int patch, const char *matObjName)
bytesInFile = 0.0;
bytesInMem = (ncells * sizeof(int));
delete [] matlist;
}
else
......@@ -1567,6 +1571,9 @@ avtSAMRAIFileFormat::DebugMixedMaterials(int ncells, int* &matfield,
// Mark C. Miller, Wed Jan 7 11:35:37 PST 2004
// Added stuff to compute amount of compression achieved
//
// Kathleen Bonnell, Mon May 23 16:55:35 PDT 2005
// Fix memory leaks.
//
// ****************************************************************************
avtSpecies *
......@@ -1687,6 +1694,9 @@ avtSAMRAIFileFormat::GetSpecies(int patch, const char *specObjName)
<< bytesInFile / bytesInMem << "x [cummulative = "
<< bytesInFileTotal / bytesInMemTotal << "x]" << endl;
delete [] mixList;
delete [] specList;
return spec;
}
......@@ -1761,10 +1771,13 @@ avtSAMRAIFileFormat::GetSpecies(int patch, const char *specObjName)
for (j = 0; j < numSpecs; j++)
SAFE_DELETE(matSpecFracs[i][j]);
}
SAFE_DELETE(matSpecFracs[i]);
currPatchMatId++;
}
}
free(species_mf);
SAFE_DELETE(mixList);
SAFE_DELETE(specList);
bytesInMem = (mat->GetMixlen() + ncells) * sizeof(int) + nspecies_mf * sizeof(float);
bytesInFileTotal += bytesInFile;
......
......@@ -295,6 +295,9 @@ avtVistaAle3dFileFormat::GetFileNameForRead(int dom, char *fileName, int size)
// Mark C. Miller, Wed May 19 10:56:11 PDT 2004
// Added support for 2D meshes
//
// Kathleen Bonnell, Mon May 23 16:55:35 PDT 2005
// Fix memory leaks.
//
// ****************************************************************************
void
......@@ -384,7 +387,7 @@ avtVistaAle3dFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md)
// Add the GLOBAL mesh object
//
avtMeshMetaData *mesh = new avtMeshMetaData;
mesh->name = CXX_strdup(top->child[0]->text);
mesh->name = top->child[0]->text;
mesh->meshType = AVT_UNSTRUCTURED_MESH;
mesh->topologicalDimension = spatialDim;
mesh->spatialDimension = spatialDim;
......@@ -496,6 +499,7 @@ avtVistaAle3dFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md)
matNames.push_back(matNodes[i]->text);
StringHelpers::GroupStrings(matNames, matGroups, groupNames, 3, "");
delete [] matNodes;
//
// Process the group names to extract either names or numbers
// and populate this object's knowledge of materials
......@@ -819,6 +823,9 @@ avtVistaAle3dFileFormat::GetMaterial(int domain, const char *var)
// Mark C. Miller, Wed May 19 10:56:11 PDT 2004
// Added support for 2D meshes
//
// Kathleen Bonnell, Mon May 23 16:55:35 PDT 2005
// Fix memory leaks.
//
// ****************************************************************************
vtkDataSet *
......@@ -937,6 +944,7 @@ avtVistaAle3dFileFormat::GetMesh(int domain, const char *meshname)
ugrid->InsertNextCell(vtkCellType, numNodesPerElem, &elemToNode[i*numNodesPerElem]);
}
points->Delete();
delete [] elemToNode;
return ugrid;
}
......
......@@ -277,6 +277,9 @@ avtVistaDiabloFileFormat::GetFileNameForRead(int dom, char *fileName, int size)
// Mark C. Miller, Thu Apr 21 09:37:41 PDT 2005
// Fixed memory leaks
//
// Kathleen Bonnell, Mon May 23 16:55:35 PDT 2005
// Fixed memory leaks.
//
// ****************************************************************************
void
......@@ -383,7 +386,7 @@ avtVistaDiabloFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md)
// Add the GLOBAL mesh object
//
avtMeshMetaData *mesh = new avtMeshMetaData;
mesh->name = CXX_strdup(top->child[0]->text);
mesh->name = top->child[0]->text;
mesh->meshType = AVT_UNSTRUCTURED_MESH;
mesh->topologicalDimension = spatialDim;
mesh->spatialDimension = spatialDim;
......@@ -422,6 +425,7 @@ avtVistaDiabloFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md)
fieldNames.push_back(tmpFieldName);
delete [] tmpFieldName;
}