MantisBT - VTK | |||||
View Issue Details | |||||
ID | Project | Category | View Status | Date Submitted | Last Update |
0012778 | VTK | (No Category) | public | 2011-12-08 08:01 | 2016-08-12 09:55 |
Reporter | Felipe Bordeu | ||||
Assigned To | Kitware Robot | ||||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | closed | Resolution | moved | ||
Platform | OS | OS Version | |||
Product Version | 5.8.0 | ||||
Target Version | Fixed in Version | ||||
Project | Kitware | ||||
Type | feature | ||||
Summary | 0012778: 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) { | ||||
Steps To Reproduce | |||||
Additional Information | |||||
Tags | No tags attached. | ||||
Relationships | |||||
Attached Files | |||||
Issue History | |||||
Date Modified | Username | Field | Change | ||
2011-12-08 08:01 | Felipe Bordeu | New Issue | |||
2012-08-27 10:08 | Utkarsh Ayachit | Assigned To | => Kyle Lutz | ||
2012-08-27 10:08 | Utkarsh Ayachit | Status | backlog => tabled | ||
2012-08-27 13:29 | Kyle Lutz | Note Added: 0029079 | |||
2012-08-27 13:29 | Kyle Lutz | Status | tabled => active development | ||
2012-08-27 13:29 | Kyle Lutz | Resolution | open => fixed | ||
2013-12-16 13:17 | Dave DeMarle | Assigned To | Kyle Lutz => | ||
2013-12-16 13:17 | Dave DeMarle | Status | active development => backlog | ||
2014-10-02 18:54 | Cory Quammen | Note Added: 0033560 | |||
2014-10-06 03:39 | Felipe Bordeu | Note Added: 0033591 | |||
2014-10-06 13:05 | Cory Quammen | Note Added: 0033605 | |||
2016-07-06 16:48 | Berk Geveci | Status | backlog => expired | ||
2016-07-06 16:48 | Berk Geveci | Note Added: 0036248 | |||
2016-08-12 09:55 | Kitware Robot | Note Added: 0037259 | |||
2016-08-12 09:55 | Kitware Robot | Status | expired => closed | ||
2016-08-12 09:55 | Kitware Robot | Resolution | fixed => moved | ||
2016-08-12 09:55 | Kitware Robot | Assigned To | => Kitware Robot |
Notes | |||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|