------------------------------------------------------------------------------
| 217 | |
| 218 | //------------------------------------------------------------------------------ |
| 219 | std::string vtkJSONSceneExporter::ExtractColorTransferFunctionSetup( |
| 220 | vtkColorTransferFunction* function) |
| 221 | { |
| 222 | std::stringstream configuration; |
| 223 | |
| 224 | bool useAboveRangeColor = function->GetUseAboveRangeColor(); |
| 225 | bool useBelowRangeColor = function->GetUseBelowRangeColor(); |
| 226 | int colorSpace = function->GetColorSpace(); |
| 227 | double aboveRangeColor[3] = { 0 }; |
| 228 | double belowRangeColor[3] = { 0 }; |
| 229 | double nanColor[3] = { 0 }; |
| 230 | function->GetAboveRangeColor(aboveRangeColor); |
| 231 | function->GetBelowRangeColor(belowRangeColor); |
| 232 | function->GetNanColor(nanColor); |
| 233 | |
| 234 | vtkIdType numberOfNodes = function->GetSize(); |
| 235 | constexpr const char* INDENT = " "; |
| 236 | configuration << INDENT << " \"useAboveRangeColor\": " << (useAboveRangeColor ? "true" : "false") |
| 237 | << ",\n" |
| 238 | << INDENT << " \"useBelowRangeColor\": " << (useBelowRangeColor ? "true" : "false") |
| 239 | << ",\n" |
| 240 | << INDENT << " \"colorSpace\": " << colorSpace << ",\n"; |
| 241 | if (useAboveRangeColor) |
| 242 | { |
| 243 | configuration << INDENT << " \"aboveRangeColor\": [" << aboveRangeColor[0] << ", " |
| 244 | << aboveRangeColor[1] << ", " << aboveRangeColor[2] << "],\n"; |
| 245 | } |
| 246 | if (useBelowRangeColor) |
| 247 | { |
| 248 | configuration << INDENT << " \"belowRangeColor\": [" << belowRangeColor[0] << ", " |
| 249 | << belowRangeColor[1] << ", " << belowRangeColor[2] << "],\n"; |
| 250 | } |
| 251 | configuration << INDENT << " \"nanColor\": [" << nanColor[0] << ", " << nanColor[1] << ", " |
| 252 | << nanColor[2] << "],\n"; |
| 253 | configuration << INDENT << " \"nodes\": [\n"; |
| 254 | for (vtkIdType nodeId = 0; nodeId < numberOfNodes; ++nodeId) |
| 255 | { |
| 256 | double node[6]; |
| 257 | function->GetNodeValue(nodeId, node); |
| 258 | configuration << INDENT << " ["; |
| 259 | for (int i = 0; i < 6; ++i) |
| 260 | { |
| 261 | configuration << node[i] << (i == 5 ? "]" : ", "); |
| 262 | } |
| 263 | if (nodeId < numberOfNodes - 1) |
| 264 | { |
| 265 | configuration << ","; |
| 266 | } |
| 267 | configuration << "\n"; |
| 268 | } |
| 269 | configuration << INDENT << " ]\n"; |
| 270 | return configuration.str(); |
| 271 | } |
| 272 | |
| 273 | //------------------------------------------------------------------------------ |
| 274 | std::string vtkJSONSceneExporter::ExtractPiecewiseFunctionSetup(vtkPiecewiseFunction* function) |
no test coverage detected