MantisBT - VTK
View Issue Details
0012778VTK(No Category)public2011-12-08 08:012016-08-12 09:55
Felipe Bordeu 
Kitware Robot 
normalminorhave not tried
closedmoved 
5.8.0 
 
Kitware
feature
0012778: Use of Fielddata in the VTKArrayCalculator
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)
       {
No tags attached.
Issue History
2011-12-08 08:01Felipe BordeuNew Issue
2012-08-27 10:08Utkarsh AyachitAssigned To => Kyle Lutz
2012-08-27 10:08Utkarsh AyachitStatusbacklog => tabled
2012-08-27 13:29Kyle LutzNote Added: 0029079
2012-08-27 13:29Kyle LutzStatustabled => active development
2012-08-27 13:29Kyle LutzResolutionopen => fixed
2013-12-16 13:17Dave DeMarleAssigned ToKyle Lutz =>
2013-12-16 13:17Dave DeMarleStatusactive development => backlog
2014-10-02 18:54Cory QuammenNote Added: 0033560
2014-10-06 03:39Felipe BordeuNote Added: 0033591
2014-10-06 13:05Cory QuammenNote Added: 0033605
2016-07-06 16:48Berk GeveciStatusbacklog => expired
2016-07-06 16:48Berk GeveciNote Added: 0036248
2016-08-12 09:55Kitware RobotNote Added: 0037259
2016-08-12 09:55Kitware RobotStatusexpired => closed
2016-08-12 09:55Kitware RobotResolutionfixed => moved
2016-08-12 09:55Kitware RobotAssigned To => Kitware Robot

Notes
(0029079)
Kyle Lutz   
2012-08-27 13:29   
Patch pushed to gerrit for review: http://review.source.kitware.com/#/t/1139/ [^]
(0033560)
Cory Quammen   
2014-10-02 18:54   
The patch above was abandoned for not sufficiently addressing the problem.
(0033591)
Felipe Bordeu   
2014-10-06 03:39   
What do you mean by "no sufficiently addressing the problem"?
(0033605)
Cory Quammen   
2014-10-06 13:05   
Please see the reviewer comments for the gerrit topic:

 http://review.source.kitware.com/#/t/1139/ [^]

notably, this comment from Utkarsh:

"This is not a good solution for the problem. It does not address field data with more than 1 tuple correctly. In practice, e.g. Exodus, field data often has values for each time-step and this patch doesn't provide any means to access those."
(0036248)
Berk Geveci   
2016-07-06 16:48   
Setting to status of bugs that have not been updated in the last year to expired. Please re-open if still important.
(0037259)
Kitware Robot   
2016-08-12 09:55   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current VTK Issues page linked in the banner at the top of this page.