| 21 | { |
| 22 | template<class VertexSource> |
| 23 | double path_length(VertexSource& vs, unsigned path_id = 0) |
| 24 | { |
| 25 | double len = 0.0; |
| 26 | double start_x = 0.0; |
| 27 | double start_y = 0.0; |
| 28 | double x1 = 0.0; |
| 29 | double y1 = 0.0; |
| 30 | double x2 = 0.0; |
| 31 | double y2 = 0.0; |
| 32 | bool first = true; |
| 33 | |
| 34 | unsigned cmd; |
| 35 | vs.rewind(path_id); |
| 36 | while(!is_stop(cmd = vs.vertex(&x2, &y2))) |
| 37 | { |
| 38 | if(is_vertex(cmd)) |
| 39 | { |
| 40 | if(first || is_move_to(cmd)) |
| 41 | { |
| 42 | start_x = x2; |
| 43 | start_y = y2; |
| 44 | } |
| 45 | else |
| 46 | { |
| 47 | len += calc_distance(x1, y1, x2, y2); |
| 48 | } |
| 49 | x1 = x2; |
| 50 | y1 = y2; |
| 51 | first = false; |
| 52 | } |
| 53 | else |
| 54 | { |
| 55 | if(is_close(cmd) && !first) |
| 56 | { |
| 57 | len += calc_distance(x1, y1, start_x, start_y); |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | return len; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | #endif |
nothing calls this directly
no test coverage detected