コード例 #1
0
ファイル: SAReader.cpp プロジェクト: AlgoLab/FastStringGraph
void SAReader::read(SuffixArray* pSA)
{
    size_t num_elems;
    readHeader(pSA->m_numStrings, num_elems);
    pSA->m_data.reserve(num_elems);
    
    readElems(pSA->m_data);
}
コード例 #2
0
ファイル: Reader.cpp プロジェクト: FabienPean/FractureBEM
    int BEMReader::readModel(elem_map& elems, id_map& bodyIDs,
        elem_map& bndrys, elem_map& bndryParents, node_map& nodes,
        const ELEM_TYPE elemType,  const std::set<unsigned int> elemBodies,
        const ELEM_TYPE bndryType, const std::set<unsigned int> bndryBodies
    ){
		//if meshFile ends with ".stl", ".obj", ".ply" etc. use VCG to read raw-mesh (nodes & elems, nothing more)
		if( meshFile.find(".stl")!=meshFile.npos ||
			meshFile.find(".obj")!=meshFile.npos ||
			meshFile.find(".off")!=meshFile.npos ||
			meshFile.find(".ply")!=meshFile.npos
		){
			printf("\n%% reading raw triangle mesh from %s (requires --remesh option)\n%%\t",meshFile.c_str());
			return readVCG(meshFile,nodes,elems);
		}
		node_map nodes_in;
        //elem_map elems_in;
        int ret;
        // read elements and nodes
		ret=readElems(elems, elemType, elemBodies,ELEMENTS_FILE,&bodyIDs);
        if(ret<0) return ret;
        ret=readNodes(nodes_in);
        if(ret<0) return ret;
        // now switch to .boundary file
        string tmp=elemFile;
        elemFile=meshFile;
        elemFile.append(".boundary");
        ret=readElems(bndrys,bndryType,bndryBodies,BOUNDARY_FILE,NULL,&bndryParents,true);
        // restore state of the BEMReader object
        elemFile=tmp;
        //if(ret<0) return ret; // it's ok to not have a boundary file, if there's no pre-defined cracks

		// reading is complete, but for HyENA-BEM compatibility the nodes need to be numbered
		// in the same order as they appear in the element map.
        
		// run through the element map and decide new node numbers
		id_map fwd;// bkwd; // fwd[old_id]=new_id, bkwd[new_id]=old_id
		unsigned int new_id=NODE_BASE_INDEX;
		for(elem_map::iterator i = elems.begin(); i!=elems.end(); ++i){
			//run through all nodes of the element
			for(elem_map::mapped_type::iterator j = i->second.begin(); j!=i->second.end(); ++j){
				if(fwd.count(*j)==0){ // assing new number at first occurence of node
					fwd[*j]=new_id; //bkwd[new_id]=*j;
					new_id++;
				}
				(*j)=fwd[*j]; //update element
			}
		}
        nodes.clear();
		// copy from nodes_in to nodes while applying new numbering
		for(node_map::iterator i = nodes_in.begin(); i!= nodes_in.end(); ++i){
			nodes[fwd[i->first]] = i->second;
		}
		// apply new numbering to bndry elements
		for(elem_map::iterator i = bndrys.begin(); i!=bndrys.end(); ++i){
			for(elem_map::mapped_type::iterator j = i->second.begin(); j!=i->second.end(); ++j){
				(*j)=fwd[*j]; //update element
			}
		}

		return elems.size();
    }