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

Method ReadColors

IO/MINC/vtkMNIObjectReader.cxx:455–513  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

453
454//------------------------------------------------------------------------------
455int vtkMNIObjectReader::ReadColors(
456 vtkProperty* property, vtkPolyData* data, vtkIdType numPoints, vtkIdType numCells)
457{
458 // Find out what kind of coloring is used
459 vtkIdType colorType = 0;
460 if (this->ParseIdValue(&colorType) == 0)
461 {
462 return 0;
463 }
464
465 // Set the number of colors
466 vtkIdType numColors = 1;
467 if (colorType == 1)
468 {
469 numColors = numCells;
470 }
471 else if (colorType == 2)
472 {
473 numColors = numPoints;
474 }
475 else if (colorType != 0)
476 {
477 vtkErrorMacro("Color number must be 0, 1 or 2 " << this->FileName << ":" << this->LineNumber);
478 return 0;
479 }
480
481 // Read the colors
482 vtkUnsignedCharArray* colors = vtkUnsignedCharArray::New();
483 colors->SetName("Colors");
484 colors->SetNumberOfComponents(4);
485 int status = this->ParseValues(colors, 4 * numColors);
486
487 if (status != 0)
488 {
489 if (colorType == 0)
490 {
491 data->GetCellData()->SetScalars(nullptr);
492 data->GetPointData()->SetScalars(nullptr);
493 property->SetColor(
494 colors->GetValue(0) / 255.0, colors->GetValue(1) / 255.0, colors->GetValue(2) / 255.0);
495 }
496 else if (colorType == 1)
497 {
498 data->GetPointData()->SetScalars(nullptr);
499 data->GetCellData()->SetScalars(colors);
500 property->SetColor(1.0, 1.0, 1.0);
501 }
502 else if (colorType == 2)
503 {
504 data->GetCellData()->SetScalars(nullptr);
505 data->GetPointData()->SetScalars(colors);
506 property->SetColor(1.0, 1.0, 1.0);
507 }
508 }
509
510 colors->Delete();
511
512 return status;

Callers 2

ReadPolygonObjectMethod · 0.95
ReadLineObjectMethod · 0.95

Calls 11

ParseIdValueMethod · 0.95
ParseValuesMethod · 0.95
SetScalarsMethod · 0.80
NewFunction · 0.70
DeleteMethod · 0.65
SetNameMethod · 0.45
SetNumberOfComponentsMethod · 0.45
GetCellDataMethod · 0.45
GetPointDataMethod · 0.45
SetColorMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected