From: ouv Date: Fri, 9 Oct 2009 14:21:58 +0000 (+0000) Subject: Issue 0020518: [CEA 357] VISU representation of uniform cell FIELD X-Git-Tag: V5_1_3rc1~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f9a6c885e3e30b645ab98e513cabf0827b27cd03;p=modules%2Fvisu.git Issue 0020518: [CEA 357] VISU representation of uniform cell FIELD --- diff --git a/src/PIPELINE/VISU_Extractor.cxx b/src/PIPELINE/VISU_Extractor.cxx index 4cdfb583..361f5849 100644 --- a/src/PIPELINE/VISU_Extractor.cxx +++ b/src/PIPELINE/VISU_Extractor.cxx @@ -179,17 +179,12 @@ Component2Scalars(vtkDataArray *theInputDataArray, //---------------------------------------------------------------------------- template void -CutFieldDataTempl(vtkDataArray *theInputDataArray, - TValueType* theDataPtr, - vtkIdType theNbOfTuples) +CutScalarsTempl(TValueType* theDataPtr, + vtkIdType theNbOfTuples, + int theDecimals) { - SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); - int aDecimals = aResourceMgr->integerValue("VISU", "floating_point_precision", 6); - for (vtkIdType aTupleId = 0; aTupleId < theNbOfTuples; aTupleId++) { - double aValue; - theInputDataArray->GetTuple(aTupleId, &aValue); - *theDataPtr = TValueType(CutValue(aValue, aDecimals)); + *theDataPtr = TValueType(CutValue(*theDataPtr, theDecimals)); theDataPtr++; } } @@ -262,6 +257,33 @@ ExecuteScalars(vtkIdType theNbOfTuples, anOutputScalars->Delete(); } +//--------------------------------------------------------------- +template void +CutScalars(vtkIdType theNbOfTuples, + TDataSetAttributesType* theData) +{ + if (theNbOfTuples < 1) + return; + + vtkDataArray *aScalars = theData->GetScalars(); + if (!aScalars) + return; + + vtkIdType aDataType = aScalars->GetDataType(); + void *aPtr = aScalars->GetVoidPointer(0); + + SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); + int aDecimals = aResourceMgr->integerValue("VISU", "floating_point_precision", 6); + + switch(aDataType) { + vtkTemplateMacro3(CutScalarsTempl, + (VTK_TT *)(aPtr), + theNbOfTuples, + aDecimals); + default: + break; + } +} //--------------------------------------------------------------- int @@ -282,7 +304,7 @@ VISU_Extractor int aNbElems = anInput->GetNumberOfPoints(); if ( anInputPointData->GetAttribute( vtkDataSetAttributes::VECTORS ) ) ExecuteScalars( aNbElems, myScalarMode, myGaussMetric, anInputPointData, anOutputPointData ); - CutFieldData( aNbElems, anOutputPointData ); + CutScalars( aNbElems, anOutputPointData ); } vtkCellData *anInputCellData = anInput->GetCellData(); @@ -292,41 +314,8 @@ VISU_Extractor int aNbElems = anInput->GetNumberOfCells(); if ( anInputCellData->GetAttribute( vtkDataSetAttributes::VECTORS ) ) ExecuteScalars( aNbElems, myScalarMode, myGaussMetric, anInputCellData, anOutputCellData ); - CutFieldData( aNbElems, anOutputCellData ); + CutScalars( aNbElems, anOutputCellData ); } return 1; } - -//--------------------------------------------------------------- - -void VISU_Extractor::CutFieldData(int theNbElems, vtkDataSetAttributes *theData ) -{ - if (theNbElems < 1) return; - - vtkDataArray* aFieldArray = NULL; - switch (myGaussMetric) { - case VISU::AVERAGE_METRIC: aFieldArray = theData->GetArray("VISU_FIELD"); break; - case VISU::MINIMUM_METRIC: aFieldArray = theData->GetArray("VISU_FIELD_GAUSS_MIN"); break; - case VISU::MAXIMUM_METRIC: aFieldArray = theData->GetArray("VISU_FIELD_GAUSS_MAX"); break; - } - if( !aFieldArray ) return; - - vtkIdType anInputDataType = aFieldArray->GetDataType(); - vtkDataArray *aScalars = vtkDataArray::CreateDataArray(anInputDataType); - aScalars->SetNumberOfComponents( 1 ); - aScalars->SetNumberOfTuples( theNbElems ); - void *aPtr = aScalars->GetVoidPointer(0); - - switch (anInputDataType) { - vtkTemplateMacro3(CutFieldDataTempl, - aFieldArray, - (VTK_TT *)(aPtr), - theNbElems); - default: - break; - } - - theData->SetScalars(aScalars); - aScalars->Delete(); -} diff --git a/src/PIPELINE/VISU_Extractor.hxx b/src/PIPELINE/VISU_Extractor.hxx index 23a284ed..5d6b8874 100644 --- a/src/PIPELINE/VISU_Extractor.hxx +++ b/src/PIPELINE/VISU_Extractor.hxx @@ -31,7 +31,6 @@ #include "VISU_ConvertorDef.hxx" #include -class vtkDataSetAttributes; //---------------------------------------------------------------------------- class VISU_PIPELINE_EXPORT VISU_Extractor : public vtkDataSetAlgorithm @@ -69,8 +68,6 @@ protected: int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); - void CutFieldData(int theNbElems, vtkDataSetAttributes *theData); - int myScalarMode; VISU::TGaussMetric myGaussMetric; };