IMP
2.4.0
The Integrative Modeling Platform
IMP Mainpage
Modules
Classes
Examples
doc
examples
display
basic_geometry.py
1
## \example display/basic_geometry.py
2
# This example shows how to write basic geometric primitives to a file
3
# with color and name.
4
5
from
__future__
import
print_function
6
import
IMP.display
7
8
# or IMP.display.ChimeraWriter
9
# if using chimera, make sure there is a %1% in the name to support
10
# multiple frames
11
name = IMP.create_temporary_file_name(
"example"
,
".py"
)
12
print(
"File name is"
, name)
13
w =
IMP.display.PymolWriter
(name)
14
15
bb =
IMP.algebra.BoundingBox3D
(
IMP.algebra.Vector3D
(0, 0, 0),
16
IMP.algebra.Vector3D
(100, 100, 100))
17
# we could skip the outer loop if we only have one frame
18
for
f
in
range(0, 10):
19
w.set_frame(f)
20
g =
IMP.display.BoundingBoxGeometry
(bb)
21
g.set_name(
"bb"
)
22
w.add_geometry(g)
23
for
i
in
range(0, 10):
24
p =
IMP.algebra.get_random_vector_in
(bb)
25
g =
IMP.display.SphereGeometry
(
IMP.algebra.Sphere3D
(p, 10))
26
# give each a distinctive color
27
g.set_color(
IMP.display.get_display_color
(i))
28
g.set_name(str(i))
29
# add it to the file
30
w.add_geometry(g)
IMP::display::BoundingBoxGeometry
Display a bounding box.
Definition:
primitive_geometries.h:60
IMP::algebra::get_random_vector_in
Vector3D get_random_vector_in(const Cylinder3D &c)
Generate a random vector in a cylinder with uniform density.
IMP::display::SphereGeometry
Display a sphere.
Definition:
primitive_geometries.h:32
IMP::display::get_display_color
Color get_display_color(unsigned int i)
IMP::algebra::BoundingBoxD< 3 >
IMP::algebra::Vector3D
VectorD< 3 > Vector3D
Definition:
VectorD.h:395
IMP::display::PymolWriter
Write a CGO file with the geometry.
Definition:
PymolWriter.h:34
IMP::display
Output IMP model data in various file formats.
IMP::algebra::SphereD< 3 >