25 rdb-example-08-invert-points.py 27 This example shows how to open an existing database and to invert 28 a point attribute by switching the "riegl.selected" and "riegl.visible" 29 bits from 0 to 1 and vice-versa ("bit flip"). 30 Please note that this could also be accomplished by combining select and 31 update queries as shown in "rdb-example-4-update-points.cpp", but the 32 invert query might be faster (lower processing time) and easier to use. 33 This example is based on the database of rdb-example-1-create-database. 39 with riegl.rdb.rdb_open(
"pointcloud.rdbx")
as rdb:
41 with riegl.rdb.Transaction(
47 def define_attribute(name, title, description, default_value):
48 """Helper function to define a dynamic point attribute""" 49 if not rdb.point_attributes.exists(name):
50 attribute = riegl.rdb.PointAttribute(rdb)
52 attribute.title = title
53 attribute.description = description
54 attribute.unit_symbol =
"" 56 attribute.resolution = 1
57 attribute.minimum_value = 0
58 attribute.maximum_value = 1
59 attribute.default_value = default_value
60 attribute.storage_class = riegl.rdb.PointAttribute.StorageClass.DYNAMIC
61 rdb.point_attributes.add(attribute)
64 define_attribute(
"riegl.selected",
"Selected",
"Point selected", 0.0)
65 define_attribute(
"riegl.visible",
"Visible",
"Point visible", 1.0)
68 with rdb.invert()
as invert:
69 invert.attribute(
"riegl.selected")
70 while invert.next(10000) > 0:
71 print(f
"{invert.progress()}% done")
75 with rdb.invert(
"riegl.selected == 1")
as invert:
76 invert.attribute(
"riegl.visible")
77 while invert.next(10000) > 0:
78 print(f
"{invert.progress()}% done")