catch non-orthogonal transformation matrix

bugfix for f045df1ef3
This commit is contained in:
Sebastian Hoogen 2015-01-19 22:45:04 +01:00
parent 85214a4359
commit 2509e59b51

View File

@ -230,17 +230,20 @@ def getcolor(color):
#for k,v in svgcolors.iteritems(): #for k,v in svgcolors.iteritems():
# if (k.lower() == color.lower()): pass # if (k.lower() == color.lower()): pass
def transformCopyShape(shape,matrix): def transformCopyShape(shape,m):
m=matrix """apply transformation matrix m on given shape
#factor=matrix.submatrix(2).isOrthogonal() since OCCT 6.8.0 transformShape can be used to apply certian non-orthogonal
#if factor != 0.0: transformations on shapes. This way a conversion to BSplines in
if m.A11*m.A11+m.A12*m.A12 == m.A21*m.A21+m.A22*m.A22 and \ transformGeometry can be avoided."""
m.A11*m.A21+m.A12*m.A22 == 0: if abs(m.A11**2+m.A12**2 -m.A21**2-m.A22**2) < 1e-8 and \
abs(m.A11*m.A21+m.A12*m.A22) < 1e-8: #no shear
try:
newshape=shape.copy() newshape=shape.copy()
newshape.transformShape(matrix) newshape.transformShape(m)
return newshape return newshape
else: except Part.OCCError: # older versions of OCCT will refuse to work on
return shape.transformGeometry(matrix) pass # non-orthogonal matrices
return shape.transformGeometry(m)
def getsize(length,mode='discard',base=1): def getsize(length,mode='discard',base=1):
"""parses length values containing number and unit """parses length values containing number and unit