예제 #1
0
SList<node>& DynamicSPQRForest::findPathSPQR (node sH, node tH, node& rT) const
{
	SList<node>& pT = *OGDF_NEW SList<node>;
	node sT = spqrproper(sH->firstAdj()->theEdge());
	node tT = spqrproper(tH->firstAdj()->theEdge());
	node nT = findNCASPQR(sT,tT);
	while (sT!=nT) {
		edge eH = m_tNode_hRefEdge[sT];
		node uH = eH->source();
		node vH = eH->target();
		if (uH!=sH && vH!=sH) pT.pushBack(sT);
		if (uH==tH || vH==tH) { rT = sT; return pT; }
		sT = spqrproper(m_hEdge_twinEdge[eH]);
	}
	SListIterator<node> iT = pT.rbegin();
	while (tT!=nT) {
		edge eH = m_tNode_hRefEdge[tT];
		node uH = eH->source();
		node vH = eH->target();
		if (uH!=tH && vH!=tH) {
			if (iT.valid()) pT.insertAfter(tT,iT);
			else pT.pushFront(tT);
		}
		if (uH==sH || vH==sH) { rT = tT; return pT; }
		tT = spqrproper(m_hEdge_twinEdge[eH]);
	}
	if (iT.valid()) pT.insertAfter(nT,iT);
	else pT.pushFront(nT);
	rT = nT; return pT;
}
예제 #2
0
bool SDLEntity2D::LoadFrame ( std::string Name, std::string TexName, std::string MaskName, int FrameDelay, int x, int y, SGZ::RGBCOLOUR ColourKey )
{
	/// Load up a Texture into an Animation
	SListIterator<SGZAnimGroup2D*> AnimListITR = AnimList.getIterator();

	for( AnimListITR.start(); AnimListITR.valid(); AnimListITR.forth() )
		if((AnimListITR.item()->AnimName.compare(Name))==0)
		{
			SGZAnimFrame2D *Frame = new SGZAnimFrame2D;
			Frame->TextureName = TexName;
			Frame->MaskName = MaskName;
			Frame->delay = FrameDelay;
			Frame->u = x;
			Frame->v = y;
			Frame->colkey = ColourKey;
			AnimListITR.item()->FrameList.append(Frame);
			AnimListITR.item()->AnimNum++;
			AnimListITR.item()->FrameITR = AnimListITR.item()->FrameList.getIterator();

			if(!manTextures->checkExist(TexName))
				SGZ::Logger.log( SGZLOG::Warning, "Texture " + TexName + " has not been loaded yet.. make sure it is before calling this frame!");
			return true;
		}

	SGZ::Logger.log( SGZLOG::Warning, "Animation \"" + Name + "\" does not exist!\n");
	return false;
}
예제 #3
0
// Reduction reduced a set of leaves determined by their keys stored 
// in leafKeys. Integer redNumber is for debugging only.
bool PlanarPQTree::Reduction(SListPure<PlanarLeafKey<indInfo*>*> &leafKeys)
{
	SListIterator<PlanarLeafKey<indInfo*>* >  it;
	SListPure<PQLeafKey<edge,indInfo*,bool>*> castLeafKeys;
	for (it = leafKeys.begin(); it.valid(); ++it)
		castLeafKeys.pushBack((PQLeafKey<edge,indInfo*,bool>*) *it);

	return PQTree<edge,indInfo*,bool>::Reduction(castLeafKeys);
}
예제 #4
0
bool MTexture::checkExist ( const std::string &Name )
{
	SListIterator<TextureObj*> TextureITR = mTextureList.getIterator();
	for( TextureITR.start(); TextureITR.valid(); TextureITR.forth() )
		if(TextureITR.item()->mName.compare(Name)==0)
			return true;

	return false;
}
예제 #5
0
// Initializes a PQTree by a set of leaves that will korrespond to
// the set of Keys stored in leafKeys.
int PlanarPQTree::Initialize(SListPure<PlanarLeafKey<IndInfo*>*> &leafKeys)
{
	SListIterator<PlanarLeafKey<IndInfo*>* >  it;
	SListPure<PQLeafKey<edge,IndInfo*,bool>*> castLeafKeys;
	for (it = leafKeys.begin(); it.valid(); ++it)
		castLeafKeys.pushBack((PQLeafKey<edge,IndInfo*,bool>*) *it);

	return PQTree<edge,IndInfo*,bool>::Initialize(castLeafKeys);
}
예제 #6
0
	forall_nodes(v,G)
	{
		SListIterator<PlanarLeafKey<whaInfo*>* > it;
		for (it = inLeaves[v].begin(); it.valid(); ++it)
		{
			PlanarLeafKey<whaInfo*>* L = *it;
			outLeaves[L->userStructKey()->opposite(v)].pushFront(L);
		}
	}
