]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Improve pipeline management when a new modes are applied
authorapo <apo@opencascade.com>
Thu, 1 Dec 2005 10:05:49 +0000 (10:05 +0000)
committerapo <apo@opencascade.com>
Thu, 1 Dec 2005 10:05:49 +0000 (10:05 +0000)
src/PIPELINE/VISU_GaussPointsPL.cxx
src/PIPELINE/VISU_GaussPointsPL.hxx

index 79fae71538d32f96c3bc41d6de383ab8a30f0878..d3e46480ecb3c7f2cc505ef5f744c16059126a63 100644 (file)
@@ -32,6 +32,7 @@
 #include "SALOME_ExtractGeometry.h"
 #include "VISU_DeformedShapePL.hxx"
 #include "VISU_OpenGLPointSpriteMapper.hxx"
+#include "VTKViewer_PassThroughFilter.h"
 
 #include <vtkPointSource.h>
 #include <vtkElevationFilter.h>
@@ -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();
 }
 
index c3c5665feb4ae6e0dc537533c41f14aa4ca5c2cb..37c8a796c19740937ac01a1dd45b7f841ea47070 100644 (file)
@@ -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<VTKViewer_PassThroughFilter*> myPassFilter;
+  
   vtkGlyph3D* myGlyph;
   vtkSphereSource* mySphereSource;
   int myResolution;