Commit a4000f46 authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH: Fixed delete stuff.

parent 7e4b0f09
......@@ -46,7 +46,7 @@ class vtkCellArray;
class vtkCell : public vtkObject
{
public:
vtkCell(): Points(MAX_CELL_SIZE), PointIds(MAX_CELL_SIZE) {};
vtkCell();
void Initialize(int npts, int *pts, vtkPoints *p);
char *GetClassName() {return "vtkCell";};
void PrintSelf(ostream& os, vtkIndent indent);
......
......@@ -31,6 +31,7 @@ class vtkPointSet : public vtkDataSet
{
public:
vtkPointSet();
~vtkPointSet();
vtkPointSet(const vtkPointSet& ps);
char *GetClassName() {return "vtkPointSet";};
void PrintSelf(ostream& os, vtkIndent indent);
......
......@@ -31,6 +31,7 @@ class vtkXRenderWindow : public vtkRenderWindow
{
public:
vtkXRenderWindow();
~vtkXRenderWindow();
char *GetClassName() {return "vtkXRenderWindow";};
void PrintSelf(ostream& os, vtkIndent indent);
......
......@@ -375,11 +375,17 @@ void vtkCyberReader::Execute()
npolygon = newTris->GetNumberOfCells();
vtkDebugMacro(<<"Read "<<nvertex<<" vertices, "<<npolygon<<" polygons");
//
// Send to data out
// Update output and release memory
//
this->SetPoints(newPoints);
newPoints->Delete();
this->SetPolys(newTris);
newTris->Delete();
this->PointData.SetTCoords(newTCoords);
newTCoords->Delete();
this->Squeeze();
//
// Free resources
......
......@@ -13,9 +13,6 @@ written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Methods for cylinder generator
//
#include <math.h>
#include "CylSrc.hh"
#include "FPoints.hh"
......@@ -150,14 +147,20 @@ void vtkCylinderSource::Execute()
} // if capping
//
// Update ourselves
// Update ourselves and release memory
//
this->SetPoints(newPoints);
newPoints->Delete();
this->PointData.SetNormals(newNormals);
newNormals->Delete();
this->PointData.SetTCoords(newTCoords);
newTCoords->Delete();
newPolys->Squeeze(); // since we've estimated size; reclaim some space
this->SetPolys(newPolys);
newPolys->Delete();
}
void vtkCylinderSource::PrintSelf(ostream& os, vtkIndent indent)
......
......@@ -133,11 +133,17 @@ void vtkDividingCubes::Execute()
}
vtkDebugMacro(<< "Created " << NewPts->GetNumberOfPoints() << "points");
//
// Update ourselves
// Update ourselves and release memory
//
this->SetPoints(NewPts);
NewPts->Delete();
this->SetVerts(NewVerts);
NewVerts->Delete();
this->GetPointData()->SetNormals(NewNormals);
NewNormals->Delete();
this->Squeeze();
}
......
......@@ -24,7 +24,7 @@ vtkDataSetToDataSetFilter::vtkDataSetToDataSetFilter()
vtkDataSetToDataSetFilter::~vtkDataSetToDataSetFilter()
{
delete this->DataSet;
this->DataSet->Delete();
}
// Description:
......
......@@ -25,8 +25,8 @@ vtkDataSetMapper::vtkDataSetMapper()
vtkDataSetMapper::~vtkDataSetMapper()
{
// delete internally created objects.
if ( this->GeometryExtractor ) delete this->GeometryExtractor;
if ( this->PolyMapper ) delete this->PolyMapper;
if ( this->GeometryExtractor ) this->GeometryExtractor->Delete();
if ( this->PolyMapper ) this->PolyMapper->Delete();
}
void vtkDataSetMapper::SetInput(vtkDataSet *in)
......
......@@ -127,18 +127,27 @@ void vtkDashedStreamLine::Execute()
} //for this streamer
} //for all streamers
//
// Update ourselves
// Update ourselves and release memory
//
vtkDebugMacro(<<"Created " << newPts->GetNumberOfPoints() << " points, "
<< newLines->GetNumberOfCells() << " lines");
this->SetPoints(newPts);
newPts->Delete();
this->PointData.SetVectors(newVectors);
if ( newScalars ) this->PointData.SetScalars(newScalars);
newVectors->Delete();
if ( newScalars )
{
this->PointData.SetScalars(newScalars);
newScalars->Delete();
}
this->SetLines(newLines);
newLines->Delete();
this->Squeeze();
}
void vtkDashedStreamLine::PrintSelf(ostream& os, vtkIndent indent)
......
......@@ -6,8 +6,6 @@
Date: $Date$
Version: $Revision$
Description:
---------------------------------------------------------------------------
This file is part of the Visualization Toolkit. No part of this file
or its contents may be copied, reproduced or altered in any way
without the express written consent of the authors.
......@@ -15,10 +13,6 @@ without the express written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Methods for Disk generator
//
#include <math.h>
#include "DiskSrc.hh"
#include "vtkMath.hh"
......@@ -86,10 +80,13 @@ void vtkDiskSource::Execute()
}
}
//
// Update ourselves
// Update ourselves and release memory
//
this->SetPoints(newPoints);
newPoints->Delete();
this->SetPolys(newPolys);
newPolys->Delete();
}
void vtkDiskSource::PrintSelf(ostream& os, vtkIndent indent)
......
......@@ -136,8 +136,13 @@ void vtkEdgePoints::Execute()
// created, take care to reclaim memory.
//
this->SetPoints(newPts);
newPts->Delete();
this->SetVerts(newVerts);
newVerts->Delete();
this->PointData.SetScalars(newScalars);
newScalars->Delete();
this->Squeeze();
}
......@@ -147,7 +152,6 @@ void vtkEdgePoints::PrintSelf(ostream& os, vtkIndent indent)
vtkDataSetToPolyFilter::PrintSelf(os,indent);
os << indent << "Contour Value: " << this->Value << "\n";
}
......@@ -13,9 +13,6 @@ written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Methods for elevation filter
//
#include "ElevatF.hh"
#include "vtkMath.hh"
#include "FScalars.hh"
......@@ -94,6 +91,7 @@ void vtkElevationFilter::Execute()
this->PointData.PassData(this->Input->GetPointData());
this->PointData.SetScalars(newScalars);
newScalars->Delete();
}
void vtkElevationFilter::PrintSelf(ostream& os, vtkIndent indent)
......
......@@ -112,11 +112,13 @@ void vtkExtractGeometry::Execute()
}
}
//
// Update ourselves
// Update ourselves and release memory
//
delete [] pointMap;
this->SetPoints(newPts);
newPts->Delete();
this->Squeeze();
}
......
......@@ -164,14 +164,16 @@ void vtkFeatureEdges::Execute()
//
// Update ourselves.
//
if ( this->FeatureEdges ) delete polyNormals;
if ( this->FeatureEdges ) polyNormals->Delete();
this->SetPoints(newPts);
newPts->Delete();
this->SetLines(newLines);
if ( this->Coloring )
this->PointData.SetScalars(newScalars);
else
delete newScalars;
newLines->Delete();
if ( this->Coloring ) this->PointData.SetScalars(newScalars);
newScalars->Delete();
}
void vtkFeatureEdges::PrintSelf(ostream& os, vtkIndent indent)
......
......@@ -153,11 +153,15 @@ void vtkFeatureVertices::Execute()
// Update ourselves.
//
this->SetPoints(newPts);
newPts->Delete();
this->SetVerts(newVerts);
if ( this->Coloring )
this->PointData.SetScalars(newScalars);
else
delete newScalars;
newVerts->Delete();
if ( this->Coloring ) this->PointData.SetScalars(newScalars);
newScalars->Delete();
this->Squeeze();
}
void vtkFeatureVertices::PrintSelf(ostream& os, vtkIndent indent)
......
......@@ -188,20 +188,21 @@ void vtkGeometryFilter::Execute()
this->InsertNextCell(face->GetCellType(), npts, pts);
}
}
delete cellCopy;
cellCopy->Delete();
break;
} //switch
} //if visible
} //for all cells
//
// Update ourselves
// Update ourselves and release memory
//
this->SetPoints(newPts);
newPts->Delete();
this->Squeeze();
if ( cellVis ) delete [] cellVis;
}
void vtkGeometryFilter::PrintSelf(ostream& os, vtkIndent indent)
......
......@@ -48,7 +48,7 @@ void vtkGlyph3D::Execute()
int numPts, numSourcePts, numSourceCells;
int inPtId, i;
vtkPoints *sourcePts;
vtkCellArray *sourceCells;
vtkCellArray *sourceCells, *cells;
vtkFloatPoints *newPts;
vtkFloatScalars *newScalars=NULL;
vtkFloatVectors *newVectors=NULL;
......@@ -90,19 +90,27 @@ void vtkGlyph3D::Execute()
// Setting up for calls to PolyData::InsertNextCell()
if ( (sourceCells=this->Source->GetVerts())->GetNumberOfCells() > 0 )
{
this->SetVerts(new vtkCellArray(numPts*sourceCells->GetSize()));
cells = new vtkCellArray(numPts*sourceCells->GetSize());
this->SetVerts(cells);
cells->Delete();
}
if ( (sourceCells=this->Source->GetLines())->GetNumberOfCells() > 0 )
{
this->SetLines(new vtkCellArray(numPts*sourceCells->GetSize()));
cells = new vtkCellArray(numPts*sourceCells->GetSize());
this->SetLines(cells);
cells->Delete();
}
if ( (sourceCells=this->Source->GetPolys())->GetNumberOfCells() > 0 )
{
this->SetPolys(new vtkCellArray(numPts*sourceCells->GetSize()));
cells = new vtkCellArray(numPts*sourceCells->GetSize());
this->SetPolys(cells);
cells->Delete();
}
if ( (sourceCells=this->Source->GetStrips())->GetNumberOfCells() > 0 )
{
this->SetStrips(new vtkCellArray(numPts*sourceCells->GetSize()));
cells = new vtkCellArray(numPts*sourceCells->GetSize());
this->SetStrips(cells);
cells->Delete();
}
//
// Copy (input scalars) to (output scalars) and either (input vectors or
......@@ -214,12 +222,29 @@ void vtkGlyph3D::Execute()
this->PointData.CopyData(pd,i,ptIncr+i);
}
//
// Update ourselves
// Update ourselves and release memory
//
this->SetPoints(newPts);
this->PointData.SetScalars(newScalars);
this->PointData.SetVectors(newVectors);
this->PointData.SetNormals(newNormals);
newPts->Delete();
if (newScalars)
{
this->PointData.SetScalars(newScalars);
newScalars->Delete();
}
if (newVectors)
{
this->PointData.SetVectors(newVectors);
newVectors->Delete();
}
if (newNormals)
{
this->PointData.SetNormals(newNormals);
newNormals->Delete();
}
this->Squeeze();
}
......
......@@ -68,10 +68,13 @@ void vtkHedgeHog::Execute()
this->PointData.CopyData(pd,ptId,pts[1]);
}
//
// Update ourselves
// Update ourselves and release memory
//
this->SetPoints(newPts);
newPts->Delete();
this->SetLines(newLines);
newLines->Delete();
}
void vtkHedgeHog::PrintSelf(ostream& os, vtkIndent indent)
......
......@@ -174,10 +174,10 @@ void vtkImplicitModeller::Execute()
this->Cap(newScalars);
}
//
// Update self
// Update self and release memory
//
this->PointData.SetScalars(newScalars);
newScalars->Delete();
}
// Description:
......
......@@ -126,6 +126,7 @@ void vtkImplicitTextureCoords::Execute()
this->PointData.PassData(input->GetPointData());
this->PointData.SetTCoords(newTCoords);
newTCoords->Delete();
}
void vtkImplicitTextureCoords::PrintSelf(ostream& os, vtkIndent indent)
......
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