| 44 | } |
| 45 | |
| 46 | bool vtkCell3D::IsInsideOut() |
| 47 | { |
| 48 | // Strategy: |
| 49 | // - Compute the centroid of the cell. |
| 50 | // - Accumulate a signed projected distance on the normal between the faces and the centroid. |
| 51 | // - Check the sign to see if the cell is inside out or not. |
| 52 | double centroid[3], point[3], normal[3]; |
| 53 | if (!this->GetCentroid(centroid)) |
| 54 | { |
| 55 | return false; |
| 56 | } |
| 57 | double signedDistanceToCentroid = 0.0; |
| 58 | for (vtkIdType faceId = 0; faceId < this->GetNumberOfFaces(); ++faceId) |
| 59 | { |
| 60 | const vtkIdType* pointIds; |
| 61 | vtkIdType faceSize = this->GetFacePoints(faceId, pointIds); |
| 62 | if (faceSize) |
| 63 | { |
| 64 | this->Points->GetPoint(pointIds[0], point); |
| 65 | vtkPolygon::ComputeNormal(this->Points, faceSize, pointIds, normal); |
| 66 | signedDistanceToCentroid += |
| 67 | vtkPolygon::ComputeArea(this->Points, faceSize, pointIds, normal) * |
| 68 | (vtkMath::Dot(normal, centroid) - vtkMath::Dot(normal, point)); |
| 69 | } |
| 70 | } |
| 71 | return signedDistanceToCentroid > 0.0; |
| 72 | } |
| 73 | |
| 74 | //---------------------------------------------------------------------------- |
| 75 | int vtkCell3D::Inflate(double dist) |
no test coverage detected