Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <array>
- #include <algorithm>
- using namespace std;
- class Mesh;
- class Node
- {
- public:
- Node()
- : connections(25, 1), intetr(20, 1), freedom(20)
- {}
- ~Node() {}
- std::vector<Node> find_conns(const Mesh* mesh);
- std::vector<const Node*> find_connps(const Mesh* mesh);
- void set_freedom(const size_t& free) { freedom = free; }
- const size_t& get_freedom() const { return freedom; }
- private:
- std::array<double,3> location;
- double* inmesh;
- std::vector<size_t> connections;
- std::vector<size_t> intetr;
- size_t freedom;
- };
- class Mesh
- {
- public:
- Mesh()
- : m_nodes(1000000)
- {}
- ~Mesh() {}
- const Node& get_node(const size_t &index) const { return m_nodes[index]; }
- const Node* get_node_ptr(const size_t &index) const { return &m_nodes[index]; }
- void dostuff()
- {
- for (auto n : m_nodes)
- {
- std::vector<Node> conns = n.find_conns(this);
- for (auto c : conns)
- {
- c.set_freedom(1);
- }
- }
- }
- void dostuffp()
- {
- for (auto n : m_nodes)
- {
- std::vector<const Node*> conns = n.find_connps(this);
- for (auto c : conns)
- {
- c->get_freedom();
- }
- }
- }
- private:
- std::vector<Node> m_nodes;
- };
- std::vector<const Node*> Node::find_connps(const Mesh* mesh)
- {
- std::vector<const Node*> nodes(connections.size());
- std::transform(connections.begin(), connections.end(), nodes.begin(), [&] (size_t i) {return mesh->get_node_ptr(i);});
- return nodes;
- }
- std::vector<Node> Node::find_conns(const Mesh* mesh)
- {
- std::vector<Node> nodes(connections.size());
- std::transform(connections.begin(), connections.end(), nodes.begin(), [&] (size_t i) {return mesh->get_node(i);});
- return nodes;
- }
- int main(int argc, char *argv[])
- {
- Mesh mesh;
- cout << sizeof(Node) << " " << sizeof(Mesh) << " " << sizeof(Node*) << endl;
- mesh.dostuffp();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement