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

Method ReadNormalData

IO/Legacy/vtkDataReader.cxx:2354–2402  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2352//------------------------------------------------------------------------------
2353// Read normal point attributes. Return 0 if error.
2354int vtkDataReader::ReadNormalData(vtkDataSetAttributes* a, vtkIdType numPts)
2355{
2356 int skipNormal = 0;
2357 char line[256], name[256];
2358 vtkDataArray* data;
2359 char buffer[256];
2360
2361 if (!(this->ReadString(buffer) && this->ReadString(line)))
2362 {
2363 const char* fname = this->CurrentFileName.c_str();
2364 vtkErrorMacro(<< "Cannot read normal data!"
2365 << " for file: " << (fname ? fname : "(Null FileName)"));
2366 return 0;
2367 }
2368 this->DecodeString(name, buffer);
2369
2370 //
2371 // See whether normal has been already read or normal name (if specified)
2372 // matches name in file.
2373 //
2374 if (a->GetNormals() != nullptr || (this->NormalsName && strcmp(name, this->NormalsName) != 0))
2375 {
2376 skipNormal = 1;
2377 }
2378
2379 data = vtkArrayDownCast<vtkDataArray>(this->ReadArray(line, numPts, 3));
2380 if (data != nullptr)
2381 {
2382 data->SetName(name);
2383 if (!skipNormal)
2384 {
2385 a->SetNormals(data);
2386 }
2387 else if (this->ReadAllNormals)
2388 {
2389 a->AddArray(data);
2390 }
2391 data->Delete();
2392 }
2393 else
2394 {
2395 return 0;
2396 }
2397
2398 float progress = this->GetProgress();
2399 this->UpdateProgress(progress + 0.5 * (1.0 - progress));
2400
2401 return 1;
2402}
2403
2404//------------------------------------------------------------------------------
2405// Read tensor 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
DeleteMethod · 0.65
c_strMethod · 0.45
GetNormalsMethod · 0.45
SetNameMethod · 0.45
SetNormalsMethod · 0.45
AddArrayMethod · 0.45
GetProgressMethod · 0.45
UpdateProgressMethod · 0.45

Tested by

no test coverage detected