head	1.14;
access;
symbols
	bobbase:1.14
	bob:1.14.1
	r2_1:1.12
	r2_0:1.12
	r1_1_beta:1.10
	r1_1_alpha:1.9
	r1_0:1.9
	r0_11:1.9
	r0_10:1.9
	r0_9:1.8
	Eglin_alpha_1:1.5;
locks
	thoth:1.14.1.1
	thoth:1.14; strict;
comment	@//@;


1.14
date	94.11.10.18.39.06;	author ljr;	state Exp;
branches
	1.14.1.1;
next	1.13;

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

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

1.11
date	94.08.17.02.07.58;	author gmt;	state Exp;
branches;
next	1.10;

1.10
date	94.08.04.08.38.13;	author ljr;	state Exp;
branches;
next	1.9;

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

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

1.7
date	93.09.24.14.22.40;	author jnw;	state Exp;
branches;
next	1.6;

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

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

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

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

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

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

1.14.1.1
date	95.01.08.17.24.51;	author thoth;	state Exp;
branches;
next	;


desc
@Initial revision of CFront 3.0.1 compatible version
@


1.14
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: ia.c,v 1.13 1994/11/10 18:33:45 thoth Exp ljr $";
#endif

//
// $Log: ia.c,v $
//Revision 1.13  1994/11/10  18:33:45  thoth
//g++ pragmas
//
//Revision 1.12  1994/08/22  15:07:02  thoth
//stream.h should always be replaced by iostream.h
//cast to int is fine for all compilers.
//
//Revision 1.11  1994/08/17  02:07:58  gmt
//Changed to not include stream.h or iostream.h since ia.h includes
//iostream.h.
//Also, had to do an explicit cast to int when printint an exception
//number.
//(Note: all these changes are for the Mac version.)
//
//Revision 1.10  1994/08/04  08:38:13  ljr
//Changed to #include <iostream.h> instead of <stream.h> with BC++.
//
//Revision 1.9  1994/01/31  16:29:52  thoth
//renaming exit_on_throw.
//adding some convenience functions that make it easy to
//document an internal error or NYI.
//new exceptions for ia_throw.
//new version of ia_throw that takes an object.
//
//Revision 1.8  1993/11/16  13:25:01  thoth
//Add PNM IO error.
//
//Revision 1.7  1993/09/24  14:22:40  jnw
//Added initialization for IA:: class version data members
//
//Revision 1.6  93/09/15  12:23:13  thoth
//Some pointset behavior controls.
//
//Revision 1.5  93/05/26  16:28:11  thoth
//Copyright Notices.
//
//Revision 1.4  93/05/26  16:04:10  thoth
//New Error type for IAAIO
//
//Revision 1.3  92/10/05  16:55:44  jnw
//Added error names
//
//Revision 1.2  92/08/27  15:29:52  jnw
//changed to use <stream.h> rather than <iostream.h>
//Modified another bad comment (gcc-cpp sux)
//
//Revision 1.1  92/08/25  11:30:47  jnw
//Initial revision
//
//

#include <iostream.h>
#include <stdlib.h>

#include "compat.h"
#ifdef IA_PRII
#pragma implementation "ia.h"
#endif
#include "ia.h"

#if 0
/*
// The following array relies on the fact that the enum NONE for the
// enumerated type NumericType in file ``ia.h'',  will be the last of
// the enumerated types, and that the enumerated types  are indexed
// from zero: let (int)NONE == N. Then ContagionTable below is indexed
// over [0..N-1][0..N-1], just what we  want.
//
// Also note that the ContagionTable currently doesn't have any
// entries NONE,  though  this is certainly possible if we get two
// numeric types that are not coercible to a common type, for instance
// RGB colorspace and REAL.
*/
const NumericType IA::ContagionTable[(int)NONE][(int)NONE] = {
    {INTEGER,  RATIONAL,  REAL,    COMPLEX},
    {RATIONAL, RATIONAL,  REAL,    COMPLEX},
    {REAL,     REAL,      REAL,    COMPLEX},
    {COMPLEX,  COMPLEX,   COMPLEX, COMPLEX}
};
#endif

int IA::abort_on_throw = 1;
char IA::throw_on_index_uncontained =1;
const unsigned IA::index_of_uncontained = ~0;
const int IA::major_version_number = IA_MAJOR_VERSION_NUMBER;
const int IA::minor_version_number = IA_MINOR_VERSION_NUMBER;

#if 0
NumericType IA::lowest_type()
{
    return (NumericType) 0;
}

// If result_type is modified to return NONE as a possibility, nearly
// all operators  in Coord.cc (at least) will have to be rewritten.

