df3.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:bpy_lambda 作者: bcongdon 项目源码 文件源码
def importDF3(self, file, scale=1):
        try:
            f = open(file, 'rb');
            size = os.stat(file)[stat.ST_SIZE]

        except:
            print("Could not open " + file + " for read");
            return []

        (x, y, z) = struct.unpack(self.__struct2byte3__, f.read(6) )

        self.voxel = self.__create__(x, y, z)
        self.maxX = x
        self.maxY = y
        self.maxZ = z

        size = size-6
        if (size == x*y*z):     format = 8
        elif (size == 2*x*y*z): format = 16
        elif (size == 4*x*y*z): format = 32

        if (format == 32):
            for i in range(x*y*z):
                self.voxel[i] = float(struct.unpack(self.__struct4byte__, f.read(4) )[0])
        elif (format == 16):
            for i in range(x*y*z):
                self.voxel[i] = float(struct.unpack(self.__struct2byte__, f.read(2) )[0])
        elif (format == 8):
            for i in range(x*y*z):
                self.voxel[i] = float(struct.unpack(self.__struct1byte__, f.read(1) )[0])

        return self

    #### Local classes not intended for user use
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号