9 from datetime
import datetime
10 from opals
import pyDM
12 if len(sys.argv) == 1:
13 print(
"ODM parameter missing")
17 dm = pyDM.Datamanager.load(sys.argv[1],
True,
False)
21 print(
"Unable to open ODM '" + sys.argv[1] +
"'")
25 PointIndex = dm.getPointIndex()
29 x = (lim.xmax + lim.xmin) / 2
30 y = (lim.ymax + lim.ymin) / 2
31 a = (lim.xmax - lim.xmin) / 3
32 b = (lim.ymax - lim.ymin) / 3
35 z = (lim.zmin + lim.zmax) / 2
36 c = (lim.zmax - lim.zmin) / 3
42 cir = pyDM.Circle(x, y, r)
43 cyl = pyDM.Cylinder(x, y, r, zmin, zmax)
44 sph = pyDM.Sphere(x, y, z, r)
47 PolygonF = pyDM.PolygonFactory()
48 for alp
in range(0, 360, 6):
49 alpr = alp * math.pi / 180
50 PolygonF.addPoint(x + r * math.sin(alpr), y + r * math.cos(alpr))
52 pol = PolygonF.getPolygon(pyDM.Orientation.cw)
55 cirstart = datetime.now()
56 PointsInCir = PointIndex.searchPoint(cir)
57 NumPointsInCir = len(PointsInCir)
58 cirend = datetime.now()
60 cylstart = datetime.now()
61 PointsInCyl = PointIndex.searchPoint(cyl)
62 NumPointsInCyl = len(PointsInCyl)
63 cylend = datetime.now()
65 sphstart = datetime.now()
66 PointsInSph = PointIndex.searchPoint(sph)
67 NumPointsInSph = len(PointsInSph)
68 sphend = datetime.now()
70 polstart = datetime.now()
71 PointsInPol = PointIndex.searchPoint(pol)
72 NumPointsInPol = len(PointsInPol)
73 polend = datetime.now()
75 print(
"Out of %6i points total..." % dm.sizePoint())
76 print(
"The circle contains %6i points. (runtime: %s)" % (NumPointsInCir, str(cirend - cirstart)))
77 print(
"The cylinder contains %6i points. (runtime: %s)" % (NumPointsInCyl, str(cylend - cylstart)))
78 print(
"The sphere contains %6i points. (runtime: %s)" % (NumPointsInSph, str(sphend - sphstart)))
79 print(
"The polygon contains %6i points. (runtime: %s)" % (NumPointsInPol, str(polend - polstart)))