@@ -101,6 +101,7 @@ jm_checkrect()
101
101
dev_linecount = 0 ; // reset line count
102
102
long orientation = 0 ;
103
103
fz_point ll, lr, ur, ul;
104
+ fz_rect r;
104
105
PyObject *rect;
105
106
PyObject *line0, *line2;
106
107
PyObject *items = PyDict_GetItem (dev_pathdict, dictkey_items);
@@ -109,50 +110,35 @@ jm_checkrect()
109
110
line0 = PyList_GET_ITEM (items, len - 3 );
110
111
ll = JM_point_from_py (PyTuple_GET_ITEM (line0, 1 ));
111
112
lr = JM_point_from_py (PyTuple_GET_ITEM (line0, 2 ));
112
-
113
+ // no need to extract "line1"!
113
114
line2 = PyList_GET_ITEM (items, len - 1 );
114
115
ur = JM_point_from_py (PyTuple_GET_ITEM (line2, 1 ));
115
116
ul = JM_point_from_py (PyTuple_GET_ITEM (line2, 2 ));
116
117
117
118
/*
118
119
---------------------------------------------------------------------
119
- Three connected lines: at least a quad! Check whether even a rect.
120
- For this, the lines must be parallel to the axes.
121
120
Assumption:
122
121
For decomposing rects, MuPDF always starts with a horizontal line,
123
122
followed by a vertical line, followed by a horizontal line.
124
123
We will also check orientation of the enclosed area and add this info
125
124
as '+1' for anti-clockwise, '-1' for clockwise orientation.
126
125
---------------------------------------------------------------------
127
126
*/
128
- if (ll.y != lr.y ) { // not horizontal
129
- goto drop_out;
130
- }
131
- if (lr.x != ur.x ) { // not vertical
132
- goto drop_out;
133
- }
134
- if (ur.y != ul.y ) { // not horizontal
135
- goto drop_out;
127
+ if (ll.y != lr.y ||
128
+ ll.x != ul.x ||
129
+ ur.y != ul.y ||
130
+ ur.x != lr.x ) {
131
+ goto drop_out; // not a rectangle
136
132
}
137
- // we have a rect, determine orientation
138
- if (ll.x < lr.x ) { // move left to right
139
- if (lr.y > ur.y ) { // move upwards
140
- orientation = 1 ;
141
- } else {
142
- orientation = -1 ;
143
- }
144
- } else { // move right to left
145
- if (lr.y < ur.y ) { // move downwards
146
- orientation = 1 ;
147
- } else {
148
- orientation = -1 ;
149
- }
133
+
134
+ // we have a rect, replace last 3 "l" items by one "re" item.
135
+ if (ul.y < lr.y ) {
136
+ r = fz_make_rect (ul.x , ul.y , lr.x , lr.y );
137
+ orientation = 1 ;
138
+ } else {
139
+ r = fz_make_rect (ll.x , ll.y , ur.x , ur.y );
140
+ orientation = -1 ;
150
141
}
151
- // Replace last 3 "l" items by one "re" item.
152
- fz_rect r = fz_make_rect (ul.x , ul.y , ul.x , ul.y );
153
- r = fz_include_point_in_rect (r, ur);
154
- r = fz_include_point_in_rect (r, ll);
155
- r = fz_include_point_in_rect (r, lr);
156
142
rect = PyTuple_New (3 );
157
143
PyTuple_SET_ITEM (rect, 0 , PyUnicode_FromString (" re" ));
158
144
PyTuple_SET_ITEM (rect, 1 , JM_py_from_rect (r));
0 commit comments