From: David Sarrut Date: Fri, 18 Nov 2011 15:54:06 +0000 (+0100) Subject: Add compute intersection X-Git-Tag: v1.3.0~104^2~31 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=d2d75b63a31a4bfbbed0c22333e34dba688e6503;p=clitk.git Add compute intersection --- 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) {