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

Method ReadVectorData

IO/Legacy/vtkDataReader.cxx:2302–2350  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Read vector point attributes. Return 0 if error.

Source from the content-addressed store, hash-verified

2300//------------------------------------------------------------------------------
2301// Read vector point attributes. Return 0 if error.
2302int vtkDataReader::ReadVectorData(vtkDataSetAttributes* a, vtkIdType numPts)
2303{
2304 int skipVector = 0;
2305 char line[256], name[256];
2306 vtkDataArray* data;
2307 char buffer[256];
2308
2309 if (!(this->ReadString(buffer) && this->ReadString(line)))
2310 {
2311 const char* fname = this->CurrentFileName.c_str();
2312 vtkErrorMacro(<< "Cannot read vector data!"
2313 << " for file: " << (fname ? fname : "(Null FileName)"));
2314 return 0;
2315 }
2316 this->DecodeString(name, buffer);
2317
2318 //
2319 // See whether vector has been already read or vector name (if specified)
2320 // matches name in file.
2321 //
2322 if (a->GetVectors() != nullptr || (this->VectorsName && strcmp(name, this->VectorsName) != 0))
2323 {
2324 skipVector = 1;
2325 }
2326
2327 data = vtkArrayDownCast<vtkDataArray>(this->ReadArray(line, numPts, 3));
2328 if (data != nullptr)
2329 {
2330 data->SetName(name);
2331 if (!skipVector)
2332 {
2333 a->SetVectors(data);
2334 }
2335 else if (this->ReadAllVectors)
2336 {
2337 a->AddArray(data);
2338 }
2339 data->Delete();
2340 }
2341 else
2342 {
2343 return 0;
2344 }
2345
2346 float progress = this->GetProgress();
2347 this->UpdateProgress(progress + 0.5 * (1.0 - progress));
2348
2349 return 1;
2350}
2351
2352//------------------------------------------------------------------------------
2353// Read normal point attributes. Return 0 if error.

Callers 5

ReadCellDataMethod · 0.95
ReadPointDataMethod · 0.95
ReadVertexDataMethod · 0.95
ReadEdgeDataMethod · 0.95
ReadRowDataMethod · 0.95

Calls 11

ReadStringMethod · 0.95
DecodeStringMethod · 0.95
ReadArrayMethod · 0.95
SetVectorsMethod · 0.80
DeleteMethod · 0.65
c_strMethod · 0.45
GetVectorsMethod · 0.45
SetNameMethod · 0.45
AddArrayMethod · 0.45
GetProgressMethod · 0.45
UpdateProgressMethod · 0.45

Tested by

no test coverage detected