From 0f818b9f1bc96c72af53cb06826a5bb0ed849f84 Mon Sep 17 00:00:00 2001 From: ouv Date: Tue, 30 Aug 2005 10:02:28 +0000 Subject: [PATCH] VISU_OpenGLPointSpriteMapper functionality added --- src/PIPELINE/VISU_GaussPointsPL.cxx | 108 +++++++++++++++++++++++++++- src/PIPELINE/VISU_GaussPointsPL.hxx | 15 +++- 2 files changed, 120 insertions(+), 3 deletions(-) diff --git a/src/PIPELINE/VISU_GaussPointsPL.cxx b/src/PIPELINE/VISU_GaussPointsPL.cxx index c4400bdc..233d4e24 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.cxx +++ b/src/PIPELINE/VISU_GaussPointsPL.cxx @@ -28,11 +28,115 @@ #include "VISU_GaussPointsPL.hxx" #include "VISU_PipeLineUtils.hxx" +#include "VISU_OpenGLPointSpriteMapper.hxx" + +#include +#include +#include +#include +#include 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; + } +} diff --git a/src/PIPELINE/VISU_GaussPointsPL.hxx b/src/PIPELINE/VISU_GaussPointsPL.hxx index 356641fd..98b7780c 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.hxx +++ b/src/PIPELINE/VISU_GaussPointsPL.hxx @@ -30,7 +30,11 @@ #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 -- 2.39.2