NumericType IA::result_type (NumericType first, NumericType second)
{
    NumericType   result_type;

    if (first==NONE || second==NONE)
        ia_throw(TYPE_UNSPECIFIED, __FILE__, __LINE__);

    result_type = ContagionTable[first][second];

/*    // Can't happen (yet).
*/

    if (result_type==NONE)
        ia_throw(TYPE_MISMATCH, __FILE__, __LINE__);

    return result_type; // too pascalish :)
}

ostream &operator<<(ostream &stream, NumericType type)
{
    switch (type) {
    case INTEGER:
	stream << "INTEGER";
	break;
    case REAL:
	stream << "REAL";
	break;
    case RATIONAL:
	stream << "RATIONAL";
	break;
    case COMPLEX:
	stream << "COMPLEX";
	break;
    case NONE:
	stream << "NONE";
	break;
    default:
	stream << "Unknown?!";
	break;
    }
    return stream;
}
#endif


VOL_F void IA::internal_error(char *file, int line)
{
    cerr << "IAC++ internal error @@ "
	<< file << ":" << line << ".  Aborting.\n" << flush;
    abort();
}

VOL_F void IA::not_yet_implemented(char *file, int line)
{
    cerr << "IAC++ Error: Feature not yet implemented @@ "
	<< file << ":" << line << ".  Aborting.\n" << flush;
    abort();
}

VOL_F void ia_throw(IA::Error e, char *file, int line)
{
    cerr << "throw: fatal ";
    switch (e) {
	// IA:: is necessary here
    case IA::TYPE_MISMATCH:
	cerr << "Type Mismatch";
	break;
    case IA::TYPE_UNSPECIFIED:
	cerr << "Type Unspecified";
	break;
    case IA::POINT_INDEX_MISMATCH:
	cerr << "Point Index Mismatch";
	break;
    case IA::POINT_UNINITIALIZED:
	cerr << "Point Uninitialized";
	break;
    case IA::POINT_TOO_LARGE:
        cerr << "Result Point has too many dimensions";
        break;
    case IA::INVALID_OPERATION:
	cerr << "Invalid Operation";
	break;
    case IA::PSET_REQUIRE_EXTENSIVE:
	cerr << "Operation requires an extensive PointSet";
	break;
    case IA::PSET_DIMENSION_MISMATCH:
	cerr << "Dimensions of argument PointSets don't match";
	break;
    case IA::PSET_INDEX_UNCONTAINED:
	cerr << "Operation tried to index point not contained in a PointSet";
	break;
    case IA::PSET_SIZE_MISMATCH:
	cerr << "Cardinality of argument PointSet is not correct";
	break;
    case IA::IMAGE_REQUIRE_VALUE:
	cerr << "Operation requires image arguments to have values";
	break;
    case IA::IMAGE_REQUIRE_EXTENSIVE:
	cerr << "Operation requires extensive image arguments";
	break;
    case IA::IMAGE_STRUCTURE_NOT_SUPPORTED:
	cerr << "Operation is undefined on images with the specified structure";
	break;
    case IA::PSET_MISMATCH:
	cerr << "Operation is defined only with exactly matching PointSets";
	break;
    case IA::IMAGE_DOMAIN_ERROR:
	cerr << "Operation attempted to find a point not in an image's domain";
	break;
    case IA::IMAGE_REQUIRE_VALUE_ITER:
	cerr << "Operation requires an image value iterator";
	break;
    case IA::IMAGE_REQUIRE_PIXEL_ITER:
	cerr << "Operation requires an image pixel iterator";
	break;
    case IA::IMAGE_VECTOR_CNSTR_SZMISMATCH:
	cerr << "Vector size mismatch in vector image constructor";
	break;
    case IA::IMAGE_POINT_OUTSIDE_DOMAIN:
	cerr << "Attempt to reference image value outside image domain";
	break;
    case IA::IAAIO_FORMAT_ERROR:
	cerr << "Format error during IAA file I/O";
	break;
    case IA::PNM_IO_ERROR:
	cerr << "Error during PNM file I/O";
	break;
    default:
	cerr << "unnamed exception (" << ( int )e << ")";
	break;
    }
    cerr << " at " << file << ':' << line << ".\n";

    if (IA::abort_on_throw)
	abort();
}

VOL_F void ia_throw(const IA::Exception &e)
{
    e.diagnose(cerr);

    if (IA::abort_on_throw)
	abort();
}

//

ostream &GenericException::diagnose(ostream &o) const
{
    return o << "throw: fatal " << explanation
	<< " at " << filename << ":" << line << ".\n";

}
@


