MantisBT - ParaView
View Issue Details
0005626ParaView(No Category)public2007-08-30 13:062016-08-12 09:57
Ken Moreland 
Kyle Lutz 
normalfeaturealways
closedmoved 
 
 
SDAV
array-calculator-field-data-support
incorrect functionality
0005626: Make array calculator operate on field data
The array calculator should be able to operate on field data. I think there are two use cases for this. First, there should be a field data option in addition to point data and cell data that allows the calculator to create a new field data array. Second, there probably should be a way to apply a field data variable to the calculation of point or cell data.
No tags attached.
has duplicate 0010631closed Utkarsh Ayachit Paraview Calculator doesn't assume FieldData 
has duplicate 0011585closed Utkarsh Ayachit Need ability to see global data in the calculator 
child of 0004942closed Eric Stanton Global exodus variables 
patch bug.5626.patch (6,919) 2009-02-17 11:32
https://www.vtk.org/Bug/file/7060/bug.5626.patch
Issue History
2007-08-30 13:06Ken MorelandNew Issue
2007-08-30 13:06Ken MorelandRelationship addedrelated to 0004942
2007-08-30 13:06Ken MorelandAssigned To => Eric Stanton
2007-08-30 13:06Ken MorelandStatusbacklog => tabled
2007-08-30 13:07Ken MorelandRelationship replacedchild of 0004942
2008-04-15 09:31Berk GeveciAssigned ToEric Stanton => Utkarsh Ayachit
2008-04-15 09:31Berk GeveciCategory => 3.6
2009-02-16 16:03Ken MorelandNote Added: 0014965
2009-02-17 11:32Utkarsh AyachitFile Added: bug.5626.patch
2009-02-17 11:33Utkarsh AyachitNote Added: 0015021
2009-02-17 11:33Utkarsh AyachitCategory3.6 => 3.8
2009-05-13 13:41Utkarsh AyachitTarget Version => 3.8
2010-04-29 08:17Utkarsh AyachitRelationship addedhas duplicate 0010631
2010-11-26 14:14David PartykaAssigned ToUtkarsh Ayachit => Robert Maynard
2011-02-16 10:25Robert MaynardRelationship addedrelated to 0011585
2011-02-16 10:25Robert MaynardTarget Version3.8 => 3.10.1
2011-03-31 11:24Utkarsh AyachitTarget Version3.10.1 => 3.12
2011-06-16 13:10Zack GalbreathCategory => (No Category)
2011-10-12 04:51Felipe BordeuNote Added: 0027566
2011-12-08 08:16Felipe BordeuNote Edited: 0027566bug_revision_view_page.php?bugnote_id=27566#r406
2012-08-27 10:07Utkarsh AyachitAssigned ToRobert Maynard => Kyle Lutz
2012-08-27 10:08Utkarsh AyachitProject => SDAV
2012-08-27 10:08Utkarsh AyachitType => incorrect functionality
2012-08-27 10:23Kyle LutzStatusbacklog => todo
2012-08-27 13:24Kyle LutzNote Added: 0029077
2012-08-27 13:24Kyle LutzTopic Name => array-calculator-field-data-support
2012-08-27 13:24Kyle LutzStatustodo => gatekeeper review
2012-08-27 13:24Kyle LutzResolutionopen => fixed
2012-09-03 13:30Utkarsh AyachitStatusgatekeeper review => customer review
2012-09-03 13:30Utkarsh AyachitNote Added: 0029120
2012-09-11 17:03Utkarsh AyachitRelationship replacedhas duplicate 0011585
2012-09-25 09:25Utkarsh AyachitStatuscustomer review => todo
2015-01-02 10:43Utkarsh AyachitFixed in Version => 4.3
2016-07-13 20:55Alan ScottNote Added: 0036440
2016-08-12 09:57Kitware RobotNote Added: 0037531
2016-08-12 09:57Kitware RobotStatustodo => closed
2016-08-12 09:57Kitware RobotFixed in Version4.3 =>
2016-08-12 09:57Kitware RobotResolutionfixed => moved

