head	1.8;
access
	monica
	thoth;
symbols;
locks
	monica:1.8; strict;
comment	@// @;


1.8
date	94.11.04.21.54.55;	author monica;	state Exp;
branches;
next	1.7;

1.7
date	94.09.14.19.45.15;	author monica;	state Exp;
branches;
next	1.6;

1.6
date	94.08.24.00.30.59;	author monica;	state Exp;
branches;
next	1.5;

1.5
date	94.08.24.00.02.50;	author monica;	state Exp;
branches;
next	1.4;

1.4
date	93.03.10.13.52.29;	author thoth;	state Exp;
branches;
next	1.3;

1.3
date	93.01.19.14.56.53;	author jnw;	state Exp;
branches;
next	1.2;

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

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


desc
@initial revision
@


1.8
log
@*** empty log message ***
@
text
@// Emacs: -*- C++ -*-
static char test002rcsid[] = "$Id: test002.c,v 1.7 1994/09/14 19:45:15 monica Exp monica $";

//
// $Log: test002.c,v $
 //Revision 1.7  1994/09/14  19:45:15  monica
 //*** empty log message ***
 //
 //Revision 1.6  1994/08/24  00:30:59  monica
 //int main & exit(0)
 //
//Revision 1.5  1994/08/24  00:02:50  monica
//added int main & return 0;
//
// Revision 1.4  1993/03/10  13:52:29  thoth
// Test out the OtherDI constructor.
// Use IntDiscreteImages instead of DiscreteImage<int>.
// We can test range() again.
//
// Revision 1.3  93/01/19  14:56:53  jnw
// Modified to support IA_ naming convention
// 
// Revision 1.2  92/11/14  09:39:40  jnw
// Testing new iterator types
// 
// Revision 1.1  92/11/13  13:48:26  jnw
// Initial revision
// 

#include <stream.h>

#include <stdlib.h>


//#define WORKAROUND_CFRONT_FRIEND_MANGLING_BUG
//#include "ValueSet.h"
//#undef WORKAROUND_CFRONT_FRIEND_MANGLING_BUG

//#include "IntPointSet.h"
//#include "IPSIter.h"
//#include "DIVIter.h"
//#include "DiscreteImage.h"
//#include "OtherDI.h"
//#include "DIPIter.h"
//#include "FloatPoint.h"

#include "test.h"

typedef IA_PSIter<IA_Point<int> >  IA_IPSIter;

ostream& operator <<(ostream& o, IA_Set<IA_Point<int> > & ps)
{
    IA_IPSIter psiter(ps);
    IA_Point<int> p;

    o << "{";
    while(psiter(p)){
	cout << p << ",";
    }
    return o << "}\n";
    
}

class NormDI: public IA_OtherDI<int> {
  public:
    NormDI(IA_Set<IA_Point<int> > ps)
    :IA_OtherDI<int>(ps) {}
    int operator()(const IA_Point<int> &p) const { return p.enorm(); }
    IA_BaseDI<int> *clone_self() const { return new NormDI(*this); }
};
#if 0
int norm1(IntPoint p)
{
    return p.enorm();
}
#endif

int norm2(const IntPoint &p)
{
    return p.enorm();
}

int plus(int i, int j)
{
    return i + j;
}


int plus2(const int& i, const int& j)
{
    return i+j;
}


int vec[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };

#define test(decl,str) { cout << ">>>Testing " #decl  str "<<<\n"; \
		     di = decl; \
		     cout << di; \
		     di[p] = 228952153; \
		     cout << di << ">>> <<<\n\n"; }

