]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
IMP 0017328: min and max scalar map of results given at gauss points. A fix for the... V5_1_main_20090918
authorjfa <jfa@opencascade.com>
Wed, 16 Sep 2009 10:57:45 +0000 (10:57 +0000)
committerjfa <jfa@opencascade.com>
Wed, 16 Sep 2009 10:57:45 +0000 (10:57 +0000)
src/PIPELINE/VISU_Extractor.cxx

index 105e7f5f4f45238cae553fd17a66e586ad722e23..241e0cbda3e081824da7f33e0cb929881b9b90c0 100644 (file)
@@ -98,12 +98,31 @@ VISU_Extractor
 
 
 //----------------------------------------------------------------------------
-template<typename TValueType>
+template<typename TValueType> 
 void
 Module2Scalars(vtkDataArray *theInputDataArray,
-               TValueType* theOutputPtr,
-               vtkIdType theNbOfTuples,
-               VISU::TGaussMetric theGaussMetric)
+              TValueType* theOutputPtr,
+              vtkIdType theNbOfTuples)
+{
+  vtkIdType aNbComp = theInputDataArray->GetNumberOfComponents();
+  std::vector<vtkFloatingPointType> anArray(aNbComp < 3? 3: aNbComp);
+  for(vtkIdType aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++){
+    theInputDataArray->GetTuple(aTupleId, &anArray[0]);
+    vtkFloatingPointType aVector[3] = {anArray[0], anArray[1], anArray[2]};
+    vtkFloatingPointType aScalar = sqrt(aVector[0]*aVector[0] + 
+                                       aVector[1]*aVector[1] + 
+                                       aVector[2]*aVector[2]);
+    *theOutputPtr = TValueType(aScalar);
+    theOutputPtr++;
+  }
+}
+
+template<typename TValueType>
+void
+Module2ScalarsMOD(vtkDataArray *theInputDataArray,
+                  TValueType* theOutputPtr,
+                  vtkIdType theNbOfTuples,
+                  VISU::TGaussMetric theGaussMetric)
 {
   vtkIdType aNbComp = theInputDataArray->GetNumberOfComponents();
   if (aNbComp != 3) // Min, Max, Avg
@@ -168,17 +187,27 @@ ExecuteScalars(vtkIdType theNbOfTuples,
   void *anOutputPtr = anOutputScalars->GetVoidPointer(0);
 
   if (theScalarMode == 0) {
-    aFieldArray = theInputData->GetArray("VISU_FIELD_GAUSS_MOD");
-    if (!aFieldArray)
-      return;
-    switch (anInputDataType) {
-      vtkTemplateMacro4(Module2Scalars,
-                        aFieldArray,
-                        (VTK_TT *)(anOutputPtr),
-                        theNbOfTuples,
-                        theGaussMetric);
-    default:
-      break;
+    vtkDataArray* aFieldArrayMOD = theInputData->GetArray("VISU_FIELD_GAUSS_MOD");
+    if (aFieldArrayMOD) {
+      switch (anInputDataType) {
+        vtkTemplateMacro4(Module2ScalarsMOD,
+                          aFieldArrayMOD,
+                          (VTK_TT *)(anOutputPtr),
+                          theNbOfTuples,
+                          theGaussMetric);
+      default:
+        break;
+      }
+    }
+    else {
+      switch (anInputDataType) {
+        vtkTemplateMacro3(Module2Scalars,
+                          aFieldArray,
+                          (VTK_TT *)(anOutputPtr),
+                          theNbOfTuples);
+      default:
+        break;
+      }
     }
   } else {
     switch (anInputDataType) {