]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
merge from V4_1_0_maintainance branch (from tag mergeto_BR_QT4_Dev_29Jul08) mergefrom_V4_1_0_maintainance_29Jul08
authorvsr <vsr@opencascade.com>
Tue, 29 Jul 2008 15:20:59 +0000 (15:20 +0000)
committervsr <vsr@opencascade.com>
Tue, 29 Jul 2008 15:20:59 +0000 (15:20 +0000)
src/CONVERTOR/VISU_MedConvertor.cxx
src/CONVERTOR/VISU_Structures.cxx
src/CONVERTOR/VISU_Structures.hxx
src/CONVERTOR/VISU_Structures_impl.cxx
src/CONVERTOR/VISU_Structures_impl.hxx
src/VISU_I/VISU_ColoredPrs3d_i.cc
src/VISU_I/VISU_ColoredPrs3d_i.hh
src/VISU_I/VISU_GaussPoints_i.cc
src/VISU_I/VISU_GaussPoints_i.hh
src/VISU_I/VISU_ScalarMap_i.cc
src/VISU_I/VISU_ScalarMap_i.hh

index e86e2e16a4662b0d3b7e3f059379978bd3e804df..153f76f1f0ad165ccf0c9a5ca13f8b594abadc5a 100644 (file)
@@ -1553,6 +1553,7 @@ void
 BuildTimeStampMinMax(MED::SharedPtr<TimeStampValueType> theTimeStampValue,
                     const MED::TGeom2Gauss& theGeom2Gauss,
                     VISU::TMinMaxArr& theMinMaxArr,
+                     VISU::TMinMaxArr& theAverageMinMaxArr,
                     TInt theNbComp,
                     TInt theNbComp2)
 {
@@ -1574,7 +1575,8 @@ BuildTimeStampMinMax(MED::SharedPtr<TimeStampValueType> theTimeStampValue,
            "; aNbElem = "<<aNbElem<<
            "; aNbGauss = "<<aNbGauss<<
            endl);
-                 
+    
+    bool isAverageByGaussPoints = (aNbGauss > 1);
     // To calculate min/max per components
     for(TInt iElem = 0; iElem < aNbElem; iElem++){
       typename TimeStampValueType::TTMeshValue::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
@@ -1583,11 +1585,27 @@ BuildTimeStampMinMax(MED::SharedPtr<TimeStampValueType> theTimeStampValue,
        VISU::TMinMax& aMinMax = theMinMaxArr[iComp+1];
        vtkFloatingPointType& aMin = aMinMax.first;
        vtkFloatingPointType& aMax = aMinMax.second;
-       for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
+        VISU::TMinMax& anAverageMinMax = theAverageMinMaxArr[iComp+1];
+        vtkFloatingPointType& anAverageMin = anAverageMinMax.first;
+       vtkFloatingPointType& anAverageMax = anAverageMinMax.second;
+        vtkFloatingPointType anAverageValue = 0.0;
+        for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
          const vtkFloatingPointType& aVal = aMValueSlice[iGauss];
-         aMin = std::min(aMin,aVal);
-         aMax = std::max(aMax,aVal);
+          aMin = std::min(aMin,aVal);
+          aMax = std::max(aMax,aVal);          
+          if(isAverageByGaussPoints){
+            anAverageValue += aVal;
+          }
+          else {
+            anAverageMin = aMin;
+            anAverageMax = aMax;
+          }
        }
+        if(isAverageByGaussPoints){
+          anAverageValue /= aNbGauss;
+          anAverageMin = std::min(anAverageMin,anAverageValue);
+          anAverageMax = std::max(anAverageMax,anAverageValue);
+        }
       }
     }
                  
