Salome HOME
0051571: TC6.6.0: "Export to MED file" doesn't export file to folder,that has space...
[modules/visu.git] / src / PIPELINE / VISU_StreamLinesPL.cxx
index 6eb70ecc4dd8e6a5286217264ce7231eebd1ff7d..6fd7b52cd82592f3090159f198bb7b191480d3bd 100644 (file)
@@ -1,23 +1,23 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  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 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.
+// 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
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 //  VISU OBJECT : interactive object for VISU entities implementation
 //#include "VISU_UsedPointsFilter.hxx"
 #include "VISU_MaskPointsFilter.hxx"
 #include "VISU_PipeLineUtils.hxx"
-#include "VISU_StreamLine.hxx"
 
+#include "VTKViewer_CellCenters.h"
 #include "VTKViewer_GeometryFilter.h"
 
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
+
 #include <algorithm>
 
 #include <vtkCell.h>
 #include <vtkDataSet.h>
+#include <vtkStreamLine.h>
 
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
@@ -64,12 +68,13 @@ VISU_StreamLinesPL
   SetIsShrinkable(false);
   SetIsFeatureEdgesAllowed(false);
 
-  myStream = VISU_StreamLine::New();
-  myCenters = vtkCellCenters::New();
+  myStream = vtkStreamLine::New();
+  myCenters = VTKViewer_CellCenters::New();
   myGeomFilter = VTKViewer_GeometryFilter::New();
   myPointsFilter = VISU_MaskPointsFilter::New();
-  myPercents = 0.3;
   mySource = NULL;
+
+  myPercents = GetUsedPointsDefault();
 }
 
 
@@ -173,7 +178,7 @@ VISU_StreamLinesPL
   size_t anIsPossible = CheckAvailableMemory(aSize);
   if(!anIsPossible){
     vtkFloatingPointType aMaxStepLength = std::max(GetMaxStepLength(theDataSet),thePropogationTime);
-    vtkFloatingPointType aMinStepLength = GetMinStepLength(theDataSet);
+    vtkFloatingPointType aMinStepLength = GetMinStepLength(theDataSet,thePercents);
     vtkFloatingPointType aDeltaStepLength = (aMaxStepLength - aMinStepLength)/aStepLengthIncrease;
     for(int i = 2, aStepChanged = 1, aPerecentsChanged = 1; aStepChanged || aPerecentsChanged; i++){
       vtkFloatingPointType aStepLength = theStepLength + aDeltaStepLength;
@@ -223,10 +228,12 @@ VISU_StreamLinesPL
                                       thePercents);
 
   thePropogationTime = CorrectPropagationTime(thePropogationTime,
-                                              aPointSet);
+                                              aPointSet,
+                                              thePercents);
 
   theStepLength = CorrectStepLength(theStepLength,
-                                    aPointSet);
+                                    aPointSet,
+                                    thePercents);
 
   size_t anIsAccepted = FindPossibleParams(aPointSet,
                                            theStepLength,
@@ -310,10 +317,11 @@ VISU_StreamLinesPL
 //----------------------------------------------------------------------------
 size_t
 VISU_StreamLinesPL
-::IsPossible(vtkPointSet* theDataSet, 
-             vtkFloatingPointType thePercents)
+::IsPossible(vtkPointSet* theDataSet)
 {
-  vtkFloatingPointType aStepLength = GetBaseStepLength(theDataSet);
+  vtkFloatingPointType aPercents = GetUsedPointsDefault();
+  vtkFloatingPointType aStepLength = GetBaseStepLength(theDataSet,
+                                                       aPercents);
   vtkFloatingPointType aBasePropTime = GetBasePropagationTime(theDataSet);
   VISU_MaskPointsFilter *aPointsFilter = VISU_MaskPointsFilter::New();
   aPointsFilter->SetInput(theDataSet);
@@ -322,7 +330,7 @@ VISU_StreamLinesPL
   size_t aRes = FindPossibleParams(aDataSet,
                                    aStepLength,
                                    aBasePropTime,
-                                   thePercents);
+                                   aPercents);
   aPointsFilter->Delete();
   return aRes;
 }
@@ -489,12 +497,13 @@ VISU_StreamLinesPL
 //----------------------------------------------------------------------------
 vtkFloatingPointType
 VISU_StreamLinesPL
-::GetMinPropagationTime(vtkDataSet* theDataSet)
+::GetMinPropagationTime(vtkDataSet* theDataSet, 
+                        vtkFloatingPointType thePercents)
 {
   if(!theDataSet) 
     return -1.0;
 
-  return GetMinStepLength(theDataSet);
+  return GetMinStepLength(theDataSet, thePercents);
 }
 
 
