GitHub PullRequestReviewCommentEvent at 2014-09-19 11:00:29
Repository: ogs
Actor: endJunction
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/ufz/ogs/pulls/comments/17778940","id":17778940,"diff_hunk":"@@ -68,304 +71,186 @@ MeshLib::Mesh* MeshLayerMapper::CreateLayers(const MeshLib::Mesh &mesh, const st\n \t\t// add nodes for new layer\n \t\tunsigned node_offset (nNodes * layer_id);\n \t\tif (layer_id > 0) z_offset += thickness[layer_id-1];\n-\t\tfor (unsigned i = 0; i < nNodes; ++i)\n-\t\t{\n-\t\t\tconst double* coords = nodes[i]->getCoords();\n-\t\t\tnew_nodes.push_back (new MeshLib::Node(coords[0], coords[1], coords[2]-z_offset, node_offset+i));\n-\t\t}\n+\n+\t\tstd::transform(nodes.cbegin(), nodes.cend(), new_nodes.begin() + node_offset,\n+\t\t\t[&z_offset](MeshLib::Node* node){ return new MeshLib::Node((*node)[0], (*node)[1], (*node)[2]-z_offset); });\n \n \t\t// starting with 2nd layer create prism or hex elements connecting the last layer with the current one\n-\t\tif (layer_id > 0)\n+\t\tif (layer_id == 0)\n+\t\t\tcontinue;\n+\n+\t\tnode_offset -= nNodes;\n+\t\tconst unsigned mat_id (nLayers - layer_id);\n+\n+\t\tfor (unsigned i = 0; i < nOrgElems; ++i)\n \t\t{\n-\t\t\tnode_offset -= nNodes;\n-\t\t\tconst unsigned mat_id (nLayers - layer_id);\n+\t\t\tconst MeshLib::Element* sfc_elem( elems[i] );\n+\t\t\tif (sfc_elem->getDimension() < 2) // ignore line-elements\n+\t\t\t\tcontinue;\n+\t\t\t\t\n+\t\t\tconst unsigned nElemNodes(sfc_elem->getNNodes());\n+\t\t\tMeshLib::Node** e_nodes = new MeshLib::Node*[2*nElemNodes];\n \n-\t\t\tfor (unsigned i = 0; i < nOrgElems; ++i)\n+\t\t\tfor (unsigned j=0; j<nElemNodes; ++j)\n \t\t\t{\n-\t\t\t\tconst MeshLib::Element* sfc_elem( elems[i] );\n-\t\t\t\tif (sfc_elem->getDimension() != 2)\n-\t\t\t\t{\n-\t\t\t\t\tWARN(\"MshLayerMapper::CreateLayers() - Method can only handle 2D mesh elements.\");\n-\t\t\t\t\tWARN(\"Skipping Element %d of type \\\"%s\\\".\", i, MeshElemType2String(sfc_elem->getGeomType()).c_str());\n-\t\t\t\t\tcontinue;\n-\t\t\t\t}\n-\t\t\t\t\n-\t\t\t\tconst unsigned nElemNodes(sfc_elem->getNNodes());\n-\t\t\t\tMeshLib::Node** e_nodes = new MeshLib::Node*[2*nElemNodes];\n-\n-\t\t\t\tfor (unsigned j=0; j<nElemNodes; ++j)\n-\t\t\t\t{\n-\t\t\t\t\tconst unsigned node_id = sfc_elem->getNode(j)->getID() + node_offset;\n-\t\t\t\t\te_nodes[j] = new_nodes[node_id+nNodes];\n-\t\t\t\t\te_nodes[j+nElemNodes] = new_nodes[node_id];\n-\t\t\t\t}\n-\t\t\t\tif (sfc_elem->getGeomType() == MeshElemType::TRIANGLE)\t// extrude triangles to prism\n-\t\t\t\t\tnew_elems.push_back (new MeshLib::Prism(e_nodes, mat_id));\n-\t\t\t\telse if (sfc_elem->getGeomType() == MeshElemType::QUAD)\t// extrude quads to hexes\n-\t\t\t\t\tnew_elems.push_back (new MeshLib::Hex(e_nodes, mat_id));\n+\t\t\t\tconst unsigned node_id = sfc_elem->getNode(j)->getID() + node_offset;\n+\t\t\t\te_nodes[j] = new_nodes[node_id+nNodes];\n+\t\t\t\te_nodes[j+nElemNodes] = new_nodes[node_id];\n \t\t\t}\n+\t\t\tif (sfc_elem->getGeomType() == MeshElemType::TRIANGLE)\t// extrude triangles to prism\n+\t\t\t\tnew_elems.push_back (new MeshLib::Prism(e_nodes, mat_id));\n+\t\t\telse if (sfc_elem->getGeomType() == MeshElemType::QUAD)\t// extrude quads to hexes\n+\t\t\t\tnew_elems.push_back (new MeshLib::Hex(e_nodes, mat_id));\n \t\t}\n \t}\n-\treturn new MeshLib::Mesh(\"SubsurfaceMesh\", new_nodes, new_elems);\n+\treturn new MeshLib::Mesh(mesh_name, new_nodes, new_elems);\n }\n \n-bool MeshLayerMapper::LayerMapping(MeshLib::Mesh &new_mesh, const std::string &rasterfile,\n-                                   const unsigned nLayers, const unsigned layer_id, double noDataReplacementValue = 0.0)\n+bool MeshLayerMapper::createRasterLayers(MeshLib::Mesh const& mesh, std::vector<GeoLib::Raster const*> const& rasters, double noDataReplacementValue)\n {\n-\tconst GeoLib::Raster *raster(GeoLib::Raster::getRasterFromASCFile(rasterfile));\n+    const std::size_t nLayers(rasters.size());\n+    if (nLayers < 1 || mesh.getDimension() != 2)\n+    {\n+        ERR(\"MeshLayerMapper::createRasterLayers(): A 2D mesh and at least two rasters required as input.\");\n+        return nullptr;\n+    }\n+\n+    MeshLib::Mesh* dem_mesh (new MeshLib::Mesh(mesh));\n+    if (layerMapping(*dem_mesh, *rasters.back(), 0))\n+    {\n+        std::size_t const nNodes = mesh.getNNodes();\n+        _nodes.reserve(nLayers * nNodes);\n+\n+        // number of triangles in the original mesh\n+        std::size_t const nElems (std::count_if(mesh.getElements().begin(), mesh.getElements().end(),\n+            [](MeshLib::Element const* elem) { return (elem->getGeomType() == MeshElemType::TRIANGLE);}));\n+        _elements.reserve(nElems * (nLayers-1));\n+\n+        for (std::size_t i=0; i<nLayers; ++i)\n+            addLayerToMesh(*dem_mesh, i, *rasters[i]);\n+\n+        return true;\n+    }\n+    return false;\n+}\n+\n+void MeshLayerMapper::addLayerToMesh(const MeshLib::Mesh &dem_mesh, unsigned layer_id, GeoLib::Raster const& raster)\n+{\n+    std::size_t const nNodes = dem_mesh.getNNodes();\n+    std::vector<MeshLib::Node*> const& nodes = dem_mesh.getNodes();\n+    int const last_layer_node_offset = (layer_id-1) * nNodes;\n+    unsigned const layer_node_offset = layer_id * nNodes;","path":"MeshLib/MeshGenerators/MeshLayerMapper.cpp","position":171,"original_position":171,"commit_id":"683684c3e3543bf0ccce122b09add4d078c9883d","original_commit_id":"683684c3e3543bf0ccce122b09add4d078c9883d","user":{"login":"endJunction","id":329493,"avatar_url":"https://avatars.githubusercontent.com/u/329493?v=2","gravatar_id":"9faada7d0ec663487a846669b1b83fa8","url":"https://api.github.com/users/endJunction","html_url":"https://github.com/endJunction","followers_url":"https://api.github.com/users/endJunction/followers","following_url":"https://api.github.com/users/endJunction/following{/other_user}","gists_url":"https://api.github.com/users/endJunction/gists{/gist_id}","starred_url":"https://api.github.com/users/endJunction/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/endJunction/subscriptions","organizations_url":"https://api.github.com/users/endJunction/orgs","repos_url":"https://api.github.com/users/endJunction/repos","events_url":"https://api.github.com/users/endJunction/events{/privacy}","received_events_url":"https://api.github.com/users/endJunction/received_events","type":"User","site_admin":false},"body":"Unused variable","created_at":"2014-09-19T11:00:29Z","updated_at":"2014-09-19T11:00:29Z","html_url":"https://github.com/ufz/ogs/pull/476#discussion_r17778940","pull_request_url":"https://api.github.com/repos/ufz/ogs/pulls/476","_links":{"self":{"href":"https://api.github.com/repos/ufz/ogs/pulls/comments/17778940"},"html":{"href":"https://github.com/ufz/ogs/pull/476#discussion_r17778940"},"pull_request":{"href":"https://api.github.com/repos/ufz/ogs/pulls/476"}}},"pull_request":{"url":"https://api.github.com/repos/ufz/ogs/pulls/476","id":21447415,"html_url":"https://github.com/ufz/ogs/pull/476","diff_url":"https://github.com/ufz/ogs/pull/476.diff","patch_url":"https://github.com/ufz/ogs/pull/476.patch","issue_url":"https://api.github.com/repos/ufz/ogs/issues/476","number":476,"state":"open","locked":false,"title":"Unified mesh layer mapping","user":{"login":"rinkk","id":798445,"avatar_url":"https://avatars.githubusercontent.com/u/798445?v=2","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":"* Unifies the interface of MeshLayerMapper and LayeredVolume and introduces base class for these two  to handle common functionality.\r\n* Allows to create prism-meshes from incomplete layers or conflicting information and unifies/simplifies GUI dialogue for inputting the relevant information.\r\n* Moves ascii-raster I/O to FileIO","created_at":"2014-09-18T16:56:50Z","updated_at":"2014-09-19T11:00:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cd46e81c258f5b00fb8cd14f00b9bcb52bd346d0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ufz/ogs/pulls/476/commits","review_comments_url":"https://api.github.com/repos/ufz/ogs/pulls/476/comments","review_comment_url":"https://api.github.com/repos/ufz/ogs/pulls/comments/{number}","comments_url":"https://api.github.com/repos/ufz/ogs/issues/476/comments","statuses_url":"https://api.github.com/repos/ufz/ogs/statuses/683684c3e3543bf0ccce122b09add4d078c9883d","head":{"label":"rinkk:UnifiedLayerMapping","ref":"UnifiedLayerMapping","sha":"683684c3e3543bf0ccce122b09add4d078c9883d","user":{"login":"rinkk","id":798445,"avatar_url":"https://avatars.githubusercontent.com/u/798445?v=2","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},"repo":{"id":7148641,"name":"ogs","full_name":"rinkk/ogs","owner":{"login":"rinkk","id":798445,"avatar_url":"https://avatars.githubusercontent.com/u/798445?v=2","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},"private":false,"html_url":"https://github.com/rinkk/ogs","description":"OGS source code","fork":true,"url":"https://api.github.com/repos/rinkk/ogs","forks_url":"https://api.github.com/repos/rinkk/ogs/forks","keys_url":"https://api.github.com/repos/rinkk/ogs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rinkk/ogs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rinkk/ogs/teams","hooks_url":"https://api.github.com/repos/rinkk/ogs/hooks","issue_events_url":"https://api.github.com/repos/rinkk/ogs/issues/events{/number}","events_url":"https://api.github.com/repos/rinkk/ogs/events","assignees_url":"https://api.github.com/repos/rinkk/ogs/assignees{/user}","branches_url":"https://api.github.com/repos/rinkk/ogs/branches{/branch}","tags_url":"https://api.github.com/repos/rinkk/ogs/tags","blobs_url":"https://api.github.com/repos/rinkk/ogs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rinkk/ogs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rinkk/ogs/git/refs{/sha}","trees_url":"https://api.github.com/repos/rinkk/ogs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rinkk/ogs/statuses/{sha}","languages_url":"https://api.github.com/repos/rinkk/ogs/languages","stargazers_url":"https://api.github.com/repos/rinkk/ogs/stargazers","contributors_url":"https://api.github.com/repos/rinkk/ogs/contributors","subscribers_url":"https://api.github.com/repos/rinkk/ogs/subscribers","subscription_url":"https://api.github.com/repos/rinkk/ogs/subscription","commits_url":"https://api.github.com/repos/rinkk/ogs/commits{/sha}","git_commits_url":"https://api.github.com/repos/rinkk/ogs/git/commits{/sha}","comments_url":"https://api.github.com/repos/rinkk/ogs/comments{/number}","issue_comment_url":"https://api.github.com/repos/rinkk/ogs/issues/comments/{number}","contents_url":"https://api.github.com/repos/rinkk/ogs/contents/{+path}","compare_url":"https://api.github.com/repos/rinkk/ogs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rinkk/ogs/merges","archive_url":"https://api.github.com/repos/rinkk/ogs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rinkk/ogs/downloads","issues_url":"https://api.github.com/repos/rinkk/ogs/issues{/number}","pulls_url":"https://api.github.com/repos/rinkk/ogs/pulls{/number}","milestones_url":"https://api.github.com/repos/rinkk/ogs/milestones{/number}","notifications_url":"https://api.github.com/repos/rinkk/ogs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rinkk/ogs/labels{/name}","releases_url":"https://api.github.com/repos/rinkk/ogs/releases{/id}","created_at":"2012-12-13T13:27:20Z","updated_at":"2014-09-01T13:43:48Z","pushed_at":"2014-09-18T17:05:43Z","git_url":"git://github.com/rinkk/ogs.git","ssh_url":"git@github.com:rinkk/ogs.git","clone_url":"https://github.com/rinkk/ogs.git","svn_url":"https://github.com/rinkk/ogs","homepage":"www.opengeosys.org","size":9178,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ufz:master","ref":"master","sha":"dd154c82fb176da46ef39ece8653242f599e20fe","user":{"login":"ufz","id":767517,"avatar_url":"https://avatars.githubusercontent.com/u/767517?v=2","gravatar_id":"65100d32f0bc59887348df58edc7c8fc","url":"https://api.github.com/users/ufz","html_url":"https://github.com/ufz","followers_url":"https://api.github.com/users/ufz/followers","following_url":"https://api.github.com/users/ufz/following{/other_user}","gists_url":"https://api.github.com/users/ufz/gists{/gist_id}","starred_url":"https://api.github.com/users/ufz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ufz/subscriptions","organizations_url":"https://api.github.com/users/ufz/orgs","repos_url":"https://api.github.com/users/ufz/repos","events_url":"https://api.github.com/users/ufz/events{/privacy}","received_events_url":"https://api.github.com/users/ufz/received_events","type":"Organization","site_admin":false},"repo":{"id":1701384,"name":"ogs","full_name":"ufz/ogs","owner":{"login":"ufz","id":767517,"avatar_url":"https://avatars.githubusercontent.com/u/767517?v=2","gravatar_id":"65100d32f0bc59887348df58edc7c8fc","url":"https://api.github.com/users/ufz","html_url":"https://github.com/ufz","followers_url":"https://api.github.com/users/ufz/followers","following_url":"https://api.github.com/users/ufz/following{/other_user}","gists_url":"https://api.github.com/users/ufz/gists{/gist_id}","starred_url":"https://api.github.com/users/ufz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ufz/subscriptions","organizations_url":"https://api.github.com/users/ufz/orgs","repos_url":"https://api.github.com/users/ufz/repos","events_url":"https://api.github.com/users/ufz/events{/privacy}","received_events_url":"https://api.github.com/users/ufz/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ufz/ogs","description":"OGS source code","fork":false,"url":"https://api.github.com/repos/ufz/ogs","forks_url":"https://api.github.com/repos/ufz/ogs/forks","keys_url":"https://api.github.com/repos/ufz/ogs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ufz/ogs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ufz/ogs/teams","hooks_url":"https://api.github.com/repos/ufz/ogs/hooks","issue_events_url":"https://api.github.com/repos/ufz/ogs/issues/events{/number}","events_url":"https://api.github.com/repos/ufz/ogs/events","assignees_url":"https://api.github.com/repos/ufz/ogs/assignees{/user}","branches_url":"https://api.github.com/repos/ufz/ogs/branches{/branch}","tags_url":"https://api.github.com/repos/ufz/ogs/tags","blobs_url":"https://api.github.com/repos/ufz/ogs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ufz/ogs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ufz/ogs/git/refs{/sha}","trees_url":"https://api.github.com/repos/ufz/ogs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ufz/ogs/statuses/{sha}","languages_url":"https://api.github.com/repos/ufz/ogs/languages","stargazers_url":"https://api.github.com/repos/ufz/ogs/stargazers","contributors_url":"https://api.github.com/repos/ufz/ogs/contributors","subscribers_url":"https://api.github.com/repos/ufz/ogs/subscribers","subscription_url":"https://api.github.com/repos/ufz/ogs/subscription","commits_url":"https://api.github.com/repos/ufz/ogs/commits{/sha}","git_commits_url":"https://api.github.com/repos/ufz/ogs/git/commits{/sha}","comments_url":"https://api.github.com/repos/ufz/ogs/comments{/number}","issue_comment_url":"https://api.github.com/repos/ufz/ogs/issues/comments/{number}","contents_url":"https://api.github.com/repos/ufz/ogs/contents/{+path}","compare_url":"https://api.github.com/repos/ufz/ogs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ufz/ogs/merges","archive_url":"https://api.github.com/repos/ufz/ogs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ufz/ogs/downloads","issues_url":"https://api.github.com/repos/ufz/ogs/issues{/number}","pulls_url":"https://api.github.com/repos/ufz/ogs/pulls{/number}","milestones_url":"https://api.github.com/repos/ufz/ogs/milestones{/number}","notifications_url":"https://api.github.com/repos/ufz/ogs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ufz/ogs/labels{/name}","releases_url":"https://api.github.com/repos/ufz/ogs/releases{/id}","created_at":"2011-05-04T14:09:57Z","updated_at":"2014-09-02T11:52:00Z","pushed_at":"2014-09-19T05:14:27Z","git_url":"git://github.com/ufz/ogs.git","ssh_url":"git@github.com:ufz/ogs.git","clone_url":"https://github.com/ufz/ogs.git","svn_url":"https://github.com/ufz/ogs","homepage":"www.opengeosys.org","size":15010,"stargazers_count":13,"watchers_count":13,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":28,"mirror_url":null,"open_issues_count":56,"forks":28,"open_issues":56,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ufz/ogs/pulls/476"},"html":{"href":"https://github.com/ufz/ogs/pull/476"},"issue":{"href":"https://api.github.com/repos/ufz/ogs/issues/476"},"comments":{"href":"https://api.github.com/repos/ufz/ogs/issues/476/comments"},"review_comments":{"href":"https://api.github.com/repos/ufz/ogs/pulls/476/comments"},"review_comment":{"href":"https://api.github.com/repos/ufz/ogs/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/ufz/ogs/pulls/476/commits"},"statuses":{"href":"https://api.github.com/repos/ufz/ogs/statuses/683684c3e3543bf0ccce122b09add4d078c9883d"}}}}