head	1.19;
access;
symbols
	r2_1:1.17
	r2_0:1.17
	r1_1_beta:1.16
	r1_1_alpha:1.15
	r1_0:1.15
	r0_11:1.15
	r0_10:1.15
	r0_9:1.15
	Eglin_alpha_1:1.12;
locks; strict;
comment	@// @;


1.19
date	94.11.10.19.53.56;	author ljr;	state Exp;
branches;
next	1.18;

1.18
date	94.10.06.17.39.00;	author fjsoria;	state Exp;
branches;
next	1.17;

1.17
date	94.08.18.23.39.28;	author thoth;	state Exp;
branches;
next	1.16;

1.16
date	94.07.25.16.59.44;	author thoth;	state Exp;
branches;
next	1.15;

1.15
date	93.09.15.12.30.23;	author thoth;	state Exp;
branches;
next	1.14;

1.14
date	93.08.08.13.11.38;	author thoth;	state Exp;
branches;
next	1.13;

1.13
date	93.07.15.11.35.19;	author thoth;	state Exp;
branches;
next	1.12;

1.12
date	93.05.28.15.05.08;	author thoth;	state Exp;
branches;
next	1.11;

1.11
date	93.05.26.16.40.59;	author thoth;	state Exp;
branches;
next	1.10;

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

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

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

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

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

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

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

1.3
date	92.09.03.13.31.04;	author thoth;	state Exp;
branches;
next	1.2;

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

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


desc
@CFrontified version
@


1.19
log
@Added IA_NO_RCS_STATIC_DATA guard.
@
text
@// Emacs: -*- C++ -*-

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

#ifndef IA_NO_RCS_STATIC_DATA
static char copyright[] = "Copyright 1993, Center for Computer Vision and Visualization,\nUniversity of Florida.  All rights reserved.\n";

static char rcsid[] = "$Id: BoxyIPS.c,v 1.18 1994/10/06 17:39:00 fjsoria Exp ljr $";
#endif

// 
// $Log: BoxyIPS.c,v $
// Revision 1.18  1994/10/06  17:39:00  fjsoria
// commented rscid[] line
//
// Revision 1.17  1994/08/18  23:39:28  thoth
// DOS-inspired filename rework
//
// Revision 1.16  1994/07/25  16:59:44  thoth
// Name sanitization.
//
// Revision 1.15  1993/09/15  12:30:23  thoth
// Pointset behavior controls have moved to IA::
//
// Revision 1.14  93/08/08  13:11:38  thoth
// Optimization to reduce Point-Point op=
// 
// Revision 1.13  93/07/15  11:35:19  thoth
// Add support for iterator virtual method.
// 
// Revision 1.12  93/05/28  15:05:08  thoth
// removed dependency on with-ia-pointset*
// 
// Revision 1.11  93/05/26  16:40:59  thoth
// Copyright Notices.
// 
// Revision 1.10  93/04/19  23:27:24  thoth
// Convert BaseIPS to IA_BasePS<IA_IntPoint>
// 
// Revision 1.9  93/04/17  15:19:54  thoth
// IA_IntPoint upgrades (dim, inf, sup)
// 
// Revision 1.8  93/04/16  15:50:02  thoth
// use IA_IntPoint instead of IntPoint.
// 
// Revision 1.7  92/12/16  14:47:56  thoth
// conversion to IA_ mostly complete
// 
// Revision 1.6  92/12/07  12:04:32  thoth
// new IntPoint index(unsigned) operation for use with "other" iterators.
// 
// Revision 1.5  92/09/30  10:26:47  thoth
// contains now accepts const Point<>&
// type() system now based on address of static data member
// 
// Revision 1.4  92/09/20  14:04:48  thoth
// new infimum and supremum methods for point sets.
// 
// Revision 1.3  92/09/03  13:31:04  thoth
// hash_self now deals with unsigneds
// 
// Revision 1.2  92/08/26  13:42:26  thoth
// meaningful exception types
// 
// Revision 1.1  92/08/23  13:29:54  thoth
// Initial revision
// 
// 

#include "ia.h"
#include "BoxyIPS.h"
#include "BoxyIPSIter.h"
#include "IntPS.h"

#ifdef IA_PRII
#pragma implementation
#endif

char IA_BoxyIPS::type_;

