| 39 | } |
| 40 | |
| 41 | void InsertPoint(float dist2, vtkIdType id) |
| 42 | { |
| 43 | if (dist2 <= this->LargestDist2 || this->NumPoints < this->NumDesiredPoints) |
| 44 | { |
| 45 | std::map<float, std::list<vtkIdType>>::iterator it = this->dist2ToIds.find(dist2); |
| 46 | this->NumPoints++; |
| 47 | if (it == this->dist2ToIds.end()) |
| 48 | { |
| 49 | std::list<vtkIdType> idset; |
| 50 | idset.push_back(id); |
| 51 | this->dist2ToIds[dist2] = idset; |
| 52 | } |
| 53 | else |
| 54 | { |
| 55 | it->second.push_back(id); |
| 56 | } |
| 57 | if (this->NumPoints > this->NumDesiredPoints) |
| 58 | { |
| 59 | it = this->dist2ToIds.end(); |
| 60 | --it; |
| 61 | if ((this->NumPoints - it->second.size()) > this->NumDesiredPoints) |
| 62 | { |
| 63 | this->NumPoints -= it->second.size(); |
| 64 | std::map<float, std::list<vtkIdType>>::iterator it2 = it; |
| 65 | --it2; |
| 66 | this->LargestDist2 = it2->first; |
| 67 | this->dist2ToIds.erase(it); |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | void GetSortedIds(vtkIdList* ids) |
| 73 | { |
| 74 | ids->Reset(); |