From 69667910c62b2c9e30d795a9af668855a8de78d3 Mon Sep 17 00:00:00 2001 From: David Sarrut Date: Mon, 24 Oct 2011 08:31:03 +0200 Subject: [PATCH] Add ComputeBBUnion --- itk/clitkBoundingBoxUtils.h | 7 +++++++ itk/clitkBoundingBoxUtils.txx | 26 ++++++++++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/itk/clitkBoundingBoxUtils.h b/itk/clitkBoundingBoxUtils.h index 2138d63..311e67d 100644 --- a/itk/clitkBoundingBoxUtils.h +++ b/itk/clitkBoundingBoxUtils.h @@ -40,12 +40,19 @@ namespace clitk { typename itk::BoundingBox::Pointer bbi1, typename itk::BoundingBox::Pointer bbi2); + //-------------------------------------------------------------------- + template + void ComputeBBUnion(typename itk::BoundingBox::Pointer bbo, + typename itk::BoundingBox::Pointer bbi1, + typename itk::BoundingBox::Pointer bbi2); + //-------------------------------------------------------------------- template void ComputeRegionFromBB(const ImageType * image, const typename itk::BoundingBox::Pointer bb, typename ImageType::RegionType & region); + } // end clitk namespace #include "clitkBoundingBoxUtils.txx" diff --git a/itk/clitkBoundingBoxUtils.txx b/itk/clitkBoundingBoxUtils.txx index 26f38b2..d6fbc24 100644 --- a/itk/clitkBoundingBoxUtils.txx +++ b/itk/clitkBoundingBoxUtils.txx @@ -51,19 +51,33 @@ namespace clitk { void ComputeBBIntersection(typename itk::BoundingBox::Pointer bbo, typename itk::BoundingBox::Pointer bbi1, typename itk::BoundingBox::Pointer bbi2) { - typedef itk::BoundingBox BBType; typedef typename BBType::PointType PointType; PointType lastPoint; PointType firstPoint; - for(unsigned int i=0; iGetMinimum()[i], - bbi2->GetMinimum()[i]); - lastPoint[i] = std::min(bbi1->GetMaximum()[i], - bbi2->GetMaximum()[i]); + firstPoint[i] = std::max(bbi1->GetMinimum()[i], bbi2->GetMinimum()[i]); + lastPoint[i] = std::min(bbi1->GetMaximum()[i], bbi2->GetMaximum()[i]); } + bbo->SetMaximum(lastPoint); + bbo->SetMinimum(firstPoint); + } + //-------------------------------------------------------------------- + + ///-------------------------------------------------------------------- + template + void ComputeBBUnion(typename itk::BoundingBox::Pointer bbo, + typename itk::BoundingBox::Pointer bbi1, + typename itk::BoundingBox::Pointer bbi2) { + typedef itk::BoundingBox BBType; + typedef typename BBType::PointType PointType; + PointType lastPoint; + PointType firstPoint; + for(unsigned int i=0; iGetMinimum()[i], bbi2->GetMinimum()[i]); + lastPoint[i] = std::max(bbi1->GetMaximum()[i], bbi2->GetMaximum()[i]); + } bbo->SetMaximum(lastPoint); bbo->SetMinimum(firstPoint); } -- 2.47.1