void Mesh::setNodesConnectedByEdges() { const std::size_t nNodes (this->_nodes.size()); for (unsigned i=0; i<nNodes; ++i) { MeshLib::Node* node (_nodes[i]); std::vector<MeshLib::Node*> conn_set; const std::vector<MeshLib::Element*> &conn_elems (node->getElements()); const std::size_t nConnElems (conn_elems.size()); for (unsigned j=0; j<nConnElems; ++j) { const unsigned idx (conn_elems[j]->getNodeIDinElement(node)); const unsigned nElemNodes (conn_elems[j]->getNBaseNodes()); for (unsigned k(0); k<nElemNodes; ++k) { bool is_in_vector (false); const std::size_t nConnNodes (conn_set.size()); for (unsigned l(0); l<nConnNodes; ++l) if (conn_elems[j]->getNode(k) == conn_set[l]) is_in_vector = true; if (is_in_vector) continue; if (conn_elems[j]->isEdge(idx, k)) //TODO doesn't work with higher order nodes conn_set.push_back(_nodes[conn_elems[j]->getNode(k)->getID()]); } } node->setConnectedNodes(conn_set); } }
void Mesh::setNodesConnectedByElements() { const size_t nNodes (this->_nodes.size()); for (unsigned i=0; i<nNodes; ++i) { MeshLib::Node* node (_nodes[i]); std::vector<MeshLib::Node*> conn_vec; const std::vector<MeshLib::Element*> &conn_elems (node->getElements()); const size_t nConnElems (conn_elems.size()); for (unsigned j=0; j<nConnElems; ++j) { const unsigned nElemNodes (conn_elems[j]->getNNodes()); for (unsigned k(0); k<nElemNodes; ++k) { bool is_in_vector (false); const MeshLib::Node* c_node (conn_elems[j]->getNode(k)); if (c_node == node) continue; const size_t nConnNodes (conn_vec.size()); for (unsigned l(0); l<nConnNodes; ++l) if (c_node == conn_vec[l]) is_in_vector = true; if (!is_in_vector) conn_vec.push_back(_nodes[c_node->getID()]); } } node->setConnectedNodes(conn_vec); } }