@@ -1595,18 +1613,42 @@ BuildTimeStampMinMax(MED::SharedPtr<TimeStampValueType> theTimeStampValue,
     VISU::TMinMax& aMinMax = theMinMaxArr[0];
     vtkFloatingPointType& aMin = aMinMax.first;
     vtkFloatingPointType& aMax = aMinMax.second;
+    VISU::TMinMax& anAverageMinMax = theAverageMinMaxArr[0];
+    vtkFloatingPointType& anAverageMin = anAverageMinMax.first;
+    vtkFloatingPointType& anAverageMax = anAverageMinMax.second;
     for(TInt iElem = 0; iElem < aNbElem; iElem++){
       typename TimeStampValueType::TTMeshValue::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetGaussValueSliceArr(iElem);
       for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
-       const typename TimeStampValueType::TTMeshValue::TCValueSlice& aMValueSlice = aMValueSliceArr[iGauss];
-       vtkFloatingPointType aValue = 0.0;
-       for(TInt iComp = 0; iComp < theNbComp2; iComp++){
-         vtkFloatingPointType aVal = aMValueSlice[iComp];
-         aValue += aVal*aVal;
-       }
-       aValue = sqrt(aValue);
-       aMin = std::min(aMin,aValue);
-       aMax = std::max(aMax,aValue);
+        const typename TimeStampValueType::TTMeshValue::TCValueSlice& aMValueSlice = aMValueSliceArr[iGauss];
+        vtkFloatingPointType aValue = 0.0;
+        for(TInt iComp = 0; iComp < theNbComp2; iComp++){
+          vtkFloatingPointType aVal = aMValueSlice[iComp];
+          aValue += aVal*aVal;
+        }
+        aValue = sqrt(aValue);
+        aMin = std::min(aMin,aValue);
+        aMax = std::max(aMax,aValue);
+      }
+      if(isAverageByGaussPoints){
+        typename TimeStampValueType::TTMeshValue::TCValueSliceArr aMCompValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
+        vtkFloatingPointType aValue = 0.0;
+        for(TInt iComp = 0; iComp < theNbComp2; iComp++){
+          const typename TimeStampValueType::TTMeshValue::TCValueSlice& aMCompValueSlice = aMCompValueSliceArr[iComp];
+          vtkFloatingPointType anAverageValue = 0.0;
+          for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
+            const vtkFloatingPointType& aVal = aMCompValueSlice[iGauss];
+            anAverageValue += aVal;
+          }
+          anAverageValue /= aNbGauss;
+          aValue += anAverageValue*anAverageValue;
+        }
+        aValue = sqrt(aValue);
+        anAverageMin = std::min(anAverageMin,aValue);
+        anAverageMax = std::max(anAverageMax,aValue);
+      }
+      else {
+        anAverageMin = aMin;
+        anAverageMax = aMax;
       }
     }
   }
@@ -1692,6 +1734,7 @@ VISU_MedConvertor
            aNbComp2 = 3;
 
          VISU::TMinMaxArr& aMinMaxArr = aField->myMinMaxArr;
