Exemple #1
0
 def ds_map(self):
   data = ply2.create()
   data['type'].append('map')
   data['meta']['location'] = 'Middle Earth'
   
   names = numpy.zeros(9, dtype=numpy.object)
   names[0] = 'Hobbiton'
   names[1] = 'Bree'
   names[2] = 'Rivendell'
   names[3] = 'Moria'
   names[4] = u'Lothl\u00f3rien'
   names[5] = 'Edoras'
   names[6] = "Helm's Deep"
   names[7] = 'Isengard'
   names[8] = 'Minas Tirith'
   
   data['element']['city'] = OrderedDict()
   data['element']['city']['name'] = names
   data['element']['city']['x'] = numpy.array([67.4, 79.0, 99.1, 100.5, 113.0, 105.1, 99.5, 98.5, 135.6], dtype=numpy.float32)
   data['element']['city']['y'] = numpy.array([55.5, 54.1, 53.3, 69.5, 74.6, 99.6, 98.7, 94.8, 111.3], dtype=numpy.float32)
   
   names = numpy.zeros(3, dtype=numpy.object)
   names[0] = 'Orthanc'
   names[1] = u'Barad-d\u00fbr'
   names[2] = 'Cirith Ungol'
   
   data['element']['tower'] = OrderedDict()
   data['element']['tower']['name'] = names
   data['element']['tower']['x'] = numpy.array([98.5, 156.2, 145.2], dtype=numpy.float32)
   data['element']['tower']['y'] = numpy.array([94.8, 107.8, 111.0], dtype=numpy.float32)
   
   return data
Exemple #2
0
 def ds_mesh(self):
   data = ply2.create()
   data['type'].append('mesh')
   
   verts = numpy.empty((8, 3), dtype=numpy.float32)
   verts[0,:] = ( 1.0,  1.0, -1.0)
   verts[1,:] = ( 1.0, -1.0, -1.0)
   verts[2,:] = (-1.0, -1.0, -1.0)
   verts[3,:] = (-1.0,  1.0, -1.0)
   verts[4,:] = ( 1.0,  1.0,  1.0)
   verts[5,:] = (-1.0,  1.0,  1.0)
   verts[6,:] = (-1.0, -1.0,  1.0)
   verts[7,:] = ( 1.0, -1.0,  1.0)
   
   faces = numpy.empty(6, dtype=numpy.object)
   faces[0] = numpy.array([0, 1, 2, 3], dtype=numpy.int32)
   faces[1] = numpy.array([4, 5, 6, 7], dtype=numpy.int32)
   faces[2] = numpy.array([0, 4, 7, 1], dtype=numpy.int32)
   faces[3] = numpy.array([1, 7, 6, 2], dtype=numpy.int32)
   faces[4] = numpy.array([2, 6, 5, 3], dtype=numpy.int32)
   faces[5] = numpy.array([4, 0, 3, 5], dtype=numpy.int32)
   
   data['element']['vertex'] = OrderedDict()
   data['element']['vertex']['x'] = verts[:,0]
   data['element']['vertex']['y'] = verts[:,1]
   data['element']['vertex']['z'] = verts[:,2]
   
   data['element']['face'] = OrderedDict()
   data['element']['face']['vertex_indices'] = faces
   
   return data
Exemple #3
0
    def ds_mesh(self):
        data = ply2.create()
        data['type'].append('mesh')

        verts = numpy.empty((8, 3), dtype=numpy.float32)
        verts[0, :] = (1.0, 1.0, -1.0)
        verts[1, :] = (1.0, -1.0, -1.0)
        verts[2, :] = (-1.0, -1.0, -1.0)
        verts[3, :] = (-1.0, 1.0, -1.0)
        verts[4, :] = (1.0, 1.0, 1.0)
        verts[5, :] = (-1.0, 1.0, 1.0)
        verts[6, :] = (-1.0, -1.0, 1.0)
        verts[7, :] = (1.0, -1.0, 1.0)

        faces = numpy.empty(6, dtype=numpy.object)
        faces[0] = numpy.array([0, 1, 2, 3], dtype=numpy.int32)
        faces[1] = numpy.array([4, 5, 6, 7], dtype=numpy.int32)
        faces[2] = numpy.array([0, 4, 7, 1], dtype=numpy.int32)
        faces[3] = numpy.array([1, 7, 6, 2], dtype=numpy.int32)
        faces[4] = numpy.array([2, 6, 5, 3], dtype=numpy.int32)
        faces[5] = numpy.array([4, 0, 3, 5], dtype=numpy.int32)

        data['element']['vertex'] = OrderedDict()
        data['element']['vertex']['x'] = verts[:, 0]
        data['element']['vertex']['y'] = verts[:, 1]
        data['element']['vertex']['z'] = verts[:, 2]

        data['element']['face'] = OrderedDict()
        data['element']['face']['vertex_indices'] = faces

        return data