int main()
{
    IA_DiscreteImage<int> di,di2;
    IA_Set<IA_Point<int> > ps(IA_Point<int> (0,0),IA_Point<int> (3,3)),
	ps2(IA_Point<int> (1,1),IA_Point<int> (2,2)),
	ps3(IA_Point<int> (0,0),IA_Point<int> (4,4));
    IA_Point<int>  p(1,1);
    IA_ValueSet<int> v;

    test(IA_DiscreteImage<int>(ps,1),"");

    test(IA_DiscreteImage<int>(NormDI(ps)),"NormDI");

    test(IA_DiscreteImage<int>(ps, norm2),"int norm2(const IA_Point<int> &)");

    test(IA_DiscreteImage<int>(ps, vec, ps.card()),"");

    cout << ">>>Checking multiple assign of shared image<<<\n";
    di2 = IA_DiscreteImage<int>(NormDI(ps));
    di = di2;
    di[p] = 7;
    cout << di << di2 << ">>> <<<\n\n";

    cout << ">>>Extracting Range of Previous image<<<\n";
    v = di.range();
    cout << "Range is " << v << ">>> <<<\n\n";

    cout << ">>>Testing reduction with function int plus(int,int): "
	 << di.reduce(plus,0) << "<<<\n" << ">>> <<<\n\n";

    cout << ">>>Testing reduction with function int plus(const int&,const int&): "
	 << di.reduce(plus2,0) << "\n" << ">>> <<<\n\n";


    cout << ">>>Testing pixel iterator function by computing centroid<<<\n";
    cout << (di = IA_DiscreteImage<int>(ps,2));

#if 1
    // this code is screwy.  What is going on?
    IA_DIPIter<int> iter(di);
    IA_Point<int> loc, locsum, newloc;
    int val,newval;

    iter(loc,val);
    locsum = loc;
    while(iter(newloc,newval)){
	loc += newloc*newval;
	locsum += newloc;
	val += newval;
    }

    cout << "Centroid is " << (locsum/(float)di.card()) << "\n" << ">>> <<<\n\n";
#endif
    test(IA_DiscreteImage<int>(ps, new int[16], 16),"");

    di = IA_DiscreteImage<int>(NormDI(ps));
    cout << "Testing Restriction of image "
	 << di
	 << " to IntPointSet " << ps << "\n";
    cout << (di.restrict(ps)) << "\n>>> <<<\n\n";

    di[IntPoint(0,0)] = 1;

    cout << "Testing Restriction of image "
	 << di
	 << " to IntPointSet " << ps << "\n";
    cout << (di.restrict(ps)) << "\n>>> <<<\n\n";

    di = 1;
    cout << "Testing Restriction of image "
	 << di
	 << " to IntPointSet " << ps << "\n";
    cout << (di.restrict(ps)) << "\n>>> <<<\n\n";

    di = IA_DiscreteImage<int>(ps2, 1);
    di2 = IA_DiscreteImage<int>(NormDI(ps3));
    cout << "Testing Extension of image "
	 << di << " to Image " << di2 << "\n";
    cout << (di.extend(di2)) << "\n>>> <<<\n\n";

    exit(0);

    return 0;
}
@


1.7
log
@*** empty log message ***
@
text
@d2 1
a2 1
static char test002rcsid[] = "$Id: test002.c,v 1.6 1994/08/24 00:30:59 monica Exp monica $";
d6 3
d35 15
a49 11
#define WORKAROUND_CFRONT_FRIEND_MANGLING_BUG
#include "ValueSet.h"
#undef WORKAROUND_CFRONT_FRIEND_MANGLING_BUG

#include "IntPointSet.h"
#include "IPSIter.h"
#include "DIVIter.h"
#include "DiscreteImage.h"
#include "OtherDI.h"
#include "DIPIter.h"
#include "FloatPoint.h"
d51 1
a51 1
ostream& operator <<(ostream& o, IA_IntPointSet& ps)
d54 1
a54 1
    IA_IntPoint p;
d66 1
a66 1
    NormDI(IA_IntPointSet ps)
d68 1
a68 1
    int operator()(const IA_IntPoint &p) const { return p.enorm(); }
d106 4
a109 4
    IA_IntPointSet ps(IA_IntPoint(0,0),IA_IntPoint(3,3)),
	ps2(IA_IntPoint(1,1),IA_IntPoint(2,2)),
	ps3(IA_IntPoint(0,0),IA_IntPoint(4,4));
    IA_IntPoint p(1,1);
d116 1
a116 1
    test(IA_DiscreteImage<int>(ps, norm2),"int norm2(const IA_IntPoint&)");
d143 1
a143 1
    IA_IntPoint loc, locsum, newloc;
@


1.6
log
@int main & exit(0)
@
text
@d2 1
a2 1
static char test002rcsid[] = "$Id: test002.c,v 1.5 1994/08/24 00:02:50 monica Exp monica $";
d6 3
@


1.5
log
@added int main & return 0;
@
text
@d2 1
a2 1
static char test002rcsid[] = "$Id: test002.c,v 1.4 1993/03/10 13:52:29 thoth Exp monica $";
d6 3
@


