00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 #ifndef SMESHN_H
00044 #define SMESHN_H
00045 
00046 
00047 #include <iostream>
00048 
00049 #include <LEDA/array.h>
00050 #include <LEDA/h_array.h>
00051 
00052 
00053 #include "STopology.h"
00054 #include "SMeshNMod.h"
00055 #include "SMeshNPosition.h"
00056 
00057 
00058 
00059 class SMeshNEntry {
00060 public:
00061   int _id;
00062   const SMeshNPosition *_pos;
00063   SMeshNEntry(int id, const SMeshNPosition *pos) :
00064     _id(id), _pos(pos) {};
00065 
00066   friend std::istream &operator>>(std::istream &i, SMeshNEntry &e) { return i; };
00067   friend std::ostream &operator<<(std::ostream &o, const SMeshNEntry &e) { return o; };
00068 };
00069 
00070 
00075 class SMeshN : public virtual STopology {
00076   TYPEINFO0(SMeshN, "meshN");
00077   friend class SMeshNMod;
00078 public:
00082   SMeshN(SDimArray &meshSize);
00083 
00087   SMeshN(int dim);
00088 
00091   virtual ~SMeshN() {}
00092 
00095   virtual STopologyMod &getModifier() 
00096     { return _mod; };
00097 
00102   virtual int getCount() const {
00103     int count = 1;
00104     for (int i=0; i<getDim(); i++)
00105       count *= _size[i];
00106     return count;
00107   };
00108   
00112   virtual int getDim() const { return _size.size(); };
00113 
00117   virtual SDimArray getSize() const { return _size; };
00118 
00123   virtual int getIDAt(int pos) const;
00124   
00129   virtual int getPos(int ID) const;
00130   
00135   virtual bool isPosFree(int pos) const;
00136 
00142   virtual bool canEmbedAt(const STopology &top, int pos) const;
00143   virtual bool canEmbedAt(const SComplexPosition &rHcPos) const;
00144 
00145   
00146   
00147   
00148   
00149   
00150   
00156   virtual void embed(const STopology& top, int pos, int ID);
00157   virtual void embed(const STopology& top,
00158          const SComplexPosition *pMeshNPos, int ID);
00159   
00163   virtual void remove(int ID);
00164   
00167   virtual void clear();
00168 
00169   virtual bool fitsInto(const STopology *top) const {
00170     const SMeshN *meshN = dynamic_cast<const SMeshN*>(top);
00171     bool ok = true;
00172     for (int i=0; i<getDim(); i++)
00173       if (_size[i] > meshN->getSize()[i]) {
00174   ok = false;
00175   break;
00176       }
00177     return ok;
00178   }
00179 
00180 protected:
00181   SDimArray _size;
00182 
00183   
00184   leda_h_array<int, SMeshNEntry*> _IDtoEntry;  
00185   static SMeshNEntry _defaultEntry;
00186 
00187   void setSize(SDimArray &newSize);
00188 
00189 private:
00190   
00191   SMeshNMod _mod;
00192   
00193 };
00194 
00195 #endif //SMESHN_H