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

Method CommitSimplification

Common/DataModel/vtkReebGraph.cxx:1559–1805  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1557
1558//------------------------------------------------------------------------------
1559int vtkReebGraph::Implementation::CommitSimplification()
1560{
1561 // now re-construct the graph with projected deg-2 nodes.
1562 std::vector<std::pair<std::pair<int, int>, std::vector<int>>> before, after;
1563
1564 vtkEdgeListIterator* eIt = vtkEdgeListIterator::New();
1565 this->Parent->GetEdges(eIt);
1566 vtkVariantArray* edgeInfo =
1567 vtkArrayDownCast<vtkVariantArray>(this->Parent->GetEdgeData()->GetAbstractArray("Vertex Ids"));
1568 vtkDataArray* vertexInfo = this->Parent->GetVertexData()->GetArray("Vertex Ids");
1569
1570 // avoids double projection
1571 int vertexNumber = vertexInfo->GetNumberOfTuples();
1572 std::vector<bool> segmentedVertices;
1573
1574 do
1575 {
1576 std::pair<std::pair<int, int>, std::vector<int>> superArc;
1577
1578 vtkEdgeType e = eIt->Next();
1579 vtkAbstractArray* vertexList = edgeInfo->GetPointer(e.Id)->ToArray();
1580
1581 superArc.first.first = (int)*(vertexInfo->GetTuple(e.Source));
1582 superArc.first.second = (int)*(vertexInfo->GetTuple(e.Target));
1583
1584 superArc.second.resize(vertexList->GetNumberOfTuples());
1585 vertexNumber += vertexList->GetNumberOfTuples();
1586 for (unsigned int i = 0; i < superArc.second.size(); i++)
1587 superArc.second[i] = vertexList->GetVariantValue(i).ToInt();
1588
1589 before.push_back(superArc);
1590 } while (eIt->HasNext());
1591
1592 segmentedVertices.resize(vertexNumber);
1593 for (unsigned int i = 0; i < segmentedVertices.size(); i++)
1594 segmentedVertices[i] = false;
1595
1596 vtkIdType prevArcId = -1, arcId = 0;
1597 while (arcId != prevArcId)
1598 {
1599 prevArcId = arcId;
1600 arcId = GetPreviousArcId();
1601 }
1602 prevArcId = -1;
1603
1604 while (prevArcId != arcId)
1605 {
1606 if (this->GetArc(arcId))
1607 {
1608 int down, up;
1609 down = this->GetNode((this->GetArc(arcId))->NodeId0)->VertexId;
1610 up = this->GetNode((this->GetArc(arcId))->NodeId1)->VertexId;
1611
1612 std::pair<std::pair<int, int>, std::vector<int>> superArc;
1613
1614 superArc.first.first = down;
1615 superArc.first.second = up;
1616

Callers

nothing calls this directly

Calls 15

GetArcMethod · 0.95
GetNodeMethod · 0.95
GetAbstractArrayMethod · 0.80
GetEdgeDataMethod · 0.80
GetVertexDataMethod · 0.80
GetNumberOfVerticesMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
sortFunction · 0.50
GetEdgesMethod · 0.45
GetArrayMethod · 0.45
GetNumberOfTuplesMethod · 0.45

Tested by

no test coverage detected