void IDefReader::processScriptItemNode( P_ITEM madeItem, QDomElement &Node )
{
	for( UI16 k = 0; k < Node.childNodes().count(); k++ )
	{
		QDomElement currChild = Node.childNodes().item( k ).toElement();
		if( currChild.nodeName() == "amount" )
		{
			QString Value = QString();
			UI16 i = 0;
			if( currChild.hasChildNodes() ) // <random> i.e.
				for( i = 0; i < currChild.childNodes().count(); i++ )
				{
					if( currChild.childNodes().item( i ).isText() )
						Value += currChild.childNodes().item( i ).toText().data();
					else if( currChild.childNodes().item( i ).isElement() )
						Value += processNode( currChild.childNodes().item( i ).toElement() );
				}
			else
				Value = currChild.nodeValue();

			if( Value.toInt() < 1 )
				Value = QString("1");

			if( madeItem->isPileable() )
				madeItem->setAmount( Value.toInt() );
			else
				for( i = 1; i < Value.toInt(); i++ ) //dupe it n-1 times
					Commands->DupeItem(-1, madeItem, 1);
		}
		else if( currChild.nodeName() == "color" ) //process <color> tags
		{
			QString Value = QString();
			if( currChild.hasChildNodes() ) // colorlist or random i.e.
				for( UI16 i = 0; i < currChild.childNodes().count(); i++ )
				{
					if( currChild.childNodes().item( i ).isText() )
						Value += currChild.childNodes().item( i ).toText().data();
					else if( currChild.childNodes().item( i ).isElement() )
						Value += processNode( currChild.childNodes().item( i ).toElement() );
				}
			else
				Value = currChild.nodeValue();
			
			if( Value.toInt() < 0 )
				Value = QString("0");

			madeItem->setColor( Value.toInt() );
		}
		else if( currChild.nodeName() == "inherit" && currChild.attributes().contains("id") )
		{
			QDomElement* derivalSection = DefManager->getSection( WPDT_ITEM, currChild.attribute("id") );
			if( !derivalSection->isNull() )
				this->applyNodes( madeItem, derivalSection );
		}
	}
}
示例#2
0
Path PathCreator::calculatePath(DebugNode* start, DebugNode* end)
{
    startNode = start;
    endNode = end;

    PathingNode* currentParentNode;
    for(processNode(start, 0, NULL), currentParentNode=processedNodes[0]; !endNodeHasLowestTEC() && openNodesRemaining(); currentParentNode = getOpenNodeWithLowestTEC())
    {
        currentParentNode->open=false;
        for(int i = 0; i<currentParentNode->node->numConnections; i++)
        {
            float connectionCostSquared = glm::pow(currentParentNode->node->connections[i]->cost, 2.0f);
            float costSoFar = connectionCostSquared + currentParentNode->costSoFar;
            processNode(currentParentNode->node->connections[i]->node, costSoFar, currentParentNode);
        }
    }
    Path p = Path(nullptr, 0);
    if(openNodesRemaining())//If the end node could actually be reached
    {
        QList <DebugNode*> reversePath;
        bool reachedStartNode = false;
        uint numNodesInPath = 0;
        PathingNode* currentNode = currentParentNode;//current parent node will be end node
        while(!reachedStartNode)
        {
            reversePath.prepend(currentNode->node);
            numNodesInPath++;
            if(currentNode->node == startNode)
            {
                reachedStartNode = true;
            }
            else
            {
                currentNode = currentNode->parentNode;
            }
        }
        DebugNode** path = new DebugNode*[numNodesInPath];
        for(uint i = 0; i<numNodesInPath; i++)
        {
            path[i] = reversePath[i];
        }
        reversePath.clear();
        p = Path(path, numNodesInPath);
    }
    else
    {
        cout << "IMPOSSIBLE PATH" << endl;
    }
    processedNodes.clear();
    return p;
}
    //-----------------------------------------------------------------------
    bool BspRaySceneQuery::processNode(const BspNode* node, const Ray& tracingRay, 
        RaySceneQueryListener* listener, Real maxDistance, Real traceDistance)
    {
        if (node->isLeaf())
        {
            return processLeaf(node, tracingRay, listener, maxDistance, traceDistance);
        }

        bool res = true;
        std::pair<bool, Real> result = tracingRay.intersects(node->getSplitPlane());
        if (result.first && result.second < maxDistance)
        {
            // Crosses the split plane, need to perform 2 queries
            // Calculate split point ray
            Vector3 splitPoint = tracingRay.getOrigin() 
                + tracingRay.getDirection() * result.second;
            Ray splitRay(splitPoint, tracingRay.getDirection());

            if (node->getSide(tracingRay.getOrigin()) == Plane::NEGATIVE_SIDE)
            {
                // Intersects from -ve side, so do back then front
                res = processNode(
                    node->getBack(), tracingRay, listener, result.second, traceDistance);
                if (!res) return res;
                
                res = processNode(
                    node->getFront(), splitRay, listener, 
                    maxDistance - result.second, 
                    traceDistance + result.second);
            }
            else
            {
                // Intersects from +ve side, so do front then back
                res = processNode(node->getFront(), tracingRay, listener, 
                    result.second, traceDistance);
                if (!res) return res;
                res = processNode(node->getBack(), splitRay, listener,
                    maxDistance - result.second, 
                    traceDistance + result.second);
            }
        }
        else
        {
            // Does not cross the splitting plane, just cascade down one side
            res = processNode(node->getNextNode(tracingRay.getOrigin()),
                tracingRay, listener, maxDistance, traceDistance);
        }

        return res;
    }
