Remove non-triangles, double triangles.
| 183 | |
| 184 | // Remove non-triangles, double triangles. |
| 185 | void Foam::triSurface::checkTriangles(const bool verbose) |
| 186 | { |
| 187 | // Simple check on indices ok. |
| 188 | const label maxPointi = points().size() - 1; |
| 189 | |
| 190 | forAll(*this, facei) |
| 191 | { |
| 192 | const triSurface::FaceType& f = (*this)[facei]; |
| 193 | |
| 194 | forAll(f, fp) |
| 195 | { |
| 196 | if (f[fp] < 0 || f[fp] > maxPointi) |
| 197 | { |
| 198 | FatalErrorInFunction |
| 199 | << "triangle " << f |
| 200 | << " uses point indices outside point range 0.." |
| 201 | << maxPointi |
| 202 | << exit(FatalError); |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | // Two phase process |
| 208 | // 1. mark invalid faces |
| 209 | // 2. pack |
| 210 | // Done to keep numbering constant in phase 1 |
| 211 | |
| 212 | // List of valid triangles |
| 213 | boolList valid(size(), true); |
| 214 | bool hasInvalid = false; |
| 215 | |
| 216 | forAll(*this, facei) |
| 217 | { |
| 218 | const labelledTri& f = (*this)[facei]; |
| 219 | |
| 220 | if ((f[0] == f[1]) || (f[0] == f[2]) || (f[1] == f[2])) |
| 221 | { |
| 222 | // 'degenerate' triangle check |
| 223 | valid[facei] = false; |
| 224 | hasInvalid = true; |
| 225 | |
| 226 | if (verbose) |
| 227 | { |
| 228 | WarningInFunction |
| 229 | << "triangle " << facei |
| 230 | << " does not have three unique vertices:\n"; |
| 231 | printTriangle(Warning, " ", f, points()); |
| 232 | } |
| 233 | } |
| 234 | else |
| 235 | { |
| 236 | // duplicate triangle check |
| 237 | const labelList& fEdges = faceEdges()[facei]; |
| 238 | |
| 239 | // Check if faceNeighbours use same points as this face. |
| 240 | // Note: discards normal information - sides of baffle are merged. |
| 241 | |
| 242 | forAll(fEdges, fp) |