NeighbourhoodOp(Dst, Src, Ext, Ext2, Ngb) { foreach d, s, e, e2 in Dst, Src, Ext, Ext2 { phase = 1; do { Ngb.init(phase, s.x, s.y, Src(s), Ext(e), Ext2(e2)); foreach n in Ngb.size() Ngb.next(n.x, n.y, Src(s - (Ngb.size()/2) + n), Ext(e - (Ngb.size()/2) + n), Ext2(e2 - (Ngb.size()/2) + n)); Ngb.done(phase); } while (Ngb.hasNextPhase(phase++)); Dst(d) = ngb.result(); } }
The requirements on the NgbT template parameter expressed as class definition are:
template<class DstValT, class SrcValT, class ExtValT, class Ext2ValT> class NgbT { public: typedef HxTagLoop IteratorCategory; typedef HxTagNPhase PhaseCategory; NgbT(HxTagList& tags); ~NgbT(); HxSizes size(); void init(int phase, int ix, int iy, SrcValT v1, ExtValT v2, Ext2ValT v3); void next(int nx, int ny, SrcValT v1, ExtValT v2, Ext2ValT v3); void done(int phase); bool hasNextPhase(int thisPhase); DstValT result() const; static HxString className(); };
Example(s):