head	1.23;
access;
symbols
	bobbase:1.21
	bob:1.21.1
	r2_1:1.21
	r2_0:1.21
	r1_1_beta:1.21
	r1_1_alpha:1.20
	r1_0:1.20
	r0_11:1.20
	r0_10:1.20
	r0_9:1.20
	Eglin_alpha_1:1.17;
locks
	thoth:1.21.1.1; strict;
comment	@// @;


1.23
date	94.12.06.18.43.53;	author gmt;	state Exp;
branches;
next	1.22;

1.22
date	94.12.03.03.27.28;	author fjsoria;	state Exp;
branches;
next	1.21;

1.21
date	94.07.25.16.49.03;	author thoth;	state Exp;
branches
	1.21.1.1;
next	1.20;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

1.21.1.1
date	95.02.06.18.07.48;	author thoth;	state Exp;
branches;
next	;


desc
@header file for the Base of the IntPointSet data structures
@


1.23
log
@Put in guarded returns in situations where IA_NO_CONSTRUCTOR_ON_RETURN
applies.
@
text
@// Emacs: -*- C++ -*-

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

// 
// $Log: BasePS.h,v $
// Revision 1.22  1994/12/03  03:27:28  fjsoria
// fixing screw up with chages to hash_managed_delete and
// with outline function problem t(all outlines are now
// inlines)
//
// Revision 1.21  1994/07/25  16:49:03  thoth
// Use IA::Type instead of IA_PointSetType.
//
// Revision 1.20  1993/11/17  18:02:03  thoth
// extensivep() is now extensive()
//
// Revision 1.19  1993/08/08  13:11:06  thoth
// deInline some of the fallback virtual functions.
//
// Revision 1.18  93/07/15  11:34:09  thoth
// eliminate cruft.
// Add support for iterator virtual method.
// 
// Revision 1.17  93/06/10  17:14:48  thoth
// *** empty log message ***
// 
// Revision 1.16  93/05/26  16:40:51  thoth
// Copyright Notices.
// 
// Revision 1.15  93/02/12  16:25:38  thoth
// more IA_ prefixes.
// more comments.
// 
// Revision 1.14  92/12/16  14:47:55  thoth
// conversion to IA_ mostly complete
// 
// Revision 1.13  92/12/07  12:05:07  thoth
// new IntPoint index(unsigned) operation for use with "other" iterators.
// 
// Revision 1.12  92/09/30  10:23:47  thoth
// BasePS is now templatized
// infimum & supremum virtuals now inf & sup
// contains now accepts const Point<>&
// type() system now based on address of static data member
// reference counts are protected from IntPointSet, unfortunately
// 
// Revision 1.11  92/09/20  17:37:31  thoth
// fixed spelling error
// 
// Revision 1.10  92/09/20  14:04:20  thoth
// new infimum and supremum methods for point sets.
// 
// Revision 1.9  92/09/03  13:29:58  thoth
// hash_self now deals with unsigneds
// offsetted is only valid for extensives
// lazy point sets now exist
// 
// Revision 1.8  92/08/26  13:41:58  thoth
// meaningful exception types
// 
// Revision 1.7  92/08/25  15:28:36  thoth
// new offsetted virtual functions
// 
// Revision 1.6  92/08/23  13:29:44  thoth
// CFrontified version
// 
// 

#ifndef BasePS_h_
#define BasePS_h_

#ifdef IA_PRII
#pragma interface
#endif

#include "ia.h"

#include "Point.h"
#include "IntPoint.h"
#include "DblPoint.h"
/*

  The BasePS class defines the interface for all PS objects derived
from it.  It has no information about implementation of classes
derived from it and therefore most of its virtual functions are
abstract.

  The functions that MUST be defined by each derived class are
abstract.

  A few of the virtual functions have bodies that throw.  This is
because most derived classes would also throw.  The default throw
prevents the duplication of code that would occurr if each were
abstract and every derived class would have to write its own version
that threw.

*/


template <class P>
class IA_BasePSIter;

template <class P_t>
class IA_BasePS {
private:
    int	refcount;
protected:
    unsigned		dimen;
public:
    // Take care of data members so derived classes don\'t have to worry.
    IA_BasePS(unsigned dim) { dimen = dim; refcount=0; }
    // Destructors can never be abstract.
    virtual ~IA_BasePS() {
	// nothing to clean up
    }
							
