def decode(self, int_val): bit_array = QtCore.QBitArray(64) i = 0 for exp in self.DENT_KEY: if exp <= int_val: bit_array.setBit(i) int_val -= exp i += 1 return bit_array
def known_teeth_key(self): ''' returns a 64bit integer key of which teeth are present ''' bit_array = QtCore.QBitArray(64) i = 0 for row in SETTINGS.TOOTH_GRID: for tooth_id in row: tooth = self.teeth.get(tooth_id) if tooth and tooth.is_present: bit_array.setBit(i) i += 1 return SETTINGS.tooth_decoder.encode(bit_array)
return ascii if __name__ == "__main__": def chart(bit_array): ret_str = "chart =" for i in range(bit_array.count()): if bit_array.at(i): ret_str += "X" else: ret_str += "-" tp = TeethPresentDecoder() full_bit_array = QtCore.QBitArray(64) adult_bit_array = QtCore.QBitArray(64) for i in xrange(16, 48): adult_bit_array.setBit(i) full_bit_array.setBit(i) child_bit_array = QtCore.QBitArray(64) for start in (3, 51): for i in xrange(10): child_bit_array.setBit(i + start) full_bit_array.setBit(i + start) for bit_array in (full_bit_array, child_bit_array, adult_bit_array): key = tp.encode(bit_array) print key