head	1.8;
access;
symbols
	r0_10:1.8
	Eglin_alpha_1:1.8;
locks; strict;
comment	@// @;


1.8
date	93.05.27.11.28.20;	author thoth;	state Exp;
branches;
next	1.7;

1.7
date	93.04.17.18.45.06;	author thoth;	state Exp;
branches;
next	1.6;

1.6
date	93.02.23.14.07.04;	author thoth;	state Exp;
branches;
next	1.5;

1.5
date	93.02.20.12.43.43;	author thoth;	state Exp;
branches;
next	1.4;

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

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

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

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


desc
@Value Iterator class
@


1.8
log
@Copyright Notices
@
text
@// Emacs: -*- C++ -*-

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

static char DIVIterrcsid[] = "$Id: DIVIter.c,v 1.7 93/04/17 18:45:06 thoth Exp Locker: thoth $";

// 
// $Log:	DIVIter.c,v $
// Revision 1.7  93/04/17  18:45:06  thoth
// Iterator support is no longer based on a switch statement.  We now
// use a virtual method.  The user can now provide faster iterators.
// 
// Revision 1.6  93/02/23  14:07:04  thoth
// We now have the OtherDI[VP]Iter.  All non-vector, non-const DIs will
// use this.  We may provide a way to override this in the future
// (virtual BaseDI[VP]Iter* BaseDI::iterator() const method?).
// 
// Revision 1.5  93/02/20  12:43:43  thoth
// There are now two sorts of BaseDIIters.
// 
// Revision 1.4  93/02/17  11:00:09  thoth
// fixed the make_x_iter invocations.
// 
// Revision 1.3  93/01/19  14:55:58  jnw
// Modified to support IA_ naming convention
// 
// Revision 1.2  92/11/14  09:39:00  jnw
// Modified to support new function image iterators
// 
// Revision 1.1  92/11/13  13:45:27  jnw
// Initial revision
// 
// Revision 1.1  92/10/05  11:46:31  jnw
// Initial revision
// 
//

#include "DIVIter.h"
#include "ConstDIVIter.h"
#include "VectorDIVIter.h"
#include "OtherDIIter.h"

template <class T>
class IA_errorDIVIter: public IA_BaseDIVIter<T> {
  public:
    IA_errorDIVIter() 
    :IA_BaseDIVIter<T>(0) {}

    virtual IA_BaseDIVIter<T> * clone_self() { 
	ia_throw( IA::IMAGE_REQUIRE_VALUE_ITER, __FILE__, __LINE__);
	return new IA_errorDIVIter;
    }

    virtual int next(T&) { 
	ia_throw( IA::IMAGE_REQUIRE_VALUE_ITER, __FILE__, __LINE__);
	return 0;
    }

    // this method resets the iterator to the beginning of the point set
    virtual void reset() { 
	ia_throw( IA::IMAGE_REQUIRE_VALUE_ITER, __FILE__, __LINE__);
    }

};

//
//
//

template <class T>
IA_DIVIter<T>::IA_DIVIter()
{
    iter = new IA_errorDIVIter<T>;
}

template <class T>
IA_DIVIter<T>& IA_DIVIter<T>::operator=(const IA_DiscreteImage<T> &image)
{
    delete this->iter;

    this->iter = image.bdip->value_iterator();

    return *this;
}

template <class T>
IA_DIVIter<T>& IA_DIVIter<T>::operator=(const IA_DIVIter<T> &x)
{
    if (x.iter==this->iter)
	return *this;

    delete this->iter;

    this->iter = x.iter->clone_self();

    return *this;
}
@


1.7
log
@Iterator support is no longer based on a switch statement.  We now
use a virtual method.  The user can now provide faster iterators.
@
text
@a1 1
static char DIVIterrcsid[] = "$Id: DIVIter.c,v 1.6 93/02/23 14:07:04 thoth Exp Locker: thoth $";
d3 7
d12 4
@


1.6
log
@We now have the OtherDI[VP]Iter.  All non-vector, non-const DIs will
use this.  We may provide a way to override this in the future
(virtual BaseDI[VP]Iter* BaseDI::iterator() const method?).
@
text
@d2 1
a2 1
static char DIVIterrcsid[] = "$Id: DIVIter.c,v 1.5 93/02/20 12:43:43 thoth Exp Locker: thoth $";
d6 5
d37 28
a64 2
IA_BaseDIVIter<T>* IA_DIVIter<T>::make_value_iter(const IA_DiscreteImage<T>&
						 image)
