IMP logo
algebra examples

geometry

This example shows writting one piece of geometry to an hdf5 and then reading it back.

import IMP.rmf
import RMF
# create a temporary file
tfn= IMP.create_temporary_file_name("rmf_geometry", "rmf")
# open the hdf5, clearing any existing contents
# creating a box geometry
bb= IMP.algebra.BoundingBox3D(IMP.algebra.Vector3D(0,0,0),
IMP.algebra.Vector3D(10, 10, 10))
# add the geometry to the file
IMP.rmf.add_geometry(f, g)
bb= IMP.algebra.BoundingBox3D(IMP.algebra.Vector3D(1,1,1),
IMP.algebra.Vector3D(10, 10, 10))
g.set_geometry(bb)
# save a second frame with the bounding box
del f
# recreate the geometries from the file. The geometry will be the same
# but it will not be a IMP.display.BoundingBoxGeometry, it will be
# a set of cylinders instead.
print gs[0].get_name()
print "Try running rmf_display on", tfn
# load another frame
# cast it to a BoundingBoxGeometry and print out the geometry
print IMP.display.BoundingBoxGeometry.get_from(gs[0]).get_geometry()

grid space

This example shows how to use the grid support in IMP.algebra to discretize a set of continuous points. In this case the points are simply randomly drawn from the surface of a sphere, but they could be taken from something more interesting.

# create a unit grid with its origin at 0,0,0
s= IMP.algebra.Sphere3D(IMP.algebra.Vector3D(1,1,1), 6)
count=0
for i in range(0,100):
ei= g.get_extended_index(p)
if g.get_has_index(ei):
print "hit"
else:
g.add_voxel(ei, count)
count=count+1
print "There are", len(g.get_all_indexes()), "distinct values", count


Generated on Tue May 22 2012 23:33:20 for IMP by doxygen 1.8.1