From: apo Date: Fri, 23 Sep 2005 05:49:02 +0000 (+0000) Subject: To improve memory management X-Git-Tag: BR-D5-38-2003_D2005-12-10~154 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f5db3c345c2ace5994c4a7762220188397259d9c;p=modules%2Fvisu.git To improve memory management --- diff --git a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx index c4e69e35..1b30eae4 100755 --- a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx +++ b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx @@ -27,26 +27,25 @@ #include "VISU_OpenGLPointSpriteMapper.hxx" -#include "vtkCellArray.h" -#include "vtkCellData.h" -#include "vtkCommand.h" -#include "vtkDataArray.h" -#include "vtkFloatArray.h" -#include "vtkMatrix4x4.h" -#include "vtkObjectFactory.h" -#include "vtkOpenGLRenderer.h" -#include "vtkPlane.h" -#include "vtkPlaneCollection.h" -#include "vtkPointData.h" -#include "vtkPolyData.h" -#include "vtkPolygon.h" -#include "vtkProperty.h" -#include "vtkTimerLog.h" -#include "vtkTriangle.h" -#include "vtkOpenGLRenderWindow.h" -#include "vtkOpenGLTexture.h" -#include "vtkXMLImageDataReader.h" -#include "vtkImageData.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include //#include @@ -59,7 +58,7 @@ #include #ifndef VTK_IMPLEMENT_MESA_CXX -vtkCxxRevisionMacro(VISU_OpenGLPointSpriteMapper, "$Revision$"); +vtkCxxRevisionMacro(VISU_OpenGLPointSpriteMapper, "Revision$"); vtkStandardNewMacro(VISU_OpenGLPointSpriteMapper); #endif @@ -133,8 +132,6 @@ VISU_OpenGLPointSpriteMapper::VISU_OpenGLPointSpriteMapper() this->PointSpriteMaxSize = 50.0; this->PointSpriteMagnification = 1.0; - this->ImageData = 0; - this->XMLImageDataReader = vtkXMLImageDataReader::New(); this->PointSpriteTexture = 0; this->IsUsingOpenGLMapper = false; } @@ -157,16 +154,6 @@ VISU_OpenGLPointSpriteMapper::~VISU_OpenGLPointSpriteMapper() delete [] this->SizeChannelArray; this->SizeChannelArray = NULL; } - if (this->ImageData) - { - this->ImageData->Delete(); - this->ImageData = NULL; - } - if (this->XMLImageDataReader) - { - this->XMLImageDataReader->Delete(); - this->XMLImageDataReader = NULL; - } } //----------------------------------------------------------------------------- void VISU_OpenGLPointSpriteMapper::ShallowCopy( vtkAbstractMapper* mapper ) @@ -740,24 +727,29 @@ void VISU_OpenGLPointSpriteMapper::CleanupSprites() //glDisable( GL_VERTEX_PROGRAM_ARB ); } + + //----------------------------------------------------------------------------- -void VISU_OpenGLPointSpriteMapper::SetImageData( vtkImageData* theImageData ) +void +VISU_OpenGLPointSpriteMapper +::SetImageData( vtkImageData* theImageData ) { - //cout << "VISU_OpenGLPointSpriteMapper::SetImageData " << this << " " << theImageData << endl; - //theImageData->Print( cout ); - this->ImageData = theImageData; +} - //cout << this->ImageData << endl; +vtkImageData* +VISU_OpenGLPointSpriteMapper +::GetImageData() +{ + return this->ImageData.GetPointer(); } + + //----------------------------------------------------------------------------- void VISU_OpenGLPointSpriteMapper::InitTexture() { - //cout << "VISU_OpenGLPointSpriteMapper::InitTexture " << this << " " << this->ImageData << endl; - - //this->ImageData->Print( cout ); - - unsigned char* dataPtr = (unsigned char*)this->ImageData->GetScalarPointer(); + int* aSize = GetImageData()->GetDimensions(); + unsigned char* dataPtr = (unsigned char*)GetImageData()->GetScalarPointer(); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); @@ -766,7 +758,7 @@ void VISU_OpenGLPointSpriteMapper::InitTexture() glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 16, 16, 0, + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, aSize[0], aSize[1], 0, GL_RGBA, GL_UNSIGNED_BYTE, dataPtr ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); @@ -787,10 +779,7 @@ void VISU_OpenGLPointSpriteMapper::DrawPoints(int idx, vtkCellArray *cells, vtkRenderer *ren) { - //this->XMLImageDataReader->SetFileName( "/dn06/salome/ouv/SALOME/TextureAlphaChannel.vti" ); - //vtkImageData* imageData = this->XMLImageDataReader->GetOutput(); - - if( this->ImageData ) + if( this->GetImageData() ) this->InitTexture(); this->InitSprites(); diff --git a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx index 45a96bb1..694b5c46 100755 --- a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx +++ b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx @@ -34,7 +34,8 @@ #include -#include "vtkConfigure.h" +#include +#include class vtkCellArray; class vtkPoints; @@ -154,9 +155,8 @@ public: void SetPointSpriteMaxSize( float ); void SetPointSpriteMagnification( float ); - void SetImageData( vtkImageData* ); - //vtkSetMacro(ImageData, vtkImageData*); - vtkGetMacro(ImageData, vtkImageData*); + void SetImageData(vtkImageData* theImageData); + vtkImageData* GetImageData(); protected: VISU_OpenGLPointSpriteMapper(); @@ -205,10 +205,10 @@ protected: float PointSpriteMaxSize; float PointSpriteMagnification; - vtkXMLImageDataReader* XMLImageDataReader; GLuint PointSpriteTexture; - vtkImageData* ImageData; + + vtkSmartPointer ImageData; bool IsUsingOpenGLMapper; };