예제 #7
0
std::string SDLEntity2D::CheckVar( std::string Name )
{
	SListIterator<SGZVarGroup*> VarITR = VarList.getIterator();

	for( VarITR.start(); VarITR.valid(); VarITR.forth() )
		if((VarITR.item()->Name.compare(Name))==0)
			return VarITR.item()->Variable;

	return "none";
}
예제 #8
0
bool MTexture::setColourKey ( const std::string &Name, const SGZ::RGBCOLOUR &key )
{
	SListIterator<TextureObj*> TextureITR = mTextureList.getIterator();
	for( TextureITR.start(); TextureITR.valid(); TextureITR.forth() )
		if(TextureITR.item()->mName.compare(Name)==0)
			TextureITR.item()->mData->setColourKey(key);


	SGZ::Logger.log( SGZLOG::Warning, "Texture " + Name + " does not exist!\n");
	return false;
}
// Reduction reduced a set of leaves determined by their keys stored 
// in leafKeys. Integer redNumber is for debugging only.
bool PlanarSubgraphPQTree::
Reduction(SListPure<PlanarLeafKey<whaInfo*>*> &leafKeys,
		  SList<PQLeafKey<edge,whaInfo*,bool>*> &eliminatedKeys,
		  int redNumber)
{
	SListPure<PQLeafKey<edge,whaInfo*,bool>*> castLeafKeys;

	SListIterator<PlanarLeafKey<whaInfo*>* >  it;
	for (it = leafKeys.begin(); it.valid(); ++it)
	{
		castLeafKeys.pushBack((PQLeafKey<edge,whaInfo*,bool>*) *it);
		#ifdef OGDF_DEBUG
		if (int(ogdf::debugLevel) >= int(dlHeavyChecks))
		{		
			cout << (*it)->print() << endl;
		}
		#endif
	}

	determineMinRemoveSequence(castLeafKeys,eliminatedKeys);
	removeEliminatedLeaves(eliminatedKeys);

	SListIterator<PQLeafKey<edge,whaInfo*,bool>* >  itn = castLeafKeys.begin();
	SListIterator<PQLeafKey<edge,whaInfo*,bool>* >  itp = itn++;
	for (; itn.valid();)
	{
		if ((*itn)->nodePointer()->status()== WHA_DELETE) 
		{
			itn++;
			castLeafKeys.delSucc(itp);
		}
		else
			itp = itn++;
	}
	
	if ((*castLeafKeys.begin())->nodePointer()->status() == WHA_DELETE)
		castLeafKeys.popFront();

	
	return Reduce(castLeafKeys,redNumber);
}
예제 #10
0
void* MTexture::getTexture( const std::string &Name )
{
	SListIterator<TextureObj*> TextureITR = mTextureList.getIterator();
	for( TextureITR.start(); TextureITR.valid(); TextureITR.forth() )
		if(TextureITR.item()->mName.compare(Name)==0)
		{
			return TextureITR.item()->mData->getTexture();
		}

	SGZ::Logger.log( SGZLOG::Warning, "Texture " + Name + " does not exist!\n");
	return NULL;
}
예제 #11
0
MTexture::~MTexture()
{
	/** Destructor */
	SListIterator<TextureObj*> TextureITR = mTextureList.getIterator();

	TextureITR.start();
	while (TextureITR.valid())
	{
		mTextureList.remove(TextureITR);
		TextureITR.forth();
	}
}
예제 #12
0
bool MTexture::blitTexture ( const std::string &Name, const SGZ::VECTOR3 &vector, const SGZ::SCALER u, const SGZ::SCALER v, const SGZ::SCALER w, const SGZ::SCALER h )
{
	SListIterator<TextureObj*> TextureITR = mTextureList.getIterator();
	for( TextureITR.start(); TextureITR.valid(); TextureITR.forth() )
		if(TextureITR.item()->mName.compare(Name)==0)
		{
			TextureITR.item()->mData->blitTexture(vector,u,v,w,h);
			return true;
		}
	SGZ::Logger.log( SGZLOG::Warning, "Texture " + Name + " does not exist!\n");
	return false;
}
예제 #13
0
bool MTexture::delTexture( const std::string &Name )
{
	SListIterator<TextureObj*> TextureITR = mTextureList.getIterator();
	for( TextureITR.start(); TextureITR.valid(); TextureITR.forth() )
		if(TextureITR.item()->mName.compare(Name)==0)
		{
			mTextureList.remove(TextureITR);
			return true;
		}

	SGZ::Logger.log( SGZLOG::Warning, "Texture " + Name + " does not exist!\n");
	return false;
}
예제 #14
0
bool MTexture::addTexMask( const std::string &Name, const std::string &Maskname )
{
	SListIterator<TextureObj*> TextureITR = mTextureList.getIterator();
	for( TextureITR.start(); TextureITR.valid(); TextureITR.forth() )
		if(TextureITR.item()->mName.compare(Name)==0)
		{
			TextureITR.item()->mData->loadTextureMask(Maskname);
			return true;
		}

	SGZ::Logger.log( SGZLOG::Warning, "Texture " + Name + " does not exist!\n");
	return false;
}
예제 #15
0
bool SDLEntity2D::DeleteVar( std::string Name )
{
	SListIterator<SGZVarGroup*> VarITR = VarList.getIterator();

	for( VarITR.start(); VarITR.valid(); VarITR.forth() )
		if((VarITR.item()->Name.compare(Name))==0)
		{
			VarList.remove(VarITR);
			return true;
		}

	SGZ::Logger.log( SGZLOG::Warning, "Variable \"" + Name + "\" does not exist!\n");
	return false;
}
예제 #16
0
파일: UMLGraph.cpp 프로젝트: marvin2k/ogdf
void UMLGraph::undoStars()
{
	SListIterator<node> it = m_centerNodes.begin();
	while (it.valid())
	{
		undoStar(*it, false);
		++it;
	}//while

	m_hiddenEdges->restore();
	m_centerNodes.clear();
	m_replacementEdge.init();

}//undostars
예제 #17
0
bool SDLEntity2D::ChangeVar ( std::string Name, std::string Value )
{
	/** Load up a Texture into an Animation*/
	SListIterator<SGZVarGroup*> VarITR = VarList.getIterator();

	for( VarITR.start(); VarITR.valid(); VarITR.forth() )
		if((VarITR.item()->Name.compare(Name))==0)
		{
			VarITR.item()->Variable = Value;
			return true;
		}

	SGZ::Logger.log( SGZLOG::Warning, "Variable \"" + Name + "\" does not exist!\n");
	return false;
}
예제 #18
0
	void VarEdgeInserterDynCore::insert(edge eOrig, SList<adjEntry>& eip)
	{
		eip.clear();
		node s = m_pr.copy(eOrig->source());
		node t = m_pr.copy(eOrig->target());

		// find path from s to t in BC-tree
		// call of blockInsert() is done when we have found the path
		// if no path is found, s and t are in different connected components
		// and thus an empty edge insertion path is correct!
		DynamicSPQRForest& dSPQRF = m_pBC->dynamicSPQRForest();
		SList<node>& path = dSPQRF.findPath(s, t);
		if (!path.empty()) {
			SListIterator<node> it = path.begin();
			node repS = dSPQRF.repVertex(s, *it);
			for (SListIterator<node> jt = it; it.valid(); ++it) {
				node repT = (++jt).valid() ? dSPQRF.cutVertex(*jt, *it) : dSPQRF.repVertex(t, *it);

				// less than 3 nodes requires no crossings (cannot build SPQR-tree
				// for a graph with less than 3 nodes!)
				if (dSPQRF.numberOfNodes(*it) > 3) {
					List<adjEntry> L;
					blockInsert(repS, repT, L); // call biconnected case

					// transform crossed edges to edges in G
					for (adjEntry kt : L) {
						edge e = kt->theEdge();
						eip.pushBack(e->adjSource() == kt ? dSPQRF.original(e)->adjSource()
							: dSPQRF.original(e)->adjTarget());
					}
				}
				if (jt.valid()) repS = dSPQRF.cutVertex(*it, *jt);
			}
		}
		delete &path;
	}
