| 112 | } |
| 113 | |
| 114 | void InsertPoint(float dist2, vtkIdType id) |
| 115 | { |
| 116 | if (dist2 <= this->LargestDist2 || this->NumPoints < this->NumDesiredPoints) |
| 117 | { |
| 118 | std::map<float, std::list<vtkIdType>>::iterator it = this->dist2ToIds.find(dist2); |
| 119 | this->NumPoints++; |
| 120 | if (it == this->dist2ToIds.end()) |
| 121 | { |
| 122 | std::list<vtkIdType> idset; |
| 123 | idset.push_back(id); |
| 124 | this->dist2ToIds[dist2] = idset; |
| 125 | } |
| 126 | else |
| 127 | { |
| 128 | it->second.push_back(id); |
| 129 | } |
| 130 | if (this->NumPoints > this->NumDesiredPoints) |
| 131 | { |
| 132 | it = this->dist2ToIds.end(); |
| 133 | --it; |
| 134 | if ((this->NumPoints - it->second.size()) > this->NumDesiredPoints) |
| 135 | { |
| 136 | this->NumPoints -= it->second.size(); |
| 137 | std::map<float, std::list<vtkIdType>>::iterator it2 = it; |
| 138 | --it2; |
| 139 | this->LargestDist2 = it2->first; |
| 140 | this->dist2ToIds.erase(it); |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | void GetSortedIds(vtkIdList* ids) |
| 146 | { |
| 147 | ids->Reset(); |