    // This method is for the hash table.  It returns true iff the BasePS*
    // points to an object of the same class as *this, and the other IPS
    // is structurally equivalent.
    virtual int equal(IA_BasePS*) const =0;

    // This method is for the hash table.  It returns a value that is
    // uniquely determined by the points in the point set.
    virtual unsigned hash_self(unsigned) const =0;

    // This function returns a number that is distinct to every non-abstract
    // class derived from us.  Please return the address of a static data
    // member.
    virtual IA::Type type() const =0;

    // The dimensionality of the point set
    unsigned dim() const { return dimen; }

    // Returns nonzero iff the P_t is a member of the point set.
    virtual int contains(const P_t&) const =0;

    // Returns the index of the point inside the iteration order of
    // the pointset.  It is an error if the point is not contained.
    // It is an error if the point set is not extensive.
    virtual unsigned index(const P_t&) const {
      ia_throw(IA::PSET_REQUIRE_EXTENSIVE,__FILE__,__LINE__);
#if 0
      // we should put this var in class IA
      return PS_t::index_of_uncontained;
#else
      return ~0;
#endif
    }
  
  // And here is the inverse of the previous function
    virtual P_t index(unsigned) const  {
     ia_throw(IA::PSET_REQUIRE_EXTENSIVE,__FILE__,__LINE__);
#if 0
     // we should put this var in class IA
     return PS_t::index_of_uncontained;
#else
#ifdef IA_NO_CONSTRUCTOR_ON_RETURN
      P_t tmp( ~0 );
      return tmp;
#else
     return ~0;
#endif
#endif
   }
  
    // Returns the lexicographically minimum point in the point set
    virtual P_t min() const{
      ia_throw(IA::PSET_REQUIRE_EXTENSIVE,__FILE__,__LINE__);
#ifdef IA_NO_CONSTRUCTOR_ON_RETURN
      P_t tmp;
      return tmp;
#else
      return P_t();
#endif
    }
  // Returns the lexicographically maximum point in the point set
    virtual P_t max() const {
      ia_throw(IA::PSET_REQUIRE_EXTENSIVE,__FILE__,__LINE__);
#ifdef IA_NO_CONSTRUCTOR_ON_RETURN
      P_t tmp;
      return tmp;
#else
      return P_t();
#endif
    }
  
    // The infimum of the pointset. (greatest lower bound)
    virtual P_t inf() const{
      ia_throw(IA::PSET_REQUIRE_EXTENSIVE,__FILE__,__LINE__);
#ifdef IA_NO_CONSTRUCTOR_ON_RETURN
      P_t tmp;
      return tmp;
#else
      return P_t();
#endif
    }
    // The supremum of the pointset. (least upper bound)
    virtual P_t sup() const {
      ia_throw(IA::PSET_REQUIRE_EXTENSIVE,__FILE__,__LINE__);
#ifdef IA_NO_CONSTRUCTOR_ON_RETURN
      P_t tmp;
      return tmp;
#else
      return P_t();
#endif
    }
  
    // returns a point in the point set.  Which point it returns is not
    // specified or guaranteed.
    // do we need this any more?
    virtual P_t choice() const {
      ia_throw(IA::PSET_REQUIRE_EXTENSIVE,__FILE__,__LINE__);
#ifdef IA_NO_CONSTRUCTOR_ON_RETURN
      P_t tmp;
      return tmp;
#else
      return P_t();
#endif
    }
    // returns a count of the number of points in the point set.
    virtual unsigned card() const {
	ia_throw(IA::PSET_REQUIRE_EXTENSIVE,__FILE__,__LINE__);
	return 0;
    }

    // returns true iff the point set contains no points
    virtual int empty() const {
	ia_throw(IA::PSET_REQUIRE_EXTENSIVE,__FILE__,__LINE__);
	return 0;
    }

    // Returns a pointer to something derived from BasePS allocated
    // on the heap.  The something is "similar" to this pointset, but
    // all the points are translated by the argument.
    virtual IA_BasePS * offsetted(const P_t &) const{
	// This should be defined to return a lazy by default.
	ia_throw(IA::PSET_REQUIRE_EXTENSIVE,__FILE__,__LINE__);
	return 0;
    }

