#include #include #include #include namespace icl{ UnaryOp::UnaryOp():m_poMT(0),m_buf(0){}; UnaryOp::UnaryOp(const UnaryOp &other): m_poMT(0),m_oROIHandler(other.m_oROIHandler),m_buf(0){} UnaryOp &UnaryOp::operator=(const UnaryOp &other){ m_oROIHandler = other.m_oROIHandler; ICL_DELETE( m_poMT ); return *this; } UnaryOp::~UnaryOp(){ ICL_DELETE( m_poMT ); ICL_DELETE( m_buf ); } const ImgBase *UnaryOp::apply(const ImgBase *src){ apply(src,&m_buf); return m_buf; } void UnaryOp::applyMT(const ImgBase *poSrc, ImgBase **ppoDst, unsigned int nThreads){ ICLASSERT_RETURN( nThreads > 0 ); ICLASSERT_RETURN( poSrc ); if(nThreads == 1){ apply(poSrc,ppoDst); return; } if(!prepare (ppoDst, poSrc)) return; bool ctr = getClipToROI(); bool co = getCheckOnly(); setClipToROI(false); setCheckOnly(true); const std::vector srcs = ImageSplitter::split(poSrc,nThreads); std::vector dsts = ImageSplitter::split(*ppoDst,nThreads); MultiThreader::WorkSet works(nThreads); for(unsigned int i=0;i(dsts[i])); } if(!m_poMT){ m_poMT = new MultiThreader(nThreads); }else{ if(m_poMT->getNumThreads() != (int)nThreads){ delete m_poMT; m_poMT = new MultiThreader(nThreads); } } (*m_poMT)( works ); for(unsigned int i=0;i