Exemple #4
0
 def ds_image(self):
   data = ply2.create()
   data['type'].append('image.rgb')
   data['element']['pixel'] = OrderedDict()
   data['element']['pixel']['red'] = numpy.array([[0, 255], [0, 0]], dtype=numpy.uint8)
   data['element']['pixel']['green'] = numpy.array([[0, 0], [255, 0]], dtype=numpy.uint8)
   data['element']['pixel']['blue'] = numpy.array([[0, 0], [0, 255]], dtype=numpy.uint8)
   return data
Exemple #5
0
 def ds_floats(self):
     data = ply2.create()
     data['element']['values'] = OrderedDict()
     data['element']['values']['x'] = numpy.array([1, 2, 3],
                                                  dtype=numpy.float32)
     data['element']['values']['y'] = numpy.array([1.5, 5.6, numpy.pi],
                                                  dtype=numpy.float32)
     return data
Exemple #6
0
 def ds_image(self):
     data = ply2.create()
     data['type'].append('image.rgb')
     data['element']['pixel'] = OrderedDict()
     data['element']['pixel']['red'] = numpy.array([[0, 255], [0, 0]],
                                                   dtype=numpy.uint8)
     data['element']['pixel']['green'] = numpy.array([[0, 0], [255, 0]],
                                                     dtype=numpy.uint8)
     data['element']['pixel']['blue'] = numpy.array([[0, 0], [0, 255]],
                                                    dtype=numpy.uint8)
     return data
Exemple #7
0
 def ds_arrays(self):
   samples = numpy.zeros(5, dtype=numpy.object)
   samples[0] = numpy.array([3, 1, 4, 2], dtype=numpy.int8)
   samples[1] = numpy.array([42, 42], dtype=numpy.int8) 
   samples[2] = numpy.array([100, 101, 102, -1, -2, 0], dtype=numpy.int8)
   samples[3] = numpy.array([-12], dtype=numpy.int8)
   samples[4] = numpy.array([], dtype=numpy.int8)
   
   data = ply2.create()
   data['element']['samples'] = OrderedDict()
   data['element']['samples']['values'] = samples
   
   return data
Exemple #8
0
    def ds_arrays(self):
        samples = numpy.zeros(5, dtype=numpy.object)
        samples[0] = numpy.array([3, 1, 4, 2], dtype=numpy.int8)
        samples[1] = numpy.array([42, 42], dtype=numpy.int8)
        samples[2] = numpy.array([100, 101, 102, -1, -2, 0], dtype=numpy.int8)
        samples[3] = numpy.array([-12], dtype=numpy.int8)
        samples[4] = numpy.array([], dtype=numpy.int8)

        data = ply2.create()
        data['element']['samples'] = OrderedDict()
        data['element']['samples']['values'] = samples

        return data
Exemple #9
0
 def ds_strings(self):
   names = numpy.zeros(8, dtype=numpy.object)
   names[0] = 'The Alien'
   names[1] = 'Ripley'
   names[2] = 'Ash'
   names[3] = u'Bite Me'
   names[4] = '    '
   names[5] = '  Penguin'
   names[6] = 'Joker  '
   names[7] = 'Two\nFace'
   
   data = ply2.create()
   data['element']['people'] = OrderedDict()
   data['element']['people']['name'] = names
   
   return data
Exemple #10
0
 def ds_graph(self):
   data = ply2.create()
   
   name = numpy.zeros(2, dtype=numpy.object)
   name[0] = 'x'
   name[1] = 'y'
   
   value = numpy.zeros(2, dtype=numpy.object)
   value[0] = numpy.sin(numpy.linspace(0.0, numpy.pi, 32))
   value[1] = numpy.cos(numpy.linspace(0.0, numpy.pi, 32))
   
   data['element']['variable'] = OrderedDict()
   data['element']['variable']['name'] = name
   data['element']['variable']['value'] = value
   
   return data
Exemple #11
0
    def ds_graph(self):
        data = ply2.create()

        name = numpy.zeros(2, dtype=numpy.object)
        name[0] = 'x'
        name[1] = 'y'

        value = numpy.zeros(2, dtype=numpy.object)
        value[0] = numpy.sin(numpy.linspace(0.0, numpy.pi, 32))
        value[1] = numpy.cos(numpy.linspace(0.0, numpy.pi, 32))

        data['element']['variable'] = OrderedDict()
        data['element']['variable']['name'] = name
        data['element']['variable']['value'] = value

        return data
Exemple #12
0
    def ds_strings(self):
        names = numpy.zeros(8, dtype=numpy.object)
        names[0] = 'The Alien'
        names[1] = 'Ripley'
        names[2] = 'Ash'
        names[3] = u'Bite Me'
        names[4] = '    '
        names[5] = '  Penguin'
        names[6] = 'Joker  '
        names[7] = 'Two\nFace'

        data = ply2.create()
        data['element']['people'] = OrderedDict()
        data['element']['people']['name'] = names

        return data
