{"action":"created","comment":{"url":"https://api.github.com/repos/BlueBrain/Brion/pulls/comments/52283505","id":52283505,"diff_hunk":"@@ -202,13 +254,199 @@ class Circuit::Impl\n     CircuitTable _table;\n };\n \n+\n+//////////////////////////////////////////////////\n+/// MVD3 implementation\n+//////////////////////////////////////////////////\n+\n+template<typename SrcArray, typename DstArray, typename AssignOps>\n+inline void array_range_to_index(const MVD3::Range & range,\n+                                 const GIDSet& gids,\n+                                 SrcArray & src,\n+                                 DstArray & dst,\n+                                 const AssignOps & assign_ops){\n+    size_t s_source = std::distance(src.begin(), src.end()); (void) s_source;\n+    size_t s_dest = std::distance(dst.begin(), dst.end()); (void) s_dest;\n+\n+    if(gids.empty() == true){ // we work on full range, no translation needed\n+        assert(s_source == s_dest);\n+        std::transform(src.begin(), src.end(), dst.begin(), assign_ops);\n+    }else{\n+        assert(s_dest == gids.size());\n+        typename DstArray::iterator dst_it = dst.begin();\n+        for(GIDSet::const_iterator it = gids.begin(); it != gids.end(); ++it){\n+            assert( *it >= range.offset && *it < (range.offset + range.count+1));\n+            typename SrcArray::iterator src_it = src.begin();\n+            std::advance(src_it, *it - range.offset );\n+            *dst_it = assign_ops(*src_it);\n+            ++dst_it;\n+        }\n+    }\n+}\n+\n+std::string swap_string(std::string & in){\n+    std::string res;\n+    res.swap(in);\n+    return res;\n+}\n+\n+std::string size_to_string(size_t in){\n+    return boost::lexical_cast<std::string>(in);\n+}\n+\n+Vector3f boost_mul_array_to_vmml(const MVD3::Positions::subarray<1>::type & subarray){\n+    Vector3f res;\n+    std::copy(subarray.begin(), subarray.end(), res.begin());\n+    return res;\n+}\n+\n+\n+MVD3::Range range_from_gidset(const GIDSet & gids){\n+    if(gids.size() > 0){\n+        const size_t offset = *gids.begin();\n+        const size_t range_count = *gids.rbegin() - offset +1;\n+        return MVD3::Range(offset, range_count);\n+    }\n+    return MVD3::Range(0,0); // full range\n+}\n+\n+class Circuit::ImplMVD3 : public Circuit::Impl\n+{\n+public:\n+    ImplMVD3(const std::string & src) : _file(){\n+        // convert any HighFive exception\n+        try{\n+            _file.reset(new MVD3::MVD3File(src));\n+        }catch(std::exception & e){\n+            throw std::runtime_error(std::string(\"Impossible to Open/Read MVD3 file \") + src + \" \" + e.what());\n+        }\n+    }\n+\n+    virtual ~ImplMVD3() {}\n+\n+    virtual NeuronMatrix get( const GIDSet& gids, const uint32_t attributes ) const{\n+        NeuronMatrix result;\n+        std::bitset< NEURON_ALL > bits( attributes );\n+        MVD3::Range range = range_from_gidset(gids);\n+\n+        if(bits.none()){\n+            return result;\n+        }\n+\n+        const size_t size_result = (gids.size() > 0)?gids.size():getNumNeurons();\n+        result.resize(boost::extents[size_result][bits.count()]);\n+\n+        size_t pos =0;\n+        for(int i=0; i < NEURON_ALL; ++i){\n+            typedef NeuronMatrix::index_range NeuronMatrixRange;\n+            if(bits[i] == true){\n+                switch(1 << i){\n+                case NEURON_COLUMN_GID:\n+                case NEURON_MINICOLUMN_GID:\n+                case NEURON_LAYER:\n+                case NEURON_METYPE:{\n+                    throw std::runtime_error(\"Layer, metype, mini-column or column gid informations are not supported by the MVD3 file format\");\n+                }\n+                case NEURON_ROTATION:\n+                case NEURON_POSITION_X:\n+                case NEURON_POSITION_Y:\n+                case NEURON_POSITION_Z:{\n+                    throw std::runtime_error(\"Position (X,Y,Z) or rotation informations are not string properties in MVD3\"\n+                                             \"please see Brion::Circuit API for details\");\n+                }\n+                case NEURON_ETYPE:{\n+                    std::vector<size_t> etypes = _file->getIndexEtypes(range);\n+                    NeuronMatrix::array_view<1>::type column_view = result[boost::indices[NeuronMatrixRange()][pos]];\n+                    array_range_to_index(range, gids, etypes, column_view, size_to_string);\n+                    break;\n+                }\n+                case NEURON_MTYPE:{\n+                    std::vector<size_t> mtypes = _file->getIndexMtypes(range);\n+                    NeuronMatrix::array_view<1>::type column_view = result[boost::indices[NeuronMatrixRange()][pos]];\n+                    array_range_to_index(range, gids, mtypes, column_view, size_to_string);\n+                    break;\n+                }\n+                case NEURON_MORPHOLOGY_NAME:{\n+                    std::vector<std::string> morphos = _file->getMorphologies(range);\n+                    NeuronMatrix::array_view<1>::type column_view = result[boost::indices[NeuronMatrixRange()][pos]];\n+                    array_range_to_index(range, gids, morphos, column_view, swap_string);\n+                    break;\n+                }\n+                default:\n+                break;\n+                }\n+                pos += 1;\n+            }\n+        }\n+        assert(pos == bits.count());\n+        return result;\n+    }\n+\n+    virtual Vector3fs getPositions(const GIDSet &gids) const{\n+        Vector3fs results;\n+        MVD3::Range range = range_from_gidset(gids);\n+        MVD3::Positions positions = _file->getPositions(range);\n+        assert(positions.shape()[1] ==3);\n+        array_range_to_index(range, gids, positions, results, boost_mul_array_to_vmml);\n+        return results;\n+    }\n+\n+    virtual size_t getNumNeurons() const{\n+        return _file->getNbNeuron();\n+    }\n+\n+\n+    virtual Strings getTypes( const NeuronClass type ) const{\n+        switch( type ){\n+            case NEURONCLASS_ETYPE:{\n+                return _file->listAllEtypes();\n+            }\n+            case NEURONCLASS_MTYPE:{\n+                return _file->listAllMtypes();\n+            }\n+            case NEURONCLASS_MORPHOLOGY_CLASS:{\n+                return _file->listAllMorphologies();\n+            }\n+            case NEURONCLASS_FUNCTION_CLASS:{\n+                return _file->listAllSynapseClass();\n+            }\n+            case NEURONCLASS_INVALID:\n+            default:\n+            break;\n+        }\n+        return Strings();\n+    }\n+\n+private:\n+    mutable boost::scoped_ptr<MVD3::MVD3File> _file;\n+};\n+\n+\n+//////////////////////////////////////////////////\n+/// Circuit Pimpl mapper\n+//////////////////////////////////////////////////\n+\n+Circuit::Impl* Circuit::instanciate(const std::string & source){\n+    namespace fs = boost::filesystem;\n+    fs::path path = source;\n+    const std::string ext = fs::extension( path );\n+    if( ext == \".mvd\" || ext == \".mvd2\" ){","path":"brion/circuit.cpp","position":341,"original_position":341,"commit_id":"ae1629d0dd8fbd7fc25926dbbc980e848e86648f","original_commit_id":"ae1629d0dd8fbd7fc25926dbbc980e848e86648f","user":{"login":"adevress","id":1773511,"avatar_url":"https://avatars.githubusercontent.com/u/1773511?v=3","gravatar_id":"","url":"https://api.github.com/users/adevress","html_url":"https://github.com/adevress","followers_url":"https://api.github.com/users/adevress/followers","following_url":"https://api.github.com/users/adevress/following{/other_user}","gists_url":"https://api.github.com/users/adevress/gists{/gist_id}","starred_url":"https://api.github.com/users/adevress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adevress/subscriptions","organizations_url":"https://api.github.com/users/adevress/orgs","repos_url":"https://api.github.com/users/adevress/repos","events_url":"https://api.github.com/users/adevress/events{/privacy}","received_events_url":"https://api.github.com/users/adevress/received_events","type":"User","site_admin":false},"body":"It was like this before, I did not change it, just moved it :)","created_at":"2016-02-09T09:26:00Z","updated_at":"2016-02-09T09:26:00Z","html_url":"https://github.com/BlueBrain/Brion/pull/41#discussion_r52283505","pull_request_url":"https://api.github.com/repos/BlueBrain/Brion/pulls/41","_links":{"self":{"href":"https://api.github.com/repos/BlueBrain/Brion/pulls/comments/52283505"},"html":{"href":"https://github.com/BlueBrain/Brion/pull/41#discussion_r52283505"},"pull_request":{"href":"https://api.github.com/repos/BlueBrain/Brion/pulls/41"}}},"pull_request":{"url":"https://api.github.com/repos/BlueBrain/Brion/pulls/41","id":58641342,"html_url":"https://github.com/BlueBrain/Brion/pull/41","diff_url":"https://github.com/BlueBrain/Brion/pull/41.diff","patch_url":"https://github.com/BlueBrain/Brion/pull/41.patch","issue_url":"https://api.github.com/repos/BlueBrain/Brion/issues/41","number":41,"state":"open","locked":false,"title":"Initial partial implementation for MVD3 support","user":{"login":"adevress","id":1773511,"avatar_url":"https://avatars.githubusercontent.com/u/1773511?v=3","gravatar_id":"","url":"https://api.github.com/users/adevress","html_url":"https://github.com/adevress","followers_url":"https://api.github.com/users/adevress/followers","following_url":"https://api.github.com/users/adevress/following{/other_user}","gists_url":"https://api.github.com/users/adevress/gists{/gist_id}","starred_url":"https://api.github.com/users/adevress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adevress/subscriptions","organizations_url":"https://api.github.com/users/adevress/orgs","repos_url":"https://api.github.com/users/adevress/repos","events_url":"https://api.github.com/users/adevress/events{/privacy}","received_events_url":"https://api.github.com/users/adevress/received_events","type":"User","site_admin":false},"body":"- Add basic MVD3 support to Brion::circuit\r\n- Add mvd-tool as a subproject for MVD3 parsing\r\n- Move feature from Brain API to Brion API ( improve perfs with MVD3 )\r\n- Add tests for MVD3 parsing\r\n- Add Nix support","created_at":"2016-02-08T17:35:05Z","updated_at":"2016-02-09T09:26:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"733fc68ce912c220821283707b0036a58c424f86","assignee":{"login":"tribal-tec","id":701401,"avatar_url":"https://avatars.githubusercontent.com/u/701401?v=3","gravatar_id":"","url":"https://api.github.com/users/tribal-tec","html_url":"https://github.com/tribal-tec","followers_url":"https://api.github.com/users/tribal-tec/followers","following_url":"https://api.github.com/users/tribal-tec/following{/other_user}","gists_url":"https://api.github.com/users/tribal-tec/gists{/gist_id}","starred_url":"https://api.github.com/users/tribal-tec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tribal-tec/subscriptions","organizations_url":"https://api.github.com/users/tribal-tec/orgs","repos_url":"https://api.github.com/users/tribal-tec/repos","events_url":"https://api.github.com/users/tribal-tec/events{/privacy}","received_events_url":"https://api.github.com/users/tribal-tec/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/BlueBrain/Brion/pulls/41/commits","review_comments_url":"https://api.github.com/repos/BlueBrain/Brion/pulls/41/comments","review_comment_url":"https://api.github.com/repos/BlueBrain/Brion/pulls/comments{/number}","comments_url":"https://api.github.com/repos/BlueBrain/Brion/issues/41/comments","statuses_url":"https://api.github.com/repos/BlueBrain/Brion/statuses/ae1629d0dd8fbd7fc25926dbbc980e848e86648f","head":{"label":"adevress:master","ref":"master","sha":"ae1629d0dd8fbd7fc25926dbbc980e848e86648f","user":{"login":"adevress","id":1773511,"avatar_url":"https://avatars.githubusercontent.com/u/1773511?v=3","gravatar_id":"","url":"https://api.github.com/users/adevress","html_url":"https://github.com/adevress","followers_url":"https://api.github.com/users/adevress/followers","following_url":"https://api.github.com/users/adevress/following{/other_user}","gists_url":"https://api.github.com/users/adevress/gists{/gist_id}","starred_url":"https://api.github.com/users/adevress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adevress/subscriptions","organizations_url":"https://api.github.com/users/adevress/orgs","repos_url":"https://api.github.com/users/adevress/repos","events_url":"https://api.github.com/users/adevress/events{/privacy}","received_events_url":"https://api.github.com/users/adevress/received_events","type":"User","site_admin":false},"repo":{"id":51313435,"name":"Brion","full_name":"adevress/Brion","owner":{"login":"adevress","id":1773511,"avatar_url":"https://avatars.githubusercontent.com/u/1773511?v=3","gravatar_id":"","url":"https://api.github.com/users/adevress","html_url":"https://github.com/adevress","followers_url":"https://api.github.com/users/adevress/followers","following_url":"https://api.github.com/users/adevress/following{/other_user}","gists_url":"https://api.github.com/users/adevress/gists{/gist_id}","starred_url":"https://api.github.com/users/adevress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adevress/subscriptions","organizations_url":"https://api.github.com/users/adevress/orgs","repos_url":"https://api.github.com/users/adevress/repos","events_url":"https://api.github.com/users/adevress/events{/privacy}","received_events_url":"https://api.github.com/users/adevress/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/adevress/Brion","description":"Blue Brain C++ File IO Library","fork":true,"url":"https://api.github.com/repos/adevress/Brion","forks_url":"https://api.github.com/repos/adevress/Brion/forks","keys_url":"https://api.github.com/repos/adevress/Brion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/adevress/Brion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/adevress/Brion/teams","hooks_url":"https://api.github.com/repos/adevress/Brion/hooks","issue_events_url":"https://api.github.com/repos/adevress/Brion/issues/events{/number}","events_url":"https://api.github.com/repos/adevress/Brion/events","assignees_url":"https://api.github.com/repos/adevress/Brion/assignees{/user}","branches_url":"https://api.github.com/repos/adevress/Brion/branches{/branch}","tags_url":"https://api.github.com/repos/adevress/Brion/tags","blobs_url":"https://api.github.com/repos/adevress/Brion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/adevress/Brion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/adevress/Brion/git/refs{/sha}","trees_url":"https://api.github.com/repos/adevress/Brion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/adevress/Brion/statuses/{sha}","languages_url":"https://api.github.com/repos/adevress/Brion/languages","stargazers_url":"https://api.github.com/repos/adevress/Brion/stargazers","contributors_url":"https://api.github.com/repos/adevress/Brion/contributors","subscribers_url":"https://api.github.com/repos/adevress/Brion/subscribers","subscription_url":"https://api.github.com/repos/adevress/Brion/subscription","commits_url":"https://api.github.com/repos/adevress/Brion/commits{/sha}","git_commits_url":"https://api.github.com/repos/adevress/Brion/git/commits{/sha}","comments_url":"https://api.github.com/repos/adevress/Brion/comments{/number}","issue_comment_url":"https://api.github.com/repos/adevress/Brion/issues/comments{/number}","contents_url":"https://api.github.com/repos/adevress/Brion/contents/{+path}","compare_url":"https://api.github.com/repos/adevress/Brion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/adevress/Brion/merges","archive_url":"https://api.github.com/repos/adevress/Brion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/adevress/Brion/downloads","issues_url":"https://api.github.com/repos/adevress/Brion/issues{/number}","pulls_url":"https://api.github.com/repos/adevress/Brion/pulls{/number}","milestones_url":"https://api.github.com/repos/adevress/Brion/milestones{/number}","notifications_url":"https://api.github.com/repos/adevress/Brion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/adevress/Brion/labels{/name}","releases_url":"https://api.github.com/repos/adevress/Brion/releases{/id}","deployments_url":"https://api.github.com/repos/adevress/Brion/deployments","created_at":"2016-02-08T17:23:48Z","updated_at":"2016-02-08T17:23:49Z","pushed_at":"2016-02-08T21:42:17Z","git_url":"git://github.com/adevress/Brion.git","ssh_url":"git@github.com:adevress/Brion.git","clone_url":"https://github.com/adevress/Brion.git","svn_url":"https://github.com/adevress/Brion","homepage":"http://bluebrain.github.io/","size":343,"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":"BlueBrain:master","ref":"master","sha":"5c2ef23c5777005e4b5ab047809df6023d2e66d1","user":{"login":"BlueBrain","id":1479142,"avatar_url":"https://avatars.githubusercontent.com/u/1479142?v=3","gravatar_id":"","url":"https://api.github.com/users/BlueBrain","html_url":"https://github.com/BlueBrain","followers_url":"https://api.github.com/users/BlueBrain/followers","following_url":"https://api.github.com/users/BlueBrain/following{/other_user}","gists_url":"https://api.github.com/users/BlueBrain/gists{/gist_id}","starred_url":"https://api.github.com/users/BlueBrain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BlueBrain/subscriptions","organizations_url":"https://api.github.com/users/BlueBrain/orgs","repos_url":"https://api.github.com/users/BlueBrain/repos","events_url":"https://api.github.com/users/BlueBrain/events{/privacy}","received_events_url":"https://api.github.com/users/BlueBrain/received_events","type":"Organization","site_admin":false},"repo":{"id":35547993,"name":"Brion","full_name":"BlueBrain/Brion","owner":{"login":"BlueBrain","id":1479142,"avatar_url":"https://avatars.githubusercontent.com/u/1479142?v=3","gravatar_id":"","url":"https://api.github.com/users/BlueBrain","html_url":"https://github.com/BlueBrain","followers_url":"https://api.github.com/users/BlueBrain/followers","following_url":"https://api.github.com/users/BlueBrain/following{/other_user}","gists_url":"https://api.github.com/users/BlueBrain/gists{/gist_id}","starred_url":"https://api.github.com/users/BlueBrain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BlueBrain/subscriptions","organizations_url":"https://api.github.com/users/BlueBrain/orgs","repos_url":"https://api.github.com/users/BlueBrain/repos","events_url":"https://api.github.com/users/BlueBrain/events{/privacy}","received_events_url":"https://api.github.com/users/BlueBrain/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/BlueBrain/Brion","description":"Blue Brain C++ File IO Library","fork":false,"url":"https://api.github.com/repos/BlueBrain/Brion","forks_url":"https://api.github.com/repos/BlueBrain/Brion/forks","keys_url":"https://api.github.com/repos/BlueBrain/Brion/keys{/key_id}","collaborators_url":"https://api.github.com/repos/BlueBrain/Brion/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/BlueBrain/Brion/teams","hooks_url":"https://api.github.com/repos/BlueBrain/Brion/hooks","issue_events_url":"https://api.github.com/repos/BlueBrain/Brion/issues/events{/number}","events_url":"https://api.github.com/repos/BlueBrain/Brion/events","assignees_url":"https://api.github.com/repos/BlueBrain/Brion/assignees{/user}","branches_url":"https://api.github.com/repos/BlueBrain/Brion/branches{/branch}","tags_url":"https://api.github.com/repos/BlueBrain/Brion/tags","blobs_url":"https://api.github.com/repos/BlueBrain/Brion/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/BlueBrain/Brion/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/BlueBrain/Brion/git/refs{/sha}","trees_url":"https://api.github.com/repos/BlueBrain/Brion/git/trees{/sha}","statuses_url":"https://api.github.com/repos/BlueBrain/Brion/statuses/{sha}","languages_url":"https://api.github.com/repos/BlueBrain/Brion/languages","stargazers_url":"https://api.github.com/repos/BlueBrain/Brion/stargazers","contributors_url":"https://api.github.com/repos/BlueBrain/Brion/contributors","subscribers_url":"https://api.github.com/repos/BlueBrain/Brion/subscribers","subscription_url":"https://api.github.com/repos/BlueBrain/Brion/subscription","commits_url":"https://api.github.com/repos/BlueBrain/Brion/commits{/sha}","git_commits_url":"https://api.github.com/repos/BlueBrain/Brion/git/commits{/sha}","comments_url":"https://api.github.com/repos/BlueBrain/Brion/comments{/number}","issue_comment_url":"https://api.github.com/repos/BlueBrain/Brion/issues/comments{/number}","contents_url":"https://api.github.com/repos/BlueBrain/Brion/contents/{+path}","compare_url":"https://api.github.com/repos/BlueBrain/Brion/compare/{base}...{head}","merges_url":"https://api.github.com/repos/BlueBrain/Brion/merges","archive_url":"https://api.github.com/repos/BlueBrain/Brion/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/BlueBrain/Brion/downloads","issues_url":"https://api.github.com/repos/BlueBrain/Brion/issues{/number}","pulls_url":"https://api.github.com/repos/BlueBrain/Brion/pulls{/number}","milestones_url":"https://api.github.com/repos/BlueBrain/Brion/milestones{/number}","notifications_url":"https://api.github.com/repos/BlueBrain/Brion/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/BlueBrain/Brion/labels{/name}","releases_url":"https://api.github.com/repos/BlueBrain/Brion/releases{/id}","deployments_url":"https://api.github.com/repos/BlueBrain/Brion/deployments","created_at":"2015-05-13T12:33:49Z","updated_at":"2016-01-13T08:52:11Z","pushed_at":"2016-02-08T21:42:17Z","git_url":"git://github.com/BlueBrain/Brion.git","ssh_url":"git@github.com:BlueBrain/Brion.git","clone_url":"https://github.com/BlueBrain/Brion.git","svn_url":"https://github.com/BlueBrain/Brion","homepage":"http://bluebrain.github.io/","size":347,"stargazers_count":3,"watchers_count":3,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":2,"forks":9,"open_issues":2,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/BlueBrain/Brion/pulls/41"},"html":{"href":"https://github.com/BlueBrain/Brion/pull/41"},"issue":{"href":"https://api.github.com/repos/BlueBrain/Brion/issues/41"},"comments":{"href":"https://api.github.com/repos/BlueBrain/Brion/issues/41/comments"},"review_comments":{"href":"https://api.github.com/repos/BlueBrain/Brion/pulls/41/comments"},"review_comment":{"href":"https://api.github.com/repos/BlueBrain/Brion/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/BlueBrain/Brion/pulls/41/commits"},"statuses":{"href":"https://api.github.com/repos/BlueBrain/Brion/statuses/ae1629d0dd8fbd7fc25926dbbc980e848e86648f"}}}}