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


1.10
date	93.05.27.11.28.12;	author thoth;	state Exp;
branches;
next	1.9;

1.9
date	93.05.26.16.59.39;	author thoth;	state Exp;
branches;
next	1.8;

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

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

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

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

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

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

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

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


desc
@Initial revision
@


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

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


static char ConstDIrcsid[] = "$Id: ConstDI.c,v 1.9 93/05/26 16:59:39 thoth Exp Locker: thoth $";

// $Log:	ConstDI.c,v $
// Revision 1.9  93/05/26  16:59:39  thoth
// plug memory leak.
// 
// Revision 1.8  93/05/18  21:38:48  thoth
// range method returns ValueSet again.
// new value_array method gives an Array of image values.
// 
// 
// Revision 1.7  93/04/17  18:45:01  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/03/10  13:31:59  thoth
// range method no longer returns valueset due to
// difficulties with template implementation.
// 
// Revision 1.5  93/02/20  12:38:32  thoth
// operator() is too simple to be outline.
// equality testing does not belong here.
// 
// Revision 1.4  93/02/08  11:34:32  thoth
// static dummy member belongs here.
// equal method should be correct now
// range method now faster.
// 
// Revision 1.3  93/01/19  14:55:44  jnw
// Modified to support IA_ naming convention
// 
// Revision 1.2  92/11/14  09:35:18  jnw
// Substituted () and [] for val and ref
// 
// Revision 1.1  92/10/05  11:43:28  jnw
// Initial revision
// 

#include "VectorDI.h"
#include "ConstDI.h"
#include "ConstDIVIter.h"
#include "ConstDIPIter.h"
#include "IPSIter.h"

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

template <class T>
IA_BaseDI<T>* IA_ConstDI<T>::clone_self_extensively() const
{
    // VectorDI will throw if the pointset is nonextensive
    return (IA_BaseDI<T> *) new IA_VectorDI<T>(this->ps, this->value);
}

#if 1
template <class T>
IA_ValueSet<T> IA_ConstDI<T>::range() const
{
    return value;
}
#else
template <class T>
T* IA_ConstDI<T>::range(unsigned *sz) const
{
    T	*vec = new T[*sz=1];
    vec[0] = value;
    return vec;
}
#endif
template <class T>
IA_Array<T> IA_ConstDI<T>::value_array() const
{
    const int	sz=domain().card();
    T	*vec = new T[sz];
    for (int i=0; i<sz; i++)
	vec[i] = value;
    return IA_Array<T>(vec,sz,1);
}

//
// iterator support below
//

template <class T>
IA_BaseDIVIter<T> *IA_ConstDI<T>::value_iterator() const
{
    return new IA_ConstDIVIter<T>(this);
}

template <class T>
IA_BaseDIPIter<T> *IA_ConstDI<T>::pixel_iterator() const
{
    return new IA_ConstDIPIter<T>(this);
}

//
//
//

template <class T>
ostream& IA_ConstDI<T>::print_this(ostream &o) const
{
    o << "Constant Image - Value : " << this->value ;
    if (this->ps.extensivep()){
	IA_IPSIter iter(this->ps);
	IA_IntPoint p;
	o << ", Points follow\n";
	while(iter(p)) {
	    o << p << ", ";
	}
    } else {
	o << ", Comprehensive PointSet";
    }
    return o << "\n";
}
@


1.9
log
@plug memory leak.
@
text
@d3 4
a6 1
static char ConstDIrcsid[] = "$Id: ConstDI.c,v 1.8 93/05/18 21:38:48 thoth Exp Locker: thoth $";
d8 3
d12 3
@


1.8
log
@range method returns ValueSet again.
new value_array method gives an Array of image values.

@
text
@d3 1
a3 1
static char ConstDIrcsid[] = "$Id: ConstDI.c,v 1.7 93/04/17 18:45:01 thoth Exp Locker: thoth $";
d6 5
d76 1
a76 1
    return IA_Array<T>(vec,sz);
