File tree Expand file tree Collapse file tree 2 files changed +9
-51
lines changed
Sources/FortunesAlgorithm Expand file tree Collapse file tree 2 files changed +9
-51
lines changed Original file line number Diff line number Diff line change @@ -71,8 +71,9 @@ public class FortuneSweep {
7171 public func compute(
7272 sites: Set < Site > ,
7373 diagram: inout Diagram ,
74- clippingRect: Rectangle
75- ) {
74+ clippingRect: Rectangle ,
75+ maxStepsCount: Int = - 1
76+ ) -> Bool {
7677 self . diagram = diagram
7778 self . clipper = clippingRect
7879 let filteredSites = sites. filter { clipper. contains ( $0) }
@@ -85,8 +86,9 @@ public class FortuneSweep {
8586 /// Diagram is a whole plane. Do nothing
8687 if events. isEmpty {
8788 logger? . log ( " Computation done. No sites inside defined area! " , level: . info)
88- return
89+ return true
8990 }
91+
9092 currentStep = 0
9193 sweepLineY = 0
9294 firstSiteY = nil
@@ -98,14 +100,15 @@ public class FortuneSweep {
98100 )
99101
100102 logger? . log ( " \n \n Computation started! " , level: . info)
101- var finished = false
102- while !finished {
103+
104+ while !eventQueue . isEmpty && currentStep != maxStepsCount {
103105 step ( )
104- finished = eventQueue. isEmpty
105106 }
106107 if eventQueue. isEmpty {
107108 terminate ( )
109+ return true
108110 }
111+ return false
109112 }
110113
111114 /// Performs one step of the algorithm
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments