コード例 #1
0
 def __repr__(self):
     return self.__class__.__name__ + ' dist: %d, points: %d-%d, l:%s, c: %d, n: %d, bidir: %s, reverse: %s, edgeindices: %s, u1: %d, u2: %d, restrictions:%s, orientations:(%d,%d), excess: %s' % (
         self.cost, self.ivertices[0], self.ivertices[1], self.layernumref,
         self.cellnumref, self.numincellref, str(self.ratt.bidirectional),
         str(self.ratt.reversedir), str(self.edgeindices), self.unk1,
         self.unk2, str(self.restrictions), self.orientations[0],
         self.orientations[1], dump(self.excess))
コード例 #2
0
    def deSerialize(self, cell, data, bigendian):
        prefix = bigendian2prefix[bigendian]

        bbox, data = self._deserialize_bbox(cell, data, bigendian)

        parts = []
        origdata = data

        self.textslot = unpack(prefix + "B", data)[0] << 24
        data = data[1:]
        [self.objtype] = unpack(prefix + "B", data)
        data = data[1:]

        nvertices = unpack(prefix + "H", data)[0]

        data = data[2:]

        [temp] = unpack(prefix + "H", data)
        data = data[2:]
        polytype = temp >> 13
        nsubpolys = temp & 0x1fff

        subpolytype = [polytype]
        subnvertices = []
        lastoffset = 0
        pointsum = 0
        for sub in range(1, nsubpolys):
            [temp] = unpack(prefix + "H", data)
            data = data[2:]

            subpolytype.append(temp >> 13)

            offset = temp & 0x1fff
            subnvertices.append(offset - lastoffset - 1)
            pointsum = pointsum + offset - lastoffset - 1
            lastoffset = offset

        subnvertices.append(nvertices - pointsum)

        for nsub in range(nsubpolys):
            vlist = []
            ndelta = 0
            end = None
            if subpolytype[nsub] in [0, 2]:
                if subpolytype[nsub] == 0:
                    position = bbox.c1 + \
                               N.array(unpack(prefix+"2I",data))
                    data = data[8:]
                else:
                    position = bbox.c1 + \
                               N.array(unpack(prefix+"2H",data))
                    data = data[4:]

                ndelta = subnvertices[nsub] - 1

            elif subpolytype[nsub] in [3, 4, 5, 6, 7]:
                if subpolytype[nsub] == 6:
                    position = bbox.c1
                    ndelta = subnvertices[nsub] - 1
                elif subpolytype[nsub] == 5:
                    position = bbox.c2
                    end = bbox.c1
                    ndelta = subnvertices[nsub] - 2
                elif subpolytype[nsub] == 7:
                    position = N.array([bbox.c2[0], bbox.c1[1]])
                    end = N.array([bbox.c1[0], bbox.c2[1]])
                    ndelta = subnvertices[nsub] - 2
                elif subpolytype[nsub] == 3:
                    position = bbox.c2
                    ndelta = subnvertices[nsub] - 1
                elif subpolytype[nsub] == 4:
                    position = bbox.c1 + \
                          N.array(unpack(prefix+"2B",data))
                    data = data[2:]
                    ndelta = subnvertices[nsub] - 1
            else:
                print dump(origdata)
                raise ValueError, "Unhandled subpoly type %d" % subpolytype[
                    nsub]

            ## Add the difference encoded points
            delta = N.array(unpack(prefix + "%db" % (2 * ndelta), data))
            data = data[2 * ndelta:]

            delta = delta.reshape((ndelta, 2))

            vlist = N.concatenate([[position], delta]).cumsum(0)

            if end != None:
                vlist = N.concatenate([vlist, [end]])

            parts.append(vlist)

        [self.cornerdatapresent] = unpack(prefix + "b", data)
        data = data[1:]

        if self.cornerdatapresent != -1:
            data = data[nvertices:]

        # Skip alignment
        if (len(data) % 2) == 1:
            data = data[1:]

        if len(data) == 2:
            self.textslot = self.textslot | unpack(prefix + "H", data)[0]

        parts = [[(v[0], -v[1]) for v in cell.relToAbsCoords(part)]
                 for part in parts]
        self._coords = tuple(parts)
コード例 #3
0
 def excessdump(self):
     return dump(self.excess)
