]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To improve memory management
authorapo <apo@opencascade.com>
Fri, 23 Sep 2005 05:49:02 +0000 (05:49 +0000)
committerapo <apo@opencascade.com>
Fri, 23 Sep 2005 05:49:02 +0000 (05:49 +0000)
src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx
src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx

index c4e69e3553af227d859b45a93de1cda98fb3972e..1b30eae45012fe225c5824834773a94f2a2e0e81 100755 (executable)
 
 #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 <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 <vtkImageData.h>
 
 #include <GL/glext.h>
 //#include <GL/glx.h>
@@ -59,7 +58,7 @@
 #include <vector>
 
 #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();
index 45a96bb1bc620fdafc98d1d37df64d72ee0f1f92..694b5c4664b594e88627550fc08c310997857990 100755 (executable)
@@ -34,7 +34,8 @@
 
 #include <GL/gl.h>
 
-#include "vtkConfigure.h"
+#include <vtkSmartPointer.h>
+#include <vtkConfigure.h>
 
 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<vtkImageData> ImageData;
 
   bool              IsUsingOpenGLMapper;
 };