From: apo Date: Wed, 28 Sep 2005 13:43:19 +0000 (+0000) Subject: To calculate min/max for vector modulus X-Git-Tag: BR-D5-38-2003_D2005-12-10~118 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e4522f454b2aa3a58ede833ad1df370ec5926371;p=modules%2Fvisu.git To calculate min/max for vector modulus --- diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 6cf610fa..8ea39fb0 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -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; diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 6031a74a..166cbbee 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -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,"- "<