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


1.2
date     93.02.17.11.01.44;  author thoth;  state Exp;
branches ;
next     1.1;

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


desc
@Int Discrete Image support routines.
@


1.2
log
@A futile attempt to get the multiple inheritance scheme to work.
@
text
@// Emacs: -*- C++ -*-
static char test002rcsid[] = "$Id: IntDI.c,v 1.1 93/02/16 10:50:46 thoth Exp Locker: thoth $";

//
// $Log:	IntDI.c,v $
// Revision 1.1  93/02/16  10:50:46  thoth
// Initial revision
// 
//

#include <iostream.h>
#include "IntPointSet.h"
#include "IPSIter.h"
#include "IntDI.h"
#include "ErrorDI.h"
#include	"with-ia-pointset.h"

IA_ErrorDI<int> IA_DiscreteImage<int>::errorDI;

IA_IntDiscreteImage IA_IntDiscreteImage::read_PGM(istream &i)
{
    int	width, height,maxval;
    if (i.get()=='P' && i.get()=='5' && i>>ws>>width>>height>>maxval) {
	const int	size=width*height;
	unsigned char	*tmp = new unsigned char[size];
	{
	    int	ch = i.get();
	    if (ch!='\n')
		i.putback(ch);
	}
	if (!i.read(tmp, size))
	    return IA_IntDiscreteImage();
	int	*data = new int[size];
	for (unsigned i=0; i<size; i++)
	    data[i] = tmp[i];
	delete[] tmp;
	IA_IntDiscreteImage
	    rval(data, IA_IntPointSet(IA_IntPoint(0,0),
				      IA_IntPoint(height-1,width-1)),
		 size);
	delete[] data;
	return rval;
    } else {
	return IA_IntDiscreteImage();
    }
}

ostream &IA_IntDiscreteImage::write_PGM(ostream &o) const
{
    IntPointSet boxydomain(domain().inf(),domain().sup());
    IntPoint	width(domain().sup()-domain().inf()+1);
    o<<"P5\n"<<width[1] << " " << width[0] << " 255\n";
    IPSIter	iter(boxydomain);
    IntPoint	ip;

    while (iter(ip)) {
	o.put((char) (*this)(ip));
    }
    return o;
}

static void __dummy__()
{
    IA_IntPointSet	ps;
    IA_IntDiscreteImage	i1;
    IA_IntDiscreteImage
	i2(i1),
	i3(0,ps),
	i4((int*)0, ps, 0),
	i5((int(*)(const IA_IntPoint&))0, ps),
	//i6((int(*)(IA_IntPoint))0, ps),
	i7(IA_ArithDI<int>()),
	i8(IA_BitwiseDI<int>()),
	i9(IA_LatticeDI<int>()),
	i10(IA_DiscreteImage<int>());
    i1 = i1.restrict(ps);
    (void)(i2-i1);
}
@


1.1
log
@Initial revision
@
text
@d2 1
a2 1
static char test002rcsid[] = "$Id: test100.c,v 1.1 92/11/14 09:45:50 jnw Exp Locker: jnw $";
d5 4
a8 1
// $Log:	test100.c,v $
d76 2
a77 2
    //i1 = ((IA_DiscreteImage<int>&)i1) & ps;
    //i2-i1;
@
