DM_iterate_simple.py
## @package python.DM_iterate_simple
#
# iterating over all points of an existing ODM within python
#
from __future__ import print_function # print function syntax as in python 3
import sys
from opals import pyDM # for pyDM in release mode
def DM_iterate_simple(filename):
# open the odm / pyDM.Datamanager.load parameters: filename(string), readOnly(bool) threadSafety(bool)
dm = pyDM.Datamanager.load(filename, True, False)
# if the dm wasn't opened successful exit function
if not dm:
print("Unable to open ODM '" + filename + "'")
return
idx = 0
print("Output", dm.sizePoint(), " points from the ODM")
# now iterate over all points
for pt in dm.points():
idx += 1
# output point
print(idx, ".point", "%.3f" % pt.x, "%.3f" % pt.y, "%.3f" % pt.z)
print("done")
if len(sys.argv) == 1:
print("ODM parameter missing")
exit(-1)
DM_iterate_simple(sys.argv[1])