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