shape_doc 0.1
|
00001 #ifndef __shape__line__hpp__ 00002 #define __shape__line__hpp__ 00003 00004 #include <iostream> 00005 # include <shape/shape.hpp> 00006 # include <shape/point.hpp> 00007 00008 # define TMPL template<class K> 00009 # define Shape geometric<K> 00010 # define Line line<K> 00011 00012 namespace mmx { 00013 namespace shape { 00014 00015 TMPL struct line; 00016 TMPL struct line_def: public point_def<K> {typedef line<K> Face;}; 00017 00018 TMPL 00019 class line : public Shape { 00020 00021 public : 00022 typedef typename point_def<K>::Scalar Scalar; 00023 typedef typename point_def<K>::Point Point; 00024 line(Point* origin, Point* extremity): Shape() { 00025 m_origin = *origin; 00026 m_extremity = *extremity; 00027 } 00028 line(Point origin, Point extremity): Shape() { 00029 m_origin = origin; 00030 m_extremity = extremity; 00031 } 00032 ~line(){ 00033 } 00034 00035 inline Point origin(void) const { return m_origin ; } 00036 inline Point extremity(void) const { return m_extremity ; } 00037 00038 inline void setOrigin(Point origin) { this->m_origin = origin ; } 00039 inline void setExtremity(Point extremity) { this->m_extremity = extremity ; } 00040 00041 bool operator == (const Line & other) const ; 00042 bool operator != (const Line & other) const ; 00043 Line & operator = (const Line & other) ; 00044 00045 00046 private : 00047 Point m_origin; 00048 Point m_extremity; 00049 }; 00050 00051 TMPL bool 00052 Line::operator == (const Line & other) const { 00053 return (m_origin == other.m_origin && m_extremity == other.m_extremity) ; 00054 } 00055 00059 TMPL bool 00060 Line::operator != (const Line & other) const { 00061 return !(m_origin == other.m_origin && m_extremity == other.m_extremity); 00062 } 00063 00064 TMPL Line& 00065 Line::operator = (const Line & other) { 00066 if(this == &other) 00067 return *this ; 00068 00069 this->m_origin = other.origin() ; 00070 this->m_extremity = other.extremity() ; 00071 return *this ; 00072 } 00073 00074 } ; // namespace shape 00075 00076 template<class OSTREAM, class K> OSTREAM& 00077 operator<<(OSTREAM& os, const shape::line<K>& l) { 00078 os << l.origin() << std::endl << l.extremity() << std::endl; 00079 return os; 00080 } 00081 00082 } ; // namespace mmx 00083 00084 #undef Shape 00085 #undef TMPL 00086 #undef Line 00087 #endif