@


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
@d3 1
a3 1
static char ConstDIrcsid[] = "$Id: ConstDI.c,v 1.6 93/03/10 13:31:59 thoth Exp Locker: thoth $";
d6 4
d49 1
d51 6
d63 10
a72 1

@


1.6
log
@range method no longer returns valueset due to
difficulties with template implementation.
@
text
@d3 1
a3 1
static char ConstDIrcsid[] = "$Id: ConstDI.c,v 1.5 93/02/20 12:38:32 thoth Exp Locker: thoth $";
d6 4
d31 2
d53 20
@


1.5
log
@operator() is too simple to be outline.
equality testing does not belong here.
@
text
@d3 1
a3 1
static char ConstDIrcsid[] = "$Id: ConstDI.c,v 1.4 93/02/08 11:34:32 thoth Exp Locker: thoth $";
d6 4
d40 1
a40 1
IA_ValueSet<T> IA_ConstDI<T>::range() const
d42 3
a44 1
    return IA_ValueSet<T>(this->value);
@


1.4
log
@static dummy member belongs here.
equal method should be correct now
range method now faster.
@
text
@d3 1
a3 1
static char ConstDIrcsid[] = "$Id: ConstDI.c,v 1.3 93/01/19 14:55:44 jnw Exp Locker: thoth $";
d6 5
a28 16
T IA_ConstDI<T>::operator ()(const IA_IntPoint &p) const
{
    if (!this->ps.contains(p))
	ia_throw(IA::IMAGE_DOMAIN_ERROR, __FILE__, __LINE__);
    return value;
}

template <class T>
int IA_ConstDI<T>::equal(const IA_BaseDI<T>* other) const
{
    return (this->domain() == other->domain()
	    && this->type()==other->type()
	    && this->value == ((IA_ConstDI<T> *)other)->value);
}

template <class T>
d31 2
a32 6
    if (this->ps.extensivep()) {
	return (IA_BaseDI<T> *) new IA_VectorDI<T>(this->value, this->ps);
    } else {
	ia_throw( IA::PSET_REQUIRE_EXTENSIVE, __FILE__, __LINE__);
    }

@


1.3
log
@Modified to support IA_ naming convention
@
text
@d3 1
a3 1
static char ConstDIrcsid[] = "$Id: ConstDI.c,v 1.2 92/11/14 09:35:18 jnw Exp Locker: jnw $";
d6 3
d21 3
d34 1
a34 1
    return (((IA_BaseDI<T> *)this)->equal(other)
d53 1
a53 2
    IA_ValueSet<T> result = this->value;
    return result;
@


1.2
log
@Substituted () and [] for val and ref
@
text
@d3 1
a3 1
static char ConstDIrcsid[] = "$Id: ConstDI.c,v 1.1 92/10/05 11:43:28 jnw Exp Locker: jnw $";
d6 3
d18 1
a18 1
T ConstDI<T>::operator ()(const IntPoint &p) const
d26 1
a26 1
int ConstDI<T>::equal(const BaseDI<T>* other) const
d28 1
a28 1
    return (((BaseDI<T> *)this)->equal(other)
d30 1
a30 1
	    && this->value == ((ConstDI<T> *)other)->value);
d34 1
a34 1
BaseDI<T>* ConstDI<T>::clone_self_extensively() const
d37 1
a37 1
	return (BaseDI<T> *) new VectorDI<T>(this->value, this->ps);
d45 1
a45 1
ValueSet<T> ConstDI<T>::range() const
d47 1
a47 1
    ValueSet<T> result = this->value;
d53 1
a53 1
ostream& ConstDI<T>::print_this(ostream &o) const
d57 2
a58 2
	IPSIter iter(this->ps);
	IntPoint p;
@


1.1
log
@Initial revision
@
text
@d3 1
a3 1
static char ConstDIrcsid[] = "$Id$";
d5 4
a8 1
// $Log$
d23 8
d40 8
@
