RMF
Toggle main menu visibility
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
4
import
RMF
5
6
file_name = RMF._get_temporary_file_path(
"reference_frame.rmfz"
)
7
print(
"file is"
, file_name)
8
fh =
RMF.create_rmf_file
(file_name)
9
fh.add_frame(
"root"
, RMF.FRAME)
10
11
rh = fh.get_root_node()
12
13
reference_frame_factory = RMF.ReferenceFrameFactory(fh)
14
segment_factory = RMF.SegmentFactory(fh)
15
color_factory = RMF.ColoredFactory(fh)
16
17
# first make a copy at the origin
18
origin = rh.add_child(
"origin"
, RMF.REPRESENTATION)
19
rbo = reference_frame_factory.get(origin)
20
rbo.set_translation(
RMF.Vector3
(0, 0, 0))
21
rbo.set_rotation(
RMF.Vector4
(1, 0, 0, 0))
22
x = origin.add_child(
"x"
, RMF.GEOMETRY)
23
sx = segment_factory.get(x)
24
sx.set_coordinates_list([
RMF.Vector3
(0, 0, 0),
RMF.Vector3
(1, 0, 0)])
25
cx = color_factory.get(x)
26
cx.set_rgb_color(
RMF.Vector3
(1, 0, 0))
27
y = origin.add_child(
"y"
, RMF.GEOMETRY)
28
sy = segment_factory.get(y)
29
sy.set_coordinates_list([
RMF.Vector3
(0, 0, 0),
RMF.Vector3
(0, 1, 0)])
30
cy = color_factory.get(y)
31
cy.set_rgb_color(
RMF.Vector3
(0, 1, 0))
32
z = origin.add_child(
"z"
, RMF.GEOMETRY)
33
sz = segment_factory.get(z)
34
sz.set_coordinates_list([
RMF.Vector3
(0, 0, 0),
RMF.Vector3
(0, 0, 1)])
35
cz = color_factory.get(z)
36
cz.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
41
remote = rh.add_child(
"remote"
, RMF.REPRESENTATION)
42
rbr = reference_frame_factory.get(remote)
43
rbr.set_translation(
RMF.Vector3
(1, 0, 0))
44
rbr.set_rotation(
RMF.Vector4
(.5, .5, .5, .5))
45
remote.add_child(x)
46
remote.add_child(y)
47
remote.add_child(z)
RMF::Vector< 3U >
RMF::create_rmf_file
FileHandle create_rmf_file(std::string path)
Create an RMF from a file system path.