Comment from Aurélien Motteux 2007-11-08.
BuildTimeStampMinMax(MED::SharedPtr<TimeStampValueType> theTimeStampValue,
const MED::TGeom2Gauss& theGeom2Gauss,
VISU::TMinMaxArr& theMinMaxArr,
+ VISU::TMinMaxArr& theAverageMinMaxArr,
TInt theNbComp,
TInt theNbComp2)
{
"; 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);
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 = min(aMin,aVal);
- aMax = max(aMax,aVal);
+ aMin = min(aMin,aVal);
+ aMax = max(aMax,aVal);
+ if(isAverageByGaussPoints){
+ anAverageValue += aVal;
+ }
+ else {
+ anAverageMin = aMin;
+ anAverageMax = aMax;
+ }
}
+ if(isAverageByGaussPoints){
+ anAverageValue /= aNbGauss;
+ anAverageMin = min(anAverageMin,anAverageValue);
+ anAverageMax = max(anAverageMax,anAverageValue);
+ }
}
}
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 = min(aMin,aValue);
- aMax = 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 = min(aMin,aValue);
+ aMax = 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 = min(anAverageMin,aValue);
+ anAverageMax = max(anAverageMax,aValue);
+ }
+ else {
+ anAverageMin = aMin;
+ anAverageMax = aMax;
}
}
}
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()");
BuildTimeStampMinMax<MED::TFloatTimeStampValue>(CastToFloatTimeStampValue(aTimeStampValue),
aGeom2Gauss,
aMinMaxArr,
+ anAverageMinMaxArr,
aNbComp,
aNbComp2);
else
BuildTimeStampMinMax<MED::TIntTimeStampValue>(CastToIntTimeStampValue(aTimeStampValue),
aGeom2Gauss,
aMinMaxArr,
+ anAverageMinMaxArr,
aNbComp,
aNbComp2);
::TField():
myNbComp(0),
myEntity(TEntity(-1)),
- myIsMinMaxInitilized(false)
+ myIsMinMaxInitilized(false),
+ myIsELNO( false )
{}
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
/*!
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();
::TFieldImpl()
: myDataSize( 0 )
, myDataType( 0 )
- , myIsELNO( false )
{}
void
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;
}
}
return myMinMaxArr[theCompID];
}
-
+ TMinMax
+ TFieldImpl
+ ::GetAverageMinMax(vtkIdType theCompID)
+ {
+ return myAverageMinMaxArr[theCompID];
+ }
+
//----------------------------------------------------------------------------
const PMeshValue&
TGeom2Value
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
};
{
if(!theResult->IsMinMaxDone())
theResult->GetInput()->BuildMinMax();
-
- return theField->GetMinMax(theCompID);
+ if(theField->myIsELNO)
+ return theField->GetMinMax(theCompID);
+ else
+ return theField->GetAverageMinMax(theCompID);
}
//---------------------------------------------------------------
}
-//----------------------------------------------------------------------------
-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
virtual
vtkFloatingPointType
- GetComponentMin(vtkIdType theCompID);
+ GetComponentMin(vtkIdType theCompID) = 0;
virtual
vtkFloatingPointType
- GetComponentMax(vtkIdType theCompID);
+ GetComponentMax(vtkIdType theCompID) = 0;
virtual
CORBA::Double
{
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 ) );
+}
virtual
void
RemoveAllGeom();
+
+ virtual
+ vtkFloatingPointType
+ GetComponentMin(vtkIdType theCompID);
+
+ virtual
+ vtkFloatingPointType
+ GetComponentMax(vtkIdType theCompID);
protected:
//! Redefines VISU_ColoredPrs3d_i::DoSetInput
}
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 ) );
+}
void
UpdateActor(VISU_ActorBase* theActor);
+ virtual
+ vtkFloatingPointType
+ GetComponentMin(vtkIdType theCompID);
+
+ virtual
+ vtkFloatingPointType
+ GetComponentMax(vtkIdType theCompID);
+
private:
VISU_ScalarMapPL* myScalarMapPL;
};