View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005626ParaView(No Category)public2007-08-30 13:062016-08-12 09:57
ReporterKen Moreland 
Assigned ToKyle Lutz 
PrioritynormalSeverityfeatureReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0005626: Make array calculator operate on field data
DescriptionThe 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.
TagsNo tags attached.
ProjectSDAV
Topic Namearray-calculator-field-data-support
Typeincorrect functionality
Attached Filespatch file icon bug.5626.patch [^] (6,919 bytes) 2009-02-17 11:32 [Show Content]

 Relationships
has duplicate 0010631closedUtkarsh Ayachit Paraview Calculator doesn't assume FieldData 
has duplicate 0011585closedUtkarsh Ayachit Need ability to see global data in the calculator 
child of 0004942closedEric Stanton Global exodus variables 

  Notes
(0014965)
Ken Moreland (manager)
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 (administrator)
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 (reporter)
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 (viewer)
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 (administrator)
2012-09-03 13:30

merged into master, if applicable.
(0036440)
Alan Scott (manager)
2016-07-13 20:55

Added to Trello
(0037531)
Kitware Robot (administrator)
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.

 Issue History
Date Modified Username Field Change
2007-08-30 13:06 Ken Moreland New Issue
2007-08-30 13:06 Ken Moreland Relationship added related to 0004942
2007-08-30 13:06 Ken Moreland Assigned To => Eric Stanton
2007-08-30 13:06 Ken Moreland Status backlog => tabled
2007-08-30 13:07 Ken Moreland Relationship replaced child of 0004942
2008-04-15 09:31 Berk Geveci Assigned To Eric Stanton => Utkarsh Ayachit
2008-04-15 09:31 Berk Geveci Category => 3.6
2009-02-16 16:03 Ken Moreland Note Added: 0014965
2009-02-17 11:32 Utkarsh Ayachit File Added: bug.5626.patch
2009-02-17 11:33 Utkarsh Ayachit Note Added: 0015021
2009-02-17 11:33 Utkarsh Ayachit Category 3.6 => 3.8
2009-05-13 13:41 Utkarsh Ayachit Target Version => 3.8
2010-04-29 08:17 Utkarsh Ayachit Relationship added has duplicate 0010631
2010-11-26 14:14 David Partyka Assigned To Utkarsh Ayachit => Robert Maynard
2011-02-16 10:25 Robert Maynard Relationship added related to 0011585
2011-02-16 10:25 Robert Maynard Target Version 3.8 => 3.10.1
2011-03-31 11:24 Utkarsh Ayachit Target Version 3.10.1 => 3.12
2011-06-16 13:10 Zack Galbreath Category => (No Category)
2011-10-12 04:51 Felipe Bordeu Note Added: 0027566
2011-12-08 08:16 Felipe Bordeu Note Edited: 0027566
2012-08-27 10:07 Utkarsh Ayachit Assigned To Robert Maynard => Kyle Lutz
2012-08-27 10:08 Utkarsh Ayachit Project => SDAV
2012-08-27 10:08 Utkarsh Ayachit Type => incorrect functionality
2012-08-27 10:23 Kyle Lutz Status backlog => todo
2012-08-27 13:24 Kyle Lutz Note Added: 0029077
2012-08-27 13:24 Kyle Lutz Topic Name => array-calculator-field-data-support
2012-08-27 13:24 Kyle Lutz Status todo => gatekeeper review
2012-08-27 13:24 Kyle Lutz Resolution open => fixed
2012-09-03 13:30 Utkarsh Ayachit Status gatekeeper review => customer review
2012-09-03 13:30 Utkarsh Ayachit Note Added: 0029120
2012-09-11 17:03 Utkarsh Ayachit Relationship replaced has duplicate 0011585
2012-09-25 09:25 Utkarsh Ayachit Status customer review => todo
2015-01-02 10:43 Utkarsh Ayachit Fixed in Version => 4.3
2016-07-13 20:55 Alan Scott Note Added: 0036440
2016-08-12 09:57 Kitware Robot Note Added: 0037531
2016-08-12 09:57 Kitware Robot Status todo => closed
2016-08-12 09:57 Kitware Robot Fixed in Version 4.3 =>
2016-08-12 09:57 Kitware Robot Resolution fixed => moved


Copyright © 2000 - 2018 MantisBT Team