shape_doc 0.1
/Users/mourrain/Devel/mmx/shape/include/shape/cell_list.hpp
Go to the documentation of this file.
00001 /*****************************************************************************
00002  * M a t h e m a  g i x
00003  *****************************************************************************
00004  * Cell
00005  * 2008-03-20
00006  * Julien Wintz & Bernard Mourrain
00007  *****************************************************************************
00008  *               Copyright (C) 2008 INRIA Sophia-Antipolis
00009  *****************************************************************************
00010  * Comments :
00011  ****************************************************************************/
00012 
00013 # ifndef shape_cell_list_hpp
00014 # define shape_cell_list_hpp
00015 
00016 # include <shape/cell2d.hpp>
00017 # define TMPL template<class C, class V>
00018 # define REF  REF_OF(V)
00019 # define Point     point<C,REF>
00020 # define SELF       cell_list<C,V>
00021 # undef Cell
00022 # undef Topology
00023 //====================================================================
00024 namespace mmx {
00025 namespace shape {
00026 
00027 template<class C, class V=default_env>
00028 class cell_list: public cell<C,V>  {
00029 public:
00030   typedef bounding_box<C,REF>      BoundingBox;
00031   typedef cell<C,REF>              Cell;
00032   typedef topology<C,V>          Topology;
00033 
00034   cell_list(void) ;
00035   cell_list(double xmin, double xmax) ;
00036   cell_list(double xmin, double xmax, double ymin, double ymax) ;
00037   cell_list(double xmin, double xmax, double ymin, double ymax, bool itr) ;
00038   cell_list(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) ;
00039   cell_list(const BoundingBox& bx);
00040   virtual ~cell_list(void) ;
00041 
00042   virtual bool is_active  (void) const;
00043   virtual bool is_regular (void)  = 0 ;
00044 
00045   virtual bool insert_regular(Topology*);// = 0 ;
00046   virtual bool insert_singular(Topology*);// = 0 ;
00047   
00048 
00049   void push_back(Cell *) ; 
00050   int  count(void) { return m_objects.size() ; }
00051 
00052 
00053 protected:
00054   Seq<Cell *>        m_objects  ;
00055 };
00056   
00057   
00058 TMPL SELF::cell_list(void){}
00059 TMPL SELF::cell_list(double xmin, double xmax) : Cell(xmin, xmax) {}
00060 TMPL SELF::cell_list(double xmin, double xmax, double ymin, double ymax) :  Cell(xmin, xmax, ymin, ymax) {}
00061 TMPL SELF::cell_list(double xmin, double xmax, double ymin, double ymax, bool itr) : Cell(xmin, xmax, ymin, ymax) {}
00062 TMPL SELF::cell_list(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) : Cell(xmin, xmax, ymin, ymax, zmin, zmax) {}
00063 TMPL SELF::cell_list(const BoundingBox& bx): Cell(bx) {};
00064 
00065 TMPL SELF::~cell_list(void) {
00066     foreach (Cell* m, m_objects) delete m;
00067   }
00068   
00069 TMPL  bool 
00070 SELF::is_active() const {
00071   foreach (Cell* m, m_objects) 
00072     if(m->is_active()) return true;
00073   return false;
00074 }
00075 
00076 TMPL bool 
00077 SELF::insert_regular(Topology* s) {
00078   //    foreach(Point* p, m_singulars) s->insert_singular(p);
00079   foreach(Cell*  m, m_objects)   m->insert_regular(s);
00080   return true;
00081 }
00082   
00083 TMPL bool 
00084 SELF::insert_singular(Topology* s) {
00085   //s->singular(this);
00086   foreach(Cell * m, m_objects) m->insert_singular(s);
00087   return true;
00088 }
00089 
00090 TMPL void 
00091 SELF::push_back(Cell *cv) {
00092   m_objects.push_back(cv);
00093 }
00094   
00095   
00096 } ; // namesapce shape
00097 } ; // namespace mmx
00098 
00099 # undef TMPL
00100 # undef SELF
00101 # undef REF
00102 # undef Point
00103 # endif // shape_cell_list_hpp