Salome HOME
Fix for Bug IPAL8945
[modules/visu.git] / src / PIPELINE / VISU_StreamLinesPL.cxx
index fabf699384ec74d8e8c1147d45d3f875a3738bf2..509074a9ebf5d9d679605248ef6f2fe9bc0a730c 100644 (file)
@@ -1,23 +1,23 @@
 //  VISU OBJECT : interactive object for VISU entities implementation
 //
 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
 //
 //
 // File:    VISU_PipeLine.cxx
 #include "VISU_StreamLinesPL.hxx"
 #include "VISU_PipeLineUtils.hxx"
 #include "VISU_UsedPointsFilter.hxx"
-#include "SALOME_GeometryFilter.h"
+#include "VTKViewer_GeometryFilter.h"
 
+#include <algo.h>
+
+#include <vtkCell.h>
 #include <vtkPointSet.h>
 #include <vtkStreamLine.h>
 
@@ -39,94 +42,204 @@ static int MYDEBUG = 0;
 static int MYDEBUG = 0;
 #endif
 
-static float EPS = 1.0e-20;
-int VISU_StreamLinesPL::myMaxIncrementMemorySize = 64;
-
-void SetStreamerSource(vtkStreamer *theStreamer, vtkPointSet* theDataSet, float thePercents){
-  theDataSet->Update();
-  VISU_UsedPointsFilter* anUsedPointsFilter = VISU_UsedPointsFilter::New();
-  anUsedPointsFilter->SetInput(theDataSet);
-  anUsedPointsFilter->SetPercentsOfUsedPoints(thePercents);
-  theStreamer->SetSource(anUsedPointsFilter->GetOutput());
-  anUsedPointsFilter->Register(theStreamer);
-  anUsedPointsFilter->Delete();
-}
+static float EPS = 1.0e-7;
+static float aMinNbOfSteps = 1.0E+2;
+//static float aMaxNbOfSteps = 1.0E+3;
+static float aCoeffOfIntStep = 1.0E+1;
 
 
 vtkStandardNewMacro(VISU_StreamLinesPL);
 
 VISU_StreamLinesPL::VISU_StreamLinesPL(){
   myStream = vtkStreamLine::New();
-  myGeomFilter = SALOME_GeometryFilter::New();
+  myCenters = vtkCellCenters::New();
+  myGeomFilter = VTKViewer_GeometryFilter::New();
+  myPointsFilter = VISU_UsedPointsFilter::New();
+  myPercents = 0.3;
   mySource = NULL;
 }
 
 VISU_StreamLinesPL::~VISU_StreamLinesPL(){
-  myStream->Delete();
+  myPointsFilter->UnRegisterAllOutputs();
+  myPointsFilter->Delete();
+
+  myCenters->UnRegisterAllOutputs();
+  myCenters->Delete();
+
+  myGeomFilter->UnRegisterAllOutputs();
   myGeomFilter->Delete();
-  SetSource(NULL);
+
+  myStream->UnRegisterAllOutputs();
+  myStream->Delete();
 }
 
 void VISU_StreamLinesPL::ShallowCopy(VISU_PipeLine *thePipeLine){
-  VISU_DeformedShapePL::ShallowCopy(thePipeLine);
   if(VISU_StreamLinesPL *aPipeLine = dynamic_cast<VISU_StreamLinesPL*>(thePipeLine)){
+    SetParams(aPipeLine->GetIntegrationStep(),
+             aPipeLine->GetPropagationTime(),
+             aPipeLine->GetStepLength(),
+             aPipeLine->GetSource(),
+             aPipeLine->GetUsedPoints(),
+             aPipeLine->GetDirection());
+  }
+  VISU_DeformedShapePL::ShallowCopy(thePipeLine);
+}
+
 