コード例 #4
0
 def __repr__(self):
     return self.__class__.__name__ + ' dist: %d, points: %d-%d, l:%s, c: %d, n: %d, bidir: %s, reverse: %s, edgeindices: %s, u1: %d, u2: %d, restrictions:%s, orientations:(%d,%d), excess: %s'%(
         self.cost, self.ivertices[0], self.ivertices[1], self.layernumref, self.cellnumref, self.numincellref, str(self.ratt.bidirectional), 
         str(self.ratt.reversedir), str(self.edgeindices), self.unk1, self.unk2, str(self.restrictions), self.orientations[0],
         self.orientations[1], dump(self.excess))
コード例 #5
0
 def excessdump(self):
     return dump(self.excess)
コード例 #6
0
    def deSerialize(self, cell, data, bigendian):
        prefix = bigendian2prefix[bigendian]
        
        bbox, data = self._deserialize_bbox(cell, data, bigendian)

        parts = []
        origdata = data
        
        self.textslot = unpack(prefix+"B", data)[0] << 24
        data = data[1:]
        [self.objtype] = unpack(prefix+"B", data)
        data = data[1:]

        nvertices = unpack(prefix+"H", data)[0]

        data = data[2:]

        [temp] = unpack(prefix+"H", data)
        data = data[2:]
        polytype = temp >> 13
        nsubpolys = temp & 0x1fff

        subpolytype = [polytype]
        subnvertices = []
        lastoffset = 0
        pointsum=0
        for sub in range(1,nsubpolys):
            [temp] = unpack(prefix+"H",data)
            data = data[2:]

            subpolytype.append(temp>>13)

            offset = temp & 0x1fff
            subnvertices.append(offset-lastoffset-1)
            pointsum = pointsum + offset - lastoffset - 1
            lastoffset = offset

        subnvertices.append(nvertices - pointsum)

        for nsub in range(nsubpolys):
            vlist = []
            ndelta = 0
            end = None
            if subpolytype[nsub] in [0,2]:
                if subpolytype[nsub] == 0:
                    position = bbox.c1 + \
                               N.array(unpack(prefix+"2I",data))
                    data = data[8:]
                else: 
                    position = bbox.c1 + \
                               N.array(unpack(prefix+"2H",data))
                    data = data[4:]

                ndelta = subnvertices[nsub] - 1

            elif subpolytype[nsub] in [3,4,5,6,7]:
                if subpolytype[nsub] == 6:
                    position = bbox.c1
                    ndelta = subnvertices[nsub]-1
                elif subpolytype[nsub] == 5:
                    position = bbox.c2
                    end = bbox.c1
                    ndelta = subnvertices[nsub]-2
                elif subpolytype[nsub] == 7:
                    position = N.array([bbox.c2[0], bbox.c1[1]])
                    end = N.array([bbox.c1[0], bbox.c2[1]])
                    ndelta = subnvertices[nsub]-2
                elif subpolytype[nsub] == 3:
                    position = bbox.c2
                    ndelta = subnvertices[nsub]-1
                elif subpolytype[nsub] == 4:
                    position = bbox.c1 + \
                          N.array(unpack(prefix+"2B",data))
                    data = data[2:]
                    ndelta = subnvertices[nsub]-1
            else:
                print dump(origdata)
                raise ValueError, "Unhandled subpoly type %d"%subpolytype[nsub]

            ## Add the difference encoded points
            delta = N.array(unpack(prefix + "%db"%(2*ndelta), data))
            data = data[2*ndelta:]

            delta = delta.reshape((ndelta, 2))

            vlist = N.concatenate([[position], delta]).cumsum(0)

            if end != None:
                vlist = N.concatenate([vlist, [end]])
                    
            parts.append( vlist )

        [self.cornerdatapresent] = unpack(prefix+"b",data)
        data = data[1:]

        if self.cornerdatapresent != -1:
            data = data[nvertices:]

        # Skip alignment
        if (len(data)%2) == 1:
            data = data[1:]

        if len(data) == 2:
            self.textslot = self.textslot | unpack(prefix+"H",data)[0]

        parts = [[(v[0],-v[1]) for v in cell.relToAbsCoords(part)] for part in parts]
        self._coords =tuple(parts)