------------------------------------------------------------------------------
| 1454 | |
| 1455 | //------------------------------------------------------------------------------ |
| 1456 | int vtkXMLUnstructuredDataReader::ReadFaceArray(vtkIdType numberOfCells, vtkXMLDataElement* eCells, |
| 1457 | vtkIdTypeArray* outFaces, vtkIdTypeArray* outFaceOffsets) |
| 1458 | { |
| 1459 | if (numberOfCells <= 0) |
| 1460 | { |
| 1461 | return 1; |
| 1462 | } |
| 1463 | else |
| 1464 | { |
| 1465 | if (!eCells || !outFaces || !outFaceOffsets) |
| 1466 | { |
| 1467 | return 0; |
| 1468 | } |
| 1469 | } |
| 1470 | |
| 1471 | // Split progress range into 1/5 for faces array and 4/5 for |
| 1472 | // faceoffsets array. This assumes an average of 4 points per |
| 1473 | // face. Unfortunately, we cannot know the length ahead of time |
| 1474 | // to calculate the real fraction. |
| 1475 | float progressRange[2] = { 0, 0 }; |
| 1476 | this->GetProgressRange(progressRange); |
| 1477 | float fractions[3] = { 0, 0.2f, 1 }; |
| 1478 | |
| 1479 | // Set range of progress for offsets array. |
| 1480 | this->SetProgressRange(progressRange, 0, fractions); |
| 1481 | |
| 1482 | // Read the cell offsets. |
| 1483 | vtkXMLDataElement* efaceOffsets = this->FindDataArrayWithName(eCells, "faceoffsets"); |
| 1484 | if (!efaceOffsets) |
| 1485 | { |
| 1486 | vtkErrorMacro("Cannot read face offsets from " |
| 1487 | << eCells->GetName() << " in piece " << this->Piece |
| 1488 | << " because the \"faceoffsets\" array could not be found."); |
| 1489 | return 0; |
| 1490 | } |
| 1491 | vtkAbstractArray* ac1 = this->CreateArray(efaceOffsets); |
| 1492 | vtkDataArray* c1 = vtkArrayDownCast<vtkDataArray>(ac1); |
| 1493 | if (!c1 || (c1->GetNumberOfComponents() != 1)) |
| 1494 | { |
| 1495 | vtkErrorMacro("Cannot read face offsets from " |
| 1496 | << eCells->GetName() << " in piece " << this->Piece |
| 1497 | << " because the \"faceoffsets\" array could not be created" |
| 1498 | << " with one component."); |
| 1499 | if (ac1) |
| 1500 | { |
| 1501 | ac1->Delete(); |
| 1502 | } |
| 1503 | return 0; |
| 1504 | } |
| 1505 | c1->SetNumberOfTuples(numberOfCells); |
| 1506 | if (!this->ReadArrayValues(efaceOffsets, 0, c1, 0, numberOfCells)) |
| 1507 | { |
| 1508 | vtkErrorMacro("Cannot read face offsets from " |
| 1509 | << eCells->GetName() << " in piece " << this->Piece |
| 1510 | << " because the \"faceoffsets\" array is not long enough."); |
| 1511 | return 0; |
| 1512 | } |
| 1513 | vtkIdTypeArray* faceOffsets = this->ConvertToIdTypeArray(c1); |
nothing calls this directly
no test coverage detected