示例#4
0
文件: test1.c 项目: bobwolff68/neuron
/**
 * streamFile:
 * @filename: the file name to parse
 *
 * Parse and print information about an XML file.
 */
static void
streamFile(const char *filename) {
    xmlTextReaderPtr reader;
    int ret;
 
#define VALIDATEDTD
#ifdef VALIDATEDTD
    /*
     * Pass some special parsing options to activate DTD attribute defaulting,
     * entities substitution and DTD validation
     */
    reader = xmlReaderForFile(filename, NULL,
                 XML_PARSE_DTDATTR |  /* default DTD attributes */
		 XML_PARSE_NOENT |    /* substitute entities */
		 XML_PARSE_DTDVALID); /* validate with the DTD */
#else
    reader = xmlReaderForFile(filename, NULL, 0);
#endif
    if (reader != NULL) {
        ret = xmlTextReaderRead(reader);
        while (ret == 1) {
            processNode(reader);
            ret = xmlTextReaderRead(reader);
        }
        xmlFreeTextReader(reader);
        if (ret != 0) {
            fprintf(stderr, "%s : failed to parse\n", filename);
        }
    } else {
        fprintf(stderr, "Unable to open %s\n", filename);
    }
}
示例#5
0
int main(int argc, char *argv[])
{
    xmlTextReaderPtr reader;
    int ret;

    //  Readerの作成
    reader = xmlNewTextReaderFilename("./sample.xml");
    if ( !reader ) {
        printf("Failed to open XML file.\n");
        return 1;
    }

    printf("-----------------------\n"); 
    
    //  次のノードに移動 
    ret = xmlTextReaderRead(reader);
    while (ret == 1) {
        //  現在のノードを処理
        processNode(reader);

        //  次のノードに移動
        ret = xmlTextReaderRead(reader);
    }
    
    //  Reader のすべてのリソースを開放
    xmlFreeTextReader(reader);

    //  xmlTextReaderRead の戻り値が -1 だった場合はパースエラー
    if (ret == -1) {
        printf("Parse error.\n");
        return 1;
    }

    return 0;
}
示例#6
0
void Editor_Html2Usfm::processNode (xml_node node)
{
  switch (node.type ()) {
    case node_element:
    {
      openElementNode (node);
      for (xml_node child : node.children()) {
        processNode (child);
      }
      closeElementNode (node);
      break;
    }
    case node_pcdata:
    {
      // Add the text to the current USFM line.
      string text = node.text ().get ();
      currentLine += text;
      break;
    }
    default:
    {
      string nodename = node.name ();
      Database_Logs::log ("Unknown XML node " + nodename + " while saving editor text");
      break;
    }
  }
}
示例#7
0
int streamFileXML2(char *filename, int sanitize, struct osmdata_t *osmdata) {
    xmlTextReaderPtr reader;
    int ret = 0;

    if (sanitize)
        reader = sanitizerOpen(filename);
    else
        reader = inputUTF8(filename);

    if (reader != NULL) {
        ret = xmlTextReaderRead(reader);
        while (ret == 1) {
	  processNode(reader, osmdata);
            ret = xmlTextReaderRead(reader);
        }

        if (ret != 0) {
            fprintf(stderr, "%s : failed to parse\n", filename);
            return ret;
        }

        xmlFreeTextReader(reader);
    } else {
        fprintf(stderr, "Unable to open %s\n", filename);
        return 1;
    }
    return 0;
}
示例#8
0
void DotSceneLoader::processNodes(rapidxml::xml_node<>* XMLNode) {
	rapidxml::xml_node<>* pElement;

	// Process node (*)
	pElement = XMLNode->first_node("node");
	while (pElement) {
		processNode(pElement);
		pElement = pElement->next_sibling("node");
	}

	// Process position (?)
	pElement = XMLNode->first_node("position");
	if (pElement) {
		mAttachNode->setPosition(parseVector3(pElement));
		mAttachNode->setInitialState();
	}

	// Process rotation (?)
	pElement = XMLNode->first_node("rotation");
	if (pElement) {
		mAttachNode->setOrientation(parseQuaternion(pElement));
		mAttachNode->setInitialState();
	}

	// Process scale (?)
	pElement = XMLNode->first_node("scale");
	if (pElement) {
		mAttachNode->setScale(parseVector3(pElement));
		mAttachNode->setInitialState();
	}
}
示例#9
0
int main(int argc, char *argv[]) {
	LIBXML_TEST_VERSION

	// xmlTextReaderPtr reader = xmlReaderForFile("/run/media/svartalf/storage/wikipedia/ruwiki-20140706-pages-meta-history1.xml", NULL, 0);
	xmlTextReaderPtr reader = xmlReaderForFile("/tmp/test.xml", NULL, 0);

	FILE *output = fopen("/tmp/output.bin", "w");
	output_write_header(output);

	Revision *rev = revision_create();

	int result = xmlTextReaderRead(reader);
	while (result == 1) {
		processNode(reader, rev);
		result = xmlTextReaderRead(reader);

		if (revision_filled(rev)) {
			output_write_row(output, rev);
			revision_clear(rev);
		}

	}

	output_close(output);

	xmlFreeTextReader(reader);
	if (result != 0) {
		fprintf(stderr, "failed to parse: %d\n", result);
	}
	xmlCleanupParser();

	return 0;

}
void processNode(FbxNode *node,GameObject *rootGo)
{
	PrintTabs();
	const char* nodeName = node->GetName();
	FbxDouble3 translation =  node->LclTranslation.Get();
	FbxDouble3 rotation = node->LclRotation.Get();
	FbxDouble3 scaling = node->LclScaling.Get();

	std::cout << "Node " << nodeName << " Postion " << translation[0] << " " << translation[1] << " " << translation[2] << " "
		<< " Rotation " << rotation[0] << " " << rotation[1] << " " << rotation[2] << " "
		<< " Scale " << scaling[0] << " " << scaling[1] << " " << scaling[2] << std::endl;

	level++;
	GameObject * go = new GameObject();
	go->setTransform(new Transform());
	rootGo->addChild(go);

	// Print the node's attributes.
	for (int i = 0; i < node->GetNodeAttributeCount(); i++){
		processAttribute(node->GetNodeAttributeByIndex(i), go);
	}

	// Recursively print the children.
	for (int j = 0; j < node->GetChildCount(); j++)
		processNode(node->GetChild(j), rootGo);
	level--;
	PrintTabs();
}
示例#11
0
void fbxLoader2::processNode(FbxNode* node)
{
	//FbxNodeAttribute::EType attributeType;
	if(node->GetNodeAttribute())
	{
		switch(node->GetNodeAttribute()->GetAttributeType())
		{
		case FbxNodeAttribute::eMesh:
			processMesh(node);
			break;

		case FbxNodeAttribute::eSkeleton:
			break;

		case FbxNodeAttribute::eLight:
			break;
			
		case FbxNodeAttribute::eCamera:
			break;
		}
	}

	for(int i = 0; i<node->GetChildCount(); i++)
	{
		processNode(node->GetChild(i));
	}
}
示例#12
0
void DotSceneLoader::processNodes(TiXmlElement* xmlNode) {
	TiXmlElement *element;

	// Process node (*)
	element = xmlNode->FirstChildElement("node");
	while(element) {
		processNode(element);
		element = element->NextSiblingElement("node");
	}

	// Process position (?)
	element = xmlNode->FirstChildElement("position");
	if(element) {
		rootNode->setPosition(parseVector3(element));
	}

	// Process rotation (?)
	element = xmlNode->FirstChildElement("rotation");
	if(element) {
		rootNode->setOrientation(parseQuaternion(element));
	}

	// Process scale (?)
	element = xmlNode->FirstChildElement("scale");
	if(element) {
		rootNode->setScale(parseVector3(element));
	}
}
	void ParticleScriptCompiler::compileAffector(const ScriptNodePtr &node)
	{
		if(node->children.empty() || node->children.front()->type != SNT_WORD)
			return;

		// Create the emitter based on the first child
		ParticleAffector *affector = 0;
		String type = node->children.front()->token;
		try{
			affector = mSystem->addAffector(type);
		}catch(...){
			addError(CE_OBJECTALLOCATIONERROR, node->children.front()->file, 
				node->children.front()->line, node->children.front()->column);
			return;
		}

		// Jump ahead now to the '{' as the emitter does not support other parameters in the header
		ScriptNodeList::iterator i = findNode(node->children.begin(), node->children.end(), SNT_LBRACE);
		if(i == node->children.end())
			return;

		ScriptNodeList::iterator j = (*i)->children.begin();
		while(j != (*i)->children.end())
		{
			if(!processNode(j, (*i)->children.end()))
			{
				String name = (*j)->token, 
					value = getParameterValue((*j)->children.begin(), (*j)->children.end());
				if(!affector->setParameter(name, value))
					addError(CE_INVALIDPROPERTY, (*j)->file, (*j)->line, (*j)->column);
				++j;
			}
		}
	}
