Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

MakeRoi.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Array_MakeRoi_h
00002 #define Impala_Core_Array_MakeRoi_h
00003 
00004 #include "Core/Geometry/Rectangle.h"
00005 #include "Core/Array/SetPart.h"
00006 
00007 namespace Impala
00008 {
00009 namespace Core
00010 {
00011 namespace Array
00012 {
00013 
00014 
00015 template<class ArrayT>
00016 inline ArrayT*
00017 MakeRoi(ArrayT* src, const Geometry::Rectangle& rect)
00018 {
00019     /* check for rectangles outside the valid memory range */
00020     if((rect.mLeft   < - src->BW()) || 
00021        (rect.mTop    < - src->BH()) ||
00022        (rect.mRight  >= src->CW() + src->BW()) ||
00023        (rect.mBottom >= src->CH() + src->BH()) ) {
00024 
00025         std::cerr << "[ERROR] Segfault highly likely due to too small border in MakeRoi (therefore aborted): " << 
00026                    "left=" << rect.mLeft   <<"; limit="<< - src->BW() <<"; top="<< 
00027                               rect.mTop    <<"; limit="<< - src->BH() <<"; right="<<
00028                               rect.mRight  <<"; limit="<< src->CW() + src->BW() <<"; bottom="<<
00029                               rect.mBottom <<"; limit="<< src->CH() + src->BH() << std::endl;
00030         /* refuse to work in this case */
00031         return 0;
00032     }
00033 
00034     ArrayT* roi = new ArrayT(rect.Width(), rect.Height(), 0, 0);
00035     SetPart(roi, src, rect.mLeft, rect.mTop, rect.Width(), rect.Height(), 0, 0);
00036     return roi;
00037 }
00038 
00039 } // namespace Array
00040 } // namespace Core
00041 } // namespace Impala
00042 
00043 #endif

Generated on Fri Mar 19 09:30:48 2010 for ImpalaSrc by  doxygen 1.5.1