head	1.45;
access;
symbols
	bobbase:1.41
	bob:1.41.1
	r2_1:1.35
	r2_0:1.35
	r1_1_beta:1.34
	r1_1_alpha:1.33
	r1_0:1.33
	r0_11:1.32
	r0_10:1.30
	r0_9:1.29
	Eglin_alpha_1:1.24;
locks; strict;
comment	@// @;


1.45
date	94.12.08.19.23.21;	author fjsoria;	state Exp;
branches;
next	1.44;

1.44
date	94.12.03.04.17.17;	author fjsoria;	state Exp;
branches;
next	1.43;

1.43
date	94.12.03.03.21.10;	author fjsoria;	state Exp;
branches;
next	1.42;

1.42
date	94.12.01.22.05.59;	author fjsoria;	state Exp;
branches;
next	1.41;

1.41
date	94.11.10.19.53.56;	author ljr;	state Exp;
branches
	1.41.1.1;
next	1.40;

1.40
date	94.11.10.18.50.09;	author fjsoria;	state Exp;
branches;
next	1.39;

1.39
date	94.11.03.18.39.46;	author fjsoria;	state Exp;
branches;
next	1.38;

1.38
date	94.10.06.17.39.00;	author fjsoria;	state Exp;
branches;
next	1.37;

1.37
date	94.09.27.20.47.09;	author fjsoria;	state Exp;
branches;
next	1.36;

1.36
date	94.09.13.19.10.59;	author ljr;	state Exp;
branches;
next	1.35;

1.35
date	94.08.18.23.38.01;	author thoth;	state Exp;
branches;
next	1.34;

1.34
date	94.07.25.16.58.52;	author thoth;	state Exp;
branches;
next	1.33;

1.33
date	94.05.08.19.35.40;	author thoth;	state Exp;
branches;
next	1.32;

1.32
date	94.04.26.18.13.57;	author thoth;	state Exp;
branches;
next	1.31;

1.31
date	94.03.14.15.38.32;	author thoth;	state Exp;
branches;
next	1.30;

1.30
date	94.01.31.16.37.35;	author thoth;	state Exp;
branches;
next	1.29;

1.29
date	93.11.17.18.03.47;	author thoth;	state Exp;
branches;
next	1.28;

1.28
date	93.10.20.15.50.54;	author thoth;	state Exp;
branches;
next	1.27;

1.27
date	93.09.15.12.36.18;	author thoth;	state Exp;
branches;
next	1.26;

1.26
date	93.08.08.13.17.33;	author thoth;	state Exp;
branches;
next	1.25;

1.25
date	93.07.15.11.45.17;	author thoth;	state Exp;
branches;
next	1.24;

1.24
date	93.05.28.15.05.29;	author thoth;	state Exp;
branches;
next	1.23;

1.23
date	93.05.26.16.57.46;	author thoth;	state Exp;
branches;
next	1.22;

1.22
date	93.05.19.14.44.37;	author thoth;	state Exp;
branches;
next	1.21;

1.21
date	93.04.29.12.50.41;	author thoth;	state Exp;
branches;
next	1.20;

1.20
date	93.04.19.23.27.40;	author thoth;	state Exp;
branches;
next	1.19;

1.19
date	93.04.17.15.19.51;	author thoth;	state Exp;
branches;
next	1.18;

1.18
date	93.04.16.15.50.18;	author thoth;	state Exp;
branches;
next	1.17;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1.41.1.1
date	94.11.21.19.41.56;	author thoth;	state Exp;
branches;
next	;


desc
@CFrontified version
@


1.45
log
@removed PS_Specials.c and put static data code for
double's point and set in here.
@
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: IntPS.c,v 1.44 1994/12/03 04:17:17 fjsoria Exp fjsoria $";
#endif

//
// $Log: IntPS.c,v $
// Revision 1.44  1994/12/03  04:17:17  fjsoria
// changed pointset_erros.h to pset_errors.h
//
// Revision 1.43  1994/12/03  03:21:10  fjsoria
// fixing my screwup with the hash_managed_delete fix
// this is the correct code (cross the fingers and squeeze tight)
//
// Revision 1.41  1994/11/10  19:53:56  ljr
// Added IA_NO_RCS_STATIC_DATA guard.
//
// Revision 1.40  1994/11/10  18:50:09  fjsoria
// *** empty log message ***
//
// Revision 1.39  1994/11/03  18:39:46  fjsoria
// *** empty log message ***
//
// Revision 1.38  1994/10/06  17:39:00  fjsoria
// commented rscid[] line
//
// Revision 1.37  1994/09/27  20:47:09  fjsoria
// g++ v2.6 does no like n0n-inlined destructors
// added __NO_INLINE_DESTRUCTORS
//
// Revision 1.36  1994/09/13  19:10:59  ljr
// Added workarounds for conditional expressions that create temporaries.
//
// Revision 1.35  1994/08/18  23:38:01  thoth
// DOS-inspired filename rework
//
// Revision 1.34  1994/07/25  16:58:52  thoth
// \Name sanitization
//
// Revision 1.33  1994/05/08  19:35:40  thoth
// New pointset concatenation capability.
// New intpointset decomposition capability.
//
// Revision 1.32  1994/04/26  18:13:57  thoth
// New array constructor that doesn't require dimension.
// White and Black Hole have been renamed to universal and empty _pset
//
// Revision 1.31  1994/03/14  15:38:32  thoth
// Check for errors in translation operation.
//
// Revision 1.30  1994/01/31  16:37:35  thoth
// We now document internal errors when they occur.
// We can now transpose boxy 2D pointsets.
//
// Revision 1.29  1993/11/17  18:03:47  thoth
// IPSIter is now PSIter<IntPoint>
// Pointcmp is now pointcmp
// extensivep() is now extensive()
//
// Revision 1.28  1993/10/20  15:50:54  thoth
// New naming scheme.  Closures are named Closure.
//
// Revision 1.27  1993/09/15  12:36:18  thoth
// Pointset behavior controls have moved to IA::
//
// Revision 1.26  93/08/08  13:17:33  thoth
// Parametrization of the pointsets on the point type using
// template specialization.
//
// Revision 1.25  93/07/15  11:45:17  thoth
// new lookup_and_set allows other classes (such as BasePSIter)
// to cooperate in refcounting the BasePSs.
//
// Revision 1.24  93/05/28  15:05:29  thoth
// removed dependency on with-ia-pointset*
//
// Revision 1.23  93/05/26  16:57:46  thoth
// Copyright Notices
//
// Revision 1.22  93/05/19  14:44:37  thoth
// LatticeRelation is now in IA::
//
// Revision 1.21  93/04/29  12:50:41  thoth
// Mondo PointSets are now templatized.
//
// Revision 1.20  93/04/19  23:27:40  thoth
// Convert BaseIPS to IA_BasePS<IA_IntPoint>
//
// Revision 1.19  93/04/17  15:19:51  thoth
// IA_IntPoint upgrades (dim, inf, sup)
//
// Revision 1.18  93/04/16  15:50:18  thoth
// use IA_IntPoint instead of IntPoint.
//
// Revision 1.17  93/02/12  16:23:41  thoth
// more IA_ prefixes.
// Removed #if 0 cruft.
// comp undefined bug is now gone from CFront
//
// Revision 1.16  93/01/20  11:36:18  thoth
// new PredicatePS class to allow for families of comprehensive pointsets.
//
// Revision 1.15  92/12/16  14:48:09  thoth
// conversion to IA_ mostly complete
//
// Revision 1.14  92/12/15  21:16:21  thoth
// added boxy predicate method.
//
// Revision 1.13  92/11/11  12:11:46  thoth
// added another restriction utility.
//
// Revision 1.12  92/11/04  11:58:51  thoth
// New union_with_structure function for image extension.
//
// Revision 1.11  92/10/25  20:53:24  thoth
// changed argument passing on set restriction routines.
//
// Revision 1.10  92/10/22  15:11:13  thoth
// lazy comparison handling (untested)
// pointset restriction utilities.
//
// Revision 1.9  92/10/07  23:15:31  thoth
// trim gratuitous includes from public headers.
// boxy boxy intersect should now be faster.
//
// Revision 1.8  92/09/30  10:30:52  thoth
// Lazies are now templatized.
// White and Black holes are now semi-public classes, unfortunately.
// reference counts are protected from IntPointSet, unfortunately.
// type() system now based on address of static data member.
//
// Revision 1.7  92/09/20  17:38:44  thoth
// Minkowski addition of point sets now supported.
//
// Revision 1.6  92/09/14  21:56:27  thoth
// the IntPointSet is now responsible for deleting hashed pointers.
// dimension is now a parameter to the IntPoint array constructor.
// added special code for ext/comp difference.
//
// Revision 1.5  92/09/07  13:21:31  thoth
// Black and White holes can be extensive
// |&^/ operators are now friends.
// intersection has untested code to handle comp&ext
//
// Revision 1.4  92/09/03  13:34:27  thoth
// hash_self now deals with unsigneds
// I unnamed unused formal parameters
// lazy point sets now exist
// (but operators & and / need adjustment)
//
// Revision 1.3  92/08/26  13:43:37  thoth
// meaningful exception types
// eliminated dummy parameter to constructor (was workaround for g++)
// aborts are clearly labeled and less common
//
// Revision 1.2  92/08/25  15:28:48  thoth
// new offsetted virtual functions
// new converter from IntPoint to IntPointSet.
// CFront supports agregates in ternary, wheee!
// set difference is operator/, not -
// operator+ is set translation, using the offsetted() function of BaseIPS
// lattice operations on sets defined in terms of compare() friend
//
// Revision 1.1  92/08/23  13:30:13  thoth
// Initial revision
//
//

#ifdef IA_PRI
#pragma implementation "IntPS.h"
#endif

#include <stdlib.h>
#include "IntPS.h"
#include "HashTable.h"
#include "PSIter.h"
#include "SetStructure.h"

#include "pset_errors.h"
#include "BasePS.h"
#include "BoxyIPS.h"
#include "YoderIPS.h"
#include "LazyPS.h"
#include "MondoPS.h"
#include "ClosurePS.h"

IA_HashTable * IA_Set<IA_Point<int> >::hash_table;

int IA_IPS_HT_initter::count;

IA_IPS_HT_initter::IA_IPS_HT_initter()
{
    if (count++ == 0) {
	IA_Set<IA_Point<int> >::hash_table = new IA_HashTable;
    }
}

IA_IPS_HT_initter::~IA_IPS_HT_initter()
{
    if (--count == 0) {
	delete IA_Set<IA_Point<int> >::hash_table;
	IA_Set<IA_Point<int> >::hash_table = 0;
    }
}

void IA_Set<IA_Point<int> >::lookup_and_set(IA_BasePS<IA_Point<int> > *ips)
{
    if (hash_table->reference(ips, &this->ps)) {
	ips->enref();
	if (ips->unref()<=0)
	    delete ips;
    } else {
	// ips->refcount=0;
    }

    ps->enref();
}

void IA_Set<IA_Point<int> >::disassociate_ps()
{
    hash_managed_delete(ps);
    ps=0;
}

IA_Set<IA_Point<int> >::IA_Set()
{
    this->lookup_and_set(new IA_BlackHole_<IA_Point<int> >(0));
}

IA_Set<IA_Point<int> >::IA_Set(IA::Type t, unsigned dim)
{
    if (t == IA_WhiteHole_<IA_Point<int> >::s_type())
	this->lookup_and_set(new IA_WhiteHole_<IA_Point<int> >(dim));
    else if (t == IA_BlackHole_<IA_Point<int> >::s_type())
	this->lookup_and_set(new IA_BlackHole_<IA_Point<int> >(dim));
    else {
	ia_throw(IA::TYPE_MISMATCH, __FILE__, __LINE__);
	this->lookup_and_set(new IA_BlackHole_<IA_Point<int> >(0));
    }
}

IA_Set<IA_Point<int> >::IA_Set(const IA_Point<int>& p)
{
    this->lookup_and_set(new IA_BoxyIPS(p, p));
}

IA_Set<IA_Point<int> >::IA_Set(const IA_Point<int>& p0, const IA_Point<int>& p1)
{
    this->lookup_and_set(new IA_BoxyIPS(p0, p1));
}

IA_Set<IA_Point<int> >::IA_Set(unsigned dimen, int(*f)(IA_Point<int>)) {
    this->lookup_and_set(new IA_PredicatePS_V<IA_Point<int> >(dimen, f));
}

IA_Set<IA_Point<int> >::IA_Set(unsigned dimen, int(*f)(const IA_Point<int>&)) {
    this->lookup_and_set(new IA_PredicatePS_CR<IA_Point<int> >(dimen, f));
}

IA_Set<IA_Point<int> >::IA_Set(const IA_ClosurePS<IA_Point<int> >&ps)
{
    this->lookup_and_set(ps.clone_self());
}

IA_Set<IA_Point<int> >::IA_Set(const IA_BoxyIPS& bps)
{
    this->lookup_and_set(new IA_BoxyIPS(bps));
}

IA_Set<IA_Point<int> >::IA_Set(const IA_YoderIPS& yps)
{
    if (yps.isboxy()){
	if (yps.nslices<1) {
	    // We've got a black hole which is, of course, boxy
	    this->lookup_and_set(new  IA_BlackHole_<IA_Point<int> >(yps.dimen));
	} else {
	    this->lookup_and_set(new IA_BoxyIPS(yps.min(), yps.max()));
	}
    } else this->lookup_and_set(new IA_YoderIPS(yps));
}


extern "C"
/*static*/ int ipcmp(const void *a, const void *b)
{
  return pointcmp(*(IA_Point<int>*)a,*(IA_Point<int>*)b);
}

IA_Set<IA_Point<int> >::IA_Set(unsigned dimen, const IA_Point<int> *aip, unsigned len)
{
    if (len<1) {
	this->lookup_and_set(new IA_BlackHole_<IA_Point<int> >(dimen));
	return;
    }

    for (unsigned i=0; i<len; i++) {
	if (aip[i].dim() != dimen) {
	    ia_throw(IA::PSET_DIMENSION_MISMATCH, __FILE__, __LINE__);
	    this->lookup_and_set(new IA_BlackHole_<IA_Point<int> >(0));
	    return;
	}
    }

    if (dimen<1) {
	if (len>0)
	    this->lookup_and_set(new IA_WhiteHole_<IA_Point<int> >(0));
	else
	    this->lookup_and_set(new IA_BlackHole_<IA_Point<int> >(0));
	return;
    }

    for (i=0; i+1<len; i++) {
	if (pointcmp(aip[i],aip[i+1]) ==1)
	    break;
    }

    IA_Point<int>	*newaip;
    if (i+1<len) {
	newaip = new IA_Point<int>[len];
	for (i=0; i<len; i++)
	    newaip[i] = aip[i];
	SortIntPointArray(newaip, len);
#if 0
	cout << "sorting array\n" << flush;
	for (i=0; i<len; i++)
	    cout << newaip[i] << ' ';
	cout << '\n';
#endif
    } else
	newaip = (IA_Point<int>*)aip;

    IA_YoderIPS *temp = new IA_YoderIPS(newaip, len);
    if (temp->isboxy()) {
	if (temp->nslices<1)
	    this->lookup_and_set(new IA_BlackHole_<IA_Point<int> >(temp->dimen));
	else
	    this->lookup_and_set(new IA_BoxyIPS(temp->min(), temp->max()));
	delete temp;
    } else
	this->lookup_and_set(temp);

    if (newaip!=aip)
	delete [] newaip;
}

IA_Set<IA_Point<int> >::IA_Set(const IA_Point<int> *aip, unsigned len)
{
    if (len<1) {
	ia_throw(Pointset_EmptyPointArray_Exception(__FILE__, __LINE__));
	this->lookup_and_set(new IA_BlackHole_<IA_Point<int> >(0));
	return;
    }

    const unsigned dimen = aip[0].dim();

    for (unsigned i=1; i<len; i++) {
	if (aip[i].dim() != dimen) {
	    ia_throw(IA::PSET_DIMENSION_MISMATCH, __FILE__, __LINE__);
	    this->lookup_and_set(new IA_BlackHole_<IA_Point<int> >(0));
	    return;
	}
    }

    if (dimen<1) {
	if (len>0)
	    this->lookup_and_set(new IA_WhiteHole_<IA_Point<int> >(0));
	else
	    this->lookup_and_set(new IA_BlackHole_<IA_Point<int> >(0));
	return;
    }

    for (i=0; i+1<len; i++) {
	if (pointcmp(aip[i],aip[i+1]) ==1)
	    break;
    }

    IA_Point<int
>	*newaip;
    if (i+1<len) {
	newaip = new IA_Point<int>[len];
	for (i=0; i<len; i++)
	    newaip[i] = aip[i];
	SortIntPointArray(newaip, len);
#if 0
	cout << "sorting array\n" << flush;
	for (i=0; i<len; i++)
	    cout << newaip[i] << ' ';
	cout << '\n';
#endif
    } else
	newaip = (IA_Point<int>*)aip;

    IA_YoderIPS *temp = new IA_YoderIPS(newaip, len);
    if (temp->isboxy()) {
	if (temp->nslices<1)
	    this->lookup_and_set(new IA_BlackHole_<IA_Point<int> >(temp->dimen));
	else
	    this->lookup_and_set(new IA_BoxyIPS(temp->min(), temp->max()));
	delete temp;
    } else
	this->lookup_and_set(temp);

    if (newaip!=aip)
	delete [] newaip;
}

#ifndef __NO_OUTLINE_DESTRUCTORS
IA_Set<IA_Point<int> >::~IA_Set()
{
    if (ps==0) {
	cerr << "Internal Error: pointset destructed twice!\n";
	return;
    }
    this->disassociate_ps();
    ps = 0;
}
#endif

