Пример #1
0
 def test_aliases(self):
     """Test that aliases can be used and resolve"""
     for suffix in RMF.suffixes:
         path = RMF._get_temporary_file_path("alias." + suffix)
         print(path)
         fh = RMF.create_rmf_file(path)
         print("create factory")
         af = RMF.AliasFactory(fh)
         rh = fh.get_root_node()
         nh = rh.add_child("hi", RMF.REPRESENTATION)
         af.get(nh.add_child("alias", RMF.ALIAS)).set_aliased(rh)
         ch = nh.get_children()
         self.assertEqual(len(ch), 1)
         print(ch)
         print("final check")
         print(af.get(ch[0]).get_aliased())
         self.assertEqual(af.get(ch[0]).get_aliased(), rh)
         print("done")
Пример #2
0
        curh = curph.add_child("atom" + str(j), RMF.REPRESENTATION)
        p = pf.get(curh)
        p.set_coordinates(RMF.Vector3(3 * i, 3 * j, 0))
        p.set_mass(1)
        p.set_radius(1)
        c = cf.get(curh)
        if j % 3 == 0:
            c.set_rgb_color(RMF.Vector3(1, 0, 0))
            red.append(curh)
        elif j % 3 == 1:
            c.set_rgb_color(RMF.Vector3(0, 1, 0))
            green.append(curh)
        else:
            c.set_rgb_color(RMF.Vector3(0, 0, 1))
            blue.append(curh)

# add a second organization scheme by color
crh = rh.add_child("colors", RMF.REPRESENTATION)

redh = crh.add_child("red", RMF.REPRESENTATION)
greenh = crh.add_child("green", RMF.REPRESENTATION)
blueh = crh.add_child("blue", RMF.REPRESENTATION)

af = RMF.AliasFactory(fh)
for r in red:
    af.get(redh.add_child("red", RMF.ALIAS)).set_aliased(r)
for g in green:
    af.get(greenh.add_child("green", RMF.ALIAS)).set_aliased(g)
for b in blue:
    af.get(blueh.add_child("blue", RMF.ALIAS)).set_aliased(b)