Hi,
I have written a class with two methods to save nodes in a map and to
print this map. The nodes in this case are joints of a loaded model.
Once executed the map remains empty.
I think it is because somewhere I need to declare a pointer to the root
node that the saving function receives a filled node-tree. But I don't
know where and how exactly.
hope that anyone has a hint for me,
Sadi
This is the class definition and the methods of it:
#include <map>
#include <string>
#include <OpenSG/OSGNodePtr.h>
// defining a map with string key and a NodePtr
typedef std::map<std::string, OSG::NodePtr> jointlist;
typedef std::map<std::string, OSG::NodePtr>::iterator it;
class GenerateJointList {
private:
// member variables
jointlist mJointList, mResultList;
it mIter;
public:
// generates list
void generateJointList(OSG::NodePtr scene);
// prints list
void printList();
};
void GenerateJointList::generateJointList(NodePtr scene) {
UInt32 children = scene->getNChildren();
// Returns an iterator referring to the first element
// in the map container
mIter = mJointList.begin();
// check if it is one of the joints we are looking for
// all joint node names begin with "Gelenk"
if(getName(scene) == "Gelenk") {
// Insert joint to list!
mJointList.insert(mIter, pair<string,
NodePtr>(string(getName(scene)), scene));
}
// check all children
for (int i = 0; i < children; i++) {
generateJointList(scene->getChild(i));
}
}
void GenerateJointList::printList() {
cout << endl << endl;
cout << "Printing all joint-node names";
cout << "-------------------------------------------";
cout << endl << endl;
// prints list on command line
for (mIter = mJointList.begin(); mIter != mJointList.end();
mIter++) {
cout << (*mIter).first << " => " << (*mIter).second <<
endl;
}
}
--
Sadi Tanis
University of Koblenz/Landau
Student of Computer Vision
Simmerner Straße 134
56075 Koblenz Germany
Tel. +49.261.208.98.73
E-mail [EMAIL PROTECTED]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users