Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/visu.git] / src / PIPELINE / VISU_IsoSurfacesPL.cxx
index 25abb517505a28ff7e1a674122215c8cb4d34300..853e25265d60c8a1fb524a8890eb6e8298f81394 100644 (file)
@@ -1,24 +1,25 @@
-//  Copyright (C) 2007-2008  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
 // File:    VISU_PipeLine.cxx
 // Author:  Alexey PETROV
@@ -32,6 +33,7 @@
 
 #include <vtkContourFilter.h>
 
+#define GAP_COEFFICIENT 0.0001
 
 
 //----------------------------------------------------------------------------
@@ -49,7 +51,7 @@ VISU_IsoSurfacesPL
 
   myContourFilter = vtkContourFilter::New();
 
-  myCellDataToPointData = vtkCellDataToPointData::New();
+  myCellDataToPointData = VISU_CellDataToPointData::New();
 }
 
 
@@ -83,7 +85,7 @@ VISU_IsoSurfacesPL
 void
 VISU_IsoSurfacesPL
 ::DoShallowCopy(VISU_PipeLine *thePipeLine,
-               bool theIsCopyInput)
+                bool theIsCopyInput)
 {
   Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
 
@@ -91,6 +93,7 @@ VISU_IsoSurfacesPL
     SetNbParts(aPipeLine->GetNbParts());
     vtkFloatingPointType aRange[2] = {aPipeLine->GetMin(), aPipeLine->GetMax()};
     SetRange(aRange);
+    SetRangeFixed(aPipeLine->IsRangeFixed());
   }
 }
 
@@ -134,15 +137,20 @@ VISU_IsoSurfacesPL
 //----------------------------------------------------------------------------
 void
 VISU_IsoSurfacesPL
-::SetRange(vtkFloatingPointType theRange[2])
+::SetRange(vtkFloatingPointType theRange[2], bool theIsForced)
 {
-  if(VISU::CheckIsSameRange(myRange, theRange))
+  if(VISU::CheckIsSameRange(myRange, theRange) && !theIsForced)
     return;
 
   if(theRange[0] <= theRange[1]){
     myRange[0] = theRange[0];  
     myRange[1] = theRange[1];
     vtkFloatingPointType aRange[2] = {theRange[0], theRange[1]};
+    if( IsRangeFixed() ) {
+      double aDelta = fabs( aRange[1] - aRange[0] ) * GAP_COEFFICIENT;
+      aRange[0] += aDelta;
+      aRange[1] -= aDelta;
+    }
     if(GetScaling() == VTK_SCALE_LOG10)
       VISU_LookupTable::ComputeLogRange(theRange, aRange);
     myContourFilter->GenerateValues(GetNbParts(), aRange);
@@ -168,6 +176,25 @@ VISU_IsoSurfacesPL
 }
 
 
+//----------------------------------------------------------------------------
+void
+VISU_IsoSurfacesPL
+::SetRangeFixed(bool theIsFixed)
+{
+  myIsRangeFixed = theIsFixed;
+  SetRange( myRange, true );
+}
+
+
+//----------------------------------------------------------------------------
+bool
+VISU_IsoSurfacesPL
+::IsRangeFixed()
+{
+  return myIsRangeFixed;
+}
+
+
 void
 //----------------------------------------------------------------------------
 VISU_IsoSurfacesPL
@@ -180,6 +207,8 @@ VISU_IsoSurfacesPL
   vtkFloatingPointType aScalarRange[2];
   GetSourceRange(aScalarRange);
   SetRange(aScalarRange);
+
+  SetRangeFixed(true);
 }
 
 //----------------------------------------------------------------------------
@@ -190,8 +219,8 @@ VISU_IsoSurfacesPL
   Superclass::Build();
 
   VISU::CellDataToPoint(myContourFilter,
-                       myCellDataToPointData,
-                       GetMergedInput());
+                        myCellDataToPointData,
+                        GetMergedInput());
 
 }
 
@@ -233,6 +262,11 @@ VISU_IsoSurfacesPL
 
   vtkFloatingPointType aRange[2] = {GetMax() - theMapScale*(GetMax()-GetMin()), GetMax()};
   vtkFloatingPointType aNewRange[2] = {aRange[0], aRange[1]};
+  if( IsRangeFixed() ) {
+    double aDelta = fabs( aNewRange[1] - aNewRange[0] ) * GAP_COEFFICIENT;
+    aNewRange[0] += aDelta;
+    aNewRange[1] -= aDelta;
+  }
   if(GetScaling() == VTK_SCALE_LOG10)
     VISU_LookupTable::ComputeLogRange(aRange,aNewRange);
   myContourFilter->GenerateValues(GetNbParts(), aNewRange);