MCPcopy Create free account
hub / github.com/Kitware/VTK / ExtractColorTransferFunctionSetup

Method ExtractColorTransferFunctionSetup

IO/Export/vtkJSONSceneExporter.cxx:219–271  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

217
218//------------------------------------------------------------------------------
219std::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//------------------------------------------------------------------------------
274std::string vtkJSONSceneExporter::ExtractPiecewiseFunctionSetup(vtkPiecewiseFunction* function)

Callers 1

Calls 4

GetColorSpaceMethod · 0.80
GetSizeMethod · 0.45
GetNodeValueMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected