/****************************************************************************
 *   gops.h : 
 *   		header file for GFC Ordered Point Set.
 *
 *   Change Log :
 *		 July 1, 1998 Initial version,  Liujian Qian
 *
 *   $Id: gops.h,v 1.11 1998/12/10 00:11:41 qian Exp $
 ***************************************************************************/
#ifndef _GOPS_H_
#define _GOPS_H_

#include "gadt_rect.h"

/**
 * Class for generic Ordered Point Sets.
 *
 * Each OPS object contains several "parts" that are
 * a series of ordered points or vertices (pairs of
 * x,y coordinates).  GOps provides the infrastructure
 * for defining ADTs such as GPolygon and GArc, both 
 * are essentially represented by multiple 
 * parts of ordered series of points (In the case of GArc,
 * the parts are the branches; while for GPolygon the
 * parts are the holes or rings). GOps provides the
 * basic functionalities for manipulating such point
 * sets. 
 * 
 */
class GOps : public GObject
{
private:
    
    //these stuff are for in-memory house-keeping only
    uint32  parts_cap; //current capacity of the parts buffer
    uint32  point_cap; //current capacity of the coord buffer

    //these are the amounts each time the capacities gets increaseed.
    enum { parts_inc=5};   	// 2's power of 5: 32-part (integer) increment
    enum { point_inc=6};	// 2's power of 6: 64-point increment

    //the buffer for "output" method.
    DataPipe bp;    

public:
    enum {max_parts=1024};

    //these stuff are what gets actually stored to the disk
    //when necessary.
    Coord  xl,yl,zl,xh,yh,zh; //the MBR of the OPS.    
    int    n_points; //total # of points 
    int    n_parts;  //# of parts or separable ordered point sets
    int*   parts;    //an array holding the # of points for each part
    Coord* coord;    //the coordinates for all the points.

public:
    /**
     */
    GOps();
    /**
     */
    GOps(const GOps& o);
    /**
     */
    GOps&  operator= (const GOps& other);
    /**
     */
    virtual ~GOps();
    
    virtual Result 	init (void) ;
    virtual uint32 	getPSize () const ;
    
    virtual Result 	input (const char* ) ;
    
    virtual Result 	output (char*& ) ;
    
    virtual Result 	pack (DataPipe& ) ;
    
    virtual Result 	unpack (DataPipe& ) ;

    virtual Result      mbr(GRect& r) const;
    virtual Result	calcMbr(GRect& r) ;
    virtual void	setMbr(const GRect& r);
    virtual Result      scale      (double xf, double yf, double zf=1);
    virtual Result      translate  (double xf, double yf, double zf=1);
    virtual Result	rotate	   (double, bool);
    virtual Result	transform  (const GMatrix&);

    /**
     * add a part, which is just an array of coordinate pairs.
     */
    virtual Result	addPart (int n_pnts, Coord* c);
    /**
     * return the information about a specific part.
     */
    virtual int		getPart (int nth, Coord*& cp);
    /**
     * return the number of points (pairs of cooridnates) in the nth part
     */
    virtual int		getPartSize(int nth);
    
    virtual void	set(int n_parts, int n_pnts, const int* parts, 
			    const Coord* coord);
    /**
     * total length of all the parts.
     */
    virtual double	totalLength() const;
    /**
     * return the length of the nth part
     */
    virtual double	partLength(int nth) const;

    //topological operations
    virtual int		isInside(const GRect& r) const;
    virtual int		isInside(const GCircle& c) const;

    virtual int		intersects(int n_pnts, Coord* coo) const;
    virtual int		intersects(const GSegment& seg_in) const;
    virtual int		intersects(const GRect& r) const;
    virtual int		intersects(const GCircle& c) const;
    virtual int		intersects(const GOps& other) const;
    
    friend  ostream&	operator<<(ostream&, const GOps& o);
    
    friend DataPipe& 	operator<< (DataPipe& p, GObject& a) ;
    
    friend DataPipe& 	operator>> (DataPipe& p, GObject& a)  ;


    int 		PointCapacity(int n_pnts);
    int 		PartsCapacity(int n_parts);

    virtual Result 	extendPartsTo(int n, bool keep);
    virtual Result 	extendPointTo(int n, bool keep);

	
};

#endif
	


Documentation generated by lqian@lqian-sun on Wed Jul 14 09:36:10 EDT 1999