Esempio n. 1
0
    void Geometry::import_meshes(const Meshes& m) {
        meshes_.clear();
        vertices_.clear();
        unsigned n_vert_max = 0;
        unsigned iit = 0;
        std::map<const Vertex *, Vertex *> map_vertices;

        // count the vertices
        for (Meshes::const_iterator mit=m.begin();mit!=m.end();++mit)
            n_vert_max += mit->nb_vertices();
        
        vertices_.reserve(n_vert_max);
        meshes_.reserve(m.size());

        for (Meshes::const_iterator mit=m.begin();mit!=m.end();++mit,++iit) {
            meshes_.push_back(Mesh(vertices_,mit->name()));
            for (Mesh::const_vertex_iterator vit=mit->vertex_begin();vit!=mit->vertex_end();vit++) {
                meshes_[iit].add_vertex(**vit);
                map_vertices[*vit] = *meshes_[iit].vertex_rbegin();
            }
        }

        // Copy the triangles in the geometry.
        iit = 0;
        for (Meshes::const_iterator mit=m.begin();mit!=m.end();++mit,++iit) {
            for (Mesh::const_iterator tit=mit->begin();tit!=mit->end();++tit)
                meshes_[iit].push_back(Triangle(map_vertices[(*tit)[0]], 
                                                map_vertices[(*tit)[1]], 
                                                map_vertices[(*tit)[2]]));
            meshes_[iit].update();
        }
    }
Esempio n. 2
0
void Mesh_File_Reader::load(
    Meshes & final_meshes,
    const std::set<Label> & names,
    bool load_vertices,
    bool load_triangles,
    bool load_mapping,
    bool load_triangle_strips)
{
    Meshes meshes;
    for (std::set<Label>::const_iterator name = names.begin();
         name != names.end();
         ++name) {
        insert_new_or_updated(*name, final_meshes, meshes,
                              load_vertices, load_triangles, 
                              load_triangle_strips, load_mapping);
    }

    // Final insertion from local container to result
    for (Meshes::iterator i = meshes.begin();
         i != meshes.end();
         ++i)
    {
        // This insertion replaces old existing meshes with its updated 
        // version also
        final_meshes.insert(i.label(), i.ptr());
    }
}
Esempio n. 3
0
void Mesh_File_Reader::load(
    Meshes & final_meshes,
    const Cell_Target & cells, 
    const URI & circuit_source,
    bool load_vertices,
    bool load_triangles,
    bool load_mapping,
    bool load_triangle_strips)
{
    Meshes meshes;

    boost::filesystem::path mvd_file = uri_to_filename(circuit_source);
    if (mvd_file == "" || boost::filesystem::extension(mvd_file) != ".mvd2")
    {
        throw_exception(Bad_Data_Source("Loading meshes: circuit_source '" + 
                                        circuit_source + "' "), 
                        FATAL_LEVEL, __FILE__, __LINE__);
    }
    MVD_File_Parser mvd_parser(mvd_file);

    mvd_parser.parse_file(cells);
    for (Cell_Target::iterator cell_gid = cells.begin(); 
         cell_gid != cells.end();
         ++cell_gid)
    {
        MVD_Cell_Index index = mvd_parser.cell_index(*cell_gid);
        if (index == UNDEFINED_MVD_CELL_INDEX)
        {
            std::stringstream msg;
            msg << "Loading meshes: bad cell target, neuron gid " 
                << *cell_gid << " not in mvd file '" << mvd_file << "'";
            throw_exception(Bad_Data(msg.str()), 
                            FATAL_LEVEL, __FILE__, __LINE__);
        }

        const Label & label = mvd_parser.morphology_names()[index];
        if (meshes.find(label) == meshes.end())
        {
            insert_new_or_updated(label, final_meshes, meshes, 
                                  load_vertices, load_triangles,
                                  load_triangle_strips, load_mapping);
        }
    }

    // Final insertion from local container to result
    for (Meshes::iterator i = meshes.begin();
         i != meshes.end();
         ++i)
    {
        // This insertion replaces old existing meshes with its updated 
        // version also
        final_meshes.insert(i.label(), i.ptr());
    }
}