Example #1
0
void Scene::processGraph(string nodeID, Appearance *app)
{
	Node *node = nodes[nodeID];
	if(node->appearance) //se nó tem aparência, substitui a do pai
		app=node->appearance;

	if(app) //se a aparência não for nula
		app->apply(); //aplica a aparência para desenhar as primitivas
	else
		(new CGFappearance())->apply(); //material por defeito

	if (node->displayList) //se houver uma display list, chama-a e ignora filhos
		glCallList(node->displayListID);
	else //se não, percorre normalmente
	{
		glMultMatrixf(node->T);
		if (node->animation != NULL && runAnimations)
			node->animation->draw();
		for (vector<Primitiva *>::iterator it = node->primitivas.begin(); it != node->primitivas.end(); it++)
			(*it)->draw();

		for (vector<string>::iterator it = node->children.begin(); it != node->children.end(); it++)
		{
			glPushMatrix();
			processGraph(*it, app);
			glPopMatrix();
		}
	}
}
string AlienDictionary::alienOrder() {
    processGraph();
    topologicalSort();
    if (cycle) return "";
    string retval;
    for (int i=rPostOrder.size()-1; i>=0; i--) {
        retval.push_back(nodeToChar[rPostOrder[i]]);
    }
    return retval;
}
Example #3
0
void doJob(const std::string& inputMaf, const std::string& outDir, 
		   std::vector<ParamPair> simplParams, std::vector<int> minBlockSizes)
{

	const int MIN_ALIGNMENT = 1;
	const int MAX_ALIGNMENT_GAP = 0;
	const auto EMPTY_GROUP = BlockGroups();

	BlockGroups blockGroups = EMPTY_GROUP;
	PermVec currentBlocks;
	//sort blocks in reverse order (will use it as stack)
	std::sort(minBlockSizes.begin(), minBlockSizes.end(), std::greater<int>());
	makeDirectory(outDir);

	//read maf alignment and join adjacent columns
	std::cerr << "\tParsing MAF file\n";
	PermVec mafBlocks = mafToPermutations(inputMaf, MIN_ALIGNMENT);
	compressPaths(mafBlocks, MAX_ALIGNMENT_GAP, currentBlocks, blockGroups);

	//iterative simplification
	for (const ParamPair& ppair : simplParams)
	{
		if (minBlockSizes.empty()) break;
		//output blocks of certain size
		while (!minBlockSizes.empty() && minBlockSizes.back() < ppair.minBlock)
		{
			std::string blockDir = outDir + "/" + 
								   std::to_string(minBlockSizes.back());
			outputBlocks(blockDir, currentBlocks, blockGroups,
						 minBlockSizes.back());
			minBlockSizes.pop_back();
		}

		std::cerr << "\tSimplification with " << ppair.minBlock << " "
				  << ppair.maxGap << std::endl;
		PermVec inputBlocks = filterBySize(currentBlocks, EMPTY_GROUP,
										   ppair.minBlock, true);
		PermVec outBlocks;
		blockGroups.clear();
		processGraph(inputBlocks, ppair.maxGap, outBlocks, blockGroups);
		currentBlocks = outBlocks;
	}

	//if any left
	for (int minBlock : minBlockSizes)
	{
		std::string blockDir = outDir + "/" + std::to_string(minBlock);
		outputBlocks(blockDir, currentBlocks, blockGroups, minBlock);
	}
}
Example #4
0
void YafFile::loadFile(char* filename)
{
	TiXmlDocument* doc=new TiXmlDocument( filename );
	bool loadOkay = doc->LoadFile();
	if ( !loadOkay )
	{
		printf( "Could not load file '%s'. Error='%s'. Exiting.\n", filename, doc->ErrorDesc() );
		exit( 1 );
	}

	TiXmlElement* yafElement= doc->FirstChildElement( "yaf" );

	if (yafElement == NULL)
	{
		printf("Main yaf block element not found! Exiting!\n");
		exit(1);
	}
	TiXmlElement* globalsElement = yafElement->FirstChildElement( "globals" );
	processGlobals(globalsElement);
	TiXmlElement* lightingElement = yafElement->FirstChildElement("lighting");
	processGlobalLight(lightingElement);
	processLights(lightingElement);
	TiXmlElement* camerasElement = yafElement->FirstChildElement("cameras");
	processCameras(camerasElement);
	TiXmlElement* texturesElement = yafElement->FirstChildElement("textures");
	processTextures(texturesElement);

	TiXmlElement* appearanceElement = yafElement->FirstChildElement("appearances");
	processAppearances(appearanceElement);

	TiXmlElement* animationsElement = yafElement->FirstChildElement("animations");
	if(animationsElement!=NULL)
	{
		processAnimations(animationsElement);
		map<string,Animation*>::iterator it = animations.begin();
		for(;it!=animations.end();it++)
		{
			(*it->second).print();
		}
	}

	TiXmlElement* graphElement = yafElement->FirstChildElement("graph");
	processGraph(graphElement);
}
Example #5
0
void YafScene::processGraph( string rootid, vector<Appearence*> &appstack ){
	GraphNode *n0 = sg->graphNodes->at( rootid );
	sg->updateTheme();

	bool newApp = false;

	unsigned int maxSize = n0->nodeRefIdVector.size();

	if( n0->hasDL() ){
		glCallList( n0->getDL() );	
	}else{
		if( n0->appRefId != "" ){
			if( sg->getAppearences()->count(n0->getAppRefId()) ){ // Is this really needed? //
				appstack.push_back( sg->getAppearences()->at(n0->getAppRefId()));
				newApp = true;
			}
		}

		if(!appstack.empty()){
			glMaterialfv(GL_FRONT, GL_EMISSION, appstack[appstack.size()-1]->getEmissive() );
			appstack[appstack.size()-1]->apply();
		}
		
		glMultMatrixf( n0->getTransformationMatrix() );

		if( n0->hasAnimation() )
			sg->getAnimations()->at( n0->getAnimationRef() )->apply( n0->getTransformationMatrix()[12], n0->getTransformationMatrix()[13], n0->getTransformationMatrix()[14] );

		if( n0->primitives.size() > 0){
			for(unsigned int i=0; i<n0->primitives.size(); i++){
				n0->primitives[i]->draw();
			}
		}

		if( newApp && !appstack.empty() ) appstack.pop_back();

		for(unsigned int i = 0; i<maxSize; i++){
			glPushMatrix();
			processGraph( n0->nodeRefIdVector[i], appstack );
			glPopMatrix();
		}
	}

}
Example #6
0
void XMLScene::loadFile()
{
	TiXmlDocument* doc=new TiXmlDocument( filename );
	bool loadOkay = doc->LoadFile();
	if ( !loadOkay )
	{
		printf( "Could not load file '%s'. Error='%s'. Exiting.\n", filename, doc->ErrorDesc() );
		exit( 1 );
	}

	TiXmlElement* anfElement= doc->FirstChildElement( "anf" );

	if (anfElement == NULL)
	{
		printf("Main anf block element not found! Exiting!\n");
		exit(1);
	}
	TiXmlElement* globalsElement = anfElement->FirstChildElement( "globals" );
	processGlobals(globalsElement);
	TiXmlElement* camerasElement = anfElement->FirstChildElement("cameras");
	processCameras(camerasElement);
	TiXmlElement* lightingElement = anfElement->FirstChildElement("lights");
	defineGlobalVariables();
	processLights(lightingElement);
	defineGlobalVariables();
	TiXmlElement* texturesElement = anfElement->FirstChildElement("textures");
	processTextures(texturesElement);

	TiXmlElement* appearanceElement = anfElement->FirstChildElement("appearances");
	processAppearances(appearanceElement);

	TiXmlElement* graphElement = anfElement->FirstChildElement("graph");
	processGraph(graphElement);
	//sets the children to the correct bool
	sceneGraph->setChildDisplay();

}
Example #7
0
void YafScene::display(){

	// ---- BEGIN Background, camera and axis setup

	// Clear image and depth buffer everytime we update the scene
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

	// Initialize Model-View matrix as identity (no transformation
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	// Drawmode //
	if( *(sg->getDrawModeChoice()) == 0 )
		glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
	else
		if( *(sg->getDrawModeChoice()) == 1 )
			glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
		else
			if( *(sg->getDrawModeChoice()) == 2 )
				glPolygonMode( GL_FRONT_AND_BACK, GL_POINT );

	// Apply transformations corresponding to the camera position relative to the origin
	//activeCamera->applyView();

	/*for( map<string, Camera*>::iterator it = sg->getCameras()->begin(); it != sg->getCameras()->end(); it++ ){      
			if( distance(sg->getCameras()->begin(), it) == *(sg->getActualCamera()))
					this->activateCamera( *(sg->getActualCamera()) + 3 );
	}*/

	switch(*(sg->getActualCamera())){
		case 0 : activeCamera->applyView(); // Free Camera //
				 break;
		case 1 : gluLookAt (0.0, 7.5, 12.5, 12.5, 3.0, 12.5, 0.0, 1.0, 0.0); // White Player //
				 break;
		case 2 : gluLookAt (25.0, 7.5, 12.5, 12.5, 3.0, 12.5, 0.0, 1.0, 0.0); // Black Player //
				 break;
		case 3 : gluLookAt (12.5, 7.5, 0.0, 12.5, 3.0, 12.5, 0.0, 1.0, 0.0); // Sideview //
				 break;
		case 4 : gluLookAt (0.0, 15.0, 0.0, 12.5, 5.0, 12.5, 0.0, 1.0, 0.0); // OverView //
				 break;

	}

	//activeCamera->applyView();

	// Draw (and update) light
	for( map<string, Lighting*>::iterator it = sg->getLights()->begin(); it != sg->getLights()->end(); it++ ){	
		if( *(it->second->getToogled()) ){
			it->second->enable();
		}
		else
			it->second->disable();

		it->second->update();
		it->second->draw();
	}
	
	// Draw axis
	//axis.draw();


	// ---- END Background, camera and axis setup


	// ---- END feature demos
	vector<Appearence*> stack;
	stack.clear();
	processGraph( this->sg->getRootid(), stack );
	if( sg->gameOver ){
		char *gameOverMsg = (char *)malloc(sizeof(char) * 256 );
		char *gameOverMsgAux = (char *)malloc(sizeof(char) * 65 );
		
		strcpy(gameOverMsg, "GAME OVER ! ");
		if( sg->p1points > sg->p2points ){
			strcat(gameOverMsg, "Player ");
			itoa(1, gameOverMsgAux, 10);
			strcat(gameOverMsg, gameOverMsgAux);
			strcat(gameOverMsg, " Wins!");
		} else if( sg->p2points > sg->p1points ){
			strcat(gameOverMsg, "Player ");
			itoa(2, gameOverMsgAux, 10);
			strcat(gameOverMsg, gameOverMsgAux);
			strcat(gameOverMsg, " Wins!");
		} else {
			strcat(gameOverMsg, "It's a draw!");
		}

		sg->getPainter()->draw(gameOverMsg, 100, 100);


		char *gameTime = (char *)malloc(sizeof(char)*512);
		char *gameTimeAux = (char *)malloc(sizeof(char)*65);

		strcpy(gameTime, "The game took ");
		itoa((sg->endTime-sg->startTime)/1000.0, gameTimeAux, 10);
		strcat(gameTime, gameTimeAux);
		strcat(gameTime, " seconds!");

		sg->getPainter()->draw(gameTime, 100, 120);
	}

	char *p1score = (char *)malloc(sizeof(char) *256);
	char *p2score = (char *)malloc(sizeof(char) *256);
	char *p1aux = (char *)malloc(sizeof(char)*65);
	char *p2aux = (char *)malloc(sizeof(char)*65);

	strcat(p1score, "Player 1: ");
	strcat(p2score, "Player 2: ");

	itoa(sg->p1points, p1aux, 10);
	strcat(p1score, p1aux);
	itoa(sg->p2points, p2aux, 10);
	strcat(p2score, p2aux);

	strcat(p1score, " points!");
	strcat(p2score, " points!");
	sg->getPainter()->draw(p1score, 100, 140);
	sg->getPainter()->draw(p2score, 100, 160);

	if( sg->getPlayingMovie() == true ) {

		if( movieIndex == 0 ){
			sg->setCurrentLogical( sg->getLogicalBoard() );
			sg->setCurrentAppearence( sg->getAppearenceBoard() );
			this->sg->setBothBoards( sg->pStack[movieIndex], sg->pStack[movieIndex+1] );
			movieIndex += 2;
			timeElapsed = glutGet(GLUT_ELAPSED_TIME);
		}

		if((glutGet(GLUT_ELAPSED_TIME) - timeElapsed > 1000 ) && (movieIndex < sg->pStack.size())){
			this->sg->setBothBoards( sg->pStack[movieIndex], sg->pStack[movieIndex+1] );
			movieIndex += 2;
			timeElapsed = glutGet(GLUT_ELAPSED_TIME);
		}

		if((movieIndex >= sg->pStack.size()) && (glutGet(GLUT_ELAPSED_TIME) - timeElapsed > 1000 )){
			this->sg->setBothBoards( sg->getCurrentLogical(), sg->getCurrentAppearence() );
			sg->setPlayingMovie( false );
			movieIndex = 0;
			timeElapsed = 0;
		}
	}

	glPushMatrix();
		glTranslatef(8.5 ,0.5, 8.5);
		this->sg->getBoard()->draw();
	glPopMatrix();
	//this->sg->getText()->draw("FAIL");
	// We have been drawing in a memory area that is not visible - the back buffer, 
	// while the graphics card is showing the contents of another buffer - the front buffer
	// glutSwapBuffers() will swap pointers so that the back buffer becomes the front buffer and vice-versa
	glutSwapBuffers();

}
Example #8
0
void Scene::display() 
{
	//limpa a cor activa debackground e define nova cor RGBA
	if (gameEnvironment==1)
		glClearColor(backgroundR, backgroundG, backgroundB, backgroundA);
	else if (gameEnvironment==2)
		glClearColor(backgroundR2, backgroundG2, backgroundB2, backgroundA2);

	// Clear image and depth buffer everytime we update the scene
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

	//Define drawmode
	glPolygonMode(GL_FRONT_AND_BACK, this->drawMode);

	// Initialize Model-View matrix as identity (no transformation
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	// Apply transformations corresponding to the camera position relative to the origin
	CGFscene::activeCamera->applyView();

	GLint rMode;
 
	glGetIntegerv(GL_RENDER_MODE, &rMode);

	if (rMode == GL_RENDER) //se em modo normal, desenha a cena
	{
		// Draw (and update) light
		std::list<CGFlight *>::iterator it = scene_lights.begin();
		for (; it != scene_lights.end(); ++it)
			((Light *)(*it))->draw();

		// Draw axis
		//axis.draw();
		
		// ---- END Background, camera and axis setup
		processGraph(rootNode); //temos de passar o id do nó inicial
		//board->draw();
		// We have been drawing in a memory area that is not visible - the back buffer, 
		// while the graphics card is showing the contents of another buffer - the front buffer
		// glutSwapBuffers() will swap pointers so that the back buffer becomes the front buffer and vice-versa
		//board->drawHotspots(); //Testing
	}
	if (!Animation::animationRunning || !waitForAnimations)
	{
		if (inReplay)
			replay();
		else if (!computerPlaying) //only draw arrows and hotspots if it's a human player's turn
		{
			if (rMode == GL_SELECT && gameState == PLACEPIECE && gameStarted) //se em modo de pick, desenha os hotspots
				board->drawHotspots();

			if (gameState == ROTATE) //in all render modes
				board->drawArrows(player);
		}
		else //if the computer is playing, start the rotation
			computerPlay();
	}
	glutSwapBuffers();
	//std::this_thread::sleep_for(std::chrono::milliseconds(17));
}
 void LazyConstraintCallback::main() {
   assert( graphs.numGraphs() == 2 );
   for ( int i = 0, e = graphs.numGraphs(); i != e; ++i ) {
     processGraph( i );
   }
 }
