[vtk-developers] [VTK 0012778]: Use of Fielddata in the VTKArrayCalculator
Mantis Bug Tracker
mantis at public.kitware.com
Thu Dec 8 08:01:59 EST 2011
The following issue has been SUBMITTED.
======================================================================
http://paraview.org/Bug/view.php?id=12778
======================================================================
Reported By: Felipe Bordeu
Assigned To:
======================================================================
Project: VTK
Issue ID: 12778
Category: (No Category)
Reproducibility: have not tried
Severity: minor
Priority: normal
Status: backlog
Project: Kitware
Type: feature
Resolution: open
Fixed in Version:
======================================================================
Date Submitted: 2011-12-08 08:01 EST
Last Modified: 2011-12-08 08:01 EST
======================================================================
Summary: Use of Fielddata in the VTKArrayCalculator
Description:
I came with this solution to use field data in the vtkArrayCalculator:
the idea is very simple:
we retrieve the field data and we put it into the inFieldData variable,
Then If a field is not found in the point/cell data, then we search in the
fielddata.
diff --git a/Graphics/vtkArrayCalculator.cxx b/Graphics/vtkArrayCalculator.cxx
index a2db7ae..d7c53eb 100644
--- a/Graphics/vtkArrayCalculator.cxx
+++ b/Graphics/vtkArrayCalculator.cxx
@@ -225,6 +225,7 @@ int vtkArrayCalculator::RequestData(
double scalarResult[1];
vtkDataArray* resultArray = 0;
vtkPoints* resultPoints = 0;
+ vtkFieldData* inFieldData = 0;
this->FunctionParser->SetReplaceInvalidValues(this->ReplaceInvalidValues);
this->FunctionParser->SetReplacementValue(this->ReplacementValue);
@@ -252,6 +253,7 @@ int vtkArrayCalculator::RequestData(
attributeDataType = 1;
numTuples = dsInput->GetNumberOfCells();
}
+ inFieldData = dsInput->GetFieldData();
}
else if (graphInput)
{
@@ -270,6 +272,7 @@ int vtkArrayCalculator::RequestData(
attributeDataType = 1;
numTuples = graphInput->GetNumberOfEdges();
}
+ inFieldData = graphInput->GetFieldData();
}
if (numTuples < 1)
@@ -301,8 +304,30 @@ int vtkArrayCalculator::RequestData(
}
else
{
- vtkErrorMacro("Invalid array name: " << this->ScalarArrayNames[i]);
- return 1;
+ // now we search in the fielddata for the array
+ currentArray = inFieldData->GetArray(this->ScalarArrayNames[i]);
+ if (currentArray)
+ {
+ if (currentArray->GetNumberOfComponents() >
+ this->SelectedScalarComponents[i])
+ {
+ this->FunctionParser->
+ SetScalarVariableValue(
+ this->ScalarVariableNames[i],
+ currentArray->GetComponent(0,
this->SelectedScalarComponents[i]));
+ }
+ else
+ {
+ vtkErrorMacro("Array " << this->ScalarArrayNames[i]
+ << " does not contain the selected component.");
+ return 1;
+ }
+ }
+ else
+ {
+ vtkErrorMacro("Invalid array name: " << this->ScalarArrayNames[i]);
+ return 1;
+ }
}
}
@@ -334,8 +359,36 @@ int vtkArrayCalculator::RequestData(
}
else
{
- vtkErrorMacro("Invalid array name: " << this->VectorArrayNames[i]);
- return 1;
+ // now we search in the fielddata for the array
+ currentArray = inFieldData->GetArray(this->VectorArrayNames[i]);
+ if (currentArray)
+ {
+ if ((currentArray->GetNumberOfComponents() >
+ this->SelectedVectorComponents[i][0]) &&
+ (currentArray->GetNumberOfComponents() >
+ this->SelectedVectorComponents[i][1]) &&
+ (currentArray->GetNumberOfComponents() >
+ this->SelectedVectorComponents[i][2]))
+ {
+ this->FunctionParser->
+ SetVectorVariableValue(
+ this->VectorVariableNames[i],
+ currentArray->GetComponent(0,
this->SelectedVectorComponents[i][0]),
+ currentArray->GetComponent(0,
this->SelectedVectorComponents[i][1]),
+ currentArray->GetComponent(0,
this->SelectedVectorComponents[i][2]));
+ }
+ else
+ {
+ vtkErrorMacro("Array " << this->VectorArrayNames[i]
+ << " does not contain the selected component.");
+ return 1;
+ }
+ }
+ else
+ {
+ vtkErrorMacro("Invalid array name: " << this->VectorArrayNames[i]);
+ return 1;
+ }
}
}
@@ -448,19 +501,21 @@ int vtkArrayCalculator::RequestData(
for (j = 0; j < this->NumberOfScalarArrays; j++)
{
currentArray = inFD->GetArray(this->ScalarArrayNames[j]);
- this->FunctionParser->
- SetScalarVariableValue(
- j, currentArray->GetComponent(i, this->SelectedScalarComponents[j]));
+ if (currentArray)
+ this->FunctionParser->
+ SetScalarVariableValue(
+ j, currentArray->GetComponent(i,
this->SelectedScalarComponents[j]));
}
for (j = 0; j < this->NumberOfVectorArrays; j++)
{
currentArray = inFD->GetArray(this->VectorArrayNames[j]);
- this->FunctionParser->
- SetVectorVariableValue(
- j, currentArray->GetComponent(i,
this->SelectedVectorComponents[j][0]),
- currentArray->GetComponent(
- i, this->SelectedVectorComponents[j][1]),
- currentArray->GetComponent(i, this->SelectedVectorComponents[j][2]));
+ if (currentArray)
+ this->FunctionParser->
+ SetVectorVariableValue(
+ j, currentArray->GetComponent(i,
this->SelectedVectorComponents[j][0]),
+ currentArray->GetComponent(
+ i, this->SelectedVectorComponents[j][1]),
+ currentArray->GetComponent(i,
this->SelectedVectorComponents[j][2]));
}
if(attributeDataType == 0)
{
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2011-12-08 08:01 Felipe Bordeu New Issue
======================================================================
More information about the vtk-developers
mailing list