home
about
news
download
doc
source
systems
tests
bugs
contact
IMP Reference Guide
develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
IMP Manual
Reference Guide
Tutorial Index
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
import
IMP.display
6
import
sys
7
8
IMP.setup_from_argv
(
9
sys.argv,
10
"Write basic geometric primitives to a file with color and name."
)
11
12
name =
IMP.create_temporary_file_name
(
"example"
,
".py"
)
13
print(
"File name is"
, name)
14
w =
IMP.display.PymolWriter
(name)
15
16
bb =
IMP.algebra.BoundingBox3D
(
IMP.algebra.Vector3D
(0, 0, 0),
17
IMP.algebra.Vector3D
(100, 100, 100))
18
# we could skip the outer loop if we only have one frame
19
for
f
in
range(0, 10):
20
w.set_frame(f)
21
g =
IMP.display.BoundingBoxGeometry
(bb)
22
g.set_name(
"bb"
)
23
w.add_geometry(g)
24
for
i
in
range(0, 10):
25
p =
IMP.algebra.get_random_vector_in
(bb)
26
g =
IMP.display.SphereGeometry
(
IMP.algebra.Sphere3D
(p, 10))
27
# give each a distinctive color
28
g.set_color(
IMP.display.get_display_color
(i))
29
g.set_name(str(i))
30
# add it to the file
31
w.add_geometry(g)
IMP::algebra::BoundingBoxD< 3 >
IMP::algebra::SphereD< 3 >
IMP::display::BoundingBoxGeometry
Display a bounding box.
Definition
primitive_geometries.h:60
IMP::display::PymolWriter
Write a CGO file with the geometry.
Definition
PymolWriter.h:34
IMP::display::SphereGeometry
Display a sphere.
Definition
primitive_geometries.h:32
IMP::algebra::Vector3D
VectorD< 3 > Vector3D
Definition
VectorD.h:407
IMP::algebra::get_random_vector_in
VectorD< D > get_random_vector_in(const BoundingBoxD< D > &bb)
Generate a random vector in a box with uniform density.
Definition
vector_generators.h:39
IMP::display
Output IMP model data in various file formats.
IMP::display::get_display_color
Color get_display_color(unsigned int i)
IMP::create_temporary_file_name
std::string create_temporary_file_name(std::string prefix="imp_temp", std::string suffix="")
Create a temporary file.
IMP::setup_from_argv
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.