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

Method WriteArray

IO/Export/vtkJSONDataSetWriter.cxx:147–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145//------------------------------------------------------------------------------
146
147std::string vtkJSONDataSetWriter::WriteArray(
148 vtkDataArray* array, const char* className, const char* arrayName)
149{
150 bool needConvert;
151 std::string id = vtkJSONDataSetWriter::GetUID(array, needConvert);
152 std::stringstream arrayPath;
153 arrayPath << "data/" << id;
154 bool success = vtkJSONDataSetWriter::WriteArrayContents(array, arrayPath.str().c_str());
155
156 if (!success)
157 {
158 return "{}";
159 }
160
161 const char* INDENT = " ";
162 std::stringstream ss;
163 ss << "{\n"
164 << INDENT << " \"vtkClass\": \"" << className << "\",\n"
165 << INDENT << " \"name\": \""
166 << this->GetValidString(arrayName == nullptr ? array->GetName() : arrayName) << "\",\n"
167 << INDENT << " \"numberOfComponents\": " << array->GetNumberOfComponents() << ",\n"
168 << INDENT << " \"dataType\": \"" << vtkJSONDataSetWriter::GetShortType(array, needConvert)
169 << "Array\",\n"
170 << INDENT << " \"ref\": {\n"
171 << INDENT << " \"encode\": \"LittleEndian\",\n"
172 << INDENT << " \"basepath\": \"data\",\n"
173 << INDENT << " \"id\": \"" << id << "\"\n"
174 << INDENT << " },\n"
175 << INDENT << " \"size\": " << array->GetNumberOfValues() << "\n"
176 << INDENT << "}";
177
178 return ss.str();
179}
180
181//------------------------------------------------------------------------------
182void vtkJSONDataSetWriter::Write(vtkDataSet* dataset)

Callers 2

WriteMethod · 0.95

Calls 6

GetValidStringMethod · 0.95
c_strMethod · 0.45
strMethod · 0.45
GetNameMethod · 0.45
GetNumberOfComponentsMethod · 0.45
GetNumberOfValuesMethod · 0.45

Tested by

no test coverage detected