    // Returns true if it is possible to iterate over this point set.
    // extensiveness implies many things.  Lack of extensiveness makes
    // the equal, hash_self, index, min, max, inf, sup, choice, card
    // and empty methods meaningless.
    virtual int extensive() const =0;

    // returns a pointer to an iterator over the pointset
    virtual IA_BasePSIter<P_t> *iterator() const {
	ia_throw(IA::PSET_REQUIRE_EXTENSIVE,__FILE__,__LINE__);
	return 0;
    }

    // A debugging function.
    virtual void output(ostream&, unsigned=0) const =0;

    // So anyone can frob the reference count.
    // Don\'t try this at home, kids.
    void enref() { refcount++; }
    int unref() { return --refcount; }
    // friend class PS_t;
};

// handles the hash table for IntPointSets,
// just does the refcount for DblPointSets
// commented out make hash_managed_delete a ROF

//template <class P>
//void hash_managed_delete(IA_BasePS<P> *);


void hash_managed_delete(IA_BasePS<IA_Point<int> > *);
void hash_managed_delete(IA_BasePS<IA_Point<double> > *);

#endif
@


1.22
log
@fixing screw up with chages to hash_managed_delete and
with outline function problem t(all outlines are now
inlines)
@
text
@d10 5
d161 4
d167 1
d173 4
d178 1
d183 4
d188 1
d194 4
d199 1
d204 4
d209 1
d217 4
d222 1
@


1.21
log
@Use IA::Type instead of IA_PointSetType.
@
text
@d10 3
d78 2
a79 1

d139 21
a159 5
    virtual unsigned index(const P_t&) const;

    // And here is the inverse of the previous function
    virtual P_t index(unsigned) const;

d161 10
a170 5
    virtual P_t min() const;

    // Returns the lexicographically maximum point in the point set
    virtual P_t max() const;

d172 4
a175 2
    virtual P_t inf() const;

d177 5
a181 2
    virtual P_t sup() const;

d185 4
a188 2
    virtual P_t choice() const;

d231 11
@


1.21.1.1
log
@Conversion to throws of classes instead of enums.
new reflect_through_origin() method.
hash_managed_delete for BasePS deletions.
@
text
@a9 3
// Revision 1.21  1994/07/25  16:49:03  thoth
// Use IA::Type instead of IA_PointSetType.
//
a75 2
#include "pset_errors.h"

d159 1
a159 1
	ia_throw(Pointset_RequireExtensive_Exception(__FILE__, __LINE__));
d165 1
a165 1
	ia_throw(Pointset_RequireExtensive_Exception(__FILE__, __LINE__));
d174 1
a174 1
	ia_throw(Pointset_RequireExtensive_Exception(__FILE__, __LINE__));
a177 2
    virtual IA_BasePS * reflect_through_origin() const;

d186 1
a186 1
	ia_throw(Pointset_RequireExtensive_Exception(__FILE__, __LINE__));
a198 5

// handles the hash table for IntPointSets,
// just does the refcount for DblPointSets
template <class P>
void hash_managed_delete(IA_BasePS<P> *);
@


1.20
log
@extensivep() is now extensive()
@
text
@d10 3
a93 1
typedef const char * IA_PointSetType;
d124 1
a124 1
    virtual IA_PointSetType type() const =0;
@


1.19
log
@deInline some of the fallback virtual functions.
@
text
@d9 4
a12 1
// $Log:	BasePS.h,v $
d180 1
a180 1
    virtual int extensivep() const =0;
@


1.18
log
@eliminate cruft.
Add support for iterator virtual method.
@
text
@d10 4
d68 1
d136 1
a136 4
    virtual P_t min() const {
	ia_throw(IA::PSET_REQUIRE_EXTENSIVE,__FILE__,__LINE__);
	return P_t();
    }
d139 1
a139 4
    virtual P_t max() const {
	ia_throw(IA::PSET_REQUIRE_EXTENSIVE,__FILE__,__LINE__);
	return P_t();
    }
d142 1
a142 4
    virtual P_t inf() const {
	ia_throw(IA::PSET_REQUIRE_EXTENSIVE,__FILE__,__LINE__);
	return P_t();
    }
