コード例 #1
0
ファイル: SceneFileLoader.cpp プロジェクト: Neilfy/OgreSimple
	void SceneFileLoader::loadFile(string path)
	{
		try
		{

			//创建一个XML的文档对象。
			TiXmlDocument *myDocument = new TiXmlDocument(path.c_str());
			myDocument->LoadFile();
			//获得根元素,即Persons。
			TiXmlElement *RootElement = myDocument->RootElement();

			string val = RootElement->Value();
			if (RootElement && val == "Nodes")
			{
				readNodes(RootElement,m_Nodes);
			}

			createEntitys(m_Nodes);

			delete myDocument;

		}
		catch (string& e)
		{

		}
	}
コード例 #2
0
ファイル: dictionary.cpp プロジェクト: kuhumcst/cstlemma
bool dictionary::initdict(FILE * fpin)
    {
    if(fpin)
        {
        return readStrings(fpin) && readLeaves(fpin) && readNodes(fpin);
        }
    return false;
    }
コード例 #3
0
ファイル: api.c プロジェクト: Osterjour/51degrees.node
// Reads the input file into memory returning 1 if it
// was read unsuccessfully, otherwise 0.
DataSetInitStatus readFile(char* fileName) {
    DataSetInitStatus status = DATA_SET_INIT_STATUS_SUCCESS;

	FILE *inputFilePtr;

	// Open the file and hold on to the pointer.
	inputFilePtr = fopen(fileName, "rb");

	// If the file didn't open return -1.
	if (inputFilePtr == NULL) {
        return DATA_SET_INIT_STATUS_FILE_NOT_FOUND;
	}
	// Read the various data segments if the version is
	// one we can read.
    status = readVersion(inputFilePtr);
    if (status != DATA_SET_INIT_STATUS_SUCCESS) {
        fclose(inputFilePtr);
        return status;
    }
	status = readCopyright(inputFilePtr);
	if (status != DATA_SET_INIT_STATUS_SUCCESS) {
        fclose(inputFilePtr);
        return status;
	}
	status = readStrings(inputFilePtr);
	if (status != DATA_SET_INIT_STATUS_SUCCESS) {
        fclose(inputFilePtr);
        return status;
	}
    status = readProperties(inputFilePtr);
    if (status != DATA_SET_INIT_STATUS_SUCCESS) {
        fclose(inputFilePtr);
        return status;
    }
    status = readDevices(inputFilePtr);
    if (status != DATA_SET_INIT_STATUS_SUCCESS) {
        fclose(inputFilePtr);
        return status;
    }
    status = readLookupList(inputFilePtr);
    if (status != DATA_SET_INIT_STATUS_SUCCESS) {

        fclose(inputFilePtr);
        return status;
    }
	status = readNodes(inputFilePtr);
	if (status != DATA_SET_INIT_STATUS_SUCCESS) {
        fclose(inputFilePtr);
        return status;
    }
	fclose(inputFilePtr);

	return status;
}
コード例 #4
0
ファイル: NAmigaHunkDecoder.cpp プロジェクト: laulandne/src
bool NAmigaHunkDecoder::decodeNodes()
{
#ifdef DEBUG_VERBOSE
  DEBUG_OUT<<"Amiga decodeNodes...\n";
#endif // DEBUG_VERBOSE
  if(!checkSanity()) return false;
  offset=0;
  numHunks=0;
  nextHunk=0;
  readHeader();
  readNodes();
  return true;
}
コード例 #5
0
ファイル: pathfinder.cpp プロジェクト: ej2xu/cs106b
string loadGraphFile(Graph &graph, Map<coordT> &m) {
	ifstream in;
	promptUserForFile(in);
	InitGraphics();
	string image = drawBackGround(in);
	string token;
	in >> token;
	if (token == "NODES") readNodes(in, graph, m);
	else Error("File format error."); 
	readArcs(in, graph);
	in.close();
	return image;
}
コード例 #6
0
bool GraphModelXmlReader::read(QIODevice &in)
{
    auto *m_graphModel = dynamic_cast<GraphModel*>(m_model);
    if(!m_graphModel) {
        return false;
    }

    QXmlStreamReader stream(&in);

    stream.readNextStartElement();
    {
        readProperties(stream);
        readNodes(stream);
        readEdges(stream);
    }

    return true;
}
コード例 #7
0
ファイル: SceneFileLoader.cpp プロジェクト: Neilfy/OgreSimple
	void SceneFileLoader::readNode(TiXmlElement* Node, vector<NODE>& container)
	{
		string val;
		NODE info;
		TiXmlElement* subNode=0;
		info.name = Node->Attribute("name");
		string type = Node->Attribute("type");
		if(type == "model")
			info.type = 1;
		else if(type == "box")
			info.type = 2;

		for( subNode = Node->FirstChildElement(); subNode; subNode = subNode->NextSiblingElement() )
		{
			val = subNode->Value();
			if (val == "Mesh")
			{
				info.mesh = subNode->FirstChild()->Value();
			}

			if (val == "Position")
			{
				string pos = subNode->FirstChild()->Value();
				vector<string> vecOut;
				splitString(pos, ",", vecOut);
				info.position.x = parseFloat(vecOut[0]);
				info.position.y = parseFloat(vecOut[1]);
				info.position.z = parseFloat(vecOut[2]);
			}

			if (val == "Scale")
			{
				string scale = subNode->FirstChild()->Value();
				vector<string> vecOut;
				splitString(scale, ",", vecOut);
				info.scale.x = parseFloat(vecOut[0]);
				info.scale.y = parseFloat(vecOut[1]);
				info.scale.z = parseFloat(vecOut[2]);
			}

			if (val == "size")
			{
				string pos = subNode->FirstChild()->Value();
				vector<string> vecOut;
				splitString(pos, ",", vecOut);
				info.size.x = parseFloat(vecOut[0]);
				info.size.y = parseFloat(vecOut[1]);
				info.size.z = parseFloat(vecOut[2]);
			}

			if (val == "texture")
			{
				info.texture = subNode->FirstChild()->Value();
			}

			if (val == "Nodes")
			{
				readNodes(subNode,info.nodes);
			}
		}

		container.push_back(info);
	}
コード例 #8
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();
    }