#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;
+ }
+}