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

Method InsertUniquePoint

Common/DataModel/vtkMergePoints.cxx:111–146  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

109
110//------------------------------------------------------------------------------
111int vtkMergePoints::InsertUniquePoint(const double x[3], vtkIdType& id)
112{
113 //
114 // Locate bucket that point is in.
115 //
116 vtkIdType idx = this->GetBucketIndex(x);
117 vtkIdList* bucket = this->HashTable[idx];
118
119 if (bucket) // see whether we've got duplicate point
120 {
121 //
122 // Check the list of points in that bucket.
123 //
124 vtkIdType ptId = vtkMergePointsFindPointInBucket(bucket, this->Points, x);
125 if (ptId != -1)
126 {
127 // point is already in the list, return 0 and set the id parameter
128 id = ptId;
129 return 0;
130 }
131 }
132 else
133 {
134 // create a bucket point list and insert the point
135 bucket = vtkIdList::New();
136 bucket->Allocate(this->NumberOfPointsPerBucket / 2, this->NumberOfPointsPerBucket / 3);
137 this->HashTable[idx] = bucket;
138 }
139
140 // point has to be added
141 bucket->InsertNextId(this->InsertionPointId);
142 this->Points->InsertPoint(this->InsertionPointId, x);
143 id = this->InsertionPointId++;
144
145 return 1;
146}
147
148//------------------------------------------------------------------------------
149void vtkMergePoints::PrintSelf(ostream& os, vtkIndent indent)

Callers

nothing calls this directly

Calls 6

InsertNextIdMethod · 0.80
NewFunction · 0.50
GetBucketIndexMethod · 0.45
AllocateMethod · 0.45
InsertPointMethod · 0.45

Tested by

no test coverage detected