RMF
reference_frame_particle.py
1## \example reference_frame_particle.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("first frame", RMF.FRAME)
10
11rh = fh.get_root_node()
12
13reference_frame_factory = RMF.ReferenceFrameFactory(fh)
14ball_factory = RMF.BallFactory(fh)
15particle_factory = RMF.ParticleFactory(fh)
16color_factory = RMF.ColoredFactory(fh)
17bond_factory = RMF.BondFactory(fh)
18
19origin = rh.add_child("origin", RMF.REPRESENTATION)
20pd = particle_factory.get(origin)
21pd.set_radius(1)
22pd.set_mass(2)
23pd.set_coordinates(RMF.Vector3(0, 0, 0))
24
25for i in range(0, 3):
26 c = rh.add_child(str(i), RMF.REPRESENTATION)
27 pd = particle_factory.get(c)
28 pd.set_radius(1)
29 pd.set_mass(2)
30 coords = [0, 0, 0]
31 coords[i] = 2
32 pd.set_coordinates(RMF.Vector3(*coords))
33
34
35frame = rh.add_child("frame", RMF.REPRESENTATION)
36rbo = reference_frame_factory.get(frame)
37rbo.set_translation(RMF.Vector3(5, 0, 0))
38rbo.set_rotation(RMF.Vector4(1, 0, 0, 0))
39pd = particle_factory.get(frame)
40pd.set_radius(5)
41pd.set_mass(2)
42pd.set_coordinates(RMF.Vector3(0, 0, 0))
43
44for i in range(0, 3):
45 ch = frame.add_child("site", RMF.GEOMETRY)
46 coords = [0, 0, 0]
47 coords[i] = 5
48 v = RMF.Vector3(*coords)
49 ball_factory.get(ch).set_coordinates(v)
50 ball_factory.get(ch).set_radius(1)
51 bch = frame.add_child("bond", RMF.BOND)
52 bond_factory.get(bch).set_bonded_0(ch.get_id().get_index())
53 bond_factory.get(bch).set_bonded_1(frame.get_id().get_index())
FileHandle create_rmf_file(std::string path)
Create an RMF from a file system path.