Salome HOME
Merge from V5_1_main 14/05/2010
[modules/visu.git] / src / PIPELINE / VISU_FieldTransform.cxx
index 7816f8efed11371c8e0f525a566acad4120c6f7f..0b3a4eb2f1e124da62e133c02c879a1f329c7e66 100644 (file)
@@ -1,25 +1,28 @@
-//  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//  Copyright (C) 2007-2010  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 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
 //  File   : VISU_FieldTransform.cxx
 //  Module : VISU
-
+//
 #include "VISU_FieldTransform.hxx"
 #include "VTKViewer_Transform.h"
 #include "VISU_PipeLineUtils.hxx"
@@ -159,9 +162,9 @@ VISU_FieldTransform
 template<typename TValueType> 
 void
 LinearTransformVectors(TValueType* theInputPtr,
-                      TValueType* theOutputPtr,
-                      vtkIdType theNbOfTuples,
-                      vtkFloatingPointType theScale[3])
+                       TValueType* theOutputPtr,
+                       vtkIdType theNbOfTuples,
+                       vtkFloatingPointType theScale[3])
 {
   for(vtkIdType aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++){
     for(vtkIdType aComponentId = 0; aComponentId < 3; aComponentId++){
@@ -177,14 +180,14 @@ LinearTransformVectors(TValueType* theInputPtr,
 template<typename TValueType> 
 void
 NonLinearTransformVectors(vtkDataArray *theInputVectors,
-                         TValueType* theInputPtr,
-                         TValueType* theOutputPtr,
-                         vtkIdType theNbOfTuples,
-                         vtkFloatingPointType theScale[3],
-                         VISU_FieldTransform::TTransformFun theFunction,
-                         vtkFloatingPointType theModifiedScalarMin,
-                         vtkFloatingPointType theModifiedScalarDelta,
-                         vtkFloatingPointType theSourceScalarMax)
+                          TValueType* theInputPtr,
+                          TValueType* theOutputPtr,
+                          vtkIdType theNbOfTuples,
+                          vtkFloatingPointType theScale[3],
+                          VISU_FieldTransform::TTransformFun theFunction,
+                          vtkFloatingPointType theModifiedScalarMin,
+                          vtkFloatingPointType theModifiedScalarDelta,
+                          vtkFloatingPointType theSourceScalarMax)
 {
   for(vtkIdType aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++){
     vtkFloatingPointType anInputVector[3];
@@ -192,9 +195,9 @@ NonLinearTransformVectors(vtkDataArray *theInputVectors,
     vtkFloatingPointType aMagnification = vtkMath::Norm(anInputVector);
     if(aMagnification > Tolerance)
       aMagnification = 
-       ((*theFunction)(aMagnification) - theModifiedScalarMin) / 
-       theModifiedScalarDelta * theSourceScalarMax / 
-       aMagnification;
+        ((*theFunction)(aMagnification) - theModifiedScalarMin) / 
+        theModifiedScalarDelta * theSourceScalarMax / 
+        aMagnification;
     if(aMagnification < 0.0) 
       aMagnification = 0.0;
     for(vtkIdType aComponentId = 0; aComponentId < 3; aComponentId++){
@@ -210,11 +213,11 @@ NonLinearTransformVectors(vtkDataArray *theInputVectors,
 template<typename TDataSetAttributesType> 
 void
 ExecuteVectors(VISU_FieldTransform::TTransformFun theFunction,
-              VTKViewer_Transform* theTransform,
-              vtkFloatingPointType theScalarRange[2], 
-              vtkIdType theNbOfTuples,
-              TDataSetAttributesType* theInputData, 
-              TDataSetAttributesType* theOutputData)
+               VTKViewer_Transform* theTransform,
+               vtkFloatingPointType theScalarRange[2], 
+               vtkIdType theNbOfTuples,
+               TDataSetAttributesType* theInputData, 
+               TDataSetAttributesType* theOutputData)
 {
   vtkDataArray *anInputVectors = theInputData->GetVectors();
   if(!anInputVectors || theNbOfTuples < 1) 
@@ -244,25 +247,25 @@ ExecuteVectors(VISU_FieldTransform::TTransformFun theFunction,
   if(theFunction == &(VISU_FieldTransform::Ident)){
     switch(anInputDataType){
       vtkTemplateMacro4(LinearTransformVectors,
-                       (VTK_TT *)(anInputPtr), 
-                       (VTK_TT *)(anOutputPtr), 
-                       theNbOfTuples,
-                       aScale);
+                        (VTK_TT *)(anInputPtr), 
+                        (VTK_TT *)(anOutputPtr), 
+                        theNbOfTuples,
+                        aScale);
     default:
       break;
     }  
   }else{
     switch(anInputDataType){
       vtkTemplateMacro9(NonLinearTransformVectors,
-                       anInputVectors,
-                       (VTK_TT *)(anInputPtr), 
-                       (VTK_TT *)(anOutputPtr), 
-                       theNbOfTuples,
-                       aScale,
-                       theFunction,
-                       aScalarRange[0],
-                       aScalarDelta,
-                       theScalarRange[1]);
+                        anInputVectors,
+                        (VTK_TT *)(anInputPtr), 
+                        (VTK_TT *)(anOutputPtr), 
+                        theNbOfTuples,
+                        aScale,
+                        theFunction,
+                        aScalarRange[0],
+                        aScalarDelta,
+                        theScalarRange[1]);
     default:
       break;
     }  
@@ -277,11 +280,11 @@ ExecuteVectors(VISU_FieldTransform::TTransformFun theFunction,
 template<typename TValueType> 
 void
 NonLinearTransformScalars(vtkDataArray *theInputScalars,
-                         TValueType* theInputPtr,
-                         TValueType* theOutputPtr,
-                         vtkIdType theNbOfTuples,
-                         VISU_FieldTransform::TTransformFun theFunction,
-                         vtkFloatingPointType theModifiedScalarMin)
+                          TValueType* theInputPtr,
+                          TValueType* theOutputPtr,
+                          vtkIdType theNbOfTuples,
+                          VISU_FieldTransform::TTransformFun theFunction,
+                          vtkFloatingPointType theModifiedScalarMin)
 {
   for(vtkIdType aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++){
     vtkFloatingPointType aScalar = (*theFunction)(vtkFloatingPointType(*theInputPtr));
@@ -298,10 +301,10 @@ NonLinearTransformScalars(vtkDataArray *theInputScalars,
 template<typename TDataSetAttributesType> 
 void
 ExecuteScalars(VISU_FieldTransform::TTransformFun theFunction, 
-              vtkFloatingPointType theScalarRange[2],
-              vtkIdType theNbOfTuples, 
-              TDataSetAttributesType* theInputData, 
-              TDataSetAttributesType* theOutputData)
+               vtkFloatingPointType theScalarRange[2],
+               vtkIdType theNbOfTuples, 
+               TDataSetAttributesType* theInputData, 
+               TDataSetAttributesType* theOutputData)
 {
   vtkDataArray *anInputScalars = theInputData->GetScalars();
   if(!anInputScalars || theNbOfTuples < 1)
@@ -321,12 +324,12 @@ ExecuteScalars(VISU_FieldTransform::TTransformFun theFunction,
 
   switch(anInputDataType){
     vtkTemplateMacro6(NonLinearTransformScalars,
-                     anInputScalars,
-                     (VTK_TT *)(anInputPtr), 
-                     (VTK_TT *)(anOutputPtr), 
-                     theNbOfTuples,
-                     theFunction,
-                     aScalarRange[0]);
+                      anInputScalars,
+                      (VTK_TT *)(anInputPtr), 
+                      (VTK_TT *)(anOutputPtr), 
+                      theNbOfTuples,
+                      theFunction,
+                      aScalarRange[0]);
   default:
     break;
   }  
@@ -340,8 +343,8 @@ ExecuteScalars(VISU_FieldTransform::TTransformFun theFunction,
 int
 VISU_FieldTransform
 ::RequestData(vtkInformation *vtkNotUsed(request),
-             vtkInformationVector **inputVector,
-             vtkInformationVector *outputVector)
+              vtkInformationVector **inputVector,
+              vtkInformationVector *outputVector)
 {
   // get the info objects
   vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
@@ -362,30 +365,30 @@ VISU_FieldTransform
     output->GetCellData()->CopyVectorsOff();
 
     ExecuteScalars(myFunction,
-                  myScalarRange,
-                  input->GetNumberOfPoints(),
-                  input->GetPointData(),
-                  output->GetPointData());
+                   myScalarRange,
+                   input->GetNumberOfPoints(),
+                   input->GetPointData(),
+                   output->GetPointData());
 
     ExecuteVectors(myFunction,
-                  myTransform,
-                  myScalarRange,
-                  input->GetNumberOfPoints(),
-                  input->GetPointData(),
-                  output->GetPointData());
+                   myTransform,
+                   myScalarRange,
+                   input->GetNumberOfPoints(),
+                   input->GetPointData(),
+                   output->GetPointData());
 
     ExecuteScalars(myFunction,
-                  myScalarRange,
-                  input->GetNumberOfCells(),
-                  input->GetCellData(),
-                  output->GetCellData());
+                   myScalarRange,
+                   input->GetNumberOfCells(),
+                   input->GetCellData(),
+                   output->GetCellData());
 
     ExecuteVectors(myFunction,
-                  myTransform,
-                  myScalarRange,
-                  input->GetNumberOfCells(),
-                  input->GetCellData(),
-                  output->GetCellData());
+                   myTransform,
+                   myScalarRange,
+                   input->GetNumberOfCells(),
+                   input->GetCellData(),
+                   output->GetCellData());
   }else{
     output->GetPointData()->CopyAllOn();
     output->GetCellData()->CopyAllOn();