d66 1
a66 9
    IA_DiscreteImageType	itype=image.bdip->type();
    
    if (itype==IA_ConstDI<T>::s_type()) {
	return new IA_ConstDIVIter<T>(image,(IA_ConstDI<T>*)image.bdip);
    } else if (itype==IA_VectorDI<T>::s_type()) {
	return new IA_VectorDIVIter<T>(image,(IA_VectorDI<T>*)image.bdip);
    } else {
	return new IA_OtherDIVIter<T>(image);
    }
d74 1
a74 1
    this->iter = make_value_iter(image);
@


1.5
log
@There are now two sorts of BaseDIIters.
@
text
@d2 1
a2 1
static char DIVIterrcsid[] = "$Id: DIVIter.c,v 1.4 93/02/17 11:00:09 thoth Exp Locker: thoth $";
d6 3
d29 1
a29 2
//#include "FunctionDIVIter.h"
//#include "FunctionRefDIVIter.h"
a40 7
#if 0
    } else if (itype==IA_FunctionDI<T>::s_type()) {
	return new IA_FunctionDIVIter<T>(image,(IA_FunctionDI<T>*)image.bdip);
    } else if (itype==IA_FunctionRefDI<T>::s_type()) {
	return new IA_FunctionRefDIVIter<T>(image,
					    (IA_FunctionRefDI<T>*)image.bdip);
#endif
d42 1
a42 4
	abort();
// What do I call this error?  Hmmm...
//	ia_throw(IA::, __FILE__, __LINE__);
	return 0;
@


1.4
log
@fixed the make_x_iter invocations.
@
text
@d2 1
a2 1
static char DIVIterrcsid[] = "$Id: DIVIter.c,v 1.3 93/01/19 14:55:58 jnw Exp Locker: thoth $";
d6 3
d26 2
a27 2
#include "FunctionDIVIter.h"
#include "FunctionRefDIVIter.h"
d30 1
a30 1
IA_BaseDIIter<T>* IA_DIVIter<T>::make_value_iter(const IA_DiscreteImage<T>&
d39 1
d45 1
@


1.3
log
@Modified to support IA_ naming convention
@
text
@d2 1
a2 1
static char DIVIterrcsid[] = "$Id: DIVIter.c,v 1.2 92/11/14 09:39:00 jnw Exp Locker: jnw $";
d6 3
d54 1
a54 1
    this->iter = make_iter(image);
@


1.2
log
@Modified to support new function image iterators
@
text
@d2 1
a2 1
static char DIVIterrcsid[] = "$Id: DIVIter.c,v 1.1 92/11/13 13:45:27 jnw Exp Locker: jnw $";
d6 3
d24 2
a25 1
BaseDIIter<T>* DIVIter<T>::make_value_iter(const DiscreteImage<T> & image)
d27 1
a27 1
    DiscreteImageType	itype=image.bdip->type();
d29 9
a37 8
    if (itype==ConstDI<T>::s_type()) {
	return new ConstDIVIter<T>(image,(ConstDI<T>*)image.bdip);
    } else if (itype==VectorDI<T>::s_type()) {
	return new VectorDIVIter<T>(image,(VectorDI<T>*)image.bdip);
    } else if (itype==FunctionDI<T>::s_type()) {
	return new FunctionDIVIter<T>(image,(FunctionDI<T>*)image.bdip);
    } else if (itype==FunctionRefDI<T>::s_type()) {
	return new FunctionRefDIVIter<T>(image,(FunctionRefDI<T>*)image.bdip);
d47 1
a47 1
DIVIter<T>& DIVIter<T>::operator=(const DiscreteImage<T> &image)
d57 1
a57 1
DIVIter<T>& DIVIter<T>::operator=(const DIVIter<T> &x)
@


1.1
log
@Initial revision
@
text
@d2 1
a2 1
static char DIVIterrcsid[] = "$Id: DIVIter.c,v 1.1 92/10/05 11:46:31 jnw Exp Locker: jnw $";
d6 3
d17 2
d29 4
@