IA_Set<IA_Point<int> >& IA_Set<IA_Point<int> >::operator=(const IA_Set<IA_Point<int> > &ips)
{ 
    IA_BasePS<IA_Point<int> >	*temp;
    temp = ips.ps;
    temp->enref();
    this->disassociate_ps();
    ps = temp;

    return *this;
}

int IA_Set<IA_Point<int> >::boxy() const
{
    return ps->type() == IA_BoxyIPS::s_type();
}

void IA_Set<IA_Point<int> >::print_hashtable(ostream &o)
{
    hash_table->print(o);
}

IA_Set<IA_Point<int> > operator|(const IA_Set<IA_Point<int> >& lhs,const IA_Set<IA_Point<int> > &rhs)
{
    if (lhs.dim() != rhs.dim()) {
	// need better message
	// cout << lhs.dim() << "!=" << rhs.dim() << '\n' << flush;
	ia_throw(IA::PSET_DIMENSION_MISMATCH, __FILE__, __LINE__);
	return IA_Set<IA_Point<int> >();
    }

    if (lhs.ps->type() == IA_BlackHole_<IA_Point<int> >::s_type())
	return rhs;
    if (lhs.ps->type() == IA_WhiteHole_<IA_Point<int> >::s_type())
	return lhs;

    if (rhs.ps->type() == IA_BlackHole_<IA_Point<int> >::s_type())
	return lhs;
    if (rhs.ps->type() == IA_WhiteHole_<IA_Point<int> >::s_type())
	return rhs;

    if (lhs.extensive() && rhs.extensive()) {

// the code enclosed by the following if block is obsolete
#if 0
	YoderIPS	*left, *right;
	switch (lhs.ps->type()) {
	case BOXY:
	    left = new YoderIPS(*(BoxyIPS*)lhs.ps);
	    break;
	case YODER:
	    left = (YoderIPS*)lhs.ps;
	    break;
	default:
	    // the other extensive pointsets were taken care of before.
	    IA::internal_error(__FILE__,__LINE__);
	    break;
	}

	switch (rhs.ps->type()) {
	case BOXY:
	    right = new YoderIPS(*(BoxyIPS*)rhs.ps);
	    break;
	case YODER:
	    right = (YoderIPS*)rhs.ps;
	    break;
	default:
	    // the other extensive pointsets were taken care of before.
	    IA::internal_error(__FILE__,__LINE__);
	    break;
	}

	YoderIPS result( *left | *right );

	if (left != lhs.ps)
	    delete left;
	if (right != rhs.ps)
	    delete right;
#endif

#ifdef IA_NO_TEMPS_IN_CONDITIONAL_EXPRS
    IA_YoderIPS *left, *right;

    if (lhs.ps->type()==IA_BoxyIPS::s_type())
        left = new IA_YoderIPS(*(IA_BoxyIPS*)lhs.ps);
    else
        left = (IA_YoderIPS*)lhs.ps;

    if (rhs.ps->type()==IA_BoxyIPS::s_type())
        right = new IA_YoderIPS(*(IA_BoxyIPS*)rhs.ps);
    else
        right = (IA_YoderIPS*)rhs.ps;

    IA_YoderIPS result( *left | *right );

    if (left != lhs.ps)
        delete left;
    if (right != rhs.ps)
        delete right;
#else
	IA_YoderIPS result
	  ( ( (lhs.ps->type()==IA_BoxyIPS::s_type()) ?
	     IA_YoderIPS(*(IA_BoxyIPS*)lhs.ps) :
	     *(IA_YoderIPS*)lhs.ps )
	   |
	   ( (rhs.ps->type()==IA_BoxyIPS::s_type()) ?
	    IA_YoderIPS(*(IA_BoxyIPS*)rhs.ps) :
	    *(IA_YoderIPS*)rhs.ps )
	   );
#endif
	// this constructor checks for emptiness and boxiness
	return IA_Set<IA_Point<int> >(result);
    } else {
	return new IA_LazyUnionPS<IA_Set<IA_Point<int> >,IA_Point<int> >(lhs, rhs);
    }
}

//

// intersect an extensive point set with a comprehensive one
// precondition:
// ext.extensive() ==1
// ext.dim() == comp.dim()
IA_Set<IA_Point<int> > ext_comp_intersect(const IA_Set<IA_Point<int> > &ext, const IA_Set<IA_Point<int> > &comp)
{
    IA_PSIter<IA_Point<int> >	iter(ext);
    IA_Point<int>	ip;

    IA_Point<int>	*arr=new IA_Point<int>[ext.card()];
    unsigned	count=0;

    while (iter(ip)) {
	if (comp.contains(ip)) {
	    arr[count++] = ip;
	}
    }

    return IA_Set<IA_Point<int> >(ext.dim(), arr,count);
}

IA_Set<IA_Point<int> > operator&(const IA_Set<IA_Point<int> >& lhs, const IA_Set<IA_Point<int> > &rhs)
{
    if (lhs.dim() != rhs.dim()) {
	// need better message
	ia_throw(IA::PSET_DIMENSION_MISMATCH, __FILE__, __LINE__);
	return IA_Set<IA_Point<int> >();
    }

    if (lhs.ps->type()==IA_BlackHole_<IA_Point<int> >::s_type())
	return lhs;
    if (lhs.ps->type()==IA_WhiteHole_<IA_Point<int> >::s_type())
	return rhs;

    if (rhs.ps->type()==IA_BlackHole_<IA_Point<int> >::s_type())
	return rhs;
    if (rhs.ps->type()==IA_WhiteHole_<IA_Point<int> >::s_type())
	return lhs;

    int lext, rext;
    lext = lhs.extensive();
    rext = rhs.extensive();
    if (lext && rext) {
	if (lhs.ps->type()==IA_BoxyIPS::s_type() &&
	    rhs.ps->type()==IA_BoxyIPS::s_type() ) {
	    IA_Point<int>	bottom(sup(lhs.ps->inf(), rhs.ps->inf()));
	    IA_Point<int>	top(inf (lhs.ps->sup(), rhs.ps->sup()));
	    if (bottom<=top)
		return IA_Set<IA_Point<int> >(bottom, top);
	    else
		return new IA_BlackHole_<IA_Point<int> >(lhs.dim());
	} else {
#ifdef IA_NO_TEMPS_IN_CONDITIONAL_EXPRS
       IA_YoderIPS *left, *right;

       if (lhs.ps->type()==IA_BoxyIPS::s_type())
           left = new IA_YoderIPS(*(IA_BoxyIPS*)lhs.ps);
       else
           left = (IA_YoderIPS*)lhs.ps;

       if (rhs.ps->type()==IA_BoxyIPS::s_type())
           right = new IA_YoderIPS(*(IA_BoxyIPS*)rhs.ps);
       else
           right = (IA_YoderIPS*)rhs.ps;

       IA_YoderIPS result(*left & *right);

       if (left != lhs.ps)
           delete left;
       if (right != rhs.ps)
           delete right;
#else
	    IA_YoderIPS result
		( ( (lhs.ps->type()==IA_BoxyIPS::s_type()) ?
		    IA_YoderIPS(*(IA_BoxyIPS*)lhs.ps) :
		    *(IA_YoderIPS*)lhs.ps )
		  &
		  ( (rhs.ps->type()==IA_BoxyIPS::s_type()) ?
		    IA_YoderIPS(*(IA_BoxyIPS*)rhs.ps) :
		    *(IA_YoderIPS*)rhs.ps )
		  );
#endif
	    return IA_Set<IA_Point<int> >(result);
	}
    } else if (lext) {
	return ext_comp_intersect(lhs, rhs);
    } else if (rext) {
	return ext_comp_intersect(rhs, lhs);
    } else {
	return new IA_LazyIntersectionPS<IA_Set<IA_Point<int> >,IA_Point<int> >(lhs,rhs);
    }
}


IA_Set<IA_Point<int> > intersect_with_structure
(const IA_Set<IA_Point<int> > &lhs, const IA_Set<IA_Point<int> > &rhs, IA_SetStructure *result)
{
    if (lhs.dim() != rhs.dim()) {
	// need better message
	ia_throw(IA::PSET_DIMENSION_MISMATCH, __FILE__, __LINE__);
	return IA_Set<IA_Point<int> >();
    }

    if (lhs.ps->type()==IA_BlackHole_<IA_Point<int> >::s_type()) {
	return lhs;
    }
    if (lhs.ps->type()==IA_WhiteHole_<IA_Point<int> >::s_type()) {
	*result = (rhs.ps->type()==IA_WhiteHole_<IA_Point<int> >::s_type())
	    ? IA_SetStructure::BOTH
	    : IA_SetStructure::FIRST_ONLY;
	return rhs;
    }

    if (rhs.ps->type()==IA_BlackHole_<IA_Point<int> >::s_type()) {
	result->add_interval(lhs.card(), IA_SetStructure::FIRST_ONLY);
	return rhs;
    }
    if (rhs.ps->type()==IA_WhiteHole_<IA_Point<int> >::s_type()) {
	result->add_interval(lhs.card(), IA_SetStructure::BOTH);
	return lhs;
    }

    if (!lhs.extensive()) {
	// not rational
	return lhs & rhs;
    }

    if (!rhs.extensive()) {
	// deal with this later
	return lhs & rhs;
    }

#ifdef IA_NO_TEMPS_IN_CONDITIONAL_EXPRS
    IA_YoderIPS *left, *right;

    if (lhs.ps->type()==IA_BoxyIPS::s_type())
        left = new IA_YoderIPS(*(IA_BoxyIPS*)lhs.ps);
    else
        left = (IA_YoderIPS*)lhs.ps;

    if (rhs.ps->type()==IA_BoxyIPS::s_type())
        right = new IA_YoderIPS(*(IA_BoxyIPS*)rhs.ps);
    else
        right = (IA_YoderIPS*)rhs.ps;

    IA_Set<IA_Point<int> > retval((*left).intersect_with_structure(*right, result));

    if (left != lhs.ps)
        delete left;
    if (right != rhs.ps)
        delete right;

    return retval;
#else
    return ( (lhs.ps->type()==IA_BoxyIPS::s_type()) ?
	     IA_YoderIPS(*(IA_BoxyIPS*)lhs.ps) :
	     *(IA_YoderIPS*)lhs.ps ). intersect_with_structure(
		 ( (rhs.ps->type()==IA_BoxyIPS::s_type()) ?
		   IA_YoderIPS(*(IA_BoxyIPS*)rhs.ps) :
		   *(IA_YoderIPS*)rhs.ps ),
		 result);
#endif
}

IA_Set<IA_Point<int> > intersect_with_dualstruct
(const IA_Set<IA_Point<int> > &lhs, const IA_Set<IA_Point<int> > &rhs, IA_SetStructure *result)
{
    if (lhs.dim() != rhs.dim()) {
	// need better message
	ia_throw(IA::PSET_DIMENSION_MISMATCH, __FILE__, __LINE__);
	return IA_Set<IA_Point<int> >();
    }

    if (lhs.ps->type()==IA_BlackHole_<IA_Point<int> >::s_type()) {
	result->add_interval(rhs.card(), IA_SetStructure::SECOND_ONLY);
	return lhs;
    }
    if (lhs.ps->type()==IA_WhiteHole_<IA_Point<int> >::s_type()) {
	*result = (rhs.ps->type()==IA_WhiteHole_<IA_Point<int> >::s_type())
	    ? IA_SetStructure::BOTH
	    : IA_SetStructure::FIRST_ONLY;
	return rhs;
    }

    if (rhs.ps->type()==IA_BlackHole_<IA_Point<int> >::s_type()) {
	result->add_interval(lhs.card(), IA_SetStructure::FIRST_ONLY);
	return rhs;
    }
    if (rhs.ps->type()==IA_WhiteHole_<IA_Point<int> >::s_type()) {
	result->add_interval(lhs.card(), IA_SetStructure::BOTH);
	return lhs;
    }

    if (!lhs.extensive()) {
	// not rational
	return lhs & rhs;
    }

    if (!rhs.extensive()) {
	// deal with this later
	return lhs & rhs;
    }

#ifdef IA_NO_TEMPS_IN_CONDITIONAL_EXPRS
    IA_YoderIPS *left, *right;

    if (lhs.ps->type()==IA_BoxyIPS::s_type())
        left = new IA_YoderIPS(*(IA_BoxyIPS*)lhs.ps);
    else
        left = (IA_YoderIPS*)lhs.ps;

    if (rhs.ps->type()==IA_BoxyIPS::s_type())
        right = new IA_YoderIPS(*(IA_BoxyIPS*)rhs.ps);
    else
        right = (IA_YoderIPS*)rhs.ps;

    IA_Set<IA_Point<int> > retval((*left).intersect_with_dualstruct(*right, result));

    if (left != lhs.ps)
        delete left;
    if (right != rhs.ps)
        delete right;

    return retval;
#else
    return ( (lhs.ps->type()==IA_BoxyIPS::s_type()) ?
	     IA_YoderIPS(*(IA_BoxyIPS*)lhs.ps) :
	     *(IA_YoderIPS*)lhs.ps ). intersect_with_dualstruct(
		 ( (rhs.ps->type()==IA_BoxyIPS::s_type()) ?
		   IA_YoderIPS(*(IA_BoxyIPS*)rhs.ps) :
		   *(IA_YoderIPS*)rhs.ps ),
		 result);
#endif
}

IA_Set<IA_Point<int> > union_with_structure
(const IA_Set<IA_Point<int> > &lhs, const IA_Set<IA_Point<int> > &rhs, IA_SetStructure *result)
{
    if (lhs.dim() != rhs.dim()) {
	// need better message
	ia_throw(IA::PSET_DIMENSION_MISMATCH, __FILE__, __LINE__);
	return IA_Set<IA_Point<int> >();
    }

    if (lhs.ps->type()==IA_BlackHole_<IA_Point<int> >::s_type()) {
	result->add_interval(rhs.card(), IA_SetStructure::SECOND_ONLY);
	return rhs;
    }
    if (lhs.ps->type()==IA_WhiteHole_<IA_Point<int> >::s_type()) {
	*result = (rhs.ps->type()==IA_WhiteHole_<IA_Point<int> >::s_type())
	    ? IA_SetStructure::BOTH
	    : IA_SetStructure::FIRST_ONLY;
	return lhs;
    }

    if (rhs.ps->type()==IA_BlackHole_<IA_Point<int> >::s_type()) {
	result->add_interval(lhs.card(), IA_SetStructure::FIRST_ONLY);
	return lhs;
    }
    if (rhs.ps->type()==IA_WhiteHole_<IA_Point<int> >::s_type()) {
	*result = (lhs.ps->type()==IA_WhiteHole_<IA_Point<int> >::s_type())
	    ? IA_SetStructure::BOTH
	    : IA_SetStructure::SECOND_ONLY;
	return rhs;
    }

    if (!lhs.extensive() || !rhs.extensive()) {
	return lhs | rhs;
    }

#ifdef IA_NO_TEMPS_IN_CONDITIONAL_EXPRS
    IA_YoderIPS *left, *right;

    if (lhs.ps->type()==IA_BoxyIPS::s_type())
        left = new IA_YoderIPS(*(IA_BoxyIPS*)lhs.ps);
    else
        left = (IA_YoderIPS*)lhs.ps;

    if (rhs.ps->type()==IA_BoxyIPS::s_type())
        right = new IA_YoderIPS(*(IA_BoxyIPS*)rhs.ps);
    else
        right = (IA_YoderIPS*)rhs.ps;

    IA_Set<IA_Point<int> > retval((*left).union_with_structure(*right, result));

    if (left != lhs.ps)
        delete left;
    if (right != rhs.ps)
        delete right;

    return retval;
#else
    return ( (lhs.ps->type()==IA_BoxyIPS::s_type()) ?
	     IA_YoderIPS(*(IA_BoxyIPS*)lhs.ps) :
	     *(IA_YoderIPS*)lhs.ps ). union_with_structure(
		 ( (rhs.ps->type()==IA_BoxyIPS::s_type()) ?
		   IA_YoderIPS(*(IA_BoxyIPS*)rhs.ps) :
		   *(IA_YoderIPS*)rhs.ps ),
		 result);
#endif
}


