------------------------------------------------------------------------------
| 1664 | |
| 1665 | //------------------------------------------------------------------------------ |
| 1666 | int vtkXMLUnstructuredDataReader::ReadFaceCellArray(vtkIdType numberOfCells, |
| 1667 | vtkXMLDataElement* eCells, vtkCellArray* outFaces, vtkCellArray* outFaceOffsets) |
| 1668 | { |
| 1669 | if (numberOfCells <= 0) |
| 1670 | { |
| 1671 | return 1; |
| 1672 | } |
| 1673 | else |
| 1674 | { |
| 1675 | if (!eCells || !outFaces || !outFaceOffsets) |
| 1676 | { |
| 1677 | return 0; |
| 1678 | } |
| 1679 | } |
| 1680 | |
| 1681 | // Split progress range into 1/5 for faces array and 4/5 for |
| 1682 | // faceoffsets array. This assumes an average of 4 points per |
| 1683 | // face. Unfortunately, we cannot know the length ahead of time |
| 1684 | // to calculate the real fraction. |
| 1685 | float progressRange[2] = { 0, 0 }; |
| 1686 | this->GetProgressRange(progressRange); |
| 1687 | float fractions[3] = { 0, 0.2f, 1 }; |
| 1688 | |
| 1689 | // Set range of progress for offsets array. |
| 1690 | this->SetProgressRange(progressRange, 0, fractions); |
| 1691 | |
| 1692 | // Read the cell offsets. |
| 1693 | vtkXMLDataElement* efaceOffsets = this->FindDataArrayWithName(eCells, "faceoffsets"); |
| 1694 | if (!efaceOffsets) |
| 1695 | { |
| 1696 | vtkErrorMacro("Cannot read face offsets from " |
| 1697 | << eCells->GetName() << " in piece " << this->Piece |
| 1698 | << " because the \"faceoffsets\" array could not be found."); |
| 1699 | return 0; |
| 1700 | } |
| 1701 | vtkAbstractArray* ac1 = this->CreateArray(efaceOffsets); |
| 1702 | vtkDataArray* c1 = vtkArrayDownCast<vtkDataArray>(ac1); |
| 1703 | if (!c1 || (c1->GetNumberOfComponents() != 1)) |
| 1704 | { |
| 1705 | vtkErrorMacro("Cannot read face offsets from " |
| 1706 | << eCells->GetName() << " in piece " << this->Piece |
| 1707 | << " because the \"faceoffsets\" array could not be created" |
| 1708 | << " with one component."); |
| 1709 | if (ac1) |
| 1710 | { |
| 1711 | ac1->Delete(); |
| 1712 | } |
| 1713 | return 0; |
| 1714 | } |
| 1715 | c1->SetNumberOfTuples(numberOfCells); |
| 1716 | if (!this->ReadArrayValues(efaceOffsets, 0, c1, 0, numberOfCells)) |
| 1717 | { |
| 1718 | vtkErrorMacro("Cannot read face offsets from " |
| 1719 | << eCells->GetName() << " in piece " << this->Piece |
| 1720 | << " because the \"faceoffsets\" array is not long enough."); |
| 1721 | return 0; |
| 1722 | } |
| 1723 | vtkIdTypeArray* faceOffsets = this->ConvertToIdTypeArray(c1); |
no test coverage detected