RMF
Toggle main menu visibility
externals.py
1
## \example externals.py
2
# Show how to create an RMF file that has references to external files.
3
# And how to read it back, sort of.
4
import
RMF
5
import
os.path
6
import
sys
7
8
input_pdb = os.path.join(os.path.split(sys.argv[0])[0],
"simple.pdb"
)
9
rmf_name = RMF._get_temporary_file_path(
"externals.rmf"
)
10
output_pdb = RMF._get_temporary_file_path(
"simple.pdb"
)
11
print(
"file name is"
, rmf_name)
12
13
rmf =
RMF.create_rmf_file
(rmf_name)
14
rmf.add_frame(
"root"
, RMF.FRAME)
15
16
# copy simple.pdb to output dir
17
open(output_pdb,
"w"
).write(open(input_pdb,
"r"
).read())
18
pdb_relpath =
"./simple.pdb"
19
20
rpf = RMF.ReferenceFrameFactory(rmf)
21
ef = RMF.ExternalFactory(rmf)
22
# add a couple transformed copies of simple
23
c0 = rmf.get_root_node().add_child(
"copy0"
, RMF.REPRESENTATION)
24
rb0 = rpf.get(c0)
25
rb0.set_translation(
RMF.Vector3
(0, 0, 0))
26
rb0.set_rotation(
RMF.Vector4
(1, 0, 0, 0))
27
external = c0.add_child(
"simple.pdb"
, RMF.REPRESENTATION)
28
ed = ef.get(external)
29
ed.set_path(pdb_relpath)
30
31
# add another, reusing the same reference node
32
c1 = rmf.get_root_node().add_child(
"copy1"
, RMF.REPRESENTATION)
33
rb1 = rpf.get(c1)
34
rb1.set_translation(
RMF.Vector3
(20, 0, 0))
35
rb1.set_rotation(
RMF.Vector4
(.5, .5, .5, .5))
36
c1.add_child(external)
RMF::Vector< 3U >
RMF::create_rmf_file
FileHandle create_rmf_file(std::string path)
Create an RMF from a file system path.