head	1.2;
access;
symbols;
locks; strict;
comment	@// @;


1.2
date	94.08.26.03.51.55;	author rjj;	state Exp;
branches;
next	1.1;

1.1
date	94.06.20.05.32.43;	author rjj;	state Exp;
branches;
next	;


desc
@Initial control version.
@


1.2
log
@Modifed includes to conform with iac++ v2.0.
Modifed enorm() call to use the non-member function version.
@
text
@// shaped-pointset.c
//      Copyright 1994, Center for Computer Vision and Visualization,
//      University of Florida.  All rights reserved.


#include "DblPoint.h"
#include "shaped-pointset.h"
#include "ClosurePS.h"


////////////////////////////////////////////////////////////////////////
// Here we define some functions to create various sizes of shaped 
//      pointsets.
// While it would be possible to define a class IA_ShapedPS, derived
//      from IA_Set, it is not clear what benefit that might have for
//      now, so we will just defined functions that will return the
//      correct IA_Set<P>

IA_Set<IA_Point<int> >
cross_hair( const IA_Point<int> & start_point,
	    unsigned int radius ) {

    IA_Point<int>
	start, end;
    IA_Set<IA_Point<int> >
	result(start_point);

    for (unsigned int d=0; d<start_point.dim(); d++) {
	start = start_point;
	end   = start_point;

	start[d] += radius;
	end[d]   -= radius;

	// We will build the point set by unioning up on each dimension.
	result   |= IA_boxy_pset(start,end);
    }

    return result;
}



////////////////////////////////////////////////////////////////////////
// digital_disc()
//   We will try this one by defining a function PS that will be round
//   and then restrict it to an extensive point set.

class roundPS: public IA_ClosurePS<IA_Point<int> > {
private:
    IA_Point<int>  center;
    double         radius;
public:
    roundPS( const IA_Point<int> & _center, double _radius )
    : IA_ClosurePS<IA_Point<int> >( _center.dim() ),
      center( _center ), radius( _radius ) { }

    int contains( const IA_Point<int> & p ) const {
	return
	    enorm(this->center - p) <= radius;
    }

    IA_ClosurePS<IA_Point<int> > * clone_self() const {
	return new roundPS(center,radius);
    }
};



IA_Set<IA_Point<int> >
digital_disc( const IA_Point<int> & center, double radius ) {
    // we return the intersection of the disc and a close to
    //    minimal containing bounding box
    IA_Point<int>
	top_left(     trunc(center-radius-1) ),
	bottom_right( trunc(center+radius+1) );

    return
	roundPS( center, radius )
	& IA_boxy_pset( top_left, bottom_right );
}

@


1.1
log
@Initial revision
@
text
@d6 1
a6 1
#include "FloatPoint.h"
d60 1
a60 1
	    (this->center - p).enorm() <= radius;
@
