pickling.py
Go to the documentation of this file.
1 import unittest
2 from test_case import TestCase
3 import coal
4 
5 import pickle
6 import numpy as np
7 
8 
9 def tetahedron():
10  pts = coal.StdVec_Vec3s()
11  pts.append(np.array((0, 0, 0)))
12  pts.append(np.array((0, 1, 0)))
13  pts.append(np.array((1, 0, 0)))
14  pts.append(np.array((0, 0, 1)))
15  tri = coal.StdVec_Triangle()
16  tri.append(coal.Triangle(0, 1, 2))
17  tri.append(coal.Triangle(0, 1, 3))
18  tri.append(coal.Triangle(0, 2, 3))
19  tri.append(coal.Triangle(1, 2, 3))
20  return coal.Convex(pts, tri)
21 
22 
24  def pickling(self, obj):
25  with open("save.p", "wb") as f:
26  pickle.dump(obj, f)
27  with open("save.p", "rb") as f:
28  obj2 = pickle.load(f)
29 
30  self.assertTrue(obj == obj2)
31 
32  def test_all_shapes(self):
33  box = coal.Box(1.0, 2.0, 3.0)
34  self.pickling(box)
35 
36  sphere = coal.Sphere(1.0)
37  self.pickling(sphere)
38 
39  ellipsoid = coal.Ellipsoid(1.0, 2.0, 3.0)
40  self.pickling(ellipsoid)
41 
42  convex = tetahedron()
43  self.pickling(convex)
44 
45  capsule = coal.Capsule(1.0, 2.0)
46  self.pickling(capsule)
47 
48  cylinder = coal.Cylinder(1.0, 2.0)
49  self.pickling(cylinder)
50 
51  plane = coal.Plane(np.array([0.0, 0.0, 1.0]), 2.0)
52  self.pickling(plane)
53 
54  half_space = coal.Halfspace(np.array([0.0, 0.0, 1.0]), 2.0)
55  self.pickling(half_space)
56 
57 
58 if __name__ == "__main__":
59  unittest.main()
pickling.TestGeometryPickling
Definition: pickling.py:23
pickling.tetahedron
def tetahedron()
Definition: pickling.py:9
pickling.TestGeometryPickling.test_all_shapes
def test_all_shapes(self)
Definition: pickling.py:32
coal::Halfspace
Half Space: this is equivalent to the Plane in ODE. A Half space has a priviledged direction: the dir...
Definition: coal/shape/geometric_shapes.h:892
pickling.TestGeometryPickling.pickling
def pickling(self, obj)
Definition: pickling.py:24
test_case.TestCase
Definition: test_case.py:5
coal::Capsule
Capsule It is where is the distance between the point x and the capsule segment AB,...
Definition: coal/shape/geometric_shapes.h:383
coal::Ellipsoid
Ellipsoid centered at point zero.
Definition: coal/shape/geometric_shapes.h:305
coal::Plane
Infinite plane. A plane can be viewed as two half spaces; it has no priviledged direction....
Definition: coal/shape/geometric_shapes.h:983
coal::Box
Center at zero point, axis aligned box.
Definition: coal/shape/geometric_shapes.h:166
coal::Sphere
Center at zero point sphere.
Definition: coal/shape/geometric_shapes.h:240
coal::Convex
Convex polytope.
Definition: coal/serialization/collision_object.h:51
coal::Cylinder
Cylinder along Z axis. The cylinder is defined at its centroid.
Definition: coal/shape/geometric_shapes.h:560
coal::Triangle
Triangle with 3 indices for points.
Definition: coal/data_types.h:111


hpp-fcl
Author(s):
autogenerated on Sat Nov 23 2024 03:44:58