// construct a BoxyIPS given two corners of the hyperrectangle
IA_BoxyIPS::IA_BoxyIPS(const IA_Point<int>& p1, const IA_Point<int>& p2)
: IA_BasePS<IA_Point<int> >(p1.dim()), start(::inf(p1,p2)), end(::sup(p1,p2))
{
    // we should throw a different error when there is a mismatch.
 
    // dimen can not be zero.  The two points must have equal dimension
    if (p1.dim()==0) {
	ia_throw(IA::POINT_UNINITIALIZED, __FILE__, __LINE__);
	return;
    }
#if 0				// This error is thrown by inf and sup
    if (p1.dim() != p2.dim()) {
	ia_throw(IA::PSET_DIMENSION_MISMATCH, __FILE__, __LINE__);
	return;
    }
#endif
}

IA_BoxyIPS& IA_BoxyIPS::operator=(const IA_BoxyIPS& bps)
{
    this->dimen = bps.dimen;
    this->start = bps.start;
    this->end = bps.end;

    return *this;
}

// The following code uses the member initialization syntax.  It's
// faster than allowing the no-argument constructor for members and
// then using assignment.
IA_BoxyIPS::IA_BoxyIPS(const IA_BoxyIPS& bps)
: IA_BasePS<IA_Point<int> >(bps.dimen),
  start(bps.start),
  end(bps.end)
{
}

int IA_BoxyIPS::equal(IA_BasePS<IA_Point<int> > * psb) const
{
    return psb->type() == type() &&
	*this == *(IA_BoxyIPS*)psb;
}

unsigned IA_BoxyIPS::hash_self(unsigned modulus) const
{
    unsigned	sigma = 0;
    for (unsigned i=0; i<this->dimen; i++) {
	sigma += this->start[i];
	sigma += this->end[i];
    }
    return sigma % modulus;
}

int IA_BoxyIPS::operator==(const IA_BoxyIPS& bps) const
{
    if (this->dimen != bps.dimen)
	return 0;

    return this->start == bps.start && this->end == bps.end;
}

int IA_BoxyIPS::contains(const IA_Point<int> &ip) const
{
    return this->start <= ip && ip <= this->end;
}

unsigned IA_BoxyIPS::index(const IA_Point<int> &ip) const
{
    if (!this->contains(ip)) {
	if (IA::throw_on_index_uncontained)
	    ia_throw(IA::PSET_INDEX_UNCONTAINED, __FILE__,__LINE__);
	return IA::index_of_uncontained;
    }

    unsigned offset=0;
    for (unsigned i=0; i<this->dimen; i++) {
	offset *= width(i);
	offset += ip[i] - this->start[i];
    }
    return offset;
}

IA_Point<int> IA_BoxyIPS::index(unsigned idx) const
{
    int	*rval = new int[dimen];
    for (int i = dimen-1; i>=0; i--) {
	rval[i] = idx % width(i) + start[i];
	idx /= width(i);
    }

    if (idx) {
	if (IA::throw_on_index_uncontained)
	    ia_throw(IA::PSET_INDEX_UNCONTAINED, __FILE__,__LINE__);
	// the index was outside the card
	return IA_Point<int>();
    } else {
	// give away the array
	return IA_Point<int>(rval, dimen, 1);
    }
}

unsigned IA_BoxyIPS::card() const
{
    unsigned	size=1;

    for (unsigned idx=0; idx < this->dimen; idx++) {
	size *= width(idx);
    }
    return size;
}

IA_BasePSIter<IA_Point<int> > * IA_BoxyIPS::iterator() const
{
    // cast away const
    return new IA_BoxyIPSIter((IA_BoxyIPS*)this);
}

void IA_BoxyIPS::output(ostream &o, unsigned indent) const
{
  for (unsigned i=0; i<indent; i++)
    o << ' ';
  o << start << ".." << end << '\n';
}
@


1.18
log
@commented rscid[] line
@
text
@d8 2
a9 1
//static char copyright[] = "Copyright 1993, Center for Computer Vision and Visualization,\nUniversity of Florida.  All rights reserved.\n";
d11 2
a12 1
//static char rcsid[] = "$Id: BoxyIPS.c,v 1.17 1994/08/18 23:39:28 thoth Exp fjsoria $";
d16 3
@


1.17
log
@DOS-inspired filename rework
@
text
@d8 1
a8 1
static char copyright[] = "Copyright 1993, Center for Computer Vision and Visualization,\nUniversity of Florida.  All rights reserved.\n";
d10 1
a10 1
static char rcsid[] = "$Id: BoxyIPS.c,v 1.16 1994/07/25 16:59:44 thoth Exp thoth $";
d14 3
@


