// Emacs: -*- C++ -*-

//
//	Copyright 1993, Center for Computer Vision and Visualization,
//	University of Florida.  All rights reserved.
//


//
// $Log: template-reduction,v $
// Revision 1.4  1994/01/07  15:10:00  thoth
// Image class is now CoreImage and named image types are
// Image<P,T>.
//
// Revision 1.3  1993/12/29  17:33:18  thoth
// New operator scheme that prevents the need for trivial Image conversions.
//
// Revision 1.2  1993/11/17  18:45:07  thoth
// IPSIter is now PSIter<IntPoint>.
//
// Revision 1.1  1993/10/20  18:32:02  thoth
// Initial revision
//

IA_Image<IA_IntPoint, RTYPE>
REDUCT(IA_IntPointSet domain,
       IA_DDTemplate<TITYPE > templ,
       IA_IntPointSet dest_domain)
{
    IA_Image<IA_IntPoint, RTYPE>	rval(dest_domain, (RTYPE)ZERO);

    IA_PSIter<IA_IntPoint>	psiter(domain);
    IA_IntPoint	scan;

    while (psiter(scan)) {
	TITYPE	curr = templ(scan);
	IA_IPIter<IA_IntPoint, TBTYPE>	iiter(curr);
	IA_IntPoint	p;
	TBTYPE	val;
	// _IRESULT_=rval[p]
	// _TVAL_=val

	while (iiter(p,val)) {
	    if (rval.domain().contains(p)) {
		ACCUMULATE ;
	    }
	}
    }
    return rval;
}

// end