Example #10
0
bool GraphMLImporter::processGraph_Nodes(
	QDomElement& graphElement
)
{
	bool ok = true;

	iColor_ = 0;

	// nodes
	for ( QDomElement nodeElement = graphElement.firstChildElement( "node" ); ok && !nodeElement.isNull(); nodeElement = nodeElement.nextSiblingElement( "node" ) ) {
		QString nameId = nodeElement.attribute( "id" );
		QString name = NULL;
		// pozerame sa na data ktore nesie
		Data::Type* newNodeType;
		newNodeType = NULL;
		QDomNodeList nodeDataList = nodeElement.elementsByTagName( "data" );
		for ( unsigned int j = 0; j < nodeDataList.length(); j++ ) {
			QDomNode nodeData = nodeDataList.item( static_cast<int>( j ) );
			if ( !nodeData.isNull() && nodeData.isElement() ) {
				QDomElement nodeDataElement = nodeData.toElement();
				QString dataName = nodeDataElement.attribute( "key" );
				QString dataValue = nodeDataElement.text();
				// rozpoznavame typy
				if ( dataName == nodeTypeAttribute_ ) {
					// overime ci uz dany typ existuje v grafe
					QList<Data::Type*> types = context_->getGraph().getTypesByName( dataValue );
					if ( types.isEmpty() ) {
						QMap<QString, QString>* settings = new QMap<QString, QString>;

						settings->insert( "color.R", QString::number( colors_[iColor_][0] ) );
						settings->insert( "color.G", QString::number( colors_[iColor_][1] ) );
						settings->insert( "color.B", QString::number( colors_[iColor_][2] ) );
						settings->insert( "color.A", QString::number( colors_[iColor_][3] ) );
						settings->insert( "scale",		Util::ApplicationConfig::get()->getValue( "Viewer.Textures.DefaultNodeScale" ) );
						settings->insert( "textureFile", Util::ApplicationConfig::get()->getValue( "Viewer.Textures.Node" ) );

						newNodeType = context_->getGraph().addType( dataValue, settings );

						iColor_++;
						if ( iColor_ == colors_.size() ) {
							iColor_ = 0;
						}
					}
					else {
						newNodeType = types.first();
					}

				}
				else {
					// kazde dalsie data nacitame do nosica dat - Node.name
					// FIXME potom prerobit cez Adamove Node.settings
					if ( name == NULL ) {
						name = dataName+":"+dataValue;
					}
					else {
						name += " | "+dataName+":"+dataValue;
					}
				}
			}
		}

		// ak sme nenasli name, tak ako name pouzijeme aspon ID
		if ( name == NULL ) {
			name = nameId;
		}

		// ak nebol najdeny ziaden typ, tak pouzijeme defaultny typ
		osg::ref_ptr<Data::Node> node;
		if ( newNodeType == NULL ) {
			node = context_->getGraph().addNode( name, nodeType_ );
		}
		else {
			node = context_->getGraph().addNode( name, newNodeType );
		}
		readNodes_->addNode( nameId, node );

		// subgraphs
		for ( QDomElement subgraphElement = nodeElement.firstChildElement( "graph" ); ok && !subgraphElement.isNull(); subgraphElement = subgraphElement.nextSiblingElement( "graph" ) ) {
			if ( ok ) {
				context_->getGraph().createNestedGraph( node );
			}

			if ( ok ) {
				ok = processGraph( subgraphElement );
			}

			if ( ok ) {
				context_->getGraph().closeNestedGraph();
			}
		}

		entitiesProcessed_++;
		context_->getInfoHandler().setProgress( static_cast<unsigned int>( entitiesProcessed_ * 100 / entitiesCount_ ) );
	}

	return ok;
}
Example #11
0
bool GraphMLImporter::import(
	ImporterContext& context
)
{
	// context
	context_ = &context;
	// helpers
	graphOp_.reset( new GraphOperations( context_->getGraph() ) );
	readNodes_.reset( new ReadNodesStore() );

	// default types
	edgeType_ = NULL;
	nodeType_ = NULL;
	( void )graphOp_->addDefaultTypes( edgeType_, nodeType_ );

	// ziskame pristup ku nastaveniam
	Util::ApplicationConfig* appConf = Util::ApplicationConfig::get();
	edgeTypeAttribute_ = appConf->getValue( "GraphMLParser.edgeTypeAttribute" );
	nodeTypeAttribute_ = appConf->getValue( "GraphMLParser.nodeTypeAttribute" );

	// pole farieb FIXME oddelit farby hran od farieb uzlov
	colors_.push_back( ColorType( 0, 1, 0, 1 ) );
	colors_.push_back( ColorType( 0, 1, 1, 1 ) );
	colors_.push_back( ColorType( 1, 0, 0, 1 ) );
	colors_.push_back( ColorType( 1, 0, 1, 1 ) );
	colors_.push_back( ColorType( 1, 1, 0, 1 ) );
	colors_.push_back( ColorType( 1, 1, 1, 1 ) );

	iColor_ = 0;

	bool ok = true;

	// ziskame graph element
	QDomElement graphElement;
	if ( ok ) {
		QDomNode graphNode;

		QDomDocument doc( "graphMLDocument" );
		if ( doc.setContent( &( context_->getStream() ) ) ) {
			QDomElement docElem = doc.documentElement();
			if ( !docElem.isNull() && docElem.nodeName() == "graphml" ) {
				QDomNodeList graphNodes = docElem.elementsByTagName( "graph" );
				if ( graphNodes.length() > 0 ) {
					graphNode = graphNodes.item( 0 );
					if ( !graphNode.isNull() && graphNode.parentNode() == docElem && graphNode.isElement() ) {
						graphElement = graphNode.toElement();
					}
				}
			}
		}

		ok = !graphElement.isNull();

		context_->getInfoHandler().reportError( ok, "Zvoleny subor nie je validny GraphML subor." );
	}

	if ( ok ) {
		// for progress reporting
		entitiesProcessed_ = 0;
		entitiesCount_ = graphElement.elementsByTagName( "node" ).size() + graphElement.elementsByTagName( "edge" ).count();
	}

	if ( ok ) {
		ok = processGraph( graphElement );
	}

	return ok;
}
Example #12
0
bool GraphMLImporter::processGraph_Edges(
	QDomElement& graphElement
)
{
	bool ok = true;

	iColor_ = 0;

	// default direction
	bool defaultDirection;
	if ( graphElement.attribute( "edgedefault" ) == "directed" ) {
		defaultDirection = true;
	}
	else {
		defaultDirection = false;
	}

	// edges
	for ( QDomElement edgeElement = graphElement.firstChildElement( "edge" ); ok && !edgeElement.isNull(); edgeElement = edgeElement.nextSiblingElement( "edge" ) ) {
		QString sourceId = edgeElement.attribute( "source" );
		QString targetId = edgeElement.attribute( "target" );

		QString direction = NULL;
		bool directed = false;
		direction = edgeElement.attribute( "directed" );
		if ( direction == NULL ) {
			directed = defaultDirection;
			if ( directed ) {
				direction = "_directed";
			}
			else {
				direction = "";
			}
		}
		else {
			if ( direction == "true" ) {
				direction = "_directed";
				directed = true;
			}
			else {
				direction = "";
				directed = false;
			}
		}

		// pozerame sa na data ktore hrana nesie
		Data::Type* newEdgeType;
		newEdgeType = NULL;
		QDomNodeList edgeDataList = edgeElement.elementsByTagName( "data" );
		for ( unsigned int j = 0; j < edgeDataList.length(); j++ ) {
			QDomNode edgeData = edgeDataList.item( static_cast<int>( j ) );
			if ( !edgeData.isNull() && edgeData.isElement() ) {
				QDomElement edgeDataElement = edgeData.toElement();
				QString dataName = edgeDataElement.attribute( "key" );
				QString dataValue = edgeDataElement.text();
				// rozpoznavame typy deklarovane atributom relation
				if ( dataName == edgeTypeAttribute_ ) {
					// overime ci uz dany typ existuje v grafe
					QList<Data::Type*> types = context_->getGraph().getTypesByName( dataValue+direction );
					if ( types.isEmpty() ) {
						QMap<QString, QString>* settings = new QMap<QString, QString>;

						// FIXME spravit tak, aby to rotovalo po tom poli - palo az to budes prerabat tak pre hrany pouzi ine pole, take co ma alfu na 0.5.. a to sa tyka aj uzlov s defaultnym typom
						settings->insert( "color.R", QString::number( colors_[iColor_][0] ) );
						settings->insert( "color.G", QString::number( colors_[iColor_][1] ) );
						settings->insert( "color.B", QString::number( colors_[iColor_][2] ) );
						settings->insert( "color.A", QString::number( colors_[iColor_][3] ) );
						settings->insert( "scale",		Util::ApplicationConfig::get()->getValue( "Viewer.Textures.DefaultNodeScale" ) );

						if ( !directed ) {
							settings->insert( "textureFile", Util::ApplicationConfig::get()->getValue( "Viewer.Textures.Edge" ) );
						}
						else {
							settings->insert( "textureFile", Util::ApplicationConfig::get()->getValue( "Viewer.Textures.OrientedEdgePrefix" ) );
							settings->insert( "textureFile", Util::ApplicationConfig::get()->getValue( "Viewer.Textures.OrientedEdgeSuffix" ) );
						}

						newEdgeType = context_->getGraph().addType( dataValue+direction, settings );

						iColor_++;
						if ( iColor_ == colors_.size() ) {
							iColor_ = 0;
						}
					}
					else {
						newEdgeType = types.first();
					}

				}
				else {
					// kazde dalsie data nacitame do nosica dat - Edge.name
					// FIXME potom prerobit cez Adamove Node.settings
				}
			}
		}

		// ak nebol najdeny typ, tak pouzijeme defaulty
		if ( newEdgeType == NULL ) {
			newEdgeType = edgeType_;
		}

		context_->getGraph().addEdge( sourceId+targetId, readNodes_->get( sourceId ), readNodes_->get( targetId ), newEdgeType, directed );

		// vnorene grafy
		for ( QDomElement subgraphElement = edgeElement.firstChildElement( "graph" ); ok && !subgraphElement.isNull(); subgraphElement = subgraphElement.nextSiblingElement( "graph" ) ) {
			if ( ok ) {
				// TODO: begin subgraph in edge
			}

			if ( ok ) {
				ok = processGraph( subgraphElement );
			}

			if ( ok ) {
				// TODO: end subgraph in edge
			}
		}

		entitiesProcessed_++;
		context_->getInfoHandler().setProgress( static_cast<unsigned int>( entitiesProcessed_ * 100 / entitiesCount_ ) );
	}

	return ok;
}
void run(context_t& ctx, bool directed) {
    bool is_master = ctx.dc.procid() == 0;
    timer_start(is_master);

#ifdef GRANULA
    granula::operation powergraphJob("PowerGraph", "Id.Unique", "Job", "Id.Unique");
    granula::operation loadGraph("PowerGraph", "Id.Unique", "LoadGraph", "Id.Unique");
    if(is_master) {
        cout<<powergraphJob.getOperationInfo("StartTime", powergraphJob.getEpoch())<<endl;
        cout<<loadGraph.getOperationInfo("StartTime", loadGraph.getEpoch())<<endl;
    }
#endif

    // process parmaeters
    global_directed = directed;

    // load graph
    timer_next("load graph");
    graph_type graph(ctx.dc);
    load_graph(graph, ctx);
    graph.finalize();

#ifdef GRANULA
    if(is_master) {
        cout<<loadGraph.getOperationInfo("EndTime", loadGraph.getEpoch())<<endl;
    }
#endif

    // start engine
    timer_next("initialize engine");
    graphlab::omni_engine<triangle_count> engine(ctx.dc, graph, "synchronous", ctx.clopts);
    engine.signal_all();

#ifdef GRANULA
    granula::operation processGraph("PowerGraph", "Id.Unique", "ProcessGraph", "Id.Unique");
    if(is_master) {
        cout<<processGraph.getOperationInfo("StartTime", processGraph.getEpoch())<<endl;
    }
#endif

    // run algorithm
    timer_next("run algorithm");
    engine.start();

#ifdef GRANULA
    if(is_master) {
        cout<<processGraph.getOperationInfo("EndTime", processGraph.getEpoch())<<endl;
    }
#endif

#ifdef GRANULA
    granula::operation offloadGraph("PowerGraph", "Id.Unique", "OffloadGraph", "Id.Unique");
    if(is_master) {
        cout<<offloadGraph.getOperationInfo("StartTime", offloadGraph.getEpoch())<<endl;
    }
#endif

    // print output
    if (ctx.output_enabled) {
        timer_next("print output");
        vector<pair<graphlab::vertex_id_type, vertex_data_type> > data;
        collect_vertex_data(graph, data, is_master);

        for (size_t i = 0; i < data.size(); i++) {
            (*ctx.output_stream) << data[i].first << " " << data[i].second.clustering_coef << endl;
        }
    }

    timer_end();

#ifdef GRANULA
    if(is_master) {
        cout<<offloadGraph.getOperationInfo("EndTime", offloadGraph.getEpoch())<<endl;
        cout<<powergraphJob.getOperationInfo("EndTime", powergraphJob.getEpoch())<<endl;
    }
#endif

}