comparison OrthancStone/Sources/Toolbox/SlicesSorter.cpp @ 1766:ae18b5cfbd3e

VolumeImageGeometry::DetectProjection() reports if normal is opposite
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 May 2021 11:31:34 +0200
parents 9ac2a65d4172
children 3889ae96d2e9
comparison
equal deleted inserted replaced
1765:177f93c8371c 1766:ae18b5cfbd3e
257 257
258 return false; 258 return false;
259 } 259 }
260 260
261 261
262 bool SlicesSorter::LookupClosestSlice(size_t& index,
263 double& distance,
264 const CoordinateSystem3D& slice) const
265 {
266 // TODO Turn this linear-time lookup into a log-time lookup,
267 // keeping track of whether the slices are sorted along the normal
268
269 bool found = false;
270
271 distance = std::numeric_limits<double>::infinity();
272
273 for (size_t i = 0; i < slices_.size(); i++)
274 {
275 assert(slices_[i] != NULL);
276
277 double tmp;
278 if (CoordinateSystem3D::ComputeDistance(tmp, slices_[i]->GetGeometry(), slice))
279 {
280 if (!found ||
281 tmp < distance)
282 {
283 index = i;
284 distance = tmp;
285 found = true;
286 }
287 }
288 }
289
290 return found;
291 }
292
293
294 bool SlicesSorter::ComputeSpacingBetweenSlices(double& spacing /* out */) const 262 bool SlicesSorter::ComputeSpacingBetweenSlices(double& spacing /* out */) const
295 { 263 {
296 if (GetSlicesCount() <= 1) 264 if (GetSlicesCount() <= 1)
297 { 265 {
298 // This is a volume that is empty or that contains one single 266 // This is a volume that is empty or that contains one single