Commits

Anonymous committed fd592cc

round sooner rather than later to improve join

Comments (0)

Files changed (7)

VectorBoolean/FBBezierContour.h

 - (void) addReverseCurve:(FBBezierCurve *)curve;
 - (void) addReverseCurveFrom:(FBEdgeCrossing *)startCrossing to:(FBEdgeCrossing *)endCrossing;
 
+- (void) round;
+
 @property (readonly) NSArray *edges;
 @property (readonly) NSRect bounds;
 @property (readonly) NSPoint testPoint;

VectorBoolean/FBBezierContour.m

     return edge.curve.endPoint1;
 }
 
+- (void) round
+{
+    for (FBContourEdge *edge in _edges)
+        [edge round];
+}
+
 - (id)copyWithZone:(NSZone *)zone
 {
     FBBezierContour *copy = [[FBBezierContour allocWithZone:zone] init];

VectorBoolean/FBBezierCurve.h

 - (NSPoint) pointAtParameter:(CGFloat)parameter leftBezierCurve:(FBBezierCurve **)leftBezierCurve rightBezierCurve:(FBBezierCurve **)rightBezierCurve;
 - (FBBezierCurve *) subcurveWithRange:(FBRange)range;
 
+- (void) round;
+
 @end

VectorBoolean/FBBezierCurve.m

     return FBArePointsClose(_endPoint1, _endPoint2);
 }
 
+- (void) round
+{
+    _endPoint1 = FBRoundPoint(_endPoint1);
+    _controlPoint1 = FBRoundPoint(_controlPoint1);
+    _controlPoint2 = FBRoundPoint(_controlPoint2);
+    _endPoint2 = FBRoundPoint(_endPoint2);
+}
+
 - (NSString *) description
 {
     return [NSString stringWithFormat:@"<%@ (%f, %f)-[%f, %f] curve to [%f, %f]-(%f, %f)>", 

VectorBoolean/FBBezierGraph.m

 
 - (void) addContour:(FBBezierContour *)contour;
 - (void) addBezierGraph:(FBBezierGraph *)graph;
+- (void) round;
 
 @property (readonly) NSArray *contours;
 @property (readonly) NSRect bounds;
     [graph markCrossingsAsEntryOrExitWithBezierGraph:self markInside:NO];
     
     FBBezierGraph *result = [self bezierGraphFromIntersections];
+    [result round];
     
     // Clean up crossings so the graphs can be reused
     [self removeCrossings];
     [graph markCrossingsAsEntryOrExitWithBezierGraph:self markInside:YES];
     
     FBBezierGraph *result = [self bezierGraphFromIntersections];
+    [result round];
     
     // Clean up crossings so the graphs can be reused
     [self removeCrossings];
     [graph markCrossingsAsEntryOrExitWithBezierGraph:self markInside:YES];
     
     FBBezierGraph *result = [self bezierGraphFromIntersections];
+    [result round];
     
     // Clean up crossings so the graphs can be reused
     [self removeCrossings];
         BOOL firstPoint = YES;        
         for (FBContourEdge *edge in contour.edges) {
             if ( firstPoint ) {
-                [path moveToPoint:FBRoundPoint(edge.curve.endPoint1)];
+                [path moveToPoint:edge.curve.endPoint1];
                 firstPoint = NO;
             }
             
-            [path curveToPoint:FBRoundPoint(edge.curve.endPoint2) controlPoint1:FBRoundPoint(edge.curve.controlPoint1) controlPoint2:FBRoundPoint(edge.curve.controlPoint2)];
+            [path curveToPoint:edge.curve.endPoint2 controlPoint1:edge.curve.controlPoint1 controlPoint2:edge.curve.controlPoint2];
         }
     }
     
     return path;
 }
 
+- (void) round
+{
+    for (FBBezierContour *contour in _contours)
+        [contour round];
+}
+
 - (BOOL) insertCrossingsWithBezierGraph:(FBBezierGraph *)other
 {
     // Find all intersections and, if they cross the other graph, create crossings for them

VectorBoolean/FBContourEdge.h

 - (void) addCrossing:(FBEdgeCrossing *)crossing;
 - (void) removeCrossing:(FBEdgeCrossing *)crossing;
 - (void) removeAllCrossings;
+- (void) round;
 
 @end

VectorBoolean/FBContourEdge.m

     return [_crossings objectAtIndex:[_crossings count] - 1];    
 }
 
+- (void) round
+{
+    [_curve round];
+}
+
 - (NSString *) description
 {
     return [NSString stringWithFormat:@"<%@: curve = %@ crossings = %@>", NSStringFromClass([self class]), [_curve description], FBArrayDescription(_crossings)];