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