From 344a9cd90b51928b510ae5fb9a111051a96e921b Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 16 Sep 2009 10:57:45 +0000 Subject: [PATCH] IMP 0017328: min and max scalar map of results given at gauss points. A fix for the modulus case. --- src/PIPELINE/VISU_Extractor.cxx | 59 ++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 15 deletions(-) diff --git a/src/PIPELINE/VISU_Extractor.cxx b/src/PIPELINE/VISU_Extractor.cxx index 105e7f5f..241e0cbd 100644 --- a/src/PIPELINE/VISU_Extractor.cxx +++ b/src/PIPELINE/VISU_Extractor.cxx @@ -98,12 +98,31 @@ VISU_Extractor //---------------------------------------------------------------------------- -template +template void Module2Scalars(vtkDataArray *theInputDataArray, - TValueType* theOutputPtr, - vtkIdType theNbOfTuples, - VISU::TGaussMetric theGaussMetric) + TValueType* theOutputPtr, + vtkIdType theNbOfTuples) +{ + vtkIdType aNbComp = theInputDataArray->GetNumberOfComponents(); + std::vector 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 +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) { -- 2.39.2