Salome HOME
Fix for Bug IPAL8945
[modules/visu.git] / src / PIPELINE / VISU_DeformedShapePL.cxx
index 9b200331a11350a366748ed4aa4ae466eb48accf..0b8e346208120b6f36c319bd5c9646e5b313c96f 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_DeformedShapePL.hxx"
 #include "VISU_PipeLineUtils.hxx"
-#include "SALOME_Transform.h"
+#include "VTKViewer_Transform.h"
 
 #include <vtkWarpVector.h>
 
-#ifdef _DEBUG_
-static int MYDEBUG = 1;
-#else
-static int MYDEBUG = 0;
-#endif
-
 vtkStandardNewMacro(VISU_DeformedShapePL);
 
 VISU_DeformedShapePL::VISU_DeformedShapePL(){
@@ -53,10 +47,10 @@ VISU_DeformedShapePL::~VISU_DeformedShapePL(){
 }
 
 void VISU_DeformedShapePL::ShallowCopy(VISU_PipeLine *thePipeLine){
-  VISU_ScalarMapPL::ShallowCopy(thePipeLine);
   if(VISU_DeformedShapePL *aPipeLine = dynamic_cast<VISU_DeformedShapePL*>(thePipeLine)){
     SetScale(aPipeLine->GetScale());
   }
+  VISU_ScalarMapPL::ShallowCopy(thePipeLine);
 }
 
 float VISU_DeformedShapePL::GetScaleFactor(vtkDataSet* theDataSet){
@@ -70,7 +64,7 @@ float VISU_DeformedShapePL::GetScaleFactor(vtkDataSet* theDataSet){
   for(int i = 0; i < 6; i += 2){
     aVol = fabs(aBounds[i+1] - aBounds[i]);
     if(aVol > 0) {
-      idim++; 
+      idim++;
       aVolume *= aVol;
     }
   }
@@ -79,25 +73,32 @@ float VISU_DeformedShapePL::GetScaleFactor(vtkDataSet* theDataSet){
 }
 
 
-void VISU_DeformedShapePL::SetScale(float theScale) { 
-  if(myScaleFactor == theScale) return;
+void VISU_DeformedShapePL::SetScale(float theScale) {
+  myWarpVector->SetScaleFactor(theScale);
   myScaleFactor = theScale;
-  myWarpVector->SetScaleFactor(myScaleFactor);
   Modified();
 }
-float VISU_DeformedShapePL::GetScale() { 
-  return myWarpVector->GetScaleFactor();
+float VISU_DeformedShapePL::GetScale() {
+  return myScaleFactor;
 }
 
 void VISU_DeformedShapePL::Init(){
   VISU_ScalarMapPL::Init();
   float aScalarRange[2];
   GetSourceRange(aScalarRange);
-  SetScale(GetScaleFactor(myInput)/aScalarRange[1]);
+
+  vtkDataSet* aDataSet = GetInput2();
+  float aScaleFactor = VISU_DeformedShapePL::GetScaleFactor( aDataSet );
+
+  static double EPS = 1.0 / VTK_LARGE_FLOAT;
+  if(fabs(aScalarRange[1]) > EPS)
+    SetScale(aScaleFactor / aScalarRange[1]);
+  else
+    SetScale(0.0);
 }
 
 VISU_ScalarMapPL::THook* VISU_DeformedShapePL::DoHook(){
-  VISU::CellDataToPoint(myWarpVector,myCellDataToPointData,myInput,myFieldTransform);
+  VISU::CellDataToPoint(myWarpVector,myCellDataToPointData,GetInput2(),myFieldTransform);
   return myWarpVector->GetOutput();
 }