示例#14
0
文件: Assimp.cpp 项目: Inzuki/Game
bool core::ModelLoader::loadModel(const char *fp, Model *m){
	Assimp::Importer importer;

	const aiScene *scene = importer.ReadFile(fp, aiProcess_Triangulate | aiProcess_OptimizeMeshes | aiProcess_JoinIdenticalVertices | aiProcess_FlipUVs);

	if(!scene)
		return false;

	m->rootPath = (std::string)fp;
	for(int x = m->rootPath.size() - 1; x >= 0; x--){
		if(m->rootPath[x] == '/' || m->rootPath[x] == '\\'){
			m->rootPath = m->rootPath.substr(0, x + 1);
			x = -1;
		}
	}

	processAnimations(scene, m);
	processNode(scene, scene->mRootNode, m);

	if(scene->HasAnimations())
		m->animations[m->currentAnim].buildBoneTree(scene, scene->mRootNode, &m->animations[m->currentAnim].root, m);

	m->modelTrans = glm::mat4(1.f);
	m->modelLoaded = true;

	return true;
};
示例#15
0
// If it's a leaf, update the lower bound.
// Otherwise, process it.
void tryProcessNode(Knapsack* ks, Heap* h, Node* n) {
  int i;
  pthread_rwlock_rdlock(&ks->_lblock);
  int lb = ks->_lowerBound;
  pthread_rwlock_unlock(&ks->_lblock);
  if (n->_depth >= (ks->_nbItems-1)) {
    if (n->_value > (double)lb) {
      pthread_rwlock_wrlock(&ks->_lblock);
      // Double checking the value of lowerbound; there's an edge case where
      // another thread could update it between these two locks
      if (n->_value > ks->_lowerBound) {
        printf("tighten LB to %d\n", n->_value);
        ks->_lowerBound = n->_value;
        pthread_rwlock_unlock(&ks->_lblock);
        for (i=0; i<n->_depth+1; i++) {
          ks->_bestX[i] = n->_x[i];
        }
        for (i=n->_depth+1; i<ks->_nbItems; i++) {
          ks->_bestX[i] = 0;
        }
      } else {
        pthread_rwlock_unlock(&ks->_lblock);
      }
    }
    destroyNode(n);
    pthread_mutex_lock(&ks->_counterMutex);
    (ks->_nodesProcessed)++;
    pthread_mutex_unlock(&ks->_counterMutex);
  } else {
    processNode(ks, h, n);
  }
}
bool LevelGeometryLoader::processNodes(TiXmlElement *XMLNode)
{
	ASSERT(XMLNode);

    TiXmlElement *pElement;

    XMLNode = XMLNode->FirstChildElement("nodes");
    if(!XMLNode){
    	debugWARNING("No entities found in the scene\n");
    	return false;
    }

    // Process node (*)
    pElement = XMLNode->FirstChildElement("node");
    while(pElement)
    {
    	Ogre::SceneNode *node = 0;
        if(!processNode(pElement, node)){
        	debugERROR("Error processing node\n");
        	ASSERT(false);
        	return false;
        }
        pElement = pElement->NextSiblingElement("node");
        ASSERT(node);
        ASSERT(node->getAttachedObject(0)); // we have something attached
        mEntities.push_back(node);
    }

    return true;
}
示例#17
0
static void handleFile(const char *filename) {
    xmlTextReaderPtr reader;
    int ret;

    if (count) {
	elem = 0;
	attrs = 0;
    }

    reader = xmlNewTextReaderFilename(filename);
    if (reader != NULL) {
	if (valid)
	    xmlTextReaderSetParserProp(reader, XML_PARSER_VALIDATE, 1);

	/*
	 * Process all nodes in sequence
	 */
	ret = xmlTextReaderRead(reader);
	while (ret == 1) {
	    processNode(reader);
	    ret = xmlTextReaderRead(reader);
	}

	/*
	 * Done, cleanup and status
	 */
	xmlFreeTextReader(reader);
	if (ret != 0) {
	    printf("%s : failed to parse\n", filename);
	} else if (count)
	    printf("%s : %d elements, %d attributes\n", filename, elem, attrs);
    } else {
	fprintf(stderr, "Unable to open %s\n", filename);
    }
}
/**
 * streamFile:
 * @filename: the file name to parse
 *
 * Parse, validate and print information about an XML file.
 */
