]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Issue 0020518: [CEA 357] VISU representation of uniform cell FIELD
authorouv <ouv@opencascade.com>
Fri, 9 Oct 2009 14:21:58 +0000 (14:21 +0000)
committerouv <ouv@opencascade.com>
Fri, 9 Oct 2009 14:21:58 +0000 (14:21 +0000)
src/PIPELINE/VISU_Extractor.cxx
src/PIPELINE/VISU_Extractor.hxx

index 4cdfb5834cabe328fa2130f483c94d836286389d..361f58497cf6a32a9bfd553b417eaa426adbd62a 100644 (file)
@@ -179,17 +179,12 @@ Component2Scalars(vtkDataArray *theInputDataArray,
 //----------------------------------------------------------------------------
 template<typename TValueType>
 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<typename TDataSetAttributesType> 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();
-}
index 23a284ed8453b8d99d6f6cfbf6fde11b66404cf2..5d6b8874faa76143e5df641ebd6e0c7bcefc74de 100644 (file)
@@ -31,7 +31,6 @@
 #include "VISU_ConvertorDef.hxx"
 #include <vtkDataSetAlgorithm.h>
 
-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;
 };