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