Commit 8f9af135 authored by hrchilds's avatar hrchilds

Update from March 13, 2005

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@430 18c085ea-50e0-402c-830e-de6fd14e8384
parent 791c6777
......@@ -35,6 +35,9 @@ using std::vector;
// Hank Childs, Mon Sep 30 15:06:42 PDT 2002
// Initialize materials to NULL.
//
// Hank Childs, Sun Mar 13 10:43:10 PST 2005
// Initialize species to NULL.
//
// ****************************************************************************
avtDatasetCollection::avtDatasetCollection(int nd)
......@@ -47,15 +50,20 @@ avtDatasetCollection::avtDatasetCollection(int nd)
vtkds = new vtkDataSet**[nDomains];
avtds = new avtDataTree_p[nDomains];
materials = new avtMaterial*[nDomains];
species = new avtSpecies*[nDomains];
for (int i = 0 ; i < nDomains ; i++)
{
vtkds[i] = NULL;
avtds[i] = NULL;
materials[i] = NULL;
species[i] = NULL;
}
mixvars = new vector<void_ref_ptr>[nDomains];
materialsShouldBeFreed = false;
speciesShouldBeFreed = false;
}
......@@ -76,6 +84,9 @@ avtDatasetCollection::avtDatasetCollection(int nd)
// Hank Childs, Thu Jul 4 13:24:11 PDT 2002
// Add support for multiple mixed variables.
//
// Hank Childs, Sun Mar 13 10:43:53 PST 2005
// Free up materials and species if we own them.
//
// ****************************************************************************
avtDatasetCollection::~avtDatasetCollection()
......@@ -96,6 +107,11 @@ avtDatasetCollection::~avtDatasetCollection()
vtkds[i] = NULL;
}
avtds[i] = NULL;
if (materialsShouldBeFreed && materials[i] != NULL)
delete materials[i];
if (speciesShouldBeFreed && species[i] != NULL)
delete species[i];
}
delete [] vtkds;
vtkds = NULL;
......@@ -103,6 +119,8 @@ avtDatasetCollection::~avtDatasetCollection()
avtds = NULL;
delete [] materials;
materials = NULL;
delete [] species;
species = NULL;
delete [] mixvars;
mixvars = NULL;
}
......
......@@ -37,6 +37,9 @@ class avtMixedVariable;
// Brad Whitlock, Mon Jul 15 16:27:25 PST 2002
// Added API.
//
// Hank Childs, Sun Mar 13 10:41:17 PST 2005
// Fixed problem with memory leak.
//
// ****************************************************************************
struct DATABASE_API avtDatasetCollection
......@@ -61,17 +64,19 @@ struct DATABASE_API avtDatasetCollection
avtDataTree_p AssembleDataTree(
std::vector<int> &);
void SetMaterial(int i,
avtMaterial *mat)
void SetMaterial(int i,avtMaterial *mat)
{ materials[i] = mat; };
avtMaterial *GetMaterial(int i)
{ return materials[i]; };
void MaterialsShouldBeFreed(void)
{materialsShouldBeFreed = true;};
void SetSpecies(int i,
avtSpecies *spec)
void SetSpecies(int i, avtSpecies *spec)
{ species[i] = spec; };
avtSpecies *GetSpecies(int i)
{ return species[i]; };
void SpeciesShouldBeFreed(void)
{speciesShouldBeFreed = true;};
void AddMixVar(int i, void_ref_ptr mix);
void_ref_ptr GetMixVar(int i, std::string);
......@@ -85,6 +90,8 @@ struct DATABASE_API avtDatasetCollection
avtMaterial **materials;
avtSpecies **species;
std::vector<void_ref_ptr> *mixvars;
bool materialsShouldBeFreed;
bool speciesShouldBeFreed;
};
......
......@@ -228,6 +228,9 @@ class PickVarInfo;
// indicating whether or not they can safely do collective communication
// (typically for error handling) or whether they should blow it off.
//
// Hank Childs, Fri Mar 11 11:21:57 PST 2005
// Fix memory leak with non-cachable variables.
//
// ****************************************************************************
class DATABASE_API avtGenericDatabase : public avtDatasetDatabase
......@@ -262,6 +265,8 @@ class DATABASE_API avtGenericDatabase : public avtDatasetDatabase
protected:
avtFileFormatInterface *Interface;
avtVariableCache cache;
vtkDataArray *nonCachableVariableReference;
vtkDataSet *nonCachableMeshReference;
int lastTimestep;
......@@ -446,6 +451,9 @@ class DATABASE_API avtGenericDatabase : public avtDatasetDatabase
void AssociateBounds(vtkDataSet *);
void ScaleMesh(vtkDataSet *);
void ManageMemoryForNonCachableVar(vtkDataArray *);
void ManageMemoryForNonCachableMesh(vtkDataSet *);
};
......
......@@ -103,6 +103,9 @@ avtGradientFilter::~avtGradientFilter()
// Hank Childs, Fri Mar 4 08:21:04 PST 2005
// Create centering conversion modules if needed.
//
// Hank Childs, Fri Mar 11 16:01:21 PST 2005
// Fix memory leak.
//
// ****************************************************************************
vtkDataArray *
......@@ -199,6 +202,7 @@ avtGradientFilter::DeriveVariable(vtkDataSet *in_ds)
nodeValue, in_ds, scalarValues,
neighborCellIds);
neighborCellIds->Delete();
results->SetTuple3(nodeId, xComponent, yComponent, zComponent);
}
......
......@@ -274,6 +274,9 @@ avtCondenseDatasetFilter::ExecuteData(vtkDataSet *in_ds, int, std::string)
// Do not set outputs of filters to NULL, since this will prevent them
// from re-executing correctly in DLB-mode.
//
// Hank Childs, Fri Mar 11 07:37:05 PST 2005
// Fix non-problem size leak introduced with last fix.
//
// ****************************************************************************
void
......@@ -282,9 +285,14 @@ avtCondenseDatasetFilter::ReleaseData(void)
avtStreamer::ReleaseData();
rpfPD->SetInput(NULL);
rpfPD->SetOutput(vtkPolyData::New());
vtkPolyData *p = vtkPolyData::New();
rpfPD->SetOutput(p);
p->Delete();
rpfUG->SetInput(NULL);
rpfUG->SetOutput(vtkUnstructuredGrid::New());
vtkUnstructuredGrid *u = vtkUnstructuredGrid::New();
rpfUG->SetOutput(u);
u->Delete();
}
......@@ -987,6 +987,9 @@ avtContourFilter::CreateLabels()
// Hank Childs, Sun Mar 6 08:18:53 PST 2005
// Removed cd2pd.
//
// Hank Childs, Fri Mar 11 07:37:05 PST 2005
// Fix non-problem size leak introduced with last fix.
//
// ****************************************************************************
void
......@@ -995,7 +998,9 @@ avtContourFilter::ReleaseData(void)
avtDataTreeStreamer::ReleaseData();
cf->SetInput(NULL);
cf->SetOutput(vtkPolyData::New());
vtkPolyData *p = vtkPolyData::New();
cf->SetOutput(p);
p->Delete();
}
......@@ -60,13 +60,13 @@ using std::vector;
// Hank Childs, Wed Oct 15 19:17:11 PDT 2003
// Added forceFaceConsolidation.
//
// Hank Childs, Fri Mar 11 08:07:26 PST 2005
// Removed data member filters.
//
// ****************************************************************************
avtFacelistFilter::avtFacelistFilter()
{
rf = vtkRectilinearGridFacelistFilter::New();
sf = vtkStructuredGridFacelistFilter::New();
uf = vtkUnstructuredGridFacelistFilter::New();
useFacelists = true;
create3DCellNumbers = false;
forceFaceConsolidation = false;
......@@ -91,25 +91,13 @@ avtFacelistFilter::avtFacelistFilter()
// I modified the class to use vtkUnstructuredGridFacelistFilter instead
// of vtkGeometryFilter for unstructured grids.
//
// Hank Childs, Fri Mar 11 08:07:26 PST 2005
// Removed data member filters.
//
// ****************************************************************************
avtFacelistFilter::~avtFacelistFilter()
{
if (rf != NULL)
{
rf->Delete();
rf = NULL;
}
if (sf != NULL)
{
sf->Delete();
sf = NULL;
}
if (uf != NULL)
{
uf->Delete();
uf = NULL;
}
}
// ****************************************************************************
......@@ -144,12 +132,17 @@ avtFacelistFilter::SetCreate3DCellNumbers(bool create)
// Programmer: Hank Childs
// Creation: October 15, 2003
//
// Modifications:
//
// Hank Childs, Fri Mar 11 08:07:26 PST 2005
// Do not call method for rectilinear facelist filter, since it is now
// instantiated on the fly.
//
// ****************************************************************************
void
avtFacelistFilter::SetForceFaceConsolidation(bool afc)
{
forceFaceConsolidation = afc;
rf->SetForceFaceConsolidation(afc ? 1 : 0);
}
......@@ -338,33 +331,35 @@ avtFacelistFilter::ExecuteData(vtkDataSet *in_ds, int domain, std::string)
// Hank Childs, Wed May 5 16:18:44 PDT 2004
// Do not prevent normal calculation for rectilinear grids.
//
// Hank Childs, Fri Mar 11 08:11:03 PST 2005
// Instantiate VTK filters on the fly.
//
// ****************************************************************************
vtkDataSet *
avtFacelistFilter::Take3DFaces(vtkDataSet *in_ds, int domain)
{
vtkPolyData *pd = vtkPolyData::New();
vtkDataSet *out_ds = NULL;
bool mustDeReference = false;
vtkPolyData *pd = vtkPolyData::New();
bool hasCellData = (in_ds->GetCellData()->GetNumberOfArrays() > 0
? true : false);
vtkRectilinearGridFacelistFilter *rf = vtkRectilinearGridFacelistFilter::New();
rf->SetForceFaceConsolidation(forceFaceConsolidation ? 1 : 0);
vtkStructuredGridFacelistFilter *sf = vtkStructuredGridFacelistFilter::New();
vtkUnstructuredGridFacelistFilter *uf = vtkUnstructuredGridFacelistFilter::New();
switch (in_ds->GetDataObjectType())
{
case VTK_RECTILINEAR_GRID:
rf->SetInput((vtkRectilinearGrid *) in_ds);
rf->SetOutput(pd);
rf->Update();
out_ds = pd;
mustDeReference = true;
out_ds = rf->GetOutput();
break;
case VTK_STRUCTURED_GRID:
sf->SetInput((vtkStructuredGrid *) in_ds);
sf->SetOutput(pd);
sf->Update();
out_ds = pd;
mustDeReference = true;
out_ds = sf->GetOutput();
break;
case VTK_UNSTRUCTURED_GRID:
......@@ -399,7 +394,6 @@ avtFacelistFilter::Take3DFaces(vtkDataSet *in_ds, int domain)
{
fl->CalcFacelist((vtkUnstructuredGrid *) in_ds, pd);
out_ds = pd;
mustDeReference = true;
}
CATCH (BadIndexException)
{
......@@ -416,10 +410,8 @@ avtFacelistFilter::Take3DFaces(vtkDataSet *in_ds, int domain)
debug5 << "Ugrid forced to calculate facelist for domain "
<< domain << endl;
uf->SetInput((vtkUnstructuredGrid *) in_ds);
uf->SetOutput(pd);
uf->Update();
out_ds = pd;
mustDeReference = true;
out_ds = uf->GetOutput();
}
}
break;
......@@ -430,18 +422,17 @@ avtFacelistFilter::Take3DFaces(vtkDataSet *in_ds, int domain)
debug1 << "Unknown meshtype encountered in facelist filter, passing "
<< "input through as output." << endl;
out_ds = in_ds;
mustDeReference = false;
break;
}
ManageMemory(out_ds);
if (mustDeReference)
{
out_ds->Delete();
}
debug4 << "Facelist filter reduction for domain " << domain
<< ": input has " << in_ds->GetNumberOfCells() << " cells, out has "
<< out_ds->GetNumberOfCells() << endl;
pd->Delete();
rf->Delete();
sf->Delete();
uf->Delete();
return out_ds;
}
......@@ -473,6 +464,9 @@ avtFacelistFilter::Take3DFaces(vtkDataSet *in_ds, int domain)
// Use the rectilinear grid facelist filter since it can do face
// consolidation.
//
// Hank Childs, Fri Mar 11 08:11:03 PST 2005
// Instantiate VTK filters on the fly.
//
// ****************************************************************************
vtkDataSet *
......@@ -505,11 +499,14 @@ avtFacelistFilter::Take2DFaces(vtkDataSet *in_ds)
//
if (dstype == VTK_RECTILINEAR_GRID)
{
vtkRectilinearGridFacelistFilter *rf = vtkRectilinearGridFacelistFilter::New();
rf->SetForceFaceConsolidation(forceFaceConsolidation ? 1 : 0);
rf->SetInput((vtkRectilinearGrid *) in_ds);
rf->SetOutput(out_ds);
out_ds->Update();
rf->SetOutput(NULL);
out_ds->SetSource(NULL);
rf->Delete();
}
else if (dstype == VTK_STRUCTURED_GRID)
{
......@@ -790,37 +787,6 @@ avtFacelistFilter::RefashionDataObjectInfo(void)
}
// ****************************************************************************
// Method: avtFacelistFilter::ReleaseData
//
// Purpose:
// Releases any problem sized data being stored in the filter.
//
// Programmer: Hank Childs
// Creation: September 10, 2002
//
// Modifications:
//
// Hank Childs, Fri Mar 4 08:12:25 PST 2005
// Do not set outputs of filters to NULL, since this will prevent them
// from re-executing correctly in DLB-mode.
//
// ****************************************************************************
void
avtFacelistFilter::ReleaseData(void)
{
avtStreamer::ReleaseData();
rf->SetInput(NULL);
rf->SetOutput(vtkPolyData::New());
sf->SetInput(NULL);
sf->SetOutput(vtkPolyData::New());
uf->SetInput(NULL);
uf->SetOutput(vtkPolyData::New());
}
// ****************************************************************************
// Method: avtFacelistFilter::PerformRestriction
//
......
......@@ -58,6 +58,9 @@ class avtMultiFacelist;
// Kathleen Bonnell, Fri Feb 18 11:13:16 PST 2005
// Added ConvertToPolys.
//
// Hank Childs, Fri Mar 11 08:07:26 PST 2005
// Remove data member filters. Also remove ReleaseData.
//
// ****************************************************************************
class AVTFILTERS_API avtFacelistFilter : public avtStreamer
......@@ -70,15 +73,11 @@ class AVTFILTERS_API avtFacelistFilter : public avtStreamer
{ return "avtFacelistFilter"; };
virtual const char *GetDescription(void)
{ return "Calculating external faces"; };
virtual void ReleaseData(void);
void SetCreate3DCellNumbers(bool);
void SetForceFaceConsolidation(bool);
protected:
vtkRectilinearGridFacelistFilter *rf;
vtkStructuredGridFacelistFilter *sf;
vtkUnstructuredGridFacelistFilter *uf;
bool useFacelists;
bool create3DCellNumbers;
int forceFaceConsolidation;
......
......@@ -8,6 +8,8 @@
#include <visit-config.h>
#include <vtkImageData.h>
#include <avtCommonDataFunctions.h>
#include <avtDataset.h>
#include <avtDatasetExaminer.h>
......@@ -228,6 +230,9 @@ avtRayTracer::SetGradientBackgroundColors(const float bg1[3],
// Hank Childs, Thu Dec 9 17:15:44 PST 2004
// Cast rays in tiles for big images ['1948].
//
// Hank Childs, Sun Mar 13 11:16:20 PST 2005
// Fix memory leak.
//
// ****************************************************************************
void
......@@ -342,8 +347,10 @@ avtRayTracer::Execute(void)
if (PAR_Rank() == 0)
{
whole_image = new avtImage(this);
whole_image->GetImage() = avtImageRepresentation::NewImage(screen[0],
screen[1]);
vtkImageData *img = avtImageRepresentation::NewImage(screen[0],
screen[1]);
whole_image->GetImage() = img;
img->Delete();
}
for (int i = 0 ; i < numDivisions ; i++)
for (int j = 0 ; j < numDivisions ; j++)
......
......@@ -343,6 +343,9 @@ avtResampleFilter::BypassResample(void)
// Added support for using bounds from attributes. Also set up arbitrator
// if necessary.
//
// Hank Childs, Sun Mar 13 10:07:07 PST 2005
// Fix memory leak.
//
// ****************************************************************************
void
......@@ -581,6 +584,7 @@ avtResampleFilter::ResampleInput(void)
SetOutputDataTree(dummy);
}
rg->Delete();
for (i = 0 ; i < effectiveVars ; i++)
{
vars[i]->Delete();
......
......@@ -229,6 +229,9 @@ avtSurfaceFilter::Equivalent(const AttributeGroup *a)
// Hank Childs, Fri Mar 4 08:47:07 PST 2005
// Create cd2pd on an as-needed basis.
//
// Hank Childs, Wed Mar 9 15:45:44 PST 2005
// Fix memory leak.
//
// ****************************************************************************
vtkDataSet *
......@@ -349,6 +352,10 @@ avtSurfaceFilter::ExecuteData(vtkDataSet *inDS, int, std::string)
if (cd2pd != NULL)
cd2pd->Delete();
ManageMemory(outUG);
outUG->Delete();
return (vtkDataSet*) outUG;
}
......@@ -714,6 +721,9 @@ avtSurfaceFilter::CalculateScaleValues(double *de, double *se)
// Do not set outputs of filters to NULL, since this will prevent them
// from re-executing correctly in DLB-mode. Also removed cd2pd.
//
// Hank Childs, Fri Mar 11 07:37:05 PST 2005
// Fix non-problem size leak introduced with last fix.
//
// ****************************************************************************
void
......@@ -722,7 +732,9 @@ avtSurfaceFilter::ReleaseData(void)
avtStreamer::ReleaseData();
filter->SetInput(NULL);
filter->SetOutput(vtkUnstructuredGrid::New());
vtkUnstructuredGrid *u = vtkUnstructuredGrid::New();
filter->SetOutput(u);
u->Delete();
filter->SetinScalars(NULL);
}
......
......@@ -73,6 +73,11 @@ avtTiledImageCompositor::~avtTiledImageCompositor()
// Programmer: Jeremy Meredith
// Creation: August 30, 2004
//
// Modifications:
//
// Hank Childs, Sun Mar 13 11:19:18 PST 2005
// Fix memory leak.
//
// ****************************************************************************
void
......@@ -141,6 +146,8 @@ avtTiledImageCompositor::Execute(void)
SetOutputImage(theOutput);
// Free the memory (yes, it is safe not to check for NULL in C++)
if (outputImageData != NULL)
outputImageData->Delete();
delete[] pixelSizes;
delete[] displacements;
#else
......
......@@ -967,13 +967,17 @@ avtDataSpecification::GetSecondaryVariablesWithoutDuplicates(void)
// Brad Whitlock, Mon Nov 1 16:07:37 PST 2004
// I added a return statement since the return type is int.
//
// Hank Childs, Fri Mar 11 10:54:13 PST 2005
// Return the index of the selection, since that is what most callers count
// on.
//
// ****************************************************************************
int
avtDataSpecification::AddDataSelection(avtDataSelection *sel)
{
selList.push_back(sel);
return selList.size();
return selList.size()-1;
}
// ****************************************************************************
......
......@@ -157,6 +157,11 @@ avtTerminatingDatasetSource::FetchData(avtDataSpecification_p spec)
// Added check for existence of true spatial extents before attempting to
// merge cummulative
//
// Hank Childs, Fri Mar 11 08:16:49 PST 2005
// Initialize 6 values for vectors, even though we only use 2, since that
// fixes a UMR in avtExtents, where it copies 6 values due to legacy reasons
// (but still only uses 2).
//
// ****************************************************************************
void
......@@ -194,7 +199,11 @@ avtTerminatingDatasetSource::MergeExtents(vtkDataSet *ds)
}
int nvars = atts.GetNumberOfVariables();
double dextents[2];
// We will probably use only 2 of the 6. But this avoids a UMR where
// the avtExtents object copies 6 values for vectors (even though it only
// uses the first 2 -- but that's a bigger battle.)
double dextents[6] =
{ FLT_MAX, -FLT_MAX, FLT_MAX, -FLT_MAX, FLT_MAX, -FLT_MAX };
for (int i = 0 ; i < nvars ; i++)
{
const char *vname = atts.GetVariableName(i).c_str();
......
......@@ -547,6 +547,9 @@ avtPlot::Execute(avtDataObjectReader_p reader)
// Hank Childs, Wed Mar 2 11:11:59 PST 2005
// Pass a pipeline specification to the sink, not a data specification.
//
// Hank Childs, Sun Mar 13 11:13:01 PST 2005
// Fix memory leak.
//
// ****************************************************************************
avtActor_p
......@@ -647,6 +650,7 @@ avtPlot::Execute(avtDataObjectReader_p reader, avtDataObject_p dob)
// create some bogus geometry data
vtkPolyData *emptyPolyData = vtkPolyData::New();
avtSourceFromDataset emptySource((vtkDataSet**)&emptyPolyData,1);
emptyPolyData->Delete();
avtDataObject_p geo = emptySource.GetOutput();
// although we're creating bogus geometry data here, we still need
......@@ -687,6 +691,7 @@ avtPlot::Execute(avtDataObjectReader_p reader, avtDataObject_p dob)
// create some bogus geometry data
vtkPolyData *emptyPolyData = vtkPolyData::New();
avtSourceFromDataset emptySource((vtkDataSet**)&emptyPolyData,1);
emptyPolyData->Delete();
avtDataObject_p geo = emptySource.GetOutput();
// although we're creating bogus geometry data here, we still need
......
......@@ -8,8 +8,6 @@
#include <vtkIntArray.h>
#include <vtkPointData.h>
#include <vtkPoints.h>
#include <vtkVisItUtility.h>
// ****************************************************************************
......@@ -53,6 +51,9 @@ avtActualNodeCoordsQuery::~avtActualNodeCoordsQuery()
// Kathleen Bonnell, Wed Jun 16 13:54:28 PDT 2004
// avtOriginalNode numbers is now of type vtkIntArray.
//
// Hank Childs, Thu Mar 10 10:32:40 PST 2005
// Fix memory leak.
//
// ****************************************************************************
void
......@@ -109,7 +110,7 @@ avtActualNodeCoordsQuery::Execute(vtkDataSet *ds, const int dom)
if (actualId >= 0 && actualId < ds->GetNumberOfPoints())
{
vtkVisItUtility::GetPoints(ds)->GetPoint(actualId, actualCoords);
ds->GetPoint(actualId, actualCoords);
}
else
{
......
......@@ -8,7 +8,6 @@
#include <vtkIdList.h>
#include <vtkPoints.h>
#include <vtkPointLocator.h>
#include <vtkVisItUtility.h>
#include <avtTerminatingSource.h>
......@@ -106,6 +105,9 @@ avtCurvePickQuery::PostExecute(void)
// Creation: December 2, 2003
//
// Modifications:
//
// Hank Childs, Thu Mar 10 10:30:35 PST 2005
// Fix memory leak.
//
// ****************************************************************************
......@@ -132,11 +134,10 @@ avtCurvePickQuery::Execute(vtkDataSet *ds, const int dom)
if (pointId != -1)
{
vtkPoints *points = vtkVisItUtility::GetPoints(ds);
float *p;
if (pickAtts.GetPickType() == PickAttributes::CurveNode)
{
p = points->GetPoint(pointId);
p = ds->GetPoint(pointId);
pt1[0] = p[0];
<