Go to the documentation of this file.00001
00002
00003
00004
00005 #ifndef continuityData_hh
00006 #define continuityData_hh
00007
00008 #include <iostream>
00009 #include <map>
00010 #include "geometry/cell.hh"
00011 #include "geometry/connector.hh"
00012 #include "basics/exceptions.hh"
00013 #include "toolbox/hashMap.hh"
00014 #include "toolbox/set.hh"
00015
00016 namespace concepts {
00017
00018 class CellData;
00019
00020
00021
00025 class WrongRelations : public ExceptionBase {};
00026
00027
00028
00029
00036 class ConnectorData {
00037 public:
00039 typedef std::map<uint, const CellData*>::iterator iterator;
00041 typedef std::map<uint, const CellData*>::const_iterator const_iterator;
00042
00049 void addCell(const CellData& c);
00051 bool hasCell(const Connector& c) const;
00057 void replaceCell(const CellData& remove, const CellData& add);
00058
00060 iterator begin() { return cells_.begin(); }
00062 const_iterator begin() const { return cells_.begin(); }
00064 iterator end() { return cells_.end(); }
00066 const_iterator end() const { return cells_.end(); }
00067 protected:
00069 std::map<uint, const CellData*> cells_;
00070 };
00071
00072
00073
00077 class CellData {
00078 public:
00083 CellData(const Connector& cell, const CellData* father) :
00084 cell_(cell) {
00085 addFather(father);
00086 cntrData_.addCell(*this);
00087 }
00089 const Connector& cell() const { return cell_; }
00091 const Connector1* edge(const uint i) const;
00093 const Connector2* face(const uint i) const;
00095 bool hasFace(const Connector2& f) const;
00097 bool hasEdge(const Connector1& e) const;
00099 const CellData* father() const {
00100 if (father_.begin()==father_.end()) {
00101 return 0;
00102 }
00103 else return father_.begin()->second;
00104 }
00106 ConnectorData fathers() const { return father_; }
00112 const CellData* father(uint i) const;
00116 const ConnectorData fathers(uint i) const;
00118 void addFather(const CellData* father);
00120 int related(const CellData& c) const {
00121 return cell_.related(c.cell()); }
00123 Key key() const { return cell_.key(); }
00124 private:
00126 const Connector& cell_;
00128 ConnectorData father_;
00130 ConnectorData cntrData_;
00131 };
00132
00133 std::ostream& operator<<(std::ostream& os, const CellData& c);
00134
00135
00136
00140 class FaceData : public ConnectorData {
00141 friend std::ostream& operator<<(std::ostream& os, const FaceData& f);
00142 public:
00146 FaceData(const Connector2& face) : face_(face) {}
00148 const Connector2& face() const { return face_; }
00150 int related(const FaceData& f) const {
00151 return face_.related(f.face()); }
00153 Key key() const { return face_.key(); }
00159 static void checkRelatedFaces(std::map<uint, FaceData>& faceList);
00160 private:
00162 const Connector2& face_;
00163 };
00164
00165
00166
00170 class EdgeData : public ConnectorData {
00171 friend std::ostream& operator<<(std::ostream& os, const EdgeData& e);
00172 public:
00176 EdgeData(const Connector1& edge) : edge_(edge), io_(false) {}
00178 const Connector1& edge() const { return edge_; }
00180 int related(const EdgeData& e) const {
00181 return edge_.related(e.edge()); }
00183 void addFace(const FaceData& f);
00189 static bool doCheckRelations(std::map<uint, EdgeData>& edgeList);
00214 bool checkRelations();
00216 Key key() const { return edge_.key(); }
00223 static void checkRelatedEdges(std::map<uint, EdgeData>& edgeList);
00224 private:
00226 const Connector1& edge_;
00230 bool io_;
00232 std::map<uint, FaceData> faces_;
00236 void recreateFaceList_();
00238 const CellData* findCommonCell_(const FaceData& face) const;
00239 };
00240
00241
00242
00246 class VertexData : public ConnectorData {
00247 friend std::ostream& operator<<(std::ostream& os, const VertexData& e);
00248 public:
00252 VertexData(const Connector0& vertex) : vertex_(vertex), io_(false) {}
00254 const Connector0& vertex() const { return vertex_; }
00256 void addEdge(const EdgeData& e);
00262 static bool doCheckRelations(std::map<uint, VertexData>& vertexList);
00287 bool checkRelations();
00289 Key key() const { return vertex_.key(); }
00290 private:
00292 const Connector0& vertex_;
00296 bool io_;
00298 std::map<uint, EdgeData> edges_;
00302 void recreateEdgeList_();
00304 const CellData* findCommonCell_(const EdgeData& edge) const;
00305 };
00306
00307
00308
00314 class EdgesOfVertices : public HashMap<Set<Connector1*> > {
00315 public:
00317 EdgesOfVertices() {}
00319 EdgesOfVertices(const concepts::Connector2& cell);
00321 void addCell(const concepts::Connector2& cell);
00322 };
00323
00324 }
00325
00326 #endif // continuityData_hh