------------------------------------------------------------------------------
| 169 | |
| 170 | //------------------------------------------------------------------------------ |
| 171 | const char* vtkPiecewiseFunction::GetType() |
| 172 | { |
| 173 | unsigned int i; |
| 174 | double value; |
| 175 | double prev_value = 0.0; |
| 176 | int function_type; |
| 177 | |
| 178 | function_type = 0; |
| 179 | |
| 180 | if (!this->Internal->Nodes.empty()) |
| 181 | { |
| 182 | prev_value = this->Internal->Nodes[0]->Y; |
| 183 | } |
| 184 | |
| 185 | for (i = 1; i < this->Internal->Nodes.size(); i++) |
| 186 | { |
| 187 | value = this->Internal->Nodes[i]->Y; |
| 188 | |
| 189 | // Do not change the function type if equal |
| 190 | if (value != prev_value) |
| 191 | { |
| 192 | if (value > prev_value) |
| 193 | { |
| 194 | switch (function_type) |
| 195 | { |
| 196 | case 0: |
| 197 | case 1: |
| 198 | function_type = 1; // NonDecreasing |
| 199 | break; |
| 200 | case 2: |
| 201 | function_type = 3; // Varied |
| 202 | break; |
| 203 | } |
| 204 | } |
| 205 | else // value < prev_value |
| 206 | { |
| 207 | switch (function_type) |
| 208 | { |
| 209 | case 0: |
| 210 | case 2: |
| 211 | function_type = 2; // NonIncreasing |
| 212 | break; |
| 213 | case 1: |
| 214 | function_type = 3; // Varied |
| 215 | break; |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | prev_value = value; |
| 221 | |
| 222 | // Exit loop if we find a Varied function |
| 223 | if (function_type == 3) |
| 224 | { |
| 225 | break; |
| 226 | } |
| 227 | } |
| 228 |
no test coverage detected