#if 1
IA_Set<IA_Point<int> > operator^(const IA_Set<IA_Point<int> >& lhs, const IA_Set<IA_Point<int> > &rhs)
{
    if (lhs.dim() != rhs.dim()) {
	// need better message
	// cout << lhs.dim() << "!=" << rhs.dim() << '\n' << flush;
	ia_throw(IA::PSET_DIMENSION_MISMATCH, __FILE__, __LINE__);
	return IA_Set<IA_Point<int> >();
    }

    if (lhs.ps->type()==IA_BlackHole_<IA_Point<int> >::s_type())
	return rhs;
    if (lhs.ps->type()==IA_WhiteHole_<IA_Point<int> >::s_type())
	return ~rhs;

    if (rhs.ps->type()==IA_BlackHole_<IA_Point<int> >::s_type())
	return lhs;
    if (rhs.ps->type()==IA_WhiteHole_<IA_Point<int> >::s_type())
	return ~lhs;

    if (lhs.extensive() && rhs.extensive()) {

#ifdef IA_NO_TEMPS_IN_CONDITIONAL_EXPRS
    IA_YoderIPS *left, *right;

    if (lhs.ps->type()==IA_BoxyIPS::s_type())
        left = new IA_YoderIPS(*(IA_BoxyIPS*)lhs.ps);
    else
        left = (IA_YoderIPS*)lhs.ps;

    if (rhs.ps->type()==IA_BoxyIPS::s_type())
        right = new IA_YoderIPS(*(IA_BoxyIPS*)rhs.ps);
    else
        right = (IA_YoderIPS*)rhs.ps;

    IA_YoderIPS result(*left ^ *right);

    if (left != lhs.ps)
        delete left;
    if (right != rhs.ps)
        delete right;
#else
	IA_YoderIPS result
	  ( ( (lhs.ps->type()==IA_BoxyIPS::s_type()) ?
	     IA_YoderIPS(*(IA_BoxyIPS*)lhs.ps) :
	     *(IA_YoderIPS*)lhs.ps )
	   ^
	   ( (rhs.ps->type()==IA_BoxyIPS::s_type()) ?
	    IA_YoderIPS(*(IA_BoxyIPS*)rhs.ps) :
	    *(IA_YoderIPS*)rhs.ps )
	   );
#endif
	return IA_Set<IA_Point<int> >(result);
    } else {
#if 1
	return new IA_LazyXORPS<IA_Set<IA_Point<int> >,IA_Point<int> >(lhs, rhs);
    }
#else
    } // this is where the curly brace should NOT be :(
    /* The following code belongs in the above else clause.
       However, if it is placed there, CFront generates erroneous C code.
       Since the code MAY reside outside the scope of the else and still
       be semantically equivalent, and doing so suppresses the error, 
       we will do this until CFront is fixed
       */
	int	kludge;	// if this declaration is removed, CFront flakes out
	IA_BasePS<IA_Point<int> >	*temp =  new IA_LazyXORPS<IntPointSet,IA_Point<int> >(lhs, rhs);
	return temp;
//    } // this is where the curly brace should be
#endif
}
#endif


/*
  asymmetric set difference
  */

// subtract a comprehensive point set from an extensive one
// precondition:
// ext.extensive() ==1
// ext.dim() == comp.dim()
IA_Set<IA_Point<int> > ext_comp_diff(const IA_Set<IA_Point<int> > &ext, const IA_Set<IA_Point<int> > &comp)
{
    IA_PSIter<IA_Point<int> >	iter(ext);
    IA_Point<int>	ip;

    IA_Point<int>	*arr=new IA_Point<int>[ext.card()];
    unsigned	count=0;

    while (iter(ip)) {
	if (!comp.contains(ip)) {
	    arr[count++] = ip;
	}
    }

    return IA_Set<IA_Point<int> >(ext.dim(), arr,count);
}

IA_Set<IA_Point<int> > operator/(const IA_Set<IA_Point<int> >& lhs, const IA_Set<IA_Point<int> > &rhs)
{
    if (lhs.dim() != rhs.dim()) {
	// need better message
	// cout << lhs.dim() << "!=" << rhs.dim() << '\n' << flush;
	ia_throw(IA::PSET_DIMENSION_MISMATCH, __FILE__, __LINE__);
	return IA_Set<IA_Point<int> >();
    }

    if (lhs.ps->type()==IA_BlackHole_<IA_Point<int> >::s_type())
	return lhs;
    if (lhs.ps->type()==IA_WhiteHole_<IA_Point<int> >::s_type())
	return ~rhs;

    if (rhs.ps->type()==IA_BlackHole_<IA_Point<int> >::s_type())
	return lhs;
    if (rhs.ps->type()==IA_WhiteHole_<IA_Point<int> >::s_type())
	return IA_BlackHole(lhs.dim());

    if (lhs.extensive() && rhs.extensive()) {

#ifdef IA_NO_TEMPS_IN_CONDITIONAL_EXPRS
    IA_YoderIPS *left, *right;

    if (lhs.ps->type()==IA_BoxyIPS::s_type())
        left = new IA_YoderIPS(*(IA_BoxyIPS*)lhs.ps);
    else
        left = (IA_YoderIPS*)lhs.ps;

    if (rhs.ps->type()==IA_BoxyIPS::s_type())
        right = new IA_YoderIPS(*(IA_BoxyIPS*)rhs.ps);
    else
        right = (IA_YoderIPS*)rhs.ps;

    IA_YoderIPS result(*left / *right);

    if (left != lhs.ps)
        delete left;
    if (right != rhs.ps)
        delete right;
#else
	IA_YoderIPS result
	  ( ( (lhs.ps->type()==IA_BoxyIPS::s_type()) ?
	     IA_YoderIPS(*(IA_BoxyIPS*)lhs.ps) :
	     *(IA_YoderIPS*)lhs.ps )
	   /
	   ( (rhs.ps->type()==IA_BoxyIPS::s_type()) ?
	    IA_YoderIPS(*(IA_BoxyIPS*)rhs.ps) :
	    *(IA_YoderIPS*)rhs.ps )
	   );
#endif
	return IA_Set<IA_Point<int> >(result);
    } else if (lhs.extensive()) {
	return ext_comp_diff(lhs, rhs);
    } else {
	return new IA_LazyMinusPS<IA_Set<IA_Point<int> >,IA_Point<int> >(lhs,rhs);
    }
}

IA_Set<IA_Point<int> > IA_Set<IA_Point<int> >::operator~() const
{
    if (ps->type() == IA_BlackHole_<IA_Point<int> >::s_type())
	return IA_WhiteHole(dim());
    else if (ps->type() == IA_WhiteHole_<IA_Point<int> >::s_type())
	return IA_BlackHole(dim());
    else 
	return new IA_LazyNotPS<IA_Set<IA_Point<int> >, IA_Point<int> >(*this);
}


IA_Set<IA_Point<int> > operator+(const IA_Set<IA_Point<int> >& ips, const IA_Point<int> &ip)
{
    if (ips.dim() != ip.dim()) {
	ia_throw(IA::PSET_DIMENSION_MISMATCH, __FILE__, __LINE__);
	return IA_Set<IA_Point<int> >();
    }
    if (ips.extensive())
	return ips.ps->offsetted(ip);
    else
	return new IA_LazyOffsettedPS<IA_Set<IA_Point<int> >, IA_Point<int> >(ips, ip);
}

static IA_Set<IA_Point<int> > Mink_aux(const IA_Set<IA_Point<int> >& small, const IA_Set<IA_Point<int> >& large)
{
    IA_PSIter<IA_Point<int> >	iter(small);
    IA_Point<int>	ip;
    IA_Set<IA_Point<int> >	rval(IA_BlackHole(small.dim()));

    while (iter(ip)) {
	rval |= large+ip;
    }

    return rval;
}

IA_Set<IA_Point<int> > operator+(const IA_Set<IA_Point<int> >& lhs, const IA_Set<IA_Point<int> >& rhs)
{
    if (lhs.dim() != rhs.dim()) {
	// cout << lhs.dim() << "!=" << rhs.dim() << '\n' << flush;
	ia_throw(IA::PSET_DIMENSION_MISMATCH, __FILE__, __LINE__);
	return IA_Set<IA_Point<int> >();
    }

    if (lhs.extensive()) {
	if (rhs.extensive()) {

#ifdef IA_NO_TEMPS_IN_CONDITIONAL_EXPRS
      if (lhs.card() < rhs.card())
         return Mink_aux(lhs, rhs);
      else
         return Mink_aux(rhs, lhs);
#else
	    return (lhs.card() < rhs.card()) ?
		Mink_aux(lhs, rhs) : Mink_aux(rhs,lhs);
#endif
	} else {
	    return new IA_LazyMinkowskiPS<IA_PSIter<IA_Point<int> >,IA_Set<IA_Point<int> >, IA_Point<int> >(lhs,rhs);
	}
    } else {
	if (rhs.extensive()) {
	    return new IA_LazyMinkowskiPS<IA_PSIter<IA_Point<int> >,IA_Set<IA_Point<int> >, IA_Point<int> >(rhs,lhs);
	} else {
	    ia_throw(IA::PSET_REQUIRE_EXTENSIVE, __FILE__, __LINE__);
	}
    }
}


// this doesn't handle lazys
IA::LatticeRelation
compare(const IA_Set<IA_Point<int> > &lhs, const IA_Set<IA_Point<int> > &rhs)
{
    if (lhs.dim() != rhs.dim()) {
	// need better message
	// cout << lhs.dim() << "!=" << rhs.dim() << '\n' << flush;
	ia_throw(IA::PSET_DIMENSION_MISMATCH, __FILE__, __LINE__);
	return IA::UNKNOWN;
    }

    if (lhs.ps==rhs.ps)
	return IA::EQUAL;

    if (!lhs.extensive()) {
	if (!rhs.extensive())
	    return IA::UNKNOWN;
	// else, we can check if lhs>=rhs
	IA_PSIter<IA_Point<int> >	iter(rhs);
	IA_Point<int>	ip;
	while (iter(ip)) {
	    if (!lhs.contains(ip))
		return IA::UNKNOWN;
	}
	return IA::MP_SUPERSET;
    } else if (!rhs.extensive()) {
	// else, we can check if lhs<=rhs
	IA_PSIter<IA_Point<int> >	iter(lhs);
	IA_Point<int>	ip;
	while (iter(ip)) {
	    if (!rhs.contains(ip))
		return IA::UNKNOWN;
	}
	return IA::MP_SUBSET;
    }

    // invariant: lhs.extensive() && rhs.extensive()

    IA::Type ltype=lhs.ps->type();
    IA::Type rtype=rhs.ps->type();
    if (ltype==IA_WhiteHole_<IA_Point<int> >::s_type()) {
	if (rtype==IA_WhiteHole_<IA_Point<int> >::s_type())
	    return IA::EQUAL;
	else if (rtype==IA_BlackHole_<IA_Point<int> >::s_type() ||
		 rtype==IA_YoderIPS::s_type() ||
		 rtype==IA_BoxyIPS::s_type())
	    return IA::P_SUPERSET;
	else {
	    IA::internal_error(__FILE__,__LINE__);
	}
    } else if (ltype==IA_BlackHole_<IA_Point<int> >::s_type()) {
	if (rtype==IA_BlackHole_<IA_Point<int> >::s_type())
	    return IA::EQUAL;
	else if (rtype==IA_WhiteHole_<IA_Point<int> >::s_type() ||
		 rtype==IA_YoderIPS::s_type() ||
		 rtype==IA_BoxyIPS::s_type())
	    return IA::P_SUBSET;
	else {
	    IA::internal_error(__FILE__,__LINE__);
	}
    } else if (ltype==IA_BoxyIPS::s_type() ||
	       ltype==IA_YoderIPS::s_type()) {
	if (rtype==IA_WhiteHole_<IA_Point<int> >::s_type())
	    return IA::P_SUBSET;
	else if (rtype==IA_BlackHole_<IA_Point<int> >::s_type())
	    return IA::P_SUPERSET;
	else if (rtype==IA_BoxyIPS::s_type() ||
		 rtype==IA_YoderIPS::s_type())

#ifdef IA_NO_TEMPS_IN_CONDITIONAL_EXPRS
   {
       IA_YoderIPS *left, *right;

       if (lhs.ps->type()==IA_BoxyIPS::s_type())
           left = new IA_YoderIPS(*(IA_BoxyIPS*)lhs.ps);
       else
           left = (IA_YoderIPS*)lhs.ps;

       if (rhs.ps->type()==IA_BoxyIPS::s_type())
           right = new IA_YoderIPS(*(IA_BoxyIPS*)rhs.ps);
       else
           right = (IA_YoderIPS*)rhs.ps;

       IA::LatticeRelation retval(compare(*left, *right));

       if (left != lhs.ps)
           delete left;
       if (right != rhs.ps)
           delete right;

       return retval;
   }
#else
	    return compare( (lhs.ps->type()==IA_BoxyIPS::s_type())?
			    IA_YoderIPS(*(IA_BoxyIPS*)lhs.ps) : *(IA_YoderIPS*)lhs.ps ,
			    (rhs.ps->type()==IA_BoxyIPS::s_type())?
			    IA_YoderIPS(*(IA_BoxyIPS*)rhs.ps) : *(IA_YoderIPS*)rhs.ps);
#endif
	else {
	    IA::internal_error(__FILE__,__LINE__);
	}
    }
    IA::internal_error(__FILE__,__LINE__);
    // NOTREACHED (I hope)
    return IA::UNKNOWN;
}


int operator<(const IA_Set<IA_Point<int> > &lhs, const IA_Set<IA_Point<int> > &rhs)
{
    IA::LatticeRelation	result;
    result = compare(lhs,rhs);
    return result==IA::P_SUBSET;
}

int operator<=(const IA_Set<IA_Point<int> > &lhs, const IA_Set<IA_Point<int> > &rhs)
{
    IA::LatticeRelation	result;
    result = compare(lhs,rhs);
    return result==IA::P_SUBSET
	|| result==IA::MP_SUBSET
	    || result==IA::EQUAL;
}

int operator>=(const IA_Set<IA_Point<int> > &lhs, const IA_Set<IA_Point<int> > &rhs)
{
    IA::LatticeRelation	result;
    result = compare(lhs,rhs);
    return result==IA::P_SUPERSET
	|| result==IA::MP_SUPERSET
	    || result==IA::EQUAL;
}

int operator>(const IA_Set<IA_Point<int> > &lhs, const IA_Set<IA_Point<int> > &rhs)
{
    IA::LatticeRelation	result;
    result = compare(lhs,rhs);
    return result==IA::P_SUPERSET;
}

//
//
//


IA_Set<IA_Point<int> > IA_Set<IA_Point<int> >::empty_pset(unsigned dim)
{
    return IA_Set<IA_Point<int> >(IA_BlackHole_<IA_Point<int> >::s_type(), dim);
}

IA_Set<IA_Point<int> > IA_Set<IA_Point<int> >::universal_pset(unsigned dim)
{
    return IA_Set<IA_Point<int> >(IA_WhiteHole_<IA_Point<int> >::s_type(), dim);
}

IA_Set<IA_Point<int> > IA_boxy_pset(IA_Point<int> p0, IA_Point<int> p1)
{
    return IA_Set<IA_Point<int> >(p0,p1);
}

//
//

IA_Set<IA_Point<int> > concat(int a, const IA_Set<IA_Point<int> >&ps)
{
    return IA_Set<IA_Point<int> >( IA_YoderIPS(a,a,ps) );
}

//
//

void SortIntPointArray(IA_Point<int> *aip, unsigned len)
{
  // We can use qsort because a swap of the bytes in
  // two IntPoints does not do any damage.
  qsort((char*)aip, len, sizeof(*aip), ipcmp);
}

//
//


IA_Set<IA_Point<int> > transpose(const IA_Set<IA_Point<int> > &ps)
{
    if (!ps.boxy() || ps.dim() != 2) {
	ia_throw(Pointset_BadTranspose_Exception(__FILE__, __LINE__));
	return IA_Set<IA_Point<int> >();
    }

    return IA_Set<IA_Point<int> >(ps.inf().derange(1,0), ps.sup().derange(1,0));
}


#ifdef IA_NO_AUTOINST_OF_STATIC_DATA
char IA_WhiteHole_<IA_Point<int> >::type_;
char IA_BlackHole_<IA_Point<int> >::type_;

char IA_LazyUnionPS<IA_Set<IA_Point<int> >, IA_Point<int> >::type_;

char IA_LazyIntersectionPS<IA_Set<IA_Point<int> >, IA_Point<int> >::type_;

char IA_LazyXORPS<IA_Set<IA_Point<int> >, IA_Point<int> >::type_;

char IA_LazyMinusPS<IA_Set<IA_Point<int> >, IA_Point<int> >::type_;

char IA_LazyMinkowskiPS<IA_PSIter<IA_Point<int> >, IA_Set<IA_Point<int> >, IA_Point<int> >::type_;

char IA_LazyNotPS<IA_Set<IA_Point<int> >, IA_Point<int> >::type_;

char IA_LazyOffsettedPS<IA_Set<IA_Point<int> >, IA_Point<int> >::type_;

char IA_ClosurePS<IA_Point<int> >::type_;

char IA_PredicatePS_V<IA_Point<int> >::type_;

char IA_PredicatePS_CR<IA_Point<int> >::type_;


#endif


void hash_managed_delete(IA_BasePS<IA_Point<int> > * ps)
{
    if (ps->unref()<=0) {
	IA_Set<IA_Point<int> >::hash_table->remove(ps);
	delete ps;
    }
}
@


1.44
log
@changed pointset_erros.h to pset_errors.h
@
text
@d11 1
a11 1
static char rcsid[] = "$Id: IntPS.c,v 1.43 1994/12/03 03:21:10 fjsoria Exp fjsoria $";
d16 3
d1271 22
@


1.43
log
@fixing my screwup with the hash_managed_delete fix
this is the correct code (cross the fingers and squeeze tight)
@
text
@d11 1
a11 1
static char rcsid[] = "$Id: IntPS.c,v 1.41 1994/11/10 19:53:56 ljr Exp thoth $";
d16 4
d184 1
a184 1
#include "pointset_errors.h"
@


