# Path: importerUtils.py
# def getFloat64(data, offset):
# 	'''
# 	Returns a double precision float value.
# 	Args:
# 		data
# 			A binary string.
# 		offset
# 			The zero based offset of the array.
# 	Returns:
# 		The double precision float value at offset.
# 		The new position in the 'stream'.
# 	'''
# 	val, = FLOAT64(data, offset)
# 	return val, offset + 8
# 
# def getUInt32(data, offset):
# 	'''
# 	Returns a single unsingned 32-Bit value.
# 	Args:
# 		data
# 			A binary string.
# 		offset
# 			The zero based offset of the unsigned 32-Bit value.
# 	Returns:
# 		The unsigned 32-Bit value at offset.
# 		The new position in the 'stream'.
# 	'''
# 	val, = UINT32(data, offset)
# 	return val, offset + 4
# 
# def getUInt16(data, offset):
# 	'''
# 	Returns a single unsingned 16-Bit value.
# 	Args:
# 		data
# 			A binary string.
# 		offset
# 			The zero based offset of the unsigned 16-Bit value.
# 	Returns:
# 		The unsigned 16-Bit value at offset.
# 		The new position in the 'stream'.
# 	'''
# 	val, = UINT16(data, offset)
# 	return val, offset + 2
# 
# def FloatArr2Str(arr):
# 	return (', '.join(['%g' %(f) for f in arr]))
# 
# def logError(msg, *args):
# 	if (__prmPrefOW__.GetBool("checkError", True)):    _log("logError",   Console.PrintError,   msg, args)


from importerUtils import getFloat64, getUInt32, getUInt16, FloatArr2Str, logError
from FreeCAD         import Rotation as ROT, Vector as VEC, Matrix as MAT
import math

	def __m2s__(self, index):
		v = self.m[index]
		return u"[%g, %g, %g]" %(v[0], v[1], v[2] * 10.0)

	def __str__(self): # return unicode
		m = self.__repr__()
		mask = '|'
		d1 = (self.a0 & 0x00FF0000) >> 16
		d2 = (self.a0 & 0x000001FF)
		for j in range(9):
			b = (1 << j)
			if (d1 & b):
				mask += '-' if (d2 & b) else '0'
			else:
				mask += '+' if (d2 & b) else 'x'
			if (((j+1) % 3) == 0): mask += '|'
		return u' transformation={a0=%s m=%s}' %(mask, m)

	def __repr__(self):
		m0 = self.__m2s__(0)
		m1 = self.__m2s__(1)
		m2 = self.__m2s__(2)
		return u"[%s, %s, %s]" %(m0, m1, m2)

class Transformation3D(object):
	def __init__(self):
		self.a0 = 0x00000000
		self.m = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]

	def read(self, data, offset):

# Path: importerUtils.py
# def getFloat64(data, offset):
# 	'''
# 	Returns a double precision float value.
# 	Args:
# 		data
# 			A binary string.
# 		offset
# 			The zero based offset of the array.
# 	Returns:
# 		The double precision float value at offset.
# 		The new position in the 'stream'.
# 	'''
# 	val, = FLOAT64(data, offset)
# 	return val, offset + 8
# 
# def getUInt32(data, offset):
# 	'''
# 	Returns a single unsingned 32-Bit value.
# 	Args:
# 		data
# 			A binary string.
# 		offset
# 			The zero based offset of the unsigned 32-Bit value.
# 	Returns:
# 		The unsigned 32-Bit value at offset.
# 		The new position in the 'stream'.
# 	'''
# 	val, = UINT32(data, offset)
# 	return val, offset + 4
# 
# def getUInt16(data, offset):
# 	'''
# 	Returns a single unsingned 16-Bit value.
# 	Args:
# 		data
# 			A binary string.
# 		offset
# 			The zero based offset of the unsigned 16-Bit value.
# 	Returns:
# 		The unsigned 16-Bit value at offset.
# 		The new position in the 'stream'.
# 	'''
# 	val, = UINT16(data, offset)
# 	return val, offset + 2
# 
# def FloatArr2Str(arr):
# 	return (', '.join(['%g' %(f) for f in arr]))
# 
# def logError(msg, *args):
# 	if (__prmPrefOW__.GetBool("checkError", True)):    _log("logError",   Console.PrintError,   msg, args)


# Path: importerTransformation.py
from importerUtils import getFloat64, getUInt32, getUInt16, FloatArr2Str, logError
from FreeCAD         import Rotation as ROT, Vector as VEC, Matrix as MAT
import math

	def __m2s__(self, index):
		v = self.m[index]
		return u"[%g, %g, %g]" %(v[0], v[1], v[2] * 10.0)

	def __str__(self): # return unicode
		m = self.__repr__()
		mask = '|'
		d1 = (self.a0 & 0x00FF0000) >> 16
		d2 = (self.a0 & 0x000001FF)
		for j in range(9):
			b = (1 << j)
			if (d1 & b):
				mask += '-' if (d2 & b) else '0'
			else:
				mask += '+' if (d2 & b) else 'x'
			if (((j+1) % 3) == 0): mask += '|'
		return u' transformation={a0=%s m=%s}' %(mask, m)

	def __repr__(self):
		m0 = self.__m2s__(0)
		m1 = self.__m2s__(1)
		m2 = self.__m2s__(2)
		return u"[%s, %s, %s]" %(m0, m1, m2)

class Transformation3D(object):
	def __init__(self):
		self.a0 = 0x00000000
		self.m = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]

	def read(self, data, offset):

		n, k = getUInt32(data, offset)