d145 1
a145 4
    virtual P_t sup() const {
	ia_throw(IA::PSET_REQUIRE_EXTENSIVE,__FILE__,__LINE__);
	return P_t();
    }
d150 1
a150 4
    virtual P_t choice() const {
	ia_throw(IA::PSET_REQUIRE_EXTENSIVE,__FILE__,__LINE__);
	return P_t();
    }
@


1.17
log
@*** empty log message ***
@
text
@d10 3
a63 2
#if 0
/* now obsolete */
a64 12
/* This is an enumerated type which is returned by the BaseIPS pure
virtual function type().  Each object derived from BaseIPS should have
a unique identifier in this enum */

enum PointSetType {
  WHITE, BLACK, BOXY, YODER, L_PRED,
  L_UNION, L_INTERSECT, L_XOR, L_MINUS, L_MINKOWSKI,
  L_NOT, L_OFFSET
};
#endif


d85 3
d188 6
@


1.16
log
@Copyright Notices.
@
text
@d10 3
d94 1
a94 1
typedef const char * const IA_PointSetType;
@


1.15
log
@more IA_ prefixes.
more comments.
@
text
@d3 5
d10 4
@


1.14
log
@conversion to IA_ mostly complete
@
text
@d5 3
d82 1
a82 1
typedef const char * const PointSetType;
d91 1
d93 1
a93 1
    // destructors can never be abstract
d98 1
a98 1
    // this member is for the hash table.  It returns true iff the BasePS*
d103 1
a103 1
    // this member is for the hash table.  It returns a value that is
d110 1
a110 1
    virtual PointSetType type() const =0;
d112 1
a112 1
    // the dimensionality of the point set
d115 1
a115 2
    // returns true iff the P_t is a member of the point set
    // we will eventually guarantee that this returns 0 or 1 only
d118 1
a118 1
    // returns the index of the point inside the iteration order of
d122 2
d126 1
a126 1
    // returns the lexicographically minimum point in the point set
d132 1
a132 1
    // returns the lexicographically maximum point in the point set
d138 1
d144 1
d152 1
d170 3
a172 1
    // this should be defined to return a lazy by default.
d174 1
d179 1
a179 1
    // returns true if it is possible to iterate over this point set.
d181 2
a182 2
    // the equal, hash_self, index, min, max, choice, card and empty
    // methods meaningless.
d185 1
a185 1
    // a debugging function.
d188 2
a189 1
    // so anyone can frob the reference count
@


