From: rnv Date: Fri, 25 Jul 2008 12:32:24 +0000 (+0000) Subject: Fix for issue 0016764: EDF 553 VISU : In Animation Bad range by default in Scalarmap. X-Git-Tag: V4_1_0_maintainance_20080801 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8522f970af36cebc53ae639fa48c8348014bf573;p=modules%2Fvisu.git Fix for issue 0016764: EDF 553 VISU : In Animation Bad range by default in Scalarmap. Comment from Aurélien Motteux 2007-11-08. --- diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index a31e0cf3..6a531027 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -1554,6 +1554,7 @@ void BuildTimeStampMinMax(MED::SharedPtr theTimeStampValue, const MED::TGeom2Gauss& theGeom2Gauss, VISU::TMinMaxArr& theMinMaxArr, + VISU::TMinMaxArr& theAverageMinMaxArr, TInt theNbComp, TInt theNbComp2) { @@ -1575,7 +1576,8 @@ BuildTimeStampMinMax(MED::SharedPtr theTimeStampValue, "; aNbElem = "<(CastToFloatTimeStampValue(aTimeStampValue), aGeom2Gauss, aMinMaxArr, + anAverageMinMaxArr, aNbComp, aNbComp2); else BuildTimeStampMinMax(CastToIntTimeStampValue(aTimeStampValue), aGeom2Gauss, aMinMaxArr, + anAverageMinMaxArr, aNbComp, aNbComp2); diff --git a/src/CONVERTOR/VISU_Structures.cxx b/src/CONVERTOR/VISU_Structures.cxx index 35e2791f..8a17d7e1 100644 --- a/src/CONVERTOR/VISU_Structures.cxx +++ b/src/CONVERTOR/VISU_Structures.cxx @@ -78,7 +78,8 @@ namespace VISU ::TField(): myNbComp(0), myEntity(TEntity(-1)), - myIsMinMaxInitilized(false) + myIsMinMaxInitilized(false), + myIsELNO( false ) {} diff --git a/src/CONVERTOR/VISU_Structures.hxx b/src/CONVERTOR/VISU_Structures.hxx index 31f3e626..dec5f84f 100644 --- a/src/CONVERTOR/VISU_Structures.hxx +++ b/src/CONVERTOR/VISU_Structures.hxx @@ -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(); diff --git a/src/CONVERTOR/VISU_Structures_impl.cxx b/src/CONVERTOR/VISU_Structures_impl.cxx index 1b69db66..b9451be9 100644 --- a/src/CONVERTOR/VISU_Structures_impl.cxx +++ b/src/CONVERTOR/VISU_Structures_impl.cxx @@ -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; } } @@ -1393,7 +1396,13 @@ namespace VISU return myMinMaxArr[theCompID]; } - + TMinMax + TFieldImpl + ::GetAverageMinMax(vtkIdType theCompID) + { + return myAverageMinMaxArr[theCompID]; + } + //---------------------------------------------------------------------------- const PMeshValue& TGeom2Value diff --git a/src/CONVERTOR/VISU_Structures_impl.hxx b/src/CONVERTOR/VISU_Structures_impl.hxx index 6b4bc01d..ffd9fbb4 100644 --- a/src/CONVERTOR/VISU_Structures_impl.hxx +++ b/src/CONVERTOR/VISU_Structures_impl.hxx @@ -827,10 +827,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 }; diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index e0eb4188..7d485cae 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -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 diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index 9046637c..c2035a21 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -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 diff --git a/src/VISU_I/VISU_GaussPoints_i.cc b/src/VISU_I/VISU_GaussPoints_i.cc index 79281b6e..61257495 100644 --- a/src/VISU_I/VISU_GaussPoints_i.cc +++ b/src/VISU_I/VISU_GaussPoints_i.cc @@ -1215,3 +1215,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 ) ); +} diff --git a/src/VISU_I/VISU_GaussPoints_i.hh b/src/VISU_I/VISU_GaussPoints_i.hh index 884d1b36..39edfd10 100644 --- a/src/VISU_I/VISU_GaussPoints_i.hh +++ b/src/VISU_I/VISU_GaussPoints_i.hh @@ -285,6 +285,14 @@ namespace VISU virtual void RemoveAllGeom(); + + virtual + vtkFloatingPointType + GetComponentMin(vtkIdType theCompID); + + virtual + vtkFloatingPointType + GetComponentMax(vtkIdType theCompID); protected: //! Redefines VISU_ColoredPrs3d_i::DoSetInput diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index b191ea12..b5f5938a 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -463,3 +463,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 ) ); +} diff --git a/src/VISU_I/VISU_ScalarMap_i.hh b/src/VISU_I/VISU_ScalarMap_i.hh index e83d332b..44a7ba96 100644 --- a/src/VISU_I/VISU_ScalarMap_i.hh +++ b/src/VISU_I/VISU_ScalarMap_i.hh @@ -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; };