head     1.3;
branch   ;
access   ;
symbols  ;
locks    ; strict;
comment  @// @;


1.3
date     93.02.08.13.01.13;  author thoth;  state Exp;
branches ;
next     1.2;

1.2
date     93.01.19.14.56.10;  author jnw;  state Exp;
branches ;
next     1.1;

1.1
date     92.10.05.11.44.26;  author jnw;  state Exp;
branches ;
next     ;


desc
@Initial revision
@


1.3
log
@static dummy member belongs in the .c file.
equal method no longer loops infinitely.
@
text
@// Emacs: -*- C++ -*-

static char FunctionDIrcsid[] = "$Id: FunctionDI.c,v 1.2 93/01/19 14:56:10 jnw Exp Locker: thoth $";

// $Log:	FunctionDI.c,v $
// Revision 1.2  93/01/19  14:56:10  jnw
// Modified to support IA_ naming convention
// 
// Revision 1.1  92/10/05  11:44:26  jnw
// Initial revision
// 

#include "ia.h"
#include "FunctionDI.h"
#include "VectorDI.h"
#include "IPSIter.h"

template <class T>
char IA_FunctionDI<T>::dummy;

template <class T>
T IA_FunctionDI<T>::operator ()(const IA_IntPoint& p) const {
    if (!this->ps.contains(p))
	ia_throw( IA::IMAGE_DOMAIN_ERROR, __FILE__, __LINE__);
    return (*(this->func))(p);
}

template <class T>
int IA_FunctionDI<T>::equal(const IA_BaseDI<T>* other) const
{
    IA_FunctionDI<T>* ot = (IA_FunctionDI<T> *)other;

    if  ( this->domain() == other->domain()
	  && this->type()==other->type() ){
	// PointSet and type match.  Check value function
	if (this->func == ot->func) {
	    // exact value function match
	    return 1;
	} else if (this->ps.extensivep() && ot->ps.extensivep()) {
	    // evaluate value function at each point to check for match

	    IA_IPSIter iter(this->ps);
	    IA_IntPoint p;
	    
	    while(iter(p)) {
		if ((*(this->func))(p) != (*(ot->func))(p))
		    // one value didn't match!
		    return 0;
	    }
	    return 1;
	} else 
	    return 0;
    } else
	return 0;
}


template <class T>
IA_BaseDI<T>* IA_FunctionDI<T>::clone_self_extensively() const
{
    if (this->ps.extensivep()) {
	T *vec;
	IA_IPSIter iter(this->ps);
	IA_IntPoint p;
	
	vec = new T[this->ps.card()];

	int i=0;
	while(iter(p)) {
	    vec[i++] = (*this->func)(p);
	}
	return new IA_VectorDI<T>(vec, this->ps, this->ps.card(),1);
	
    } else {
	ia_throw( IA::PSET_REQUIRE_EXTENSIVE
		  , __FILE__, __LINE__);
    }
    
}

template <class T>
ostream& IA_FunctionDI<T>::print_this(ostream& o) const
{
    o << "FunctionIntDI -";
    if (this->ps.extensivep()){
	IA_IPSIter iter(this->ps);
	IA_IntPoint p;
	
	o << "(point,value) pairs follow:\n";
	while(iter(p)) {
	    o << "(" << p << "," << (*this->func)(p) << ") ";
	}
    } else {
	o << ", Valueset : " << (int)(this->func) <<
	    ", PointSet : Comprehensive";
    }
    return o << "\n";
}
#if 0
int func(IA_IntPoint p)
{
    return p[1];
}
#endif
@


1.2
log
@Modified to support IA_ naming convention
@
text
@d3 1
a3 1
static char FunctionDIrcsid[] = "$Id: FunctionDI.c,v 1.1 92/10/05 11:44:26 jnw Exp Locker: jnw $";
d6 3
d19 3
d33 1
a33 1
    if  ( ((IA_BaseDI<T> *)this)->equal(other)
d72 1
a72 2
	return (IA_BaseDI<T> *) new
	    IA_VectorDI<T>(vec, this->ps, this->ps.card(),0);
d99 1
a99 1

d104 1
@


1.1
log
@Initial revision
@
text
@d3 1
a3 1
static char FunctionDIrcsid[] = "$Id$";
d5 4
a8 1
// $Log$
d16 1
a16 1
T FunctionDI<T>::operator ()(const IntPoint& p) const {
d23 1
a23 1
int FunctionDI<T>::equal(const BaseDI<T>* other) const
d25 1
a25 1
    FunctionDI<T>* ot = (FunctionDI<T> *)other;
d27 1
a27 1
    if  ( ((BaseDI<T> *)this)->equal(other)
d36 2
a37 2
	    IPSIter iter(this->ps);
	    IntPoint p;
d53 1
a53 1
BaseDI<T>* FunctionDI<T>::clone_self_extensively() const
d57 2
a58 2
	IPSIter iter(this->ps);
	IntPoint p;
d66 2
a67 2
	return (BaseDI<T> *) new
	    VectorDI<T>(vec, this->ps, this->ps.card(),0);
d77 1
a77 1
ostream& FunctionDI<T>::print_this(ostream& o) const
d81 2
a82 2
	IPSIter iter(this->ps);
	IntPoint p;
d95 1
a95 1
int func(IntPoint p)
@
