src/misc/ringFinder.cc

changeset 840
d077dd19bf9a
parent 832
5c751af82f35
equal deleted inserted replaced
839:5f822ad61875 840:d077dd19bf9a
76 for (double r = r0 + interval; r < r1; r += interval) 76 for (double r = r0 + interval; r < r1; r += interval)
77 { 77 {
78 Solution sol = currentSolution; 78 Solution sol = currentSolution;
79 79
80 m_stack++; 80 m_stack++;
81 bool res = findRingsRecursor (r0, r, sol) && findRingsRecursor (r, r1, sol); 81 bool res = findRingsRecursor (r0, r, sol) and findRingsRecursor (r, r1, sol);
82 m_stack--; 82 m_stack--;
83 83
84 if (res) 84 if (res)
85 { 85 {
86 // We succeeded in finding radii for this segment. If the stack is 0, this 86 // We succeeded in finding radii for this segment. If the stack is 0, this
128 // r0=3, r1=7 (scaled up by 2) yields a 2-component solution. We can then 128 // r0=3, r1=7 (scaled up by 2) yields a 2-component solution. We can then
129 // downscale the radii back by dividing the scale fields of the solution 129 // downscale the radii back by dividing the scale fields of the solution
130 // components. 130 // components.
131 double scale = 1.0; 131 double scale = 1.0;
132 132
133 if (not isZero (scale = r0 - floor (r0)) || not isZero (scale = r1 - floor (r1))) 133 if (not isZero (scale = r0 - floor (r0)) or not isZero (scale = r1 - floor (r1)))
134 { 134 {
135 double r0f = r0 / scale; 135 double r0f = r0 / scale;
136 double r1f = r1 / scale; 136 double r1f = r1 / scale;
137 137
138 if (qFuzzyCompare (floor (r0f), r0f) && qFuzzyCompare (floor (r1f), r1f)) 138 if (qFuzzyCompare (floor (r0f), r0f) and qFuzzyCompare (floor (r1f), r1f))
139 { 139 {
140 r0 = r0f; 140 r0 = r0f;
141 r1 = r1f; 141 r1 = r1f;
142 } 142 }
143 } 143 }
160 // overload to compare two solutions. 160 // overload to compare two solutions.
161 m_bestSolution = null; 161 m_bestSolution = null;
162 162
163 for (Solution const& sol : m_solutions) 163 for (Solution const& sol : m_solutions)
164 { 164 {
165 if (m_bestSolution == null || sol.isSuperiorTo (m_bestSolution)) 165 if (m_bestSolution == null or sol.isSuperiorTo (m_bestSolution))
166 m_bestSolution = &sol; 166 m_bestSolution = &sol;
167 } 167 }
168 168
169 return (m_bestSolution != null); 169 return (m_bestSolution != null);
170 } 170 }

mercurial