#ifndef CellAddress_h #define CellAddress_h #include // ------------------------------------------------------------------------ // CellAddress // Une facon d'identifier une cellule, a partir de sa position selon les // axes x, y et z // ------------------------------------------------------------------------ class CellAddress { public: // constructeur par defaut = une adresse non valide CellAddress(): m_ix(999999), m_iy(999999), m_layer(999999) {}; // constructeur complet CellAddress(int ix, int iy, int layer): m_ix(ix), m_iy(iy), m_layer(layer) {}; // adresse valide ? bool IsValid() const; // indice selon x int ix() const { return m_ix; } // indice selon y int iy() const { return m_iy; } // indice selon z (profondeur) int layer() const { return m_layer; } // definition des comparaisons entre CellAddress, necessaire pour certains // type de "container" de la librarie standard bool operator<(const CellAddress &x) const { if (x.m_iy == this ->m_iy && x.m_ix == this->m_ix) return this->m_layer < x.m_layer; if (x.m_ix == this->m_ix) return this->m_iy < x.m_iy; return this->m_ix < x.m_ix; } bool operator>(const CellAddress &x) const { if (x.m_iy == this ->m_iy && x.m_ix == this->m_ix) return this->m_layer > x.m_layer; if (x.m_ix == this->m_ix) return this->m_iy > x.m_iy; return this->m_ix > x.m_ix; } // affiche le contenue d'une addresse friend std::ostream& operator<<(std::ostream& os, const CellAddress &y) { os<<"("<