Notes
(0014965)
Ken Moreland   
2009-02-16 16:03   
If this is easy, we should do it. If not, perhaps we should just not implement it. We could try doing this with the Python calculator instead.
(0015021)
Utkarsh Ayachit   
2009-02-17 11:33   
I've attached a partial fix patch for future work. This is a tab complicated, since FieldData doesn't have fixed length arrays so the calculator needs to be updated to handle that. Deferring this to 3.8 unless told otherwise.
(0027566)
Felipe Bordeu   
2011-10-12 04:51   
(edited on: 2011-12-08 08:16)
A made this changes to add field data to the array calculator.

To make this changes to work some changes in VTK are needed:
please see http://paraview.org/Bug/view.php?id=12778 [^]

I tested the solution for scalar fielddata only but I think it is ready for vector also:

Felipe


diff --git a/ParaViewCore/VTKExtensions/vtkPVArrayCalculator.cxx b/ParaViewCore/VTKExtensions/vtkPVArrayCalculator.cxx
index 240289c..6332008 100644
--- a/ParaViewCore/VTKExtensions/vtkPVArrayCalculator.cxx
+++ b/ParaViewCore/VTKExtensions/vtkPVArrayCalculator.cxx
@@ -39,7 +39,7 @@ vtkPVArrayCalculator::~vtkPVArrayCalculator()
 
 // ----------------------------------------------------------------------------
 void vtkPVArrayCalculator::UpdateArrayAndVariableNames
- ( vtkDataObject * vtkNotUsed(theInputObj), vtkDataSetAttributes * inDataAttrs )
+ ( vtkDataObject * vtkNotUsed(theInputObj), vtkDataSetAttributes * inDataAttrs, vtkFieldData *inDataAttrsGlobal )
 {
   static char stringSufix[3][3] = { "_X", "_Y", "_Z" };
   unsigned long mtime = this->GetMTime();
@@ -98,6 +98,50 @@ void vtkPVArrayCalculator::UpdateArrayAndVariableNames
       }
     }
 
+
+ // add non-coordinate scalar and vector variables for field arrays
+ numberArays = inDataAttrsGlobal->GetNumberOfArrays(); // the input
+ for (int j = 0; j < numberArays; j ++ )
+ {
+ vtkAbstractArray* array = inDataAttrsGlobal->GetAbstractArray(j);
+ const char* array_name = array->GetName();
+ int numberComps = array->GetNumberOfComponents();
+
+ if ( numberComps == 1 )
+ {
+ this->AddScalarVariable( array_name, array_name, 0 );
+ }
+ else
+ {
+ for (int i = 0; i < numberComps; i ++ )
+ {
+ if (i < 3)
+ {
+ vtksys_ios::ostringstream var_name;
+ var_name << array_name << stringSufix[i];
+ this->AddScalarVariable(var_name.str().c_str(), array_name, i );
+ }
+ vtksys_ios::ostringstream var_name2;
+ var_name2 << array_name << "_";
+ if (array->GetComponentName(i))
+ {
+ var_name2 << array->GetComponentName(i);
+ }
+ else
+ {
+ var_name2 << i;
+ }
+ this->AddScalarVariable(var_name2.str().c_str(), array_name, i );
+ }
+
+ if ( numberComps == 3 )
+ {
+ this->AddVectorArrayName(array_name, 0, 1, 2 );
+ }
+ }
+ }
+ // end add field arrays
+
   assert(this->GetMTime() == mtime &&
     "post: mtime cannot be changed in RequestData()");
   static_cast<void>(mtime); // added so compiler won't complain im release mode.
@@ -115,6 +159,7 @@ int vtkPVArrayCalculator::RequestData
   vtkGraph * graphInput = vtkGraph::SafeDownCast( input );
   vtkDataSet * dsInput = vtkDataSet::SafeDownCast( input );
   vtkDataSetAttributes * dataAttrs = NULL;
+ vtkFieldData * dataAttrsGlobal = NULL;
  
   if ( dsInput )
     {
@@ -129,6 +174,7 @@ int vtkPVArrayCalculator::RequestData
       dataAttrs = dsInput->GetCellData();
       numTuples = dsInput->GetNumberOfCells();
       }
+ dataAttrsGlobal = dsInput->GetFieldData();
     }
   else
   if ( graphInput )
@@ -144,6 +190,7 @@ int vtkPVArrayCalculator::RequestData
       dataAttrs = graphInput->GetEdgeData();
       numTuples = graphInput->GetNumberOfEdges();
       }
+ dataAttrsGlobal = graphInput->GetFieldData();
     }
   
   if ( numTuples > 0 )
