src/misc.cpp

changeset 501
8f314f3f5054
parent 500
cad8cdc42a64
child 502
f6534d591f80
--- a/src/misc.cpp	Wed Oct 16 15:32:38 2013 +0300
+++ b/src/misc.cpp	Wed Oct 16 16:04:56 2013 +0300
@@ -316,9 +316,15 @@
 // as it would fall into an infinite recursion.
 // -----------------------------------------------------------------------------
 bool RingFinder::findRings (double r0, double r1)
+{	m_solution.clear();
+	return findRingsRecursor (r0, r1);
+}
+
+bool RingFinder::findRingsRecursor (double r0, double r1)
 {	// Find the scale and number of a ring between r1 and r0.
 	double scale = r1 - r0;
 	double num = r0 / scale;
+	print ("r0: %1, r1: %2, scale: %3, num: %4\n", r0, r1, scale, num);
 
 	// If the ring number is integral, we have found a fitting ring to r0 -> r1!
 	if (isInteger (num))
@@ -330,16 +336,19 @@
 	else
 	{	// If not, find an intermediate <r> between the radii
 		double r = ceil (num) * scale;
+		print ("\tr: %1\n", r);
 
 		// If r is the same as r0 or r1, we simply cannot find any rings between
 		// r0 and r1. Stop and return failure.
 		if (isZero (r0 - r) || isZero (r1 - r))
+		{	print ("failure!\n");
 			return false;
+		}
 
 		// Split this ring into r0 -> r and r -> r1. Recurse to possibly find
 		// the rings for these. If either recurse fails, the entire algorithm
 		// fails as well.
-		if (!findRings (r0, r) || !findRings (r, r1))
+		if (!findRingsRecursor (r0, r) || !findRingsRecursor (r, r1))
 			return false;
 	}
 

mercurial