Hello Sadi,
Sadi Tanis wrote:
> 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.
>
> 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") {
^^^^^^^^^
I think this is where the problem is: the prototype of getName is
const Char8 *getName(AttachmentContainerPtrConstArg container);
It returns a C string, i.e. a pointer to a character array, which you
can not compare with ==. You either need to use the strcmp function or
create a temporary std::string like this:
if(std::string(getName(scene)) == "Gelenk")
Hope it helps,
Carsten
-------------------------------------------------------------------------
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