static void
streamFile(const char *filename) {
    xmlTextReaderPtr reader;
    int ret;


    /*
     * Pass some special parsing options to activate DTD attribute defaulting,
     * entities substitution and DTD validation
     */
    reader = xmlReaderForFile(filename, NULL,
                 XML_PARSE_DTDATTR |  /* default DTD attributes */
		 XML_PARSE_NOENT |    /* substitute entities */
		 XML_PARSE_DTDVALID); /* validate with the DTD */
    if (reader != NULL) {
        ret = xmlTextReaderRead(reader);
        while (ret == 1) {
            processNode(reader);
            ret = xmlTextReaderRead(reader);
        }
	/*
	 * Once the document has been fully parsed check the validation results
	 */
	if (xmlTextReaderIsValid(reader) != 1) {
	    fprintf(stderr, "Document %s does not validate\n", filename);
	}
        xmlFreeTextReader(reader);
        if (ret != 0) {
            fprintf(stderr, "%s : failed to parse\n", filename);
        }
    } else {
        fprintf(stderr, "Unable to open %s\n", filename);
    }
}
示例#19
0
void Model::loadModel(std::string path)
{
	// initialize importer, transform model primitives to triangles and flip texCoords y axis
	Assimp::Importer importer;
	const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs);

	if (!scene || scene->mFlags == AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
	{
		Utils::exitMessage("Assimp Error", importer.GetErrorString());
	}

	directory = path.substr(0, path.find_last_of('/'));

	processNode(scene->mRootNode, scene);

	//std::vector<Vertex> concVertices = meshes[5].vertices;
	//std::vector<GLuint> concIndices = meshes[5].indices;
	//std::vector<Texture> concTextures = meshes[5].textures;

	//concVertices.insert(concVertices.end(), meshes[6].vertices.begin(), meshes[6].vertices.end());
	//concIndices.insert(concIndices.end(), meshes[6].indices.begin(), meshes[6].indices.end());
	//concTextures.insert(concTextures.end(), meshes[6].textures.begin(), meshes[6].textures.end());

	//int offset = meshes[5].indices.size();
	//for (int i = offset; i < concIndices.size(); i++)
	//{
	//	concIndices[i] = concIndices[i] + offset;
	//}

	//Mesh(concVertices, concIndices, concTextures);
	////meshes[5] = meshes[6];
	//meshes.pop_back();
	//meshes.pop_back();
	//meshes.push_back(Mesh(concVertices, concIndices, concTextures));
}
示例#20
0
	// load model if not yet cached
	void Model::load(const std::string& path)
	{
		m_pMeshes = std::make_shared<std::vector<Mesh>>();
		m_ShaderID = ShaderLoader::Instance().getProgram("Default");
		m_MVPMatrixLocation = glGetUniformLocation(m_ShaderID, "mvpMatrix");
		m_TextureFrontSamplerLocation = glGetUniformLocation(m_ShaderID, "textureFrontSampler");
		m_TextureSideSamplerLocation = glGetUniformLocation(m_ShaderID, "textureSideSampler");			
		m_ChinVerticalPosLocation = glGetUniformLocation(m_ShaderID, "chinVerticalPos");
		m_EyeVerticalPosLocation = glGetUniformLocation(m_ShaderID, "eyeVerticalPos");
		m_LEyeTexVerticalPosLocation = glGetUniformLocation(m_ShaderID, "LEyeVerticalTexPos");
		m_REyeTexVerticalPosLocation = glGetUniformLocation(m_ShaderID, "REyeVerticalTexPos");
		m_ChinTexVerticalPosLocation = glGetUniformLocation(m_ShaderID, "ChinTexVerticalPos");

		// Create an instance of the importer class
		Assimp::Importer importer;
		// Read in the given file into a scene and set some (example) postprocessing
		const aiScene *scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_GenNormals);// | aiProcess_FlipUVs);

		if (!scene || scene->mFlags == AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
		{
			std::string error = importer.GetErrorString();
			throw std::exception("Failed to load model. ASSIMP-ERROR");
		}
		// Start processing nodes
		processNode(scene->mRootNode, scene);
	}
