#ifndef IRectTP_HH #define IRectTP_HH ///////////////////////////////////////////////////////////////////////// //! file="amma/Geometry/CmpGeo2d/IRectTP.hh" //! lib=Mcg2 //! userlevel=Normal //! author="Radek Marik" //! date="26.12.1994" //! docentry="Geometry.2-D" //! rcsid="$Id: IRectTP.hh,v 1.8 2000/10/04 12:49:17 ees1cg Exp $" #include "amma/StdType.hh" #include "amma/Index2d.hh" #include "amma/Vector2d.hh" class ostream; //: Integer 2-D rectangle determined by touch points class IntRectangleTPC { public: enum {N = 4}; // four points public: inline IntRectangleTPC(); // Creates the empty rectangle in the origin of coordinate system. inline IntRectangleTPC(const IntRectangleTPC & rect); // Copy constructor. inline IntRectangleTPC(const Vector2dC & direction, const Index2dC & a, const Index2dC & b, const Index2dC & c, const Index2dC & d); // Creates the rectangle. The vector 'direction' has its origin // in the point 'a'. inline IntRectangleTPC(const Vector2dC & direction, const Index2dC pt[N]); // Creates the rectangle. The vector 'direction' has its origin // in the point 'a'. inline void Set(const Vector2dC & direction, const Index2dC & a, const Index2dC & b, const Index2dC & c, const Index2dC & d); // Sets the new value of the rectangle. The vector 'direction' // has its origin in the point 'a'. inline const Vector2dC & Direction() const; // Returns the direction of the first side of the rectangle. inline const Index2dC & operator[](IndexT i) const; // Returns the touching point with the index 'i'. The first point // has the index 0; private: typedef RealT AreaT; private: Index2dC points[N]; Vector2dC dir; }; ostream & operator<<(ostream & s, const IntRectangleTPC & rect); // Sends the rectangle 'rect' into the output stream 's'. #include "amma/Error.hh" //==================================================================== //======= IntRectangleTPC ============================================ //==================================================================== inline IntRectangleTPC::IntRectangleTPC() //================================ : dir(Vector2dC(0,0)) { for(MUIndexT i = 0; i < N; i++) points[i] = Index2dC(0,0); } inline IntRectangleTPC::IntRectangleTPC(const IntRectangleTPC & rect) //============================================================ : dir(rect.dir) { for(MUIndexT i = 0; i < N; i++) points[i] = rect.points[i]; } inline IntRectangleTPC::IntRectangleTPC(const Vector2dC & direction, const Index2dC & a, const Index2dC & b, const Index2dC & c, const Index2dC & d) //=========================================================== : dir(direction) { points[0] = a; points[1] = b; points[2] = c; points[3] = d; } inline IntRectangleTPC::IntRectangleTPC(const Vector2dC & direction, const Index2dC pt[N]) //================================================================= : dir(direction) { for(MUIndexT i = 0; i < N; i++) points[i] = pt[i]; } inline void IntRectangleTPC::Set(const Vector2dC & direction, const Index2dC & a, const Index2dC & b, const Index2dC & c, const Index2dC & d) //================================================ { dir = direction; points[0] = a; points[1] = b; points[2] = c; points[3] = d; } inline const Vector2dC & IntRectangleTPC::Direction() const //================================ { return(dir); } inline const Index2dC & IntRectangleTPC::operator[](IndexT i) const //========================================= { #ifdef MAMA_CHECK if (i<0 || i>=N) { errMaMa << "a bad index of touching point: " << i; errMaMa.Funtion("IntRectangleTPC::operator[]()").Exit(); } #endif return points[i.V()]; } #endif // IAPS - Image analysis program system. // End of include file IRectTP.hh