Wednesday, April 4, 2012

Trim tool fixes


The trim tool allows us to cut a part of a curve using another curve to define the start/end points. Using it, we can obtain complex shapes easily:


When doing a trim, we need to select the guide line, click on the Trim tool and then click on the part of the line that we want to be cut out (the two shapes must have at least one intersecting point). The trimming tool didn't work because the mouse click was sent as a Point3D instead of Reference and it was always (0,0,0). After changing that and enabling the code that actually retrieves the intersection points, trimming a line using another line as a guide worked, but more 'complicated' shapes didn't. The problem is that wrapper that returns the intersection points returns extra points, as well.

For a circle and line, for example, we get the two intersection points, as well as the points that are produced by the perpendicular to the drawn line:


To eliminate the extra points, I've added a check using ExtremaExtPC which checks if the points are on the line and only returns the two points we need.

After this change the circle trim works ok (and the unit tests pass) but there are some issues with trimming arcs and splines that I'm working on.
Another issue is when trying to apply a trim on a trim result, e.g. we trim a circle using a line and then we want to trim the resulting shape again, using another line.

The changes are here

No comments: