Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/visu.git] / src / PIPELINE / VISU_DeformedShapeAndScalarMapPL.cxx
index 001eb96202583888c5209ac67b28c531aa8fad77..ddff1cb32999363758f38b22113448e1f34a759d 100644 (file)
@@ -1,24 +1,22 @@
-//  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
+// 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 DeformedShapeAndScalarMapPL
 // File:    VISU_DeformedShapeAndScalarMapPL.cxx
 // Author:  Eugeny Nikolaev
 #include <vtkImplicitBoolean.h>
 #include <vtkImplicitFunction.h>
 #include <vtkUnstructuredGrid.h>
-#include <vtkCellDataToPointData.h>
 #include <vtkPointDataToCellData.h>
 #include <vtkImplicitFunctionCollection.h>
 
+#ifdef WNT
+#include <float.h>
+#define isnan _isnan
+#endif
 
 //----------------------------------------------------------------------------
 vtkStandardNewMacro(VISU_DeformedShapeAndScalarMapPL)
@@ -72,7 +73,7 @@ VISU_DeformedShapeAndScalarMapPL
 
   myScalarsFieldTransform = VISU_FieldTransform::New();
 
-  myCellDataToPointData = vtkCellDataToPointData::New();
+  myCellDataToPointData = VISU_CellDataToPointData::New();
   myScalarsElnoDisassembleFilter = VISU_ElnoDisassembleFilter::New();
 
   vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New();
@@ -136,10 +137,10 @@ VISU_DeformedShapeAndScalarMapPL
   GetMapper()->ScalarVisibilityOn();
 
   VISU::CellDataToPoint(myWarpVector,
-                       myCellDataToPointData,
-                       GetMergedInput());
+                        myCellDataToPointData,
+                        GetMergedInput());
   
-  myScalars = GetMergedInput();
+  myScalars = vtkUnstructuredGrid::SafeDownCast(GetMergedInput());
 
   UpdateScalars();
 
@@ -231,7 +232,7 @@ VISU_DeformedShapeAndScalarMapPL
 void
 VISU_DeformedShapeAndScalarMapPL
 ::DoShallowCopy(VISU_PipeLine *thePipeLine,
-               bool theIsCopyInput)
+                bool theIsCopyInput)
 {
   Superclass::DoShallowCopy(thePipeLine, theIsCopyInput);
 
@@ -254,7 +255,7 @@ VISU_DeformedShapeAndScalarMapPL
   if(GetScalars() == theScalars)
     return;
   
-  myScalars = theScalars;
+  myScalars = vtkUnstructuredGrid::SafeDownCast(theScalars);
   UpdateScalars();
 }
 
@@ -430,6 +431,9 @@ void
 VISU_DeformedShapeAndScalarMapPL
 ::SetScalarRange(vtkFloatingPointType theRange[2])
 {
+  if (isnan(theRange[0]) || isnan(theRange[1]))
+    throw std::runtime_error("NAN values in the presentation");
+
   if(VISU::CheckIsSameRange(theRange, GetScalarRange()))
     return;
 
@@ -460,4 +464,28 @@ VISU_DeformedShapeAndScalarMapPL
 {
   myScalarsExtractor->Update();
   myScalarsExtractor->GetUnstructuredGridOutput()->GetScalarRange(theRange);
+
+  if (isnan(theRange[0]) || isnan(theRange[1]))
+    throw std::runtime_error("NAN values in the presentation");
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_DeformedShapeAndScalarMapPL
+::SetGaussMetric(VISU::TGaussMetric theGaussMetric) 
+{
+  if(GetGaussMetric() == theGaussMetric)
+    return;
+
+  myScalarsExtractor->SetGaussMetric(theGaussMetric);
+}
+
+
+//----------------------------------------------------------------------------
+VISU::TGaussMetric
+VISU_DeformedShapeAndScalarMapPL
+::GetGaussMetric() 
+{
+  return myScalarsExtractor->GetGaussMetric();
 }