head	1.4;
access
	monica
	thoth;
symbols
	Eglin_alpha_1:1.1;
locks
	monica:1.4; strict;
comment	@// @;


1.4
date	94.11.09.20.25.21;	author monica;	state Exp;
branches;
next	1.3;

1.3
date	94.10.06.01.14.33;	author monica;	state Exp;
branches;
next	1.2;

1.2
date	94.08.17.04.12.11;	author monica;	state Exp;
branches;
next	1.1;

1.1
date	92.08.23.13.30.36;	author thoth;	state Exp;
branches;
next	;


desc
@CFrontified version

@


1.4
log
@removed include devfrags & any debugging calls to malloc
@
text
@// Emacs: -*- C++ -*-
static char rcsid[] = "$Id: test003.c,v 1.3 1994/10/06 01:14:33 monica Exp monica $";

//
// $Log: test003.c,v $
// Revision 1.3  1994/10/06  01:14:33  monica
// updated for DOS file naming
//
// Revision 1.2  1994/08/17  04:12:11  monica
// added int main & return 0
//
// Revision 1.1  1992/08/23  13:30:36  thoth
// Initial revision
//
//

#include "IntPoint.h"
#include "IntPS.h"
#include "PSIter.h"
#include "Set.h"

#include <iostream.h>

void test_intersection(IA_Set<IA_Point<int> > a, IA_Set<IA_Point<int> > b, IA_Set<IA_Point<int> > ab)
{
    IA_Point<int>	p, p2;

    {
	IA_PSIter<IA_Point<int> >	iter(ab);

	while (iter(p)) {
	    cout << p;
	    if (!a.contains(p) || !b.contains(p)) {
		cout << "##extra##";
	    }
	    cout << '\t';
	}
	cout << '\n';
    }

    {
	IA_PSIter<IA_Point<int> >	iter(a), iter2(b);

	while (iter(p)) {
	    iter2.reset();
	    while (iter2(p2)){
		if (p == p2) {
		    cout << p;
		    if (! (ab.contains(p))) {
			cout << "##missing##";
		    }	
		    cout << '\t';
		}
	    }
	}
	cout << '\n';
    }

    cout << '\n';
}

void printIntSet(IA_Set<IA_Point<int> > ips)
{
    char	image[80][40];
    int	x,y;
    
    for (x=0; x<40; x++)
	for (y=0; y<40; y++)
	    image[x][y] = ' ';
    
    IA_PSIter<IA_Point<int> >	iter(ips);
    IA_Point<int>	p;
    while (iter(p)) {
	image[p[0]+20][p[1]+10] = '#';
    }

    for (x=40; x<80; x++)
	for (y=0; y<40; y++)
	    image[x][y] = ips.contains(IA_Point<int>(x-60,y-10)) ? '*' : '.';
    
    for (y=0; y<40; y++) {
	for (x=0; x<75; x++)
	    cout << image[x][y];
	cout << '\n';
    }
    
}

int main()
{
    const int	x0=-5, x1=-3, x2=0, x3=3, x4=5, x5=10, x6= 15;
    const int	y0=-5, y1=-3, y2=0, y3=3, y4=5, y5=10;

    IA_Set<IA_Point<int> > ps0,ps1,ps2;

    ps0 = IA_Set<IA_Point<int> >(IA_Point<int>(x0), IA_Point<int>(x3));
    ps1 = IA_Set<IA_Point<int> >(IA_Point<int>(x1), IA_Point<int>(x4));
    ps2 = ps0 & ps1;
    test_intersection(ps0, ps1, ps0&ps1);

    ps0 = IA_Set<IA_Point<int> >(IA_Point<int>(x0), IA_Point<int>(x2)) |
	IA_Set<IA_Point<int> >(IA_Point<int>(x4), IA_Point<int>(x6));
    ps1 = IA_Set<IA_Point<int> >(IA_Point<int>(x1), IA_Point<int>(x4));
    ps2 = ps0 & ps1;
    test_intersection(ps0, ps1, ps0&ps1);


    ps0 = IA_Set<IA_Point<int> >(IA_Point<int>(x0,y2),IA_Point<int>(x4,y4)) |
	IA_Set<IA_Point<int> >(IA_Point<int>(x2,y0),IA_Point<int>(x4,y4));
    printIntSet(ps0);

    ps1 = IA_Set<IA_Point<int> >(IA_Point<int>(x1,y1),IA_Point<int>(x3,y5)) |
	IA_Set<IA_Point<int> >(IA_Point<int>(x1,y1),IA_Point<int>(x5,y3));
    printIntSet(ps1);

    printIntSet(ps0&ps1);
    test_intersection(ps0, ps1, ps0&ps1);


    return 0;

}






@


1.3
log
@updated for DOS file naming
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: test003.c,v 1.2 1994/08/17 04:12:11 monica Exp monica $";
d6 3
a16 1
#include "devfrags.h"
a94 2

    malloc_debug(2);
@


1.2
log
@added int main & return 0
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: test003.c,v 1.1 1992/08/23 13:30:36 thoth Exp monica $";
d6 3
d14 1
a14 1
#include "dev-frags.h"
@


1.1
log
@Initial revision
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: test003.cc,v 1.1 92/07/30 16:36:59 jnw Exp $";
d5 3
a7 1
// $Log$
d9 1
d13 3
a15 2
#include "IntPointSet.h"
#include "IPSIter.h"
d19 1
a19 1
void test_intersection(IntPointSet a, IntPointSet b, IntPointSet ab)
d21 1
a21 1
    IntPoint	p, p2;
d24 1
a24 1
	IPSIter	iter(ab);
d37 1
a37 1
	IPSIter	iter(a), iter2(b);
d57 1
a57 1
void printIntSet(IntPointSet ips)
d66 2
a67 2
    IPSIter	iter(ips);
    IntPoint	p;
d74 1
a74 1
	    image[x][y] = ips.contains(IntPoint(x-60,y-10)) ? '*' : '.';
d84 1
a84 1
main()
d89 1
a89 1
    IntPointSet ps0,ps1,ps2;
d93 2
a94 2
    ps0 = IntPointSet(IntPoint(x0), IntPoint(x3));
    ps1 = IntPointSet(IntPoint(x1), IntPoint(x4));
d98 3
a100 3
    ps0 = IntPointSet(IntPoint(x0), IntPoint(x2)) |
	IntPointSet(IntPoint(x4), IntPoint(x6));
    ps1 = IntPointSet(IntPoint(x1), IntPoint(x4));
d105 2
a106 2
    ps0 = IntPointSet(IntPoint(x0,y2),IntPoint(x4,y4)) |
	IntPointSet(IntPoint(x2,y0),IntPoint(x4,y4));
d109 2
a110 2
    ps1 = IntPointSet(IntPoint(x1,y1),IntPoint(x3,y5)) |
	IntPointSet(IntPoint(x1,y1),IntPoint(x5,y3));
d115 3
@
