]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To calculate min/max for vector modulus
authorapo <apo@opencascade.com>
Wed, 28 Sep 2005 13:43:19 +0000 (13:43 +0000)
committerapo <apo@opencascade.com>
Wed, 28 Sep 2005 13:43:19 +0000 (13:43 +0000)
src/CONVERTOR/VISU_Convertor_impl.cxx
src/CONVERTOR/VISU_MedConvertor.cxx

index 6cf610faccae34355a00bd41649a17d1f23e9227..8ea39fb0a45f50076e6f0515b4fa0a12a0ce723c 100644 (file)
@@ -591,8 +591,8 @@ namespace VISU
     myNbComp = theNbComp;
     myCompNames.resize(theNbComp);
     myUnitNames.resize(theNbComp);
-    myMinMaxArr.resize(theNbComp);
-    for(vtkIdType iComp = 0; iComp < theNbComp; iComp++){
+    myMinMaxArr.resize(theNbComp + 1);
+    for(vtkIdType iComp = 0; iComp <= theNbComp; iComp++){
       TMinMax& aMinMax = myMinMaxArr[iComp];
       aMinMax.first = VTK_LARGE_FLOAT;
       aMinMax.second = -VTK_LARGE_FLOAT;
index 6031a74ad6bab35112dcd4db6a3277029278ba5a..166cbbeee81495d46d9c16fa62141fd5595bef6f 100644 (file)
@@ -566,6 +566,12 @@ namespace
              endl);
       
       TInt aNbComp = myField->myNbComp;
+      int aNbComp2 = aNbComp;
+      if(aNbComp == 2 || aNbComp == 4)
+       aNbComp2 = 2;
+      else if(aNbComp > 4)
+       aNbComp2 = 3;
+
       TValField& aValField = myField->myValField;
       TMinMaxArr& aMinMaxArr = myField->myMinMaxArr;
       for(TInt iTimeStamp = 1; iTimeStamp <= myNbTimeStamps; iTimeStamp++){
@@ -602,11 +608,13 @@ namespace
            
            MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
            const MED::TMeshValue& aMMeshValue = aTimeStampValRef.GetMeshValue(aMGeom);
+
+           // To calculate min/max per components
            for(TInt iElem = 0; iElem < aNbElem; iElem++){
              MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
              for(TInt iComp = 0; iComp < aNbComp; iComp++){
                const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iComp];
-               TMinMax& aMinMax = aMinMaxArr[iComp];
+               TMinMax& aMinMax = aMinMaxArr[iComp+1];
                float& aMin = aMinMax.first;
                float& aMax = aMinMax.second;
                for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
@@ -616,10 +624,29 @@ namespace
                }
              }
            }
+
+           // To calculate min/max per vector modulus
+           TMinMax& aMinMax = aMinMaxArr[0];
+           float& aMin = aMinMax.first;
+           float& aMax = aMinMax.second;
+           for(TInt iElem = 0; iElem < aNbElem; iElem++){
+             MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetGaussValueSliceArr(iElem);
+             for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
+               const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iGauss];
+               float aValue = 0.0;
+               for(TInt iComp = 0; iComp < aNbComp2; iComp++){
+                 float aVal = aMValueSlice[iComp];
+                 aValue += aVal*aVal;
+               }
+               aValue = sqrt(aValue);
+               aMin = min(aMin,aValue);
+               aMax = max(aMax,aValue);
+             }
+           }
          }
        }
       }
-      for(TInt iComp = 0; iComp < aNbComp; iComp++){
+      for(TInt iComp = 0; iComp <= aNbComp; iComp++){
        VISU::TMinMax aMinMax = myField->GetMinMax(iComp);
        INITMSG(MYTHREADDEBUG,"- "<<this<<"; "<<iComp<<": "<<aMinMax.first<<"; "<<aMinMax.second<<endl);
       }