Beispiel #1
0
Rule::Rule(TiXmlElement* rule, DHPrefs* dhp)
	:datahandlingpreferences(dhp)
{
	effect = (rule->Attribute("effect") != NULL) ? string2effect(rule->Attribute("effect")) : UNDETERMINED;
	if(rule->FirstChild("condition")){
		condition = new Condition((TiXmlElement*)rule->FirstChild("condition"));
	}
	else
		condition = NULL;
		
	//init datahandlingpreferences
	for(TiXmlElement * child = static_cast<TiXmlElement*>(rule->FirstChild(dhPrefTag)); child;
			child = static_cast<TiXmlElement*>(child->NextSibling(dhPrefTag)) ) {
		LOGD("Rule: DHPref %s found", child->Attribute(policyIdTag.c_str()));
		(*dhp)[child->Attribute(policyIdTag.c_str())]=new DataHandlingPreferences(child);
	}
	LOGD("Rule DHPref number: %d", (*dhp).size());

	//init ProvisionalActions
	for(TiXmlElement * child = static_cast<TiXmlElement*>(rule->FirstChild(provisionalActionsTag)); child;
			child = static_cast<TiXmlElement*>(child->NextSibling(provisionalActionsTag)) ) {
		LOGD("Rule: ProvisionalActions found");
		provisionalactions.push_back(new ProvisionalActions(child));
	}
}
Beispiel #2
0
int xmlFile::GetChildList(wxArrayString& arrStr)
{
    arrStr.Clear();

    if(!m_pWorkingElement)
        return -1;

    TiXmlElement* elem = (TiXmlElement*)m_pWorkingElement->FirstChild();
    while(elem)
    {
        wxString name = cbC2U(elem->Value());
        if(!name.IsEmpty())  //Root??
        {
            if(elem->Attribute("alt_title"))
            {
                name = cbC2U(elem->Attribute("alt_title"));
                name.Replace(_T("\""), _T(""));
            }

            if(!name.IsEmpty())
                arrStr.Add(name);
        }
        elem = (TiXmlElement*)elem->NextSibling();
    }

    return arrStr.GetCount();
}
AuthorizationsSet::AuthorizationsSet(TiXmlElement* authorizationsset){

	// AuthzUseForPurpose Tag
	if (authorizationsset->FirstChild(authzTag)) {
		LOGD("AuthorizationsSet constructor, AuthzUseForPurpose found");
		TiXmlElement * child = static_cast<TiXmlElement*>(authorizationsset->FirstChild(authzTag));
		for(child = static_cast<TiXmlElement*>(child->FirstChild(purposeTag)); child; 
				child = static_cast<TiXmlElement*>(child->NextSibling(purposeTag))) {
			if (child->GetText()) {
				LOGD("Purpose %s found", child->GetText());
				authzuseforpurpose.push_back(child->GetText());
			}
			else {
				LOGD("Empty purpose tag, all purposes allowed");
				authzuseforpurpose.clear();
				for (unsigned int i = 0; i < arraysize(ontology_vector); i++) {
					authzuseforpurpose.push_back(ontology_vector[i]);
				}
				break;
			}
		}
	}
	else{
		LOGD("AuthorizationsSet constructor, AuthzUseForPurpose not found");
	}
}
Beispiel #4
0
Subject::Subject(TiXmlElement* subject){
	for(TiXmlElement * child = (TiXmlElement*)subject->FirstChild("subject-match"); child;
			child = (TiXmlElement*)child->NextSibling() ) {
		
		string tmp = (child->Attribute("match")!=NULL) ? child->Attribute ("match") : "";
		if (tmp.length() == 0)
			tmp = (child->GetText() != NULL) ? child->GetText() : "";
		
		int nextPos, pos = 0;
		while(pos < (int)tmp.length())
		{
			//nextPos = tmp.find(" ",pos);
			//if (nextPos == (int)string::npos)
			nextPos = tmp.length();			
			if(pos != nextPos){
				string attr = child->Attribute("attr");
				int dot_pos = attr.find(".");
				string key = (dot_pos != (int)string::npos) ? attr.substr(0, dot_pos) : attr;
				match_info_str * tmp_info = new match_info_str();
				tmp_info->equal_func = (child->Attribute("func")!=NULL) ? child->Attribute("func") : "glob";
				tmp_info->value = tmp.substr(pos, nextPos-pos);
				
				tmp_info->mod_func = (dot_pos != (int)string::npos) ? attr.substr(dot_pos+1) : "";
				LOGD("subject() %d - equal_func=%s, value=%s, mod_func=%s", pos, tmp_info->equal_func.data(), tmp_info->value.data(), tmp_info->mod_func.data());
				info[key].push_back(tmp_info);
			}
			pos = nextPos+1;
		}
	}
	LOGD("[Subject]  : subjects-match size : %d",info.size());
}
Policy::Policy(TiXmlElement* policy) : IPolicyBase(policy){
	iType = POLICY;
	ruleCombiningAlgorithm = (policy->Attribute("combine")!=NULL) ? policy->Attribute("combine") : deny_overrides_algorithm;
	//init subjects
	TiXmlNode * target = policy->FirstChild("target");
	if(target){
		for(TiXmlElement * child = (TiXmlElement*)target->FirstChild("subject"); child;
				child = (TiXmlElement*)child->NextSibling() ) {
			subjects.push_back(new Subject(child));
		}
	}
		
	
	// init rules
	for(TiXmlElement * child = (TiXmlElement*)policy->FirstChild("rule"); child;
			child = (TiXmlElement*)child->NextSibling("rule")) {
		rules.push_back(new Rule(child));
	}
	
	LOGD("[Policy]  : subjects size : %d",subjects.size());
	LOGD("[Policy]  : rules size : %d",rules.size());
}
void GPUImageFilter::parseXML(const char* fname){
	//load filter description file
	printf("Loading Filter...\n");


	//load and parse xml filter description file
	TiXmlDocument doc(ofToDataPath(fname).c_str());
	if (!doc.LoadFile()) printf("error loading filter description file");


	//get the name of the filter
	TiXmlElement* root_node = doc.RootElement();

	this->name = root_node->Attribute("name");

	printf("Filter Name:%s\n", this->name);


	//get the  shader source file names
	TiXmlElement* node = root_node;

	node = root_node->FirstChildElement("VertexShader");
	const char* vertSrc = node ? node->GetText() : NULL;

	node = root_node->FirstChildElement("GeometryShader");
	const char* geomSrc = node ? node->GetText() : NULL;
	if (geomSrc != NULL){ //We are using a geometry shader
		this->useGeometryShader = true;
	}

	node = root_node->FirstChildElement("FragmentShader");
	const char* fragSrc = node ? node->GetText() : NULL;

    this->shader = new ShaderProgram(vertSrc, geomSrc, ofToDataPath(fragSrc).c_str());


	//get parameters
	//TODO: add type handling
	while( (node = (TiXmlElement*)node->NextSibling("Parameter")) ){
		const char* name = node->Attribute("name");
		float type = atof(node->Attribute("type"));
		float min = atof(node->Attribute("min"));
		float max = atof(node->Attribute("max"));
		float val = atof(node->GetText());


		parameters["size_cx"] = new FilterParameter("size_cx", (float)res_x, 0, 0, 0 );
		parameters["size_cy"] = new FilterParameter("size_cy", (float)res_y, 0, 0, 0 );
		parameters[std::string(name)] = new FilterParameter(name, val, min, max, (int)type );
	}
}
ProvisionalAction::ProvisionalAction(TiXmlElement* provisionalaction){

	// AttributeValue Tags
	TiXmlElement * child = static_cast<TiXmlElement*>(provisionalaction->FirstChild(attributeValueTag));
	if (child) {
		value1 = child->GetText();
	}
	child = static_cast<TiXmlElement*>(child->NextSibling(attributeValueTag));
	if (child) {
		value2 = child->GetText();
	}
	if (value1.empty() == false && value2.empty() == false) {
		LOGD("ProvisionalAction constructor, attribute values: %s, %s", value1.c_str(), value2.c_str());
	}
	else {
		LOGD("Invalid ProvisionalAction");
	}
}
Beispiel #8
0
bool GameScreen::loadLevel(int level){
	// This function is pretty hardcoded, meaning that an inproperly declared level will probably crash the program. Can be fixed by a LOT of null-checks making this function at least twice as long. Sort of TODO
	// In essence, the function parses through an XML document and loads all elements from it.
	// For specification of XML document, see documentation outside of code.
	screenManager->LogEvent("Load New Level");
	std::stringstream ss;
	// We load a specific traininglevel if training, the level with the corresponding number otherwise.
	if (trainingMode)
		ss << "Resources/game/Levels/BILevelTraining.xml";
	else
		ss << "Resources/game/Levels/BILevel" << level << ".xml";
	TiXmlDocument doc(ss.str().c_str());
	// Try to load the level.
	if(doc.LoadFile()){
		screenManager->LogEvent(ss.str());
		currentLevel = level;
		TiXmlElement* currentElement = doc.FirstChild("Level")->FirstChild("TotalBlocks")->ToElement();
		// We need the number of blocks for parsing purposes
		int numOfBlocks = atoi(currentElement->GetText());
		// Load in level settings (mostly speed related)
		double startSpeed = strtod(currentElement->NextSibling("StepSpeed")->ToElement()->GetText(),NULL);
		double speedIncrease = strtod(currentElement->NextSibling("SpeedIncrease")->ToElement()->GetText(),NULL);
		double maxSpeed = strtod(currentElement->NextSibling("MaxSpeed")->ToElement()->GetText(),NULL);
		// Process each block.
		for (int i = 0; i < numOfBlocks && i < MAXBLOCKS; i++){
			currentElement = currentElement->NextSibling("Block")->ToElement();
			TiXmlElement* blockElement = currentElement->FirstChild("TotalAliens")->ToElement();
			// We need to know how many aliens we will encounter.
			int totalAliens = atoi(blockElement->GetText());

			// Construct the path for this block
			TiXmlElement * pathElement = blockElement->NextSibling("Path")->FirstChild("NumOfSteps")->ToElement();
			
			// Lets keep track of the path length.
			int pathLength = atoi(pathElement->GetText());
			
			int path[MAXPATHSIZE][2];
			// Contruct the Path
			for(int j = 0; j < MAXPATHSIZE; j++){
				// If we're still within path length, then there must be a step in the XML which we can parse.
				if (j < pathLength){
					pathElement = pathElement->NextSibling("Step")->ToElement();
					path[j][0] = atoi(pathElement->FirstChild("X")->ToElement()->GetText());
					path[j][1] = atoi(pathElement->FirstChild("Y")->ToElement()->GetText());
				}
				else{
					path[j][0] = -1;
					path[j][1] = -1;
				}
			}
			// Construct block
			alienBlocks[i] = new AlienBlock(sceneManager, path, startSpeed, speedIncrease, maxSpeed);

			// Load each Alien
			for(int j = 0; j < totalAliens; j++){
				blockElement = blockElement->NextSibling("Alien")->ToElement();

				// Get info about the Alien.
				string name = blockElement->FirstChild("Name")->ToElement()->GetText();
				int relX = atoi(blockElement->FirstChild("RelPos")->FirstChild("X")->ToElement()->GetText());
				int relY = atoi(blockElement->FirstChild("RelPos")->FirstChild("Y")->ToElement()->GetText());

				int matX = atoi(blockElement->FirstChild("MatPos")->FirstChild("X")->ToElement()->GetText());
				int matY = atoi(blockElement->FirstChild("MatPos")->FirstChild("Y")->ToElement()->GetText());

				int type = atoi(blockElement->FirstChild("Type")->ToElement()->GetText());

				// Construct Alien from info.
				Alien *alien = new Alien(sceneManager, name, type);
				// Add the Alien to the currently parsed block.
				alienBlocks[i]->addAlien(alien, relX, relY);
				// Also keep the Alien in a seperate matrix for flashing purposes.
				alienMatrix[matX][matY] = alien;
			}
		}
		// Suffling the matrix to ensure random flashing and such.
		ShuffleMatrix();
		isLoading = false;
		// Start a new repetition cycle.
		repetition = 0;
		m_bResetTabP300 = true;
		maxRepetitions = 8;
		progressBar->reset(maxRepetitions);
		currentState = BlackScreen;
		return true;
	}
	else{
		return false;
	}
}
Beispiel #9
0
void dModel::LoadXML (const char* name, dLoaderContext& context)
{
	_ASSERTE (0);

	const TiXmlElement* root;
	TiXmlDocument doc (name);
	doc.LoadFile();

	char path[256];
	char* tmpName;
	strcpy (path, name);
	tmpName = strrchr (path, '/');
	if (!tmpName) {
		tmpName = strrchr (path, '\\');
	} 
	if (tmpName) {
		tmpName[0] = 0;
	}

	root = doc.RootElement();
	
	for (TiXmlElement* skeleton = (TiXmlElement*)root->FirstChildElement ("skeleton"); skeleton; skeleton = (TiXmlElement*)root->NextSibling ("skeleton")) {
		char pathName[256];
		ModelComponent<dList<dBone*> >& data = m_skeleton.Append()->GetInfo();
		strncpy (data.m_name, skeleton->GetText(), sizeof (data.m_name) - 1);

		strcpy (pathName, path);
		strcat (pathName, "/");
		strcat (pathName, data.m_name);
		dBone::Load (pathName, data.m_data, context);
	}

	for (TiXmlElement* meshes = (TiXmlElement*)root->FirstChildElement ("mesh"); meshes; meshes = (TiXmlElement*)root->NextSibling ("mesh")) {
		char pathName[256];
		ModelComponent<dList<dMeshInstance> >& data = m_meshList.Append()->GetInfo();

		strncpy (data.m_name, meshes->GetText(), sizeof (data.m_name) - 1);
		strcpy (pathName, path);
		strcat (pathName, "/");
		strcat (pathName, data.m_name);
		dMesh::LoadXML (pathName, data.m_data, context);
	}

	for (ModelComponentList<dList<dMeshInstance> >::dListNode* list = m_meshList.GetFirst(); list; list = list->GetNext()) {
		for (dList<dMeshInstance>::dListNode* node = list->GetInfo().m_data.GetFirst(); node; node = node->GetNext()) { 
			_ASSERTE (0);
//			if (node->GetInfo()->GetType() == dMesh::D_SKIN_MESH) {
//				node->GetInfo()->m_weighList->SetBindingPose(node->GetInfo(), *this); 
//			}
		}
	}

	for (TiXmlElement* anim = (TiXmlElement*)root->FirstChildElement("animation"); anim; anim = (TiXmlElement*)anim->NextSibling("animation")) {
		char pathName[256];
		ModelComponent<dAnimationClip*>& data = m_animations.Append()->GetInfo();

		strncpy (data.m_name, anim->GetText(), sizeof (data.m_name) - 1);
		strcpy (pathName, path);
		strcat (pathName, "/");
		strcat (pathName, data.m_name);
		
		data.m_data = new dAnimationClip ();
		data.m_data->LoadXML (pathName);
	}

	context.LoaderFixup (this);
}
Beispiel #10
0
static void updateConfigs()
{
    TiXmlElement* element = NULL;
    TiXmlNode *node = NULL;
    TiXmlNode *inside = NULL;

    TiXmlDocument doc("cac_config.xml");
    doc.LoadFile();
    
    if (doc.Error() && doc.ErrorId() == TiXmlBase::TIXML_ERROR_OPENING_FILE)
    {
        LOG_ERROR << "ERROR";
        return;
    }

    LOG_INFO << "aaa"; 
    node = doc.FirstChild("configs");   
    LOG_INFO << "bbb";
    if ((NULL == node) || !(element = node->ToElement()))
    {
        LOG_ERROR << "Parse config file error.";
        return;
    }

    LOG_INFO << "ccc";
    inside = element->FirstChild("item");
    
    while (inside)
    {
        LOG_INFO << "ddd";
        TiXmlElement *tmpElement = inside->ToElement();
        if (NULL == tmpElement)
        {
            LOG_WARN << "Bad config item";
            inside = element->NextSibling();
            continue;
        }

        string itemName(tmpElement->Attribute("name"));
        string itemValue(tmpElement->Attribute("value"));

        if ("local_ip" == itemName)
        {
            localIP_ = itemValue;
        }
        else if ("proxy_ip" == itemName)
        {
            proxyIP_ = itemValue;
        }
        else if ("proxy_port" == itemName)
        {
            uint16_t tmpProxyPort;
            try
            {
                tmpProxyPort = boost::lexical_cast<uint16_t>(itemValue);
                proxyPort_ = tmpProxyPort; 
            }
            catch (boost::bad_lexical_cast& e)
            {
                LOG_WARN << "Parse item fail.";
            }
        }
        else if ("system_tick" == itemName)
        {
            uint16_t tmpSystemTick;

            try 
            {
                tmpSystemTick = boost::lexical_cast<uint16_t>(itemValue);
 
                systemTick_ = tmpSystemTick;
            }
            catch (boost::bad_lexical_cast& e)
            {
                LOG_WARN << "Parse item fail.";
            }
        }
        else if ("heartbeat_tick" == itemName)
        {
            uint32_t tmpHeartbeatTick;

            try
            {
                tmpHeartbeatTick = boost::lexical_cast<uint32_t>(itemValue);
                
                heartBeatTick_ = tmpHeartbeatTick;
            }
            catch (boost::bad_lexical_cast& e)
            {
                LOG_WARN << "Parse item fail.";
            }
        }
        else if ("uploadmonidata_tick" == itemName)
        {
            uint32_t tmpUploadMoniDataTick;

            try
            {
                tmpUploadMoniDataTick = boost::lexical_cast<uint32_t>(itemValue);
 
                uploadMoniDataTick_ = tmpUploadMoniDataTick;
            }
            catch (boost::bad_lexical_cast& e)
            {
                LOG_WARN << "Parse item fail.";
            }
        }
        else if ("db_path" == itemName)
        {
            dbPath_ = itemValue;
        }
        else if ("db_user" == itemName)
        {
            dbUser_ = itemValue;
        }
        else if ("db_passwd" == itemName)
        {
            dbPasswd_ = itemValue;
        }
        else if ("db_name" == itemName)
        {
            dbName_ = itemValue;
        }
        else if ("cacid" == itemName)
        {
            cacid_ = itemValue;
        }
        else if ("last_upload" == itemName)
        {
            uint64_t tmpLastUpload;

            try
            {
                lastUploadTime_ = boost::lexical_cast<uint64_t>(itemValue);
                lastUploadTime_ = tmpLastUpload;
            }
            catch (boost::bad_lexical_cast& e)
            {
                LOG_WARN << "Parse item fail.";
            }
        }
        else
        {
            LOG_WARN << "Unknown config item found.";
            node = element->NextSibling();
            continue;
        }

        inside = element->NextSibling();
    }
}
Beispiel #11
0
bool TransFunc1DKeys::loadOsirixCLUT(const std::string& filename) {
    LINFO("Opening Osirix CLUT: " << filename);

    TiXmlDocument doc(filename.c_str());

    //TODO: this loader is much to specific to a certain order of XML tags and will crash if
    // anything is missing (#276).
    if (doc.LoadFile()) {
        // read and check version of plist file
        TiXmlNode* currNode = doc.FirstChild("plist");
        TiXmlElement* currElement = currNode->ToElement();

        currNode = currNode->FirstChild("dict");
        currNode = currNode->FirstChild("key");
        currElement = currNode->ToElement();

        // get reference to red, green and blue channel
        TiXmlElement* blueElement = 0;
        TiXmlElement* greenElement = 0;
        TiXmlElement* redElement = 0;
        TiXmlNode* blueNode = currElement->NextSibling();
        TiXmlNode* greenNode = ((blueNode->NextSibling())->NextSibling());
        TiXmlNode* redNode = ((greenNode->NextSibling())->NextSibling());
        blueNode = blueNode->FirstChild("integer");
        greenNode = greenNode->FirstChild("integer");
        redNode = redNode->FirstChild("integer");

        unsigned char* data = new unsigned char[256*4];

        for (int i = 0; i < 256; ++i) {
            data[4*i + 0] = 0;
            data[4*i + 1] = 0;
            data[4*i + 2] = 0;
            data[4*i + 3] = 0;

            blueNode = blueNode->NextSibling("integer");
            greenNode = greenNode->NextSibling("integer");
            redNode = redNode->NextSibling("integer");

            if (blueNode == 0 || greenNode == 0 || redNode == 0)
                continue;

            blueElement = blueNode->ToElement();
            greenElement = greenNode->ToElement();
            redElement = redNode->ToElement();

            data[4*i + 0] = atoi(redElement->GetText());
            data[4*i + 1] = atoi(greenElement->GetText());
            data[4*i + 2] = atoi(blueElement->GetText());
            data[4*i + 3] = (char)(255);
        }

        dimensions_ = tgt::ivec3(256, 1, 1);
        generateKeys(data);
        delete[] data;

        return true;
    }
    else
        return false;
}
TriggersSet::TriggersSet(TiXmlElement* triggersset){

	string purposes;
	while (purposes.size() < arraysize(ontology_vector))
		purposes.append("0");

	// Trigger Tag

	// TriggerAtTime
	if(triggersset->FirstChild(triggerAtTimeTag)){
		for(TiXmlElement * child = static_cast<TiXmlElement*>(triggersset->FirstChild(triggerAtTimeTag)); child;
				child = static_cast<TiXmlElement*>(child->NextSibling(triggerAtTimeTag)) ) {
			trigger[triggerIdTag] = triggerAtTimeTag;

			// read Start parameter
			TiXmlElement * start = static_cast<TiXmlElement*>(child->FirstChild(startTag));
			if (static_cast<TiXmlElement*>(start->FirstChild(startNowTag)))
				trigger[startTag]=startNowTag;
			if (static_cast<TiXmlElement*>(start->FirstChild(dateAndTimeTag)))
				trigger[startTag]=(static_cast<TiXmlElement*>(start->FirstChild(dateAndTimeTag)))->GetText();

			// read MaxDelay parameter
			TiXmlElement * maxdelay = static_cast<TiXmlElement*>(child->FirstChild(maxDelayTag));
			trigger[maxDelayTag]=(static_cast<TiXmlElement*>(maxdelay->FirstChild(durationTag)))->GetText();
			
			triggers.push_back(trigger);
			trigger.clear();
		}
	}

	// TriggerPersonalDataAccessedForPurpose
	if(triggersset->FirstChild(triggerPersonalDataAccessedTag)){
		for(TiXmlElement * child = static_cast<TiXmlElement*>(triggersset->FirstChild(triggerPersonalDataAccessedTag)); child;
				child = static_cast<TiXmlElement*>(child->NextSibling(triggerPersonalDataAccessedTag)) ) {
			trigger[triggerIdTag] = triggerPersonalDataAccessedTag;

			// read Purpose parameters
			for(TiXmlElement * purpose = static_cast<TiXmlElement*>(child->FirstChild(purposeTag)); purpose;
					purpose = static_cast<TiXmlElement*>(child->NextSibling(purposeTag)) ) {
				string p = (static_cast<TiXmlElement*>(child->FirstChild(purposeTag)))->GetText();
				for(unsigned int i = 0; i<arraysize(ontology_vector); i++) {
					if (p.compare(ontology_vector[i]) == 0)
						purposes[i]='1';
				}
			}
			trigger[purposeTag]=purposes;
			for(unsigned int i=0; i<arraysize(ontology_vector); i++)
				purposes[i]='0';

			// read MaxDelay parameter
			TiXmlElement * maxdelay = static_cast<TiXmlElement*>(child->FirstChild(maxDelayTag));
			trigger[maxDelayTag]=(static_cast<TiXmlElement*>(maxdelay->FirstChild(durationTag)))->GetText();
			
			triggers.push_back(trigger);
			trigger.clear();
		}
	}

	// TriggerPersonalDataDeleted
	if(triggersset->FirstChild(triggerPersonalDataDeletedTag)){
		for(TiXmlElement * child = static_cast<TiXmlElement*>(triggersset->FirstChild(triggerPersonalDataDeletedTag)); child;
				child = static_cast<TiXmlElement*>(child->NextSibling(triggerPersonalDataDeletedTag)) ) {
			trigger[triggerIdTag] = triggerPersonalDataDeletedTag;

			// read MaxDelay parameter
			TiXmlElement * maxdelay = static_cast<TiXmlElement*>(child->FirstChild(maxDelayTag));
			trigger[maxDelayTag]=(static_cast<TiXmlElement*>(maxdelay->FirstChild(durationTag)))->GetText();
			
			triggers.push_back(trigger);
			trigger.clear();
		}
	}

	// TriggerDataSubjectAccess
	if(triggersset->FirstChild(triggerDataSubjectAccessTag)){
		for(TiXmlElement * child = static_cast<TiXmlElement*>(triggersset->FirstChild(triggerDataSubjectAccessTag)); child;
				child = static_cast<TiXmlElement*>(child->NextSibling(triggerDataSubjectAccessTag)) ) {
			trigger[triggerIdTag] = triggerDataSubjectAccessTag;

			// read url parameter
			trigger[uriTag] = (static_cast<TiXmlElement*>(child->FirstChild(uriTag)))->GetText();
			
			triggers.push_back(trigger);
			trigger.clear();
		}
	}

}
Beispiel #13
0
bool dSceneGraph::Deserialize (TiXmlElement* rootNode, int revision)
{
	Cleanup();
	int count;
	rootNode->Attribute("count", &count);

	dScene* world = (dScene*) this;
	for (TiXmlElement* element = (TiXmlElement*) rootNode->FirstChild(); element; element = (TiXmlElement*) element->NextSibling()) {
		const char* className = element->Value();
		dNodeInfo* info = dNodeInfo::CreateFromClassName (className, world);
		_ASSERTE (info);
		info->Deserialize(element, revision);
		AddNode (info, NULL);
		info->Release();
	}

	int baseIndex = Minimum()->GetKey();
	int baseIndexCount = baseIndex;
	for (TiXmlElement* element = (TiXmlElement*) rootNode->FirstChild(); element; element = (TiXmlElement*) element->NextSibling()) {
		dTreeNode* myNode = Find (baseIndexCount);
		baseIndexCount ++;
		_ASSERTE (myNode);
		dGraphNode& node = myNode->GetInfo();

		TiXmlElement* parentNodes = (TiXmlElement*) element->FirstChild ("parentNodes");
		if (parentNodes) {
			int count;
			parentNodes->Attribute("count", &count);
			const char* indices = parentNodes->Attribute ("indices");

			const char* ptr = indices;
			for (int i = 0; i < count; i ++) {
				char index[128];
				sscanf (ptr, "%s", index);
				ptr = strstr (ptr, index);
				ptr += strlen (index); 
				int parentIndex = atoi (index);

				dTreeNode* parentNode = Find(parentIndex + baseIndex);
				_ASSERTE (parentNode);
				node.m_parents.Append(parentNode);
			}
		} else {
			_ASSERTE (!m_rootNode);
			m_rootNode = myNode;
		}


		TiXmlElement* childrenNodes = (TiXmlElement*) element->FirstChild ("childrenNodes");
		if (childrenNodes) {
			int count;
			childrenNodes->Attribute("count", &count);
			const char* indices = childrenNodes->Attribute ("indices");

			const char* ptr = indices;
			for (int i = 0; i < count; i ++) {
				char index[128];
				sscanf (ptr, "%s", index);
				ptr = strstr (ptr, index);
				ptr += strlen (index); 
				int childIndex = atoi (index);

				dTreeNode* childNode = Find(childIndex + baseIndex);
				_ASSERTE (childNode);
				node.m_children.Append(childNode);
			}
		}
	}

	return true;
}
Beispiel #14
0
 TiXmlIterator& operator++() {
     root = static_cast<TiXmlElement*>(root->NextSibling());
     return *this;
 }