1.14.1.1
log
@Special rand_mod function for use by IA module so we can
easily modify it in one place and affect the entire IAC++
(for porting).
@
text
@d11 1
a11 1
static char rcsid[] = "$Id: ia.c,v 1.14 1994/11/10 18:39:06 ljr Exp thoth $";
a15 3
//Revision 1.14  1994/11/10  18:39:06  ljr
//Added IA_NO_RCS_STATIC_DATA guard.
//
a68 1
#include <rand48.h>
a170 1
#if 0
a247 1
#endif
a263 7
}

//

int IA::rand_mod(int modulus)
{
    return lrand48()%modulus;
@


1.13
log
@g++ pragmas
@
text
@d8 1
d11 2
a12 1
static char rcsid[] = "$Id: ia.c,v 1.12 1994/08/22 15:07:02 thoth Exp thoth $";
d16 3
@


1.12
log
@stream.h should always be replaced by iostream.h
cast to int is fine for all compilers.
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: ia.c,v 1.11 1994/08/17 02:07:58 gmt Exp thoth $";
d14 4
d64 5
@


1.11
log
@Changed to not include stream.h or iostream.h since ia.h includes
iostream.h.
Also, had to do an explicit cast to int when printint an exception
number.
(Note: all these changes are for the Mac version.)
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: ia.c,v 1.10 1994/08/04 08:38:13 ljr Exp gmt $";
d14 7
a57 1
#ifdef __BCPLUSPLUS__
a58 3
#elif !defined __SC__
#include <stream.h>
#endif
a225 1
#ifdef __SC__
a226 3
#else
	cerr << "unnamed exception (" << e << ")";
#endif
@


1.10
log
@Changed to #include <iostream.h> instead of <stream.h> with BC++.
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: ia.c,v 1.9 1994/01/31 16:29:52 thoth Exp ljr $";
d14 3
d53 1
a53 1
#else
d223 3
d227 1
@


1.9
log
@renaming exit_on_throw.
adding some convenience functions that make it easy to
document an internal error or NYI.
new exceptions for ia_throw.
new version of ia_throw that takes an object.
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: ia.c,v 1.8 1993/11/16 13:25:01 thoth Exp thoth $";
d14 7
d48 3
d52 1
d62 1
a62 1
// over [0..N-1][0..N-1], just what we  want. 
d70 4
a73 4
    {INTEGER,  RATIONAL,  REAL,    COMPLEX},   
    {RATIONAL, RATIONAL,  REAL,    COMPLEX},   
    {REAL,     REAL,      REAL,    COMPLEX},   
    {COMPLEX,  COMPLEX,   COMPLEX, COMPLEX}    
d93 1
a93 1
{    
d95 1
a95 1
    
@


1.8
log
@Add PNM IO error.
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: ia.c,v 1.7 1993/09/24 14:22:40 jnw Exp thoth $";
d14 3
d66 1
a66 1
int IA::exit_on_throw = 1;
d126 14
d196 6
d214 19
a232 2
    if (IA::exit_on_throw)
	exit(IA::exit_on_throw);
@


1.7
log
@Added initialization for IA:: class version data members
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: ia.c,v 1.6 93/09/15 12:23:13 thoth Exp Locker: jnw $";
d13 4
a16 1
// $Log:	ia.c,v $
d179 1
a179 1
      case IA::IAAIO_FORMAT_ERROR:
d181 3
@


1.6
log
@Some pointset behavior controls.
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: ia.c,v 1.5 93/05/26 16:28:11 thoth Exp Locker: thoth $";
d14 3
d63 2
@


1.5
log
@Copyright Notices.
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: ia.c,v 1.4 93/05/26 16:04:10 thoth Exp Locker: thoth $";
d14 3
d58 2
@


1.4
log
@New Error type for IAAIO
@
text
@a1 1
static char rcsid[] = "$Id: ia.c,v 1.3 92/10/05 16:55:44 jnw Exp Locker: thoth $";
d4 9
d14 3
@


1.3
log
@Added error names
@
text
@d1 2
a2 1
static char rcsid[] = "$Id: ia.c,v 1.2 92/08/27 15:29:52 jnw Exp Locker: jnw $";
d6 3
d154 3
@


1.2
log
@changed to use <stream.h> rather than <iostream.h>
Modified another bad comment (gcc-cpp sux)
@
text
@d1 1
a1 1
static char rcsid[] = "$Id: ia.C,v 1.1 92/08/25 11:30:47 jnw Exp Locker: jnw $";
d4 5
a8 1
// $Log:	ia.C,v $
d118 33
d152 1
a152 1
	cerr << "unnamed exception";
@


1.1
log
@Initial revision
@
text
@d1 1
a1 1
static char rcsid[] = "$Id$";
d4 3
a6 1
// $Log$
d8 1
d10 1
a10 1
#include <iostream.h>
d15 1
d26 1
a26 1

d55 2
a56 1
    // Can't happen (yet).
@
