]> Creatis software - clitk.git/commitdiff
Add ComputeBBUnion
authorDavid Sarrut <david.sarrut@gmail.com>
Mon, 24 Oct 2011 06:31:03 +0000 (08:31 +0200)
committerDavid Sarrut <david.sarrut@gmail.com>
Mon, 24 Oct 2011 06:31:03 +0000 (08:31 +0200)
itk/clitkBoundingBoxUtils.h
itk/clitkBoundingBoxUtils.txx

index 2138d63ae8a7f83e8f6b553a7e5ae3b775349cc2..311e67da1204d52b8fe6be2dd60665ecc6200342 100644 (file)
@@ -40,12 +40,19 @@ namespace clitk {
                              typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi1, 
                              typename itk::BoundingBox<unsigned long, Dimension>::Pointer bbi2);
 
+  //--------------------------------------------------------------------
+  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);
+  
   //--------------------------------------------------------------------
   template<class ImageType>
   void ComputeRegionFromBB(const ImageType * image, 
                            const typename itk::BoundingBox<unsigned long, 
                                                            ImageType::ImageDimension>::Pointer bb, 
                            typename ImageType::RegionType & region);
+
 } // end clitk namespace
 
 #include "clitkBoundingBoxUtils.txx"
index 26f38b2e7a3d55dc9ecf1eed7e642bb325c807d7..d6fbc24b7eaa0248c4a9a78bdb0297f829da4a72 100644 (file)
@@ -51,19 +51,33 @@ namespace clitk {
   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) {
-
     typedef itk::BoundingBox<unsigned long, Dimension> BBType;
     typedef typename BBType::PointType PointType;
     PointType lastPoint;
     PointType firstPoint;
-
     for(unsigned int i=0; i<Dimension; i++) {
-      firstPoint[i] = std::max(bbi1->GetMinimum()[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<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) {
+    typedef itk::BoundingBox<unsigned long, Dimension> BBType;
+    typedef typename BBType::PointType PointType;
+    PointType lastPoint;
+    PointType firstPoint;
+    for(unsigned int i=0; i<Dimension; i++) {
+      firstPoint[i] = std::min(bbi1->GetMinimum()[i], bbi2->GetMinimum()[i]);
+      lastPoint[i] = std::max(bbi1->GetMaximum()[i], bbi2->GetMaximum()[i]);
+    }
     bbo->SetMaximum(lastPoint);
     bbo->SetMinimum(firstPoint);
   }