1.42
log
@changed __NO_INLINE_DESTRUCTORS to
__NO_OUTLINE_DESTRUCTORS
@
text
@d1 1
a1 1
// Emacs: -*- C++ -*-
d11 1
a11 1
static char rcsid[] = "$Id: IntPS.c,v 1.41 1994/11/10 19:53:56 ljr Exp fjsoria $";
d188 1
a188 1
IA_HashTable IA_Set<IA_Point<int> >::hash_table;
d190 17
d209 1
a209 1
    if (hash_table.reference(ips, &this->ps)) {
d222 1
a222 4
    if ( ps->unref() <= 0 ) {
	hash_table.remove(ps);
	delete ps;
    }
d436 5
d1171 2
d1267 1
a1267 3
#ifdef __NO_OUTLINE_DESTRUCTORS

void delete_domain(IA_BasePSIter<IA_Point<int> > &i)
d1269 4
a1272 4
  if (i.domain->unref() <= 0) {
    IA_Set<IA_Point<int> >::hash_table.remove(i.domain);
    delete i.domain;
  }
a1273 4


#endif

@


1.41
log
@Added IA_NO_RCS_STATIC_DATA guard.
@
text
@d11 1
a11 1
static char rcsid[] = "$Id: IntPS.c,v 1.40 1994/11/10 18:50:09 fjsoria Exp ljr $";
d16 3
d394 1
a394 1
#ifndef __NO_INLINE_DESTRUCTORS
d1246 1
a1246 1
#ifdef __NO_INLINE_DESTRUCTORS
@


1.41.1.1
log
@Added hash_managed_delete to handle BasePS deletion
Added print_hashtable.
Rework of Lazies to take advantage of Set<P<T>> abstraction.
Added operator-() to reflect through origin
Added pointset concatenation.
@
text
@d1 1
a1 1
 // Emacs: -*- C++ -*-
d8 6
a15 3
// Revision 1.41  1994/11/10  19:53:56  ljr
// Added IA_NO_RCS_STATIC_DATA guard.
//
d202 4
a205 1
    hash_managed_delete(ps);
a418 5
void IA_Set<IA_Point<int> >::print_hashtable(ostream &o)
{
    hash_table.print(o);
}

d510 1
a510 1
	return new IA_LazyUnionPS<IA_Point<int> >(lhs, rhs);
d605 1
a605 1
	return new IA_LazyIntersectionPS<IA_Point<int> >(lhs,rhs);
d874 1
a874 1
	return new IA_LazyXORPS<IA_Point<int> >(lhs, rhs);
d973 1
a973 1
	return new IA_LazyMinusPS<IA_Point<int> >(lhs,rhs);
d984 1
a984 1
	return new IA_LazyNotPS< IA_Point<int> >(*this);
d997 1
a997 1
	return new IA_LazyOffsettedPS< IA_Point<int> >(ips, ip);
d1034 1
a1034 1
	    return new IA_LazyMinkowskiPS<IA_Point<int> >(lhs,rhs);
d1038 1
a1038 1
	    return new IA_LazyMinkowskiPS<IA_Point<int> >(rhs,lhs);
a1044 5
IA_Set<IA_Point<int> > IA_Set<IA_Point<int> >::operator-() const
{
    return ps->reflect_through_origin();
}

a1213 34
IA_Set<IA_Point<int> > concat(IA_Set<IA_Point<int> > a,
			      IA_Set<IA_Point<int> > b)
{
    if (a.empty() || b.empty())
	return new IA_BlackHole_<IA_Point<int> >(a.dim()+b.dim());

    if (a.dim()==0)		// gotta be a white hole
	return b;

    if (b.dim()==0)		// ditto
	return a;

    if (a.extensive() && b.extensive()) {
	if (a.type()==IA_BoxyIPS::s_type()) {
	    if (b.type()==IA_BoxyIPS::s_type()) {
		return IA_BoxyIPS(concat(a.inf(),b.inf()),
				  concat(a.sup(),b.sup()));
	    } else {
		return IA_YoderIPS(*(IA_BoxyIPS*)a.ps).concat_with(b);
	    }
	} else if (a.type()==IA_YoderIPS::s_type()) {
	    return ((IA_YoderIPS*)a.ps)->concat_with(b);
	} else {
	    /* they can't invent a new kind of extensive pointset */
	    IA::internal_error(__FILE__, __LINE__);
	    return IA_Set<IA_Point<int> >();
	}
    } else {
	return new IA_LazyConcatenation<IA_Point<int> >(a,b);
    }
}

//
//
d1243 3
a1245 1
void hash_managed_delete(IA_BasePS<IA_Point<int> > * ps)
d1247 4
a1250 4
    if (ps->unref()<=0) {
	IA_Set<IA_Point<int> >::hash_table.remove(ps);
	delete ps;
    }
d1252 4
@


1.40
log
@*** empty log message ***
@
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: IntPS.c,v 1.39 1994/11/03 18:39:46 fjsoria Exp fjsoria $";
d16 3
@


1.39
log
@*** empty log message ***
@
text
@d10 1
a10 1
//static char rcsid[] = "$Id: IntPS.c,v 1.38 1994/10/06 17:39:00 fjsoria Exp fjsoria $";
d14 3
d1236 15
a1250 1
		   
@


1.38
log
@commented rscid[] line
@
text
@d10 1
a10 1
//static char rcsid[] = "$Id: IntPS.c,v 1.37 1994/09/27 20:47:09 fjsoria Exp fjsoria $";
d14 3
d159 4
a167 4

#ifdef IA_PRII
#pragma implementation
#endif
@


1.37
log
@g++ v2.6 does no like n0n-inlined destructors
added __NO_INLINE_DESTRUCTORS
@
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: IntPS.c,v 1.36 1994/09/13 19:10:59 ljr Exp fjsoria $";
d14 4
d1224 7
@


1.36
log
@Added workarounds for conditional expressions that create temporaries.
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: IntPS.c,v 1.35 1994/08/18 23:38:01 thoth Exp ljr $";
d14 3
d346 2
a347 1
    IA_Point<int>	*newaip;
d376 1
d386 1
a386 1

@


1.35
log
@DOS-inspired filename rework
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: IntPS.c,v 1.34 1994/07/25 16:58:52 thoth Exp thoth $";
d12 1
a12 1
// 
d14 3
d49 1
a49 1
// 
d53 1
a53 1
// 
d56 1
a56 1
// 
d59 1
a59 1
// 
d62 1
a62 1
// 
d65 1
a65 1
// 
d68 1
a68 1
// 
d71 1
a71 1
// 
d74 1
a74 1
// 
d79 1
a79 1
// 
d82 1
a82 1
// 
d85 1
a85 1
// 
d88 1
a88 1
// 
d91 1
a91 1
// 
d94 1
a94 1
// 
d97 1
a97 1
// 
d101 1
a101 1
// 
d105 1
a105 1
// 
d111 1
a111 1
// 
d114 1
a114 1
// 
d119 1
a119 1
// 
d124 1
a124 1
// 
d130 1
a130 1
// 
d135 1
a135 1
// 
d143 1
a143 1
// 
d146 2
a147 2
// 
// 
d419 2
d455 21
a486 1

d548 20
d577 1
d628 22
d657 1
d699 22
d728 1
d766 22
d795 1
d820 21
d850 1
a850 1

d918 21
d948 1
a948 1

d1003 7
d1012 1
a1012 1

d1094 25
d1123 1
@


1.34
log
@\Name sanitization
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.33 1994/05/08 19:35:40 thoth Exp thoth $";
d13 4
a16 1
// $Log: IntPointSet.c,v $
d147 1
a147 1
#include "IntPointSet.h"
d979 1
a979 1
IA_Set<IA_Point<int> > IA_empty_ipset(unsigned dim)
d984 1
a984 1
IA_Set<IA_Point<int> > IA_universal_ipset(unsigned dim)
@


1.33
log
@New pointset concatenation capability.
New intpointset decomposition capability.
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.32 1994/04/26 18:13:57 thoth Exp thoth $";
d14 4
d161 1
a161 1
IA_HashTable IA_Set<IA_IntPoint>::hash_table;
d163 1
a163 1
void IA_Set<IA_IntPoint>::lookup_and_set(IA_BasePS<IA_IntPoint> *ips)
d176 1
a176 1
void IA_Set<IA_IntPoint>::disassociate_ps()
d185 1
a185 1
IA_Set<IA_IntPoint>::IA_Set()
d187 1
a187 1
    this->lookup_and_set(new IA_BlackHole_<IA_IntPoint>(0));
d190 1
a190 1
IA_Set<IA_IntPoint>::IA_Set(IA_PointSetType t, unsigned dim)
d192 4
a195 4
    if (t == IA_WhiteHole_<IA_IntPoint>::s_type())
	this->lookup_and_set(new IA_WhiteHole_<IA_IntPoint>(dim));
    else if (t == IA_BlackHole_<IA_IntPoint>::s_type())
	this->lookup_and_set(new IA_BlackHole_<IA_IntPoint>(dim));
d198 1
a198 1
	this->lookup_and_set(new IA_BlackHole_<IA_IntPoint>(0));
d202 1
a202 1
IA_Set<IA_IntPoint>::IA_Set(const IA_IntPoint& p)
d207 1
a207 1
IA_Set<IA_IntPoint>::IA_Set(const IA_IntPoint& p0, const IA_IntPoint& p1)
d212 2
a213 2
IA_Set<IA_IntPoint>::IA_Set(unsigned dimen, int(*f)(IA_IntPoint)) {
    this->lookup_and_set(new IA_PredicatePS_V<IA_IntPoint>(dimen, f));
d216 2
a217 2
IA_Set<IA_IntPoint>::IA_Set(unsigned dimen, int(*f)(const IA_IntPoint&)) {
    this->lookup_and_set(new IA_PredicatePS_CR<IA_IntPoint>(dimen, f));
d220 1
a220 1
IA_Set<IA_IntPoint>::IA_Set(const IA_ClosurePS<IA_IntPoint>&ps)
d225 1
a225 1
IA_Set<IA_IntPoint>::IA_Set(const IA_BoxyIPS& bps)
d230 1
a230 1
IA_Set<IA_IntPoint>::IA_Set(const IA_YoderIPS& yps)
d235 1
a235 1
	    this->lookup_and_set(new  IA_BlackHole_<IA_IntPoint>(yps.dimen));
d246 1
a246 1
  return pointcmp(*(IA_IntPoint*)a,*(IA_IntPoint*)b);
d249 1
a249 1
IA_Set<IA_IntPoint>::IA_Set(unsigned dimen, const IA_IntPoint *aip, unsigned len)
d252 1
a252 1
	this->lookup_and_set(new IA_BlackHole_<IA_IntPoint>(dimen));
d259 1
a259 1
	    this->lookup_and_set(new IA_BlackHole_<IA_IntPoint>(0));
d266 1
a266 1
	    this->lookup_and_set(new IA_WhiteHole_<IA_IntPoint>(0));
d268 1
a268 1
	    this->lookup_and_set(new IA_BlackHole_<IA_IntPoint>(0));
d277 1
a277 1
    IA_IntPoint	*newaip;
d279 1
a279 1
	newaip = new IA_IntPoint[len];
d290 1
a290 1
	newaip = (IA_IntPoint*)aip;
d295 1
a295 1
	    this->lookup_and_set(new IA_BlackHole_<IA_IntPoint>(temp->dimen));
d306 1
a306 1
IA_Set<IA_IntPoint>::IA_Set(const IA_IntPoint *aip, unsigned len)
d310 1
a310 1
	this->lookup_and_set(new IA_BlackHole_<IA_IntPoint>(0));
d319 1
a319 1
	    this->lookup_and_set(new IA_BlackHole_<IA_IntPoint>(0));
d326 1
a326 1
	    this->lookup_and_set(new IA_WhiteHole_<IA_IntPoint>(0));
d328 1
a328 1
	    this->lookup_and_set(new IA_BlackHole_<IA_IntPoint>(0));
d337 1
a337 1
    IA_IntPoint	*newaip;
d339 1
a339 1
	newaip = new IA_IntPoint[len];
d350 1
a350 1
	newaip = (IA_IntPoint*)aip;
d355 1
a355 1
	    this->lookup_and_set(new IA_BlackHole_<IA_IntPoint>(temp->dimen));
d366 1
a366 1
IA_Set<IA_IntPoint>::~IA_Set()
d377 1
a377 1
IA_Set<IA_IntPoint>& IA_Set<IA_IntPoint>::operator=(const IA_Set<IA_IntPoint> &ips)
d379 1
a379 1
    IA_BasePS<IA_IntPoint>	*temp;
d388 1
a388 1
int IA_Set<IA_IntPoint>::boxy() const
d393 1
a393 1
IA_Set<IA_IntPoint> operator|(const IA_Set<IA_IntPoint>& lhs,const IA_Set<IA_IntPoint> &rhs)
d399 1
a399 1
	return IA_Set<IA_IntPoint>();
d402 1
a402 1
    if (lhs.ps->type() == IA_BlackHole_<IA_IntPoint>::s_type())
d404 1
a404 1
    if (lhs.ps->type() == IA_WhiteHole_<IA_IntPoint>::s_type())
d407 1
a407 1
    if (rhs.ps->type() == IA_BlackHole_<IA_IntPoint>::s_type())
d409 1
a409 1
    if (rhs.ps->type() == IA_WhiteHole_<IA_IntPoint>::s_type())
d460 1
a460 1
	return IA_Set<IA_IntPoint>(result);
d462 1
a462 1
	return new IA_LazyUnionPS<IA_Set<IA_IntPoint>,IA_IntPoint>(lhs, rhs);
d472 1
a472 1
IA_Set<IA_IntPoint> ext_comp_intersect(const IA_Set<IA_IntPoint> &ext, const IA_Set<IA_IntPoint> &comp)
d474 2
a475 2
    IA_PSIter<IA_IntPoint>	iter(ext);
    IA_IntPoint	ip;
d477 1
a477 1
    IA_IntPoint	*arr=new IA_IntPoint[ext.card()];
d486 1
a486 1
    return IA_Set<IA_IntPoint>(ext.dim(), arr,count);
d489 1
a489 1
IA_Set<IA_IntPoint> operator&(const IA_Set<IA_IntPoint>& lhs, const IA_Set<IA_IntPoint> &rhs)
d494 1
a494 1
	return IA_Set<IA_IntPoint>();
d497 1
a497 1
    if (lhs.ps->type()==IA_BlackHole_<IA_IntPoint>::s_type())
d499 1
a499 1
    if (lhs.ps->type()==IA_WhiteHole_<IA_IntPoint>::s_type())
d502 1
a502 1
    if (rhs.ps->type()==IA_BlackHole_<IA_IntPoint>::s_type())
d504 1
a504 1
    if (rhs.ps->type()==IA_WhiteHole_<IA_IntPoint>::s_type())
d513 2
a514 2
	    IA_IntPoint	bottom(sup(lhs.ps->inf(), rhs.ps->inf()));
	    IA_IntPoint	top(inf (lhs.ps->sup(), rhs.ps->sup()));
d516 1
a516 1
		return IA_Set<IA_IntPoint>(bottom, top);
d518 1
a518 1
		return new IA_BlackHole_<IA_IntPoint>(lhs.dim());
d529 1
a529 1
	    return IA_Set<IA_IntPoint>(result);
d536 1
a536 1
	return new IA_LazyIntersectionPS<IA_Set<IA_IntPoint>,IA_IntPoint>(lhs,rhs);
d541 2
a542 2
IA_Set<IA_IntPoint> intersect_with_structure
(const IA_Set<IA_IntPoint> &lhs, const IA_Set<IA_IntPoint> &rhs, IA_SetStructure *result)
d547 1
a547 1
	return IA_Set<IA_IntPoint>();
d550 1
a550 1
    if (lhs.ps->type()==IA_BlackHole_<IA_IntPoint>::s_type()) {
d553 2
a554 2
    if (lhs.ps->type()==IA_WhiteHole_<IA_IntPoint>::s_type()) {
	*result = (rhs.ps->type()==IA_WhiteHole_<IA_IntPoint>::s_type())
d560 1
a560 1
    if (rhs.ps->type()==IA_BlackHole_<IA_IntPoint>::s_type()) {
d564 1
a564 1
    if (rhs.ps->type()==IA_WhiteHole_<IA_IntPoint>::s_type()) {
d588 2
a589 2
IA_Set<IA_IntPoint> intersect_with_dualstruct
(const IA_Set<IA_IntPoint> &lhs, const IA_Set<IA_IntPoint> &rhs, IA_SetStructure *result)
d594 1
a594 1
	return IA_Set<IA_IntPoint>();
d597 1
a597 1
    if (lhs.ps->type()==IA_BlackHole_<IA_IntPoint>::s_type()) {
d601 2
a602 2
    if (lhs.ps->type()==IA_WhiteHole_<IA_IntPoint>::s_type()) {
	*result = (rhs.ps->type()==IA_WhiteHole_<IA_IntPoint>::s_type())
d608 1
a608 1
    if (rhs.ps->type()==IA_BlackHole_<IA_IntPoint>::s_type()) {
d612 1
a612 1
    if (rhs.ps->type()==IA_WhiteHole_<IA_IntPoint>::s_type()) {
d636 2
a637 2
IA_Set<IA_IntPoint> union_with_structure
(const IA_Set<IA_IntPoint> &lhs, const IA_Set<IA_IntPoint> &rhs, IA_SetStructure *result)
d642 1
a642 1
	return IA_Set<IA_IntPoint>();
d645 1
a645 1
    if (lhs.ps->type()==IA_BlackHole_<IA_IntPoint>::s_type()) {
d649 2
a650 2
    if (lhs.ps->type()==IA_WhiteHole_<IA_IntPoint>::s_type()) {
	*result = (rhs.ps->type()==IA_WhiteHole_<IA_IntPoint>::s_type())
d656 1
a656 1
    if (rhs.ps->type()==IA_BlackHole_<IA_IntPoint>::s_type()) {
d660 2
a661 2
    if (rhs.ps->type()==IA_WhiteHole_<IA_IntPoint>::s_type()) {
	*result = (lhs.ps->type()==IA_WhiteHole_<IA_IntPoint>::s_type())
d682 1
a682 1
IA_Set<IA_IntPoint> operator^(const IA_Set<IA_IntPoint>& lhs, const IA_Set<IA_IntPoint> &rhs)
d688 1
a688 1
	return IA_Set<IA_IntPoint>();
d691 1
a691 1
    if (lhs.ps->type()==IA_BlackHole_<IA_IntPoint>::s_type())
d693 1
a693 1
    if (lhs.ps->type()==IA_WhiteHole_<IA_IntPoint>::s_type())
d696 1
a696 1
    if (rhs.ps->type()==IA_BlackHole_<IA_IntPoint>::s_type())
d698 1
a698 1
    if (rhs.ps->type()==IA_WhiteHole_<IA_IntPoint>::s_type())
d712 1
a712 1
	return IA_Set<IA_IntPoint>(result);
d715 1
a715 1
	return new IA_LazyXORPS<IA_Set<IA_IntPoint>,IA_IntPoint>(lhs, rhs);
d726 1
a726 1
	IA_BasePS<IA_IntPoint>	*temp =  new IA_LazyXORPS<IntPointSet,IA_IntPoint>(lhs, rhs);
d742 1
a742 1
IA_Set<IA_IntPoint> ext_comp_diff(const IA_Set<IA_IntPoint> &ext, const IA_Set<IA_IntPoint> &comp)
d744 2
a745 2
    IA_PSIter<IA_IntPoint>	iter(ext);
    IA_IntPoint	ip;
d747 1
a747 1
    IA_IntPoint	*arr=new IA_IntPoint[ext.card()];
d756 1
a756 1
    return IA_Set<IA_IntPoint>(ext.dim(), arr,count);
d759 1
a759 1
IA_Set<IA_IntPoint> operator/(const IA_Set<IA_IntPoint>& lhs, const IA_Set<IA_IntPoint> &rhs)
d765 1
a765 1
	return IA_Set<IA_IntPoint>();
d768 1
a768 1
    if (lhs.ps->type()==IA_BlackHole_<IA_IntPoint>::s_type())
d770 1
a770 1
    if (lhs.ps->type()==IA_WhiteHole_<IA_IntPoint>::s_type())
d773 1
a773 1
    if (rhs.ps->type()==IA_BlackHole_<IA_IntPoint>::s_type())
d775 1
a775 1
    if (rhs.ps->type()==IA_WhiteHole_<IA_IntPoint>::s_type())
d789 1
a789 1
	return IA_Set<IA_IntPoint>(result);
d793 1
a793 1
	return new IA_LazyMinusPS<IA_Set<IA_IntPoint>,IA_IntPoint>(lhs,rhs);
d797 1
a797 1
IA_Set<IA_IntPoint> IA_Set<IA_IntPoint>::operator~() const
d799 1
a799 1
    if (ps->type() == IA_BlackHole_<IA_IntPoint>::s_type())
d801 1
a801 1
    else if (ps->type() == IA_WhiteHole_<IA_IntPoint>::s_type())
d804 1
a804 1
	return new IA_LazyNotPS<IA_Set<IA_IntPoint>, IA_IntPoint>(*this);
d808 1
a808 1
IA_Set<IA_IntPoint> operator+(const IA_Set<IA_IntPoint>& ips, const IA_IntPoint &ip)
d812 1
a812 1
	return IA_Set<IA_IntPoint>();
d817 1
a817 1
	return new IA_LazyOffsettedPS<IA_Set<IA_IntPoint>, IA_IntPoint>(ips, ip);
d820 1
a820 1
static IA_Set<IA_IntPoint> Mink_aux(const IA_Set<IA_IntPoint>& small, const IA_Set<IA_IntPoint>& large)
d822 3
a824 3
    IA_PSIter<IA_IntPoint>	iter(small);
    IA_IntPoint	ip;
    IA_Set<IA_IntPoint>	rval(IA_BlackHole(small.dim()));
d833 1
a833 1
IA_Set<IA_IntPoint> operator+(const IA_Set<IA_IntPoint>& lhs, const IA_Set<IA_IntPoint>& rhs)
d838 1
a838 1
	return IA_Set<IA_IntPoint>();
d847 1
a847 1
	    return new IA_LazyMinkowskiPS<IA_PSIter<IA_IntPoint>,IA_Set<IA_IntPoint>, IA_IntPoint>(lhs,rhs);
d851 1
a851 1
	    return new IA_LazyMinkowskiPS<IA_PSIter<IA_IntPoint>,IA_Set<IA_IntPoint>, IA_IntPoint>(rhs,lhs);
d861 1
a861 1
compare(const IA_Set<IA_IntPoint> &lhs, const IA_Set<IA_IntPoint> &rhs)
d877 2
a878 2
	IA_PSIter<IA_IntPoint>	iter(rhs);
	IA_IntPoint	ip;
d886 2
a887 2
	IA_PSIter<IA_IntPoint>	iter(lhs);
	IA_IntPoint	ip;
d897 4
a900 4
    IA_PointSetType ltype=lhs.ps->type();
    IA_PointSetType rtype=rhs.ps->type();
    if (ltype==IA_WhiteHole_<IA_IntPoint>::s_type()) {
	if (rtype==IA_WhiteHole_<IA_IntPoint>::s_type())
d902 1
a902 1
	else if (rtype==IA_BlackHole_<IA_IntPoint>::s_type() ||
d909 2
a910 2
    } else if (ltype==IA_BlackHole_<IA_IntPoint>::s_type()) {
	if (rtype==IA_BlackHole_<IA_IntPoint>::s_type())
d912 1
a912 1
	else if (rtype==IA_WhiteHole_<IA_IntPoint>::s_type() ||
d921 1
a921 1
	if (rtype==IA_WhiteHole_<IA_IntPoint>::s_type())
d923 1
a923 1
	else if (rtype==IA_BlackHole_<IA_IntPoint>::s_type())
d939 1
a939 1
int operator<(const IA_Set<IA_IntPoint> &lhs, const IA_Set<IA_IntPoint> &rhs)
d946 1
a946 1
int operator<=(const IA_Set<IA_IntPoint> &lhs, const IA_Set<IA_IntPoint> &rhs)
d955 1
a955 1
int operator>=(const IA_Set<IA_IntPoint> &lhs, const IA_Set<IA_IntPoint> &rhs)
d964 1
a964 1
int operator>(const IA_Set<IA_IntPoint> &lhs, const IA_Set<IA_IntPoint> &rhs)
d976 1
a976 1
IA_Set<IA_IntPoint> IA_empty_ipset(unsigned dim)
d978 1
a978 1
    return IA_Set<IA_IntPoint>(IA_BlackHole_<IA_IntPoint>::s_type(), dim);
d981 1
a981 1
IA_Set<IA_IntPoint> IA_universal_ipset(unsigned dim)
d983 1
a983 1
    return IA_Set<IA_IntPoint>(IA_WhiteHole_<IA_IntPoint>::s_type(), dim);
d986 1
a986 1
IA_Set<IA_IntPoint> IA_boxy_pset(IA_Point<int> p0, IA_Point<int> p1)
d988 1
a988 1
    return IA_Set<IA_IntPoint>(p0,p1);
d996 1
a996 1
    return IA_Set<IA_IntPoint>( IA_YoderIPS(a,a,ps) );
d1002 1
a1002 1
void SortIntPointArray(IA_IntPoint *aip, unsigned len)
d1013 1
a1013 1
IA_Set<IA_IntPoint> transpose(const IA_Set<IA_IntPoint> &ps)
d1017 1
a1017 1
	return IA_Set<IA_IntPoint>();
d1020 1
a1020 1
    return IA_IntPointSet(ps.inf().derange(1,0), ps.sup().derange(1,0));
@


1.32
log
@New array constructor that doesn't require dimension.
White and Black Hole have been renamed to universal and empty _pset
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.31 1994/03/14 15:38:32 thoth Exp thoth $";
d14 4
d143 1
d985 8
@


1.31
log
@Check for errors in translation operation.
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.30 1994/01/31 16:37:35 thoth Exp thoth $";
d14 3
d297 60
d967 1
a967 1
IA_Set<IA_IntPoint> IA_BlackHole(unsigned dim)
d972 1
a972 1
IA_Set<IA_IntPoint> IA_WhiteHole(unsigned dim)
d975 5
@


1.30
log
@We now document internal errors when they occur.
We can now transpose boxy 2D pointsets.
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.29 1993/11/17 18:03:47 thoth Exp thoth $";
d14 4
d738 4
@


1.29
log
@IPSIter is now PSIter<IntPoint>
Pointcmp is now pointcmp
extensivep() is now extensive()
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.28 1993/10/20 15:50:54 thoth Exp thoth $";
d14 5
d137 1
a146 10
IA_Set<IA_IntPoint> IA_BlackHole(unsigned dim)
{
    return IA_Set<IA_IntPoint>(IA_BlackHole_<IA_IntPoint>::s_type(), dim);
}

IA_Set<IA_IntPoint> IA_WhiteHole(unsigned dim)
{
    return IA_Set<IA_IntPoint>(IA_WhiteHole_<IA_IntPoint>::s_type(), dim);
}

a232 7
void SortIntPointArray(IA_IntPoint *aip, unsigned len)
{
  // We can use qsort because a swap of the bytes in
  // two IntPoints does not do any damage.
  qsort((char*)aip, len, sizeof(*aip), ipcmp);
}

d348 1
a348 1
	    abort(); // internal error
d361 1
a361 1
	    abort(); // internal error
d827 1
a827 1
	    abort(); // program error
d837 1
a837 1
	    abort(); // program error
d852 1
a852 1
	    abort(); // program error
d855 1
a855 1
    abort(); // program error
d889 39
@


1.28
log
@New naming scheme.  Closures are named Closure.
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.27 1993/09/15 12:36:18 thoth Exp thoth $";
d14 3
d126 1
a126 1
#include "IPSIter.h"
d234 1
a234 1
  return Pointcmp(*(IA_IntPoint*)a,*(IA_IntPoint*)b);
d268 1
a268 1
	if (Pointcmp(aip[i],aip[i+1]) ==1)
d347 1
a347 1
    if (lhs.extensivep() && rhs.extensivep()) {
d405 1
a405 1
// ext.extensivep() ==1
d409 1
a409 1
    IA_IPSIter	iter(ext);
d443 2
a444 2
    lext = lhs.extensivep();
    rext = rhs.extensivep();
d504 1
a504 1
    if (!lhs.extensivep()) {
d509 1
a509 1
    if (!rhs.extensivep()) {
d552 1
a552 1
    if (!lhs.extensivep()) {
d557 1
a557 1
    if (!rhs.extensivep()) {
d602 1
a602 1
    if (!lhs.extensivep() || !rhs.extensivep()) {
d636 1
a636 1
    if (lhs.extensivep() && rhs.extensivep()) {
d675 1
a675 1
// ext.extensivep() ==1
d679 1
a679 1
    IA_IPSIter	iter(ext);
d713 1
a713 1
    if (lhs.extensivep() && rhs.extensivep()) {
d725 1
a725 1
    } else if (lhs.extensivep()) {
d745 1
a745 1
    if (ips.extensivep())
d753 1
a753 1
    IA_IPSIter	iter(small);
d772 2
a773 2
    if (lhs.extensivep()) {
	if (rhs.extensivep()) {
d778 1
a778 1
	    return new IA_LazyMinkowskiPS<IA_IPSIter,IA_Set<IA_IntPoint>, IA_IntPoint>(lhs,rhs);
d781 2
a782 2
	if (rhs.extensivep()) {
	    return new IA_LazyMinkowskiPS<IA_IPSIter,IA_Set<IA_IntPoint>, IA_IntPoint>(rhs,lhs);
d804 2
a805 2
    if (!lhs.extensivep()) {
	if (!rhs.extensivep())
d808 1
a808 1
	IA_IPSIter	iter(rhs);
d815 1
a815 1
    } else if (!rhs.extensivep()) {
d817 1
a817 1
	IA_IPSIter	iter(lhs);
d826 1
a826 1
    // invariant: lhs.extensivep() && rhs.extensivep()
@


1.27
log
@Pointset behavior controls have moved to IA::
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.26 93/08/08 13:17:33 thoth Exp Locker: thoth $";
d13 4
a16 1
// $Log:	IntPointSet.c,v $
d134 1
a134 1
#include "PredicatePS.h"
d205 1
a205 1
IA_Set<IA_IntPoint>::IA_Set(const IA_PSPred<IA_IntPoint>&ps)
@


1.26
log
@Parametrization of the pointsets on the point type using
template specialization.
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.25 93/07/15 11:45:17 thoth Exp Locker: thoth $";
d14 4
a133 2
char IA_Set<IA_IntPoint>::throw_on_index_uncontained =1;
const unsigned IA_Set<IA_IntPoint>::index_of_uncontained = ~0;
@


1.25
log
@new lookup_and_set allows other classes (such as BasePSIter)
to cooperate in refcounting the BasePSs.
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.24 93/05/28 15:05:29 thoth Exp Locker: thoth $";
d14 4
d129 3
a131 3
IA_HashTable IA_IntPointSet::hash_table;
char IA_IntPointSet::throw_on_index_uncontained =1;
const unsigned IA_IntPointSet::index_of_uncontained = ~0;
d133 1
a133 1
IA_IntPointSet IA_BlackHole(unsigned dim)
d135 1
a135 1
    return IA_IntPointSet(IA_BlackHole_<IA_IntPoint>::s_type(), dim);
d138 1
a138 1
IA_IntPointSet IA_WhiteHole(unsigned dim)
d140 1
a140 1
    return IA_IntPointSet(IA_WhiteHole_<IA_IntPoint>::s_type(), dim);
d143 1
a143 1
void IA_IntPointSet::lookup_and_set(IA_BasePS<IA_IntPoint> *ips)
d156 1
a156 1
void IA_IntPointSet::disassociate_ps()
d165 1
a165 1
IA_IntPointSet::IA_IntPointSet()
d170 1
a170 1
IA_IntPointSet::IA_IntPointSet(IA_PointSetType t, unsigned dim)
d182 1
a182 1
IA_IntPointSet::IA_IntPointSet(const IA_IntPoint& p)
d187 1
a187 1
IA_IntPointSet::IA_IntPointSet(const IA_IntPoint& p0, const IA_IntPoint& p1)
d192 1
a192 1
IA_IntPointSet::IA_IntPointSet(unsigned dimen, int(*f)(IA_IntPoint)) {
d196 1
a196 1
IA_IntPointSet::IA_IntPointSet(unsigned dimen, int(*f)(const IA_IntPoint&)) {
d200 1
a200 1
IA_IntPointSet::IA_IntPointSet(const IA_PSPred<IA_IntPoint>&ps)
d205 1
a205 1
IA_IntPointSet::IA_IntPointSet(const IA_BoxyIPS& bps)
d210 1
a210 1
IA_IntPointSet::IA_IntPointSet(const IA_YoderIPS& yps)
d236 1
a236 1
IA_IntPointSet::IA_IntPointSet(unsigned dimen, const IA_IntPoint *aip, unsigned len)
d293 1
a293 1
IA_IntPointSet::~IA_IntPointSet()
d304 1
a304 1
IA_IntPointSet& IA_IntPointSet::operator=(const IA_IntPointSet &ips)
d315 1
a315 1
int IA_IntPointSet::boxy() const
d320 1
a320 1
IA_IntPointSet operator|(const IA_IntPointSet& lhs,const IA_IntPointSet &rhs)
d326 1
a326 1
	return IA_IntPointSet();
d387 1
a387 1
	return IA_IntPointSet(result);
d389 1
a389 1
	return new IA_LazyUnionPS<IA_IntPointSet,IA_IntPoint>(lhs, rhs);
d399 1
a399 1
IA_IntPointSet ext_comp_intersect(const IA_IntPointSet &ext, const IA_IntPointSet &comp)
d413 1
a413 1
    return IA_IntPointSet(ext.dim(), arr,count);
d416 1
a416 1
IA_IntPointSet operator&(const IA_IntPointSet& lhs, const IA_IntPointSet &rhs)
d421 1
a421 1
	return IA_IntPointSet();
d443 1
a443 1
		return IA_IntPointSet(bottom, top);
d456 1
a456 1
	    return IA_IntPointSet(result);
d463 1
a463 1
	return new IA_LazyIntersectionPS<IA_IntPointSet,IA_IntPoint>(lhs,rhs);
d468 2
a469 2
IA_IntPointSet intersect_with_structure
(const IA_IntPointSet &lhs, const IA_IntPointSet &rhs, IA_SetStructure *result)
d474 1
a474 1
	return IA_IntPointSet();
d515 2
a516 2
IA_IntPointSet intersect_with_dualstruct
(const IA_IntPointSet &lhs, const IA_IntPointSet &rhs, IA_SetStructure *result)
d521 1
a521 1
	return IA_IntPointSet();
d563 2
a564 2
IA_IntPointSet union_with_structure
(const IA_IntPointSet &lhs, const IA_IntPointSet &rhs, IA_SetStructure *result)
d569 1
a569 1
	return IA_IntPointSet();
d609 1
a609 1
IA_IntPointSet operator^(const IA_IntPointSet& lhs, const IA_IntPointSet &rhs)
d615 1
a615 1
	return IA_IntPointSet();
d639 1
a639 1
	return IA_IntPointSet(result);
d642 1
a642 1
	return new IA_LazyXORPS<IA_IntPointSet,IA_IntPoint>(lhs, rhs);
d669 1
a669 1
IA_IntPointSet ext_comp_diff(const IA_IntPointSet &ext, const IA_IntPointSet &comp)
d683 1
a683 1
    return IA_IntPointSet(ext.dim(), arr,count);
d686 1
a686 1
IA_IntPointSet operator/(const IA_IntPointSet& lhs, const IA_IntPointSet &rhs)
d692 1
a692 1
	return IA_IntPointSet();
d716 1
a716 1
	return IA_IntPointSet(result);
d720 1
a720 1
	return new IA_LazyMinusPS<IA_IntPointSet,IA_IntPoint>(lhs,rhs);
d724 1
a724 1
IA_IntPointSet IA_IntPointSet::operator~() const
d731 1
a731 1
	return new IA_LazyNotPS<IA_IntPointSet, IA_IntPoint>(*this);
d735 1
a735 1
IA_IntPointSet operator+(const IA_IntPointSet& ips, const IA_IntPoint &ip)
d740 1
a740 1
	return new IA_LazyOffsettedPS<IA_IntPointSet, IA_IntPoint>(ips, ip);
d743 1
a743 1
static IA_IntPointSet Mink_aux(const IA_IntPointSet& small, const IA_IntPointSet& large)
d747 1
a747 1
    IA_IntPointSet	rval(IA_BlackHole(small.dim()));
d756 1
a756 1
IA_IntPointSet operator+(const IA_IntPointSet& lhs, const IA_IntPointSet& rhs)
d761 1
a761 1
	return IA_IntPointSet();
d770 1
a770 1
	    return new IA_LazyMinkowskiPS<IA_IPSIter,IA_IntPointSet, IA_IntPoint>(lhs,rhs);
d774 1
a774 1
	    return new IA_LazyMinkowskiPS<IA_IPSIter,IA_IntPointSet, IA_IntPoint>(rhs,lhs);
d784 1
a784 1
compare(const IA_IntPointSet &lhs, const IA_IntPointSet &rhs)
d862 1
a862 1
int operator<(const IA_IntPointSet &lhs, const IA_IntPointSet &rhs)
d869 1
a869 1
int operator<=(const IA_IntPointSet &lhs, const IA_IntPointSet &rhs)
d878 1
a878 1
int operator>=(const IA_IntPointSet &lhs, const IA_IntPointSet &rhs)
d887 1
a887 1
int operator>(const IA_IntPointSet &lhs, const IA_IntPointSet &rhs)
@


1.24
log
@removed dependency on with-ia-pointset*
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.23 93/05/26 16:57:46 thoth Exp Locker: thoth $";
d14 3
d141 5
a145 3
    if (hash_table.reference(ips, &this->ps))
	delete ips;
    else {
@


1.23
log
@Copyright Notices
@
text
@d10 1
a10 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.22 93/05/19 14:44:37 thoth Exp Locker: thoth $";
d14 3
d122 3
a124 1
#include "with-ia-pointset-P.h"
d126 1
a126 5
HashTable IntPointSet::hash_table;
char IntPointSet::throw_on_index_uncontained =1;
const unsigned IntPointSet::index_of_uncontained = ~0;

IntPointSet IA_BlackHole(unsigned dim)
d128 1
a128 1
    return IntPointSet(IA_BlackHole_<IA_IntPoint>::s_type(), dim);
d131 1
a131 1
IntPointSet IA_WhiteHole(unsigned dim)
d133 1
a133 1
    return IntPointSet(IA_WhiteHole_<IA_IntPoint>::s_type(), dim);
d136 1
a136 1
void IntPointSet::lookup_and_set(IA_BasePS<IA_IntPoint> *ips)
d147 1
a147 1
void IntPointSet::disassociate_ps()
d156 1
a156 1
IntPointSet::IA_IntPointSet()
d161 1
a161 1
IntPointSet::IA_IntPointSet(IA_PointSetType t, unsigned dim)
d173 1
a173 1
IntPointSet::IA_IntPointSet(const IA_IntPoint& p)
d175 1
a175 1
    this->lookup_and_set(new BoxyIPS(p, p));
d178 1
a178 1
IntPointSet::IA_IntPointSet(const IA_IntPoint& p0, const IA_IntPoint& p1)
d180 1
a180 1
    this->lookup_and_set(new BoxyIPS(p0, p1));
d183 1
a183 1
IntPointSet::IA_IntPointSet(unsigned dimen, int(*f)(IA_IntPoint)) {
d187 1
a187 1
IntPointSet::IA_IntPointSet(unsigned dimen, int(*f)(const IA_IntPoint&)) {
d191 1
a191 1
IntPointSet::IA_IntPointSet(const IA_PSPred<IA_IntPoint>&ps)
d196 1
a196 1
IntPointSet::IA_IntPointSet(const BoxyIPS& bps)
d198 1
a198 1
    this->lookup_and_set(new BoxyIPS(bps));
d201 1
a201 1
IntPointSet::IA_IntPointSet(const YoderIPS& yps)
d208 1
a208 1
	    this->lookup_and_set(new BoxyIPS(yps.min(), yps.max()));
d210 1
a210 1
    } else this->lookup_and_set(new YoderIPS(yps));
d227 1
a227 1
IntPointSet::IA_IntPointSet(unsigned dimen, const IA_IntPoint *aip, unsigned len)
d270 1
a270 1
    YoderIPS *temp = new YoderIPS(newaip, len);
d275 1
a275 1
	    this->lookup_and_set(new BoxyIPS(temp->min(), temp->max()));
d284 1
a284 1
IntPointSet::~IA_IntPointSet()
d295 1
a295 1
IntPointSet& IntPointSet::operator=(const IntPointSet &ips)
d306 1
a306 1
int IntPointSet::boxy() const
d308 1
a308 1
    return ps->type() == BoxyIPS::s_type();
d311 1
a311 1
IntPointSet operator|(const IntPointSet& lhs,const IntPointSet &rhs)
d317 1
a317 1
	return IntPointSet();
d366 4
a369 4
	YoderIPS result
	  ( ( (lhs.ps->type()==BoxyIPS::s_type()) ?
	     YoderIPS(*(BoxyIPS*)lhs.ps) :
	     *(YoderIPS*)lhs.ps )
d371 3
a373 3
	   ( (rhs.ps->type()==BoxyIPS::s_type()) ?
	    YoderIPS(*(BoxyIPS*)rhs.ps) :
	    *(YoderIPS*)rhs.ps )
d378 1
a378 1
	return IntPointSet(result);
d380 1
a380 1
	return new IA_LazyUnionPS<IntPointSet,IA_IntPoint>(lhs, rhs);
d390 1
a390 1
IntPointSet ext_comp_intersect(const IntPointSet &ext, const IntPointSet &comp)
d392 1
a392 1
    IPSIter	iter(ext);
d404 1
a404 1
    return IntPointSet(ext.dim(), arr,count);
d407 1
a407 1
IntPointSet operator&(const IntPointSet& lhs, const IntPointSet &rhs)
d412 1
a412 1
	return IntPointSet();
d429 2
a430 2
	if (lhs.ps->type()==BoxyIPS::s_type() &&
	    rhs.ps->type()==BoxyIPS::s_type() ) {
d434 1
a434 1
		return IntPointSet(bottom, top);
d438 4
a441 4
	    YoderIPS result
		( ( (lhs.ps->type()==BoxyIPS::s_type()) ?
		    YoderIPS(*(BoxyIPS*)lhs.ps) :
		    *(YoderIPS*)lhs.ps )
d443 3
a445 3
		  ( (rhs.ps->type()==BoxyIPS::s_type()) ?
		    YoderIPS(*(BoxyIPS*)rhs.ps) :
		    *(YoderIPS*)rhs.ps )
d447 1
a447 1
	    return IntPointSet(result);
d454 1
a454 1
	return new IA_LazyIntersectionPS<IntPointSet,IA_IntPoint>(lhs,rhs);
d459 2
a460 2
IntPointSet intersect_with_structure
(const IntPointSet &lhs, const IntPointSet &rhs, SetStructure *result)
d465 1
a465 1
	return IntPointSet();
d473 2
a474 2
	    ? SetStructure::BOTH
	    : SetStructure::FIRST_ONLY;
d479 1
a479 1
	result->add_interval(lhs.card(), SetStructure::FIRST_ONLY);
d483 1
a483 1
	result->add_interval(lhs.card(), SetStructure::BOTH);
d497 6
a502 6
    return ( (lhs.ps->type()==BoxyIPS::s_type()) ?
	     YoderIPS(*(BoxyIPS*)lhs.ps) :
	     *(YoderIPS*)lhs.ps ). intersect_with_structure(
		 ( (rhs.ps->type()==BoxyIPS::s_type()) ?
		   YoderIPS(*(BoxyIPS*)rhs.ps) :
		   *(YoderIPS*)rhs.ps ),
d506 2
a507 2
IntPointSet intersect_with_dualstruct
(const IntPointSet &lhs, const IntPointSet &rhs, SetStructure *result)
d512 1
a512 1
	return IntPointSet();
d516 1
a516 1
	result->add_interval(rhs.card(), SetStructure::SECOND_ONLY);
d521 2
a522 2
	    ? SetStructure::BOTH
	    : SetStructure::FIRST_ONLY;
d527 1
a527 1
	result->add_interval(lhs.card(), SetStructure::FIRST_ONLY);
d531 1
a531 1
	result->add_interval(lhs.card(), SetStructure::BOTH);
d545 6
a550 6
    return ( (lhs.ps->type()==BoxyIPS::s_type()) ?
	     YoderIPS(*(BoxyIPS*)lhs.ps) :
	     *(YoderIPS*)lhs.ps ). intersect_with_dualstruct(
		 ( (rhs.ps->type()==BoxyIPS::s_type()) ?
		   YoderIPS(*(BoxyIPS*)rhs.ps) :
		   *(YoderIPS*)rhs.ps ),
d554 2
a555 2
IntPointSet union_with_structure
(const IntPointSet &lhs, const IntPointSet &rhs, SetStructure *result)
d560 1
a560 1
	return IntPointSet();
d564 1
a564 1
	result->add_interval(rhs.card(), SetStructure::SECOND_ONLY);
d569 2
a570 2
	    ? SetStructure::BOTH
	    : SetStructure::FIRST_ONLY;
d575 1
a575 1
	result->add_interval(lhs.card(), SetStructure::FIRST_ONLY);
d580 2
a581 2
	    ? SetStructure::BOTH
	    : SetStructure::SECOND_ONLY;
d589 6
a594 6
    return ( (lhs.ps->type()==BoxyIPS::s_type()) ?
	     YoderIPS(*(BoxyIPS*)lhs.ps) :
	     *(YoderIPS*)lhs.ps ). union_with_structure(
		 ( (rhs.ps->type()==BoxyIPS::s_type()) ?
		   YoderIPS(*(BoxyIPS*)rhs.ps) :
		   *(YoderIPS*)rhs.ps ),
d600 1
a600 1
IntPointSet operator^(const IntPointSet& lhs, const IntPointSet &rhs)
d606 1
a606 1
	return IntPointSet();
d620 4
a623 4
	YoderIPS result
	  ( ( (lhs.ps->type()==BoxyIPS::s_type()) ?
	     YoderIPS(*(BoxyIPS*)lhs.ps) :
	     *(YoderIPS*)lhs.ps )
d625 3
a627 3
	   ( (rhs.ps->type()==BoxyIPS::s_type()) ?
	    YoderIPS(*(BoxyIPS*)rhs.ps) :
	    *(YoderIPS*)rhs.ps )
d630 1
a630 1
	return IntPointSet(result);
d633 1
a633 1
	return new IA_LazyXORPS<IntPointSet,IA_IntPoint>(lhs, rhs);
d660 1
a660 1
IntPointSet ext_comp_diff(const IntPointSet &ext, const IntPointSet &comp)
d662 1
a662 1
    IPSIter	iter(ext);
d674 1
a674 1
    return IntPointSet(ext.dim(), arr,count);
d677 1
a677 1
IntPointSet operator/(const IntPointSet& lhs, const IntPointSet &rhs)
d683 1
a683 1
	return IntPointSet();
d697 4
a700 4
	YoderIPS result
	  ( ( (lhs.ps->type()==BoxyIPS::s_type()) ?
	     YoderIPS(*(BoxyIPS*)lhs.ps) :
	     *(YoderIPS*)lhs.ps )
d702 3
a704 3
	   ( (rhs.ps->type()==BoxyIPS::s_type()) ?
	    YoderIPS(*(BoxyIPS*)rhs.ps) :
	    *(YoderIPS*)rhs.ps )
d707 1
a707 1
	return IntPointSet(result);
d711 1
a711 1
	return new IA_LazyMinusPS<IntPointSet,IA_IntPoint>(lhs,rhs);
d715 1
a715 1
IntPointSet IntPointSet::operator~() const
d722 1
a722 1
	return new IA_LazyNotPS<IntPointSet, IA_IntPoint>(*this);
d726 1
a726 1
IntPointSet operator+(const IntPointSet& ips, const IA_IntPoint &ip)
d731 1
a731 1
	return new IA_LazyOffsettedPS<IntPointSet, IA_IntPoint>(ips, ip);
d734 1
a734 1
static IntPointSet Mink_aux(const IntPointSet& small, const IntPointSet& large)
d736 1
a736 1
    IPSIter	iter(small);
d738 1
a738 1
    IntPointSet	rval(IA_BlackHole(small.dim()));
d747 1
a747 1
IntPointSet operator+(const IntPointSet& lhs, const IntPointSet& rhs)
d752 1
a752 1
	return IntPointSet();
d761 1
a761 1
	    return new IA_LazyMinkowskiPS<IPSIter,IntPointSet, IA_IntPoint>(lhs,rhs);
d765 1
a765 1
	    return new IA_LazyMinkowskiPS<IPSIter,IntPointSet, IA_IntPoint>(rhs,lhs);
d775 1
a775 1
compare(const IntPointSet &lhs, const IntPointSet &rhs)
d791 1
a791 1
	IPSIter	iter(rhs);
d800 1
a800 1
	IPSIter	iter(lhs);
d817 2
a818 2
		 rtype==YoderIPS::s_type() ||
		 rtype==BoxyIPS::s_type())
d827 2
a828 2
		 rtype==YoderIPS::s_type() ||
		 rtype==BoxyIPS::s_type())
d833 2
a834 2
    } else if (ltype==BoxyIPS::s_type() ||
	       ltype==YoderIPS::s_type()) {
d839 6
a844 6
	else if (rtype==BoxyIPS::s_type() ||
		 rtype==YoderIPS::s_type())
	    return compare( (lhs.ps->type()==BoxyIPS::s_type())?
			    YoderIPS(*(BoxyIPS*)lhs.ps) : *(YoderIPS*)lhs.ps ,
			    (rhs.ps->type()==BoxyIPS::s_type())?
			    YoderIPS(*(BoxyIPS*)rhs.ps) : *(YoderIPS*)rhs.ps);
d853 1
a853 1
int operator<(const IntPointSet &lhs, const IntPointSet &rhs)
d860 1
a860 1
int operator<=(const IntPointSet &lhs, const IntPointSet &rhs)
d869 1
a869 1
int operator>=(const IntPointSet &lhs, const IntPointSet &rhs)
d878 1
a878 1
int operator>(const IntPointSet &lhs, const IntPointSet &rhs)
@


1.22
log
@LatticeRelation is now in IA::
@
text
@a1 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.21 93/04/29 12:50:41 thoth Exp Locker: thoth $";
d3 9
d14 3
@


1.21
log
@Mondo PointSets are now templatized.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.20 93/04/19 23:27:40 thoth Exp Locker: thoth $";
d6 3
d762 1
a762 1
IntPointSet::LatticeRelation
d769 1
a769 1
	return IntPointSet::UNKNOWN;
d773 1
a773 1
	return IntPointSet::EQUAL;
d777 1
a777 1
	    return IntPointSet::UNKNOWN;
d783 1
a783 1
		return IntPointSet::UNKNOWN;
d785 1
a785 1
	return IntPointSet::MP_SUPERSET;
d792 1
a792 1
		return IntPointSet::UNKNOWN;
d794 1
a794 1
	return IntPointSet::MP_SUBSET;
d803 1
a803 1
	    return IntPointSet::EQUAL;
d807 1
a807 1
	    return IntPointSet::P_SUPERSET;
d813 1
a813 1
	    return IntPointSet::EQUAL;
d817 1
a817 1
	    return IntPointSet::P_SUBSET;
d824 1
a824 1
	    return IntPointSet::P_SUBSET;
d826 1
a826 1
	    return IntPointSet::P_SUPERSET;
d843 1
a843 1
    IntPointSet::LatticeRelation	result;
d845 1
a845 1
    return result==IntPointSet::P_SUBSET;
d850 1
a850 1
    IntPointSet::LatticeRelation	result;
d852 3
a854 3
    return result==IntPointSet::P_SUBSET
	|| result==IntPointSet::MP_SUBSET
	    || result==IntPointSet::EQUAL;
d859 1
a859 1
    IntPointSet::LatticeRelation	result;
d861 3
a863 3
    return result==IntPointSet::P_SUPERSET
	|| result==IntPointSet::MP_SUPERSET
	    || result==IntPointSet::EQUAL;
d868 1
a868 1
    IntPointSet::LatticeRelation	result;
d870 1
a870 1
    return result==IntPointSet::P_SUPERSET;
@


1.20
log
@Convert BaseIPS to IA_BasePS<IA_IntPoint>
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.19 93/04/17 15:19:51 thoth Exp Locker: thoth $";
d6 3
d113 1
a113 1
    return IntPointSet(_BlackHole::s_type(), dim);
d118 1
a118 1
    return IntPointSet(_WhiteHole::s_type(), dim);
d143 1
a143 1
    this->lookup_and_set(new _BlackHole(0));
d148 4
a151 4
    if (t == _WhiteHole::s_type())
	this->lookup_and_set(new _WhiteHole(dim));
    else if (t == _BlackHole::s_type())
	this->lookup_and_set(new _BlackHole(dim));
d154 1
a154 1
	this->lookup_and_set(new _BlackHole(0));
d191 1
a191 1
	    this->lookup_and_set(new  _BlackHole(yps.dimen));
d215 1
a215 1
	this->lookup_and_set(new _BlackHole(dimen));
d222 1
a222 1
	    this->lookup_and_set(new _BlackHole(0));
d229 1
a229 1
	    this->lookup_and_set(new _WhiteHole(0));
d231 1
a231 1
	    this->lookup_and_set(new _BlackHole(0));
d258 1
a258 1
	    this->lookup_and_set(new _BlackHole(temp->dimen));
d305 1
a305 1
    if (lhs.ps->type() == _BlackHole::s_type())
d307 1
a307 1
    if (lhs.ps->type() == _WhiteHole::s_type())
d310 1
a310 1
    if (rhs.ps->type() == _BlackHole::s_type())
d312 1
a312 1
    if (rhs.ps->type() == _WhiteHole::s_type())
d400 1
a400 1
    if (lhs.ps->type()==_BlackHole::s_type())
d402 1
a402 1
    if (lhs.ps->type()==_WhiteHole::s_type())
d405 1
a405 1
    if (rhs.ps->type()==_BlackHole::s_type())
d407 1
a407 1
    if (rhs.ps->type()==_WhiteHole::s_type())
d421 1
a421 1
		return new _BlackHole(lhs.dim());
d453 1
a453 1
    if (lhs.ps->type()==_BlackHole::s_type()) {
d456 2
a457 2
    if (lhs.ps->type()==_WhiteHole::s_type()) {
	*result = (rhs.ps->type()==_WhiteHole::s_type())
d463 1
a463 1
    if (rhs.ps->type()==_BlackHole::s_type()) {
d467 1
a467 1
    if (rhs.ps->type()==_WhiteHole::s_type()) {
d500 1
a500 1
    if (lhs.ps->type()==_BlackHole::s_type()) {
d504 2
a505 2
    if (lhs.ps->type()==_WhiteHole::s_type()) {
	*result = (rhs.ps->type()==_WhiteHole::s_type())
d511 1
a511 1
    if (rhs.ps->type()==_BlackHole::s_type()) {
d515 1
a515 1
    if (rhs.ps->type()==_WhiteHole::s_type()) {
d548 1
a548 1
    if (lhs.ps->type()==_BlackHole::s_type()) {
d552 2
a553 2
    if (lhs.ps->type()==_WhiteHole::s_type()) {
	*result = (rhs.ps->type()==_WhiteHole::s_type())
d559 1
a559 1
    if (rhs.ps->type()==_BlackHole::s_type()) {
d563 2
a564 2
    if (rhs.ps->type()==_WhiteHole::s_type()) {
	*result = (lhs.ps->type()==_WhiteHole::s_type())
d594 1
a594 1
    if (lhs.ps->type()==_BlackHole::s_type())
d596 1
a596 1
    if (lhs.ps->type()==_WhiteHole::s_type())
d599 1
a599 1
    if (rhs.ps->type()==_BlackHole::s_type())
d601 1
a601 1
    if (rhs.ps->type()==_WhiteHole::s_type())
d671 1
a671 1
    if (lhs.ps->type()==_BlackHole::s_type())
d673 1
a673 1
    if (lhs.ps->type()==_WhiteHole::s_type())
d676 1
a676 1
    if (rhs.ps->type()==_BlackHole::s_type())
d678 1
a678 1
    if (rhs.ps->type()==_WhiteHole::s_type())
d702 1
a702 1
    if (ps->type() == _BlackHole::s_type())
d704 1
a704 1
    else if (ps->type() == _WhiteHole::s_type())
d798 2
a799 2
    if (ltype==_WhiteHole::s_type()) {
	if (rtype==_WhiteHole::s_type())
d801 1
a801 1
	else if (rtype==_BlackHole::s_type() ||
d808 2
a809 2
    } else if (ltype==_BlackHole::s_type()) {
	if (rtype==_BlackHole::s_type())
d811 1
a811 1
	else if (rtype==_WhiteHole::s_type() ||
d820 1
a820 1
	if (rtype==_WhiteHole::s_type())
d822 1
a822 1
	else if (rtype==_BlackHole::s_type())
@


1.19
log
@IA_IntPoint upgrades (dim, inf, sup)
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.18 93/04/16 15:50:18 thoth Exp Locker: thoth $";
d6 3
d95 1
a95 1
#include "BaseIPS.h"
d118 1
a118 1
void IntPointSet::lookup_and_set(BaseIPS *ips)
d279 1
a279 1
    BaseIPS	*temp;
d626 1
a626 1
	BaseIPS	*temp =  new IA_LazyXORPS<IntPointSet,IA_IntPoint>(lhs, rhs);
@


1.18
log
@use IA_IntPoint instead of IntPoint.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.17 93/02/12 16:23:41 thoth Exp Locker: thoth $";
d6 3
d214 1
a214 1
	if (aip[i].dimensions() != dimen) {
d410 2
a411 2
	    IA_IntPoint	bottom(supremum(lhs.ps->inf(), rhs.ps->inf()));
	    IA_IntPoint	top(infimum (lhs.ps->sup(), rhs.ps->sup()));
@


1.17
log
@more IA_ prefixes.
Removed #if 0 cruft.
comp undefined bug is now gone from CFront
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.16 93/01/20 11:36:18 thoth Exp Locker: thoth $";
d6 5
d149 1
a149 1
IntPointSet::IA_IntPointSet(const IntPoint& p)
d154 1
a154 1
IntPointSet::IA_IntPointSet(const IntPoint& p0, const IntPoint& p1)
d159 2
a160 2
IntPointSet::IA_IntPointSet(unsigned dimen, int(*f)(IntPoint)) {
    this->lookup_and_set(new IA_PredicatePS_V<IntPoint>(dimen, f));
d163 2
a164 2
IntPointSet::IA_IntPointSet(unsigned dimen, int(*f)(const IntPoint&)) {
    this->lookup_and_set(new IA_PredicatePS_CR<IntPoint>(dimen, f));
d167 1
a167 1
IntPointSet::IA_IntPointSet(const IA_PSPred<IntPoint>&ps)
d193 1
a193 1
  return Pointcmp(*(IntPoint*)a,*(IntPoint*)b);
d196 1
a196 1
void SortIntPointArray(IntPoint *aip, unsigned len)
d203 1
a203 1
IntPointSet::IA_IntPointSet(unsigned dimen, const IntPoint *aip, unsigned len)
d231 1
a231 1
    IntPoint	*newaip;
d233 1
a233 1
	newaip = new IntPoint[len];
d244 1
a244 1
	newaip = (IntPoint*)aip;
d356 1
a356 1
	return new IA_LazyUnionPS<IntPointSet,IntPoint>(lhs, rhs);
d369 1
a369 1
    IntPoint	ip;
d371 1
a371 1
    IntPoint	*arr=new IntPoint[ext.card()];
d407 2
a408 2
	    IntPoint	bottom(supremum(lhs.ps->inf(), rhs.ps->inf()));
	    IntPoint	top(infimum (lhs.ps->sup(), rhs.ps->sup()));
d430 1
a430 1
	return new IA_LazyIntersectionPS<IntPointSet,IntPoint>(lhs,rhs);
d609 1
a609 1
	return new IA_LazyXORPS<IntPointSet,IntPoint>(lhs, rhs);
d620 1
a620 1
	BaseIPS	*temp =  new IA_LazyXORPS<IntPointSet,IntPoint>(lhs, rhs);
d639 1
a639 1
    IntPoint	ip;
d641 1
a641 1
    IntPoint	*arr=new IntPoint[ext.card()];
d687 1
a687 1
	return new IA_LazyMinusPS<IntPointSet,IntPoint>(lhs,rhs);
d698 1
a698 1
	return new IA_LazyNotPS<IntPointSet, IntPoint>(*this);
d702 1
a702 1
IntPointSet operator+(const IntPointSet& ips, const IntPoint &ip)
d707 1
a707 1
	return new IA_LazyOffsettedPS<IntPointSet, IntPoint>(ips, ip);
d713 1
a713 1
    IntPoint	ip;
d737 1
a737 1
	    return new IA_LazyMinkowskiPS<IPSIter,IntPointSet, IntPoint>(lhs,rhs);
d741 1
a741 1
	    return new IA_LazyMinkowskiPS<IPSIter,IntPointSet, IntPoint>(rhs,lhs);
d768 1
a768 1
	IntPoint	ip;
d777 1
a777 1
	IntPoint	ip;
@


1.16
log
@new PredicatePS class to allow for families of comprehensive pointsets.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.15 92/12/16 14:48:09 thoth Exp Locker: thoth $";
d6 3
d97 1
a97 1
IntPointSet BlackHole(unsigned dim)
d102 1
a102 1
IntPointSet WhiteHole(unsigned dim)
d132 1
a132 1
IntPointSet::IA_IntPointSet(PointSetType t, unsigned dim)
d257 2
a258 3
#if 0
    if (ps==0 || ps==(BaseIPS*)1)
	// special PointSet types
d260 1
a260 2
#endif

d262 1
a289 5
#if 0
    cout << '|'<< lhs.dim() << "==" << rhs.dim() << '\n' << flush;
    lhs.output(cout);
    rhs.output(cout);
#endif
a578 5
#if 0
    cout << '^'<< lhs.dim() << "==" << rhs.dim() << '\n' << flush;
    lhs.output(cout);
    rhs.output(cout);
#endif
a579 1

d603 4
d618 1
a655 5
#if 0
    cout << '-'<< lhs.dim() << "==" << rhs.dim() << '\n' << flush;
    lhs.output(cout);
    rhs.output(cout);
#endif
d665 1
a665 1
	return BlackHole(lhs.dim());
d689 1
a689 1
	return WhiteHole(dim());
d691 1
a691 1
	return BlackHole(dim());
d709 1
a709 1
    IntPointSet	rval(BlackHole(small.dim()));
a754 8
#if 0
    cout << " comparing: \n";
    lhs.output(cout);
    cout << " with \n";
    rhs.output(cout);
    cout << ".\n" << flush;
#endif

d782 2
a783 2
    PointSetType ltype=lhs.ps->type();
    PointSetType rtype=rhs.ps->type();
@


1.15
log
@conversion to IA_ mostly complete
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.14 92/12/15 21:16:21 thoth Exp Locker: thoth $";
d6 3
d86 1
d157 5
@


1.14
log
@added boxy predicate method.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.13 92/11/11 12:11:46 thoth Exp Locker: thoth $";
d6 3
d84 2
d120 1
a120 1
IntPointSet::IntPointSet()
d125 1
a125 1
IntPointSet::IntPointSet(PointSetType t, unsigned dim)
d137 1
a137 1
IntPointSet::IntPointSet(const IntPoint& p)
d142 1
a142 1
IntPointSet::IntPointSet(const IntPoint& p0, const IntPoint& p1)
d147 2
a148 2
IntPointSet::IntPointSet(unsigned dimen, int(*f)(IntPoint)) {
    this->lookup_and_set(new PredicatePS_V<IntPoint>(dimen, f));
d151 2
a152 2
IntPointSet::IntPointSet(unsigned dimen, int(*f)(const IntPoint&)) {
    this->lookup_and_set(new PredicatePS_CR<IntPoint>(dimen, f));
d155 1
a155 1
IntPointSet::IntPointSet(const BoxyIPS& bps)
d160 1
a160 1
IntPointSet::IntPointSet(const YoderIPS& yps)
d186 1
a186 1
IntPointSet::IntPointSet(unsigned dimen, const IntPoint *aip, unsigned len)
d243 1
a243 1
IntPointSet::~IntPointSet()
d345 1
a345 1
	return new LazyUnionPS<IntPointSet,IntPoint>(lhs, rhs);
d419 1
a419 1
	return new LazyIntersectionPS<IntPointSet,IntPoint>(lhs,rhs);
d611 1
a611 1
	BaseIPS	*temp =  new LazyXORPS<IntPointSet,IntPoint>(lhs, rhs);
d682 1
a682 1
	return new LazyMinusPS<IntPointSet,IntPoint>(lhs,rhs);
d693 1
a693 1
	return new LazyNotPS<IntPointSet, IntPoint>(*this);
d702 1
a702 1
	return new LazyOffsettedPS<IntPointSet, IntPoint>(ips, ip);
d732 1
a732 1
	    return new LazyMinkowskiPS<IPSIter,IntPointSet, IntPoint>(lhs,rhs);
d736 1
a736 1
	    return new LazyMinkowskiPS<IPSIter,IntPointSet, IntPoint>(rhs,lhs);
@


1.13
log
@added another restriction utility.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.12 92/11/04 11:58:51 thoth Exp Locker: thoth $";
d6 3
d259 5
@


1.12
log
@New union_with_structure function for image extension.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.11 92/10/25 20:53:24 thoth Exp Locker: thoth $";
d6 3
d458 48
d531 1
a531 1
	*result = (rhs.ps->type()==_WhiteHole::s_type())
@


1.11
log
@changed argument passing on set restriction routines.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.10 92/10/22 15:11:13 thoth Exp Locker: thoth $";
d6 3
d449 44
@


1.10
log
@lazy comparison handling (untested)
pointset restriction utilities.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.9 92/10/07 23:15:31 thoth Exp Locker: thoth $";
d6 4
d405 2
a406 2
SetStructure intersect_with_structure
(const IntPointSet &lhs, const IntPointSet &rhs, IntPointSet *result)
d411 1
a411 2
	*result = IntPointSet();
	return SetStructure(0U);
a413 2
    SetStructure	s_struct(lhs.dim());

d415 1
a415 2
	*result = lhs;
	return s_struct;
d418 4
a421 5
	*result = rhs;
	if (rhs.ps->type()==_WhiteHole::s_type())
	    return SetStructure::FIRST;
	else
	    return SetStructure::NEITHER;
d425 2
a426 3
	*result = rhs;
	s_struct.add_interval(lhs.card(), SetStructure::NEITHER);
	return s_struct;
d429 2
a430 3
	*result = lhs;
	s_struct.add_interval(lhs.card(), SetStructure::FIRST);
	return s_struct;
a433 1
	*result = lhs & rhs;
d435 1
a435 1
	return s_struct;
a438 1
	*result = lhs & rhs;
d440 1
a440 1
	return s_struct;
d443 7
a449 11
    // waugh.
    YoderIPS	rsult(lhs.dim());
    s_struct = ( (lhs.ps->type()==BoxyIPS::s_type()) ?
		 YoderIPS(*(BoxyIPS*)lhs.ps) :
		 *(YoderIPS*)lhs.ps ). intersect_with_structure(
		     ( (rhs.ps->type()==BoxyIPS::s_type()) ?
		       YoderIPS(*(BoxyIPS*)rhs.ps) :
		       *(YoderIPS*)rhs.ps ),
		     &rsult);
    *result = rsult;
    return s_struct;
@


1.9
log
@trim gratuitous includes from public headers.
boxy boxy intersect should now be faster.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.8 92/09/30 10:30:52 thoth Exp Locker: thoth $";
d6 4
d400 62
d664 24
d698 1
a698 1
	    // lazies, we can't always tell
a699 1
	// we shouldn't reach this point
d708 1
a708 1
	    // lazies, we can't always tell
a709 1
	// we shouldn't reach this point
d723 1
a723 1
	    // lazies, we can't always tell
a724 1
	// we shouldn't reach this point
d726 1
a726 1
    return IntPointSet::UNKNOWN;
@


1.8
log
@Lazies are now templatized.
White and Black holes are now semi-public classes, unfortunately.
reference counts are protected from IntPointSet, unfortunately.
type() system now based on address of static data member.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.7 92/09/20 17:38:44 thoth Exp Locker: thoth $";
d6 6
d51 1
d367 20
a386 11
	YoderIPS result
	  ( ( (lhs.ps->type()==BoxyIPS::s_type()) ?
	     YoderIPS(*(BoxyIPS*)lhs.ps) :
	     *(YoderIPS*)lhs.ps )
	   &
	   ( (rhs.ps->type()==BoxyIPS::s_type()) ?
	    YoderIPS(*(BoxyIPS*)rhs.ps) :
	    *(YoderIPS*)rhs.ps )
	   );

	return IntPointSet(result);
@


1.7
log
@Minkowski addition of point sets now supported.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.c,v 1.6 92/09/14 21:56:27 thoth Exp Locker: thoth $";
d6 3
d54 2
a55 1
#include "LazyIPS.h"
d61 4
a64 25
// this is the class that contains all of the points of its dimensionality
class _WhiteHole: public BaseIPS {
public:
    _WhiteHole(unsigned dim) :BaseIPS(dim) { }
    // this class contains all points of a given dimensionality
    int equal(BaseIPS* ips) const { return ips->type()==WHITE &&
				      ips->dim() == this->dimen; }
    unsigned hash_self(unsigned) const { return 0; }
    PointSetType type() const { return WHITE; }
    int contains(IntPoint) const { return 1; }
    unsigned index(const IntPoint &) const { return 0; }
    int extensivep() const { return dimen==0;}
    unsigned card() const {
	if (this->dimen!=0)
	    ia_throw(IA::PSET_REQUIRE_EXTENSIVE,__FILE__,__LINE__);
	return 1;
    }
    int empty() const { return 0; }
    BaseIPS *offsetted(const IntPoint &) const
	{ return new _WhiteHole(dimen); }
    void output(ostream & o, unsigned indent=0) const {
      for (unsigned i=0; i<indent; i++) cout << ' ';
      o << "White"<<dimen<<'\n';
    }
};
d66 4
a69 2
// this is the 0-dimensional set that contains the 0-dimensional Point
IntPointSet WhiteHole(WHITE, 0);
a70 28
// this is the class that contains none of the points of its dimensionality
class _BlackHole: public BaseIPS {
public:
    _BlackHole(unsigned dim) :BaseIPS(dim) { }
    ~_BlackHole() {}
    // this class contains no points of a given dimensionality
    int equal(BaseIPS* ips) const { return ips->type()==BLACK &&
				      ips->dim()==this->dimen; }
    unsigned hash_self(unsigned mod) const { return (1+dimen)%mod; }
    PointSetType type() const { return BLACK; }
    int contains(IntPoint) const { return 0; }
    unsigned index(const IntPoint &) const {
	if (IntPointSet::throw_on_index_uncontained)
	    ia_throw(IA::PSET_INDEX_UNCONTAINED, __FILE__,__LINE__);
	return IntPointSet::index_of_uncontained;
    }
    int extensivep() const { return 1;}
    unsigned card() const { return 0;}
    int empty() const { return 1; }
    BaseIPS *offsetted(const IntPoint &) const
	{ return new _BlackHole(dimen); }
    void output(ostream & o, unsigned indent=0) const {
      for (unsigned i=0; i<indent; i++) cout << ' ';
      o << "Black"<<dimen<<'\n';
    }
};


d75 3
a77 2
    else
	ips->refcount=0;
d79 1
a79 1
    ps->refcount++;
d84 1
a84 1
    if ( --ps->refcount <= 0 ) {
d98 1
a98 2
    switch (t) {
    case WHITE:
d100 1
a100 2
	break;
    case BLACK:
d102 1
a102 2
	break;
    default:
a104 1
	break;
d119 1
a119 1
    this->lookup_and_set(new PredicateIPS(dimen, f));
d122 4
d230 1
a230 1
    temp->refcount++;
d251 1
a251 2
    switch (lhs.ps->type()) {
    case BLACK:
d253 1
a253 1
    case WHITE:
d255 2
a256 5
    default:
	break;
    }
    switch (rhs.ps->type()) {
    case BLACK:
d258 1
a258 1
    case WHITE:
a259 3
    default:
	break;
    }
d298 1
a298 1
	  ( ( (lhs.ps->type()==BOXY) ?
d302 1
a302 1
	   ( (rhs.ps->type()==BOXY) ?
d311 1
a311 1
	return new LazyUnionIPS(lhs, rhs);
d346 1
a346 2
    switch (lhs.ps->type()) {
    case BLACK:
d348 1
a348 1
    case WHITE:
d350 2
a351 5
    default:
	break;
    }
    switch (rhs.ps->type()) {
    case BLACK:
d353 1
a353 1
    case WHITE:
a354 3
    default:
	break;
    }
d361 1
a361 1
	  ( ( (lhs.ps->type()==BOXY) ?
d365 1
a365 1
	   ( (rhs.ps->type()==BOXY) ?
d376 1
a376 1
	return new LazyIntersectionIPS(lhs,rhs);
d395 2
a396 2
    switch (lhs.ps->type()) {
    case BLACK:
d398 1
a398 1
    case WHITE:
d400 2
a401 5
    default:
	break;
    }
    switch (rhs.ps->type()) {
    case BLACK:
d403 1
a403 1
    case WHITE:
a404 3
    default:
	break;
    }
d408 1
a408 1
	  ( ( (lhs.ps->type()==BOXY) ?
d412 1
a412 1
	   ( (rhs.ps->type()==BOXY) ?
d427 1
a427 1
	BaseIPS	*temp =  new LazyXORIPS(lhs, rhs);
d473 1
a473 2
    switch (lhs.ps->type()) {
    case BLACK:
d475 1
a475 1
    case WHITE:
d477 2
a478 5
    default:
	break;
    }
    switch (rhs.ps->type()) {
    case BLACK:
d480 1
a480 1
    case WHITE:
a481 3
    default:
	break;
    }
d485 1
a485 1
	  ( ( (lhs.ps->type()==BOXY) ?
d489 1
a489 1
	   ( (rhs.ps->type()==BOXY) ?
d498 1
a498 1
	return new LazyMinusIPS(lhs,rhs);
d504 6
a509 8
  switch (ps->type()) {
  case BLACK:
    return IntPointSet(WHITE, dim());
  case WHITE:
    return BlackHole(dim());
  default:
    return new LazyNotIPS(*this);
  }
d518 1
a518 1
	return new LazyOffsettedIPS(ips, ip);
d548 1
a548 1
	    return new LazyMinkowskiIPS(lhs,rhs);
d552 1
a552 1
	    return new LazyMinkowskiIPS(rhs,lhs);
d582 4
a585 4
    switch (lhs.ps->type()) {
    case WHITE:
	switch (rhs.ps->type()) {
	case WHITE:
d587 3
a589 3
	case BLACK:
	case YODER:
	case BOXY:
d591 1
d595 2
a596 4
	break;
    case BLACK:
	switch (rhs.ps->type()) {
	case BLACK:
d598 3
a600 3
	case WHITE:
	case YODER:
	case BOXY:
d602 1
d606 3
a608 5
	break;
    case BOXY:
    case YODER:
	switch(rhs.ps->type()) {
	case WHITE:
d610 1
a610 1
	case BLACK:
d612 7
a618 6
	case BOXY:
	case YODER:
	    return compare( (lhs.ps->type()==BOXY)?
			   YoderIPS(*(BoxyIPS*)lhs.ps) : *(YoderIPS*)lhs.ps ,
			   (rhs.ps->type()==BOXY)?
			   YoderIPS(*(BoxyIPS*)rhs.ps) : *(YoderIPS*)rhs.ps);
a621 1
	break;
@


1.6
log
@the IntPointSet is now responsible for deleting hashed pointers.
dimension is now a parameter to the IntPoint array constructor.
added special code for ext/comp difference.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.C,v 1.5 92/09/07 13:21:31 thoth Exp Locker: thoth $";
d5 6
a10 1
// $Log:	IntPointSet.C,v $
d590 38
@


1.5
log
@Black and White holes can be extensive
|&^/ operators are now friends.
intersection has untested code to handle comp&ext
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.C,v 1.4 92/09/03 13:34:27 thoth Exp Locker: thoth $";
d6 5
d113 2
d121 1
a121 1
    if ( --ps->refcount <= 0 )
d123 2
d159 4
d194 1
a194 1
IntPointSet::IntPointSet(const IntPoint *aip, unsigned len)
d197 1
a197 1
	this->lookup_and_set(new _BlackHole(0));
a200 2
    unsigned dimen=aip[0].dimensions();

d305 1
a305 1
    if (lhs.ps->extensivep() && rhs.ps->extensivep()) {
d379 1
a379 6
    // if count is zero, the IntPointSet constructor will return a
    // 0-dimensional blackhole.  We don't want that.
    if (count)
	return IntPointSet(arr,count);
    else
	return BlackHole(ext.dim());
d408 2
a409 2
    lext = lhs.ps->extensivep();
    rext = rhs.ps->extensivep();
d431 1
a431 1

d463 1
a463 1
    if (lhs.ps->extensivep() && rhs.ps->extensivep()) {
d476 11
a486 2
	return new LazyXORIPS(lhs,rhs);
    }
d488 1
d495 21
d547 1
a547 1
    if (lhs.ps->extensivep() && rhs.ps->extensivep()) {
d559 2
@


1.4
log
@hash_self now deals with unsigneds
I unnamed unused formal parameters
lazy point sets now exist
(but operators & and / need adjustment)
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.C,v 1.3 92/08/26 13:43:37 thoth Exp Locker: thoth $";
d6 6
d32 1
d58 1
a58 1
    int extensivep() const { return 1;}
d92 1
a92 1
    int extensivep() const { return 0;}
d263 1
a263 1
IntPointSet IntPointSet::operator|(const IntPointSet &rhs) const
d265 1
a265 1
    if (this->dim() != rhs.dim()) {
d267 1
a267 1
	// cout << this->dim() << "!=" << rhs.dim() << '\n' << flush;
d272 2
a273 2
    cout << '|'<< this->dim() << "==" << rhs.dim() << '\n' << flush;
    this->output(cout);
d277 1
a277 1
    switch (this->ps->type()) {
d281 1
a281 1
	return *this;
d287 1
a287 1
	return *this;
d294 1
a294 1
    if (this->ps->extensivep() && rhs.ps->extensivep()) {
d297 1
a297 1
	switch (this->ps->type()) {
d299 1
a299 1
	    left = new YoderIPS(*(BoxyIPS*)this->ps);
d302 1
a302 1
	    left = (YoderIPS*)this->ps;
d325 1
a325 1
	if (left != this->ps)
d331 3
a333 3
	  ( ( (this->ps->type()==BOXY) ?
	     YoderIPS(*(BoxyIPS*)this->ps) :
	     *(YoderIPS*)this->ps )
d344 1
a344 1
	return new LazyUnionIPS(*this, rhs);
d348 7
a354 1
IntPointSet IntPointSet::operator&(const IntPointSet &rhs) const
d356 23
a378 1
    if (this->dim() != rhs.dim()) {
d384 1
a384 1
    switch (this->ps->type()) {
d386 1
a386 1
	return *this;
d396 1
a396 1
	return *this;
d400 5
a404 2
    
    if (this->ps->extensivep() && rhs.ps->extensivep()) {
d406 3
a408 3
	  ( ( (this->ps->type()==BOXY) ?
	     YoderIPS(*(BoxyIPS*)this->ps) :
	     *(YoderIPS*)this->ps )
d416 4
d421 1
a421 1
	return new LazyIntersectionIPS(*this,rhs);
d426 1
a426 1
IntPointSet IntPointSet::operator^(const IntPointSet &rhs) const
d428 1
a428 1
    if (this->dim() != rhs.dim()) {
d430 1
a430 1
	// cout << this->dim() << "!=" << rhs.dim() << '\n' << flush;
d435 2
a436 2
    cout << '^'<< this->dim() << "==" << rhs.dim() << '\n' << flush;
    this->output(cout);
d440 1
a440 1
    switch (this->ps->type()) {
d450 1
a450 1
	return *this;
d452 1
a452 1
	return ~*this;
d457 1
a457 1
    if (this->ps->extensivep() && rhs.ps->extensivep()) {
d459 3
a461 3
	  ( ( (this->ps->type()==BOXY) ?
	     YoderIPS(*(BoxyIPS*)this->ps) :
	     *(YoderIPS*)this->ps )
d470 1
a470 1
	return new LazyXORIPS(*this,rhs);
d479 1
a479 1
IntPointSet IntPointSet::operator/(const IntPointSet &rhs) const
d481 1
a481 1
    if (this->dim() != rhs.dim()) {
d483 1
a483 1
	// cout << this->dim() << "!=" << rhs.dim() << '\n' << flush;
d488 2
a489 2
    cout << '-'<< this->dim() << "==" << rhs.dim() << '\n' << flush;
    this->output(cout);
d493 1
a493 1
    switch (this->ps->type()) {
d495 1
a495 1
	return *this;
d503 1
a503 1
	return *this;
d505 1
a505 1
	return BlackHole(this->dim());
d510 1
a510 1
    if (this->ps->extensivep() && rhs.ps->extensivep()) {
d512 3
a514 3
	  ( ( (this->ps->type()==BOXY) ?
	     YoderIPS(*(BoxyIPS*)this->ps) :
	     *(YoderIPS*)this->ps )
d523 1
a523 1
	return new LazyMinusIPS(*this,rhs);
d549 1
@


1.3
log
@meaningful exception types
eliminated dummy parameter to constructor (was workaround for g++)
aborts are clearly labeled and less common
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.C,v 1.2 92/08/25 15:28:48 thoth Exp Locker: thoth $";
d6 5
d34 1
d47 1
a47 1
    int hash_self(int) const { return 0; }
d50 1
a50 1
    unsigned index(const IntPoint &ip) const { return 0; }
d58 1
a58 1
    BaseIPS *offsetted(const IntPoint &ip) const
d77 1
a77 1
    int hash_self(int) const { return 1+dimen; }
d80 1
a80 1
    unsigned index(const IntPoint &ip) const {
d88 1
a88 1
    BaseIPS *offsetted(const IntPoint &ip) const
d336 2
a338 4

    // no lazy point sets yet
    abort(); // internal error
    return IntPointSet();
d378 2
a380 4

    // no lazy point sets yet
    abort(); // internal error
    return IntPointSet();
d427 2
a429 4

    // no lazy point sets yet
    abort(); // internal error
    return IntPointSet();
d480 2
a482 4

    // no lazy point sets yet
    abort(); // internal error
    return IntPointSet();
d493 1
a493 2
    abort(); // NYI
    return IntPointSet();
d500 4
a503 1
    return ips.ps->offsetted(ip);
@


1.2
log
@new offsetted virtual functions
new converter from IntPoint to IntPointSet.
CFront supports agregates in ternary, wheee!
set difference is operator/, not -
operator+ is set translation, using the offsetted() function of BaseIPS
lattice operations on sets defined in terms of compare() friend
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.C,v 1.1 92/08/23 13:30:13 thoth Exp Locker: thoth $";
d6 8
d48 1
a48 1
	    ia_throw(IA::INVALID_OPERATION,__FILE__,__LINE__);
d61 1
a61 1
IntPointSet WhiteHole(WHITE, 'b', 0);
d71 1
a71 1
    int hash_self(int) const { return 1; }
d76 1
a76 1
	    ia_throw(IA::INVALID_OPERATION, __FILE__,__LINE__);
d111 1
a111 1
IntPointSet::IntPointSet(PointSetType t, int dummy, unsigned dim)
d121 3
a123 1
	abort();
d179 2
a180 2
	    abort();
	    this->ps=0;
d255 1
a255 1
	ia_throw(IA::INVALID_OPERATION, __FILE__, __LINE__);
d293 1
a293 1
	    abort();
d306 1
a306 1
	    abort();
d333 1
a333 1
    abort();
d341 1
a341 1
	ia_throw(IA::INVALID_OPERATION, __FILE__, __LINE__);
d377 1
a377 1
    abort();
d387 1
a387 1
	ia_throw(IA::INVALID_OPERATION, __FILE__, __LINE__);
d428 1
a428 1
    abort();
d442 1
a442 1
	ia_throw(IA::INVALID_OPERATION, __FILE__, __LINE__);
d483 1
a483 1
    abort();
d489 1
a489 1
  switch (this->ps->type()) {
d491 1
a491 1
    return IntPointSet(WHITE, 'b', this->dim());
d493 1
a493 1
    return BlackHole(this->dim());
d495 1
a495 1
    abort();
d513 1
a513 1
	ia_throw(IA::INVALID_OPERATION, __FILE__, __LINE__);
@


1.1
log
@Initial revision
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IntPointSet.cc,v 1.6 92/08/20 11:10:41 thoth Exp $";
d5 3
a7 1
// $Log:	IntPointSet.cc,v $
d9 1
d44 2
d74 2
d117 5
d272 1
a272 1
#if 1
d353 9
a361 13
	YoderIPS	*left, *right;
	switch (this->ps->type()) {
	case BOXY:
	    left = new YoderIPS(*(BoxyIPS*)this->ps);
	    break;
	case YODER:
	    left = (YoderIPS*)this->ps;
	    break;
	default:
	    // the other extensive pointsets were taken care of before.
	    abort();
	    break;
	}
a362 20
	switch (rhs.ps->type()) {
	case BOXY:
	    right = new YoderIPS(*(BoxyIPS*)rhs.ps);
	    break;
	case YODER:
	    right = (YoderIPS*)rhs.ps;
	    break;
	default:
	    // the other extensive pointsets were taken care of before.
	    abort();
	    break;
	}

	YoderIPS result( *left & *right );

	if (left != this->ps)
	    delete left;
	if (right != rhs.ps)
	    delete right;

d404 9
a412 13
	YoderIPS	*left, *right;
	switch (this->ps->type()) {
	case BOXY:
	    left = new YoderIPS(*(BoxyIPS*)this->ps);
	    break;
	case YODER:
	    left = (YoderIPS*)this->ps;
	    break;
	default:
	    // the other extensive pointsets were taken care of before.
	    abort();
	    break;
	}
a413 20
	switch (rhs.ps->type()) {
	case BOXY:
	    right = new YoderIPS(*(BoxyIPS*)rhs.ps);
	    break;
	case YODER:
	    right = (YoderIPS*)rhs.ps;
	    break;
	default:
	    // the other extensive pointsets were taken care of before.
	    abort();
	    break;
	}

	YoderIPS result( *left ^ *right );

	if (left != this->ps)
	    delete left;
	if (right != rhs.ps)
	    delete right;

d423 5
a427 1
IntPointSet IntPointSet::operator-(const IntPointSet &rhs) const
d459 9
a467 13
	YoderIPS	*left, *right;
	switch (this->ps->type()) {
	case BOXY:
	    left = new YoderIPS(*(BoxyIPS*)this->ps);
	    break;
	case YODER:
	    left = (YoderIPS*)this->ps;
	    break;
	default:
	    // the other extensive pointsets were taken care of before.
	    abort();
	    break;
	}
a468 20
	switch (rhs.ps->type()) {
	case BOXY:
	    right = new YoderIPS(*(BoxyIPS*)rhs.ps);
	    break;
	case YODER:
	    right = (YoderIPS*)rhs.ps;
	    break;
	default:
	    // the other extensive pointsets were taken care of before.
	    abort();
	    break;
	}

	YoderIPS result( *left - *right );

	if (left != this->ps)
	    delete left;
	if (right != rhs.ps)
	    delete right;

d488 107
@