Exemple #13
0
    def ds_colour_map(self):
        data = ply2.create()
        data['type'].append('colour_map.rgb')

        samples = numpy.empty((3, 6), dtype=numpy.float32)
        samples[0, :] = [0, 0, 0, 0, 0, 0]
        samples[1, :] = [1, 1, 1, 1, 1, 1]
        samples[2, :] = [0.5, 0.5, 0.5, 0.25, 0.25, 0.25]

        data['element']['sample'] = OrderedDict()
        data['element']['sample']['in.r'] = samples[:, 0]
        data['element']['sample']['in.g'] = samples[:, 1]
        data['element']['sample']['in.b'] = samples[:, 2]
        data['element']['sample']['out.r'] = samples[:, 3]
        data['element']['sample']['out.g'] = samples[:, 4]
        data['element']['sample']['out.b'] = samples[:, 5]

        return data
Exemple #14
0
 def ds_colour_map(self):
   data = ply2.create()
   data['type'].append('colour_map.rgb')
   
   samples = numpy.empty((3, 6), dtype=numpy.float32)
   samples[0,:] = [0, 0, 0, 0, 0, 0]
   samples[1,:] = [1, 1, 1, 1, 1, 1]
   samples[2,:] = [0.5, 0.5, 0.5, 0.25, 0.25, 0.25]
   
   data['element']['sample'] = OrderedDict()
   data['element']['sample']['in.r'] = samples[:,0]
   data['element']['sample']['in.g'] = samples[:,1]
   data['element']['sample']['in.b'] = samples[:,2]
   data['element']['sample']['out.r'] = samples[:,3]
   data['element']['sample']['out.g'] = samples[:,4]
   data['element']['sample']['out.b'] = samples[:,5]
   
   return data
Exemple #15
0
    def ds_map(self):
        data = ply2.create()
        data['type'].append('map')
        data['meta']['location'] = 'Middle Earth'

        names = numpy.zeros(9, dtype=numpy.object)
        names[0] = 'Hobbiton'
        names[1] = 'Bree'
        names[2] = 'Rivendell'
        names[3] = 'Moria'
        names[4] = u'Lothl\u00f3rien'
        names[5] = 'Edoras'
        names[6] = "Helm's Deep"
        names[7] = 'Isengard'
        names[8] = 'Minas Tirith'

        data['element']['city'] = OrderedDict()
        data['element']['city']['name'] = names
        data['element']['city']['x'] = numpy.array(
            [67.4, 79.0, 99.1, 100.5, 113.0, 105.1, 99.5, 98.5, 135.6],
            dtype=numpy.float32)
        data['element']['city']['y'] = numpy.array(
            [55.5, 54.1, 53.3, 69.5, 74.6, 99.6, 98.7, 94.8, 111.3],
            dtype=numpy.float32)

        names = numpy.zeros(3, dtype=numpy.object)
        names[0] = 'Orthanc'
        names[1] = u'Barad-d\u00fbr'
        names[2] = 'Cirith Ungol'

        data['element']['tower'] = OrderedDict()
        data['element']['tower']['name'] = names
        data['element']['tower']['x'] = numpy.array([98.5, 156.2, 145.2],
                                                    dtype=numpy.float32)
        data['element']['tower']['y'] = numpy.array([94.8, 107.8, 111.0],
                                                    dtype=numpy.float32)

        return data
Exemple #16
0
 def ds_meta(self):
     data = ply2.create()
     data['meta']['author'] = 'Cthulhu'
     data['meta']['tentacles'] = 42
     data['meta']['pi'] = numpy.pi
     return data
Exemple #17
0
 def ds_empty_element(self):
   data = ply2.create()
   data['element']['dummy'] = dict()
   return data
Exemple #18
0
 def ds_ints(self):
   data = ply2.create()
   data['element']['values'] = dict()
   data['element']['values']['x'] = numpy.array([1, 2, 3], dtype=numpy.int32)
   return data
Exemple #19
0
 def ds_floats(self):
   data = ply2.create()
   data['element']['values'] = OrderedDict()
   data['element']['values']['x'] = numpy.array([1, 2, 3], dtype=numpy.float32)
   data['element']['values']['y'] = numpy.array([1.5, 5.6, numpy.pi], dtype=numpy.float32)
   return data
Exemple #20
0
 def ds_ints(self):
     data = ply2.create()
     data['element']['values'] = dict()
     data['element']['values']['x'] = numpy.array([1, 2, 3],
                                                  dtype=numpy.int32)
     return data
Exemple #21
0
 def ds_empty_element(self):
     data = ply2.create()
     data['element']['dummy'] = dict()
     return data
Exemple #22
0
 def ds_default(self):
     return ply2.create()
Exemple #23
0
 def ds_default(self):
   return ply2.create()
Exemple #24
0
 def ds_meta(self):
   data = ply2.create()
   data['meta']['author'] = 'Cthulhu'
   data['meta']['tentacles'] = 42
   data['meta']['pi'] = numpy.pi
   return data
Exemple #25
0
 def test_create(self):
     for binary in [False, True]:
         for compress in [0, 1, 2]:
             data = ply2.create(binary, compress)
             ply2.verify(data)
Exemple #26
0
 def test_create(self):
   for binary in [False, True]:
     for compress in [0, 1, 2]:
       data = ply2.create(binary, compress)
       ply2.verify(data)