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

Method AddVertexInternal

Common/DataModel/vtkGraph.cxx:1144–1238  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1142
1143//------------------------------------------------------------------------------
1144void vtkGraph::AddVertexInternal(vtkVariantArray* propertyArr, vtkIdType* vertex)
1145{
1146 this->ForceOwnership();
1147
1148 vtkDistributedGraphHelper* helper = this->GetDistributedGraphHelper();
1149
1150 if (propertyArr) // Add/replace vertex properties if passed in
1151 {
1152 vtkAbstractArray* peds = this->GetVertexData()->GetPedigreeIds();
1153 // If the properties include pedigreeIds, we need to see if this
1154 // pedigree already exists and, if so, simply update its properties.
1155 if (peds)
1156 {
1157 // Get the array index associated with pedIds.
1158 vtkIdType pedIdx = this->GetVertexData()->SetPedigreeIds(peds);
1159 vtkVariant pedigreeId = propertyArr->GetValue(pedIdx);
1160 if (helper)
1161 {
1162 vtkIdType myRank = this->Information->Get(vtkDataObject::DATA_PIECE_NUMBER());
1163 if (helper->GetVertexOwnerByPedigreeId(pedigreeId) != myRank)
1164 {
1165 helper->AddVertexInternal(propertyArr, vertex);
1166 return;
1167 }
1168 }
1169
1170 vtkIdType vertexIndex = this->FindVertex(pedigreeId);
1171
1172 // FindVertex returns distributed ids for parallel graphs, must account
1173 // for this prior to the range check.
1174 if (helper)
1175 {
1176 vertexIndex = helper->GetVertexIndex(vertexIndex);
1177 }
1178 if (vertexIndex != -1 && vertexIndex < this->GetNumberOfVertices())
1179 {
1180 for (int iprop = 0; iprop < propertyArr->GetNumberOfValues(); iprop++)
1181 {
1182 vtkAbstractArray* arr = this->GetVertexData()->GetAbstractArray(iprop);
1183 arr->InsertVariantValue(vertexIndex, propertyArr->GetValue(iprop));
1184 }
1185 if (vertex)
1186 {
1187 *vertex = vertexIndex;
1188 }
1189 return;
1190 }
1191
1192 this->Internals->Adjacency.emplace_back(); // Add a new (local) vertex
1193 vtkIdType index = static_cast<vtkIdType>(this->Internals->Adjacency.size() - 1);
1194
1195 vtkDataSetAttributes* vertexData = this->GetVertexData();
1196 int numProps = propertyArr->GetNumberOfValues();
1197 assert(numProps == vertexData->GetNumberOfArrays());
1198 for (int iprop = 0; iprop < numProps; iprop++)
1199 {
1200 vtkAbstractArray* arr = vertexData->GetAbstractArray(iprop);
1201 arr->InsertVariantValue(index, propertyArr->GetValue(iprop));

Callers 6

AddEdgeInternalMethod · 0.95
AddVertexMethod · 0.80
LazyAddVertexMethod · 0.80
AddVertexMethod · 0.80
LazyAddVertexMethod · 0.80
AppendAtomMethod · 0.80

Calls 15

ForceOwnershipMethod · 0.95
FindVertexMethod · 0.95
GetNumberOfVerticesMethod · 0.95
GetPedigreeIdsMethod · 0.80
GetVertexDataMethod · 0.80
SetPedigreeIdsMethod · 0.80
GetAbstractArrayMethod · 0.80
MakeDistributedIdMethod · 0.80
assertFunction · 0.50
GetValueMethod · 0.45

Tested by

no test coverage detected