// Parse the box from the stream
CNCSError CNCSJP2File::CNCSJP2GMLGeoLocationBox::Parse(class CNCSJP2File &JP2File, CNCSJPCIOStream &Stream)
{
#ifdef NCS_BUILD_WITH_STDERR_DEBUG_INFO
    fprintf(stderr,"Parsing GML box information\n");
#endif

    CNCSError Error(NCS_SUCCESS);
    m_bValid = false;

    double dRegX = 0.0;
    double dRegY = 0.0;
    double p1[3];
    double p2[3];
    UINT32 nEPSGCode = 0;
    int nResults = 0;
    bool bSRSAttributePresent = false;
    UINT32 nImageWidth = JP2File.m_FileInfo.nSizeX;
    UINT32 nImageHeight = JP2File.m_FileInfo.nSizeY;

    NCSJP2_CHECKIO_BEGIN(Error, Stream);
    char buf[1024 + 1];
    Stream.Read(buf, NCSMin((UINT32)m_nLDBox, sizeof(buf)-1));
    buf[NCSMin((UINT32)m_nLDBox, sizeof(buf)-1)] = '\0';

    TiXmlDocument doc;
    doc.Parse(buf);
    TiXmlHandle docHandle(&doc);
    TiXmlElement *GeoLocation_1 = docHandle.FirstChild("JPEG2000_GeoLocation").FirstChild("gml:RectifiedGrid").Element();//.FirstChild( "Element" ).Child( "Child", 1 ).Element();
    if(GeoLocation_1 && GeoLocation_1->Attribute("gml:id") && !stricmp(GeoLocation_1->Attribute("gml:id"), "JPEG2000_GeoLocation_1")) {
        TiXmlElement *OriginPoint = docHandle.FirstChild("JPEG2000_GeoLocation").FirstChild("gml:RectifiedGrid").FirstChild("gml:origin").FirstChild("gml:Point").Element();
        if(OriginPoint && OriginPoint->Attribute("gml:id") && !stricmp(OriginPoint->Attribute("gml:id"), "JPEG2000_Origin")) {
            const char *pTxt = OriginPoint->Attribute("srsName");
            if(pTxt) {
                nResults += sscanf(pTxt, "epsg:%u", &nEPSGCode);
                bSRSAttributePresent = true;
            }
            TiXmlText *Coords = docHandle.FirstChild("JPEG2000_GeoLocation").FirstChild("gml:RectifiedGrid").FirstChild("gml:origin").FirstChild("gml:Point").FirstChild("gml:coordinates").FirstChild().Text();
            if(Coords) {
                pTxt = Coords->Value();
                if(pTxt) {
                    nResults += sscanf(pTxt, "%lf,%lf", &dRegX, &dRegY);
                }
            }
        }
        TiXmlElement *offsetVector = docHandle.FirstChild("JPEG2000_GeoLocation").FirstChild("gml:RectifiedGrid").FirstChild("gml:offsetVector").Element();
        if(offsetVector && offsetVector->Attribute("gml:id") && !stricmp(offsetVector->Attribute("gml:id"), "p1")) {
            TiXmlText *Coords = docHandle.FirstChild("JPEG2000_GeoLocation").FirstChild("gml:RectifiedGrid").FirstChild("gml:offsetVector").FirstChild().Text();
            if(Coords) {
                const char *pTxt = Coords->Value();
                if(pTxt) {
                    nResults += sscanf(pTxt, "%lf,%lf,%lf", &p1[0], &p1[1], &p1[2]);
                }
            }

            offsetVector = (TiXmlElement*)offsetVector->NextSibling("gml:offsetVector");
            if(offsetVector && offsetVector->Attribute("gml:id") && !stricmp(offsetVector->Attribute("gml:id"), "p2")) {
                TiXmlText *Coords = ((TiXmlElement*)offsetVector->FirstChild())->ToText();
                if(Coords) {
                    const char *pTxt = Coords->Value();
                    if(pTxt) {
                        nResults += sscanf(pTxt, "%lf,%lf,%lf", &p2[0], &p2[1], &p2[2]);
                    }
                }
            }
        }
    }
    NCSJP2_CHECKIO_END();

    if((nResults == 9 && bSRSAttributePresent) || (nResults == 8 && !bSRSAttributePresent)) {
        IEEE8 dRegistrationX = dRegX + nImageHeight * p1[0];
        IEEE8 dRegistrationY = dRegY + nImageHeight * p1[1];

        if(p1[2] == 0.0 && p2[2] == 0.0) {
//				p1[0] = sin(Deg2Rad(dCWRotationDegrees)) * dCellSizeX;
//				p1[1] = cos(Deg2Rad(dCWRotationDegrees)) * dCellSizeY;
//				p2[0] = cos(Deg2Rad(dCWRotationDegrees)) * dCellSizeX;
//				p2[1] = -sin(Deg2Rad(dCWRotationDegrees)) * dCellSizeY;

            double dCWRotationDegrees = Rad2Deg(atan(p1[0] / p2[0]));
            double dCellSizeX = p2[0] / cos(atan(p1[0] / p2[0]));
            double dCellSizeY = p1[1] / cos(atan(p1[0] / p2[0]));

            m_GMLFileInfo.fOriginX = dRegistrationX;
            m_GMLFileInfo.fOriginY = dRegistrationY;
            m_GMLFileInfo.fCellIncrementX = dCellSizeX;
            m_GMLFileInfo.fCellIncrementY = dCellSizeY;
            m_GMLFileInfo.fCWRotationDegrees = dCWRotationDegrees;

            CNCSGDTEPSG& Epsg = *CNCSGDTEPSG::Instance();
            char *pProjection = NULL;
            char *pDatum = NULL;
            NCSFree(m_GMLFileInfo.szProjection);
            NCSFree(m_GMLFileInfo.szDatum);
            if (bSRSAttributePresent && nEPSGCode &&
                    (Epsg.GetProjectionAndDatum(nEPSGCode, &pProjection, &pDatum) == NCS_SUCCESS))
            {
                if(pProjection && pDatum)
                {
                    m_GMLFileInfo.szProjection= NCSStrDup(pProjection);
                    m_GMLFileInfo.szDatum = NCSStrDup(pDatum);
                    NCSFree(pProjection);
                    NCSFree(pDatum);
                }
                else if (nEPSGCode) //EPSG code present but invalid or unrecognised?
                {
                    char szEPSG[32];
                    *szEPSG = '\0';
                    sprintf(szEPSG,"epsg:%u",nEPSGCode);
                    m_GMLFileInfo.szProjection = NCSStrDup(szEPSG);
                    m_GMLFileInfo.szDatum = NCSStrDup(szEPSG);
                }
            }
            else
            {
                m_GMLFileInfo.szDatum = NCSStrDup("RAW");
                m_GMLFileInfo.szProjection = NCSStrDup("RAW");
            }
            if(stricmp(m_GMLFileInfo.szProjection, "GEODETIC") == 0)
                m_GMLFileInfo.eCellSizeUnits = ECW_CELL_UNITS_DEGREES;
            else
                m_GMLFileInfo.eCellSizeUnits = ECW_CELL_UNITS_METERS;
        }
        else return NCS_JP2_GEODATA_READ_ERROR;
    }
    else return NCS_JP2_GEODATA_READ_ERROR;
    m_bValid = true;
    NCSStandardizeFileInfoEx(&m_GMLFileInfo);

    return NCS_SUCCESS;
}