Salome HOME
Merge from V5_1_main 10/06/2010
[modules/visu.git] / src / PIPELINE / VISU_DeformedShapePL.cxx
index 6631af081dda168fcf1ec15b0334ffc25b797cec..3312723f25b0631385ff6ba0c227db855f70cd9c 100644 (file)
@@ -1,6 +1,6 @@
-//  VISU OBJECT : interactive object for VISU entities implementation
+//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  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
 //  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
 // File:    VISU_PipeLine.cxx
 // Author:  Alexey PETROV
 // Module : VISU
-
-
+//
 #include "VISU_DeformedShapePL.hxx"
 #include "VISU_PipeLineUtils.hxx"
 #include "VTKViewer_Transform.h"
@@ -39,9 +39,11 @@ vtkStandardNewMacro(VISU_DeformedShapePL);
 //----------------------------------------------------------------------------
 VISU_DeformedShapePL
 ::VISU_DeformedShapePL():
-  myScaleFactor(0.0)
+  myScaleFactor(0.0),
+  myMapScaleFactor(1.0)
 {
   SetIsShrinkable(true);
+  SetIsFeatureEdgesAllowed(true);
 
   myWarpVector = vtkWarpVector::New();
   myCellDataToPointData = vtkCellDataToPointData::New();
@@ -76,7 +78,7 @@ VISU_DeformedShapePL
 void
 VISU_DeformedShapePL
 ::DoShallowCopy(VISU_PipeLine *thePipeLine,
-               bool theIsCopyInput)
+                bool theIsCopyInput)
 {
   Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
 
@@ -109,6 +111,8 @@ VISU_DeformedShapePL
       aVolume *= aVol;
     }
   }
+  if( aNbElem == 0 || fabs(idim) < 1.0 / VTK_LARGE_FLOAT )
+    return 0.0; // to avoid division by zero
   aVolume /= aNbElem;
   return pow(aVolume, vtkFloatingPointType(1.0/idim));
 }
@@ -139,8 +143,8 @@ VISU_DeformedShapePL
 {
   if(VISU::CheckIsSameValue(myWarpVector->GetScaleFactor(), theScale))
     return;
-
-  myWarpVector->SetScaleFactor(theScale);
+  
+  myWarpVector->SetScaleFactor(theScale*myMapScaleFactor);
   myScaleFactor = theScale;
 }
 
@@ -184,8 +188,8 @@ VISU_DeformedShapePL
 ::InsertCustomPL()
 {
   VISU::CellDataToPoint(myWarpVector,
-                       myCellDataToPointData,
-                       GetMergedInput());
+                        myCellDataToPointData,
+                        GetMergedInput());
 
   return myWarpVector->GetOutput();
 }
@@ -215,9 +219,14 @@ void
 VISU_DeformedShapePL
 ::SetMapScale(vtkFloatingPointType theMapScale)
 {
+  myMapScaleFactor = theMapScale;
   Superclass::SetMapScale(theMapScale);
 
-  myWarpVector->SetScaleFactor(myScaleFactor*theMapScale);
+  vtkFloatingPointType aMapScale = myScaleFactor * theMapScale;
+  if(VISU::CheckIsSameValue(myWarpVector->GetScaleFactor(), aMapScale))
+    return;
+
+  myWarpVector->SetScaleFactor( aMapScale );
 }