+          VISU::TMinMaxArr& anAverageMinMaxArr = aField->myAverageMinMaxArr;
          TSetIsDone aSetIsDone(aField->myIsMinMaxInitilized);
          for(TInt iTimeStamp = aNbTimeStamps; iTimeStamp >= 1; iTimeStamp--){
            VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPTimeStampInfo()");
@@ -1720,12 +1763,14 @@ VISU_MedConvertor
                 BuildTimeStampMinMax<MED::TFloatTimeStampValue>(CastToFloatTimeStampValue(aTimeStampValue),
                                                                 aGeom2Gauss,
                                                                 aMinMaxArr,
+                                                                anAverageMinMaxArr,
                                                                 aNbComp,
                                                                 aNbComp2);
               else
                 BuildTimeStampMinMax<MED::TIntTimeStampValue>(CastToIntTimeStampValue(aTimeStampValue),
                                                               aGeom2Gauss,
                                                               aMinMaxArr,
+                                                              anAverageMinMaxArr,
                                                               aNbComp,
                                                               aNbComp2);
 
index 35e2791fe99866b5122b55413ca25c4ec91ea90b..8a17d7e1af07e42067c7ce55ddab0c32eccd0360 100644 (file)
@@ -78,7 +78,8 @@ namespace VISU
   ::TField(): 
     myNbComp(0),
     myEntity(TEntity(-1)),
-    myIsMinMaxInitilized(false)
+    myIsMinMaxInitilized(false),
+    myIsELNO( false )
   {}
   
   
index 31f3e626e191e056c86422c39dbe66de29dbf4fd..dec5f84fd927ce13daf800de5fee61e6549513db 100644 (file)
@@ -219,6 +219,7 @@ namespace VISU
     TNames myCompNames; //!< Contains names of components of the MED FIELD
     TNames myUnitNames; //!< Contains names of units of the MED FIELD
     vtkIdType myNbComp; //!< Keeps number of components for the MED FIELD
+    bool myIsELNO;      //!< Defines whether this field contains specific "ELNO" data or not
 
     //! Calculate min/max values for each of the MED FIELD components among all its timestamps
     /*!
@@ -229,6 +230,11 @@ namespace VISU
     TMinMax 
     GetMinMax(vtkIdType theCompID) = 0;
     
+    //! Calculate average min/max values for each of the MED FIELD components among all its timestamps
+    virtual
+    TMinMax 
+    GetAverageMinMax(vtkIdType theCompID) = 0;
+    
     bool myIsMinMaxInitilized; //!< Is the min / max values are calculated
 
     TField();
index 1b69db6643a0c58c661773c432b6f7642a059486..6ed0a63d0a7777a870f6d9bf376bd772870dc4b2 100644 (file)
@@ -1359,7 +1359,6 @@ namespace VISU
   ::TFieldImpl()
     : myDataSize( 0 )
     , myDataType( 0 )
-    , myIsELNO( false )
   {}
 
   void 
@@ -1372,10 +1371,14 @@ namespace VISU
     myCompNames.resize(theNbComp);
     myUnitNames.resize(theNbComp);
     myMinMaxArr.resize(theNbComp + 1);
+    myAverageMinMaxArr.resize(theNbComp + 1);
     for(vtkIdType iComp = 0; iComp <= theNbComp; iComp++){
       TMinMax& aMinMax = myMinMaxArr[iComp];
       aMinMax.first = VTK_LARGE_FLOAT;
       aMinMax.second = -VTK_LARGE_FLOAT;
+      TMinMax& anAverageMinMax = myAverageMinMaxArr[iComp];
+      anAverageMinMax.first = VTK_LARGE_FLOAT;
+      anAverageMinMax.second = -VTK_LARGE_FLOAT;
     }
   }
 
@@ -1394,6 +1397,13 @@ namespace VISU
   }
 
 
+  TMinMax 
+  TFieldImpl
+  ::GetAverageMinMax(vtkIdType theCompID)
+  {
+    return myAverageMinMaxArr[theCompID];
+  }
+  
   //----------------------------------------------------------------------------
   const PMeshValue& 
   TGeom2Value
index 8819f492999a7e15f6abe918ac3d482c4bc5c385..9cd67758b9bd6a95dae4ccd4ad2d82657ff15856 100644 (file)
@@ -828,10 +828,16 @@ namespace VISU
     TMinMax 
     GetMinMax(vtkIdType theCompID);
 
+    //! Implement the TField::GetAverageMinMax
+    virtual
+    TMinMax 
+    GetAverageMinMax(vtkIdType theCompID);
+
     vtkIdType myDataSize; //!< Keeps size of the assigned data
     vtkIdType myDataType; //!< Keeps type idetificator of the mesh data
     TMinMaxArr myMinMaxArr; //!< Keeps min/max values for each component of the MED FIELD
-    bool myIsELNO; //!< Defines whether this field contains specific "ELNO" data or not
+    TMinMaxArr myAverageMinMaxArr; //!< Keeps average by Gauss Points min/max values for each component of the MED FIELD
+                                   //!< If Nb of Gauss Points <=1 myAverageMinMaxArr equal myMinMaxArr
   };
 
 
index 787eba58d4dfb0bafb68cdd58b62ca17f5714ec0..1f153a755e49979edb4e88f7df6c6e989769d0e3 100644 (file)
@@ -86,8 +86,10 @@ namespace VISU
   {
     if(!theResult->IsMinMaxDone())
       theResult->GetInput()->BuildMinMax();
-    
-    return theField->GetMinMax(theCompID);
+    if(theField->myIsELNO)
+      return theField->GetMinMax(theCompID);
+    else
+      return theField->GetAverageMinMax(theCompID);
   }
 
   //---------------------------------------------------------------
@@ -837,82 +839,6 @@ VISU::ColoredPrs3d_i
 }
 
 
-//----------------------------------------------------------------------------
-struct TGetComponentMin: public SALOME_Event
-{
-  VISU::ColoredPrs3d_i* myColoredPrs3d;
-  vtkIdType myCompID;
-
-  typedef CORBA::Double TResult;
-  TResult myResult;
-  
-  TGetComponentMin( VISU::ColoredPrs3d_i* theColoredPrs3d,
-                   vtkIdType theCompID ):
-    myColoredPrs3d( theColoredPrs3d ),
-    myCompID( theCompID )
-  {}
-    
-  virtual
-  void
-  Execute()
-  {
-    VISU::PMinMaxController aMinMaxController = myColoredPrs3d->GetMinMaxController();
-    if ( aMinMaxController ) {
-      myResult = aMinMaxController->GetComponentMin( myCompID );
-    } else {
-      VISU::TMinMax aTMinMax = myColoredPrs3d->GetScalarField()->GetMinMax( myCompID );
-      myResult = aTMinMax.first;
-    }
-  }
-};
-
-
-//----------------------------------------------------------------------------
-vtkFloatingPointType 
-VISU::ColoredPrs3d_i
-::GetComponentMin(vtkIdType theCompID)
-{
-  return ProcessEvent( new TGetComponentMin( this, theCompID ) );
-}
-
-//----------------------------------------------------------------------------
-struct TGetComponentMax: public SALOME_Event
-{
-  VISU::ColoredPrs3d_i* myColoredPrs3d;
-  vtkIdType myCompID;
-
-  typedef CORBA::Double TResult;
-  TResult myResult;
-  
-  TGetComponentMax( VISU::ColoredPrs3d_i* theColoredPrs3d,
-                   vtkIdType theCompID ):
-    myColoredPrs3d( theColoredPrs3d ),
-    myCompID( theCompID )
-  {}
-    
-  virtual
-  void
-  Execute()
-  {
-    VISU::PMinMaxController aMinMaxController = myColoredPrs3d->GetMinMaxController();
-    if ( aMinMaxController ) {
-      myResult = aMinMaxController->GetComponentMax( myCompID );
-    } else {
-      VISU::TMinMax aTMinMax = myColoredPrs3d->GetScalarField()->GetMinMax( myCompID );
-      myResult = aTMinMax.second;
-    }
-  }
-};
-
-
-//----------------------------------------------------------------------------
-vtkFloatingPointType 
-VISU::ColoredPrs3d_i
-::GetComponentMax(vtkIdType theCompID)
-{
-  return ProcessEvent( new TGetComponentMax( this, theCompID ) );
-}
-
 //----------------------------------------------------------------------------
 void
 VISU::ColoredPrs3d_i
index 9046637c40d5369683d74bf5c7fc7fb0ed6a5204..c2035a2125f7c68fb711d2d28f3e1fd5c07b46ac 100644 (file)
@@ -228,11 +228,11 @@ namespace VISU
 
     virtual
     vtkFloatingPointType
-    GetComponentMin(vtkIdType theCompID);
+    GetComponentMin(vtkIdType theCompID) = 0;
 
     virtual
     vtkFloatingPointType
-    GetComponentMax(vtkIdType theCompID);
+    GetComponentMax(vtkIdType theCompID) = 0;
 
     virtual
     CORBA::Double 
index cbb1fe7fb8db2fb89bc93944194aaa66ebcf20ae..2fa9381553e457210e8ead41a852ce8c4c2fa56e 100644 (file)
@@ -1216,3 +1216,79 @@ VISU::GaussPoints_i
 {
   return mySpacing;
 }
+
+//----------------------------------------------------------------------------
+struct TGetComponentMin: public SALOME_Event
+{
+  VISU::ColoredPrs3d_i* myColoredPrs3d;
+  vtkIdType myCompID;
+  
+  typedef CORBA::Double TResult;
+  TResult myResult;
+  
+  TGetComponentMin( VISU::ColoredPrs3d_i* theColoredPrs3d,
+                   vtkIdType theCompID ):
+    myColoredPrs3d( theColoredPrs3d ),
+    myCompID( theCompID )
+  {}
+    
+  virtual
+  void
+  Execute()
+  {
+    VISU::PMinMaxController aMinMaxController = myColoredPrs3d->GetMinMaxController();
+    if ( aMinMaxController ) {
+      myResult = aMinMaxController->GetComponentMin( myCompID );
+    } else {
+      VISU::TMinMax aTMinMax = myColoredPrs3d->GetScalarField()->GetMinMax( myCompID );
+      myResult = aTMinMax.first;
+    }
+  }
+};
+
+
+//----------------------------------------------------------------------------
+vtkFloatingPointType 
+VISU::GaussPoints_i
+::GetComponentMin(vtkIdType theCompID)
+{
+  return ProcessEvent( new TGetComponentMin( this, theCompID ) );
+}
+
+//----------------------------------------------------------------------------
+struct TGetComponentMax: public SALOME_Event
+{
+  VISU::ColoredPrs3d_i* myColoredPrs3d;
+  vtkIdType myCompID;
+
+  typedef CORBA::Double TResult;
+  TResult myResult;
+  
+  TGetComponentMax( VISU::ColoredPrs3d_i* theColoredPrs3d,
+                   vtkIdType theCompID ):
+    myColoredPrs3d( theColoredPrs3d ),
+    myCompID( theCompID )
+  {}
+    
+  virtual
+  void
+  Execute()
+  {
+    VISU::PMinMaxController aMinMaxController = myColoredPrs3d->GetMinMaxController();
+    if ( aMinMaxController ) {
+      myResult = aMinMaxController->GetComponentMax( myCompID );
+    } else {
+      VISU::TMinMax aTMinMax = myColoredPrs3d->GetScalarField()->GetMinMax( myCompID );
+      myResult = aTMinMax.second;
+    }
+  }
+};
+
+
+//----------------------------------------------------------------------------
+vtkFloatingPointType 
+VISU::GaussPoints_i
+::GetComponentMax(vtkIdType theCompID)
+{
+  return ProcessEvent( new TGetComponentMax( this, theCompID ) );
+}
index 88e772eaa1d74c108e04c299328afd43fb9dd6b9..3a2109e01cfee0363bbbc1aa74d72faafdd82433 100644 (file)
@@ -287,6 +287,14 @@ namespace VISU
     virtual
     void
     RemoveAllGeom();
+
+    virtual
+    vtkFloatingPointType
+    GetComponentMin(vtkIdType theCompID);
+
+    virtual
+    vtkFloatingPointType
+    GetComponentMax(vtkIdType theCompID);
     
   protected:
     //! Redefines VISU_ColoredPrs3d_i::DoSetInput
index 61edb836ac49793a302c61c97f250b725a38a4f0..f0aba10aa462ef2d6295845bffa0eef745bc9a00 100644 (file)
@@ -464,3 +464,87 @@ VISU::ScalarMap_i
   }
   TSuperClass::UpdateActor(theActor);
 }
+
+//----------------------------------------------------------------------------
+struct TGetComponentMin: public SALOME_Event
+{
+  VISU::ColoredPrs3d_i* myColoredPrs3d;
+  vtkIdType myCompID;
+  
+  typedef CORBA::Double TResult;
+  TResult myResult;
+  
+  TGetComponentMin( VISU::ColoredPrs3d_i* theColoredPrs3d,
+                   vtkIdType theCompID ):
+    myColoredPrs3d( theColoredPrs3d ),
+    myCompID( theCompID )
+  {}
+    
+  virtual
+  void
+  Execute()
+  {
+    VISU::PMinMaxController aMinMaxController = myColoredPrs3d->GetMinMaxController();
+    if ( aMinMaxController ) {
+      myResult = aMinMaxController->GetComponentMin( myCompID );
+    } else {
+      VISU::TMinMax aTMinMax;
+      if(myColoredPrs3d->GetScalarField()->myIsELNO)
+       aTMinMax = myColoredPrs3d->GetScalarField()->GetMinMax( myCompID );
+      else
+       aTMinMax = myColoredPrs3d->GetScalarField()->GetAverageMinMax( myCompID );
+      myResult = aTMinMax.first;
+    }
+  }
+};
+
+
+//----------------------------------------------------------------------------
+vtkFloatingPointType 
+VISU::ScalarMap_i
+::GetComponentMin(vtkIdType theCompID)
+{
+  return ProcessEvent( new TGetComponentMin( this, theCompID ) );
+}
+
+//----------------------------------------------------------------------------
+struct TGetComponentMax: public SALOME_Event
+{
+  VISU::ColoredPrs3d_i* myColoredPrs3d;
+  vtkIdType myCompID;
+
+  typedef CORBA::Double TResult;
+  TResult myResult;
+  
+  TGetComponentMax( VISU::ColoredPrs3d_i* theColoredPrs3d,
+                   vtkIdType theCompID ):
+    myColoredPrs3d( theColoredPrs3d ),
+    myCompID( theCompID )
+  {}
+    
+  virtual
+  void
+  Execute()
+  {
+    VISU::PMinMaxController aMinMaxController = myColoredPrs3d->GetMinMaxController();
+    if ( aMinMaxController ) {
+      myResult = aMinMaxController->GetComponentMax( myCompID );
+    } else {
+      VISU::TMinMax aTMinMax;
+      if(myColoredPrs3d->GetScalarField()->myIsELNO)
+       aTMinMax = myColoredPrs3d->GetScalarField()->GetMinMax( myCompID );
+      else
+       aTMinMax = myColoredPrs3d->GetScalarField()->GetAverageMinMax( myCompID );
+      myResult = aTMinMax.second;
+    }
+  }
+};
+
+
+//----------------------------------------------------------------------------
+vtkFloatingPointType 
+VISU::ScalarMap_i
+::GetComponentMax(vtkIdType theCompID)
+{
+  return ProcessEvent( new TGetComponentMax( this, theCompID ) );
+}
index e83d332bda5c309f3fc2ee042dfa8306d4921f86..44a7ba96ed6875d1deedca2519bed2824d3131ee 100644 (file)
@@ -183,6 +183,14 @@ namespace VISU
     void
     UpdateActor(VISU_ActorBase* theActor);
 
+    virtual
+    vtkFloatingPointType
+    GetComponentMin(vtkIdType theCompID);
+
+    virtual
+    vtkFloatingPointType
+    GetComponentMax(vtkIdType theCompID);
+
   private:
     VISU_ScalarMapPL* myScalarMapPL;
   };