Compute the polygon normal from a points list, and a list of point ids that index into the points list. Parameter pts can be nullptr, indicating that the polygon indexing is {0, 1, ..., numPts-1}. This version will handle non-convex polygons.
| 196 | // the polygon indexing is {0, 1, ..., numPts-1}. This version will handle |
| 197 | // non-convex polygons. |
| 198 | vtkCellStatus vtkPolygon::ComputeNormal(vtkPoints* p, int numPts, const vtkIdType* pts, double* n) |
| 199 | { |
| 200 | // |
| 201 | // Check for special triangle case. Saves extra work. |
| 202 | // |
| 203 | n[0] = n[1] = n[2] = 0.0; |
| 204 | if (numPts < 3) |
| 205 | { |
| 206 | return vtkCellStatus::WrongNumberOfPoints; |
| 207 | } |
| 208 | |
| 209 | if (pts) |
| 210 | { |
| 211 | ::ComputeNormal<true>(p, numPts, pts, n); |
| 212 | } |
| 213 | else |
| 214 | { |
| 215 | ::ComputeNormal<false>(p, numPts, pts, n); |
| 216 | } |
| 217 | |
| 218 | return (vtkMath::Normalize(n) == 0) ? vtkCellStatus::DegenerateFaces : vtkCellStatus::Valid; |
| 219 | } |
| 220 | |
| 221 | //------------------------------------------------------------------------------ |
| 222 | // Compute the polygon normal from a points list, and a list of point ids |
no test coverage detected