Spaces:
Sleeping
Sleeping
Update dxf__omar3_2.py
Browse files- dxf__omar3_2.py +8 -6
dxf__omar3_2.py
CHANGED
|
@@ -360,7 +360,7 @@ def get_hatched_areas(filename,FinalRatio):
|
|
| 360 |
|
| 361 |
from math import sin, cos, radians
|
| 362 |
|
| 363 |
-
def rotate_point(point, angle,pdfrotation,
|
| 364 |
"""Rotates a point around center_point(origin by default)
|
| 365 |
Angle is in degrees.
|
| 366 |
Rotation is counter-clockwise
|
|
@@ -373,15 +373,15 @@ def rotate_point(point, angle,pdfrotation,pdfsize, center_point=(0, 0)):
|
|
| 373 |
# Reverse the shifting we have done
|
| 374 |
if pdfrotation!=0:
|
| 375 |
|
| 376 |
-
new_point = (new_point[0]+
|
| 377 |
else:
|
| 378 |
|
| 379 |
-
new_point = (new_point[0] + center_point[0], new_point[1]+
|
| 380 |
# new_point = (new_point[0] + center_point[0], new_point[1] + center_point[1])
|
| 381 |
return new_point
|
| 382 |
|
| 383 |
|
| 384 |
-
def rotate_polygon(polygon, angle, pdfrotation,
|
| 385 |
"""Rotates the given polygon which consists of corners represented as (x,y)
|
| 386 |
around center_point (origin by default)
|
| 387 |
Rotation is counter-clockwise
|
|
@@ -468,6 +468,9 @@ def mainFunctionDrawImgPdf(datadoc,dxfpath, dxfratio,pdfpath,pdfname):
|
|
| 468 |
rotationOld=page2.rotation
|
| 469 |
derotationMatrix=page2.derotation_matrix
|
| 470 |
pix=page2.get_pixmap()
|
|
|
|
|
|
|
|
|
|
| 471 |
if page2.rotation!=0:
|
| 472 |
|
| 473 |
rotationangle = page2.rotation
|
|
@@ -506,8 +509,7 @@ def mainFunctionDrawImgPdf(datadoc,dxfpath, dxfratio,pdfpath,pdfname):
|
|
| 506 |
shapee.append([p1[0],p1[1]])
|
| 507 |
|
| 508 |
shapee=np.flip(shapee,1)
|
| 509 |
-
shapee=rotate_polygon(shapee,rotationangle,rotationOld,
|
| 510 |
-
|
| 511 |
tol=2
|
| 512 |
condition1 = (SimilarAreaDictionary['Area'] >= polygon[1] - tol) & (SimilarAreaDictionary['Area'] <= polygon[1] +tol)
|
| 513 |
condition2 = (SimilarAreaDictionary['Perimeter'] >= polygon[2] -tol) & (SimilarAreaDictionary['Perimeter'] <= polygon[2] +tol)
|
|
|
|
| 360 |
|
| 361 |
from math import sin, cos, radians
|
| 362 |
|
| 363 |
+
def rotate_point(point, angle,pdfrotation,,width,height, center_point=(0, 0)):
|
| 364 |
"""Rotates a point around center_point(origin by default)
|
| 365 |
Angle is in degrees.
|
| 366 |
Rotation is counter-clockwise
|
|
|
|
| 373 |
# Reverse the shifting we have done
|
| 374 |
if pdfrotation!=0:
|
| 375 |
|
| 376 |
+
new_point = (new_point[0]+,width + center_point[0], new_point[1] + center_point[1]) #pdfsize[2] is the same as +width
|
| 377 |
else:
|
| 378 |
|
| 379 |
+
new_point = (new_point[0] + center_point[0], new_point[1]+ height + center_point[1]) # pdfsize[3] is the same as +height
|
| 380 |
# new_point = (new_point[0] + center_point[0], new_point[1] + center_point[1])
|
| 381 |
return new_point
|
| 382 |
|
| 383 |
|
| 384 |
+
def rotate_polygon(polygon, angle, pdfrotation,,width,height,center_point=(0, 0)):
|
| 385 |
"""Rotates the given polygon which consists of corners represented as (x,y)
|
| 386 |
around center_point (origin by default)
|
| 387 |
Rotation is counter-clockwise
|
|
|
|
| 468 |
rotationOld=page2.rotation
|
| 469 |
derotationMatrix=page2.derotation_matrix
|
| 470 |
pix=page2.get_pixmap()
|
| 471 |
+
width=abs(page2.mediabox[2])+abs(page2.mediabox[0])
|
| 472 |
+
height=abs(page2.mediabox[3])+abs(page2.mediabox[1])
|
| 473 |
+
print('mediabox', width , height)
|
| 474 |
if page2.rotation!=0:
|
| 475 |
|
| 476 |
rotationangle = page2.rotation
|
|
|
|
| 509 |
shapee.append([p1[0],p1[1]])
|
| 510 |
|
| 511 |
shapee=np.flip(shapee,1)
|
| 512 |
+
shapee=rotate_polygon(shapee,rotationangle,rotationOld,width,height)
|
|
|
|
| 513 |
tol=2
|
| 514 |
condition1 = (SimilarAreaDictionary['Area'] >= polygon[1] - tol) & (SimilarAreaDictionary['Area'] <= polygon[1] +tol)
|
| 515 |
condition2 = (SimilarAreaDictionary['Perimeter'] >= polygon[2] -tol) & (SimilarAreaDictionary['Perimeter'] <= polygon[2] +tol)
|