// Function ReplaceFullRoot either replaces the full root 
// or one full child of a partial root of a pertinent subtree
// by a single P-node  with leaves corresponding the keys stored in leafKeys.
void PlanarSubgraphPQTree::
ReplaceFullRoot(SListPure<PlanarLeafKey<whaInfo*>*> &leafKeys)
{

	PQLeaf<edge,whaInfo*,bool>          *leafPtr     = 0; // dummy
	PQInternalNode<edge,whaInfo*,bool>	*nodePtr     = 0; // dummy
	//PQNodeKey<edge,whaInfo*,bool>	    *nodeInfoPtr = 0; // dummy
	PQNode<edge,whaInfo*,bool>		    *currentNode = 0; // dummy
	SListIterator<PlanarLeafKey<whaInfo*>* >  it;

	if (!leafKeys.empty() && leafKeys.front() == leafKeys.back())
	{
		//ReplaceFullRoot: replace pertinent root by a single leaf
		leafPtr = OGDF_NEW PQLeaf<edge,whaInfo*,bool>(m_identificationNumber++,
                    EMPTY,(PQLeafKey<edge,whaInfo*,bool>*)leafKeys.front());
		exchangeNodes(m_pertinentRoot,(PQNode<edge,whaInfo*,bool>*) leafPtr);
		if (m_pertinentRoot == m_root)
			m_root = (PQNode<edge,whaInfo*,bool>*) leafPtr;      
	}
	else if (!leafKeys.empty()) // at least two leaves
	{
		//replace pertinent root by a $P$-node
		if ((m_pertinentRoot->type() == P_NODE) || 
			(m_pertinentRoot->type() == Q_NODE))
		{
			nodePtr = (PQInternalNode<edge,whaInfo*,bool>*)m_pertinentRoot;
			nodePtr->type(P_NODE);
			nodePtr->status(PERTROOT);
			nodePtr->childCount(0);
			while (!fullChildren(m_pertinentRoot)->empty())
			{	
				currentNode = fullChildren(m_pertinentRoot)->popFrontRet();
				removeChildFromSiblings(currentNode);
			}
		}      
		else if (m_pertinentRoot->type() == LEAF)
		{
			nodePtr = OGDF_NEW PQInternalNode<edge,whaInfo*,bool>(m_identificationNumber++,
														 P_NODE,EMPTY);
			exchangeNodes(m_pertinentRoot,nodePtr);
		}
		SListPure<PQLeafKey<edge,whaInfo*,bool>*> castLeafKeys;
		for (it = leafKeys.begin(); it.valid(); ++it)
			castLeafKeys.pushBack((PQLeafKey<edge,whaInfo*,bool>*) *it);
		addNewLeavesToTree(nodePtr,castLeafKeys);
	}
  
}
예제 #20
0
// Function ReplaceFullRoot either replaces the full root 
// or one full child of a partial root of a pertinent subtree
// by a single P-node  with leaves corresponding the keys stored in leafKeys.
void PlanarPQTree::ReplaceFullRoot(SListPure<PlanarLeafKey<indInfo*>*> &leafKeys)
{
	if (!leafKeys.empty() && leafKeys.front() == leafKeys.back())
	{
		//ReplaceFullRoot: replace pertinent root by a single leaf
		PQLeaf<edge,indInfo*,bool> *leafPtr =
			OGDF_NEW PQLeaf<edge,indInfo*,bool>(m_identificationNumber++,
            EMPTY,(PQLeafKey<edge,indInfo*,bool>*)leafKeys.front());

		exchangeNodes(m_pertinentRoot,(PQNode<edge,indInfo*,bool>*) leafPtr);
		if (m_pertinentRoot == m_root)
			m_root = (PQNode<edge,indInfo*,bool>*) leafPtr;      
		m_pertinentRoot = 0;  // check for this emptyAllPertinentNodes
	}

	else if (!leafKeys.empty()) // at least two leaves
	{
		PQInternalNode<edge,indInfo*,bool> *nodePtr = 0; // dummy
		//replace pertinent root by a $P$-node
		if ((m_pertinentRoot->type() == PQNodeRoot::PNode) || 
			(m_pertinentRoot->type() == PQNodeRoot::QNode))
		{
			nodePtr = (PQInternalNode<edge,indInfo*,bool>*)m_pertinentRoot;
			nodePtr->type(PQNodeRoot::PNode);
			nodePtr->childCount(0);
			while (!fullChildren(m_pertinentRoot)->empty())
				removeChildFromSiblings(fullChildren(m_pertinentRoot)->popFrontRet());
		}      
		else if (m_pertinentRoot->type() == PQNodeRoot::leaf)
		{
			nodePtr = OGDF_NEW PQInternalNode<edge,indInfo*,bool>(m_identificationNumber++,
														 PQNodeRoot::PNode,EMPTY);
			exchangeNodes(m_pertinentRoot,nodePtr);
			m_pertinentRoot = 0;  // check for this emptyAllPertinentNodes
		}
		
		SListPure<PQLeafKey<edge,indInfo*,bool>*> castLeafKeys;
		SListIterator<PlanarLeafKey<indInfo*>* >  it;
		for (it = leafKeys.begin(); it.valid(); ++it)
			castLeafKeys.pushBack((PQLeafKey<edge,indInfo*,bool>*) *it);
		addNewLeavesToTree(nodePtr,castLeafKeys);
	}
}
예제 #21
0
bool MTexture::blitTexture ( const std::string &Name,  const float x1, const float y1, const float u1, const float v1,
												const float x2, const float y2, const float u2, const float v2,
												const float x3, const float y3, const float u3, const float v3,
												const float x4, const float y4, const float u4, const float v4,
																								const int layer )
{
	SListIterator<TextureObj*> TextureITR = mTextureList.getIterator();
	for( TextureITR.start(); TextureITR.valid(); TextureITR.forth() )
		if(TextureITR.item()->mName.compare(Name)==0)
		{
			TextureITR.item()->mData->blitTexture(   x1, y1, u1, v1,
													 x2, y2, u2, v2,
													 x3, y3, u3, v3,
													 x4, y4, u4, v4,
													 layer);
			return true;
		}
	SGZ::Logger.log( SGZLOG::Warning, "Texture " + Name + " does not exist!\n");
	return false;
}
예제 #22
0
bool SDLEntity2D::DeleteAnimation( std::string Name )
{
	SListIterator<SGZAnimGroup2D*> AnimListITR = AnimList.getIterator();

	for( AnimListITR.start(); AnimListITR.valid(); AnimListITR.forth() )
		if((AnimListITR.item()->AnimName.compare(Name))==0)
		{
			AnimListITR.item()->FrameITR.start();
			while (AnimListITR.item()->FrameITR.valid())
			{
				AnimListITR.item()->FrameList.remove(AnimListITR.item()->FrameITR);
				AnimListITR.item()->FrameITR.forth();
			}

			AnimList.remove(AnimListITR);
			return true;
		}

	SGZ::Logger.log( SGZLOG::Warning, "Animation \"" + Name + "\" does not exist!\n");
	return false;
}
void PlanarSubgraphPQTree::
removeEliminatedLeaves(SList<PQLeafKey<edge,whaInfo*,bool>*> &eliminatedKeys)
{
	PQNode<edge,whaInfo*,bool>*  nodePtr = 0;
	PQNode<edge,whaInfo*,bool>*  parent  = 0;
	PQNode<edge,whaInfo*,bool>*  sibling = 0;

	SListIterator<PQLeafKey<edge,whaInfo*,bool>*> it;
	for (it = eliminatedKeys.begin(); it.valid(); it++)
	{
		nodePtr = (*it)->nodePointer();
		parent = nodePtr->parent();
		sibling = nodePtr->getNextSib(NULL);

		removeNodeFromTree(parent,nodePtr);
		checkIfOnlyChild(sibling,parent);
		if (parent->status() == TO_BE_DELETED)
		{
			parent->status(WHA_DELETE);
		}
		nodePtr->status(WHA_DELETE);
	}
}
예제 #24
0
void EmbedPQTree::ReplaceFullRoot(
	SListPure<PlanarLeafKey<indInfo*>*> &leafKeys,
	SListPure<PQBasicKey<edge,indInfo*,bool>*> &frontier,
	node v,
	bool addIndicator,
	PQNode<edge,indInfo*,bool> *opposite)
{
	EmbedIndicator *newInd = 0; 

	front(m_pertinentRoot,frontier);
	if (addIndicator)
	{
		indInfo *newInfo = OGDF_NEW indInfo(v);
		embedKey *nodeInfoPtr = OGDF_NEW embedKey(newInfo);
		newInd = OGDF_NEW EmbedIndicator(m_identificationNumber++,
			(PQNodeKey<edge,indInfo*,bool>*)nodeInfoPtr);
		newInd->setNodeInfo(nodeInfoPtr);
		nodeInfoPtr->setNodePointer(newInd);
	}

	if (!leafKeys.empty() && leafKeys.front() == leafKeys.back())
	{
		//ReplaceFullRoot: replace pertinent root by a single leaf
		if (addIndicator)
		{
			opposite = m_pertinentRoot->getNextSib(opposite);
			if (!opposite) // m_pertinentRoot is endmost child
			{
				addNodeToNewParent(m_pertinentRoot->parent(),newInd,
								   m_pertinentRoot,opposite);
			}
			else 
				addNodeToNewParent(0,newInd,m_pertinentRoot,opposite);

			// Setting the sibling pointers into opposite direction of
			// scanning the front allows to track swaps of the indicator
			newInd->changeSiblings(m_pertinentRoot,0);
			newInd->changeSiblings(opposite,0);
			newInd->putSibling(m_pertinentRoot,LEFT);
			newInd->putSibling(opposite,RIGHT);
		}
		PQLeaf<edge,indInfo*,bool> *leafPtr =
			OGDF_NEW PQLeaf<edge,indInfo*,bool>(m_identificationNumber++,
			EMPTY,(PQLeafKey<edge,indInfo*,bool>*)leafKeys.front());
		exchangeNodes(m_pertinentRoot,(PQNode<edge,indInfo*,bool>*) leafPtr);
 		if (m_pertinentRoot == m_root)
			m_root = (PQNode<edge,indInfo*,bool>*) leafPtr;      
		m_pertinentRoot = 0;  // check for this emptyAllPertinentNodes
	}

	else if (!leafKeys.empty()) // at least two leaves
	{
		//replace pertinent root by a $P$-node
		if (addIndicator)
		{
			opposite = m_pertinentRoot->getNextSib(opposite);
			if (!opposite) // m_pertinentRoot is endmost child
			{
				addNodeToNewParent(m_pertinentRoot->parent(),newInd,
								   m_pertinentRoot,opposite);
			}
			else 
				addNodeToNewParent(0,newInd,m_pertinentRoot,opposite);

			// Setting the sibling pointers into opposite direction of
			// scanning the front allows to track swaps of the indicator
			newInd->changeSiblings(m_pertinentRoot,0);
			newInd->changeSiblings(opposite,0);
			newInd->putSibling(m_pertinentRoot,LEFT);
			newInd->putSibling(opposite,RIGHT);
		}

		PQInternalNode<edge,indInfo*,bool> *nodePtr = 0; // dummy
		if ((m_pertinentRoot->type() == PQNodeRoot::PNode) || 
			(m_pertinentRoot->type() == PQNodeRoot::QNode))
		{
			nodePtr = (PQInternalNode<edge,indInfo*,bool>*)m_pertinentRoot;
			nodePtr->type(PQNodeRoot::PNode);
			nodePtr->childCount(0);
			while (!fullChildren(m_pertinentRoot)->empty())
			{	
				PQNode<edge,indInfo*,bool> *currentNode =
					fullChildren(m_pertinentRoot)->popFrontRet();
				removeChildFromSiblings(currentNode);
			}
		}      
		else if (m_pertinentRoot->type() == PQNodeRoot::leaf)
		{
			nodePtr = OGDF_NEW PQInternalNode<edge,indInfo*,bool>(m_identificationNumber++,
														 PQNodeRoot::PNode,EMPTY);
			exchangeNodes(m_pertinentRoot,nodePtr);
			m_pertinentRoot = 0;  // check for this emptyAllPertinentNodes
		}
	
		SListPure<PQLeafKey<edge,indInfo*,bool>*> castLeafKeys;
		SListIterator<PlanarLeafKey<indInfo*>* > it;
		for (it = leafKeys.begin(); it.valid(); ++it)
			castLeafKeys.pushBack((PQLeafKey<edge,indInfo*,bool>*) *it);
		addNewLeavesToTree(nodePtr,castLeafKeys);
	}  
}
예제 #25
0
void randomHierarchy(Graph &G,
	int numberOfNodes,int numberOfEdges,
	bool planar,bool singleSource,bool longEdges)
{
	G.clear();

	node *nnr = new node[3*numberOfNodes];
	int  *vrt = new int[3*numberOfNodes];
	int  *fst = new int[numberOfNodes+1];
	List<bEdge> startEdges;
	bEdge actEdge, nextEdge, toDelete;
	node v;
	int act, next, n1, n2, idc=0;
	double x1, x2, r;
	bool connected;

	/** Place nodes **/

	for(int i = 0; i < numberOfNodes; i++)
		G.newNode();

	int numberOfLayers=0, totNumber=0, realCount=0;
	fst[0] = 0;
	forall_nodes(v,G) {
		if(longEdges&&numberOfLayers) vrt[totNumber++] = 1;

		nnr[totNumber] = v;
		vrt[totNumber++] = 0;
		realCount++;
		r = double(randomNumber(0,1000)) / 1000.0;
		if((totNumber == 1 && singleSource) || realCount == numberOfNodes || r*r*numberOfNodes < 1)
		{
			if(longEdges && numberOfLayers)
				vrt[totNumber++] = 1;
			fst[++numberOfLayers] = totNumber;
		}
	}

	/** Determine allowed neighbours **/

	int *leftN  = new int[totNumber];
	int *rightN = new int[totNumber];
	for(int l = 1; l < numberOfLayers; l++)
	{
		if(planar) {
			n1 = fst[l-1];
			n2 = fst[l];
			leftN[n2] = n1;
			while(n1 < fst[l] && n2 < fst[l+1]) {
				r = double(randomNumber(0,1000)) / 1000.0;
				if(n1 != fst[l]-1 &&
					(n2 == fst[l+1]-1 ||
					r < (double)(fst[l]-fst[l-1])/(double)(fst[l+1]-fst[l-1])))
					n1++;
				else {
					rightN[n2] = n1;
					if(++n2 < fst[l+1])
						leftN[n2] = n1;
				}
			}
		}
		else
			for(n2 = fst[l]; n2 < fst[l+1]; n2++) {
				leftN [n2] = fst[l-1];
				rightN[n2] = fst[l]-1;
			}
	}

	/** Insert edges **/

	SList<bEdge> *edgeIn  = new SList<bEdge>[totNumber];
	SList<bEdge> *edgeOut = new SList<bEdge>[totNumber];
	if(numberOfLayers) {
		x1 = numberOfEdges;
		x2 = 0;
		for(n2 = fst[1]; n2 < totNumber; n2++)
			if(!vrt[n2])
				x2 += rightN[n2] - leftN[n2]+1;

		for(n2 = fst[1]; n2 < totNumber; n2++)
			if(!vrt[n2]) {
				connected = !singleSource;
				for(n1 = leftN[n2]; n1 <= rightN[n2] || !connected; n1++) {
					r = double(randomNumber(0,1000)) / 1000.0;
					if(r < x1/x2 || n1 > rightN[n2]) {
						next = (n1 <= rightN[n2] ? n1 : randomNumber(leftN[n2],rightN[n2]));
						act = n2;
						nextEdge = OGDF_NEW BEdge(next,act,idc++);
						while(vrt[next]) {
							act = next;
							next = randomNumber(leftN[act],rightN[act]);
							edgeOut[act].pushBack(nextEdge);
							nextEdge = OGDF_NEW BEdge(next,act,idc++);
							edgeIn[act].pushBack(nextEdge);
						}
						startEdges.pushBack(nextEdge);
						connected = 1;
						x1 -= 1;
					}
					if(n1<=rightN[n2])
						x2-=1;
				}
			}
		}

	delete[] leftN;
	delete[] rightN;

	if(planar)
		for(act = 0; act < totNumber; act++) {
			CmpTail cmpTail;
			edgeIn[act].quicksort(cmpTail);
			CmpHead cmpHead;
			edgeOut[act].quicksort(cmpHead);
		}

	for(act = 0; act < totNumber; act++) {
		SListIterator<bEdge> it;
		for(it = edgeIn[act].begin(); it.valid(); ++it) {
			nextEdge = *it;
			nextEdge->next = edgeOut[act].popFrontRet();
		}
	}

	delete[] edgeOut;

	ListIterator<bEdge> it;
	for(it = startEdges.begin(); it.valid(); ++it) {
		actEdge = *it;
		nextEdge = actEdge;
		while(vrt[nextEdge->head])
			nextEdge = nextEdge->next;
		G.newEdge(nnr[actEdge->tail], nnr[nextEdge->head]);
	}

	/** Clean up **/
	for(it = startEdges.begin(); it.valid(); ++it) {
		nextEdge = *it;
		toDelete = nextEdge;
		while(vrt[nextEdge->head]) {
			nextEdge = nextEdge->next;
			delete toDelete;
			toDelete = nextEdge;
		}
		delete toDelete;
	}

	delete[] edgeIn;
	delete[] fst;
	delete[] vrt;
	delete[] nnr;
}
예제 #26
0
// separate pertinent nodes in the lists of possible different minor-types
void FindKuratowskis::splitInMinorTypes(
			const SListPure<adjEntry>& externalFacePath,
			int marker)
{
	// mark nodes, which are before stopX or behind stopY in CCW-traversal and add
	// all extern nodes strictly between stopX and stopY to list
	// externE for minor E (pertinent nodes are considered because of the
	// position of z left or right of w)
	SListConstIterator<adjEntry> itExtern;
	SListIterator<WInfo> it = k.wNodes.begin();
	node x;
	bool between = false;
	SListPure<WInfo*> infoList;
	SListIterator<WInfo*> itList;
	ExternE externEdummy;
	// compute list of externE nodes
	for (itExtern=externalFacePath.begin(); itExtern.valid(); ++itExtern) {
		x = (*itExtern)->theNode();
		if (x==k.stopX || x==k.stopY) {
			between = (between==false) ? true : false;
		} else {
			if (!between) {
				m_wasHere[x]=marker;
			} else {
				if (pBM->externallyActive(x,k.V_DFI)) {
					externEdummy.theNode = x;

					// check minor type B and save extern linkage
					if (it.valid() && (*it).w==x &&
							!m_pertinentRoots[x].empty() &&
							m_lowPoint[m_nodeFromDFI[-m_dfi[m_pertinentRoots[x].back()]]]
							< k.V_DFI) {
						WInfo& info(*it);

						// checking minor type B
						info.minorType |= WInfo::B;
						// mark extern node for later extraction
						externEdummy.startnodes.pushBack(0);
						// create externE-list
						k.externE.pushBack(externEdummy);
						// save extern linkage
						info.externEStart = k.externE.rbegin();
						info.externEEnd = k.externE.rbegin();
					} else {
						// create externE-list
						externEdummy.startnodes.clear();
						k.externE.pushBack(externEdummy);
					}

					// save for each wNode the first externally active successor
					// on the external face
					for (itList = infoList.begin(); itList.valid(); ++itList)
						(*itList)->firstExternEAfterW = x;
					infoList.clear();


				}

				// get appropriate WInfo
				if (it.valid() && (*it).w==x) {
					infoList.pushBack(&(*it));
					++it;
				}
			}
		}
	}

	// divide wNodes in different minor types
	// avoids multiple computation of the externE range
	itExtern = externalFacePath.begin();
	SListIterator<ExternE> itExternE = k.externE.begin();
	WInfo* oldInfo = NULL;
	for (it=k.wNodes.begin(); it.valid(); ++it) {
		WInfo& info(*it);

		// checking minor type A
		if (k.RReal!=k.V) info.minorType |= WInfo::A;

		// if a XYPath exists
		if (info.highestXYPath!=NULL) {
			if (m_wasHere[info.highestXYPath->front()->theNode()]==marker)
				info.pxAboveStopX = true;
			if (m_wasHere[info.highestXYPath->back()->theNode()]==marker)
				info.pyAboveStopY = true;

			// checking minor type C
			if (info.pxAboveStopX || info.pyAboveStopY)
				info.minorType |= WInfo::C;

			// checking minor type D
			if (info.zPath!=NULL) info.minorType |= WInfo::D;

			// checking minor type E
			if (!k.externE.empty()) {
				node t;

				// compute valid range of externE-nodes in linear time
				if (oldInfo!=NULL && info.highestXYPath==oldInfo->highestXYPath) {
					// found the same highestXYPath as before
					info.externEStart = oldInfo->externEStart;
					info.externEEnd = oldInfo->externEEnd;
					if (oldInfo->minorType & WInfo::E) info.minorType |= WInfo::E;
				} else {
					// compute range of a new highestXYPath
					node px;
					if (info.pxAboveStopX) px = k.stopX;
						else px = info.highestXYPath->front()->theNode();
					node py;
					if (info.pyAboveStopY) py = k.stopY;
						else py = info.highestXYPath->back()->theNode();
					while ((*itExtern)->theNode() != px) ++itExtern;
					t = (*(++itExtern))->theNode();
					node start = NULL;
					node end = NULL;
					while (t != py) {
						if (pBM->externallyActive(t,k.V_DFI)) {
							if (start==NULL) start = t;
							end = t;
						}
						t = (*(++itExtern))->theNode();
					}
					if (start != NULL) {
						while ((*itExternE).theNode != start) ++itExternE;
						info.externEStart = itExternE;
						// mark node to extract external subgraph later
						(*itExternE).startnodes.pushBack(0);
						node temp = start;
						while (temp != end) {
							temp = (*++itExternE).theNode;
							// mark node to extract external subgraph later
							(*itExternE).startnodes.pushBack(0);
						}
						info.externEEnd = itExternE;
						info.minorType |= WInfo::E;
					}
					oldInfo = &info;
				}
			}
		}

		/*
		// use this to find special kuratowski-structures
		if ((info.minorType & (WInfo::A|WInfo::B|WInfo::C|WInfo::D|WInfo::E)) ==
			(WInfo::A|WInfo::B|WInfo::C|WInfo::D|WInfo::E)) {
			char t; cin >> t;
		}
		*/
	}

	// extract the externalSubgraph of all saved externally active nodes
	// exclude the already extracted minor b-types
	#ifdef OGDF_DEBUG
	int visited = m_nodeMarker+1;
	#endif
	for (itExternE=k.externE.begin(); itExternE.valid(); ++itExternE) {
		if ((*itExternE).startnodes.empty()) continue;

		ExternE& externE(*itExternE);
		externE.startnodes.clear();
		if (m_bundles) {
			OGDF_ASSERT(m_wasHere[externE.theNode] < visited);
			extractExternalSubgraphBundles(externE.theNode,k.V_DFI,
										k.externalSubgraph,++m_nodeMarker);
		} else {
			extractExternalSubgraph(externE.theNode,k.V_DFI,externE.startnodes,
															externE.endnodes);
			SListIterator<int> itInt;
			SListPure<edge> dummy;
			for (itInt = externE.startnodes.begin(); itInt.valid(); ++itInt)
				externE.externalPaths.pushBack(dummy);
		}
	}
}
예제 #27
0
bool SDLEntity2D::Update ( float deltaTime )
{
	mDeltaTime = deltaTime;
	position.x += velocity.x * deltaTime;
	position.y += velocity.y * deltaTime;
	position.z += velocity.z * deltaTime;

	/// Update our beloved entity
	SListIterator<SGZAnimGroup2D*> AnimListITR = AnimList.getIterator();

	offset.x = (Uint16)position.x;
	offset.y = (Uint16)position.y;
	offset.w = (Uint16)entityWidth;
	offset.h = (Uint16)entityHeight;

	//CurrentFrame = SDL_GetVideoSurface();
	
	for( AnimListITR.start(); AnimListITR.valid(); AnimListITR.forth() )
		if((AnimListITR.item()->AnimName.compare(CurrentAnim))==0)
		{
			if(AnimListITR.item()->AnimTimer.currenttime() >= AnimListITR.item()->FrameITR.item()->delay)
			{
				AnimListITR.item()->FrameITR.forth();
				AnimListITR.item()->CurAnim++;
				AnimListITR.item()->AnimTimer.reset();
			}

			if (AnimListITR.item()->FrameList.size() == AnimListITR.item()->CurAnim)
			{
				AnimListITR.item()->CurAnim = 0;
				AnimListITR.item()->FrameITR.start();
			}
			
			if(AnimListITR.item()->FrameITR.valid())
			{
				frame.x = (Uint16)AnimListITR.item()->FrameITR.item()->u;
				frame.y = (Uint16)AnimListITR.item()->FrameITR.item()->v;
				frame.w = (Uint16)entityWidth;
				frame.h = (Uint16)entityHeight;

				CurrentFrame = static_cast<SDL_Surface*>(manTextures->getTexture(AnimListITR.item()->FrameITR.item()->TextureName));
				SDL_SetColorKey(CurrentFrame, SDL_SRCCOLORKEY, SDL_MapRGB(	CurrentFrame->format,
																			(Uint32)AnimListITR.item()->FrameITR.item()->colkey.r,
																			(Uint32)AnimListITR.item()->FrameITR.item()->colkey.g,
																			(Uint32)AnimListITR.item()->FrameITR.item()->colkey.b));

				offset.w = (Uint16)entityWidth;
				offset.h = (Uint16)entityHeight;
				offset.x = (Sint16)position.x;
				offset.y = (Sint16)position.y;
				
				Uint32 old32Colour = SDL_MapRGB(	CurrentFrame->format,
													oldColour.r,
													oldColour.g,
													oldColour.b);
				
				Uint32 new32Colour = SDL_MapRGB(	CurrentFrame->format,
													newColour.r,
													newColour.g,
													newColour.b);
													
				//SDL_LockSurface(CurrentFrame);
				
				SDL_BlitSurface(CurrentFrame, &frame, SDL_GetVideoSurface(), &offset );
													
				if (SDL_GetVideoSurface()->format->BitsPerPixel == 16) {
					Uint16 *pixels = (Uint16 *)SDL_GetVideoSurface()->pixels;
					for (int index_y = offset.y; index_y < offset.y + offset.h; ++index_y){
						for (int index_x = offset.x; index_x < offset.x + offset.w; ++index_x){
							Uint16 colour = pixels[ ( index_y * SDL_GetVideoSurface()->w ) + index_x ];
 
							if ( colour == old32Colour )
								pixels[ ( index_y * SDL_GetVideoSurface()->w ) + index_x ] = new32Colour;
							else
								pixels[ ( index_y * SDL_GetVideoSurface()->w ) + index_x ] = colour;
						}
					}
				}
				else {
					Uint32 *pixels = (Uint32 *)CurrentFrame->pixels;
					for (int index_y = 0; index_y < CurrentFrame->h; ++index_y){
						for (int index_x = 0; index_x < CurrentFrame->w; ++index_x){
							Uint32 colour = pixels[ ( index_y * CurrentFrame->w ) + index_x ];
 
							if ( colour == old32Colour )
								pixels[ ( index_y * CurrentFrame->w ) + index_x ] = new32Colour;
							else
								pixels[ ( index_y * CurrentFrame->w ) + index_x ] = colour;
						}
					}
				}
				
				//SDL_UnlockSurface(CurrentFrame);
			}
			
			return true;
		}

	return true;
}