1.16
log
@Name sanitization.
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: BoxyIPS.c,v 1.15 1993/09/15 12:30:23 thoth Exp thoth $";
d14 3
d68 1
a68 1
#include "IntPointSet.h"
@


1.15
log
@Pointset behavior controls have moved to IA::
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: BoxyIPS.c,v 1.14 93/08/08 13:11:38 thoth Exp Locker: thoth $";
d13 4
a16 1
// $Log:	BoxyIPS.c,v $
d74 2
a75 2
IA_BoxyIPS::IA_BoxyIPS(const IA_IntPoint& p1, const IA_IntPoint& p2)
: IA_BasePS<IA_IntPoint>(p1.dim()), start(::inf(p1,p2)), end(::sup(p1,p2))
d105 1
a105 1
: IA_BasePS<IA_IntPoint>(bps.dimen),
d111 1
a111 1
int IA_BoxyIPS::equal(IA_BasePS<IA_IntPoint> * psb) const
d135 1
a135 1
int IA_BoxyIPS::contains(const IA_IntPoint &ip) const
d140 1
a140 1
unsigned IA_BoxyIPS::index(const IA_IntPoint &ip) const
d156 1
a156 1
IA_IntPoint IA_BoxyIPS::index(unsigned idx) const
d168 1
a168 1
	return IA_IntPoint();
d171 1
a171 1
	return IA_IntPoint(rval, dimen, 1);
d185 1
a185 1
IA_BasePSIter<IA_IntPoint> * IA_BoxyIPS::iterator() const
@


1.14
log
@Optimization to reduce Point-Point op=
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: BoxyIPS.c,v 1.13 93/07/15 11:35:19 thoth Exp Locker: thoth $";
d14 3
d140 1
a140 1
	if (IA_IntPointSet::throw_on_index_uncontained)
d142 1
a142 1
	return IA_IntPointSet::index_of_uncontained;
d162 1
a162 1
	if (IA_IntPointSet::throw_on_index_uncontained)
@


1.13
log
@Add support for iterator virtual method.
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: BoxyIPS.c,v 1.12 93/05/28 15:05:08 thoth Exp Locker: thoth $";
d14 3
d69 1
a69 1
: IA_BasePS<IA_IntPoint>(p1.dim())
d72 2
d78 1
a78 1

a81 20
    }

    // dimen can not be zero.  The two points must have equal dimension

    // this just gets them to have the right size
#if 1
    start = ::inf(p1,p2);
    end = ::sup(p1,p2);
