#ifndef IPolyg2_HH #define IPolyg2_HH //////////////////////////////////////////////////////////////////////// //! file="amma/Geometry/CmpGeo2d/IPolyg2.hh" //! lib=Mcg2 //! userlevel=Normal //! author="Radek Marik" //! docentry="Geometry.2-D" //! date="20.12.1994" //! rcsid="$Id: IPolyg2.hh,v 1.9 1999/10/11 12:22:24 ees1cg Exp $" #include "amma/StdType.hh" #include "amma/Index2d.hh" #include "amma/DList.hh" #include "amma/EdgeList.hh" class istream; class ostream; class IntRectangleTPC; typedef DListC Index2ListC; //==================================================================== //======= IntPolygon2dC ============================================== //==================================================================== //: An integer polygon in 2d space // The IntPolygon2dC class is a representation of a polygon in 2 dimensional // digital space. A polygon is the region of a plane bounded by // a finite collection of line segments forming a simple closed curve. class IntPolygon2dC: private Index2ListC { // =============== // == BIG OBJECT = // =============== public: // Type definitions // ---------------- typedef LongIntT AreaT; // polygon area public: // Constructor, copies, assigment, and destructor // ---------------------------------------------- inline IntPolygon2dC(); // Empty polygon. IntPolygon2dC(const IntPolygon2dC & points); // Another access to the polygon. inline IntPolygon2dC(const Index2ListC & points); // Constructs a polygon from a list of points. The 'points' will // be shared by the polygon (as a big object). IntPolygon2dC(const DListC & vertexes); // Construct a polygon from a list of vertexes. IntPolygon2dC(const DListC & vertexes); // Construct a polygon from a list of vertexes. // Access to the object model // -------------------------- inline const Index2ListC & List() const; // Access to the constant list of vertexes. // Derived characteristics of the object // ------------------------------------- AreaT Area2() const; // Returns twice the signed area of this polygon. // Ref.: - O'Rourke,J.: Computatinal geometry in C; // Cambridge University Press, 1994, pp. 20-26 IntRectangleTPC MinimumRectangle() const; // Returns a minimum enclosing rectangle of this polygon. The polygon // must be convex and counter-clockwise oriented. private: // Special type definitions // ------------------------ typedef RealT DAreaT; // non-integer area during computation. private: // Special member functions // ------------------------ inline Index2ListC & MyList(); // Returns the reference to the list of indexes. friend istream & operator>>(istream & s, IntPolygon2dC & pol); friend ostream & operator<<(ostream & s, const IntPolygon2dC & pol); }; istream & operator>>(istream & s, IntPolygon2dC & pol); // Reads a polygon from the input stream. ostream & operator<<(ostream & s, const IntPolygon2dC & pol); // Sends the polygon into the output stream. typedef DListC FooIntPolygon2dCPPPPPC; // help GNU C++ 2.6.0 void SaveAsGF(ostream & s, const DListC & pols, IntPolygon2dC::AreaT minArea = 0); // Save all polygons which inside area is bigger than 'minArea' // into the stream 's'. //==================================================================== //======= IntPolygon2dC ============================================== //==================================================================== inline const Index2ListC & IntPolygon2dC::List() const //========================= { return(*this); } inline Index2ListC & IntPolygon2dC::MyList() //===================== { return(*this); } inline IntPolygon2dC::IntPolygon2dC() //============================ : Index2ListC() {} inline IntPolygon2dC::IntPolygon2dC(const Index2ListC & points) //====================================================== : Index2ListC(points) {} #endif // IAPS - Image analysis program system. // End of include file IPolyg2.hh