示例#21
0
文件: Model.cpp 项目: Dwarfius/GP2
bool Model::loadFBXFromFile(const string& fileName)
{
	//initialize the sdk manager
	FbxManager *manager = FbxManager::Create();

	//setting up the IO settings object
	FbxIOSettings *settings = FbxIOSettings::Create(manager, IOSROOT);
	manager->SetIOSettings(settings);

	//creating the importer
	FbxImporter *importer = FbxImporter::Create(manager, "");

	//initializing the importer with contents of file
	if (!importer->Initialize(fileName.c_str(), -1, settings))
		return false;

	//creating a scene to be filled with objects
	FbxScene *scene = FbxScene::Create(manager, "myScene");
	importer->Import(scene);

	FbxGeometryConverter geomConverter(manager);
	geomConverter.Triangulate(scene, true);

	FbxNode *root = scene->GetRootNode();
	if (root)
	{
		//printf("Root Node: %s\n", root->GetName());
		int childCount = root->GetChildCount();
		for (int i = 0; i < childCount; i++)
			processNode(root->GetChild(i), 1);
	}
	importer->Destroy();
	return true;
}
示例#22
0
int Model::processNode(FbxNode *node, int level, Data &model) {
  const char* nodeName = node->GetName();
  FbxDouble3 translation = node->LclTranslation.Get();
  FbxDouble3 rotation = node->LclRotation.Get();
  FbxDouble3 scaling = node->LclScaling.Get();

  LOG(INFO) << "Node " << nodeName << " Postion " << translation[0] << " " << translation[1] << " " << translation[2] << " "
    << " Rotation " << rotation[0] << " " << rotation[1] << " " << rotation[2] << " "
    << " Scale " << scaling[0] << " " << scaling[1] << " " << scaling[2];

  level++;

  model.model.push_back(new Data());

  // Print the node's attributes.
  for (int i = 0; i < node->GetNodeAttributeCount(); i++) {
    processAttribute(node->GetNodeAttributeByIndex(i), level, model);
  }

  // Recursively print the children.
  for (int j = 0; j < node->GetChildCount(); j++)
    processNode(node->GetChild(j), level, model);
  level--;

  return level;
}
示例#23
0
void Editor_Export::processNodeChildren (xmlNodePtr node)
{
  node = node->xmlChildrenNode;
  while (node != NULL) {
    processNode (node);
    node = node->next;
  }
}
示例#24
0
void Editor_Export::processNoteCitation (xmlNodePtr node)
{
  // Remove the note citation from the text.
  xmlNodePtr child = node->xmlChildrenNode;
  while (child != NULL) {
    xmlNodePtr cache = child;
    child = child->next;
    xmlUnlinkNode (cache);
    xmlFree (cache);
  }
  
  // Get more information about the footnote to retrieve.
  string href;
  string id;
  xmlChar * property = xmlGetProp (node, BAD_CAST "href");
  if (property) {
    href = (char *) property;
    xmlFree (property);
    id = href.substr (1);
  }
  
  // Sample footnote body.
  // <p class="x"><a href="#citation1" id="note1">x</a><span> </span><span>+ 2 Joh. 1.1</span></p>
  // Retrieve the <a> element from it.
  // At first this was done through an XPath expression: 
  // http://www.grinninglizard.com/tinyxml2docs/index.html
  // But XPath crashes on Android.
  // Therefore now it iterates of all the nodes to find the required <a> element.
  xmlNodePtr aElement = get_note_pointer (xmlDocGetRootElement (document), id);
  if (aElement) {

    // It now has the 'a' element: Get its 'p' parent, and then remove that 'a' element.
    // So we remain with:
    // <p class="x"><span> </span><span>+ 2 Joh. 1.1</span></p>
    xmlNodePtr pElement = aElement->parent;
    xmlUnlinkNode (aElement);
    xmlFree (aElement);
    
    // Preserve active character styles in the main text, and reset them for the note.
    vector <string> preservedCharacterStyles = characterStyles;
    characterStyles.clear();
    
    // Process this 'p' element.
    processingNote = true;
    processNode (pElement);
    processingNote = false;
    
    // Restore the active character styles for the main text.
    characterStyles = preservedCharacterStyles;
    
    // Remove this element so it can't be processed again.
    xmlUnlinkNode (pElement);
    xmlFree (pElement);
    
  } else {
    Database_Logs::log ("Discarding note with id " + id + " and href " + href);
  }
}
示例#25
0
文件: Assimp.cpp 项目: Inzuki/Game
void core::ModelLoader::processNode(const aiScene *scene, aiNode *node, Model *m){
	if(node->mNumMeshes > 0)
		for(unsigned int x = 0; x < node->mNumMeshes; x++)
			processMesh(scene, node, scene->mMeshes[node->mMeshes[x]], m);

	if(node->mNumChildren > 0)
		for(unsigned int x = 0; x < node->mNumChildren; x++)
			processNode(scene, node->mChildren[x], m);
};
示例#26
0
void Model::loadModel(const std::string &path) {
    Assimp::Importer import;
    const aiScene* scene = import.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs);
    if(not scene or scene->mFlags == AI_SCENE_FLAGS_INCOMPLETE or not scene->mRootNode) {
        std::cerr << "ERROR::ASSIMP::" << import.GetErrorString() << std::endl;
        return;
    }
    directory = path.substr(0, path.find_last_of('/'));
    processNode(scene->mRootNode, scene);
}
	void parsePreorder(TreeNode *node)
	{
		if( node != nullptr )
		{
			processNode( node );
			parsePreorder(node->left);
			parsePreorder(node->right);
		}

	}
