RMF
make_reference_frames.py

This simple example makes an RMF file with several rigid copies of the same thing

1 ## \example make_reference_frames.py
2 # This simple example makes an RMF file with several rigid copies of the
3 # same thing
4 from __future__ import print_function
5 import RMF
6 
7 file_name = RMF._get_temporary_file_path("reference_frame.rmfz")
8 print("file is", file_name)
9 fh = RMF.create_rmf_file(file_name)
10 fh.add_frame("root", RMF.FRAME)
11 
12 rh = fh.get_root_node()
13 
14 reference_frame_factory = RMF.ReferenceFrameFactory(fh)
15 segment_factory = RMF.SegmentFactory(fh)
16 color_factory = RMF.ColoredFactory(fh)
17 
18 # first make a copy at the origin
19 origin = rh.add_child("origin", RMF.REPRESENTATION)
20 rbo = reference_frame_factory.get(origin)
21 rbo.set_translation(RMF.Vector3(0, 0, 0))
22 rbo.set_rotation(RMF.Vector4(1, 0, 0, 0))
23 x = origin.add_child("x", RMF.GEOMETRY)
24 sx = segment_factory.get(x)
25 sx.set_coordinates_list([RMF.Vector3(0, 0, 0), RMF.Vector3(1, 0, 0)])
26 cx = color_factory.get(x)
27 cx.set_rgb_color(RMF.Vector3(1, 0, 0))
28 y = origin.add_child("y", RMF.GEOMETRY)
29 sy = segment_factory.get(y)
30 sy.set_coordinates_list([RMF.Vector3(0, 0, 0), RMF.Vector3(0, 1, 0)])
31 cy = color_factory.get(y)
32 cy.set_rgb_color(RMF.Vector3(0, 1, 0))
33 z = origin.add_child("z", RMF.GEOMETRY)
34 sz = segment_factory.get(z)
35 sz.set_coordinates_list([RMF.Vector3(0, 0, 0), RMF.Vector3(0, 0, 1)])
36 cz = color_factory.get(z)
37 cz.set_rgb_color(RMF.Vector3(0, 0, 1))
38 
39 
40 # now we add another copy
41 # this will result in one off of the origin and rotated
42 remote = rh.add_child("remote", RMF.REPRESENTATION)
43 rbr = reference_frame_factory.get(remote)
44 rbr.set_translation(RMF.Vector3(1, 0, 0))
45 rbr.set_rotation(RMF.Vector4(.5, .5, .5, .5))
46 remote.add_child(x)
47 remote.add_child(y)
48 remote.add_child(z)