comparison OrthancServer/SliceOrdering.cpp @ 1842:697ae8d0e287

better handling of ordered-slices
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 30 Nov 2015 13:16:52 +0100
parents ec66a16aa398
children 1ba224001fd0
comparison
equal deleted inserted replaced
1841:5d8134e54c03 1842:697ae8d0e287
274 } 274 }
275 275
276 PositionComparator comparator(normal_); 276 PositionComparator comparator(normal_);
277 std::sort(instances_.begin(), instances_.end(), comparator); 277 std::sort(instances_.begin(), instances_.end(), comparator);
278 278
279 float a = instances_.front()->ComputeRelativePosition(normal_); 279 float a = instances_[0]->ComputeRelativePosition(normal_);
280 float b = instances_.back()->ComputeRelativePosition(normal_); 280 for (size_t i = 1; i < instances_.size(); i++)
281 281 {
282 if (std::fabs(b - a) <= 10.0f * std::numeric_limits<float>::epsilon()) 282 float b = instances_[i]->ComputeRelativePosition(normal_);
283 { 283
284 // Not enough difference between the minimum and maximum 284 if (std::fabs(b - a) <= 10.0f * std::numeric_limits<float>::epsilon())
285 // positions along the normal of the volume 285 {
286 return false; 286 // Not enough space between two slices along the normal of the volume
287 } 287 printf("Not enough space\n");
288 else 288 return false;
289 { 289 }
290 // This is a 3D volume 290
291 isVolume_ = true; 291 a = b;
292 return true; 292 }
293 } 293
294 // This is a 3D volume
295 isVolume_ = true;
296 return true;
294 } 297 }
295 298
296 299
297 bool SliceOrdering::SortUsingIndexInSeries() 300 bool SliceOrdering::SortUsingIndexInSeries()
298 { 301 {