1.13
log
@new IntPoint index(unsigned) operation for use with "other" iterators.
@
text
@d5 3
d82 1
a82 1
class BasePS {
d88 1
a88 1
    BasePS(unsigned dim) { dimen = dim; refcount=0; }
d90 1
a90 1
    virtual ~BasePS() {
d97 1
a97 1
    virtual int equal(BasePS*) const =0;
d163 1
a163 1
    virtual BasePS * offsetted(const P_t &) const{
@


1.12
log
@BasePS is now templatized
infimum & supremum virtuals now inf & sup
contains now accepts const Point<>&
type() system now based on address of static data member
reference counts are protected from IntPointSet, unfortunately
@
text
@d5 7
d116 1
@


1.11
log
@fixed spelling error
@
text
@d4 4
a7 1
// $Log:	BaseIPS.h,v $
d27 2
a28 2
#ifndef BaseIPS_h_
#define BaseIPS_h_
a34 1
#include "IntPoint.h"
d36 3
d48 1
d53 1
a53 1
  The BaseIPS class defines the interface for all IPS objects derived
d69 1
a69 1
class IntPointSet;
d71 2
a72 1
class BaseIPS {
d78 1
a78 1
    BaseIPS(unsigned dim) { dimen = dim; refcount=0; }
d80 1
a80 1
    virtual ~BaseIPS() {
d84 1
a84 1
    // this member is for the hash table.  It returns true iff the BaseIPS*
d87 1
a87 1
    virtual int equal(BaseIPS*) const =0;
d92 4
a95 1
    
d101 1
a101 1
    // returns true iff the IntPoint is a member of the point set
d103 1
a103 1
    virtual int contains(IntPoint) const =0;
d108 1
a108 1
    virtual unsigned index(const IntPoint&) const;
d111 1
a111 1
    virtual IntPoint min() const {
d113 1
a113 1
	return IntPoint();
d117 1
a117 1
    virtual IntPoint max() const {
d119 1
a119 1
	return IntPoint();
d122 1
a122 1
    virtual IntPoint infimum() const {
d124 1
a124 1
	return IntPoint();
d127 1
a127 1
    virtual IntPoint supremum() const {
d129 1
a129 1
	return IntPoint();
d134 1
a134 1
    virtual IntPoint choice() const {
d136 1
a136 1
	return IntPoint();
d152 1
a152 1
    virtual BaseIPS * offsetted(const IntPoint &) const{
d166 4
a169 2
    // so he can frob the reference count
    friend class IntPointSet;
@


1.10
log
@new infemum and supremum methods for point sets.
@
text
@d5 3
d112 1
a112 1
    virtual IntPoint infemum() const {
@


1.9
log
@hash_self now deals with unsigneds
offsetted is only valid for extensives
lazy point sets now exist
@
text
@d5 5
d89 1
d105 10
@


1.8
log
@meaningful exception types
@
text
@d5 3
d31 3
a33 1
  WHITE, BLACK, BOXY, YODER
d76 1
a76 1
    virtual int hash_self(int) const =0;
d123 4
a126 1
    virtual BaseIPS * offsetted(const IntPoint &) const=0;
@


1.7
log
@new offsetted virtual functions
@
text
@d5 3
d88 1
a88 1
	ia_throw(IA::INVALID_OPERATION,__FILE__,__LINE__);
d94 1
a94 1
	ia_throw(IA::INVALID_OPERATION,__FILE__,__LINE__);
d101 1
a101 1
	ia_throw(IA::INVALID_OPERATION,__FILE__,__LINE__);
d107 1
a107 1
	ia_throw(IA::INVALID_OPERATION,__FILE__,__LINE__);
d113 1
a113 1
	ia_throw(IA::INVALID_OPERATION,__FILE__,__LINE__);
@


1.6
log
@CFrontified version
@
text
@d5 2
d8 1
d113 3
@


1.5
log
@Reference counting is now the responsibility of IntPointSet
@
text
@a4 2
// Revision 1.4  92/08/14  15:45:04  thoth
// Added an index(IntPoint) function to the IntPointSet
a5 10
// Revision 1.3  92/07/26  16:27:26  thoth
// Added some comments so people might be able to understand the code.
// 
// Revision 1.2  92/07/21  11:16:47  thoth
// most IPS members are const
// 
// Revision 1.1  92/07/16  11:49:17  thoth
// Initial revision
// 
// 
d10 1
d12 1
a55 1
	return;
d82 1
a82 1
	throw(IA::INVALID_OPERATION,__FILE__,__LINE__);
d88 1
a88 1
	throw(IA::INVALID_OPERATION,__FILE__,__LINE__);
d95 1
a95 1
	throw(IA::INVALID_OPERATION,__FILE__,__LINE__);
d101 1
a101 1
	throw(IA::INVALID_OPERATION,__FILE__,__LINE__);
d107 1
a107 1
	throw(IA::INVALID_OPERATION,__FILE__,__LINE__);
@


1.4
log
@Added an index(IntPoint) function to the IntPointSet
@
text
@d5 3
d54 2
d57 2
d62 1
d128 5
a132 4
    // We don't really need to be friends with the base,
    // just all derived classes.
    //
    // friend class IntPointSet;
@


1.3
log
@Added some comments so people might be able to understand the code.
@
text
@d5 3
d78 5
d116 2
a117 2
    // the equal, hash_self, min, max, choice, card and empty methods
    // meaningless.
@


1.2
log
@most IPS members are const
@
text
@d5 3
d21 4
a28 1
// should some of these abstract functions throw?
d30 18
d58 3
d62 3
d68 2
d72 1
d75 1
d80 2
d86 3
d94 1
d99 2
d105 5
@


1.1
log
@Initial revision
@
text
@d4 3
a6 1
// $Log$
d8 1
d42 1
a42 1
    virtual IntPoint min() {
d46 1
a46 1
    virtual IntPoint max() {
d50 1
a50 1
    virtual IntPoint choice() {
d55 1
a55 1
    virtual unsigned card() {
d59 1
a59 1
    virtual int empty() {
@
