Hi David,
On Fri, Dec 20, 2013 at 02:55:00PM -0800, mathog wrote:
In the patch for bug 1263242 here
https://bugs.launchpad.net/inkscape/+bug/1263242
I can't work out how to get to your patch from this link.
these 3 functions were added to emf-print.cpp.
Geom::Path pathv_to_simple_polygon(Geom::PathVector const &pathv,
int *vertices); Geom::Path pathv_to_rect(Geom::PathVector const &pathv, bool *is_rect, double *angle); Geom::Point get_pathrect_corner(Geom::Path pathRect, double angle, int corner);
The first function returns a path in which any points on a polygonal path (stored in a PathVector) that are not at a vertex have been eliminated. It also eliminates one point where two fall within epsilon of each other. (Duplicate points, not sure what the technical term for them is.) If the pathvector holds more than one path or has any curves that are not linear then it returns an empty path.
This name is not quite ideal, a simple polygon is one which also has no self intersections, something you don't guarantee. Perhaps describe what it does: remove_superfluous_vertices ?
The second analyzes a PathVector to see if it is a rectangle. It does this by first calling the preceding function, then checking that the path has 4 sides and that each side is 90 degrees from its two neighbors. If that is the case is_rect comes back true. The angle returned is that of the minimal rotation that will align the sides of the rectangle with the X and Y axes.
Sounds good, definitely could go in 2geom.
The third returns the coordinates of the Upper Left, Upper Right, Lower Right, and Lower Left corners of the rectangle, as determined by the value of "corner", given the rotation angle and path returned by the preceding function.
You might construct this using the Rect::corner function combined with multiplication by a rotation.
njh