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

Method ValidateLinkGraph

Infovis/Core/vtkTableToGraph.cxx:57–117  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

55
56//------------------------------------------------------------------------------
57int vtkTableToGraph::ValidateLinkGraph()
58{
59 if (!this->LinkGraph)
60 {
61 this->LinkGraph = vtkMutableDirectedGraph::New();
62 }
63 if (!vtkArrayDownCast<vtkStringArray>(
64 this->LinkGraph->GetVertexData()->GetAbstractArray("column")))
65 {
66 if (this->LinkGraph->GetNumberOfVertices() == 0)
67 {
68 vtkStringArray* column = vtkStringArray::New();
69 column->SetName("column");
70 this->LinkGraph->GetVertexData()->AddArray(column);
71 column->Delete();
72 this->Modified();
73 }
74 else
75 {
76 vtkErrorMacro("The link graph must contain a string array named \"column\".");
77 return 0;
78 }
79 }
80 if (!vtkArrayDownCast<vtkStringArray>(
81 this->LinkGraph->GetVertexData()->GetAbstractArray("domain")))
82 {
83 vtkStringArray* domain = vtkStringArray::New();
84 domain->SetName("domain");
85 domain->SetNumberOfTuples(this->LinkGraph->GetNumberOfVertices());
86 for (vtkIdType i = 0; i < this->LinkGraph->GetNumberOfVertices(); i++)
87 {
88 domain->SetValue(i, "");
89 }
90 this->LinkGraph->GetVertexData()->AddArray(domain);
91 domain->Delete();
92 this->Modified();
93 }
94 if (!vtkArrayDownCast<vtkBitArray>(this->LinkGraph->GetVertexData()->GetAbstractArray("hidden")))
95 {
96 vtkBitArray* hidden = vtkBitArray::New();
97 hidden->SetName("hidden");
98 hidden->SetNumberOfTuples(this->LinkGraph->GetNumberOfVertices());
99 this->LinkGraph->GetVertexData()->AddArray(hidden);
100 hidden->Delete();
101 this->Modified();
102 }
103 if (!vtkArrayDownCast<vtkIntArray>(this->LinkGraph->GetVertexData()->GetAbstractArray("active")))
104 {
105 vtkIntArray* active = vtkIntArray::New();
106 active->SetName("active");
107 active->SetNumberOfTuples(this->LinkGraph->GetNumberOfVertices());
108 for (vtkIdType i = 0; i < this->LinkGraph->GetNumberOfVertices(); ++i)
109 {
110 active->SetValue(i, 1);
111 }
112 this->LinkGraph->GetVertexData()->AddArray(active);
113 active->Delete();
114 this->Modified();

Callers 4

AddLinkVertexMethod · 0.95
ClearLinkVerticesMethod · 0.95
AddLinkEdgeMethod · 0.95
RequestDataMethod · 0.95

Calls 10

GetAbstractArrayMethod · 0.80
GetVertexDataMethod · 0.80
GetNumberOfVerticesMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
SetNameMethod · 0.45
AddArrayMethod · 0.45
ModifiedMethod · 0.45
SetNumberOfTuplesMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected