//----------------------------------------------------------------------------
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++;
}
}
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
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();
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();
-}