示例#28
0
int LocalFileMng::readXmlInt( QDomNode node , const QString& nodeName, int defaultValue, bool bCanBeEmpty, bool bShouldExists, bool tinyXmlCompatMode)
{
	QString text = processNode( node, nodeName, bCanBeEmpty, bShouldExists );
	if ( text == NULL ) {
		_WARNINGLOG( QString( "\tusing default value : '%1' for node '%2'" ).arg( defaultValue ).arg( nodeName ));
		return defaultValue;
	} else {
		return QLocale::c().toInt( text );
	}
}
示例#29
0
void ModelLoader::loadModel(std::string path) {
	const aiScene *scene = import.ReadFile(path, aiProcess_FlipUVs);

	if (!scene || (scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE) || !scene->mRootNode) {
		std::cout << "ERROR::ASSIMP::" << import.GetErrorString() << std::endl;
		return;
	}

	processNode(scene->mRootNode, scene);
}
    //-----------------------------------------------------------------------
    void BspRaySceneQuery::execute(RaySceneQueryListener* listener)
    {
        clearTemporaries();
		BspLevelPtr lvl = static_cast<BspSceneManager*>(mParentSceneMgr)->getLevel();
		if (!lvl.isNull())
		{
			processNode(
				lvl->getRootNode(), 
				mRay, listener);
		}
    }