@@ -503,7 +512,7 @@ vtkFloatingPointType
 VISU_StreamLinesPL
 ::GetMinPropagationTime()
 {
-  return GetMinPropagationTime(GetExtractorFilter()->GetOutput());
+  return GetMinPropagationTime(GetExtractorFilter()->GetOutput(), GetUsedPoints());
 }
 
 
@@ -532,9 +541,10 @@ VISU_StreamLinesPL
 vtkFloatingPointType
 VISU_StreamLinesPL
 ::CorrectPropagationTime(vtkFloatingPointType thePropagationTime, 
-                         vtkDataSet* theDataSet)
+                         vtkDataSet* theDataSet, 
+                         vtkFloatingPointType thePercents)
 {
-  vtkFloatingPointType aMinPropagationTime = GetMinPropagationTime(theDataSet);
+  vtkFloatingPointType aMinPropagationTime = GetMinPropagationTime(theDataSet, thePercents);
   if(aMinPropagationTime > thePropagationTime)
     thePropagationTime = aMinPropagationTime;
 
@@ -573,10 +583,11 @@ VISU_StreamLinesPL
 //----------------------------------------------------------------------------
 vtkFloatingPointType 
 VISU_StreamLinesPL
-::GetMinStepLength(vtkDataSet* theDataSet)
+::GetMinStepLength(vtkDataSet* theDataSet, 
+                   vtkFloatingPointType thePercents)
 {
   static vtkFloatingPointType aNbOfStepsOfIntStep = 1.0E+1;
-  vtkFloatingPointType anIntStep = GetMinIntegrationStep(theDataSet);
+  vtkFloatingPointType anIntStep = GetMinIntegrationStep(theDataSet, thePercents);
   vtkFloatingPointType aStepLength = anIntStep * aNbOfStepsOfIntStep / GetVelocityCoeff(theDataSet);
   return aStepLength;
 }
@@ -587,7 +598,7 @@ vtkFloatingPointType
 VISU_StreamLinesPL
 ::GetMinStepLength()
 {
-  return GetMinStepLength(GetExtractorFilter()->GetOutput());
+  return GetMinStepLength(GetExtractorFilter()->GetOutput(), GetUsedPoints());
 }
 
 
@@ -614,9 +625,10 @@ VISU_StreamLinesPL
 vtkFloatingPointType
 VISU_StreamLinesPL
 ::CorrectStepLength(vtkFloatingPointType theStep, 
-                    vtkDataSet* theDataSet)
+                    vtkDataSet* theDataSet, 
+                    vtkFloatingPointType thePercents)
 {
-  vtkFloatingPointType aMinStep = GetMinStepLength(theDataSet);
+  vtkFloatingPointType aMinStep = GetMinStepLength(theDataSet, thePercents);
   if(theStep < aMinStep) 
     theStep = aMinStep;
 
@@ -631,17 +643,28 @@ VISU_StreamLinesPL
 //----------------------------------------------------------------------------
 vtkFloatingPointType
 VISU_StreamLinesPL
-::GetBaseStepLength(vtkDataSet* theDataSet)
+::GetBaseStepLength(vtkDataSet* theDataSet, 
+                    vtkFloatingPointType thePercents)
 {
   static vtkFloatingPointType anAvgNbOfSteps = 1.0E+2;
   vtkFloatingPointType aPropagationTime = GetBasePropagationTime(theDataSet);
   vtkFloatingPointType aStepLength = aPropagationTime/anAvgNbOfSteps;
-  aStepLength = CorrectStepLength(aStepLength,theDataSet);
+  aStepLength = CorrectStepLength(aStepLength,theDataSet,thePercents);
 
   return aStepLength;
 }
 
 
+//----------------------------------------------------------------------------
+vtkFloatingPointType
+VISU_StreamLinesPL
+::GetUsedPointsDefault()
+{
+  SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
+  return aResourceMgr->doubleValue("VISU", "stream_lines_used_points", 0.01);
+}
+
+
 //----------------------------------------------------------------------------
 void
 VISU_StreamLinesPL
@@ -650,12 +673,14 @@ VISU_StreamLinesPL
   Superclass::Init();
 
   vtkDataSet* aDataSet = GetExtractorFilter()->GetOutput();
-  vtkFloatingPointType anIntStep = GetBaseIntegrationStep(aDataSet);
+  vtkFloatingPointType anIntStep = GetBaseIntegrationStep(aDataSet, GetUsedPoints());
   vtkFloatingPointType aPropagationTime = GetBasePropagationTime(aDataSet);
-  vtkFloatingPointType aStepLength = GetBaseStepLength(aDataSet);
+  vtkFloatingPointType aStepLength = GetBaseStepLength(aDataSet, GetUsedPoints());
   SetParams(anIntStep,
             aPropagationTime,
-            aStepLength);
+            aStepLength,
+            NULL,
+            GetUsedPoints());
 }