Skip to content

Commit 190d85c

Browse files
author
Oleksandr Glagoliev
committed
Prevent unnecessary termination for debug step
1 parent 3df6863 commit 190d85c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Sources/FortunesAlgorithm/FortuneSweep.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public class FortuneSweep {
3333
}
3434
}
3535
private var firstSiteY: Double?
36-
3736
private var container: Rectangle! {
3837
didSet {
3938
watcher?.updateContainer(rectangle: container)
@@ -49,6 +48,7 @@ public class FortuneSweep {
4948
watcher?.step = currentStep
5049
}
5150
}
51+
private var isTerminated: Bool!
5252
/// Result Data Structure
5353
private(set) var diagram: Diagram!
5454

@@ -98,7 +98,7 @@ public class FortuneSweep {
9898
ascending: true,
9999
startingValues: events
100100
)
101-
101+
isTerminated = false
102102
logger?.log("\n\nComputation started!", level: .info)
103103

104104
while !eventQueue.isEmpty && currentStep != maxStepsCount {
@@ -116,7 +116,11 @@ public class FortuneSweep {
116116
func debug_step() -> Bool {
117117
step()
118118
if eventQueue.isEmpty {
119-
terminate()
119+
if isTerminated == false {
120+
terminate()
121+
} else {
122+
logger?.log("Algorithm terminated", level: .info)
123+
}
120124
return true
121125
}
122126
return false
@@ -454,6 +458,7 @@ public class FortuneSweep {
454458
/// 2. Complete incomplete cells
455459
/// 3. Clip cells to clipping rectangle
456460
private func terminate() {
461+
isTerminated = true
457462
logger?.log("Event Queue is empty. Diagram bounding started.", level: .info)
458463

459464
// Step 1:

0 commit comments

Comments
 (0)