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

Method SetAttributeValueAsArray

IO/MINC/vtkMINCImageAttributes.cxx:757–821  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

755
756//------------------------------------------------------------------------------
757void vtkMINCImageAttributes::SetAttributeValueAsArray(
758 const char* variable, const char* attribute, vtkDataArray* array)
759{
760 std::string path = MI_GRPNAME;
761 if (variable && variable[0] != '\0')
762 {
763 path += MI_GRP_SEP;
764 path += variable;
765 }
766 path += MI_ATT_SEP;
767 path += attribute;
768
769 array->SetName(path.c_str());
770 this->AttributeValues->AddArray(array);
771
772 // Add to variable to VariableNames
773 vtkIdType n = this->VariableNames->GetNumberOfValues();
774 vtkIdType i = 0;
775 for (i = 0; i < n; i++)
776 {
777 if (this->VariableNames->GetValue(i) == variable)
778 {
779 break;
780 }
781 }
782 if (i == n && variable[0] != '\0')
783 {
784 this->VariableNames->InsertNextValue(variable);
785 }
786
787 // Add to attribute to AttributeNames
788 vtkStringArray* attribs = this->AttributeNames->GetStringArray(variable);
789 // Create a new array if necessary
790 if (attribs == nullptr)
791 {
792 attribs = vtkStringArray::New();
793 attribs->SetName(variable);
794 this->AttributeNames->AddArray(attribs);
795 attribs->Delete();
796 }
797
798 n = attribs->GetNumberOfValues();
799 for (i = 0; i < n; i++)
800 {
801 if (attribs->GetValue(i) == attribute)
802 {
803 break;
804 }
805 }
806 if (i == n)
807 {
808 attribs->InsertNextValue(attribute);
809 }
810
811 if (this->ValidateAttributes)
812 {
813 // Print warning if there is something wrong with the attribute
814 int result = this->ValidateAttribute(variable, attribute, array);

Callers 5

ShallowCopyMethod · 0.95

Calls 10

ValidateAttributeMethod · 0.95
GetStringArrayMethod · 0.80
NewFunction · 0.70
DeleteMethod · 0.65
SetNameMethod · 0.45
c_strMethod · 0.45
AddArrayMethod · 0.45
GetNumberOfValuesMethod · 0.45
GetValueMethod · 0.45
InsertNextValueMethod · 0.45

Tested by

no test coverage detected