| 125 | //-------------------------------------------------------------------- |
| 126 | template <class VS> |
| 127 | void add(VS& src, gpc_polygon& p) |
| 128 | { |
| 129 | unsigned cmd; |
| 130 | double x, y; |
| 131 | double start_x = 0.0; |
| 132 | double start_y = 0.0; |
| 133 | bool line_to = false; |
| 134 | unsigned orientation = 0; |
| 135 | |
| 136 | m_contour_accumulator.remove_all(); |
| 137 | |
| 138 | while (!is_stop(cmd = src.vertex(&x, &y))) |
| 139 | { |
| 140 | if (is_vertex(cmd)) |
| 141 | { |
| 142 | if (is_move_to(cmd)) |
| 143 | { |
| 144 | if (line_to) |
| 145 | { |
| 146 | end_contour(orientation); |
| 147 | orientation = 0; |
| 148 | } |
| 149 | start_contour(); |
| 150 | start_x = x; |
| 151 | start_y = y; |
| 152 | } |
| 153 | add_vertex(x, y); |
| 154 | line_to = true; |
| 155 | } |
| 156 | else |
| 157 | { |
| 158 | if (is_end_poly(cmd)) |
| 159 | { |
| 160 | orientation = get_orientation(cmd); |
| 161 | if (line_to && is_closed(cmd)) |
| 162 | { |
| 163 | add_vertex(start_x, start_y); |
| 164 | } |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | if (line_to) |
| 169 | { |
| 170 | end_contour(orientation); |
| 171 | } |
| 172 | make_polygon(p); |
| 173 | } |
| 174 | |
| 175 | private: |
| 176 | //-------------------------------------------------------------------- |
no test coverage detected