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