def readDefaultPose(file, poseLenghtUnround, poseBones): # print('Import Pose') poseBytes = b'' if poseLenghtUnround: for i in range(0, poseBones): poseBytes += file.readline() poseLenght = bin_ops.roundToMultiple( poseLenghtUnround, xps_const.ROUND_MULTIPLE) emptyBytes = poseLenght - poseLenghtUnround file.read(emptyBytes) poseString = bin_ops.decodeBytes(poseBytes) bonesPose = read_ascii_xps.poseData(poseString) return bonesPose
def readDefaultPose(file, poseLenghtUnround, poseBones): # print('Import Pose') poseBytes = b'' if poseLenghtUnround: for i in range(0, poseBones): poseBytes += file.readline() poseLenght = bin_ops.roundToMultiple(poseLenghtUnround, xps_const.ROUND_MULTIPLE) emptyBytes = poseLenght - poseLenghtUnround file.read(emptyBytes) poseString = bin_ops.decodeBytes(poseBytes) bonesPose = read_ascii_xps.poseData(poseString) return bonesPose
def fillPoseString(poseBytes): poseLenghtUnround = len(poseBytes) poseLenght = bin_ops.roundToMultiple( poseLenghtUnround, xps_const.ROUND_MULTIPLE) emptyFill = b'0' * (poseLenght - poseLenghtUnround) return poseBytes + emptyFill
def readHeader(file): header = xps_types.XpsHeader() # MagicNumber magic_number = bin_ops.readUInt32(file) # XPS Version version_mayor = bin_ops.readUInt16(file) version_minor = bin_ops.readUInt16(file) # XNAaral Name xna_aral = readFilesString(file) # Settings Length settingsLen = bin_ops.readUInt32(file) # MachineName machineName = readFilesString(file) # UserName userName = readFilesString(file) # File-->File filesString = readFilesString(file) xpsPoseData = None # print('*'*80) if (version_mayor <= 1 and version_minor <= 12): # print('OLD Format') settingsStream = io.BytesIO(file.read(settingsLen * 4)) else: # print('NEW Format') valuesRead = 0 hash = bin_ops.readUInt32(file) valuesRead += 1 * 4 items = bin_ops.readUInt32(file) valuesRead += 1 * 4 # print('hash', hash) # print('items', items) for i in range(items): # print('valuesRead', valuesRead) optType = bin_ops.readUInt32(file) valuesRead += 1 * 4 optcount = bin_ops.readUInt32(file) valuesRead += 1 * 4 optInfo = bin_ops.readUInt32(file) valuesRead += 1 * 4 # print('------') # print('count',i) # print('optType',optType) # print('optcount',optcount) # print('optInfo',optInfo) if (optType == 255): # print('Read None') readNone(file, optcount) valuesRead += optcount * 2 elif (optType == 2): # print('Read Flags') readFlags(file, optcount) valuesRead += optcount * 2 * 4 elif (optType == 1): # print('Read Pose') xpsPoseData = readDefaultPose(file, optcount, optInfo) readCount = bin_ops.roundToMultiple( optcount, xps_const.ROUND_MULTIPLE) valuesRead += readCount else: # print('Read Waste') loopStart = valuesRead // 4 loopFinish = settingsLen # print (loopStart, loopFinish) for j in range(loopStart, loopFinish): # print('waste',j - loopStart) waste = bin_ops.readUInt32(file) header.magic_number = magic_number header.version_mayor = version_mayor header.version_minor = version_minor header.xna_aral = xna_aral header.settingsLen = settingsLen header.machine = machineName header.user = userName header.files = filesString header.pose = xpsPoseData return header
def readHeader(file): header = xps_types.XpsHeader() # MagicNumber magic_number = bin_ops.readUInt32(file) # XPS Version version_mayor = bin_ops.readUInt16(file) version_minor = bin_ops.readUInt16(file) # XNAaral Name xna_aral = readFilesString(file) # Settings Length settingsLen = bin_ops.readUInt32(file) # MachineName machineName = readFilesString(file) # UserName userName = readFilesString(file) # File-->File filesString = readFilesString(file) xpsPoseData = None # print('*'*80) if (version_mayor <= 1 and version_minor <= 12): # print('OLD Format') settingsStream = io.BytesIO(file.read(settingsLen * 4)) else: # print('NEW Format') valuesRead = 0 hash = bin_ops.readUInt32(file) valuesRead += 1 * 4 items = bin_ops.readUInt32(file) valuesRead += 1 * 4 # print('hash', hash) # print('items', items) for i in range(items): # print('valuesRead', valuesRead) optType = bin_ops.readUInt32(file) valuesRead += 1 * 4 optcount = bin_ops.readUInt32(file) valuesRead += 1 * 4 optInfo = bin_ops.readUInt32(file) valuesRead += 1 * 4 # print('------') # print('count',i) # print('optType',optType) # print('optcount',optcount) # print('optInfo',optInfo) if (optType == 255): # print('Read None') readNone(file, optcount) valuesRead += optcount * 2 elif (optType == 2): # print('Read Flags') readFlags(file, optcount) valuesRead += optcount * 2 * 4 elif (optType == 1): # print('Read Pose') xpsPoseData = readDefaultPose(file, optcount, optInfo) readCount = bin_ops.roundToMultiple(optcount, xps_const.ROUND_MULTIPLE) valuesRead += readCount else: # print('Read Waste') loopStart = valuesRead // 4 loopFinish = settingsLen # print (loopStart, loopFinish) for j in range(loopStart, loopFinish): # print('waste',j - loopStart) waste = bin_ops.readUInt32(file) header.magic_number = magic_number header.version_mayor = version_mayor header.version_minor = version_minor header.xna_aral = xna_aral header.settingsLen = settingsLen header.machine = machineName header.user = userName header.files = filesString header.pose = xpsPoseData return header
def fillPoseString(poseBytes): poseLenghtUnround = len(poseBytes) poseLenght = bin_ops.roundToMultiple(poseLenghtUnround, xps_const.ROUND_MULTIPLE) emptyFill = b'0' * (poseLenght - poseLenghtUnround) return poseBytes + emptyFill