#else
    start = end = p1;

    // start is pointwise <= end
    for (unsigned idx =0; idx<this->dimen; idx++) {
	if (p1[idx]<p2[idx]) {
	    this->start[idx] = p1[idx];
	    this->end[idx] = p2[idx];
	} else {
	    this->end[idx] = p1[idx];
	    this->start[idx] = p2[idx];
	}
@


1.12
log
@removed dependency on with-ia-pointset*
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: BoxyIPS.c,v 1.11 93/05/26 16:40:59 thoth Exp Locker: thoth $";
d14 3
d55 1
d192 6
@


1.11
log
@Copyright Notices.
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: BoxyIPS.c,v 1.10 93/04/19 23:27:24 thoth Exp Locker: thoth $";
d14 3
d58 1
a58 1
#include "with-ia-pointset-P.h"
a59 2
char BoxyIPS::type_;

d61 1
a61 1
BoxyIPS::IA_BoxyIPS(const IA_IntPoint& p1, const IA_IntPoint& p2)
d97 1
a97 1
BoxyIPS& BoxyIPS::operator=(const BoxyIPS& bps)
d109 1
a109 1
BoxyIPS::IA_BoxyIPS(const BoxyIPS& bps)
d116 1
a116 1
int BoxyIPS::equal(IA_BasePS<IA_IntPoint> * psb) const
d119 1
a119 1
	*this == *(BoxyIPS*)psb;
d122 1
a122 1
unsigned BoxyIPS::hash_self(unsigned modulus) const
d132 1
a132 1
int BoxyIPS::operator==(const BoxyIPS& bps) const
d140 1
a140 1
int BoxyIPS::contains(const IA_IntPoint &ip) const
d145 1
a145 1
unsigned BoxyIPS::index(const IA_IntPoint &ip) const
d148 1
a148 1
	if (IntPointSet::throw_on_index_uncontained)
d150 1
a150 1
	return IntPointSet::index_of_uncontained;
d161 1
a161 1
IA_IntPoint BoxyIPS::index(unsigned idx) const
d170 1
a170 1
	if (IntPointSet::throw_on_index_uncontained)
d180 1
a180 1
unsigned BoxyIPS::card() const
d190 1
a190 1
void BoxyIPS::output(ostream &o, unsigned indent) const
@


1.10
log
@Convert BaseIPS to IA_BasePS<IA_IntPoint>
@
text
@a1 1
static char rcsid[] = "$Id: BoxyIPS.c,v 1.9 93/04/17 15:19:54 thoth Exp Locker: thoth $";
d3 9
d14 3
@


1.9
log
@IA_IntPoint upgrades (dim, inf, sup)
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: BoxyIPS.c,v 1.8 93/04/16 15:50:02 thoth Exp Locker: thoth $";
d6 3
d50 1
a50 1
: BaseIPS(p1.dim())
d98 1
a98 1
: BaseIPS(bps.dimen),
d104 1
a104 1
int BoxyIPS::equal(BaseIPS * psb) const
@


1.8
log
@use IA_IntPoint instead of IntPoint.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: BoxyIPS.c,v 1.7 92/12/16 14:47:56 thoth Exp Locker: thoth $";
d6 3
d47 1
a47 1
: BaseIPS(p1.dimensions())
d50 1
a50 1
    if (p1.dimensions()==0) {
d55 1
a55 1
    if (p1.dimensions() != p2.dimensions()) {
d64 2
a65 2
    start = ::infimum(p1,p2);
    end = ::supremum(p1,p2);
@


1.7
log
@conversion to IA_ mostly complete
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: BoxyIPS.c,v 1.6 92/12/07 12:04:32 thoth Exp Locker: thoth $";
d6 3
d43 1
a43 1
BoxyIPS::IA_BoxyIPS(const IntPoint& p1, const IntPoint& p2)
d122 1
a122 1
int BoxyIPS::contains(const IntPoint &ip) const
d127 1
a127 1
unsigned BoxyIPS::index(const IntPoint &ip) const
d143 1
a143 1
IntPoint BoxyIPS::index(unsigned idx) const
d155 1
a155 1
	return IntPoint();
d158 1
a158 1
	return IntPoint(rval, dimen, 1);
@


1.6
log
@new IntPoint index(unsigned) operation for use with "other" iterators.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: BoxyIPS.c,v 1.5 92/09/30 10:26:47 thoth Exp Locker: thoth $";
d6 3
d35 2
d40 1
a40 1
BoxyIPS::BoxyIPS(const IntPoint& p1, const IntPoint& p2)
d88 1
a88 1
BoxyIPS::BoxyIPS(const BoxyIPS& bps)
@


1.5
log
@contains now accepts const Point<>&
type() system now based on address of static data member
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: BoxyIPS.c,v 1.4 92/09/20 14:04:48 thoth Exp Locker: thoth $";
d6 4
d129 1
a129 1
	offset *= this->end[i] - this->start[i] +1;
d135 19
d159 1
a159 1
	size *= this->end[idx] - this->start[idx] +1;
@


1.4
log
@new infimum and supremum methods for point sets.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: BoxyIPS.c,v 1.3 92/09/03 13:31:04 thoth Exp Locker: thoth $";
d6 3
d22 1
d28 1
a28 1
#include "IntPointSet.h"
d88 1
a88 1
    return psb->type() == BOXY &&
d110 1
a110 1
int BoxyIPS::contains(IntPoint ip) const
@


1.3
log
@hash_self now deals with unsigneds
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: BoxyIPS.C,v 1.2 92/08/26 13:42:26 thoth Exp Locker: thoth $";
d5 4
a8 1
// $Log:	BoxyIPS.C,v $
d44 4
d60 1
@


1.2
log
@meaningful exception types
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: BoxyIPS.C,v 1.1 92/08/23 13:29:54 thoth Exp Locker: thoth $";
d6 3
d80 1
a80 1
int BoxyIPS::hash_self(int modulus) const
@


1.1
log
@Initial revision
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: BoxyIPS.cc,v 1.5 92/08/20 11:08:59 thoth Exp $";
d5 3
a7 1
// $Log:	BoxyIPS.cc,v $
d9 1
d25 1
a25 1
    if (p1.dimensions()==0 || p1.dimensions() != p2.dimensions())
d27 2
d30 5
d104 1
a104 1
	    ia_throw(IA::INVALID_OPERATION, __FILE__,__LINE__);
@