1.4
log
@Test out the OtherDI constructor.
Use IntDiscreteImages instead of DiscreteImage<int>.
We can test range() again.
@
text
@d2 1
a2 1
static char test002rcsid[] = "$Id: test002.c,v 1.3 93/01/19 14:56:53 jnw Exp Locker: thoth $";
d5 6
a10 1
// $Log:	test002.c,v $
d90 1
a90 1
main()
d172 1
@


1.3
log
@Modified to support IA_ naming convention
@
text
@d2 1
a2 1
static char test002rcsid[] = "$Id: test002.c,v 1.2 92/11/14 09:39:40 jnw Exp Locker: jnw $";
d6 3
d20 2
a21 1
#define FIX_VS
d23 2
a24 1
#undef FIX_VS
d29 1
d45 9
d58 1
d89 2
a90 2
	ps2(IA_IntPoint(1,1),IA_IntPoint(2,2)), ps3(IA_IntPoint(0,0),
						    IA_IntPoint(4,4));
d94 1
a94 1
    test(IA_DiscreteImage<int>(1,ps),"");
d96 1
a96 1
    test(IA_DiscreteImage<int>(norm1, ps),"int norm1(IA_IntPoint)");
d98 1
a98 1
    test(IA_DiscreteImage<int>(norm2, ps),"int norm2(const IA_IntPoint&)");
d100 1
a100 1
    test(IA_DiscreteImage<int>(vec, ps, ps.card()),"");
d103 1
a103 1
    di2 = IA_DiscreteImage<int>(norm1,ps);
d105 1
a105 1
    di[p] = 3;
d108 3
a110 3
//    cout << ">>>Extracting Range of Previous image<<<\n";
//    v = di.range();
//    cout << "Range is " << v << ">>> <<<\n\n";
d120 1
a120 1
    cout << (di = IA_DiscreteImage<int>(2,ps));
d122 2
d136 3
a138 1
    cout << "Centroid is " << locsum/(float)di.card() << "\n" << ">>> <<<\n\n";
d140 5
a144 1
    test(IA_DiscreteImage<int>(new int[16], ps, 16),"");
a145 1
    di = IA_DiscreteImage<int>(norm1,ps);
d147 1
d151 1
a151 2
    
    cout << (di & ps) << "\n>>> <<<\n\n";
d153 1
d157 1
d159 2
a160 2
    di = IA_DiscreteImage<int>(1, ps2);
    di2 = IA_DiscreteImage<int>(norm2,ps3);
d163 1
a163 1
    cout << (di | di2) << "\n>>> <<<\n\n";
@


1.2
log
@Testing new iterator types
@
text
@d2 1
a2 1
static char test002rcsid[] = "$Id: test002.c,v 1.1 92/11/13 13:48:26 jnw Exp Locker: jnw $";
d6 3
d27 1
a27 1
ostream& operator <<(ostream& o, IntPointSet& ps)
d29 2
a30 2
    IPSIter psiter(ps);
    IntPoint p;
d71 6
a76 5
    DiscreteImage<int> di,di2;
    IntPointSet ps(IntPoint(0,0),IntPoint(3,3)),
	ps2(IntPoint(1,1),IntPoint(2,2)), ps3(IntPoint(0,0), IntPoint(4,4));
    IntPoint p(1,1);
    ValueSet<int> v;
d78 1
a78 1
    test(DiscreteImage<int>(1,ps),"");
d80 1
a80 1
    test(DiscreteImage<int>(norm1, ps),"int norm1(IntPoint)");
d82 1
a82 1
    test(DiscreteImage<int>(norm2, ps),"int norm2(const IntPoint&)");
d84 1
a84 1
    test(DiscreteImage<int>(vec, ps, ps.card()),"");
d87 1
a87 1
    di2 = DiscreteImage<int>(norm1,ps);
d104 1
a104 1
    cout << (di = DiscreteImage<int>(2,ps));
d106 2
a107 2
    DIPIter<int> iter(di);
    IntPoint loc, locsum, newloc;
d120 1
a120 1
    test(DiscreteImage<int>(new int[16], ps, 16),"");
d122 1
a122 1
    di = DiscreteImage<int>(norm1,ps);
d134 2
a135 2
    di = DiscreteImage<int>(1, ps2);
    di2 = DiscreteImage<int>(norm2,ps3);
@


1.1
log
@Initial revision
@
text
@d2 1
a2 1
static char test002rcsid[] = "$Id$";
d5 4
a8 1
// $Log$
d130 2
a131 1
    di2 = DiscreteImage<int>(1,ps3);
@
