Salome HOME
Bug IPAL22927: TC6.5.0: bounding box is not updated for Point Map 3D
[modules/visu.git] / src / PIPELINE / VISU_OpenGLPointSpriteMapper.cxx
index 82d59e3508fa4e0116237ef6105ff3627d6a871c..c25fc6b57a57b947c5f10fc12f81e5dbed005489 100755 (executable)
@@ -1,24 +1,25 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  VISU OBJECT : interactive object for VISU entities implementation
 // File:    VISU_OpenGLPointSpriteMapper.cxx
 // Author:  
@@ -441,7 +442,7 @@ bool VISU_OpenGLPointSpriteMapper::InitExtensions()
   if( this->ExtensionsInitialized )
     return true;
 
-  InitializeARB();
+  IsARBInitialized = InitializeARB();
 
   char* ext = (char*)glGetString( GL_EXTENSIONS );
   //cout << "OpenGL extensions : " << ext << endl;
@@ -742,7 +743,7 @@ void VISU_OpenGLPointSpriteMapper::InitTextures()
   int* aSize = GetImageData()->GetDimensions();
   unsigned char* dataPtr = (unsigned char*)GetImageData()->GetScalarPointer();
   glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, aSize[0], aSize[1], 0,
-               GL_RGBA, GL_UNSIGNED_BYTE, dataPtr );
+                GL_RGBA, GL_UNSIGNED_BYTE, dataPtr );
 
   //glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
   glEnable( GL_TEXTURE_2D );