-    //Order of setting of the values are important 
-    SetUsedPoints(aPipeLine->GetUsedPoints());
-    SetSource(aPipeLine->GetSource());
+float VISU_StreamLinesPL::GetNecasseryMemorySize(vtkIdType theNbOfPoints, float theStepLength,
+                                                float thePropogationTime, float thePercents)
+{
+  static float aStreamPointSize = sizeof(float)*15 + sizeof(vtkIdType)*2;
+  static float aStreamArraySize = aStreamPointSize*1024; // == 69632
 
-    SetDirection(aPipeLine->GetDirection());
+  float aNbCells = thePercents*theNbOfPoints*2.0;
+  float aNbPointsPerCell = thePropogationTime/theStepLength;
+  float aCellsSize = aNbCells*(1+aNbPointsPerCell);
+  float aPointsSize = aCellsSize*3.0*sizeof(float);
 
-    //Order of setting of the values are important 
-    SetIntegrationStep(aPipeLine->GetIntegrationStep());
-    SetPropagationTime(aPipeLine->GetPropagationTime());
-    SetStepLength(aPipeLine->GetStepLength());
+  float aConnectivitySize = aCellsSize*sizeof(vtkIdType);
+  float aTypesSize = aNbCells*sizeof(char);
+  float aLocationsSize = aNbCells*sizeof(int);
+  //float aNbCellsPerPoint = aCellsSize / aNbCells - 1;
+  float aMeshSize = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize;
+
+  float anAssignedDataSize = aCellsSize*4.0*sizeof(float);
+  float anOutputDataSetSize = aMeshSize + anAssignedDataSize;
+
+  float aResult = aStreamArraySize*aNbCells + anOutputDataSetSize;
+  return aResult;
+}
+
+int VISU_StreamLinesPL::FindPossibleParams(vtkPointSet* theDataSet, float& theStepLength,
+                                          float& thePropogationTime, float& thePercents)
+{
+  static float aPercentsDecrease = 3.0, aStepLengthIncrease = 9.0;
+  vtkIdType aNbOfPoints = theDataSet->GetNumberOfPoints();
+  float aSize = GetNecasseryMemorySize(aNbOfPoints,theStepLength,thePropogationTime,thePercents);
+  int isPoss = CheckAvailableMemory(aSize);
+  if(!isPoss){
+    float aMaxStepLength = max(GetMaxStepLength(theDataSet),thePropogationTime);
+    float aMinStepLength = GetMinStepLength(theDataSet);
+    float aDeltaStepLength = (aMaxStepLength - aMinStepLength)/aStepLengthIncrease;
+    for(int i = 2, aStepChanged = 1, aPerecentsChanged = 1; aStepChanged || aPerecentsChanged; i++){
+      float aStepLength = theStepLength + aDeltaStepLength;
+      if(aStepLength < aMaxStepLength) theStepLength = aStepLength;
+      else if(aStepChanged){
+       aStepLength = aMaxStepLength;
+       aStepChanged = 0;
+      }
+      float aPercents = thePercents /= aPercentsDecrease;
+      if(aPercents*aNbOfPoints > 1) thePercents = aPercents;
+      else if(aPerecentsChanged) {
+       thePercents = 1.1 / aNbOfPoints;
+       aPerecentsChanged = 0;
+      }
+      aSize = GetNecasseryMemorySize(aNbOfPoints,theStepLength,thePropogationTime,thePercents);
+      if(CheckAvailableMemory(aSize)){
+       isPoss = i;
+       break;
+      }
+    }
   }
+  if(MYDEBUG) MESSAGE("FindPossibleParams - aSize = "<<aSize<<"; isPoss = "<<isPoss);
+  return isPoss;
 }
 
