Salome HOME
Fix for Bug IPAL8945
[modules/visu.git] / src / PIPELINE / VISU_StreamLinesPL.cxx
index 2141182b8ed02e3a37e54d54b59ee8898d94c444..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 <vtkStreamLine.h>
 
 #ifdef _DEBUG_
-static int MYDEBUG = 1;
+static int MYDEBUG = 0;
 #else
 static int MYDEBUG = 0;
 #endif
 
 static float EPS = 1.0e-7;
 static float aMinNbOfSteps = 1.0E+2;
-static float aMaxNbOfSteps = 1.0E+3;
+//static float aMaxNbOfSteps = 1.0E+3;
 static float aCoeffOfIntStep = 1.0E+1;
 
 
@@ -74,18 +74,19 @@ VISU_StreamLinesPL::~VISU_StreamLinesPL(){
 }
 
 void VISU_StreamLinesPL::ShallowCopy(VISU_PipeLine *thePipeLine){
-  VISU_DeformedShapePL::ShallowCopy(thePipeLine);
-  if(VISU_StreamLinesPL *aPipeLine = dynamic_cast<VISU_StreamLinesPL*>(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);
 }
 
 
-float VISU_StreamLinesPL::GetNecasseryMemorySize(vtkIdType theNbOfPoints, float theStepLength, 
+float VISU_StreamLinesPL::GetNecasseryMemorySize(vtkIdType theNbOfPoints, float theStepLength,
                                                 float thePropogationTime, float thePercents)
 {
   static float aStreamPointSize = sizeof(float)*15 + sizeof(vtkIdType)*2;
@@ -99,7 +100,7 @@ float VISU_StreamLinesPL::GetNecasseryMemorySize(vtkIdType theNbOfPoints, float
   float aConnectivitySize = aCellsSize*sizeof(vtkIdType);
   float aTypesSize = aNbCells*sizeof(char);
   float aLocationsSize = aNbCells*sizeof(int);
-  float aNbCellsPerPoint = aCellsSize / aNbCells - 1;
+  //float aNbCellsPerPoint = aCellsSize / aNbCells - 1;
   float aMeshSize = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize;
 
   float anAssignedDataSize = aCellsSize*4.0*sizeof(float);
@@ -109,7 +110,7 @@ float VISU_StreamLinesPL::GetNecasseryMemorySize(vtkIdType theNbOfPoints, float
   return aResult;
 }
 
-int VISU_StreamLinesPL::FindPossibleParams(vtkPointSet* theDataSet, float& theStepLength, 
+int VISU_StreamLinesPL::FindPossibleParams(vtkPointSet* theDataSet, float& theStepLength,
                                           float& thePropogationTime, float& thePercents)
 {
   static float aPercentsDecrease = 3.0, aStepLengthIncrease = 9.0;
@@ -145,11 +146,11 @@ int VISU_StreamLinesPL::FindPossibleParams(vtkPointSet* theDataSet, float& theSt
 }
 
 
-int VISU_StreamLinesPL::SetParams(float theIntStep, 
+int VISU_StreamLinesPL::SetParams(float theIntStep,
                                  float thePropogationTime,
                                  float theStepLength,
-                                 vtkPointSet* theSource, 
-                                 float thePercents,            
+                                 vtkPointSet* theSource,
+                                 float thePercents,
                                  int theDirection,
                                  int isOnlyTry)
 {
@@ -165,7 +166,7 @@ int VISU_StreamLinesPL::SetParams(float theIntStep,
   if((!isOnlyTry && isAccepted) || (isOnlyTry && isAccepted == 1)){
     mySource = theSource;
     myPercents = thePercents;
-    if(myInput->GetCellData()->GetNumberOfArrays()){
+    if(GetInput2()->GetCellData()->GetNumberOfArrays()){
       myCenters->SetInput(aDataSet);
       myCenters->VertexCellsOn();
       aDataSet = myCenters->GetOutput();
@@ -190,7 +191,7 @@ vtkPointSet* VISU_StreamLinesPL::GetSource() {
   return mySource;
 }
 
-float VISU_StreamLinesPL::GetUsedPoints() { 
+float VISU_StreamLinesPL::GetUsedPoints() {
   return myPercents;
 }
 
@@ -225,10 +226,10 @@ int VISU_StreamLinesPL::IsPossible(vtkPointSet* theDataSet, float thePercents){
 float VISU_StreamLinesPL::GetIntegrationStep(){
   return myStream->GetIntegrationStepLength();
 }
-float VISU_StreamLinesPL::GetStepLength() { 
+float VISU_StreamLinesPL::GetStepLength() {
   return myStream->GetStepLength();
 }
-float VISU_StreamLinesPL::GetPropagationTime() { 
+float VISU_StreamLinesPL::GetPropagationTime() {
   return myStream->GetMaximumPropagationTime();
 }
 int VISU_StreamLinesPL::GetDirection(){
@@ -256,11 +257,11 @@ float VISU_StreamLinesPL::GetMinIntegrationStep(vtkPointSet* theDataSet, float t
   vtkIdType aNbOfPoints = theDataSet->GetNumberOfPoints();
   float aSize = GetNecasseryMemorySize(aNbOfPoints,anStepLength,aBasePropTime,thePercents);
   float aRealSize = GetAvailableMemory(aSize);
-  float anAverageVolume = aVolume / aRealSize; 
+  float anAverageVolume = aVolume / aRealSize;
   float aStep = pow(double(anAverageVolume), double(1.0/double(degree)));
   return aStep;
 }
-float VISU_StreamLinesPL::GetMinIntegrationStep(){ 
+float VISU_StreamLinesPL::GetMinIntegrationStep(){
   return GetMinIntegrationStep(myExtractor->GetOutput(),GetUsedPoints());
 }
 
@@ -276,25 +277,25 @@ float VISU_StreamLinesPL::GetMaxIntegrationStep(vtkPointSet* theDataSet) {
   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(){ 
+}
+float VISU_StreamLinesPL::GetMaxIntegrationStep(){
   return GetMaxIntegrationStep(myExtractor->GetOutput());
 }
 
-float VISU_StreamLinesPL::GetBaseIntegrationStep(vtkPointSet* theDataSet, float thePercents){ 
+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) 
+  if(aMinMax > anIntegrationStep)
     anIntegrationStep = (anIntegrationStep*aCoeffOfIntStep*0.9+aMinMax)/aCoeffOfIntStep;
-  if(aMinIntegrationStep > anIntegrationStep) 
+  if(aMinIntegrationStep > anIntegrationStep)
     anIntegrationStep = aMinIntegrationStep;
   return anIntegrationStep;
 }
 
-float VISU_StreamLinesPL::CorrectIntegrationStep(float theStep, vtkPointSet* theDataSet, float thePercents){ 
+float VISU_StreamLinesPL::CorrectIntegrationStep(float theStep, vtkPointSet* theDataSet, float thePercents){
   theDataSet->Update();
   float aMinIntegrationStep = GetMinIntegrationStep(theDataSet,thePercents);
   float aMaxIntegrationStep = GetMaxIntegrationStep(theDataSet);
@@ -337,7 +338,7 @@ float VISU_StreamLinesPL::GetBasePropagationTime(vtkPointSet* theDataSet){
   float aPropagationTime = theDataSet->GetLength()/GetVelocityCoeff(theDataSet);
   return aPropagationTime;
 }
-float VISU_StreamLinesPL::GetBasePropagationTime(){ 
+float VISU_StreamLinesPL::GetBasePropagationTime(){
   return GetBasePropagationTime(myExtractor->GetOutput());
 }
 
@@ -386,9 +387,9 @@ void VISU_StreamLinesPL::Init(){
 }
 
 VISU_ScalarMapPL::THook* VISU_StreamLinesPL::DoHook(){
-  myInput->Update();
-  VISU::CellDataToPoint(myStream,myCellDataToPointData,myInput,myFieldTransform);
-  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());