00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 # ifndef shape_cell3d_list_hpp
00014 # define shape_cell3d_list_hpp
00015
00016 # include <shape/bcell3d.hpp>
00017 # include <shape/solver_implicit.hpp>
00018
00019 # define TMPL template<class C, class V>
00020 # define REF REF_OF(V)
00021 # define Point point<C,3,REF>
00022 # define SELF bcell3d_list<C,V>
00023 # define Solver solver_implicit<C,V>
00024 # undef Cell
00025 # undef Topology
00026
00027 namespace mmx {
00028 namespace shape {
00029
00030 template<class C, class V=default_env>
00031 class bcell3d_list: public bcell3d<C,V> {
00032 public:
00033 typedef bounding_box<C,REF> BoundingBox;
00034 typedef bcell3d<C,REF> Cell;
00035 typedef topology<C,V> Topology;
00036
00037 bcell3d_list(void) ;
00038 bcell3d_list(double xmin, double xmax) ;
00039 bcell3d_list(double xmin, double xmax, double ymin, double ymax) ;
00040 bcell3d_list(double xmin, double xmax, double ymin, double ymax, bool itr) ;
00041 bcell3d_list(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) ;
00042 bcell3d_list(const BoundingBox& bx);
00043 virtual ~bcell3d_list(void) ;
00044
00045 virtual bool is_active (void) const;
00046 virtual bool is_regular (void) ;
00047
00048 virtual bool insert_regular(Topology*);
00049 virtual bool insert_singular(Topology*);
00050
00051
00052 void push_back(Cell *) ;
00053 int count(void) { return m_objects.size() ; }
00054
00055
00056 virtual bool is_intersected(){return true;}
00057
00058 virtual bool topology_regular(Topology*);
00059 virtual void subdivide(Cell*& left, Cell*& right, int v, double s);
00060 virtual void split_position(int& v, double& s);
00061
00062 protected:
00063 Seq<Cell *> m_objects ;
00064 Seq<Point*> m_singulars;
00065 mutable bool m_intersect;
00066 };
00067
00068 TMPL SELF::bcell3d_list(void): m_intersect(false) {}
00069 TMPL SELF::bcell3d_list(double xmin, double xmax) : Cell(xmin, xmax), m_intersect(true) {}
00070 TMPL SELF::bcell3d_list(double xmin, double xmax, double ymin, double ymax) : Cell(xmin, xmax, ymin, ymax), m_intersect(true) {}
00071 TMPL SELF::bcell3d_list(double xmin, double xmax, double ymin, double ymax, bool itr) : Cell(xmin, xmax, ymin, ymax), m_intersect(itr) {}
00072 TMPL SELF::bcell3d_list(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) : Cell(xmin, xmax, ymin, ymax, zmin, zmax), m_intersect(false) {}
00073 TMPL SELF::bcell3d_list(const BoundingBox& bx): Cell(bx), m_intersect(true) {};
00074
00075 TMPL SELF::~bcell3d_list(void) {
00076 foreach (Cell* m, m_objects) delete m;
00077 }
00078
00079 TMPL bool
00080 SELF::is_active() const {
00081 foreach (Cell* m, m_objects)
00082 if(m->is_active()) return true;
00083 return false;
00084 }
00085
00086 TMPL bool
00087 SELF::insert_regular(Topology* s) {
00088
00089 foreach(Cell* m, m_objects) m->insert_regular(s);
00090 return true;
00091 }
00092
00093 TMPL bool
00094 SELF::insert_singular(Topology* s) {
00095
00096 foreach(Cell * m, m_objects) m->insert_singular(s);
00097 return true;
00098 }
00099
00100 TMPL void
00101 SELF::push_back(Cell *cv) {
00102 m_objects.push_back(cv);
00103 }
00104
00105 TMPL bool
00106 SELF::is_regular() {
00107 foreach (Cell* m, this->m_objects)
00108 if(!m->is_regular()) return false;
00109
00110 if(this->m_objects.size() >1 && m_intersect) {
00111
00112
00113
00114 m_intersect = false;
00115 }
00116
00117 if (m_singulars.size() > 1) return false;
00118
00119 return true;
00120 }
00121
00122 TMPL bool SELF::topology_regular (Topology* s) {
00123 return true;
00124 }
00125
00126
00127 TMPL void SELF::split_position(int& v, double& s) {
00128 double sx = (this->xmax()-this->xmin());
00129 double sy = (this->ymax()-this->ymin());
00130 double sz = (this->zmax()-this->zmin());
00131
00132 if(sx<sy)
00133 if(sy<sz) {
00134 v=2;
00135 s=(this->zmax()+this->zmin())/2;
00136 } else {
00137 v=1;
00138 s=(this->ymax()+this->ymin())/2;
00139 }
00140 else
00141 if(sx<sz) {
00142 v=2;
00143 s=(this->zmax()+this->zmin())/2;
00144 } else {
00145 v=0;
00146 s=(this->xmax()+this->xmin())/2;
00147 }
00148 }
00149
00150 TMPL void
00151 SELF::subdivide(Cell*& , Cell*& , int , double ) {
00152
00153 typedef SELF Cell_t;
00154
00155 }
00156
00157 } ;
00158 } ;
00159 # undef TMPL
00160 # undef SELF
00161 # undef REF
00162 # undef Point
00163 # undef Solver
00164 # endif // shape_cell3d_list_hpp