(self)
| 9 | |
| 10 | class TestStarPolygon(Testing.vtkTest): |
| 11 | def test(self): |
| 12 | n = 12 |
| 13 | t = 2.0*math.pi/n |
| 14 | s = (1.0 + math.sin(t))/math.cos(t) - 1.0 |
| 15 | |
| 16 | points = vtkPoints() |
| 17 | for z,e in enumerate([-1.0e-6,0.0,1.0e-6]): |
| 18 | for i in range(n): |
| 19 | r = 25.0*(1.0 + (i%2)*s + e) |
| 20 | x, y = r*math.cos(i*t), r*math.sin(i*t) |
| 21 | points.InsertNextPoint([x, y, 10.0*z]) |
| 22 | |
| 23 | nn = [-1,-1,-1] |
| 24 | for ci in range(3): |
| 25 | pts = [ci*n + i for i in range(n)] |
| 26 | vtkPolygon.ComputeNormal(points, n, pts, nn) |
| 27 | area = vtkPolygon.ComputeArea(points, n, pts, nn) |
| 28 | print("Cell: %2d Normal: [%5.2f, %5.2f, %5.2f], Area: %g" % (ci, nn[0], nn[1], nn[2], area)) |
| 29 | self.assertEqual(abs(vtkMath.Norm(nn) - 1.0) < 0.0001, True) |
| 30 | |
| 31 | if __name__ == "__main__": |
| 32 | Testing.main([(TestStarPolygon, 'test')]) |
nothing calls this directly
no test coverage detected