Commits

Andy Finnell  committed d147f30

add ability to retreive the contours that intersect with another contour

  • Participants
  • Parent commits 7b81b71

Comments (0)

Files changed (4)

File VectorBoolean/FBBezierContour.h

 @property (readonly) NSPoint testPoint;
 @property (readonly) NSPoint firstPoint;
 @property FBContourInside inside;
+@property (readonly) NSArray *intersectingContours;
 
 @end

File VectorBoolean/FBBezierContour.m

         [edge round];
 }
 
+- (NSArray *) intersectingContours
+{
+    NSMutableArray *contours = [NSMutableArray arrayWithCapacity:3];
+    for (FBContourEdge *edge in _edges) {
+        NSArray *intersectingEdges = edge.intersectingEdges;
+        for (FBContourEdge *intersectingEdge in intersectingEdges) {
+            if ( ![contours containsObject:intersectingEdge.contour] )
+                [contours addObject:intersectingEdge.contour];
+        }
+    }
+    return contours;
+}
+
 - (id)copyWithZone:(NSZone *)zone
 {
     FBBezierContour *copy = [[FBBezierContour allocWithZone:zone] init];

File VectorBoolean/FBContourEdge.h

 @property (readonly) FBContourEdge *previous;
 @property (readonly) FBEdgeCrossing *firstCrossing;
 @property (readonly) FBEdgeCrossing *lastCrossing;
+@property (readonly) NSArray *intersectingEdges;
 
 @property (getter = isStartShared) BOOL startShared;
 @property (getter = isStopShared) BOOL stopShared;

File VectorBoolean/FBContourEdge.m

     return [self.contour.edges objectAtIndex:_index - 1];
 }
 
+- (NSArray *) intersectingEdges
+{
+    NSMutableArray *edges = [NSMutableArray arrayWithCapacity:[_crossings count]];
+    for (FBEdgeCrossing *crossing in _crossings) {
+        FBContourEdge *intersectingEdge = crossing.counterpart.edge;
+        if ( ![edges containsObject:intersectingEdge] )
+            [edges addObject:intersectingEdge];
+    }
+    return edges;
+}
+
 - (FBEdgeCrossing *) firstCrossing
 {
     if ( [_crossings count] == 0 )