MCPcopy Create free account
hub / github.com/Kitware/VTK / test

Method test

Common/DataModel/Testing/Python/TestStarPolygon.py:11–29  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

9
10class 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
31if __name__ == "__main__":
32 Testing.main([(TestStarPolygon, 'test')])

Callers

nothing calls this directly

Calls 11

enumerateFunction · 0.85
sinMethod · 0.80
cosMethod · 0.80
NormMethod · 0.80
vtkPointsClass · 0.50
rangeClass · 0.50
printFunction · 0.50
absFunction · 0.50
InsertNextPointMethod · 0.45
ComputeNormalMethod · 0.45
ComputeAreaMethod · 0.45

Tested by

no test coverage detected