コード例 #1
0
ファイル: PMLReader.cpp プロジェクト: conanhung/sofa_rc1
//update all the physical model atoms positions
void PMLReader::updatePML()
{
	std::vector<PMLBody*>::iterator itb = bodiesList.begin();
	StructuralComponent * atoms = pm->getAtoms();
	Atom * atom;

	while (itb != bodiesList.end())
	{
		if( (*itb)->isTypeOf() != "interaction" )
		{
			if ((*itb)->isTypeOf() != "rigid" || ((PMLRigidBody*)*itb)->bodyFixed == false)
			{
				std::map<unsigned int, unsigned int>::iterator itm = (*itb)->AtomsToDOFsIndexes.begin();
				while(itm != (*itb)->AtomsToDOFsIndexes.end() )
				{
					atom = (Atom*) atoms->getStructureByIndex( (*itm).first );
					Vector3 pos = (*itb)->getDOF((*itm).second);
					atom->setPosition(pos[0], pos[1], pos[2]);

					itm++;
				}
			}
		}
		itb++;
	}
}
コード例 #2
0
ファイル: PMLReader.cpp プロジェクト: conanhung/sofa_rc1
//save the current scene as a pml filename
void PMLReader::saveAsPML(const char * filename)
{
	std::vector<PMLBody*>::iterator itb = bodiesList.begin();
	StructuralComponent * atoms = pm->getAtoms();
	Atom * atom;

	while (itb != bodiesList.end())
	{
		std::map<unsigned int, unsigned int>::iterator itm = (*itb)->AtomsToDOFsIndexes.begin();
		while(itm != (*itb)->AtomsToDOFsIndexes.end() )
		{
			atom = (Atom*) atoms->getStructureByIndex( (*itm).first );
			Vector3 pos = (*itb)->getDOF((*itm).second);
			atom->setPosition(pos[0], pos[1], pos[2]);

			itm++;
		}
		itb++;
	}
	std::ofstream outputFile(filename);
	pm->xmlPrint(outputFile);
	cout<<"fichier sauvegarde"<<endl;
}