-----------------------------------------------------------------------------
| 97 | |
| 98 | //----------------------------------------------------------------------------- |
| 99 | vtkDataArray* findArrayToColor(vtkDataSet* dataset) |
| 100 | { |
| 101 | bool mapScalars; |
| 102 | vtkPointData* pd = dataset->GetPointData(); |
| 103 | // first try the active scalars |
| 104 | vtkDataArray* a = pd->GetScalars(); |
| 105 | if (VolumeOptions::isArrayValidForColoring(a, mapScalars)) |
| 106 | { |
| 107 | return a; |
| 108 | } |
| 109 | // if active scalars are not set look through all arrays, |
| 110 | // if we find an array that fits, set it as active scalars and return it. |
| 111 | for(int i = 0; i < pd->GetNumberOfArrays(); ++i) |
| 112 | { |
| 113 | a = pd->GetArray(i); |
| 114 | if (VolumeOptions::isArrayValidForColoring(a, mapScalars)) |
| 115 | { |
| 116 | pd->SetScalars(a); |
| 117 | return a; |
| 118 | } |
| 119 | else |
| 120 | { |
| 121 | continue; |
| 122 | } |
| 123 | } |
| 124 | mapScalars = false; |
| 125 | return nullptr; |
| 126 | } |
| 127 | |
| 128 | } // namespace <anonymous> |
| 129 |