From: apo Date: Thu, 1 Dec 2005 10:05:49 +0000 (+0000) Subject: Improve pipeline management when a new modes are applied X-Git-Tag: TG-D5-38-2003_D2005-20-12~89 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bba7ca08edd36b1909d24c1ff3ff5ed3f9e8d165;p=modules%2Fvisu.git Improve pipeline management when a new modes are applied --- diff --git a/src/PIPELINE/VISU_GaussPointsPL.cxx b/src/PIPELINE/VISU_GaussPointsPL.cxx index 79fae715..d3e46480 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.cxx +++ b/src/PIPELINE/VISU_GaussPointsPL.cxx @@ -32,6 +32,7 @@ #include "SALOME_ExtractGeometry.h" #include "VISU_DeformedShapePL.hxx" #include "VISU_OpenGLPointSpriteMapper.hxx" +#include "VTKViewer_PassThroughFilter.h" #include #include @@ -67,9 +68,52 @@ VISU_GaussPointsPL myCellDataToPointData->SetPassCellData(true); myGlyph = vtkGlyph3D::New(); + myGlyph->SetScaleModeToScaleByScalar(); + myGlyph->SetColorModeToColorByScalar(); + myGlyph->ClampingOn(); + + myExtractor->SetInput( myExtractGeometry->GetOutput() ); + myFieldTransform->SetInput( myExtractor->GetOutput() ); + + myCellDataToPointData->SetInput( myFieldTransform->GetUnstructuredGridOutput() ); + mySphereSource = vtkSphereSource::New(); + myGlyph->SetSource( mySphereSource->GetOutput() ); + + for(int i = 0; i < 2; i++) + myPassFilter.push_back(VTKViewer_PassThroughFilter::New()); } + +//---------------------------------------------------------------------------- +VISU_GaussPointsPL +::~VISU_GaussPointsPL() +{ + if (this->myPSMapper) + { + this->myPSMapper->Delete(); + this->myPSMapper = NULL; + } + if (this->myGeomFilter) + { + this->myGeomFilter->Delete(); + this->myGeomFilter = NULL; + } + + myWarpVector->Delete(); + + myCellDataToPointData->Delete(); + + myGlyph->Delete(); + + mySphereSource->Delete(); + + for(int i = 0; i < 2; i++) + myPassFilter[i]->Delete(); +} + + +//---------------------------------------------------------------------------- void VISU_GaussPointsPL ::ShallowCopy(VISU_PipeLine *thePipeLine) @@ -82,7 +126,6 @@ VISU_GaussPointsPL // To restore mapper input from pipeline myPSMapper->SetInput(aDatsSet); - SetGaussPtsIDMapper(aPipeLine->GetGaussPtsIDMapper()); SetPrimitiveType(aPipeLine->GetPrimitiveType()); SetClamp(aPipeLine->GetClamp()); SetSize(aPipeLine->GetSize()); @@ -128,60 +171,30 @@ void VISU_GaussPointsPL ::Init() { - myExtractor->SetInput( GetInput2() ); - myFieldTransform->SetInput( myExtractor->GetOutput() ); + Superclass::Init(); - myCellDataToPointData->SetInput( myFieldTransform->GetUnstructuredGridOutput() ); + float aScalarRange[2]; + GetSourceRange(aScalarRange); + vtkDataSet* aDataSet = GetParentMesh(); + float aScaleFactor = VISU_DeformedShapePL::GetScaleFactor( aDataSet ); + SetScale( aScaleFactor / aScalarRange[1] ); // Deformed Shape - if( myIsDeformed ) - { - myWarpVector->SetInput( myCellDataToPointData->GetUnstructuredGridOutput() ); - myGeomFilter->SetInput( myWarpVector->GetOutput() ); - } - else - myGeomFilter->SetInput( myCellDataToPointData->GetUnstructuredGridOutput() ); + myPassFilter[0]->SetInput(myCellDataToPointData->GetUnstructuredGridOutput()); - // Geometrical Sphere - if( GetPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere ) - { - myGlyph->SetInput( myGeomFilter->GetOutput() ); - myGlyph->SetScaleModeToScaleByScalar(); - myGlyph->SetColorModeToColorByScalar(); - //myGlyph->SetScaleFactor( 5 ); - myGlyph->ClampingOn(); - - mySphereSource->SetRadius( GetMagnification() * GetAverageCellSize() / 2. ); - myGlyph->SetSource( mySphereSource->GetOutput() ); - - myPSMapper->SetInput( myGlyph->GetOutput() ); - } - else - myPSMapper->SetInput( myGeomFilter->GetOutput() ); + myGeomFilter->SetInput( myPassFilter[0]->GetOutput() ); - VISU_ScalarMapPL::Init(); + // Geometrical Sphere + myPassFilter[1]->SetInput(myGeomFilter->GetOutput()); - float aScalarRange[2]; - GetSourceRange(aScalarRange); - vtkDataSet* aDataSet = GetParentMesh(); - SetScale( VISU_DeformedShapePL::GetScaleFactor( aDataSet ) / aScalarRange[1] ); + myPSMapper->SetInput( myPassFilter[1]->GetPolyDataOutput() ); } //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::Build() -{ - if( myIsDeformed ) - { - myWarpVector->SetInput( myCellDataToPointData->GetUnstructuredGridOutput() ); - myGeomFilter->SetInput( myWarpVector->GetOutput() ); - } - else - { - myGeomFilter->SetInput( myCellDataToPointData->GetUnstructuredGridOutput() ); - } -} +{} //---------------------------------------------------------------------------- void @@ -193,6 +206,8 @@ VISU_GaussPointsPL SetAverageCellSize( VISU_DeformedShapePL::GetScaleFactor( GetParentMesh() ) ); + mySphereSource->SetRadius( GetMagnification() * GetAverageCellSize() / 2. ); + vtkMapper* aMapper = GetMapper(); vtkDataSet* aDataSet = aMapper->GetInput(); vtkCellData* aCellData = aDataSet->GetCellData(); @@ -204,31 +219,6 @@ VISU_GaussPointsPL VISU_ScalarMapPL::Update(); } -//---------------------------------------------------------------------------- -VISU_GaussPointsPL -::~VISU_GaussPointsPL() -{ - if (this->myPSMapper) - { - this->myPSMapper->Delete(); - this->myPSMapper = NULL; - } - if (this->myGeomFilter) - { - this->myGeomFilter->Delete(); - this->myGeomFilter = NULL; - } - - myWarpVector->Delete(); - - myCellDataToPointData->Delete(); - - myGlyph->UnRegisterAllOutputs(); - myGlyph->Delete(); - - mySphereSource->Delete(); -} - //---------------------------------------------------------------------------- VISU::TGaussPointID VISU_GaussPointsPL @@ -252,7 +242,6 @@ VISU_GaussPointsPL { myGaussPtsIDMapper = theGaussPtsIDMapper; SetIDMapper(myGaussPtsIDMapper); - Init(); } const VISU::PGaussPtsIDMapper& @@ -270,6 +259,32 @@ VISU_GaussPointsPL return aNamedIDMapper->GetVTKOutput(); } +//---------------------------------------------------------------------------- +void +VISU_GaussPointsPL +::SetIsDeformed( bool theIsDeformed ) +{ + if( theIsDeformed ) + { + myWarpVector->SetInput( myCellDataToPointData->GetUnstructuredGridOutput() ); + myPassFilter[0]->SetInput(myWarpVector->GetOutput()); + } + else + myPassFilter[0]->SetInput(myCellDataToPointData->GetUnstructuredGridOutput()); + + myIsDeformed = theIsDeformed; + + Modified(); +} + +//---------------------------------------------------------------------------- +bool +VISU_GaussPointsPL +::GetIsDeformed() const +{ + return myIsDeformed; +} + //---------------------------------------------------------------------------- void VISU_GaussPointsPL @@ -302,7 +317,16 @@ void VISU_GaussPointsPL ::SetPrimitiveType(int thePrimitiveType) { + if( thePrimitiveType == VISU_OpenGLPointSpriteMapper::GeomSphere ) + { + myGlyph->SetInput( myGeomFilter->GetOutput() ); + myPassFilter[1]->SetInput(myGlyph->GetOutput()); + } + else + myPassFilter[1]->SetInput(myGeomFilter->GetOutput()); + myPSMapper->SetPrimitiveType( thePrimitiveType ); + Modified(); } diff --git a/src/PIPELINE/VISU_GaussPointsPL.hxx b/src/PIPELINE/VISU_GaussPointsPL.hxx index c3c5665f..37c8a796 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.hxx +++ b/src/PIPELINE/VISU_GaussPointsPL.hxx @@ -252,8 +252,8 @@ public: const char* theAlphaTexture ); public: - virtual void SetIsDeformed( bool theIsDeformed ) { myIsDeformed = theIsDeformed; } - virtual bool GetIsDeformed() const { return myIsDeformed; } + virtual void SetIsDeformed( bool theIsDeformed ); + virtual bool GetIsDeformed() const; virtual void SetScale( float theScale ); virtual float GetScale(); @@ -264,7 +264,8 @@ protected: float myScaleFactor; vtkWarpVector *myWarpVector; vtkCellDataToPointData* myCellDataToPointData; - + std::vector myPassFilter; + vtkGlyph3D* myGlyph; vtkSphereSource* mySphereSource; int myResolution;