------------------------------------------------------------------------------
| 1595 | |
| 1596 | //------------------------------------------------------------------------------ |
| 1597 | int vtkSLACReader::ReadMidpointData( |
| 1598 | int meshFD, vtkMultiBlockDataSet* output, MidpointIdMap& midpointIds) |
| 1599 | { |
| 1600 | // Get the point information from the data. |
| 1601 | vtkPoints* points = |
| 1602 | vtkPoints::SafeDownCast(output->GetInformation()->Get(vtkSLACReader::POINTS())); |
| 1603 | |
| 1604 | // Read in the midpoint coordinates. |
| 1605 | MidpointCoordinateMap midpointCoords; |
| 1606 | if (!this->ReadMidpointCoordinates(meshFD, output, midpointCoords)) |
| 1607 | return 0; |
| 1608 | |
| 1609 | vtkIdType newPointTotal = points->GetNumberOfPoints() + midpointCoords.GetNumberOfMidpoints(); |
| 1610 | |
| 1611 | // Iterate over all of the parts in the output and visit the ones for the |
| 1612 | // external surface. |
| 1613 | vtkSmartPointer<vtkCompositeDataIterator> outputIter; |
| 1614 | for (outputIter.TakeReference(output->NewIterator()); !outputIter->IsDoneWithTraversal(); |
| 1615 | outputIter->GoToNextItem()) |
| 1616 | { |
| 1617 | if (!output->GetMetaData(outputIter)->Get(IS_EXTERNAL_SURFACE())) |
| 1618 | continue; |
| 1619 | |
| 1620 | // Create a new cell array so that we can convert all the cells from |
| 1621 | // triangles to quadratic triangles. |
| 1622 | vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast(output->GetDataSet(outputIter)); |
| 1623 | vtkCellArray* oldCells = ugrid->GetCells(); |
| 1624 | VTK_CREATE(vtkCellArray, newCells); |
| 1625 | newCells->AllocateEstimate(oldCells->GetNumberOfCells(), 6); |
| 1626 | |
| 1627 | // Iterate over all of the cells. |
| 1628 | vtkIdType npts; |
| 1629 | const vtkIdType* pts; |
| 1630 | for (oldCells->InitTraversal(); oldCells->GetNextCell(npts, pts);) |
| 1631 | { |
| 1632 | newCells->InsertNextCell(6); |
| 1633 | |
| 1634 | // Copy corner points. |
| 1635 | newCells->InsertCellPoint(pts[0]); |
| 1636 | newCells->InsertCellPoint(pts[1]); |
| 1637 | newCells->InsertCellPoint(pts[2]); |
| 1638 | |
| 1639 | // Add edge midpoints. |
| 1640 | for (int edgeInc = 0; edgeInc < 3; edgeInc++) |
| 1641 | { |
| 1642 | // Get the points defining the edge. |
| 1643 | vtkIdType p0 = pts[triEdges[edgeInc][0]]; |
| 1644 | vtkIdType p1 = pts[triEdges[edgeInc][1]]; |
| 1645 | EdgeEndpoints edge(p0, p1); |
| 1646 | |
| 1647 | // See if we have already copied this midpoint. |
| 1648 | vtkIdType midId; |
| 1649 | vtkIdType* midIdPointer = midpointIds.FindMidpoint(edge); |
| 1650 | if (midIdPointer != nullptr) |
| 1651 | { |
| 1652 | midId = *midIdPointer; |
| 1653 | } |
| 1654 | else |
no test coverage detected