00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 # ifndef shape_cell2d_hpp
00014 # define shape_cell2d_hpp
00015
00016
00017 # include <realroot/Seq.hpp>
00018 # include <shape/point.hpp>
00019 # include <shape/edge.hpp>
00020 # include <shape/bounding_box.hpp>
00021 # include <shape/cell.hpp>
00022 # include <shape/graph.hpp>
00023
00024 # define TMPL template<class C, class V>
00025 # define SELF cell2d<C,V>
00026 # define REF REF_OF(V)
00027 # undef Topology
00028 # undef Point
00029 # undef Edge
00030
00031 namespace mmx { namespace shape {
00032
00033 TMPL struct cell2d;
00034
00035 TMPL
00036 class cell2d : public cell<C,REF> {
00037 public:
00038
00039 typedef topology<C,V> Topology;
00040 typedef typename topology<C,V>::Point Point;
00041 typedef typename topology<C,V>::Edge Edge;
00042 typedef bounding_box<C,REF> BoundingBox;
00043 typedef cell<C,REF> Cell;
00044
00045 cell2d(void) ;
00046 cell2d(const BoundingBox & bx): Cell(bx) {}
00047 cell2d(double xmin, double xmax): Cell(xmin,xmax) {};
00048 cell2d(double xmin, double xmax, double ymin, double ymax): Cell(xmin,xmax,ymin,ymax) {} ;
00049
00050 virtual ~cell2d(void) ;
00051 virtual Point center(void) const { return Point((this->xmax()+this->xmin())/2,
00052 (this->ymax()+this->ymin())/2,0); }
00053 virtual bool is_adjacent(SELF* c);
00054 };
00055
00056 TMPL SELF::cell2d(void) { }
00057
00058 TMPL SELF::~cell2d(void) {}
00059
00060 TMPL
00061 bool SELF::is_adjacent(SELF* c2){
00062
00063 if(this->xmax()<c2->xmin() || c2->xmax()<this->xmin())
00064 return false;
00065 if(this->ymax()<c2->ymin() || c2->ymax()<this->ymin())
00066 return false;
00067 if((this->xmax()==c2->xmin() || c2->xmax()==this->xmin())) {
00068 if((this->ymax()==c2->ymin() || c2->ymax()==this->ymin()))
00069 return false;
00070 }
00071 return true;
00072 }
00073
00075 } ;
00076 } ;
00077 # undef TMPL
00078 # undef SELF
00079 # undef REF
00080 # endif // shape_cell2d_hpp