@@ -906,11 +907,11 @@ struct TCellColors2Color : TColors2Color
 //-----------------------------------------------------------------------------
 template < class TCoordinates >
 void DrawPoints( TCoordinates *theStartPoints,
-                vtkCellArray *theCells,
-                TColorFunctorBase* theColorFunctor,
-                TVertex* theVertexArr,
-                vtkIdType &theCellId,
-                vtkIdType &theVertexId )
+                 vtkCellArray *theCells,
+                 TColorFunctorBase* theColorFunctor,
+                 TVertex* theVertexArr,
+                 vtkIdType &theCellId,
+                 vtkIdType &theVertexId )
 {
   vtkIdType *ptIds = theCells->GetPointer();
   vtkIdType *endPtIds = ptIds + theCells->GetNumberOfConnectivityEntries();
@@ -943,9 +944,9 @@ void DrawPoints( TCoordinates *theStartPoints,
 //-----------------------------------------------------------------------------
 template < class TCoordinates >
 void DrawCellsPoints( vtkPolyData *theInput,
-                     vtkPoints* thePoints,
-                     TColorFunctorBase* theColorFunctor,
-                     TVertex* theVertexArr )
+                      vtkPoints* thePoints,
+                      TColorFunctorBase* theColorFunctor,
+                      TVertex* theVertexArr )
 {
   vtkIdType aCellId = 0, aVertexId = 0;
 
@@ -1024,62 +1025,62 @@ int VISU_OpenGLPointSpriteMapper::Draw(vtkRenderer *theRenderer, vtkActor *theAc
       glPointSize( this->DefaultPointSize );
 
       {
-       TColorFunctorBase* aColorFunctor = NULL;
-       if( colors && this->PointSpriteMode != 1 ) {
-         if ( cellScalars )
-           aColorFunctor = new TCellColors2Color( colors );
-         else
-           aColorFunctor = new TPointColors2Color( colors );
-       } else {
-         aColorFunctor = new TPropertyColor( theActor->GetProperty() );
-       }
-       if ( points->GetDataType() == VTK_FLOAT )
-         ::DrawCellsPoints< float >( input, points, aColorFunctor, aVertexArr );
-       else
-         ::DrawCellsPoints< double >( input, points, aColorFunctor, aVertexArr );
-
-       delete aColorFunctor;
+        TColorFunctorBase* aColorFunctor = NULL;
+        if( colors && this->PointSpriteMode != 1 ) {
+          if ( cellScalars )
+            aColorFunctor = new TCellColors2Color( colors );
+          else
+            aColorFunctor = new TPointColors2Color( colors );
+        } else {
+          aColorFunctor = new TPropertyColor( theActor->GetProperty() );
+        }
+        if ( points->GetDataType() == VTK_FLOAT )
+          ::DrawCellsPoints< float >( input, points, aColorFunctor, aVertexArr );
+        else
+          ::DrawCellsPoints< double >( input, points, aColorFunctor, aVertexArr );
+
+        delete aColorFunctor;
       }
 
       if( this->ExtensionsInitialized ) {
-       GLuint aBufferObjectID = 0;
-       vglGenBuffersARB( 1, &aBufferObjectID );
-       vglBindBufferARB( GL_ARRAY_BUFFER_ARB, aBufferObjectID );
-       
-       int anArrayObjectSize = sizeof( TVertex ) * aTotalConnectivitySize;
-       vglBufferDataARB( GL_ARRAY_BUFFER_ARB, anArrayObjectSize, aVertexArr, GL_STATIC_DRAW_ARB );
-       
-       delete [] aVertexArr;
-       
-       vglBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 );
-       vglBindBufferARB( GL_ARRAY_BUFFER_ARB, aBufferObjectID );
-       
-       glColorPointer( 4, GL_FLOAT, sizeof(TVertex), (void*)0 );
-       glVertexPointer( 3, GL_FLOAT, sizeof(TVertex), (void*)(4*sizeof(GLfloat)) );
-       
-       glEnableClientState( GL_VERTEX_ARRAY );
-       glEnableClientState( GL_COLOR_ARRAY );
-       
-       glDrawArrays( GL_POINTS, 0, aTotalConnectivitySize );
-       
-       glDisableClientState( GL_COLOR_ARRAY );
-       glDisableClientState( GL_VERTEX_ARRAY );
-       
-       vglDeleteBuffersARB( 1, &aBufferObjectID );
+        GLuint aBufferObjectID = 0;
+        vglGenBuffersARB( 1, &aBufferObjectID );
+        vglBindBufferARB( GL_ARRAY_BUFFER_ARB, aBufferObjectID );
+        
+        int anArrayObjectSize = sizeof( TVertex ) * aTotalConnectivitySize;
+        vglBufferDataARB( GL_ARRAY_BUFFER_ARB, anArrayObjectSize, aVertexArr, GL_STATIC_DRAW_ARB );
+        
+        delete [] aVertexArr;
+        
+        vglBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 );
+        vglBindBufferARB( GL_ARRAY_BUFFER_ARB, aBufferObjectID );
+        
+        glColorPointer( 4, GL_FLOAT, sizeof(TVertex), (void*)0 );
+        glVertexPointer( 3, GL_FLOAT, sizeof(TVertex), (void*)(4*sizeof(GLfloat)) );
+        
+        glEnableClientState( GL_VERTEX_ARRAY );
+        glEnableClientState( GL_COLOR_ARRAY );
+        
+        glDrawArrays( GL_POINTS, 0, aTotalConnectivitySize );
+        
+        glDisableClientState( GL_COLOR_ARRAY );
+        glDisableClientState( GL_VERTEX_ARRAY );
+        
+        vglDeleteBuffersARB( 1, &aBufferObjectID );
       } else { // there are not extensions
-       glColorPointer( 4, GL_FLOAT, sizeof(TVertex), aVertexArr );
-       glVertexPointer( 3, GL_FLOAT, sizeof(TVertex), 
-                        (void*)((GLfloat*)((void*)(aVertexArr)) + 4));
-
-       glEnableClientState( GL_VERTEX_ARRAY );
-       glEnableClientState( GL_COLOR_ARRAY );
-       
-       glDrawArrays( GL_POINTS, 0, aTotalConnectivitySize );
-       
-       glDisableClientState( GL_COLOR_ARRAY );
-       glDisableClientState( GL_VERTEX_ARRAY );
-
-       delete [] aVertexArr;
+        glColorPointer( 4, GL_FLOAT, sizeof(TVertex), aVertexArr );
+        glVertexPointer( 3, GL_FLOAT, sizeof(TVertex), 
+                         (void*)((GLfloat*)((void*)(aVertexArr)) + 4));
+
+        glEnableClientState( GL_VERTEX_ARRAY );
+        glEnableClientState( GL_COLOR_ARRAY );
+        
+        glDrawArrays( GL_POINTS, 0, aTotalConnectivitySize );
+        
+        glDisableClientState( GL_COLOR_ARRAY );
+        glDisableClientState( GL_VERTEX_ARRAY );
+
+        delete [] aVertexArr;
       }
     }