| 142 | |
| 143 | template <typename T, typename TNearPointLocator> |
| 144 | void Triangulation<T, TNearPointLocator>::removeTriangles( |
| 145 | const TriIndUSet& removedTriangles) |
| 146 | { |
| 147 | if(removedTriangles.empty()) |
| 148 | return; |
| 149 | // remove triangles and calculate triangle index mapping |
| 150 | TriIndUMap triIndMap; |
| 151 | for(TriInd iT(0), iTnew(0); iT < TriInd(triangles.size()); ++iT) |
| 152 | { |
| 153 | if(removedTriangles.count(iT)) |
| 154 | continue; |
| 155 | triIndMap[iT] = iTnew; |
| 156 | triangles[iTnew] = triangles[iT]; |
| 157 | iTnew++; |
| 158 | } |
| 159 | triangles.erase(triangles.end() - removedTriangles.size(), triangles.end()); |
| 160 | // adjust triangles' neighbors |
| 161 | for(TriInd iT(0); iT < triangles.size(); ++iT) |
| 162 | { |
| 163 | Triangle& t = triangles[iT]; |
| 164 | // update neighbors to account for removed triangles |
| 165 | NeighborsArr3& nn = t.neighbors; |
| 166 | for(NeighborsArr3::iterator n = nn.begin(); n != nn.end(); ++n) |
| 167 | { |
| 168 | if(removedTriangles.count(*n)) |
| 169 | { |
| 170 | *n = noNeighbor; |
| 171 | } |
| 172 | else if(*n != noNeighbor) |
| 173 | { |
| 174 | *n = triIndMap[*n]; |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | template <typename T, typename TNearPointLocator> |
| 181 | TriIndVec& Triangulation<T, TNearPointLocator>::VertTrisInternal() |