Exemplo n.º 1
0
void Scene::print()	{

	string strFileName = getLogFile();
	ofstream output(strFileName, ios::app);
	output << "========================================================Begin Scene" << endl;

	int nI;

	output << "SCENE at iteration " << m_nIteration << endl;

	output << "Scene objects by name: " << endl;
	NodeList::iterator it;
	for (it = _children.begin(); it != _children.end(); it++)	{
		output << "Parent: " << it->get()->getParent(0)->getName()
			<< "; Class Name:" << it->get()->className() << "; Object Name: " <<it->get()->getName() << endl;
	}

	
	for (it = _children.begin(); it != _children.end(); it++)	{
		nI = it - _children.begin();
		ref_ptr<VR::AbstractObject> pObject = dynamic_cast<VR::AbstractObject*>(this->getChild(nI));
		if (!pObject.valid())
			continue;
		else
			pObject->print(output);
	}
	output << "========================================================End Scene" << endl;

	output.close();
	m_nIteration++;
	
}
Exemplo n.º 2
0
Node * Scene::getChild(const string & astrChildName)	{
	if (astrChildName.empty())	{
		return 0;
	}

	NodeList::iterator it = _children.begin();
	for (it; it != _children.end(); it++)	{
		const string strChild = it->get()->getName();
		if (strChild == astrChildName)	{
			Node * pChild = dynamic_cast<Node*>(it->get());

			return pChild;
		}
	}
	return 0;
}
Exemplo n.º 3
0
void AbstractObject::preparedObjectData(std::vector<std::string> &avecItems, std::string & astrParent)	{
	ref_ptr<AbstractObject> pAbstractObject = dynamic_cast<AbstractObject*>(this);

	vector<string> * pvecItems = &avecItems;

	int nI=1;

	string strClassName = pAbstractObject->className();
	const string * pstrObjectName = &pAbstractObject->getName();
	string strItem = (string(2*nI,' ') + strClassName + ";" + *pstrObjectName + ";" + pAbstractObject->prepareRowData(astrParent));
	pvecItems->push_back(strItem);

	nI += 1;	//enlarge indent by 1 unit

	NodeList::iterator it;
	for (it = pAbstractObject->_children.begin(); it != pAbstractObject->_children.end(); it++)	{
		ref_ptr<AbstractObject> pChild = dynamic_cast<AbstractObject*>(it->get());

		if(pChild == NULL)	{
			break;
		}

		strClassName = pChild->className();
		pstrObjectName = &pChild->getName();
		strItem = (strClassName + ";" + *pstrObjectName + ";" + pChild->prepareRowData(pAbstractObject->getName()));

		pvecItems->push_back(string(2*nI,' ') + strItem);
	}
}
Exemplo n.º 4
0
void AbstractObject::writeObjectHierarchy(vector<string> &avecstrHierarchy)	{
	//Object name
	avecstrHierarchy.push_back(getName());
	
	ref_ptr<AbstractObject> pAO = dynamic_cast<AbstractObject*>(this);

	NodeList::iterator it = pAO->_children.begin();
	for (it; it != pAO->_children.end(); it++)	{
		string strName = it->get()->getName();
		if (strName.empty())	{
			break;
		} else {
			strName = string(2,' ') + strName;
			avecstrHierarchy.push_back(strName);
		}
	}
}