@@ -153,12 +200,13 @@ int vtkPVArrayCalculator::RequestData
     // the scenarios where the user modifies the name of a calculator whose out-
     // put is the input of a (some) subsequent calculator(s) or the user changes
     // the input of a downstream calculator.
- this->UpdateArrayAndVariableNames( input, dataAttrs );
+ this->UpdateArrayAndVariableNames( input, dataAttrs, dataAttrsGlobal );
     }
   
   input = NULL;
   dsInput = NULL;
   dataAttrs = NULL;
+ dataAttrsGlobal = NULL;
   graphInput = NULL;
   
   return this->Superclass::RequestData( request, inputVector, outputVector );
diff --git a/ParaViewCore/VTKExtensions/vtkPVArrayCalculator.h b/ParaViewCore/VTKExtensions/vtkPVArrayCalculator.h
index 669c4f5..9ed980b 100644
--- a/ParaViewCore/VTKExtensions/vtkPVArrayCalculator.h
+++ b/ParaViewCore/VTKExtensions/vtkPVArrayCalculator.h
@@ -34,6 +34,7 @@
 
 class vtkDataObject;
 class vtkDataSetAttributes;
+class vtkFieldData;
 
 class VTK_EXPORT vtkPVArrayCalculator : public vtkArrayCalculator
 {
@@ -59,7 +60,8 @@ protected:
   // to the attributes of the input dataset. This function should be called by
   // RequestData() only.
   void UpdateArrayAndVariableNames( vtkDataObject * theInputObj,
- vtkDataSetAttributes * inDataAttrs );
+ vtkDataSetAttributes * inDataAttrs,
+ vtkFieldData * inDataAttrsGlobal );
 private:
   vtkPVArrayCalculator( const vtkPVArrayCalculator & ); // Not implemented.
   void operator = ( const vtkPVArrayCalculator & ); // Not implemented.
diff --git a/Qt/Components/pqCalculatorPanel.cxx b/Qt/Components/pqCalculatorPanel.cxx
index 37e38bd..3558ab9 100644
--- a/Qt/Components/pqCalculatorPanel.cxx
+++ b/Qt/Components/pqCalculatorPanel.cxx
@@ -546,6 +546,52 @@ void pqCalculatorPanel::updateVariables(const QString& mode)
       this->Internal->VectorsMenu.addAction(name);
       }
     }
+
+ // to add field arrays to the calculator
+ fdi = f->getInput(f->getInputPortName(0), 0)->getDataInformation()
+ ->GetFieldDataInformation();
+
+ if(!fdi)
+ {
+ return;
+ }
+
+ for(int i=0; i<fdi->GetNumberOfArrays(); i++)
+ {
+ vtkPVArrayInformation* arrayInfo = fdi->GetArrayInformation(i);
+ if (arrayInfo->GetDataType() == VTK_STRING
+ || arrayInfo->GetDataType() == VTK_VARIANT )
+ {
+ continue;
+ }
+
+ int numComponents = arrayInfo->GetNumberOfComponents();
+ QString name = arrayInfo->GetName();
+
+ for(int j=0; j<numComponents; j++)
+ {
+ if(numComponents == 1)
+ {
+ this->Internal->ScalarsMenu.addAction(name);
+ }
+ else
+ {
+ QString compName(arrayInfo->GetComponentName( j ));
+ QString n = name + QString( "_%1").arg( compName );
+ QStringList d;
+ d.append(name);
+ d.append(QString("%1").arg(j));
+ QAction* a = new QAction(n, &this->Internal->ScalarsMenu);
+ a->setData(d);
+ this->Internal->ScalarsMenu.addAction(a);
+ }
+ }
+
+ if(numComponents == 3)
+ {
+ this->Internal->VectorsMenu.addAction(name);
+ }
+ }
 }
 
 void pqCalculatorPanel::variableChosen(QAction* a)

(0029077)
Kyle Lutz   
2012-08-27 13:24   
Patch applied and pushed to ParaView stage. The topic name is 'array-calculator-field-data-support' and it depends on the VTK topic 'array-calculator-field-data-support'
(0029120)
Utkarsh Ayachit   
2012-09-03 13:30   
merged into master, if applicable.
(0036440)
Alan Scott   
2016-07-13 20:55   
Added to Trello
(0037531)
Kitware Robot   
2016-08-12 09:57   
Resolving issue as `moved`.

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