boundarycell.h

Go to the documentation of this file.
00001 #ifndef __boundarycell_h
00002 #define __boundarycell_h
00003 
00004 #include  "cell.h"
00005 
00006 #define NEDGES 1
00007 
00008 namespace Gascoigne
00009 {
00010 template<int N>
00011 class BoundaryCell : public Cell<N,NEDGES>
00012 {
00013  protected:
00014 
00015   int mat, eiq, oq;
00016 
00017  public:
00018 
00019   BoundaryCell(int l = 0, int f = -1) : Cell<N,NEDGES>(l,f), mat(0), eiq(0), oq(0) {}
00020   BoundaryCell(const BoundaryCell& c) : Cell<N,NEDGES>(c)  , mat(c.material()), 
00021     eiq(c.edge_in_quad()), oq(c.of_quad()) {}
00022 
00023   int  nnchild ()     const { return N; }
00024   int  material()     const { return mat; }
00025   int& material()           { return mat; }
00026   int  edge_in_quad() const { return eiq; }
00027   int& edge_in_quad()       { return eiq; }
00028   int  of_quad()      const { return oq; }
00029   int& of_quad()            { return oq; }
00030 
00031   BoundaryCell<N>& operator=(const BoundaryCell<N>& c)
00032     {
00033       Cell<N,NEDGES>::operator=(c);
00034       mat = c.material();
00035       eiq = c.edge_in_quad();
00036       oq  = c.of_quad();
00037       return *this;
00038     }
00039 
00040   void BinWrite(std::ostream &s) const
00041   {
00042     Cell<N,NEDGES>::BinWrite(s);
00043     int sizeInt = sizeof(int);
00044     s.write(reinterpret_cast<const char*>(&(this->qlevel)),sizeInt);
00045     s.write(reinterpret_cast<const char*>(&(this->qfather)),sizeInt);
00046     s.write(reinterpret_cast<const char*>(&oq),sizeInt);
00047     s.write(reinterpret_cast<const char*>(&eiq),sizeInt);
00048     int nc = this->nchilds();
00049     s.write(reinterpret_cast<const char*>(&nc),sizeInt);
00050     for (int i=0; i<nc; i++)
00051     {
00052       s.write(reinterpret_cast<const char*>(&(this->qchilds[i])),sizeInt);
00053     }
00054   }
00055 
00056   void BinRead(std::istream &s)
00057   {
00058     Cell<N,NEDGES>::BinRead(s);
00059     int sizeInt = sizeof(int);
00060     s.read(reinterpret_cast<char*>(&(this->qlevel)),sizeInt);
00061     s.read(reinterpret_cast<char*>(&(this->qfather)),sizeInt);
00062     s.read(reinterpret_cast<char*>(&oq),sizeInt);
00063     s.read(reinterpret_cast<char*>(&eiq),sizeInt);
00064     int nc;
00065     s.read(reinterpret_cast<char*>(&nc),sizeInt);
00066     this->childs().resize(nc);
00067     for (int i=0; i<nc; i++)
00068     {
00069       s.read(reinterpret_cast<char*>(&(this->qchilds[i])),sizeInt);
00070     }
00071   }
00072 
00073   friend std::ostream& operator<<(std::ostream &s, const BoundaryCell& A)
00074     {
00075       s << " : ";
00076       s << A.vertex()  << " " << A.level()   << " ";
00077       s << A.father()  << " " << A.of_quad() << " ";
00078       s << A.edge_in_quad() << " @ ";
00079       s << A.nchilds() << " " << A.childs();
00080       
00081       
00082       /*s << "s-l-f-q  " << A.sleep() << " " << A.level();
00083         s << " " << A.father() << " " << A.of_quad() << std::endl;
00084         s << "Childs " << A.childs();
00085         s << std::endl;*/
00086       return s;
00087     }
00088   friend std::istream& operator>>(std::istream &s, BoundaryCell& A)
00089     {
00090       std::string symbol;
00091       int n;
00092       s >> symbol;
00093       if (symbol!=":")
00094         {
00095           std::cout << "ERROR in BoundaryCell::operator>>" << std::endl;
00096           exit(1);
00097         }
00098       s >> A.vertex() >> A.level();
00099       s >> A.father() >> A.of_quad() >> A.edge_in_quad();
00100       s >> symbol >> n;
00101       if (symbol!="@")
00102         {
00103           std::cout << "ERROR in BoundaryCell::operator>>" << std::endl;
00104           exit(1);
00105         }
00106       A.childs().resize(n);
00107       s >> A.childs();
00108 
00109       return s;
00110     }
00111 };
00112 }
00113 
00114 #undef NEDGES
00115 
00116 #endif

Generated on Thu Sep 14 10:34:37 2006 for Gascoigne by  doxygen 1.4.7