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

Method WritePArray

IO/XML/vtkXMLWriter.cxx:2910–2968  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2908
2909//------------------------------------------------------------------------------
2910void vtkXMLWriter::WritePArray(vtkAbstractArray* a, vtkIndent indent, const char* alternateName)
2911{
2912 vtkDataArray* d = vtkArrayDownCast<vtkDataArray>(a);
2913 ostream& os = *(this->Stream);
2914 if (d)
2915 {
2916 os << indent << "<PDataArray";
2917 }
2918 else
2919 {
2920 os << indent << "<PArray";
2921 }
2922 this->WriteWordTypeAttribute("type", a->GetDataType());
2923 if (a->GetDataType() == VTK_ID_TYPE)
2924 {
2925 this->WriteScalarAttribute("IdType", 1);
2926 }
2927 if (alternateName)
2928 {
2929 this->WriteStringAttribute("Name", alternateName);
2930 }
2931 else
2932 {
2933 const char* arrayName = a->GetName();
2934 if (arrayName)
2935 {
2936 this->WriteStringAttribute("Name", arrayName);
2937 }
2938 }
2939 if (a->GetNumberOfComponents() > 1)
2940 {
2941 this->WriteScalarAttribute("NumberOfComponents", a->GetNumberOfComponents());
2942 }
2943
2944 // always write out component names, even if only 1 component
2945 std::ostringstream buff;
2946 const char* compName = nullptr;
2947 for (int i = 0; i < a->GetNumberOfComponents(); ++i)
2948 {
2949 // get the component names
2950 buff << "ComponentName" << i;
2951 compName = a->GetComponentName(i);
2952 if (compName)
2953 {
2954 this->WriteStringAttribute(buff.str().c_str(), compName);
2955 compName = nullptr;
2956 }
2957 buff.str("");
2958 buff.clear();
2959 }
2960
2961 os << "/>\n";
2962
2963 os.flush();
2964 if (os.fail())
2965 {
2966 this->SetErrorCode(vtkErrorCode::GetLastSystemError());
2967 }

Callers 5

WritePPointDataMethod · 0.95
WritePCellDataMethod · 0.95
WritePPointsMethod · 0.95
WritePCoordinatesMethod · 0.95
WritePRowDataMethod · 0.80

Calls 11

WriteScalarAttributeMethod · 0.95
WriteStringAttributeMethod · 0.95
GetComponentNameMethod · 0.80
GetDataTypeMethod · 0.45
GetNameMethod · 0.45
GetNumberOfComponentsMethod · 0.45
c_strMethod · 0.45
strMethod · 0.45
clearMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected