]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
VISU_OpenGLPointSpriteMapper functionality added
authorouv <ouv@opencascade.com>
Tue, 30 Aug 2005 10:02:28 +0000 (10:02 +0000)
committerouv <ouv@opencascade.com>
Tue, 30 Aug 2005 10:02:28 +0000 (10:02 +0000)
src/PIPELINE/VISU_GaussPointsPL.cxx
src/PIPELINE/VISU_GaussPointsPL.hxx

index c4400bdc88f4626a345a055087ae720651172116..233d4e24283cd4ebd4c9c9e17ae220c60d51d27b 100644 (file)
 
 #include "VISU_GaussPointsPL.hxx"
 #include "VISU_PipeLineUtils.hxx"
+#include "VISU_OpenGLPointSpriteMapper.hxx"
+
+#include <vtkPointSource.h>
+#include <vtkElevationFilter.h>
+#include <vtkImageGaussianSource.h>
+#include <vtkXMLImageDataReader.h>
+#include <vtkGeometryFilter.h>
 
 vtkStandardNewMacro(VISU_GaussPointsPL);
 
 VISU_GaussPointsPL::VISU_GaussPointsPL()
-{}
+{
+  myPSMapper = VISU_OpenGLPointSpriteMapper::New();
+  //myPSMapper->DebugOn();
+
+  myGeomFilter = vtkGeometryFilter::New();
+}
+
+VISU_PipeLine::TMapper* VISU_GaussPointsPL::GetMapper()
+{
+  if(GetInput()){
+    if(!myPSMapper->GetInput()){
+      GetInput2()->Update();
+      Build();
+    }
+    myPSMapper->Update();
+  }
+  return myPSMapper;
+}
+
+void VISU_GaussPointsPL::Build()
+{
+  //cout << "VISU_GaussPointsPL::Build" << endl;
+
+  myExtractor->SetInput( GetInput2() );
+  myFieldTransform->SetInput( myExtractor->GetOutput() );
+
+  myPSMapper->SetColorModeToMapScalars();
+  myPSMapper->ScalarVisibilityOn();
+
+  myGeomFilter->SetInput( myFieldTransform->GetUnstructuredGridOutput() );
+  myPSMapper->SetInput( myGeomFilter->GetOutput() );
+  /*
+  // Create lots of points
+  vtkPointSource* blob = vtkPointSource::New();
+  blob->SetRadius( 1 );
+  blob->SetCenter( 0.0, 0.0, 0.0 );
+  blob->SetNumberOfPoints( 10000 );
+  blob->SetDistributionToUniform();
+
+  // Give them some colour
+  vtkElevationFilter* elev = vtkElevationFilter::New();
+  elev->SetInput( blob->GetOutput() );
+  elev->SetLowPoint( -1.0, 0.0, 0.0 );
+  elev->SetHighPoint( 1.0, 0.0, 0.0 );
+  myPSMapper->SetInput( elev->GetPolyDataOutput() );
+  */
+  // Create a Gaussian splat to use as sprite
+  vtkImageGaussianSource* gaussian = vtkImageGaussianSource::New();
+  gaussian->SetWholeExtent( 0, 63, 0, 63, 0, 0 );
+  gaussian->SetCenter( 31.5, 31.5, 0.0 );
+  gaussian->SetMaximum( 255 );
+  gaussian->SetStandardDeviation( 15 );
+
+  // Create a sprite mapper.
+  // Set Accumulate mode rendering
+  // Use Point fading to reduce size of points to sensible demo size
+  myPSMapper->SetImmediateModeRendering( 1 );
+  myPSMapper->SetRenderModeToAccumulate();
+  myPSMapper->SetQuadraticPointDistanceAttenuation( 1.0, 20.0, 0.0 );
+  myPSMapper->SetParticleImage( gaussian->GetOutput() );
+  /*
+  // texture for intensity
+  vtkXMLImageDataReader* aReader1 = vtkXMLImageDataReader::New();
+  aReader1->SetFileName( "/dn06/salome/ouv/SALOME3/TextureIntensity.vti" );
+  cout << "1st : " << aReader1->GetOutput() << endl;
+  GLuint textureIntensity = myPSMapper->LoadTexture( aReader1->GetOutput() );
+  myPSMapper->SetTextureIntensity( textureIntensity );
+
+  // texture for alpha channel
+  vtkXMLImageDataReader* aReader2 = vtkXMLImageDataReader::New();
+  aReader2->SetFileName( "/dn06/salome/ouv/SALOME3/TextureAlphaChannel.vti" );
+  cout << "2nd : " << aReader2->GetOutput() << endl;
+  GLuint textureAlphaChannel = myPSMapper->LoadTexture( aReader2->GetOutput() );
+  myPSMapper->SetTextureAlphaChannel( textureAlphaChannel );
+
+  aReader1->Delete();
+  aReader2->Delete();
+  */
+}
+
+void VISU_GaussPointsPL::Update()
+{
+  VISU_ScalarMapPL::Update();
+
+  myPSMapper->SetLookupTable( myMapperTable );
+  myPSMapper->SetScalarRange( myMapperTable->GetRange() );
+}
 
 VISU_GaussPointsPL::~VISU_GaussPointsPL()
-{}
+{
+  if (this->myPSMapper)
+  {
+    this->myPSMapper->Delete();
+    this->myPSMapper = NULL;
+  }
+  if (this->myGeomFilter)
+  {
+    this->myGeomFilter->Delete();
+    this->myGeomFilter = NULL;
+  }
+}
index 356641fdf4b088abff702da859b2c63ff45c233e..98b7780ce23afe778c0570281fc6c2f93eafcf3b 100644 (file)
 
 #include "VISU_ScalarMapPL.hxx"
 
-class VISU_GaussPointsPL: public VISU_ScalarMapPL
+class VISU_OpenGLPointSpriteMapper;
+
+class vtkGeometryFilter;
+
+class VISU_GaussPointsPL : public VISU_ScalarMapPL
 {
 protected:
   VISU_GaussPointsPL();
@@ -39,6 +43,15 @@ protected:
 public:
   vtkTypeMacro(VISU_GaussPointsPL,VISU_ScalarMapPL);
   static VISU_GaussPointsPL* New();
+
+  virtual TMapper* GetMapper();
+
+  virtual void Build();
+  virtual void Update();
+
+protected:
+  VISU_OpenGLPointSpriteMapper* myPSMapper;
+  vtkGeometryFilter* myGeomFilter;
 };
   
 #endif