]> Creatis software - clitk.git/commitdiff
Add compute intersection
authorDavid Sarrut <david.sarrut@gmail.com>
Fri, 18 Nov 2011 15:54:06 +0000 (16:54 +0100)
committerDavid Sarrut <david.sarrut@gmail.com>
Fri, 18 Nov 2011 15:54:06 +0000 (16:54 +0100)
itk/clitkBoundingBoxUtils.h
itk/clitkBoundingBoxUtils.txx

index 311e67da1204d52b8fe6be2dd60665ecc6200342..2fcaddd2dda8c6e2ee00a2f81524e7590b382377 100644 (file)
@@ -40,6 +40,13 @@ namespace clitk {
                              typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi1, 
                              typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi2);
 
+  //--------------------------------------------------------------------
+  template<int Dimension>
+  void ComputeBBIntersection(typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbo, 
+                             typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi1, 
+                             typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi2, 
+                             int dimension);
+
   //--------------------------------------------------------------------
   template<int Dimension>
   void ComputeBBUnion(typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbo, 
index d6fbc24b7eaa0248c4a9a78bdb0297f829da4a72..9f277cbe6ad93f2ed50d0397a60511fbbecad3ea 100644 (file)
@@ -67,6 +67,24 @@ namespace clitk {
 
   ///--------------------------------------------------------------------
   template<int Dimension>
+  void ComputeBBIntersection(typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbo, 
+                             typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi1, 
+                             typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi2, 
+                             int dimension) {
+    typedef itk::BoundingBox<unsigned long, Dimension> 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<int Dimension>
   void ComputeBBUnion(typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbo, 
                       typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi1, 
                       typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi2) {