GitHub PullRequestReviewCommentEvent at 2014-02-25 08:09:16
Repository: ogs
Actor: rinkk
Payload: {"comment":{"url":"https://api.github.com/repos/ufz/ogs/pulls/comments/10027138","id":10027138,"diff_hunk":"@@ -19,38 +19,36 @@\n \n namespace MeshLib {\n \n-MeshLib::Mesh* removeMeshNodes(const MeshLib::Mesh &mesh, const std::vector<size_t> &nodes)\n+void removeMeshNodes(MeshLib::Mesh &mesh, const std::vector<std::size_t> &del_nodes_idx)\n {\n-\tMeshLib::Mesh* new_mesh (new MeshLib::Mesh(mesh));\n-\n \t// delete nodes and their connected elements and replace them with null pointers\n-\tconst size_t delNodes = nodes.size();\n-\tstd::vector<MeshLib::Node*> mesh_nodes = new_mesh->getNodes();\n-\tfor (size_t i = 0; i < delNodes; ++i)\n+\tconst size_t nDelNodes = del_nodes_idx.size();\n+\tstd::vector<MeshLib::Node*>& mesh_nodes = mesh.getNodesVector();\n+\t\n+\tfor (std::size_t i = 0; i < nDelNodes; ++i)\n \t{\n-\t\tconst MeshLib::Node* node = new_mesh->getNode(i);\n-\t\tstd::vector<MeshLib::Element*> conn_elems = node->getElements();\n+\t\tconst unsigned idx (del_nodes_idx[i]);\n+\t\tstd::vector<MeshLib::Element*> conn_elems (mesh_nodes[idx]->getElements());\n \n-\t\tfor (size_t j = 0; j < conn_elems.size(); ++j)\n+\t\tfor (std::size_t j = 0; j < conn_elems.size(); ++j)\n \t\t{\n \t\t\tdelete conn_elems[j];\n \t\t\tconn_elems[j] = nullptr;\n \t\t}\n-\t\tdelete mesh_nodes[i];\n-\t\tmesh_nodes[i] = nullptr;\n+\t\tdelete mesh_nodes[idx];\n+\t\tmesh_nodes[idx] = nullptr;\n \t}\n \n \t// erase null pointers from node- and element vectors\n-\tstd::vector<MeshLib::Element*> elements = new_mesh->getElements();\n+\tstd::vector<MeshLib::Element*> elements = mesh.getElements();\n \tauto elem_vec_end = std::remove(elements.begin(), elements.end(), nullptr);\n \telements.erase(elem_vec_end, elements.end());\n \n \tauto node_vec_end = std::remove(mesh_nodes.begin(), mesh_nodes.end(), nullptr);\n \tmesh_nodes.erase(node_vec_end, mesh_nodes.end());\n-\n-\tnew_mesh->resetNodeIDs(); // after removing nodes set new node-IDs\n-\n-\treturn new_mesh;\n+\t\n+\tif (nDelNodes)\n+\t\tmesh.resetNodeIDs(); // after removing nodes set new node-IDs","path":"MeshLib/MeshEditing/removeMeshNodes.cpp","position":49,"original_position":49,"commit_id":"6962a58f6c46e717f641b542def9e879631205d3","original_commit_id":"6962a58f6c46e717f641b542def9e879631205d3","user":{"login":"rinkk","id":798445,"avatar_url":"https://gravatar.com/avatar/4a3a2e3b8f5a29db71fc45f7fa47e7df?d=https%3A%2F%2Fidenticons.github.com%2Fe5743c1d0e506418ae0b86fa09134651.png&r=x","gravatar_id":"4a3a2e3b8f5a29db71fc45f7fa47e7df","url":"https://api.github.com/users/rinkk","html_url":"https://github.com/rinkk","followers_url":"https://api.github.com/users/rinkk/followers","following_url":"https://api.github.com/users/rinkk/following{/other_user}","gists_url":"https://api.github.com/users/rinkk/gists{/gist_id}","starred_url":"https://api.github.com/users/rinkk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rinkk/subscriptions","organizations_url":"https://api.github.com/users/rinkk/orgs","repos_url":"https://api.github.com/users/rinkk/repos","events_url":"https://api.github.com/users/rinkk/events{/privacy}","received_events_url":"https://api.github.com/users/rinkk/received_events","type":"User","site_admin":false},"body":"yes, that is correct","created_at":"2014-02-25T08:09:16Z","updated_at":"2014-02-25T08:09:16Z","html_url":"https://github.com/ufz/ogs/pull/328#discussion_r10027138","pull_request_url":"https://api.github.com/repos/ufz/ogs/pulls/328","_links":{"self":{"href":"https://api.github.com/repos/ufz/ogs/pulls/comments/10027138"},"html":{"href":"https://github.com/ufz/ogs/pull/328#discussion_r10027138"},"pull_request":{"href":"https://api.github.com/repos/ufz/ogs/pulls/328"}}}}