-void VISU_StreamLinesPL::SetSource(vtkPointSet* theSource){
-  if (mySource != NULL) mySource->UnRegister(this);
-  mySource = theSource;
-  if (mySource != NULL) mySource->Register(this);
-  if(myInput && myInput->GetCellData()->GetNumberOfArrays()){
-    vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New();
-    aFilter->SetInput(myFieldTransform->GetUnstructuredGridOutput());
-    aFilter->PassCellDataOn();
-    myStream->SetInput(aFilter->GetOutput());
-    aFilter->Register(myStream);
-    aFilter->Delete();
-    vtkCellCenters *centers = vtkCellCenters::New(); // for vectors on cells
-    centers->SetInput(myFieldTransform->GetUnstructuredGridOutput());
-    centers->VertexCellsOn();
-    mySource = mySource? mySource: centers->GetOutput();
-    SetStreamerSource(myStream,mySource,myPercents);
-    centers->Register(myStream);
-    centers->Delete();
-  }else{
-    myStream->SetInput(myFieldTransform->GetUnstructuredGridOutput());
-    mySource = mySource? mySource: myFieldTransform->GetUnstructuredGridOutput();
-    SetStreamerSource(myStream,mySource,myPercents);
+
+int VISU_StreamLinesPL::SetParams(float theIntStep,
+                                 float thePropogationTime,
+                                 float theStepLength,
+                                 vtkPointSet* theSource,
+                                 float thePercents,
+                                 int theDirection,
+                                 int isOnlyTry)
+{
+  vtkPointSet* aDataSet = theSource? theSource: myFieldTransform->GetUnstructuredGridOutput();
+  aDataSet->Update();
+  vtkIdType aNbOfPoints = aDataSet->GetNumberOfPoints();
+  vtkPointSet* aPointSet = myExtractor->GetOutput();
+  if(thePercents*aNbOfPoints < 1) thePercents = 2.0/aNbOfPoints;
+  theIntStep = CorrectIntegrationStep(theIntStep,aPointSet,thePercents);
+  thePropogationTime = CorrectPropagationTime(thePropogationTime,aPointSet);
+  theStepLength = CorrectStepLength(theStepLength,aPointSet);
+  int isAccepted = FindPossibleParams(aPointSet,theStepLength,thePropogationTime,thePercents);
+  if((!isOnlyTry && isAccepted) || (isOnlyTry && isAccepted == 1)){
+    mySource = theSource;
+    myPercents = thePercents;
+    if(GetInput2()->GetCellData()->GetNumberOfArrays()){
+      myCenters->SetInput(aDataSet);
+      myCenters->VertexCellsOn();
+      aDataSet = myCenters->GetOutput();
+    }
+    myPointsFilter->SetInput(aDataSet);
+    myPointsFilter->SetPercentsOfUsedPoints(thePercents);
+    aDataSet = myPointsFilter->GetOutput();
+    myStream->SetSource(aDataSet);
+    myStream->SetIntegrationStepLength(theIntStep);
+    myStream->SetMaximumPropagationTime(thePropogationTime);
+    myStream->SetStepLength(theStepLength);
+    myStream->SetSavePointInterval(theIntStep*aMinNbOfSteps);
+    myStream->SetIntegrationDirection(theDirection);
+    myStream->Modified();
+    Modified();
   }
-  myStream->Modified();
-  Modified();
+  return isAccepted;
 }
 
 
-float VISU_StreamLinesPL::GetMaxIntegrationStep(vtkPointSet* theDataSet) {
-  if(!theDataSet) return 0.0;
-  theDataSet->Update();
-  float* aBounds = theDataSet->GetBounds();
-  float aMaxSizeY = aBounds[3] - aBounds[2];
-  float aMaxSizeZ = aBounds[5] - aBounds[4];
-  float aMinMax = aBounds[1] - aBounds[0];
-  if (aMinMax < EPS || (aMaxSizeY < aMinMax && aMaxSizeY > EPS)) aMinMax = aMaxSizeY;
-  if (aMinMax < EPS || (aMaxSizeZ < aMinMax && aMaxSizeZ > EPS)) aMinMax = aMaxSizeZ;
-  return aMinMax / 2.0;
-} 
+vtkPointSet* VISU_StreamLinesPL::GetSource() {
+  return mySource;
+}
+
+float VISU_StreamLinesPL::GetUsedPoints() {
+  return myPercents;
+}
+
+vtkDataSet* VISU_StreamLinesPL::GetStreamerSource(){
+  return myStream->GetSource();
+}
+
+float VISU_StreamLinesPL::GetVelocityCoeff(){
+  return GetVelocityCoeff(myExtractor->GetOutput());
+}
+
+float VISU_StreamLinesPL::GetVelocityCoeff(vtkPointSet* theDataSet){
+  float* aScalarRange = theDataSet->GetScalarRange();
+  return (fabs(aScalarRange[1]) + fabs(aScalarRange[0]))/2.0;
+}
+
+
+int VISU_StreamLinesPL::IsPossible(vtkPointSet* theDataSet, float thePercents){
+  float aStepLength = GetBaseStepLength(theDataSet);
+  float aBasePropTime = GetBasePropagationTime(theDataSet);
+  VISU_UsedPointsFilter *aPointsFilter = VISU_UsedPointsFilter::New();
+  aPointsFilter->SetInput(theDataSet);
+  vtkPointSet* aDataSet = aPointsFilter->GetOutput();
+  aDataSet->Update();
+  int aRes = FindPossibleParams(aDataSet,aStepLength,aBasePropTime,thePercents);
+  aPointsFilter->UnRegisterAllOutputs();
+  aPointsFilter->Delete();
+  return aRes;
+}
+
+
+float VISU_StreamLinesPL::GetIntegrationStep(){
+  return myStream->GetIntegrationStepLength();
+}
+float VISU_StreamLinesPL::GetStepLength() {
+  return myStream->GetStepLength();
+}
+float VISU_StreamLinesPL::GetPropagationTime() {
+  return myStream->GetMaximumPropagationTime();
+}
+int VISU_StreamLinesPL::GetDirection(){
+  return myStream->GetIntegrationDirection();
+}
 
-float VISU_StreamLinesPL::GetMinIntegrationStep(vtkPointSet* theDataSet) {
-  if(!theDataSet) return 0.0;
-  float aVolume = 1.0, tmp;
+
+float VISU_StreamLinesPL::GetMinIntegrationStep(vtkPointSet* theDataSet, float thePercents) {
+  if(!theDataSet) return -1.0;
+  float aVolume = 1.0;
   int degree = 0;
   theDataSet->Update();
   float* aBounds = theDataSet->GetBounds();
@@ -138,113 +251,145 @@ float VISU_StreamLinesPL::GetMinIntegrationStep(vtkPointSet* theDataSet) {
     }
   }
   if (degree < 1) return 0.0; // absolutely empty object
-  unsigned long aSize = 1024*theDataSet->GetActualMemorySize();
-  // we have to use no more, than myMaxIncrementMemorySize*aSize amount of memory
-  unsigned long aRealSize = GetAvailableMemory(myMaxIncrementMemorySize*aSize);
-  if(MYDEBUG) cout<<"GetMinIntegrationStep - GetActualMemorysize() = "<<aRealSize<<"; "<<aSize<<endl;
-  float anAverageVolume = aVolume / aRealSize; 
+  float anStepLength = GetMaxIntegrationStep(theDataSet)/aCoeffOfIntStep;
+  float aBasePropTime = GetBasePropagationTime(theDataSet)/GetVelocityCoeff(theDataSet);
+  thePercents = 1.0;
+  vtkIdType aNbOfPoints = theDataSet->GetNumberOfPoints();
+  float aSize = GetNecasseryMemorySize(aNbOfPoints,anStepLength,aBasePropTime,thePercents);
+  float aRealSize = GetAvailableMemory(aSize);
+  float anAverageVolume = aVolume / aRealSize;
   float aStep = pow(double(anAverageVolume), double(1.0/double(degree)));
   return aStep;
 }
+float VISU_StreamLinesPL::GetMinIntegrationStep(){
+  return GetMinIntegrationStep(myExtractor->GetOutput(),GetUsedPoints());
+}
+
 
-float VISU_StreamLinesPL::GetBasePropagationTime(vtkPointSet* theDataSet) {
-  if(!theDataSet) return 0.0;
+float VISU_StreamLinesPL::GetMaxIntegrationStep(vtkPointSet* theDataSet) {
+  if(!theDataSet) return -1.0;
   theDataSet->Update();
-  float* aScalarRange = theDataSet->GetScalarRange();
-  return theDataSet->GetLength()/fabs(aScalarRange[1] + aScalarRange[0])*2.0;
+  float aLength = theDataSet->GetLength();
+  float* aBounds = theDataSet->GetBounds();
+  float aMaxSizeY = (aBounds[3]-aBounds[2])/aLength;
+  float aMaxSizeZ = (aBounds[5]-aBounds[4])/aLength;
+  float aMinMax = (aBounds[1] - aBounds[0])/aLength;
+  if (aMinMax < EPS || (aMaxSizeY < aMinMax && aMaxSizeY > EPS)) aMinMax = aMaxSizeY;
+  if (aMinMax < EPS || (aMaxSizeZ < aMinMax && aMaxSizeZ > EPS)) aMinMax = aMaxSizeZ;
+  return aMinMax*aLength/2.0;
+}
+float VISU_StreamLinesPL::GetMaxIntegrationStep(){
+  return GetMaxIntegrationStep(myExtractor->GetOutput());
 }
 
-
-int VISU_StreamLinesPL::GetDirection(){
-  return myStream->GetIntegrationDirection();
+float VISU_StreamLinesPL::GetBaseIntegrationStep(vtkPointSet* theDataSet, float thePercents){
+  theDataSet->Update();
+  float aMinIntegrationStep = GetMinIntegrationStep(theDataSet,thePercents);
+  float aMaxIntegrationStep = GetMaxIntegrationStep(theDataSet);
+  float anIntegrationStep = aMaxIntegrationStep / aCoeffOfIntStep;
+  float aMinMax = theDataSet->GetLength()/theDataSet->GetNumberOfPoints();
+  if(aMinMax > anIntegrationStep)
+    anIntegrationStep = (anIntegrationStep*aCoeffOfIntStep*0.9+aMinMax)/aCoeffOfIntStep;
+  if(aMinIntegrationStep > anIntegrationStep)
+    anIntegrationStep = aMinIntegrationStep;
+  return anIntegrationStep;
 }
-void VISU_StreamLinesPL::SetDirection(int theDirection){
-  myStream->SetIntegrationDirection(theDirection);
-  Modified();
+
+float VISU_StreamLinesPL::CorrectIntegrationStep(float theStep, vtkPointSet* theDataSet, float thePercents){
+  theDataSet->Update();
+  float aMinIntegrationStep = GetMinIntegrationStep(theDataSet,thePercents);
+  float aMaxIntegrationStep = GetMaxIntegrationStep(theDataSet);
+  if(aMinIntegrationStep > theStep)
+    theStep = aMinIntegrationStep;
+  if(aMaxIntegrationStep < theStep)
+    theStep = aMaxIntegrationStep;
+  return theStep;
 }
 
 
-float VISU_StreamLinesPL::GetPropagationTime() { 
-  return myStream->GetMaximumPropagationTime();
+float VISU_StreamLinesPL::GetMinPropagationTime(vtkPointSet* theDataSet){
+  if(!theDataSet) return -1.0;
+  return GetMinStepLength(theDataSet);
 }
-void VISU_StreamLinesPL::SetPropagationTime(float theTime) { 
-  if(myStream->GetMaximumPropagationTime() == theTime) return;
-  myStream->SetMaximumPropagationTime(theTime);
-  Modified();
+float VISU_StreamLinesPL::GetMinPropagationTime(){
+  return GetMinPropagationTime(myExtractor->GetOutput());
 }
 
+float VISU_StreamLinesPL::GetMaxPropagationTime(vtkPointSet* theDataSet){
+  if(!theDataSet) return -1.0;
+  return GetBasePropagationTime(theDataSet)*aMinNbOfSteps;
+}
+float VISU_StreamLinesPL::GetMaxPropagationTime(){
+  return GetMaxPropagationTime(myExtractor->GetOutput());
+}
 
-float VISU_StreamLinesPL::GetIntegrationStep(){
-  return myStream->GetIntegrationStepLength();
+float VISU_StreamLinesPL::CorrectPropagationTime(float thePropagationTime, vtkPointSet* theDataSet){
+  float aMinPropagationTime = GetMinPropagationTime(theDataSet);
+  float aMaxPropagationTime = GetMaxPropagationTime(theDataSet);
+  if(aMinPropagationTime > thePropagationTime)
+    thePropagationTime = aMinPropagationTime;
+  if(aMaxPropagationTime < thePropagationTime)
+    thePropagationTime = aMaxPropagationTime;
+  return thePropagationTime;
 }
-float VISU_StreamLinesPL::SetIntegrationStep(float theStep){ 
-  if(myStream->GetIntegrationStepLength() == theStep) return theStep;
-  myExtractor->Update();
-  vtkPointSet* aDataSet = GetSource();
-  aDataSet->Update();
-  float anIntegrationStep = theStep;
-  float aMinIntegrationStep = GetMinIntegrationStep(aDataSet);
-  float aMaxIntegrationStep = GetMaxIntegrationStep(aDataSet);
-  if(aMinIntegrationStep < anIntegrationStep && anIntegrationStep < aMaxIntegrationStep){
-    myStream->SetIntegrationStepLength(theStep);
-    Modified();
-  }else{
-    anIntegrationStep = aMaxIntegrationStep / 10.0;
-    float aMinMax = aDataSet->GetLength()/myInput->GetNumberOfPoints();
-    if(aMinMax > anIntegrationStep) 
-      anIntegrationStep = (anIntegrationStep*9.0+aMinMax)/10.0;
-    if(aMinIntegrationStep > anIntegrationStep) 
-      anIntegrationStep = aMinIntegrationStep;
-  }
-  return anIntegrationStep;
+float VISU_StreamLinesPL::GetBasePropagationTime(vtkPointSet* theDataSet){
+  if(!theDataSet) return -1.0;
+  theDataSet->Update();
+  float aPropagationTime = theDataSet->GetLength()/GetVelocityCoeff(theDataSet);
+  return aPropagationTime;
+}
+float VISU_StreamLinesPL::GetBasePropagationTime(){
+  return GetBasePropagationTime(myExtractor->GetOutput());
 }
 
 
-float VISU_StreamLinesPL::GetStepLength() { 
-  return myStream->GetStepLength();
+float VISU_StreamLinesPL::GetMinStepLength(vtkPointSet* theDataSet){
+  static float aNbOfStepsOfIntStep = 1.0E+1;
+  float anIntStep = GetMinIntegrationStep(theDataSet);
+  float aStepLength = anIntStep*aNbOfStepsOfIntStep/GetVelocityCoeff(theDataSet);
+  return aStepLength;
 }
-float VISU_StreamLinesPL::GetMinStepLength(float theIntegrationStep){
-  return theIntegrationStep*2.0;
+float VISU_StreamLinesPL::GetMinStepLength(){
+  return GetMinStepLength(myExtractor->GetOutput());
+}
+
+float VISU_StreamLinesPL::GetMaxStepLength(vtkPointSet* theDataSet){
+  float aStepLength = GetBasePropagationTime(theDataSet);
+  return aStepLength;
 }
-float VISU_StreamLinesPL::GetMaxStepLength(float thePropagationTime){
-  return thePropagationTime/100.0;
+float VISU_StreamLinesPL::GetMaxStepLength(){
+  return GetMaxStepLength(myExtractor->GetOutput());
 }
-float VISU_StreamLinesPL::CorrectStepLength(float theStep, float theIntegrationStep, float thePropagationTime){
-  float aMinStep = GetMinStepLength(theIntegrationStep);
+
+float VISU_StreamLinesPL::CorrectStepLength(float theStep, vtkPointSet* theDataSet){
+  float aMinStep = GetMinStepLength(theDataSet);
   if(theStep < aMinStep) theStep = aMinStep;
-  float aMaxStep = GetMaxStepLength(thePropagationTime);
+  float aMaxStep = GetMaxStepLength(theDataSet);
   if(theStep > aMaxStep) theStep = aMaxStep;
   return theStep;
 }
-float VISU_StreamLinesPL::SetStepLength(float theStep){
-  if(myStream->GetStepLength() == theStep) return theStep;
-  float aStepLength = CorrectStepLength(theStep,GetIntegrationStep(),GetPropagationTime());
-  if(aStepLength == theStep){
-    myStream->SetStepLength(theStep);
-    Modified();
-  }
+float VISU_StreamLinesPL::GetBaseStepLength(vtkPointSet* theDataSet){
+  static float anAvgNbOfSteps = 1.0E+2;
+  float aPropagationTime = GetBasePropagationTime(theDataSet);
+  float aStepLength = aPropagationTime/anAvgNbOfSteps;
+  aStepLength = CorrectStepLength(aStepLength,theDataSet);
   return aStepLength;
 }
 
 
 void VISU_StreamLinesPL::Init(){
   VISU_ScalarMapPL::Init();
-
-  SetDirection(VTK_INTEGRATE_BOTH_DIRECTIONS);
-  vtkPointSet* aDataSet = myExtractor->GetOutput();                                                    
-  //Order of setting of the values are important 
-  myPercents = 0.3;
-  SetSource(NULL);
-
-  SetIntegrationStep(SetIntegrationStep(GetMaxIntegrationStep(aDataSet)/10.0));
-  SetPropagationTime(GetBasePropagationTime(aDataSet));
-  SetStepLength(SetStepLength(GetPropagationTime()/20.));
+  vtkPointSet* aDataSet = myExtractor->GetOutput();
+  float anIntStep = GetBaseIntegrationStep(aDataSet);
+  float aPropagationTime = GetBasePropagationTime(aDataSet);
+  float aStepLength = GetBaseStepLength(aDataSet);
+  SetParams(anIntStep,aPropagationTime,aStepLength);
 }
 
 VISU_ScalarMapPL::THook* VISU_StreamLinesPL::DoHook(){
-  SetSource(NULL);
-  myInput->Update();
-  float *aBounds = myInput->GetBounds();
+  GetInput2()->Update();
+  VISU::CellDataToPoint(myStream,myCellDataToPointData,GetInput2(),myFieldTransform);
+  float *aBounds = GetInput2()->GetBounds();
   myGeomFilter->SetExtent(aBounds);
   myGeomFilter->ExtentClippingOn();
   myGeomFilter->SetInput(myStream->GetOutput());