| #ifndef INTERFACE_H
|
| #define INTERFACE_H
|
|
|
| #include <iostream>
|
| #include <vector>
|
| #include <unordered_map>
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| class Interface {
|
| public:
|
|
|
|
|
|
|
| Interface();
|
|
|
|
|
| void addAdjacency(unsigned int index1, unsigned int index2, float dist);
|
|
|
|
|
|
|
| void buildHigherLevel(Interface& highLevelInterface,
|
| const std::vector<unsigned int>& group1,
|
| const std::vector<unsigned int>& group2);
|
|
|
|
|
| class Adjacency {
|
| public:
|
| Adjacency() {}
|
| Adjacency(unsigned int p1, unsigned int p2, float d):
|
| particle1(p1), particle2(p2), distance(d) {}
|
| Adjacency(const Interface::Adjacency& a):
|
| particle1(a.particle1), particle2(a.particle2), distance(a.distance) {}
|
| unsigned int first() const { return particle1; }
|
| unsigned int second() const { return particle2; }
|
| float dist() const { return distance; }
|
| void setDistance(float dist) { distance = dist; }
|
| friend std::ostream& operator<<(std::ostream& s, const Adjacency& adjacency) {
|
| s << adjacency.first() << ' ' << adjacency.second() << ' ' <<adjacency.dist() << std::endl;
|
| return s;
|
| }
|
| protected:
|
| unsigned int particle1, particle2;
|
| float distance;
|
| };
|
|
|
|
|
|
|
|
|
| bool isAdjacent(unsigned int index1, unsigned int index2) const;
|
|
|
|
|
| bool isInterface(unsigned int index1) const;
|
|
|
|
|
| unsigned int size() const;
|
|
|
|
|
| unsigned int adjacenciesNumber() const { return adjacencyCounter; }
|
|
|
|
|
| unsigned int neighboursNumber(unsigned int index1) const;
|
|
|
|
|
| void adjacencies(std::vector<Adjacency>& vAdj, unsigned int index1) const;
|
|
|
| typedef std::unordered_map<int, Adjacency> ParticleAdjacency;
|
| typedef std::unordered_map<int, ParticleAdjacency> InterfaceAdjacency;
|
|
|
|
|
| const ParticleAdjacency& adjacencies(unsigned int index1) const;
|
|
|
|
|
| void neighboursIntersection(const ParticleAdjacency& pa1, const ParticleAdjacency& pa2,
|
| std::vector<unsigned int>& intersection) const;
|
|
|
|
|
| void neighboursIntersection(unsigned int index1, unsigned int index2,
|
| std::vector<unsigned int>& intersection) const;
|
|
|
|
|
| void neighboursUnion(const ParticleAdjacency& pa1, const ParticleAdjacency& pa2,
|
| std::vector<unsigned int>& nUnion) const;
|
|
|
|
|
| void neighboursUnion(unsigned int index1, unsigned int index2,
|
| std::vector<unsigned int>& nUnion) const;
|
|
|
|
|
| class iterator {
|
| public:
|
| iterator();
|
| iterator(InterfaceAdjacency::iterator iInterfaceAdjIt,
|
| ParticleAdjacency::iterator iParticleAdjIt,
|
| InterfaceAdjacency::iterator iInterfaceAdjacencyEnd);
|
| iterator operator++();
|
| const Adjacency& operator*() const;
|
| bool operator==(const Interface::iterator& it1) const;
|
| bool operator!=(const Interface::iterator& it1) const;
|
| protected:
|
| InterfaceAdjacency::iterator interfaceAdjIt;
|
| ParticleAdjacency::iterator particleAdjIt;
|
| InterfaceAdjacency::iterator interfaceAdjacencyEnd;
|
| };
|
|
|
| iterator begin();
|
| iterator end();
|
|
|
| protected:
|
|
|
| InterfaceAdjacency interfaceAdjacency;
|
|
|
| unsigned int adjacencyCounter;
|
| };
|
|
|
|
|
| #endif
|
|
|