Andy Finnell avatar Andy Finnell committed d147f30

add ability to retreive the contours that intersect with another contour

Comments (0)

Files changed (4)

VectorBoolean/FBBezierContour.h

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

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];

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;

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 )
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.