Exemplo n.º 1
0
 def test_copy(self):
     bbox1 = BBox(Vector(1, 2, 3), Vector(4, 5, 6))
     bbox2 = bbox1.copy()
     bbox1._max = Vector(7, 8, 9)
     assert bbox2._min == Vector(1, 2, 3)
     assert bbox2._max == Vector(4, 5, 6)
     assert bbox1._min == Vector(1, 2, 3)
     assert bbox1._max == Vector(7, 8, 9)
Exemplo n.º 2
0
 def test_copy(self):
     bbox1 = BBox(Vector(1, 2, 3), Vector(4, 5, 6))
     bbox2 = bbox1.copy()
     bbox1._max = Vector(7, 8, 9)
     assert bbox2._min == Vector(1, 2, 3)
     assert bbox2._max == Vector(4, 5, 6)
     assert bbox1._min == Vector(1, 2, 3)
     assert bbox1._max == Vector(7, 8, 9)
Exemplo n.º 3
0
 def __init__(self, *args):
     if type(args[0]) in (types.StringType, types.UnicodeType):
         self.filename = args[0]
         self.triangles = []
         inf = open(self.filename)
         triangleList = self.from_input_file(inf)
     else:
         self.filename = self.preamble = ''
         triangleList = args
     self.triangles = triangleList
     bb = BBox()
     for tri in triangleList:
         bb = bb.expand(tri._bbox)
     self._bbox = bb
     self._classify_triangles_by_z()
Exemplo n.º 4
0
 def __init__(self, *args):
     if type(args[0]) in (types.StringType, types.UnicodeType):
         self.filename = args[0]
         self.triangles = []
         R = open(self.filename).read()
         self.preamble = ''.join(filter(lambda ch: ch != '\0', list(R[:80])))
         R = R[80:]
         numTriangles, R = struct.unpack('I', R[:4])[0], R[4:]
         triangleList = []
         for i in range(numTriangles):
             tri, R = self.triangle_from_string(R)
             triangleList.append(tri)
     else:
         self.filename = self.preamble = None
         triangleList = args
     self.triangles = triangleList
     bb = BBox()
     for tri in triangleList:
         bb = bb.expand(tri._bbox)
     self._bbox = bb
Exemplo n.º 5
0
 def test_getXiterator(self):
     bb = BBox(Vector(0.0, 0.0, 1.0), Vector(1.0, 2.0, 4.0))
     assert [x for x in bb.getXiterator(5)] == \
         [0.0, 0.25, 0.5, 0.75, 1.0]
     assert [x for x in bb.getXiterator(5)] == \
         [0.0, 0.25, 0.5, 0.75, 1.0]
Exemplo n.º 6
0
 def test__iterator(self):
     g = BBox()
     assert [x for x in g._iterator(1, 10, 4)] == \
         [1.0, 4.0, 7.0, 10.0]
     assert [x for x in g._iterator(-10, -1, 4)] == \
         [-10.0, -7.0, -4.0, -1.0]
Exemplo n.º 7
0
 def test_set_size(self):
     bbox = BBox(Vector(0, 0, 0), Vector(1, 1, 1))
     bbox.set_size(Vector(2, 3, 4))
     assert bbox._min == Vector(-0.5, -1.0, -1.5)
     assert bbox._max == Vector(1.5, 2.0, 2.5)
Exemplo n.º 8
0
 def test_size(self):
     assert BBox(Vector(0, -1, 0), Vector(1, 1,
                                          3)).size() == Vector(1, 2, 3)
Exemplo n.º 9
0
 def test_contains(self):
     bbox = BBox(Vector(0, 0, 0), Vector(1, 1, 1))
     assert Vector(0.5, 0.5, 0.5) in bbox
     assert Vector(0.5, 0.5, 1.1) not in bbox
Exemplo n.º 10
0
 def test_getYiterator(self):
     bb = BBox(Vector(0.0, 0.0, 1.0), Vector(1.0, 2.0, 4.0))
     assert [y for y in bb.getYiterator(9)] == \
         [0.0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0]
     assert [y for y in bb.getYiterator(9)] == \
         [0.0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0]
Exemplo n.º 11
0
 def test_getZiterator(self):
     bb = BBox(Vector(0.0, 0.0, 1.0), Vector(1.0, 2.0, 4.0))
     assert [z for z in bb.getZiterator(7)] == \
         [1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0]
     assert [z for z in bb.getZiterator(7)] == \
         [1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0]
Exemplo n.º 12
0
 def test_getYiterator(self):
     bb = BBox(Vector(0.0, 0.0, 1.0), Vector(1.0, 2.0, 4.0))
     assert [y for y in bb.getYiterator(9)] == \
         [0.0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0]
     assert [y for y in bb.getYiterator(9)] == \
         [0.0, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0]
Exemplo n.º 13
0
 def test__iterator(self):
     g = BBox()
     assert [x for x in g._iterator(1, 10, 4)] == \
         [1.0, 4.0, 7.0, 10.0]
     assert [x for x in g._iterator(-10, -1, 4)] == \
         [-10.0, -7.0, -4.0, -1.0]
Exemplo n.º 14
0
 def test_set_size(self):
     bbox = BBox(Vector(0, 0, 0), Vector(1, 1, 1))
     bbox.set_size(Vector(2, 3, 4))
     assert bbox._min == Vector(-0.5, -1.0, -1.5)
     assert bbox._max == Vector(1.5, 2.0, 2.5)
Exemplo n.º 15
0
 def test_getZiterator(self):
     bb = BBox(Vector(0.0, 0.0, 1.0), Vector(1.0, 2.0, 4.0))
     assert [z for z in bb.getZiterator(7)] == \
         [1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0]
     assert [z for z in bb.getZiterator(7)] == \
         [1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0]
Exemplo n.º 16
0
 def test_init(self):
     bbox = BBox(Vector(0, 0, 0), Vector(1, 1, 1))
     assert bbox._min == Vector(0, 0, 0)
     assert bbox._max == Vector(1, 1, 1)
Exemplo n.º 17
0
 def test_getXiterator(self):
     bb = BBox(Vector(0.0, 0.0, 1.0), Vector(1.0, 2.0, 4.0))
     assert [x for x in bb.getXiterator(5)] == \
         [0.0, 0.25, 0.5, 0.75, 1.0]
     assert [x for x in bb.getXiterator(5)] == \
         [0.0, 0.25, 0.5, 0.75, 1.0]