------------------------------------------------------------------------------ Determine whether point given by x[3] has been inserted into points list. Return id of previously inserted point if this is true, otherwise return -1.
| 1243 | // Return id of previously inserted point if this is true, otherwise return |
| 1244 | // -1. |
| 1245 | vtkIdType vtkPointLocator::IsInsertedPoint(const double x[3]) |
| 1246 | { |
| 1247 | int i, j, ijk[3]; |
| 1248 | vtkNeighborPoints buckets; |
| 1249 | vtkIdType nids; |
| 1250 | |
| 1251 | // Locate bucket that point is in. |
| 1252 | // |
| 1253 | this->GetBucketIndices(x, ijk); |
| 1254 | |
| 1255 | // Check the list of points in that bucket for merging. Also need to |
| 1256 | // search all neighboring buckets within the tolerance. The number |
| 1257 | // and level of neighbors to search depends upon the tolerance and |
| 1258 | // the bucket width. |
| 1259 | // |
| 1260 | int *nei, lvtk; |
| 1261 | vtkIdType ptId, cno; |
| 1262 | vtkIdList* ptIds; |
| 1263 | double pt[3]; |
| 1264 | |
| 1265 | for (lvtk = 0; lvtk <= this->InsertionLevel; lvtk++) |
| 1266 | { |
| 1267 | this->GetBucketNeighbors(&buckets, ijk, this->Divisions, lvtk); |
| 1268 | |
| 1269 | for (i = 0; i < buckets.GetNumberOfNeighbors(); i++) |
| 1270 | { |
| 1271 | nei = buckets.GetPoint(i); |
| 1272 | cno = nei[0] + nei[1] * this->XD + nei[2] * this->SliceSize; |
| 1273 | |
| 1274 | if ((ptIds = this->HashTable[cno]) != nullptr) |
| 1275 | { |
| 1276 | nids = ptIds->GetNumberOfIds(); |
| 1277 | for (j = 0; j < nids; j++) |
| 1278 | { |
| 1279 | ptId = ptIds->GetId(j); |
| 1280 | this->Points->GetPoint(ptId, pt); |
| 1281 | |
| 1282 | if (vtkMath::Distance2BetweenPoints(x, pt) <= this->InsertionTol2) |
| 1283 | { |
| 1284 | return ptId; |
| 1285 | } |
| 1286 | } |
| 1287 | } // if points in bucket |
| 1288 | } // for each neighbor |
| 1289 | } // for neighbors at this level |
| 1290 | |
| 1291 | return -1; |
| 1292 | } |
| 1293 | |
| 1294 | //------------------------------------------------------------------------------ |
| 1295 | int vtkPointLocator::InsertUniquePoint(const double x[3], vtkIdType& id) |
no test coverage detected