From d2d75b63a31a4bfbbed0c22333e34dba688e6503 Mon Sep 17 00:00:00 2001 From: David Sarrut Date: Fri, 18 Nov 2011 16:54:06 +0100 Subject: [PATCH] Add compute intersection --- itk/clitkBoundingBoxUtils.h | 7 +++++++ itk/clitkBoundingBoxUtils.txx | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/itk/clitkBoundingBoxUtils.h b/itk/clitkBoundingBoxUtils.h index 311e67d..2fcaddd 100644 --- a/itk/clitkBoundingBoxUtils.h +++ b/itk/clitkBoundingBoxUtils.h @@ -40,6 +40,13 @@ namespace clitk { typename itk::BoundingBox::Pointer bbi1, typename itk::BoundingBox::Pointer bbi2); + //-------------------------------------------------------------------- + template + void ComputeBBIntersection(typename itk::BoundingBox::Pointer bbo, + typename itk::BoundingBox::Pointer bbi1, + typename itk::BoundingBox::Pointer bbi2, + int dimension); + //-------------------------------------------------------------------- template void ComputeBBUnion(typename itk::BoundingBox::Pointer bbo, diff --git a/itk/clitkBoundingBoxUtils.txx b/itk/clitkBoundingBoxUtils.txx index d6fbc24..9f277cb 100644 --- a/itk/clitkBoundingBoxUtils.txx +++ b/itk/clitkBoundingBoxUtils.txx @@ -67,6 +67,24 @@ namespace clitk { ///-------------------------------------------------------------------- template + void ComputeBBIntersection(typename itk::BoundingBox::Pointer bbo, + typename itk::BoundingBox::Pointer bbi1, + typename itk::BoundingBox::Pointer bbi2, + int dimension) { + typedef itk::BoundingBox BBType; + typedef typename BBType::PointType PointType; + PointType lastPoint; + PointType firstPoint; + firstPoint[dimension] = std::max(bbi1->GetMinimum()[dimension], bbi2->GetMinimum()[dimension]); + lastPoint[dimension] = std::min(bbi1->GetMaximum()[dimension], bbi2->GetMaximum()[dimension]); + bbo->SetMaximum(lastPoint); + bbo->SetMinimum(firstPoint); + } + //-------------------------------------------------------------------- + + + //-------------------------------------------------------------------- + template void ComputeBBUnion(typename itk::BoundingBox::Pointer bbo, typename itk::BoundingBox::Pointer bbi1, typename itk::BoundingBox::Pointer bbi2) { -- 2.47.1