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

Method GetVertexOwnerByPedigreeId

Common/DataModel/vtkDistributedGraphHelper.cxx:179–219  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

177
178//------------------------------------------------------------------------------
179vtkIdType vtkDistributedGraphHelper::GetVertexOwnerByPedigreeId(const vtkVariant& pedigreeId)
180{
181 vtkIdType numProcs = this->Graph->GetInformation()->Get(vtkDataObject::DATA_NUMBER_OF_PIECES());
182 if (this->VertexDistribution)
183 {
184 return (this->VertexDistribution(pedigreeId, this->VertexDistributionUserData) % numProcs);
185 }
186
187 // Hash the variant in a very lame way.
188 double numericValue;
189 std::string stringValue;
190 const unsigned char *charsStart, *charsEnd;
191 if (pedigreeId.IsNumeric())
192 {
193 // Convert every numeric value into a double.
194 numericValue = pedigreeId.ToDouble();
195
196 // Hash the characters in the double.
197 charsStart = reinterpret_cast<const unsigned char*>(&numericValue);
198 charsEnd = charsStart + sizeof(double);
199 }
200 else if (pedigreeId.GetType() == VTK_STRING)
201 {
202 stringValue = pedigreeId.ToString();
203 charsStart = reinterpret_cast<const unsigned char*>(stringValue.c_str());
204 charsEnd = charsStart + stringValue.size();
205 }
206 else
207 {
208 vtkErrorMacro("Cannot hash vertex pedigree ID of type " << pedigreeId.GetType());
209 return 0;
210 }
211
212 unsigned long hash = 5381;
213 for (; charsStart != charsEnd; ++charsStart)
214 {
215 hash = ((hash << 5) + hash) ^ *charsStart;
216 }
217
218 return hash % numProcs;
219}
220VTK_ABI_NAMESPACE_END

Callers 2

FindVertexMethod · 0.80
AddVertexInternalMethod · 0.80

Calls 8

GetMethod · 0.45
GetInformationMethod · 0.45
IsNumericMethod · 0.45
ToDoubleMethod · 0.45
GetTypeMethod · 0.45
ToStringMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected