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

Method ReadMidpointData

IO/NetCDF/vtkSLACReader.cxx:1597–1697  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1595
1596//------------------------------------------------------------------------------
1597int 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

Callers 1

RequestDataMethod · 0.95

Calls 15

MidpointCoordinatesFunction · 0.85
GetNumberOfMidpointsMethod · 0.80
AllocateEstimateMethod · 0.80
InsertCellPointMethod · 0.80
FindMidpointMethod · 0.80
RemoveMidpointMethod · 0.80
AddMidpointMethod · 0.80
GetMethod · 0.45
GetInformationMethod · 0.45
GetNumberOfPointsMethod · 0.45
TakeReferenceMethod · 0.45

Tested by

no test coverage detected